Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

MasterGeVPerMip Class Reference

#include <MasterGeVPerMip.h>

List of all members.

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).

Static Public Member Functions

MasterGeVPerMipInstance ()
 Singleton access.

Private Member Functions

 MasterGeVPerMip ()

Static Private Member Functions

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

MasterGeVPerMipfMyInstance = 0


Constructor & Destructor Documentation

MasterGeVPerMip::~MasterGeVPerMip  )  [virtual]
 

Definition at line 95 of file MasterGeVPerMip.cxx.

References Print().

00096 {
00097   // dtor prints final status
00098   cout << "MasterGeVPerMip final state:" << endl;
00099   Print();
00100   cout << endl;
00101 }

MasterGeVPerMip::MasterGeVPerMip  )  [private]
 

Definition at line 39 of file MasterGeVPerMip.cxx.

References AddSet(), fAssert, fQuiet, and SelectSet().

00040 { 
00041   // ctor
00042 
00043   fQuiet  = false;  // by default don't be quiet about set selection misses
00044   fAssert = true;   // by default assert when miss set selection
00045   cout << "MasterGeVPerMip creation:" << endl;
00046 
00047   string setname;
00048   // Initial set of sets ...
00049   //           name                           NearDet   FarDet    CalDet
00050   // "default" is only to be used by those you don't care about the real GeVPerMip
00051   // In principle the "default" value represents the most recent version
00052   // The CalDet GevPerMip number is currenlty incorrect and set to zero
00053   AddSet("default"                         , 0.001775, 0.001790, 0.000000);
00054   // NOTICE: the following depends on "namespace RT = ReleaseType;" above!
00055 
00056   //Dogwood3 GevPerMip number based on Daikon MC
00057   AddSet(RT::kDogwood3 +RT::kDaikon+RT::k04, 0.001777, 0.001793, 0.000000);
00058   AddSet(RT::kDogwood3 +RT::kDaikon+RT::k07, 0.001777, 0.001793, 0.000000);
00059   AddSet(RT::kDogwood3 +RT::kGarlic+RT::k00, 0.001777, 0.001793, 0.000000);
00060 
00061   //Dogwood2 GevPerMip number based on Daikon MC
00062   AddSet(RT::kDogwood2 +RT::kDaikon+RT::k04, 0.001777, 0.001793, 0.000000);
00063   AddSet(RT::kDogwood2 +RT::kDaikon+RT::k07, 0.001777, 0.001793, 0.000000);
00064   AddSet(RT::kDogwood2 +RT::kGarlic+RT::k00, 0.001777, 0.001793, 0.000000);
00065 
00066   //Dogwood1 GevPerMip number based on Daikon MC
00067   AddSet(RT::kDogwood1 +RT::kDaikon+RT::k04, 0.001777, 0.001793, 0.000000);
00068   AddSet(RT::kDogwood1 +RT::kDaikon+RT::k07, 0.001777, 0.001793, 0.000000);
00069   AddSet(RT::kDogwood1 +RT::kGarlic+RT::k00, 0.001777, 0.001793, 0.000000);
00070   
00071   // Best Guess of Dogwood GeVPerMip number based on Cedar_Phy Daikon03
00072   AddSet("predogwood"                      , 0.001789, 0.001790, 0.000000);
00073   AddSet("dogwood"                         , 0.001775, 0.001790, 0.000000);
00074   AddSet(RT::kDogwood +RT::kDaikon+RT::k04, 0.001775, 0.001790, 0.000000);
00075   AddSet(RT::kDogwood +RT::kGarlic+RT::k00, 0.001775, 0.001790, 0.000000);
00076 
00077   // All versions of cedar_phy have the same GeVPerMip number
00078   AddSet("cedar_phy"                       , 0.001792, 0.001786, 0.000000);
00079   AddSet(RT::kCedar_Phy+RT::kDaikon+RT::k00, 0.001792, 0.001786, 0.000000);
00080   AddSet(RT::kCedar_Phy+RT::kDaikon+RT::k01, 0.001792, 0.001786, 0.000000);
00081   AddSet(RT::kCedar_Phy+RT::kDaikon+RT::k02, 0.001792, 0.001786, 0.000000);
00082   AddSet(RT::kCedar_Phy+RT::kDaikon+RT::k03, 0.001792, 0.001786, 0.000000);
00083   AddSet(RT::kCedar_Phy+RT::kDaikon+RT::k04, 0.001792, 0.001786, 0.000000);
00084   //calB
00085   AddSet("r1_24_calb"                      , 0.001759, 0.001747, 0.000000);
00086   //cedar
00087   AddSet("cedar"                           , 0.001759, 0.001737, 0.000000);
00088 
00089   // pick initial default set
00090   SelectSet();
00091 }


Member Function Documentation

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

Definition at line 117 of file MasterGeVPerMip.cxx.

References AddSet().

