StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEemcRaw.cxx
1 // $Id: StEemcRaw.cxx,v 1.19 2011/01/04 19:04:08 stevens4 Exp $
2 
3 #include <math.h>
4 #include <assert.h>
5 
6 #include <StMessMgr.h>
7 
8 #include <StEventTypes.h>
9 #include <StEvent.h>
10 
11 #include <StDAQMaker/StEEMCReader.h>
12 
13 #include <StEEmcUtil/database/StEEmcDb.h>
14 #include <StEEmcUtil/database/EEmcDbItem.h>
15 #include <StEEmcUtil/database/EEmcDbCrate.h>
16 
17 #include <StEEmcUtil/EEfeeRaw/EEfeeDataBlock.h> // for corruption tests
18 #include "StMuDSTMaker/EZTREE/EztEmcRawData.h"
19 
20 #include "StEemcRaw.h"
21 #include "StEmcRawMaker.h"
22 #include "DAQ_READER/daq_det.h"
23 #include "DAQ_ETOW/daq_etow.h"
24 #include "DAQ_ESMD/daq_esmd.h"
25 #include "DAQ_EMC/daq_emc.h"
26 #include "StChain/StRtsTable.h"
27 
28 ClassImp(StEemcRaw)
29 
30 //_____________________________________________________________________
32 {
33  mDb=0;
34  memset(hs,0,sizeof(hs));
35 }
36 
37 //___________________________________________________________
38 StEemcRaw::~StEemcRaw()
39 {
40 }
41 
42 //____________________________________________________
43 //____________________________________________________
44 //____________________________________________________
45 Bool_t StEemcRaw::make(StEmcRawMaker* maker, StEvent* mEvent){
46  if (hs[0])
47  hs[0]->Fill(0);
48 
49  StEmcRawData *eemcRaw = mEvent->emcCollection()->eemcRawData();
50 
51  if(!maker || !mDb || ! eemcRaw )
52  {
53  gMessMgr->Message("","W") << GetName()<<"::makeEemc() , some pointers are ZERO, code is sick, chain should be aborted, no EEMC data processed,JB :" <<maker << mDb << eemcRaw <<endm;
54  return false;
55  }
56 
57  if (hs[0])
58  hs[0]->Fill(1);
59  //::::::::::::::::: copy raw data to StEvent :::::::::::::
60  if(! copyRawData(maker, eemcRaw) )
61  return false;
62 
63  if(hs[0])
64  hs[0]->Fill(2);
65 
66  //::::::::::::::: assure raw data are sane ::::::::::::::::
67  StL0Trigger* trg=mEvent->l0Trigger();
68  if (! trg)
69  {
70  gMessMgr->Message("","W") << GetName()<<"::makeEemc() , l0Trigger data, EEMC not verified, abort all EEMC hits in StEvent EmcCollection, but raw data are saved" << endm;
71  return false;
72  }
73 
74 
75  int token=trg->triggerToken();
76  // printf("\nStL0Trigger::token=%d\n",token);
77  int runId=mEvent->runId();
78  int time=mEvent->time();
79 
80  if( headersAreSick(maker, eemcRaw, token, runId, time) )
81  return false;
82  if (hs[0])
83  hs[0]->Fill(3);
84 
85  if( towerDataAreSick( eemcRaw))
86  return false;
87  if (hs[0])
88  hs[0]->Fill(3);
89 
90  raw2pixels(mEvent);
91  return true;
92 
93 }
94 
95 Bool_t StEemcRaw::copyRawData(StEmcRawMaker* maker, StEmcRawData *raw)
96 {
97  StRtsTable* etow = maker->GetDaqElement("etow/adc");
98  int nb=0;
99  if(etow){
100  etow_t* etowdata = (etow_t*)*etow->begin();
101  for(int icr = 0; icr < ETOW_MAXFEE; icr++){
102  nb++;
103  const EEmcDbCrate *fiber = mDb->getFiber(icr);
104 
105  raw->createBank(icr,fiber->nHead,fiber->nCh);
106  for(int i = 0; i < fiber->nCh; i++){
107  raw->setData(icr,i,etowdata->adc[icr][i]);
108  //printf("agrdl: ETOW ADC %d %d %d\n",icr,i,etowdata->adc[icr][i]);
109  }
110  for(int i = 0; i < fiber->nHead; i++){
111  raw->setHeader(icr,i,etowdata->preamble[icr][i]);
112  //printf("agrdl: ETOW HEAD %d %d %d\n",icr,i,etowdata->preamble[icr][i]);
113  }
114  }
115  }else{
116  LOG_ERROR<<"ETOW Structure not found"<<endm;
117  }
118  StRtsTable* esmd = maker->GetDaqElement("esmd/adc");
119  if(esmd){
120  esmd_t* esmddata = (esmd_t*)*esmd->begin();
121  for(int icr = 0; icr < ESMD_MAXFEE;icr++){
122  nb++;
123  int id = icr + ETOW_MAXFEE;
124  const EEmcDbCrate *fiber = mDb->getFiber(id);
125 
126  raw->createBank(id,fiber->nHead,fiber->nCh);
127  for(int i = 0; i < fiber->nCh; i++){
128  raw->setData(id,i,esmddata->adc[icr][i]);
129  //printf("agrdl: ETOW ADC %d %d %d\n",id,i,esmddata->adc[icr][i]);
130  }
131  for(int i = 0; i < fiber->nHead; i++){
132  raw->setHeader(id,i,esmddata->preamble[icr][i]);
133  //printf("agrdl: ETOW HEAD %d %d %d\n",id,i,esmddata->preamble[icr][i]);
134  }
135  }
136  }else{
137  LOG_ERROR<<"ESMD Structure not found"<<endm;
138  }
139 
140  LOG_INFO << "StEemcRaw::copyRawData() "<<nb<<" data bloks copied" << endm;
141  return true;
142 }
143 
144 Bool_t StEemcRaw::headersAreSick(StEmcRawMaker* maker, StEmcRawData *raw, int token, int runId, int time)
145 {
146  if (! raw)
147  {
148  gMessMgr->Message("","W") << "StEemcRaw::headersAreSick() no EEMC raw data" << endm;
149  return true;
150  }
151 
152 
153  EEfeeDataBlock block; // use utility class as the work horse
154 
155  int icr;
156  int totErrBit=0;
157  int nOn=0;
158 
159  LOG_INFO << "StEemcRaw::headersAreSick() --> Nfibers=" << mDb->getNFiber() << endm;
160  //LOG_INFO << "StEemcRaw::headersAreSick() --> isEemcBankIn('T')=" << etow << endm;
161  //LOG_INFO << "StEemcRaw::headersAreSick() --> isEemcBankIn('S')=" << esmd << endm;
162 
163  for(icr=0;icr<mDb->getNFiber();icr++)
164  {
165  const EEmcDbCrate *fiber=mDb-> getFiber(icr);
166  if(!fiber->useIt)
167  continue; // drop masked out crates
168 
169  //if (fiber->type == 'T' && !etow) continue;
170  //if (fiber->type == 'S' && !esmd) continue;
171 
172  if(raw->sizeHeader(icr)<=0) {
173  LOG_WARN <<Form("StEemcRaw::headersAreSick() sizeHeader(icr=%d)<=0, crID=%d, skip it\n",icr,fiber->crID)<<endm;
174  continue; //drop cartes not present in data blocks
175  }
176  // printf(" EEMC raw-->pix crID=%d type=%c \n",fiber->crID,fiber->type);
177 
178  int isOff=EztEmcRawData::isCrateOFF(raw->header(icr));
179  // printf("AAA icr=%d isOff=%d\n",icr,isOff);
180  if(isOff)
181  { // kill this fiber for the rest of this job
182  mDb->setFiberOff(icr);
183  LOG_WARN << "StEemcRaw::headersAreSick() detected icr="<<icr<< ", name="<<fiber->name<<" is OFF,\n this fiber will ignored till the end of this job" << endm;
184  continue;
185  }
186  nOn++;
187  block.clear();
188  block.setHead(raw->header(icr));
189 
190  int lenCount=fiber->nCh+fiber->nHead;
191  int errFlag=0;
192 
193  if(fiber->type=='T')
194  lenCount+=32; // one more board exist in harware
195 
196  if(fiber->type=='S' && time<1104537600 && runId<6000000)
197  errFlag=0x28; // bug in box firmawer prior to 2005
198 
199  //HACK^2 - disable token check, March 22, 2007
200  //token=block.getToken();
201  // end of hack, Jan B.
202 
203  int trigCommand=4; // physics, 9=laser/LED, 8=??
204  int sanity=block.isHeadValid(token,fiber->crIDswitch,lenCount,trigCommand,errFlag);
205  if(0){
206  block.print(1);
207  cout<<(short)block.getCrateID()<<" "<<fiber->crIDswitch<<" :::: "<<block.getLenCount()<<" "<<lenCount<<" :::: "<<block.getTrigComm()<<" "<<trigCommand<<" :::: "<<block.getErrFlag()<<" "<<errFlag<<endl;
208  }
209  //printf("Endcap crate=%d token=%d\n",fiber->crID,block.getToken());
210  int i;
211  for(i=0;i<8;i++)
212  {// examin & histo all sanity bits
213  if(!(sanity&(1<<i)))
214  continue;
215  totErrBit++;
216  int k=icr*10+i;
217  // printf("ic=%d on bit=%d k=%d %d %d \n",ic,i,k,1<<i,sn&(1<<i) );
218  if (hs[3])
219  hs[3]->Fill(k);
220  }
221  LOG_DEBUG << GetName()<<"::checkHeader("<<fiber->name<<"), errorCode="<<sanity<<endm;
222  if(sanity) LOG_WARN << GetName()<<"::checkHeader("<<fiber->name<<"), errorCode="<<sanity<<endm;
223  }
224 
225  if (hs[4])
226  hs[4]->Fill(totErrBit);
227 
228  LOG_INFO<< GetName()<<"::checkHeader --> totErrBit "<<totErrBit<<" in "<<nOn<<" crates"<<endm;
229  return totErrBit;
230 }
231 
235 
236 Bool_t StEemcRaw::make(StEEMCReader *eeReader, StEvent* mEvent){
237  // printf("JB make() EEMC\n");
238 
239  if (hs[0])
240  hs[0]->Fill(0);
241 
242  StEmcRawData *eemcRaw = mEvent->emcCollection()->eemcRawData();
243 
244  if(!eeReader || !mDb || ! eemcRaw )
245  {
246  gMessMgr->Message("","W") << GetName()<<"::makeEemc() , some pointers are ZERO, code is sick, chain should be aborted, no EEMC data processed,JB :" <<eeReader << mDb << eemcRaw <<endm;
247  return false;
248  }
249 
250  if (hs[0])
251  hs[0]->Fill(1);
252  //::::::::::::::::: copy raw data to StEvent :::::::::::::
253  if(! copyRawData(eeReader, eemcRaw) )
254  return false;
255 
256  if(hs[0])
257  hs[0]->Fill(2);
258 
259  //::::::::::::::: assure raw data are sane ::::::::::::::::
260  StL0Trigger* trg=mEvent->l0Trigger();
261  if (! trg)
262  {
263  gMessMgr->Message("","W") << GetName()<<"::makeEemc() , l0Trigger data, EEMC not verified, abort all EEMC hits in StEvent EmcCollection, but raw data are saved" << endm;
264  return false;
265  }
266 
267 
268  int token=trg->triggerToken();
269  // printf("\nStL0Trigger::token=%d\n",token);
270  int runId=mEvent->runId();
271  int time=mEvent->time();
272 
273  if( headersAreSick(eeReader, eemcRaw, token, runId, time) )
274  return false;
275  if (hs[0])
276  hs[0]->Fill(3);
277 
278  if( towerDataAreSick( eemcRaw))
279  return false;
280  if (hs[0])
281  hs[0]->Fill(3);
282 
283  raw2pixels(mEvent);
284  return true;
285 }
286 
287 //____________________________________________________
288 //____________________________________________________
289 //____________________________________________________
290 Bool_t StEemcRaw::copyRawData(StEEMCReader *eeReader, StEmcRawData *raw)
291 {
292  int nb=0;
293  int icr;
294  for(icr=0;icr<mDb->getNFiber();icr++)
295  {
296  const EEmcDbCrate *fiber=mDb-> getFiber(icr);
297  if(!eeReader->isEemcBankIn(fiber->type))
298  continue;
299  nb++;
300  // printf("copy EEMC raw: ");fiber->print();
301  raw->createBank(icr,fiber->nHead,fiber->nCh);
302  raw->setHeader(icr,eeReader->getEemcHeadBlock(fiber->fiber,fiber->type));
303  raw->setData(icr,eeReader->getEemcDataBlock(fiber->fiber,fiber->type));
304  }
305  gMessMgr->Message("","I") << "StEemcRaw::copyRawData() "<<nb<<" data bloks copied" << endm;
306  return true;
307 }
308 
309 
310 //____________________________________________________
311 //____________________________________________________
312 //____________________________________________________
313 Bool_t StEemcRaw::headersAreSick(StEEMCReader *eeReader, StEmcRawData *raw, int token, int runId, int time)
314 {
315 
316  if (! raw)
317  {
318  gMessMgr->Message("","W") << "StEemcRaw::headersAreSick() no EEMC raw data" << endm;
319  return true;
320  }
321 
322 
323  EEfeeDataBlock block; // use utility class as the work horse
324 
325  int icr;
326  int totErrBit=0;
327  int nOn=0;
328 
329  LOG_INFO << "StEemcRaw::headersAreSick() --> Nfibers=" << mDb->getNFiber() << endm;
330  LOG_INFO << "StEemcRaw::headersAreSick() --> isEemcBankIn('T')=" << eeReader->isEemcBankIn('T') << endm;
331  LOG_INFO << "StEemcRaw::headersAreSick() --> isEemcBankIn('S')=" << eeReader->isEemcBankIn('S') << endm;
332 
333  for(icr=0;icr<mDb->getNFiber();icr++)
334  {
335  const EEmcDbCrate *fiber=mDb-> getFiber(icr);
336  if(!fiber->useIt)
337  continue; // drop masked out crates
338 
339  if (fiber->type == 'T' && !eeReader->isEemcBankIn('T')) continue;
340  if (fiber->type == 'S' && !eeReader->isEemcBankIn('S')) continue;
341 
342  if(raw->sizeHeader(icr)<=0) {
343  gMessMgr->Message("","W") <<Form("StEemcRaw::headersAreSick() sizeHeader(icr=%d)<=0, crID=%d, skip it\n",icr,fiber->crID)<<endm;
344  continue; //drop cartes not present in data blocks
345  }
346  // printf(" EEMC raw-->pix crID=%d type=%c \n",fiber->crID,fiber->type);
347 
348  int isOff=EztEmcRawData::isCrateOFF(raw->header(icr));
349  // printf("AAA icr=%d isOff=%d\n",icr,isOff);
350  if(isOff)
351  { // kill this fiber for the rest of this job
352  mDb->setFiberOff(icr);
353  gMessMgr->Message("","W") << "StEemcRaw::headersAreSick() detected icr="<<icr<< ", name="<<fiber->name<<" is OFF,\n this fiber will ignored till the end of this job" << endm;
354  continue;
355  }
356  nOn++;
357  block.clear();
358  block.setHead(raw->header(icr));
359 
360  int lenCount=fiber->nCh+fiber->nHead;
361  int errFlag=0;
362 
363  if(fiber->type=='T')
364  lenCount+=32; // one more board exist in harware
365 
366  if(fiber->type=='S' && time<1104537600 && runId<6000000)
367  errFlag=0x28; // bug in box firmawer prior to 2005
368 
369  //HACK^2 - disable token check, March 22, 2007
370  //token=block.getToken();
371  // end of hack, Jan B.
372 
373  int trigCommand=4; // physics, 9=laser/LED, 8=??
374  int sanity=block.isHeadValid(token,fiber->crIDswitch,lenCount,trigCommand,errFlag);
375  //printf("Endcap crate=%d token=%d\n",fiber->crID,block.getToken());
376  int i;
377  for(i=0;i<8;i++)
378  {// examin & histo all sanity bits
379  if(!(sanity&(1<<i)))
380  continue;
381  totErrBit++;
382  int k=icr*10+i;
383  // printf("ic=%d on bit=%d k=%d %d %d \n",ic,i,k,1<<i,sn&(1<<i) );
384  if (hs[3])
385  hs[3]->Fill(k);
386  }
387  LOG_DEBUG << GetName()<<"::checkHeader("<<fiber->name<<"), errorCode="<<sanity<<endm;
388  if(sanity) LOG_WARN << GetName()<<"::checkHeader("<<fiber->name<<"), errorCode="<<sanity<<endm;
389  }
390 
391  if (hs[4])
392  hs[4]->Fill(totErrBit);
393 
394  gMessMgr->Message("","I") << GetName()<<"::checkHeader --> totErrBit "<<totErrBit<<" in "<<nOn<<" crates"<<endm;
395  return totErrBit;
396 }
397 
398 
399 //____________________________________________________
400 //____________________________________________________
401 //____________________________________________________
402 Bool_t StEemcRaw::towerDataAreSick(StEmcRawData* raw)
403 {
404  const int mxN256one=5;
405  const int mxN256tot=40; // may need to be changed for 2005 data with more MAPMT crates, JB
406 
407  int nGhostTot=0, n256Tot=0;
408  int icr;
409  for(icr=0;icr<mDb->getNFiber();icr++)
410  {
411  const EEmcDbCrate *fiber=mDb-> getFiber(icr);
412  if(!fiber->useIt)
413  continue; // drop masked out crates
414  if(fiber->type!='T')
415  continue;
416  const UShort_t* data=raw->data(icr);
417  //assert(data);
418  int i;
419  int nGhost=0, n256=0;
420  for(i=0;i<raw->sizeData(icr);i++)
421  {
422  if((data[i] &0xff)==0 )
423  n256++;
424  if(i>=121 && data[i]>40)
425  nGhost++;
426  }
427  nGhostTot+=nGhost;
428  n256Tot+=n256;
429  if(nGhost>0)
430  {
431  int k=icr*10+5;
432  if (hs[3])
433  hs[3]->Fill(k);
434  }
435  if(n256>mxN256one)
436  {
437  int k=icr*10+6;
438  if (hs[3])
439  hs[3]->Fill(k);
440  }
441 
442  }
443 
444  if(hs[1])
445  hs[1]->Fill(n256Tot);
446  if(hs[2])
447  hs[2]->Fill(nGhostTot);
448 
449  gMessMgr->Message("","I") << GetName()<<"::checkTowerAdc-->total n256="<<n256Tot <<", nGhost="<<nGhostTot<<endm;
450  if(nGhostTot>0)
451  return true;
452  if(n256Tot>mxN256tot)
453  return true;
454  return false;
455 }
456 
457 
458 //____________________________________________________
459 //____________________________________________________
460 //____________________________________________________
461 void StEemcRaw::raw2pixels(StEvent* mEvent)
462 {
463 
464  StEmcCollection* emcC =(StEmcCollection*)mEvent->emcCollection();
465  if(emcC==0)
466  {
467  gMessMgr->Message("","W") << GetName()<<"::raw2pixels() no emc collection, skip"<<endm;
468  return ;
469  }
470 
471  StEmcRawData* raw=emcC->eemcRawData();
472  if (! raw)
473  {
474  gMessMgr->Message("","W") << "StEemcRaw::raw2pixels() no EEMC raw data" << endm;
475  return;
476  }
477 
478  // initialize tower/prePost /U/V in StEvent
479 
480  StEmcDetector* emcDet[kEndcapSmdVStripId+1]; // what a crap,JB
481  StDetectorId emcId[kEndcapSmdVStripId+1]; // more crap
482  memset(emcDet,0,sizeof(emcDet));
483 
484  int det;
485  for(det = kEndcapEmcTowerId; det<= kEndcapSmdVStripId; det++)
486  {
487  emcId[det] = StDetectorId(det);
488  emcDet[det] = new StEmcDetector(emcId[det],MaxSectors);
489  emcC->setDetector(emcDet[det]);
490  }
491 
492  gMessMgr->Message("","I") << GetName()<<"::raw2pixels() collections created"<<endm;
493 
494  // store data from raw blocks to StEvent
495  int nDrop=0;
496  int nMap=0;
497  int nTow=0, nPre=0,nSmd=0;
498  int icr;
499  for(icr=0;icr<mDb->getNFiber();icr++)
500  {
501  const EEmcDbCrate *fiber=mDb-> getFiber(icr);
502  if(!fiber->useIt)
503  continue; // drop masked out crates
504 
505  const UShort_t* data=raw->data(icr);
506  //assert(data);
507 
508  for(int chan=0;chan<raw->sizeData(icr);chan++)
509  {
510  const EEmcDbItem *x=mDb->getByCrate(fiber->crID,chan);
511  if(x==0)
512  {
513  //printf("No EEMC mapping for crate=%3d chan=%3d\n",crate,chan);
514  nDrop++;
515  continue;
516  }
517 
518  int det = 0;
519  char type=x->name[2];
520  int sec=x->sec; //range 1-12
521  int sub=1+x->sub-'A'; //range 1-5
522  int eta=x->eta; //range 1-12
523 
524  int rawAdc=data[chan];
525  float energy=123.456; // dumm value, calib & peds are not known
526 
527  switch(type)
528  { // tw/pre/post/SMD
529  case 'T': // towers
530  det = kEndcapEmcTowerId;
531  nTow++;
532  break;
533  case 'P': // pres1
534  case 'Q': // pres2
535  case 'R': // post
536  sub+=5* (type-'P'); // pack pre1,2,post together
537  det = kEndcapEmcPreShowerId;
538  nPre++;
539  break;
540  case 'U': //SMD
541  case 'V':
542  sub=1; // not used for SMD
543  eta=x->strip; //range 1-288
544  nSmd++;
545  det = kEndcapSmdUStripId;
546  if(type=='V')
547  det = kEndcapSmdVStripId;
548  break;
549  default:
550  continue;
551  }
552 
553  //assert(det);
554  if (! det)
555  {
556  gMessMgr->Message("","W") << "StEemcRaw::raw2pixels(), logic error2, skip" << endm;
557  return;
558  }
559 
560  // if(type=='T') printf("EEMC crate=%3d chan=%3d ADC: raw=%4d energy=%+10g --> %2.2dT%c%2.2d\n",fiber->crID,chan,rawAdc,energy,x->sec,x->sub,x->eta);
561 
562  StEmcRawHit* h = new StEmcRawHit(emcId[det],sec,eta,sub,rawAdc,energy);
563  emcDet[det]->addHit(h);
564  nMap++;
565 
566  } // end of loop over channels
567  }// end of loop over crates
568 
569 
570  gMessMgr->Message("","I") << GetName()<<"::raw2pixels() finished nDrop chan="<< nDrop<<",nMap="<< nMap<<",nTow="<<nTow <<",nPre="<<nPre <<", nSmd="<<nSmd <<endm;
571 
572 }
573 
574 
575 //__________________________________________________
576 //__________________________________________________
577 //__________________________________________________
578 void StEemcRaw::initHisto()
579 {
580 
581  hs[0]= new TH1F("EndcapHealth","raw data health; X: 0=nEve, 1=raw, 2=OKhead , 3=tower(No ghost/n256)",9,-1.5,7.5);
582 
583  hs[1]= new TH1F("EndcapN256","No. of n256/eve, all header OK",100, -1.5,98.5);
584  hs[2]= new TH1F("EndcapGhost","No. of tower nGhost/eve, all header OK, chan>119",100,-1.5,98.5);
585 
586  hs[3]=new TH1F("EndcapCorrBytes","sanity, crates Tw cr=0-5, Mapmt cr=6-53, X= bits(cr)+ cr*10;bits: 0=crID, 1=token,2=len,3=trgCom,4=ErrFlg,5=Ghost,6=n256 ",540,-0.5,539.5);
587 
588  hs[4]=new TH1F("EndcapCorrTot","total # of corruption bits in Headers per eve",220,-0.5,219.5);
589 
590  return;
591 }
592 
593 
594 // $Log: StEemcRaw.cxx,v $
595 // Revision 1.19 2011/01/04 19:04:08 stevens4
596 // added event time to EEMC header check
597 //
598 // Revision 1.18 2009/05/06 14:25:54 mattheww
599 // changed a threshold in EEMC
600 //
601 // Revision 1.17 2009/03/23 21:08:32 mattheww
602 // Update default BPRS ZS handling and fix EEMC minor bug
603 //
604 // Revision 1.16 2009/02/04 21:05:42 kocolosk
605 // Refactor StEEmcDb(Maker), new location for StEmcDecoder. Fixes RT #1388.
606 //
607 // Revision 1.15 2009/01/27 19:58:36 mattheww
608 // Updates to StEmcRawMaker to be compatible with 2009 DAQ Format
609 //
610 // Revision 1.14 2008/01/10 20:49:58 balewski
611 // now more warnings if ESMD is not in the run, thanks Pibero
612 //
613 // Revision 1.13 2007/04/11 03:29:11 balewski
614 // undo hacks,
615 // Endcap code is now in default configuration
616 //
617 // Revision 1.12 2007/03/23 02:18:00 balewski
618 // drop token check, temporay hack
619 //
620 // Revision 1.11 2006/12/22 15:20:59 balewski
621 // more printouts
622 //
623 // Revision 1.10 2006/07/21 14:15:09 balewski
624 // less printouts
625 //
626 // Revision 1.9 2006/01/16 11:12:00 suaide
627 // tower map bug fixed and astyle run
628 //
629 // Revision 1.8 2005/08/17 20:59:32 balewski
630 // cleanup
631 //
632 // Revision 1.7 2005/08/17 20:50:44 balewski
633 // drop only crates which are off insetad of the whole event
634 //
635 // Revision 1.6 2005/05/04 22:02:08 balewski
636 // more clear printouts
637 //
638 // Revision 1.5 2005/02/03 02:35:11 balewski
639 // accomodate MAPMT firmware change in 2005
640 //
641 // Revision 1.4 2005/01/08 03:55:36 balewski
642 // logic was too conservative
643 //
644 // Revision 1.3 2004/11/14 21:55:52 jeromel
645 // Unit var initialized (++ used later)
646 //
647 // Revision 1.2 2004/10/21 00:01:50 suaide
648 // small changes in histogramming and messages for BEMC
649 // Complete version for EEMC done by Jan Balewski
650 //
651 // Revision 1.1 2004/10/19 23:48:49 suaide
652 // Initial implementation of the endcap detector done by Jan Balewski
653 //
654 
655 //.........old pieces of code use for some tests .......................
656 
657 
658 
659 #if 0 // test of tower data storage
660 {
661  int det= kEndcapEmcTowerId;
662  int eta,sub=1,sec=12;
663  for(sec=1;sec<=12;sec++)
664  for(sub=1;sub<=5;sub++)
665  for(eta=1;eta<=12;eta++)
666  {
667  int adc=1000+ (eta-1) + (sub-1)*12 +(sec-1)*60;
668  float ener=777;
669  StEmcRawHit* h = new StEmcRawHit(emcId[det], sec,eta,sub,adc,ener);
670  emcDet[det]->addHit(h);
671  }
672 }
673 #endif
674 
675 
676 
677 #if 0 // test of Pre/post data storage
678 {
679  int det= kEndcapEmcPreShowerId;
680  int eta,sub,sec=12, pre=1;
681  for(pre=1;pre<=3;pre++)
682  for(sec=1;sec<=12;sec++)
683  for(sub=1;sub<=5;sub++)
684  for(eta=1;eta<=12;eta++)
685  {
686  int ssub=sub + 5*(pre-1);
687  int adc= eta-1 + (sub-1)*12 +(sec-1)*60 +pre*1000;
688  StEmcRawHit* h = new StEmcRawHit(emcId[det], sec,eta,ssub,adc);
689  emcDet[det]->addHit(h);
690  }
691 }
692 #endif
693 
694 
695 
696 #if 0 // test of U-smd data storage
697 {
698  det = kEndcapSmdUStripId;
699  int eta,sub=1,sec=12;
700  for(sec=1;sec<=12;sec++)
701  for(eta=1;eta<=288;eta++)
702  {
703  int adc= 1000 + eta-1 +(sec-1)*300;
704  StEmcRawHit* h = new StEmcRawHit(emcId[det], sec,eta,sub,adc);
705  emcDet[det]->addHit(h);
706  }
707 }
708 
709 for(det = kEndcapEmcTowerId; det<= kEndcapSmdVStripId; det++)
710 {
711  StEmcDetector* emcDetX= emcC->detector( StDetectorId(det));
712  // assert(emcDetX);
713  gMessMgr->Message("","I") <<" StEmcDetectorID="<< StDetectorId(det)<<" nHits="<<emcDetX->numberOfHits()<<endm;
714 }
715 
716 
717 
718 #endif
719 
720 
721 
722 #if 0 // test of new access method
723 
724 for(icr=0;icr<mDb->getNCrate();icr++)
725 {
726  const EEmcDbCrate *crate=mDb-> getCrate(icr);
727  printf("geting data for fiber: ");
728  crate->print();
729 
730  printf("---- HEAD ----\n");
731  for(ch=0;ch<crate->nHead;ch++)
732  {
733  int val=-1;
734  val=steemcreader->getEemcHead(crate->fiber,ch,crate->type);
735  printf("cr=%d ch=%d val=0x%04x\n",crate->crID,ch,val);
736  }
737 
738  printf("---- DATA ----\n");
739  for(ch=0;ch<crate->nch;ch++)
740  {
741  int val=-1;
742  val=steemcreader->getEemcData(crate->fiber,ch,type);
743  printf("cr=%d ch=%d val=0x%04x\n",crate->crID,ch,val);
744  }
745  // break;
746 }
747 #endif
748 
749 
int nCh
no. of valid channels for the crate
Definition: EEmcDbCrate.h:16
char name[StEEmcNameLen]
ASCII name of the channel, see Readme.
Definition: EEmcDbItem.h:20
int nHead
no. of header words
Definition: EEmcDbCrate.h:17
int useIt
flag to ignore data from misconfig/broken crate/box
Definition: EEmcDbCrate.h:19
char name[CrateNameLen]
crT1,... for towers, 06S1,... for mapmt
Definition: EEmcDbCrate.h:12
Definition: daq_etow.h:9
int fiber
position of the crate in the .daq data stream, couting from 0
Definition: EEmcDbCrate.h:15
char type
is &#39;T&#39; for towers &amp; &#39;S&#39; for MAPMT
Definition: EEmcDbCrate.h:18
int crIDswitch
crate ID set by hardware switch
Definition: EEmcDbCrate.h:14
int crID
logical crate ID
Definition: EEmcDbCrate.h:13