StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StECalEnergyIter.cxx
1 //*-- Author : Robert Cadman
2 
3 
4 #include "StECalEnergyIter.h"
5 #include "StMuDSTMaker/COMMON/StMuEmcCollection.h"
6 #include "StMuDSTMaker/COMMON/StMuEmcHit.h"
7 #include "StEEmcUtil/database/StEEmcDb.h"
8 #include "StEEmcUtil/database/EEmcDbItem.h"
9 #include "TMath.h"
10 
11 bool StECalEnergyIter::mIsSimu = false;
12 
13 StECalEnergyIter::StECalEnergyIter(StMuEmcCollection *emCol, int det, StEEmcDb *db, bool flag)
14  : mEmCol(emCol), mEEdb(db), mdetector(det), mIhits(0), mSuppBad(flag) {
15 
16  char cuv = 'U';
17  switch (mdetector)
18  {
19  case eemc:
20  mNhits = mEmCol->getNEndcapTowerADC();
21  break;
22  case eprs:
23  mNhits = mEmCol->getNEndcapPrsHits();
24  break;
25  case esmdv:
26  cuv = 'V'; // and fall through
27  case esmdu:
28  mNhits = mEmCol->getNEndcapSmdHits(cuv);
29  break;
30  default:
31  mNhits = 0;
32  }
33 }
34 
35 
36 bool StECalEnergyIter::next(float &e, int &adc, int &adclessped,
37  int &sec, int &eta, int &phi, char &cdet)
38 {
39  const EEmcDbItem *dbitem;
40  cdet = 'U';
41  bool dbfail;
42 
43  do {
44  if ( mNhits <= mIhits ) return false;
45  switch (mdetector)
46  {
47  case eemc:
48  mEmCol->getEndcapTowerADC(mIhits++, adc, sec, phi, eta);
49  cdet = 'T';
50  dbitem = mEEdb->getTile(sec, phi-1+'A', eta, cdet);
51  break;
52  case eprs:
53  int prsId;
54  adc = mEmCol->getEndcapPrsHit(mIhits++, sec, phi, eta,
55  prsId)->getAdc();
56  cdet = prsId-1+'P';
57  dbitem = mEEdb->getTile(sec, phi-1+'A', eta, cdet);
58  break;
59  case esmdv:
60  cdet = 'V'; // and fall through
61  case esmdu:
62  adc = mEmCol->getEndcapSmdHit(cdet, mIhits++, sec, eta)->getAdc();
63  dbitem = mEEdb->getByStrip(sec, cdet, eta);
64  break;
65  default:
66  return false;
67  }
68  dbfail = ( !dbitem || dbitem->fail || dbitem->gain < 0.5 );
69  } while ( mSuppBad && dbfail );
70 
71  if ( dbfail )
72  {
73  e = - 100.0;
74  adclessped = adc;
75  }
76  else
77  {
78  float acorr = adc - dbitem->ped;
79  e = acorr/dbitem->gain;
80  if ( mIsSimu && mdetector == eemc ) e *= 1.25;
81  adclessped = (int) TMath::Floor(acorr + 0.5);
82  }
83 
84  return true;
85 }
int getAdc() const
Return ADC value.
Definition: StMuEmcHit.h:19