00001 #ifndef L2EMCDB_H 00002 #define L2EMCDB_H 00003 #include <stdio.h> 00004 00005 /********************************************************* 00006 * $Id: L2EmcDb.h,v 1.6 2008/01/30 00:47:15 balewski Exp $ 00007 * \author Jan Balewski, IUCF, 2006 00008 ********************************************************* 00009 * Descripion: 00010 * StRoot-free DB container , common for BTOW + ETOW + ESMD 00011 ********************************************************* 00012 */ 00013 00014 class L2EmcDb { 00015 public: 00016 /* use it to decalare any ENDCAP local array 12+1 secors */ 00017 enum { EindexMax=13000}; 00018 /* use it to decalare any local BTOW array 12+1+extra */ 00019 enum { BindexMax=5400}; 00020 #define EmcDbIndexMax (L2EmcDb::EindexMax+L2EmcDb::BindexMax) /* use it to decalare any local array */ 00021 00022 enum {ETOW_DATSIZE=160, ETOW_DATUSED=128, BTOW_DATSIZE=160, ETOW_MAXFEE=6, BTOW_MAXFEE=30,MxEmcNameLen=16}; 00023 00024 struct EmcCDbItem { 00025 int key; /* unique EmcDbC ID in form 1 to EmcIndex-1, not all used */ 00026 char name[MxEmcNameLen]; /* geographical name of the pixel */ 00027 char tube[MxEmcNameLen]; /* ETOW: name of PMT; ESMD: MAPMT pixel; BTOW: softId-mod-sub-eta */ 00028 00029 /* for towers/pre/post use (sec,sub,eta) 00030 for SMD use sec,plane,strip) */ 00031 int sec,eta; /*ETOW: 1-12, 1-12; BTOW: 1-12, 1-40 */ 00032 char sub;/*ETWO: A-E; BTOW: a-j*/ 00033 char plane; /* ESMD: U-V */ 00034 int strip; /* ESMD: 1-288 */ 00035 00036 int crate, chan; /* hardware channel */ 00037 int rdo; /* index of channel in the raw data block, counts from 0 */ 00038 float gain; 00039 float ped,thr,sigPed; /* in ADC channals */ 00040 unsigned stat; /* bits, see eemcConstDB.hh for definitions */ 00041 unsigned fail; /* bits, see eemcConstDB.hh for definitions */ 00042 } ; 00043 00044 L2EmcDb(char *inpP, char *logP); 00045 ~L2EmcDb(); // saves DB for last run 00046 const EmcCDbItem *getByIndex(int i); 00047 const EmcCDbItem *getByName(char *name); // slow 00048 int name2index(char *name);// slow 00049 00050 static void printItem(const EmcCDbItem *x); 00051 bool isEmpty(const EmcCDbItem *x); 00052 bool isBTOW(const EmcCDbItem *x); 00053 bool isETOW(const EmcCDbItem *x); 00054 00055 int initRun(int runNo); 00056 int getRun() { return run_number;} 00057 void finishRun(); 00058 00059 enum {mxTxt=1000}; 00060 char logPath[mxTxt]; 00061 char inpPath[mxTxt]; 00062 char pedFile[mxTxt]; 00063 char maskFile[mxTxt]; 00064 00065 00066 void setPedFile( const char *c ); 00067 void setMaskFile( const char *c ); 00069 private: 00070 EmcCDbItem dbByIndex[EmcDbIndexMax]; // the data container 00071 00072 void clearItem(EmcCDbItem *x); 00073 void clearTables(); 00074 int importItem(EmcCDbItem *x, FILE *fd); 00075 void exportItem(EmcCDbItem *x, FILE *fd); 00076 int BtowName2Index(int sect, char *xee); //slow 00077 int readAsciiDb(char *fname, char *lbl); 00078 void writeAsciiDb(FILE *fd); 00079 00080 int changeMaskFullCrate(const char *fname, char BEflag, char *lbl); 00081 int changePedsByName(const char *fname, char *lbl); 00082 int changeMaskByName(const char *fname, char *lbl); 00083 00084 int run_number; 00085 00086 enum {txMxLbl=6, txMxSize=100}; 00087 char db_labels[txMxLbl][txMxSize]; 00088 00089 }; 00090 00091 00092 /*********************************************************** 00093 00094 Descripion: 00095 00096 1) Lets define a unique 'name' for any active element in EEMC 00097 name="ssTann" for towers, ss=sector 01-12, a=subsector='A' -'E' 00098 nn=tower in eta =01-12 00099 "ssxkkk" for SMD x='U' or 'V' plain orientation, 00100 kkk=001-288 strip ID 00101 "ssPann" for Pres1 00102 "ssQann" for Pres2 00103 "ssRann" for Post 00104 "ssLann" for LED pixel 00105 1.b) Extension for BTOW towers 00106 name="sstann" for towers, ss=sector 01-12, t='t' 00107 a=subsector='a'-'j' interlaced 00108 nn=tower etaBin =1-40 00109 Geograohical location of towers: 00110 BTOW subs 'a' infront of ETOW subs 'A' 00111 BTOW subs 'b' spans ETOW subs 'A' 00112 BTOW subs 'c' spans ETOW subs 'B' , etc ... 00113 BTOW eta bin 1 is at physical eta of +0.95 00114 BTOW eta bin 20 is at physical eta of +0.0? 00115 BTOW eta bin 21 is at physical eta of -0.0? 00116 BTOW eta bin 40 is at physical eta of -0.95 00117 00118 1.c) Extension for spare channels --> use sector 13 00119 Add 1000 to the ETOW index range. 00120 Add 400 to the BTOW index range. 00121 00122 spare ETOW chan 120-127 per crate 1-6 mapp into 00123 consecutive 13TA01, ..02, ..12, 13TB01,... 13TD12 00124 00125 spare BTOW chan papping ??? 00126 00127 00128 2) Lets define sector oriented index for any PMT/MAPMT pixel 00129 Index within sector: 00130 00131 Tower 1- 60 =(sub-1)*5+eta, where sub=1-5, eta=1-12 00132 Pre1 101-160 = the same 00133 Pre2 201-260 = the same 00134 Post 301-360 = the same 00135 smd-U 401-688 couting from shortest at eta=2 00136 smd-V 701-988 couting from shortest at eta=2 00137 00138 Index jumps by 1000 from sector to sector 00139 --> add (sectorID-1)*1000 00140 00141 Index total range [1 - 12,999], spare ~15% or ~180/sector 00142 00143 2.b) Extension for BTOW towers 00144 Tower =12,000+ (sec-1)*400 + (sub-1)*40 +eta 00145 where sec=1-12, sub=1-10, eta=1-40 00146 Index total range [13,001- 17,200], 200 spares 00147 00148 ****************************************************/ 00149 00150 00151 #endif 00152 00153 00154 /* 00155 ********************************************************************* 00156 $Log: L2EmcDb.h,v $ 00157 Revision 1.6 2008/01/30 00:47:15 balewski 00158 Added L2-Etow-calib 00159 00160 Revision 1.5 2007/12/19 02:30:16 balewski 00161 new L2-btow-calib-2008 00162 00163 Revision 1.4 2007/11/14 03:58:07 balewski 00164 cleanup of common timing measurement 00165 00166 Revision 1.3 2007/11/06 22:07:24 balewski 00167 added timeStamp controlled L2 setup from Jason 00168 00169 Revision 1.2 2007/10/22 23:10:03 balewski 00170 split L2 to generic and year specific, not finished 00171 00172 Revision 1.1 2007/10/11 00:33:14 balewski 00173 L2algo added 00174 00175 Revision 1.4 2006/03/28 19:33:23 balewski 00176 ver16b , in L2new 00177 00178 Revision 1.3 2006/03/11 17:08:32 balewski 00179 now CVS comments should work 00180 00181 */ 00182
1.5.9