00119 { 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.

Definition at line 121 of file MasterGeVPerMip.cxx.

References fBestValueCalDet, fBestValueFar, fBestValueNear, fQuiet, fSetIndex, fSetIndexMap, fSetName, SelectSet(), and TrimOption().

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

00123 {
00124   // add a new set of values
00125   // does NOT change current set
00126 
00127   // do everything lower case, no leading/trailing blanks
00128   string usrreq = TrimOption(setname);
00129   if (usrreq == "") usrreq = "default";
00130 
00131   string current = fSetName;
00132   
00133   map<string,int>::iterator itr = fSetIndexMap.find(usrreq);
00134   if ( itr != fSetIndexMap.end() ) {
00135     // already exists
00136     fSetName  = itr->first;
00137     fSetIndex = itr->second;
00138     // if it's not tagged as "-modified" don't allow it
00139     if ( fSetName.find("-modified") == string::npos) {
00140       cout << "FATAL: MasterGevPerMip::AddSet already had a \""
00141            << fSetName << "\", assert(0)." << endl;
00142       assert(0);
00143     }
00144   } else {
00145     fSetName  = usrreq;
00146     fSetIndex = fSetIndexMap.size(); // currently nothing -> index=0, 1 -> 2
00147     fSetIndexMap[usrreq] = fSetIndex;
00148     fBestValueNear.resize(fSetIndex+1);
00149     fBestValueFar.resize(fSetIndex+1);
00150     fBestValueCalDet.resize(fSetIndex+1);
00151   }
00152   fBestValueNear[fSetIndex]   = nearval;
00153   fBestValueFar[fSetIndex]    = farval;
00154   fBestValueCalDet[fSetIndex] = caldetval;
00155 
00156   // restore initial state
00157   fQuiet = true;
00158   SelectSet(current);
00159   fQuiet = false;
00160 }

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

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

Definition at line 164 of file MasterGeVPerMip.cxx.

References fBestValueCalDet, fBestValueFar, and fBestValueNear.

Referenced by get_gevpermip(), Print(), and SetValue().

00165 { 
00166   // assume fSetIndex in a fine state ...
00167   switch (det) {
00168   case Detector::kNear:    return fBestValueNear[fSetIndex];
00169   case Detector::kFar:     return fBestValueFar[fSetIndex];
00170   case Detector::kCalDet:  return fBestValueCalDet[fSetIndex];
00171   default:
00172     return 0;
00173   }
00174 }

MasterGeVPerMip & MasterGeVPerMip::Instance  )  [static]
 

Singleton access.

Definition at line 105 of file MasterGeVPerMip.cxx.

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

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

00106 {
00107   static Cleaner cleaner;  // cleaner dtor calls MasterGevPerMip dtor
00108   if ( ! fMyInstance ) {
00109     fMyInstance = new MasterGeVPerMip;
00110     cleaner.UseMe();
00111   }
00112   return *fMyInstance;
00113 }

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

Print the current value (or "all").

Definition at line 178 of file MasterGeVPerMip.cxx.

References fBestValueCalDet, fBestValueFar, fBestValueNear, fSetIndexMap, fSetName, Get(), option, and TrimOption().

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

00179 {
00180   string opt = TrimOption(option);
00181   if ( opt == "compact" ) {
00182     // default is current set
00183     cout << "MasterGeVPerMip: (\"" << setiosflags(ios::left)
00184       //<< setw(24) 
00185          << fSetName 
00186          << resetiosflags(ios::adjustfield) << "\")";
00187     cout << " Near " << Get(Detector::kNear) << ",";
00188     cout << " Far " << Get(Detector::kFar) << ",";
00189     cout << " CalDet " << Get(Detector::kCalDet) << endl;
00190     return;
00191   }
00192 
00193   ios_base::fmtflags orig_fmt = cout.flags();
00194   map<string,int>::const_iterator itr = fSetIndexMap.begin();
00195   cout << "MasterGeVPerMip:      name  index"
00196        << "    Near     "
00197        << "    Far      "
00198        << "    CalDet   "
00199        << endl;
00200   while ( itr != fSetIndexMap.end() ) {
00201     bool iscurrent = ( itr->first == fSetName );
00202     if ( iscurrent || opt == "all" ) {
00203       int indx = itr->second;
00204       if ( iscurrent ) cout << " -> " ;
00205       else             cout << "    " ;
00206       cout<< "\"" << setiosflags(ios::left)
00207            << setw(24) << itr->first 
00208            << resetiosflags(ios::adjustfield) << "\" ";
00209       cout << "(" << indx << ")";
00210       cout << setprecision(8) << fixed;
00211       cout << " " << setw(12) << fBestValueNear[indx]
00212            << " " << setw(12) << fBestValueFar[indx]
00213            << " " << setw(12) << fBestValueCalDet[indx]
00214            << endl;
00215       cout.flags(orig_fmt);
00216     }
00217     itr++;  // move along
00218   }
00219 }

void MasterGeVPerMip::SelectSet ReleaseType::Release_t  rt  ) 
 

Definition at line 223 of file MasterGeVPerMip.cxx.

References SelectSet().

00224 { SelectSet(ReleaseType::AsString(rt)); }

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

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

