StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEEmcDb.h
1 
11 #ifndef STAR_StEEmcDb_H
12 #define STAR_StEEmcDb_H
13 
14 #include <TObject.h>
15 #include <TString.h>
16 #include <TDataSet.h>
17 
18 class StMaker;
19 
20 // needed DB c-structs
21 class eemcDbADCconf_st;
22 class eemcDbPMTcal_st;
23 class eemcDbPMTname_st;
24 class eemcDbPIXcal_st;
25 class eemcDbPMTped_st;
26 class eemcDbPMTstat_st;
27 class kretDbBlobS_st;
28 
29 
30 class EEmcDbItem;
31 class EEmcDbCrate;
32 #include "StEEmcUtil/EEfeeRaw/EEdims.h"
33 
34 class DbFlavor : public TObject {
35  public:
36  static const int mx=100;
37  char flavor[mx];
38  char nameMask[mx];
39  DbFlavor(){flavor[0]=0; nameMask[0]=0;}
40 };
41 
42 class StEEmcDb : public TDataSet {
43 private:
44 
45  int mfirstSecID, mlastSecID;
46  int mNSector;
47  void clearItemArray();
48  void requestDataBase(StMaker *anyMaker);
49  int optimizeMapping(int isec);
50  void optimizeOthers(int isec);
51  void optimizeFibers();
52 
53  // pointers to Db tables for each sector
54  int *mDbsectorID;
55  eemcDbADCconf_st **mDbADCconf;
56  eemcDbPMTcal_st **mDbPMTcal ;
57  eemcDbPMTname_st **mDbPMTname ;
58  eemcDbPIXcal_st **mDbPIXcal ;
59  eemcDbPMTped_st **mDbPMTped ;
60  eemcDbPMTstat_st **mDbPMTstat ;
61  kretDbBlobS_st *mDbFiberConfBlob;
62 
63  // local fast look-up tables
64  EEmcDbItem *byIndex;
65  EEmcDbItem ***byCrate;
66  const EEmcDbItem *byStrip[MaxSectors][MaxSmdPlains][MaxSmdStrips];
67 
68  EEmcDbCrate *mDbFiber; // maps tw & mapmt crates to DAQ fibers
69  int nFiber; // # of existing crates(Tw+Mapmt)
70 
71  float KsigOverPed; // defines threshold
72  int nFound;
73  TString dbName; //name of the DB used
74  DbFlavor dbFlavor; // used if flavor is requested
75 
76  template <class St_T, class T_st> void getTable(TDataSet *eedb, int secID, TString tabName, TString mask, T_st **outTab);
77 
78  const EEmcDbItem* getStrip(int sec, char uv, int strip) const; //ranges: sec=1-12, uv=U,V ,strip=1-288; slow method
79 
80  TString mAsciiDbase; // Ascii database filename (default NONE)
81 
82  // tmp solution to hold list of strings
83  TString *chGainL;
84  int nChGain, mxChGain;
85  void changeGainsAction(const char *fname);
86 
87  TString *chMaskL;
88  int nChMask, mxChMask;
89  void changeMaskAction(const char *fname);
90 
91 // protected:
92 public:
93 
94  void setSectors(int ,int);
95  int getFirstSector() const {return mfirstSecID;}
96  int getLastSector() const {return mlastSecID;}
97 
98  void setThreshold(float x);// defines threshold for ADCs
99 
100  void setAsciiDatabase ( const Char_t *dbfile );
101  void changeGains(char *fname);// Replace gains for initialized channels
102  void changeMask(char *fname);// Replace stat/fail mask for initialized channels
103  const EEmcDbCrate * getFiber(int icr) const;
104  void setFiberOff(int icr);
105  const int getNFiber() const {return nFiber;}
106  const EEmcDbItem* getByIndex(int ikey) const;
107  void exportAscii(const char *fname="eemcDbDump.dat") const;
108  void print() const {exportAscii();}
109 
110  const EEmcDbItem* getByCrate(int crateID, int channel) const; // full DB info, crateID counts from 1, channel from 0
111 
112  const EEmcDbItem* getByStrip0(int isec, int iuv, int istrip) const; //ranges: isec=0-11, iuv=0,1 ,istrip=0-287; fast method
113 
114  const EEmcDbItem* getByStrip(int sec, char uv, int strip) const //ranges: sec=1-12, uv=U,V ,strip=1-288; fast method
115  {return getByStrip0(sec-1,uv-'U',strip-1);}
116 
117  const EEmcDbItem* getTile(int sec,char sub, int eta, char type) const; //ranges: sec=1-12,sub=A-E,eta=1-12,type=T,P-R ; slow method
118 
119  const EEmcDbItem* getT(int sec, char sub, int eta) const {return getTile(sec,sub,eta,'T');}
120 
121  const EEmcDbItem* getP(int sec, char sub, int eta) const {return getTile(sec,sub,eta,'P');}
122  const EEmcDbItem* getQ(int sec, char sub, int eta) const {return getTile(sec,sub,eta,'Q');}
123  const EEmcDbItem* getR(int sec, char sub, int eta) const {return getTile(sec,sub,eta,'R');}
124  const EEmcDbItem* getU(int sec, int strip) const {return getStrip(sec,'U',strip);}
125  const EEmcDbItem* getV(int sec, int strip) const {return getStrip(sec,'V',strip);}
126  const EEmcDbItem* StBarrelIndex2Item(int StDetId , int Bmod, int Beta, int Bsub) const;
127 
128  //
129  // Methods to acces DB info for T=tower, P=preshower-1, Q=preshower-2,
130  // R=postshower, U=SMD-U strip, V=SMD-V strip
131  //
132 
133  void setPreferredFlavor(const char *flavor, const char *tableNameMask);
134  void setPreferedFlavor(const char *flavor, const char *tableNameMask){
135  setPreferredFlavor( flavor, tableNameMask); // typo...
136  }
137 
138  int getFirstSecID() const { return mfirstSecID;}
139  int getLastSecID() const { return mlastSecID;}
140  void setDBname(TString name){ dbName=name;}
141 
142  int valid() const { return nFound;} // return # of valid BD records
143  float getKsigOverPed() const {return KsigOverPed;} // defines threshold
144 
145  StEEmcDb(const Char_t *name = "StEEmcDb"); // default name for this object
146  virtual ~StEEmcDb();
147 
148  void loadTables(StMaker *anyMaker);
149 
150  ClassDef(StEEmcDb, 1)
151 
152  };
153 
154 #endif
const EEmcDbItem * getByIndex(int ikey) const
returns full DB info for one pixel
Definition: StEEmcDb.cxx:584
const EEmcDbItem * StBarrelIndex2Item(int StDetId, int Bmod, int Beta, int Bsub) const
Definition: StEEmcDb.cxx:938
void loadTables(StMaker *anyMaker)
to access STAR-DB
Definition: StEEmcDb.cxx:211
void setSectors(int, int)
limit the range of sectors for speed
Definition: StEEmcDb.cxx:114