StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
L2EmcDb.h
1 #ifndef L2EMCDB_H
2 #define L2EMCDB_H
3 #include <stdio.h>
4 
5 /*********************************************************
6  * $Id: L2EmcDb.h,v 1.6 2008/01/30 00:47:15 balewski Exp $
7  * \author Jan Balewski, IUCF, 2006
8  *********************************************************
9  * Descripion:
10  * StRoot-free DB container , common for BTOW + ETOW + ESMD
11  *********************************************************
12  */
13 
14 class L2EmcDb {
15  public:
16  /* use it to decalare any ENDCAP local array 12+1 secors */
17  enum { EindexMax=13000};
18  /* use it to decalare any local BTOW array 12+1+extra */
19  enum { BindexMax=5400};
20 #define EmcDbIndexMax (L2EmcDb::EindexMax+L2EmcDb::BindexMax) /* use it to decalare any local array */
21 
22  enum {ETOW_DATSIZE=160, ETOW_DATUSED=128, BTOW_DATSIZE=160, ETOW_MAXFEE=6, BTOW_MAXFEE=30,MxEmcNameLen=16};
23 
24  struct EmcCDbItem {
25  int key; /* unique EmcDbC ID in form 1 to EmcIndex-1, not all used */
26  char name[MxEmcNameLen]; /* geographical name of the pixel */
27  char tube[MxEmcNameLen]; /* ETOW: name of PMT; ESMD: MAPMT pixel; BTOW: softId-mod-sub-eta */
28 
29  /* for towers/pre/post use (sec,sub,eta)
30  for SMD use sec,plane,strip) */
31  int sec,eta; /*ETOW: 1-12, 1-12; BTOW: 1-12, 1-40 */
32  char sub;/*ETWO: A-E; BTOW: a-j*/
33  char plane; /* ESMD: U-V */
34  int strip; /* ESMD: 1-288 */
35 
36  int crate, chan; /* hardware channel */
37  int rdo; /* index of channel in the raw data block, counts from 0 */
38  float gain;
39  float ped,thr,sigPed; /* in ADC channals */
40  unsigned stat; /* bits, see eemcConstDB.hh for definitions */
41  unsigned fail; /* bits, see eemcConstDB.hh for definitions */
42 } ;
43 
44  L2EmcDb(char *inpP, char *logP);
45  ~L2EmcDb(); // saves DB for last run
46  const EmcCDbItem *getByIndex(int i);
47  const EmcCDbItem *getByName(char *name); // slow
48  int name2index(char *name);// slow
49 
50  static void printItem(const EmcCDbItem *x);
51  bool isEmpty(const EmcCDbItem *x);
52  bool isBTOW(const EmcCDbItem *x);
53  bool isETOW(const EmcCDbItem *x);
54 
55  int initRun(int runNo);
56  int getRun() { return run_number;}
57  void finishRun();
58 
59  enum {mxTxt=1000};
60  char logPath[mxTxt];
61  char inpPath[mxTxt];
62  char pedFile[mxTxt];
63  char maskFile[mxTxt];
64 
65 
66  void setPedFile( const char *c );
67  void setMaskFile( const char *c );
69  private:
70  EmcCDbItem dbByIndex[EmcDbIndexMax]; // the data container
71 
72  void clearItem(EmcCDbItem *x);
73  void clearTables();
74  int importItem(EmcCDbItem *x, FILE *fd);
75  void exportItem(EmcCDbItem *x, FILE *fd);
76  int BtowName2Index(int sect, char *xee); //slow
77  int readAsciiDb(char *fname, char *lbl);
78  void writeAsciiDb(FILE *fd);
79 
80  int changeMaskFullCrate(const char *fname, char BEflag, char *lbl);
81  int changePedsByName(const char *fname, char *lbl);
82  int changeMaskByName(const char *fname, char *lbl);
83 
84  int run_number;
85 
86  enum {txMxLbl=6, txMxSize=100};
87  char db_labels[txMxLbl][txMxSize];
88 
89 };
90 
91 
92 /***********************************************************
93 
94  Descripion:
95 
96  1) Lets define a unique 'name' for any active element in EEMC
97  name="ssTann" for towers, ss=sector 01-12, a=subsector='A' -'E'
98  nn=tower in eta =01-12
99  "ssxkkk" for SMD x='U' or 'V' plain orientation,
100  kkk=001-288 strip ID
101  "ssPann" for Pres1
102  "ssQann" for Pres2
103  "ssRann" for Post
104  "ssLann" for LED pixel
105  1.b) Extension for BTOW towers
106  name="sstann" for towers, ss=sector 01-12, t='t'
107  a=subsector='a'-'j' interlaced
108  nn=tower etaBin =1-40
109  Geograohical location of towers:
110  BTOW subs 'a' infront of ETOW subs 'A'
111  BTOW subs 'b' spans ETOW subs 'A'
112  BTOW subs 'c' spans ETOW subs 'B' , etc ...
113  BTOW eta bin 1 is at physical eta of +0.95
114  BTOW eta bin 20 is at physical eta of +0.0?
115  BTOW eta bin 21 is at physical eta of -0.0?
116  BTOW eta bin 40 is at physical eta of -0.95
117 
118  1.c) Extension for spare channels --> use sector 13
119  Add 1000 to the ETOW index range.
120  Add 400 to the BTOW index range.
121 
122  spare ETOW chan 120-127 per crate 1-6 mapp into
123  consecutive 13TA01, ..02, ..12, 13TB01,... 13TD12
124 
125  spare BTOW chan papping ???
126 
127 
128  2) Lets define sector oriented index for any PMT/MAPMT pixel
129  Index within sector:
130 
131  Tower 1- 60 =(sub-1)*5+eta, where sub=1-5, eta=1-12
132  Pre1 101-160 = the same
133  Pre2 201-260 = the same
134  Post 301-360 = the same
135  smd-U 401-688 couting from shortest at eta=2
136  smd-V 701-988 couting from shortest at eta=2
137 
138  Index jumps by 1000 from sector to sector
139  --> add (sectorID-1)*1000
140 
141  Index total range [1 - 12,999], spare ~15% or ~180/sector
142 
143  2.b) Extension for BTOW towers
144  Tower =12,000+ (sec-1)*400 + (sub-1)*40 +eta
145  where sec=1-12, sub=1-10, eta=1-40
146  Index total range [13,001- 17,200], 200 spares
147 
148 ****************************************************/
149 
150 
151 #endif
152 
153 
154 /*
155 *********************************************************************
156  $Log: L2EmcDb.h,v $
157  Revision 1.6 2008/01/30 00:47:15 balewski
158  Added L2-Etow-calib
159 
160  Revision 1.5 2007/12/19 02:30:16 balewski
161  new L2-btow-calib-2008
162 
163  Revision 1.4 2007/11/14 03:58:07 balewski
164  cleanup of common timing measurement
165 
166  Revision 1.3 2007/11/06 22:07:24 balewski
167  added timeStamp controlled L2 setup from Jason
168 
169  Revision 1.2 2007/10/22 23:10:03 balewski
170  split L2 to generic and year specific, not finished
171 
172  Revision 1.1 2007/10/11 00:33:14 balewski
173  L2algo added
174 
175  Revision 1.4 2006/03/28 19:33:23 balewski
176  ver16b , in L2new
177 
178  Revision 1.3 2006/03/11 17:08:32 balewski
179  now CVS comments should work
180 
181 */
182 
void setPedFile(const char *c)
Definition: L2EmcDb.cxx:30
void setMaskFile(const char *c)
Definition: L2EmcDb.cxx:31