Definition at line 226 of file MasterGeVPerMip.cxx.

References fSetIndex, fSetIndexMap, fSetName, Print(), and TrimOption().

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

00227 {  
00228   // do everything lower case, no leading/trailing blanks
00229   string usrreq = TrimOption(setname);
00230   if (usrreq == "") usrreq = "default";
00231   
00232   map<string,int>::iterator itr = fSetIndexMap.find(usrreq);
00233   if ( itr != fSetIndexMap.end() ) {
00234     fSetName  = itr->first;
00235     fSetIndex = itr->second;
00236   } else {
00237     if ( ! fQuiet ) {
00238       cout 
00239         << "WARNING: MasterGeVPerMip::SelectSet could not find " 
00240         << "\"" << usrreq << "\"";
00241       if ( fAssert ) {
00242         cout << ", assert(0)!" << endl;
00243         assert(0);
00244       } else {
00245         cout << ", continue using:" << endl;
00246       }
00247     } // ! fQuiet
00248   }
00249   if ( ! fQuiet ) Print();
00250 }

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

Allow set selection "miss" to not assert.

Definition at line 58 of file MasterGeVPerMip.h.

00058 { fAssert = doAssert; }

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

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

Definition at line 254 of file MasterGeVPerMip.cxx.

References AddSet(), Detector::AsString(), det, fBestValueCalDet, fBestValueFar, fBestValueNear, fQuiet, fSetName, Get(), Print(), and SelectSet().

00255 { 
00256   string modsetname = fSetName;
00257   if ( modsetname.find("-modified") == string::npos) modsetname += "-modified";
00258 
00259   cout << "MasterGeVPerMip: "
00260             << "SetValue(" << Detector::AsString(det) << "," << value << ")" 
00261             << " on \"" << modsetname << "\"" << endl;
00262 
00263   fQuiet = true;  // don't complain if not found
00264   SelectSet(modsetname); // if not found leaves thing unchanged
00265 
00266   if ( fSetName != modsetname ) {
00267     // make a modified entry, so one can restore/revert to unmodified set
00268     double nearval   = Get(Detector::kNear);
00269     double farval    = Get(Detector::kFar);
00270     double caldetval = Get(Detector::kCalDet);
00271     AddSet(modsetname,nearval,farval,caldetval);
00272     SelectSet(modsetname);
00273   }
00274 
00275   switch (det) {
00276   case Detector::kNear:   fBestValueNear[fSetIndex]   = value; break;
00277   case Detector::kFar:    fBestValueFar[fSetIndex]    = value; break;
00278   case Detector::kCalDet: fBestValueCalDet[fSetIndex] = value; break;
00279   default:
00280     cout << "MasterGeVPerMip doesn't handle Detector::k"
00281               << Detector::AsString(det) << " (" << int(det) 
00282               << ")" << endl;
00283     break;
00284   }
00285   fQuiet = false; // restore complaints about unknown sets 
00286   Print();
00287 }

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

Definition at line 291 of file MasterGeVPerMip.cxx.

References UtilString::ToLower().

Referenced by AddSet(), Print(), and SelectSet().

00292 { 
00293   // convert to lowercase, strip leading/trailing spaces
00294   TString ts = ToLower(opt).Strip(TString::kBoth);
00295   // change change multiple spaces to single space
00296   while ( ts.Index("  ") != Ssiz_t(-1) )
00297     ts = ts.ReplaceAll("  "," ");
00298   // convert to STL string
00299   string s = ts.Data();
00300   return s;
00301 }


Member Data Documentation

int MasterGeVPerMip::fAssert [private]
 

Definition at line 94 of file MasterGeVPerMip.h.

Referenced by MasterGeVPerMip().

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

Definition at line 92 of file MasterGeVPerMip.h.

Referenced by AddSet(), Get(), Print(), and SetValue().

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

Definition at line 91 of file MasterGeVPerMip.h.

Referenced by AddSet(), Get(), Print(), and SetValue().

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

Definition at line 90 of file MasterGeVPerMip.h.

Referenced by AddSet(), Get(), Print(), and SetValue().

MasterGeVPerMip * MasterGeVPerMip::fMyInstance = 0 [static, private]
 

Definition at line 14 of file MasterGeVPerMip.cxx.

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

int MasterGeVPerMip::fQuiet [private]
 

Definition at line 93 of file MasterGeVPerMip.h.

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

int MasterGeVPerMip::fSetIndex [private]
 

Definition at line 88 of file MasterGeVPerMip.h.

Referenced by AddSet(), and SelectSet().

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

Definition at line 89 of file MasterGeVPerMip.h.

Referenced by AddSet(), Print(), and SelectSet().

std::string MasterGeVPerMip::fSetName [private]
 

Definition at line 87 of file MasterGeVPerMip.h.

Referenced by AddSet(), Print(), SelectSet(), and SetValue().


The documentation for this class was generated from the following files:
Generated on Mon Feb 15 11:09:30 2010 for loon by  doxygen 1.3.9.1