MasterGeVPerMip Class Reference
[DataUtil]

A class for managing sets of GeVPerMip values by release name (or arbitrary string). More...

#include <MasterGeVPerMip.h>

List of all members.

Classes

struct  Cleaner

Public Member Functions

virtual ~MasterGeVPerMip ()
double Get (Detector::Detector_t det) const
 Return the GeV-per-MIP for a particular detector from the current "set".
void Print (std::string option="") const
 Print the current value (or "all").
void SelectSet (std::string setname="default")
 Select a "set" either by string name or ReleaseType value.
void SelectSet (ReleaseType::Release_t rt)
void SetAssert (bool doAssert=true)
 Allow set selection "miss" to not assert.
void AddSet (std::string setname, double nearval, double farval, double caldetval)
 Insert new "set"s into internal DB.
void AddSet (ReleaseType::Release_t rt, double nearval, double farval, double caldetval)
void SetValue (Detector::Detector_t det, double value)
 Set an individual value (forces a "-modified" name).
bool SetExists (std::string setname) const
 Check if a "set" exists.
bool SetExists (ReleaseType::Release_t rt) const

Static Public Member Functions

static MasterGeVPerMipInstance ()
 Singleton access.

Private Member Functions

 MasterGeVPerMip ()

Static Private Member Functions

static std::string TrimOption (std::string opt)

Private Attributes

std::string fSetName
int fSetIndex
std::map< std::string, int > fSetIndexMap
std::vector< double > fBestValueNear
std::vector< double > fBestValueFar
std::vector< double > fBestValueCalDet
int fQuiet
int fAssert

Static Private Attributes

static MasterGeVPerMipfMyInstance = 0

Detailed Description

A class for managing sets of GeVPerMip values by release name (or arbitrary string).

Author:
(last to touch it)
Author
rhatcher
Version:
Revision
1.3
Date:
Date
2012/07/20 15:48:27

Contact: rhatcher@fnal.gov

Definition at line 25 of file MasterGeVPerMip.h.


Constructor & Destructor Documentation

MasterGeVPerMip::~MasterGeVPerMip (  )  [virtual]

Definition at line 129 of file MasterGeVPerMip.cxx.

References Print().

00130 {
00131   // dtor prints final status
00132   cout << "MasterGeVPerMip final state:" << endl;
00133   Print();
00134   cout << endl;
00135 }

MasterGeVPerMip::MasterGeVPerMip (  )  [private]

Definition at line 45 of file MasterGeVPerMip.cxx.

References AddSet(), fAssert, fQuiet, ReleaseType::k00, ReleaseType::k01, ReleaseType::k02, ReleaseType::k03, ReleaseType::k04, ReleaseType::k07, ReleaseType::k08, ReleaseType::k09, ReleaseType::kCedar_Phy, ReleaseType::kDaikon, ReleaseType::kDogwood, ReleaseType::kDogwood1, ReleaseType::kDogwood2, ReleaseType::kDogwood3, ReleaseType::kDogwood4, ReleaseType::kDogwood5, ReleaseType::kDogwood6, ReleaseType::kDogwood7, ReleaseType::kGarlic, and SelectSet().

