1 #include "StEmcDecoder.h"
11 #include "StEmcMappingDb.h"
16 mapping = StEmcMappingDb::instance();
18 mTowerMapBug = TowerMapBug;
21 for(
int i=0;i<4800;i++) TowerBugFixIndex[i] = i+1;
22 if(date >= 20040101 && date < 20050101) {
23 #include "TowerBug2004.txt"
25 if(date >= 20050101 && date < 20060101) {
26 #include "TowerBug2005.txt"
28 for(
int i=0;i<4800;i++) {
30 if(TowerBugFixIndex[i]!=
id) {
31 int newId = TowerBugFixIndex[i];
32 TowerBugFixIndex[newId-1] = id;
37 for(
int i=0; i<4800; i++) PreshowerBugFixIndex[i] = i+1;
38 if(date >= 20060101 && date < 20071101) {
39 #include "PreshowerBug2007.txt"
41 for(
int i=0; i<4800; i++) {
43 if(PreshowerBugFixIndex[i] !=
id) {
44 int newId = PreshowerBugFixIndex[i];
45 PreshowerBugFixIndex[newId-1] = id;
50 for(
int i=0;i<18000;i++) SmdBugFixIndex[i] = i+1;
51 if(date >= 20100101 && date < 20110101) {
52 #include "SmdBug2010.txt"
58 void StEmcDecoder::SetDateTime(
unsigned int date,
unsigned int time) {
78 int id_new = TowerBugFixIndex[id_original - 1];
79 id_shift = id_new-id_original;
91 int id_new = PreshowerBugFixIndex[id_original - 1];
92 id_shift = id_new-id_original;
104 int id_new = SmdBugFixIndex[id_original - 1];
105 id_shift = id_new-id_original;
117 GetTowerBin(
const int TowerId,
int &module,
int &eta,
int &sub)
const {
118 if(TowerId<1 || TowerId>4800)
return 0;
119 if (!mapping)
return 0;
120 if (!mapping->bemc())
return 0;
121 module = mapping->bemc(TowerId).m;
122 eta = mapping->bemc(TowerId).e;
123 sub = mapping->bemc(TowerId).s;
132 if(TDC<0 || TDC>29)
return 0;
133 if (!mapping)
return 0;
134 if (!mapping->bemc())
return 0;
135 short id = mapping->softIdFromTDC(kBarrelEmcTowerId, TDC, 0);
136 crate = mapping->bemc(
id).crate;
145 if(crate<1 || crate>30)
return 0;
146 if (!mapping)
return 0;
147 if (!mapping->bemc())
return 0;
148 short id = mapping->softIdFromCrate(kBarrelEmcTowerId, crate, 0);
149 TDC = mapping->bemc(
id).TDC;
158 if (!mapping)
return 0;
159 if (!mapping->bemc())
return 0;
161 if((
id = mapping->softIdFromDaqId(kBarrelEmcTowerId, RDO))) {
162 TDC = mapping->bemc(
id).TDC;
175 if (!mapping)
return 0;
176 if (!mapping->bemc())
return 0;
178 if((
id = mapping->softIdFromDaqId(kBarrelEmcTowerId, RDO))) {
179 crate = mapping->bemc(
id).crate;
180 crate_sequency = mapping->bemc(
id).crateChannel;
191 if (!mapping)
return 0;
193 if((
id = mapping->softIdFromDaqId(kBarrelEmcTowerId, RDO))) {
205 if(TowerId<1 || TowerId >4800)
return 0;
206 if (!mapping)
return 0;
207 if (!mapping->bemc())
return 0;
208 RDO = mapping->bemc(TowerId).daqID;
219 if(crate < 1 || crate > 30)
return 0;
220 if(crate_sequency < 0 || crate_sequency > 159)
return 0;
221 if (!mapping)
return 0;
222 TowerId = mapping->softIdFromCrate(kBarrelEmcTowerId, crate, crate_sequency);
233 if(TDC < 0 || TDC > 29)
return 0;
234 if(tdc_sequency < 0 || tdc_sequency > 159)
return 0;
235 if (!mapping)
return 0;
236 TowerId = mapping->softIdFromTDC(kBarrelEmcTowerId, TDC, tdc_sequency);
247 if(CRATE < 1 || CRATE > 30)
return 0;
248 if(crate_seq < 0 || crate_seq > 159)
return 0;
249 if (!mapping)
return 0;
250 if (!mapping->bemc())
return 0;
251 short id = mapping->softIdFromCrate(kBarrelEmcTowerId, CRATE, crate_seq);
252 patchId = mapping->bemc(
id).triggerPatch;
263 if(PATCH<0 || PATCH>299)
return 0;
264 if (!mapping)
return 0;
265 if (!mapping->bemc())
return 0;
266 for(
int id=1;
id<=4800;
id++) {
267 if(mapping->bemc(
id).triggerPatch == PATCH) {
268 CRATE = mapping->bemc(
id).crate;
269 crate_seq = (PATCH%10)*16;
281 int &triggerPatch)
const
283 if(jetPatch<0 || jetPatch>11)
return 0;
284 if (!mapping)
return 0;
285 if (!mapping->bemc())
return 0;
286 for(
int id=1;
id<=4800;
id++) {
287 if(mapping->bemc(
id).jetPatch == jetPatch) {
288 triggerPatch = mapping->bemc(
id).triggerPatch;
303 int &jetPatch,
int &jetPatch_seq)
const
305 if (triggerPatch<0 || triggerPatch>299)
return 0;
306 if (!mapping)
return 0;
307 if (!mapping->bemc())
return 0;
308 for(
int id=1;
id<=4800;
id++) {
309 if(mapping->bemc(
id).triggerPatch == triggerPatch) {
310 jetPatch = mapping->bemc(
id).jetPatch;
318 if(patchId < 0 || patchId >= 300)
return 0;
319 dsmModule = patchId/10;
325 if(dsmModule < 0 || dsmModule >= 30)
return 0;
326 for(
int i=0; i<10; i++) {
327 triggerPatches[i] = dsmModule*10 + i;
342 int& RDO,
int& index)
const
344 if (!mapping)
return 0;
346 if (!mapping->bsmde())
return 0;
347 int id = mapping->softIdFromMES(kBarrelSmdEtaStripId, module, eta, sub);
348 RDO = mapping->bsmde(
id).rdo;
349 index = mapping->bsmde(
id).rdoChannel;
352 else if(detector == 4) {
353 if (!mapping->bsmdp())
return 0;
354 int id = mapping->softIdFromMES(kBarrelSmdPhiStripId, module, eta, sub);
355 RDO = mapping->bsmdp(
id).rdo;
356 index = mapping->bsmdp(
id).rdoChannel;
372 int& eta,
int& sub,
bool print)
const
375 return GetSmdCoord(RDO,index,detector,module,eta,sub,wire,A_value,print);
390 int& s,
int& wire,
int& A_value,
bool print)
const
392 if (!mapping)
return 0;
394 if((
id = mapping->softIdFromRDO(kBarrelSmdEtaStripId, RDO, index))) {
395 if (!mapping->bsmde())
return 0;
397 m = mapping->bsmde(
id).m;
398 e = mapping->bsmde(
id).e;
399 s = mapping->bsmde(
id).s;
400 wire = mapping->bsmde(
id).wire;
401 A_value = mapping->bsmde(
id).feeA;
404 else if((
id = mapping->softIdFromRDO(kBarrelSmdPhiStripId, RDO, index))) {
405 if (!mapping->bsmdp())
return 0;
407 m = mapping->bsmdp(
id).m;
408 e = mapping->bsmdp(
id).e;
409 s = mapping->bsmdp(
id).s;
410 wire = mapping->bsmdp(
id).wire;
411 A_value = mapping->bsmdp(
id).feeA;
427 int wire, A_value, PMT;
428 return GetPsdId(RDO, index,
id, PMT, wire, A_value, print);
444 int& wire,
int& A_value,
bool print)
const
446 if (!mapping)
return 0;
447 if (!mapping->bprs())
return 0;
448 if((softId = mapping->softIdFromRDO(kBarrelEmcPreShowerId, RDO, index))) {
449 PMTBox = mapping->bprs(softId).PMTbox;
450 wire = mapping->bprs(softId).wire;
451 A_value = mapping->bprs(softId).feeA;
463 if(id<1 || id>4800)
return 0;
464 if (!mapping)
return 0;
465 if (!mapping->bprs())
return 0;
466 RDO = mapping->bprs(
id).rdo;
467 index = mapping->bprs(
id).rdoChannel;
472 *out <<
"TDC channels connections\n";
473 *out <<
"-----------------------------------------------------------\n";
477 *out <<
"Tower MAP\n";
478 *out <<
"-----------------------------------------------------------\n";
479 for(
int daq =0;daq<4800;daq++)
481 int towerId,tdc,crate,position,m,e,s;
486 *out <<
" daq id = "<<daq<<
" TDC channel = "<<tdc<<
" Crate = "<<crate
487 <<
" position in crate = "<<position<<
" software id = "<<towerId
488 <<
" m = "<<m<<
" e = "<<e<<
" s = "<<s<<endl;
494 *out <<
"Modules connected to SMD crate\n";
495 *out <<
"-----------------------------------------------------------\n";
499 *out <<
"SMD CRATE number "<<i+1<<endl;
504 *out <<
"\nSMD MAP\n";
505 *out <<
"-----------------------------------------------------------\n";
509 *out <<
"SMD CRATE number "<<i+1<<endl;
510 for(
int index =0;index<4800;index++)
514 *out <<
" RDO = "<<i<<
" index = "<<index;
516 *out <<
" detector = "<<det<<
" mod = "<<m<<
" eta = "<<e
517 <<
" sub = "<<s<<endl;
519 *out <<
" dummy connection\n";
526 *out <<
"PMT Boxes connected to PSD crate\n";
527 *out <<
"-----------------------------------------------------------\n";
531 *out <<
"PSD CRATE number "<<i+1<<endl;
536 *out <<
"\nPSD MAP\n";
537 *out <<
"-----------------------------------------------------------\n";
541 *out <<
"PSD CRATE number "<<i+1<<endl;
542 for(
int index =0;index<4800;index++)
546 *out <<
" RDO = "<<i<<
" index = "<<index;
548 *out <<
" id = "<<
id<<endl;
550 *out <<
" dummy connection\n";
557 if(softId<1 || softId>4800)
return 0;
558 if (!mapping)
return 0;
559 if (!mapping->bemc())
return 0;
560 crate = mapping->bemc(softId).crate;
561 seq = mapping->bemc(softId).crateChannel;
566 if(softId<1 || softId>4800)
return 0;
567 if (!mapping)
return 0;
568 if (!mapping->bemc())
return 0;
569 TDC = mapping->bemc(softId).TDC;
574 if(softId<1 || softId>4800)
return 0;
575 if (!mapping)
return 0;
576 if (!mapping->bemc())
return 0;
577 patchId = mapping->bemc(softId).triggerPatch;
582 if(softId<1 || softId>4800)
return 0;
583 if (!mapping)
return 0;
584 if (!mapping->bemc())
return 0;
585 jetPatch = mapping->bemc(softId).jetPatch;
590 if( (m<1) || (m>120) )
return 0;
591 if( (e<1) || (e>20) )
return 0;
592 if( (s<1) || (s>2) )
return 0;
593 if (!mapping)
return 0;
594 softId = mapping->softIdFromMES(kBarrelEmcTowerId, m, e, s);
int GetSmdBugCorrectionShift(int id_original, int &shift) const
Returns the index shift for the SMD in original map.
int GetTriggerPatchFromCrate(int crate, int sequence, int &patchId) const
returns the trigger patch from crate and sequence in the crate
virtual ~StEmcDecoder()
StEmcDecoder destructor.
int GetJetPatchFromTowerId(int softId, int &jetPatch) const
Get jet patch that contains software Id.
int GetTowerBin(int softId, int &m, int &e, int &s) const
Convert from softId to m,e,s for towers only.
int GetTowerCrateFromTDC(int TDC, int &crate) const
Get crate number from TDC channel for towers.
void PrintPsdMap(ofstream *out) const
Print SMD MAP.
int GetTowerIdFromBin(int m, int e, int s, int &softId) const
Get Software Id from (m,e,s) space.
void PrintTowerMap(ofstream *out) const
Print Tower MAP.
void PrintSmdMap(ofstream *out) const
Print SMD MAP.
bool GetFixTowerMapBug(void) const
Shows if the tower map bug is being fixed on the fly.
int GetTriggerPatchFromJetPatch(int jetPatch, int sequence, int &patchId) const
returns the trigger patch from big jet patch and the sequence in it
int GetSmdCoord(int RDO, int posInFiber, int &det, int &m, int &e, int &s, bool print=false) const
Get SMD detector (3==SMDE, 4==SMDP), m, e, s from RDO and position for SMD.
int GetTowerTDCFromDaqId(int RDO, int &TDC) const
Get TDC channel from Daq Id for towers.
int GetTowerCrateFromDaqId(int RDO, int &crate, int &sequence) const
Get crate number from Daq Id for towers.
int GetTowerIdFromCrate(int crate, int sequence, int &softId) const
Get Software Id from Crate number and position in crate for towers.
int GetPreshowerBugCorrectionShift(int id_original, int &shift) const
Returns the index shift for the preshower in original map.
int GetTowerIdFromDaqId(int RDO, int &softId) const
Get Sofwtare Id from Daq Id for towers.
int GetCrateAndSequenceFromTriggerPatch(int patchId, int &crate, int &sequence) const
returns the crate number and start point for a given trigger patch
int GetPsdRDO(int softId, int &RDO, int &posInFiber) const
Get PSD fiber and position from id.
int GetCrateFromTowerId(int softId, int &crate, int &sequence) const
Get crate number and position in crate for Software Id.
int GetTowerIdFromTDC(int TDC, int sequence, int &softId) const
Get Software Id from TDC channel number and position in TDC for towers.
void SetDateTime(int date, int time)
St_db_Maker-compatible interface.
int GetJetPatchAndSequenceFromTriggerPatch(int patchId, int &jetPatch, int &sequence) const
return the big jet patch and sequence number within it from the
int GetTriggerPatchFromTowerId(int softId, int &patchId) const
Get trigger patch that contains software Id.
int GetTowerBugCorrectionShift(int id_original, int &shift) const
Returns the index shift for the tower in original map.
int GetPsdId(int RDO, int posInFiber, int &softId, bool print=false) const
Get PSD id.
int GetTowerTDCFromCrate(int crate, int &TDC) const
Get TDC channel from crate number for towers.
int GetSmdRDO(int detector, int m, int e, int s, int &RDO, int &posInFiber) const
Get SMD fiber and position from detector number (3==SMDE, 4==SMDP), m, e, s.
int GetDaqIdFromTowerId(int softId, int &RDO) const
Get Daq Id from Software Id for towers.
int GetTDCFromTowerId(int softId, int &TDC) const
Get TDC channel from Software Id.
void SetFixTowerMapBug(bool fix)
Sets the tower map bug fix.
int GetDSMFromTriggerPatch(int patchId, int &dsmModule) const
dsmModule is set to the DSM module containing this trigger patch (0-299)
int GetTriggerPatchesFromDSM(int dsmModule, int *triggerPatches) const
triggerPatches is an int[10]; contents will be set to the TPs of the supplied DSM # ...