StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StTamuRelLum.h
1 //StTamuRelLum.h
2 //M.L. Miller (MIT)
3 //10/05
4 
5 //This file contains necessary classes to read/store/access Ernst Sichterman's (Es) Relative Luminosity file
6 
7 #ifndef StTamuRelLum_HH
8 #define StTamuRelLum_HH
9 #ifdef __ROOT__
10 #include "Rtypes.h"
11 #endif
12 
13 #include <iostream>
14 #include <fstream>
15 #include <string>
16 #include <map>
17 using namespace std;
18 
19 /* note, Ernst's definitions are as follows:
20 
21 #R1=UpUp+UpDw/DwDw+DwUp R2=UpUp+DwUp/DwDw+UpDw R3=UpUp+DwDw/UpDw+DwUp R4=UpUp/DwDw R5=UpDw/DwDw R6=DwUp/DwDw Board11[R[i],eR[i]]
22 
23 */
24 struct TamuRelLum
25 {
26  //Star RunNumber
27  int runId;
28 
29  //fill
30  int fill;
31 
32  //scaler board number
33  int board;
34 
35  //bbc time bin
36  int bbcTimeBin;
37 
38  //The N-counts as a function of spin-state (YB)
39  int uu;
40  int du;
41  int ud;
42  int dd;
43 };
44 
45 //This is needed for internal storage
47 {
48  bool operator()(const TamuRelLum& lhs, const TamuRelLum& rhs) const;
49 };
50 
51 //Class StTamuRelLum is a singleton class to read/store/access
52 
54 {
55 public:
56  //here's the map typedef
57  typedef map<TamuRelLum, TamuRelLum, TamuRelLumLessThan> RelLumMap;
58 
59  //here's access to the one global instance
60  static StTamuRelLum* instance(const string infile = "StRoot/StSpinPool/StTamuRelLum/inputs/run6.txt");
61 
62  //Print the contents of the map to screen
63  void print();
64 
65  //Access to the information for a given run:
66  //NOTE: test the pointer! If it is null, that means theres no entry for this run
67  const TamuRelLum* getRelLum(int runId, int board, int timeBin);
68 
69 private:
70 
71  //the map:
72  RelLumMap mMap;
73 
74  //This is the static instance
75  static StTamuRelLum* sInstance;
76 
77  virtual ~StTamuRelLum();
78 
79 private:
80  StTamuRelLum( const string infile ); //We make the constructor private for singleton access
81 
82  #ifdef __ROOT__
83  ClassDef(StTamuRelLum,1)
84  #endif
85 };
86 
87 
88 inline StTamuRelLum* StTamuRelLum::instance(const string infile)
89 {
90  return (sInstance) ? sInstance : new StTamuRelLum(infile);
91 }
92 
93 
94 inline ostream& operator<<(ostream& os, const TamuRelLum& rl)
95 {
96  os <<"run:\t"<<rl.runId<<" fill:\t"<<rl.fill<<" board:\t"<<rl.board<<" bin:\t"<<rl.bbcTimeBin
97  <<" uu:\t"<<rl.uu<<" du:\t"<<rl.du<<" ud:\t"<<rl.ud<<" dd:\t"<<rl.dd;
98  return os;
99 }
100 #endif