00046 { 
00047   // ctor
00048 
00049   fQuiet  = false;  // by default don't be quiet about set selection misses
00050   fAssert = true;   // by default assert when miss set selection
00051   cout << "MasterGeVPerMip creation:" << endl;
00052 
00053   string setname;
00054   // Initial set of sets ...
00055   //           name                           NearDet   FarDet    CalDet
00056   // "default" is only to be used by those you don't care about the real GeVPerMip
00057   // In principle the "default" value represents the most recent version
00058   // The CalDet GevPerMip number is currenlty incorrect and set to zero
00059   AddSet("default"                         , 0.001775, 0.001790, 0.000000);
00060   // NOTICE: the following depends on "namespace RT = ReleaseType;" above!
00061 
00062 
00063   //Dogwood7 GevPerMip number based on Daikon MC
00064   AddSet(RT::kDogwood7 +RT::kDaikon+RT::k04, 0.001777, 0.001793, 0.000000);
00065   AddSet(RT::kDogwood7 +RT::kDaikon+RT::k07, 0.001777, 0.001793, 0.000000);
00066   AddSet(RT::kDogwood7 +RT::kDaikon+RT::k08, 0.001777, 0.001793, 0.000000);
00067   AddSet(RT::kDogwood7 +RT::kDaikon+RT::k09, 0.001777, 0.001793, 0.000000);
00068 
00069 
00070   //Dogwood6 GevPerMip number based on Daikon MC - do we ever need dogwood6 for MC??? - this is an overkill, I know.
00071   AddSet(RT::kDogwood6 +RT::kDaikon+RT::k04, 0.001777, 0.001793, 0.000000);
00072   AddSet(RT::kDogwood6 +RT::kDaikon+RT::k07, 0.001777, 0.001793, 0.000000);
00073   AddSet(RT::kDogwood6 +RT::kDaikon+RT::k08, 0.001777, 0.001793, 0.000000);
00074   AddSet(RT::kDogwood6 +RT::kDaikon+RT::k09, 0.001777, 0.001793, 0.000000);
00075 
00076   //Dogwood5 GevPerMip number based on Daikon MC
00077   AddSet(RT::kDogwood5 +RT::kDaikon+RT::k04, 0.001777, 0.001793, 0.000000);
00078   AddSet(RT::kDogwood5 +RT::kDaikon+RT::k07, 0.001777, 0.001793, 0.000000);
00079   AddSet(RT::kDogwood5 +RT::kDaikon+RT::k08, 0.001777, 0.001793, 0.000000);
00080   AddSet(RT::kDogwood5 +RT::kDaikon+RT::k09, 0.001777, 0.001793, 0.000000);
00081 
00082   //Dogwood4 GevPerMip number based on Daikon MC
00083   AddSet(RT::kDogwood4 +RT::kDaikon+RT::k04, 0.001777, 0.001793, 0.000000);
00084   AddSet(RT::kDogwood4 +RT::kDaikon+RT::k07, 0.001777, 0.001793, 0.000000);
00085   AddSet(RT::kDogwood4 +RT::kDaikon+RT::k08, 0.001777, 0.001793, 0.000000);
00086   AddSet(RT::kDogwood4 +RT::kDaikon+RT::k09, 0.001777, 0.001793, 0.000000);
00087 
00088   //Dogwood3 GevPerMip number based on Daikon MC
00089   AddSet(RT::kDogwood3 +RT::kDaikon+RT::k04, 0.001777, 0.001793, 0.000000);
00090   AddSet(RT::kDogwood3 +RT::kDaikon+RT::k07, 0.001777, 0.001793, 0.000000);
00091   AddSet(RT::kDogwood3 +RT::kDaikon+RT::k08, 0.001777, 0.001793, 0.000000);
00092   AddSet(RT::kDogwood3 +RT::kDaikon+RT::k09, 0.001777, 0.001793, 0.000000);
00093   AddSet(RT::kDogwood3 +RT::kGarlic+RT::k00, 0.001777, 0.001793, 0.000000);
00094 
00095   //Dogwood2 GevPerMip number based on Daikon MC
00096   AddSet(RT::kDogwood2 +RT::kDaikon+RT::k04, 0.001777, 0.001793, 0.000000);
00097   AddSet(RT::kDogwood2 +RT::kDaikon+RT::k07, 0.001777, 0.001793, 0.000000);
00098   AddSet(RT::kDogwood2 +RT::kGarlic+RT::k00, 0.001777, 0.001793, 0.000000);
00099 
00100   //Dogwood1 GevPerMip number based on Daikon MC
00101   AddSet(RT::kDogwood1 +RT::kDaikon+RT::k04, 0.001777, 0.001793, 0.000000);
00102   AddSet(RT::kDogwood1 +RT::kDaikon+RT::k07, 0.001777, 0.001793, 0.000000);
00103   AddSet(RT::kDogwood1 +RT::kGarlic+RT::k00, 0.001777, 0.001793, 0.000000);
00104   
00105   // Best Guess of Dogwood GeVPerMip number based on Cedar_Phy Daikon03
00106   AddSet("predogwood"                      , 0.001789, 0.001790, 0.000000);
00107   AddSet("dogwood"                         , 0.001775, 0.001790, 0.000000);
00108   AddSet(RT::kDogwood  +RT::kDaikon+RT::k04, 0.001775, 0.001790, 0.000000);
00109   AddSet(RT::kDogwood  +RT::kGarlic+RT::k00, 0.001775, 0.001790, 0.000000);
00110 
00111   // All versions of cedar_phy have the same GeVPerMip number
00112   AddSet("cedar_phy"                       , 0.001792, 0.001786, 0.000000);
00113   AddSet(RT::kCedar_Phy+RT::kDaikon+RT::k00, 0.001792, 0.001786, 0.000000);
00114   AddSet(RT::kCedar_Phy+RT::kDaikon+RT::k01, 0.001792, 0.001786, 0.000000);
00115   AddSet(RT::kCedar_Phy+RT::kDaikon+RT::k02, 0.001792, 0.001786, 0.000000);
00116   AddSet(RT::kCedar_Phy+RT::kDaikon+RT::k03, 0.001792, 0.001786, 0.000000);
00117   AddSet(RT::kCedar_Phy+RT::kDaikon+RT::k04, 0.001792, 0.001786, 0.000000);
00118   //calB
00119   AddSet("r1_24_calb"                      , 0.001759, 0.001747, 0.000000);
00120   //cedar
00121   AddSet("cedar"                           , 0.001759, 0.001737, 0.000000);
00122 
00123   // pick initial default set
00124   SelectSet();
00125 }


