[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: units.h
- To: Matthew Shepherd <mashephe@indiana.edu>
- Subject: Re: units.h
- From: Edward Brash <brash@jlab.org>
- Date: Wed, 3 Dec 2008 15:55:25 -0500
- Cc: GlueX Software <halld-offline@jlab.org>
- DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:cc:message-id:from:to :in-reply-to:content-type:content-transfer-encoding:mime-version :subject:date:references:x-mailer:sender; bh=KucjUZqsFFm7lqWvZ48tHSssLGr1QZ143YHTs/LUuDw=; b=n8eQ+qo+2sptJXujTgMEpqGrcBbB8SEOzWjjW8J7oleSgrtidf1P/SDPgTREOMY90n r085JUxGoSqghJalY+yVBKNMZT9KdEa32rBf1OGaHC6TboghOSnMZ2IngQwg1TGPoiNR SgvA4lg2+ISze+htQplxExPoknCFs/P4c2RLM=
- DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=cc:message-id:from:to:in-reply-to:content-type :content-transfer-encoding:mime-version:subject:date:references :x-mailer:sender; b=VUen8P6HpR3TU+ZN3VH0fCTijF/Rccl1VnaeBCKXLhIyCj5IXp6A7GGRmTNUtU7AZV mU1v/yEDSxfgCo5Xg/Z/TyOZKVFKNyuiFFiAPDZ8n/FSlOV89t9HIXWRF3mqfdQSKW/m zQQDg6nu7dp+h8LAQs3ZG7BKCwFF3v16Ch+nk=
- In-Reply-To: <D33A4837-B705-4150-AEB0-A9768AC59318@indiana.edu>
- References: <D33A4837-B705-4150-AEB0-A9768AC59318@indiana.edu>
- Reply-To: Edward Brash <brash@jlab.org>
- Sender: owner-halld-offline@jlab.org
Hi All,
I know that I am not involved in GlueX at this point in time, but I am
still on the mailing list, and do following these discussions with
interest ...
And, I don't want to throw a spanner in the works, as it were, but
have you all considered using the CLHEP package? I think that it
might solve not only your units problem, but also provide you with a
lot of other functionality as well ...
Cheers,
Ed.
On Dec 3, 2008, at 3:30 PM, Matthew Shepherd wrote:
>
> Here's the units.h file for CLEO. Note that the unit choices are
> somewhat different from what Mark is proposing. I'll let Mark
> multiply and divide by the requisite factors of 10 and put into the
> repository in an appropriate place.
>
> -Matt
>
>
> #if !defined(EXPERIMENT_UNITS_H)
> #define EXPERIMENT_UNITS_H
> // -*- C++ -*-
> //
> // Package: Cleo
> // Module: units.h
> //
> // Description: These are just a few definitions for specifying
> units and
> // keeping things consistent.
> //
> // Usage:
> // It's just like writing up homework! Specify your units, and
> it'll all
> // work just dandy. If a length is 3.5 cm, it becomes 3.5*k_cm.
> If it's
> // 1.2 in, it becomes 1.2*k_in.
> //
> // If, on the other hand, something passes a number back to you
> in, say,
> // grams per cubic centimeter, you would *divide* by k_g_per_cm3
> to get it
> // in the correct CLEO III units. Think of the CLEO III units as
> // dimensionless, and this makes sense.
> //
> // Simple, isn't it?
> //
> // One final note: "k_degrees" refers to angles, not
> temperature. Since
> // there are no multiplicative conversions between the common
> temperature
> // units, this shouldn't cause much confusion.
> //
> // Author: Michael Marsh
> // Created: Tue Jan 20 12:06:31 EST 1998
> // $Id: units.h,v 1.6 2001/12/18 20:48:20 lkg Exp $
> //
> // Revision history
> //
> // $Log: units.h,v $
> // Revision 1.6 2001/12/18 20:48:20 lkg
> // added time units
> //
> // Revision 1.5 1998/11/24 19:35:49 mkl
> // turned float into double for standard types and units
> //
> // Revision 1.4 1998/07/03 17:29:48 marsh
> // Changed units of energy to GeV. Added units for magnetic field
> (kG).
> // Added more units, such as keV and radians, and more constants to
> convert
> // from CLEO units to all units with constants.
> //
> // Revision 1.3 1998/05/14 19:58:05 marsh
> // Added millimeters, microns, and mils.
> //
> // Revision 1.2 1998/05/07 22:26:06 marsh
> // Renamed the constants to be more readable. This was in response
> to input
> // that people didn't like the old names, such as kM, which looked
> like it
> // might be kilometers, but was in fact meters.
> //
> // Revision 1.1 1998/04/09 19:48:50 marsh
> // New in repository.
> //
>
> // system include files
> #if defined(EXCEPTION_CLASH_WITH_MATH_H_BUG)
> #define exception _math_bug_
> #include <math.h> // required for trigonometry and fabs
> #undef exception
> #else
> #include <math.h> // required for trigonometry and fabs
> #endif
>
> // user include files
>
> const double k_in_to_cm = 2.54;
>
> const double k_m = 1.0;
> const double k_cm = 0.01; // lengths are in meters
> const double k_mm = 1.0E-3;
> const double k_um = 1.0E-6; // microns
> const double k_in = k_in_to_cm * k_cm;
> const double k_mil = k_in * 1.0E-3;
> const double k_to_m = 1/k_m;
> const double k_to_cm = 1/k_cm;
> const double k_to_mm = 1/k_mm;
> const double k_to_um = 1/k_um;
> const double k_to_in = 1/k_in;
> const double k_to_mil = 1/k_mil;
>
> const double k_kg = 1.0;
> const double k_g = 0.001;
> const double k_u = 1.6605402E-27;
> const double k_to_kg = 1/k_kg;
> const double k_to_g = 1/k_g;
> const double k_to_u = 1/k_u;
>
> const double k_kg_per_m3 = 1;
> const double k_g_per_cm3 = 1000; // density is in kg/m^3
> const double k_to_kg_per_m3 = 1/k_kg_per_m3;
> const double k_to_g_per_cm3 = 1/k_g_per_cm3;
>
> const double k_Pa = 1; // pressure is in pascals
> const double k_atm = 101325;
> const double k_to_Pa = 1/k_Pa;
> const double k_to_atm = 1/k_atm;
>
> const double k_GeV = 1; // energy is in GeV
> const double k_MeV = 1.0E-3;
> const double k_keV = 1.0E-6;
> const double k_eV = 1.0E-9;
> const double k_to_GeV = 1/k_GeV;
> const double k_to_MeV = 1/k_MeV;
> const double k_to_keV = 1/k_keV;
> const double k_to_eV = 1/k_eV;
> const double k_to_J = 1.60217733E-10;
> const double k_J = 1/k_to_J;
>
> const double k_kGauss = 1;
> const double k_Gauss = 1.0E-3;
> const double k_Tesla = 10;
> const double k_to_kGauss = 1/k_kGauss;
> const double k_to_Gauss = 1/k_Gauss;
> const double k_to_Tesla = 1/k_Tesla;
>
> const double k_radians = 1; // pretty much everything uses radians
> const double k_degrees = M_PI / 180;
> const double k_to_radians = 1/k_radians;
> const double k_to_degrees = 1/k_degrees;
>
> const double k_psec = 1; // Cleo has typically used picoseconds
> const double k_nsec = 1.0E3;
> const double k_usec = 1.0E6;
> const double k_msec = 1.0E9;
> const double k_sec = 1.0E12;
> const double k_to_psec = 1/k_psec;
> const double k_to_nsec = 1/k_nsec;
> const double k_to_usec = 1/k_usec;
> const double k_to_msec = 1/k_msec;
> const double k_to_sec = 1/k_sec;
>
> #endif /* EXPERIMENT_UNITS_H */
>
Dr. Edward J. Brash
Department of Physics, Computer Science, and Engineering
Christopher Newport University
Newport News, VA, USA 23606.
Telephone: (757) 753-2831 (cell)
Telephone: (757) 269-7216 (JLab Office)
Telephone: (757) 594-7451 (CNU Office)
Fax: (757) 594-7919
Email: brash@pcs.cnu.edu
- References:
- units.h
- From: Matthew Shepherd <mashephe@indiana.edu>