Member Function Documentation

void MasterGeVPerMip::AddSet ( ReleaseType::Release_t  rt,
double  nearval,
double  farval,
double  caldetval 
)

Definition at line 151 of file MasterGeVPerMip.cxx.

References AddSet(), and ReleaseType::AsString().

00153 { AddSet(ReleaseType::AsString(rt),nearval,farval,caldetval); }

void MasterGeVPerMip::AddSet ( std::string  setname,
double  nearval,
double  farval,
double  caldetval 
)

Insert new "set"s into internal DB.

Referenced by AddSet(), MasterGeVPerMip(), mod_mastergev(), new_gevpermip_release(), and SetValue().

double MasterGeVPerMip::Get ( Detector::Detector_t  det  )  const

Return the GeV-per-MIP for a particular detector from the current "set".

Definition at line 216 of file MasterGeVPerMip.cxx.

References fBestValueCalDet, fBestValueFar, fBestValueNear, fSetIndex, Detector::kCalDet, Detector::kFar, and Detector::kNear.

Referenced by get_gevpermip(), and SetValue().

00217 { 
00218   // assume fSetIndex in a fine state ...
00219   switch (det) {
00220   case Detector::kNear:    return fBestValueNear[fSetIndex];
00221   case Detector::kFar:     return fBestValueFar[fSetIndex];
00222   case Detector::kCalDet:  return fBestValueCalDet[fSetIndex];
00223   default:
00224     return 0;
00225   }
00226 }

MasterGeVPerMip & MasterGeVPerMip::Instance (  )  [static]

Singleton access.

Definition at line 139 of file MasterGeVPerMip.cxx.

References fMyInstance, and MasterGeVPerMip::Cleaner::UseMe().

Referenced by choose_gevpermip_release(), get_gevpermip(), gevpermip_release_exists(), mod_mastergev(), new_gevpermip_release(), and print_gevpermip().

00140 {
00141   static Cleaner cleaner;  // cleaner dtor calls MasterGevPerMip dtor
00142   if ( ! fMyInstance ) {
00143     fMyInstance = new MasterGeVPerMip;
00144     cleaner.UseMe();
00145   }
00146   return *fMyInstance;
00147 }

void MasterGeVPerMip::Print ( std::string  option = ""  )  const

Print the current value (or "all").

Referenced by print_gevpermip(), SetValue(), and ~MasterGeVPerMip().

void MasterGeVPerMip::SelectSet ( ReleaseType::Release_t  rt  ) 

Definition at line 275 of file MasterGeVPerMip.cxx.

References ReleaseType::AsString(), and SelectSet().

void MasterGeVPerMip::SelectSet ( std::string  setname = "default"  ) 

Select a "set" either by string name or ReleaseType value.

Referenced by choose_gevpermip_release(), MasterGeVPerMip(), SelectSet(), and SetValue().

void MasterGeVPerMip::SetAssert ( bool  doAssert = true  )  [inline]

Allow set selection "miss" to not assert.

Definition at line 60 of file MasterGeVPerMip.h.

References fAssert.

00060 { fAssert = doAssert; }

bool MasterGeVPerMip::SetExists ( ReleaseType::Release_t  rt  )  const

Definition at line 198 of file MasterGeVPerMip.cxx.

References ReleaseType::AsString(), and SetExists().

00199 { return SetExists(ReleaseType::AsString(rt)); }

bool MasterGeVPerMip::SetExists ( std::string  setname  )  const

Check if a "set" exists.

Definition at line 200 of file MasterGeVPerMip.cxx.

References fSetIndexMap, and TrimOption().

Referenced by gevpermip_release_exists(), and SetExists().

00201 {
00202   // do everything lower case, no leading/trailing blanks
00203   string usrreq = TrimOption(setname);
00204   if (usrreq == "") usrreq = "default";
00205 
00206   map<string,int>::const_iterator itr = fSetIndexMap.find(usrreq);
00207   if ( itr != fSetIndexMap.end() ) {
00208     // already exists
00209     return true;
00210   }
00211   return false;
00212 }

void MasterGeVPerMip::SetValue ( Detector::Detector_t  det,
double  value 
)

Set an individual value (forces a "-modified" name).

Definition at line 306 of file MasterGeVPerMip.cxx.

References AddSet(), bfld::AsString(), fBestValueCalDet, fBestValueFar, fBestValueNear, fQuiet, fSetIndex, fSetName, Get(), Detector::kCalDet, Detector::kFar, Detector::kNear, Print(), and SelectSet().

00307 { 
00308   string modsetname = fSetName;
00309   if ( modsetname.find("-modified") == string::npos) modsetname += "-modified";
00310 
00311   cout << "MasterGeVPerMip: "
00312             << "SetValue(" << Detector::AsString(det) << "," << value << ")" 
00313             << " on \"" << modsetname << "\"" << endl;
00314 
00315   fQuiet = true;  // don't complain if not found
00316   SelectSet(modsetname); // if not found leaves thing unchanged
00317 
00318   if ( fSetName != modsetname ) {
00319     // make a modified entry, so one can restore/revert to unmodified set
00320     double nearval   = Get(Detector::kNear);
00321     double farval    = Get(Detector::kFar);
00322     double caldetval = Get(Detector::kCalDet);
00323     AddSet(modsetname,nearval,farval,caldetval);
00324     SelectSet(modsetname);
00325   }
00326 
00327   switch (det) {
00328   case Detector::kNear:   fBestValueNear[fSetIndex]   = value; break;
00329   case Detector::kFar:    fBestValueFar[fSetIndex]    = value; break;
00330   case Detector::kCalDet: fBestValueCalDet[fSetIndex] = value; break;
00331   default:
00332     cout << "MasterGeVPerMip doesn't handle Detector::k"
00333               << Detector::AsString(det) << " (" << int(det) 
00334               << ")" << endl;
00335     break;
00336   }
00337   fQuiet = false; // restore complaints about unknown sets 
00338   Print();
00339 }

static std::string MasterGeVPerMip::TrimOption ( std::string  opt  )  [static, private]

Referenced by SetExists().


Member Data Documentation

int MasterGeVPerMip::fAssert [private]

Definition at line 100 of file MasterGeVPerMip.h.

Referenced by MasterGeVPerMip(), and SetAssert().

std::vector<double> MasterGeVPerMip::fBestValueCalDet [private]

Definition at line 98 of file MasterGeVPerMip.h.

Referenced by Get(), and SetValue().

std::vector<double> MasterGeVPerMip::fBestValueFar [private]

Definition at line 97 of file MasterGeVPerMip.h.

Referenced by Get(), and SetValue().

std::vector<double> MasterGeVPerMip::fBestValueNear [private]

Definition at line 96 of file MasterGeVPerMip.h.

Referenced by Get(), and SetValue().

Definition at line 78 of file MasterGeVPerMip.h.

Referenced by Instance(), and MasterGeVPerMip::Cleaner::~Cleaner().

int MasterGeVPerMip::fQuiet [private]

Definition at line 99 of file MasterGeVPerMip.h.

Referenced by MasterGeVPerMip(), and SetValue().

Definition at line 94 of file MasterGeVPerMip.h.

Referenced by Get(), and SetValue().

std::map<std::string,int> MasterGeVPerMip::fSetIndexMap [private]

Definition at line 95 of file MasterGeVPerMip.h.

Referenced by SetExists().

std::string MasterGeVPerMip::fSetName [private]

Definition at line 93 of file MasterGeVPerMip.h.

Referenced by SetValue().


The documentation for this class was generated from the following files:

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1