StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StBemcData.cxx
1 #include "StBemcData.h"
2 #include "StEmcUtil/database/StEmcDecoder.h"
3 #include "StEmcUtil/geometry/StEmcGeom.h"
4 #include "StEventTypes.h"
5 #include "StEvent.h"
6 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
7 #include "StMuDSTMaker/COMMON/StMuDst.h"
8 
9 ClassImp(StBemcData)
10 
11 //_____________________________________________________________________________
12 /*
13  Default constructor. Set Initial values for some variables
14 */
16 {
17  Int_t calib[] = {1, 1, 1, 1, 0, 0, 0, 0};
18  Int_t pedSub[] = {1, 1, 1, 1, 0, 0, 0, 0};
19  Float_t cut[] = {-1, 1.5, 1.5, 1.5, -1, -1, -1, -1};
20  Int_t cutType[] = {0, 1, 1, 1, 0, 0, 0, 0};
21  Int_t onlyCal[] = {0, 0, 0, 0, 0, 0, 0, 0};
22  Int_t status[] = {1, 1, 1, 1, 0, 0, 0, 0};
23  Int_t crate[] = {1, 1, 1, 1, 0, 0, 0, 0};
24 
25  for(Int_t i=0; i<MAXDETBARREL; i++)
26  {
27  mControlADCtoE->Calibration[i]=calib[i];
28  mControlADCtoE->DeductPedestal[i]=pedSub[i];
29  mControlADCtoE->CutOff[i]=cut[i];
30  mControlADCtoE->CutOffType[i]=cutType[i];
31  mControlADCtoE->OnlyCalibrated[i]=onlyCal[i];
32  mControlADCtoE->CheckStatus[i]=status[i];
33  mControlADCtoE->CheckCrate[i]=crate[i];
34  }
35 
36  mPsdMapBug2 = kTRUE;
37  mTowerMapBug = kTRUE;
38  mSmdMapBug = kTRUE;
39 
40  // correct DB tables for swapping
41  delete mTables;
42  mTables = new StBemcTables(kTRUE, kTRUE);
43 
44 }
45 //_____________________________________________________________________________
50 {}
51 Bool_t StBemcData::make(StEmcRawData* emcraw, StEvent* event)
52 {
53  return StBemcRaw::make(emcraw,event);
54 }
55 Bool_t StBemcData::make(TDataSet* DS, StEvent* event)
56 {
57  return StBemcRaw::make(DS,event);
58 }
60 {
61  if(!emc)
62  return kFALSE;
63  if(!event)
64  return kFALSE;
65  StEmcCollection *emcN = event->emcCollection();
66  if(!emcN)
67  {
68  emcN = emc;
69  event->setEmcCollection(emcN);
70  }
71 
72  Int_t ADC[MAXDETBARREL][BSMDCH];
73  Int_t CRATE[MAXDETBARREL][BSMDCH];
74  Int_t CAP[MAXDETBARREL][BSMDCH];
75  Int_t ID[MAXDETBARREL][BSMDCH];
76  Int_t NH[MAXDETBARREL];
77  Int_t Crate,RDO,Index,Daq;
78  Int_t S;
79  Float_t E;
80  for(Int_t det=1;det<=MAXDETBARREL;det++)
81  {
82  StDetectorId id = static_cast<StDetectorId>(det+kBarrelEmcTowerId-1);
83  NH[det-1] = 0;
84  StEmcDetector* detector=emc->detector(id);
85  mNCRATESOK[det-1]=0;
86  if(detector)
87  {
88  mIsCorrupted[det-1]=kFALSE;
89  for(Int_t crate=1;crate<=MAXCRATES;crate++)
90  {
91  mCrateStatus[det-1][crate-1] = (Int_t)detector->crateStatus(crate);
92  if(mCrateStatus[det-1][crate-1]==crateOK)
93  mNCRATESOK[det-1]++;
94  if(mCrateStatus[det-1][crate-1]==crateHeaderCorrupt)
95  mIsCorrupted[det-1] = kTRUE;
96  }
97 
98  StEmcGeom* geo = StEmcGeom::instance(det);
99  for(UInt_t j=1;j<=BEMCMODULES;j++)
100  {
101  StEmcModule* module = detector->module(j);
102  if(module)
103  {
104  StSPtrVecEmcRawHit& rawHit=module->hits();
105  for(UInt_t k=0;k<rawHit.size();k++)
106  {
107  Int_t m=rawHit[k]->module();
108  Int_t e=rawHit[k]->eta();
109  Int_t s=abs(rawHit[k]->sub());
110  Int_t adc=rawHit[k]->adc();
111  Int_t cap=rawHit[k]->calibrationType();
112  while(cap>127)
113  cap-=128;
114  Int_t id;
115  geo->getId(m,e,s,id);
116  ID[det-1][NH[det-1]] = id;
117  ADC[det-1][NH[det-1]] = adc;
118  CAP[det-1][NH[det-1]] = cap;
119  if(det==BTOW)
120  {
121  mDecoder->GetDaqIdFromTowerId(id,Daq);
122  mDecoder->GetTowerCrateFromDaqId(Daq,Crate,Index);
123  }
124  else if(det==BPRS)
125  {
126  mDecoder->GetPsdRDO(id,RDO,Index);
127  Crate = RDO+1;
128  }
129  else if(det==BSMDE || det == BSMDP)
130  {
131  mDecoder->GetSmdRDO(det,m,e,s,RDO,Index);
132  Crate = RDO+1;
133  }
134  CRATE[det-1][NH[det-1]] = Crate;
135  NH[det-1]++;
136  }
137  }
138  }
139  }
140  }
141  emptyEmcCollection(emcN);
142  for(Int_t det=1;det<=MAXDETBARREL;det++)
143  {
144  clearStats(det);
145  for(Int_t i = 0;i<NH[det-1];i++)
146  {
147  S = makeHit(emcN,det,ID[det-1][i],ADC[det-1][i],CRATE[det-1][i],CAP[det-1][i],E);
148  updateStats(det,S,ADC[det-1][i],E);
149  }
150  printStats(det);
151  }
152  return kTRUE;
153 }
155 {
156  if(!muEmc)
157  return kFALSE;
158  if(!event)
159  return kFALSE;
160  StEmcCollection *emc = event->emcCollection();
161  if(!emc)
162  return kFALSE;
163  emptyEmcCollection(emc);
164 
165  for(Int_t det=1;det<=MAXDETBARREL;det++)
166  {
167  clearStats(det);
168  mNCRATESOK[det-1]=0;
169  StDetectorId did = static_cast<StDetectorId>(det+kBarrelEmcTowerId-1);
170  StEmcDetector* detector=emc->detector(did);
171  mIsCorrupted[det-1]=kFALSE;
172  for(Int_t crate = 1;crate<=MAXCRATES;crate++)
173  {
174  mCrateStatus[det-1][crate-1] = (Int_t)muEmc->getCrateStatus(crate,det);
175  if(mCrateStatus[det-1][crate-1]==crateOK)
176  mNCRATESOK[det-1]++;
177  if(mCrateStatus[det-1][crate-1]==crateHeaderCorrupt)
178  mIsCorrupted[det-1] = kTRUE;
179  if(detector)
180  detector->setCrateStatus(crate,(StEmcCrateStatus)mCrateStatus[det-1][crate-1]);
181  }
182  StEmcGeom* geo = StEmcGeom::instance(det);
183  Int_t nh=0;
184  Int_t ADC=0,ID=0,CRATE=0,RDO=0,INDEX=0,CAP=0,DAQ=0;
185  Int_t m=0,e=0,s=0;
186  Float_t E=0;
187  Int_t S=0;
188  if (det==BTOW)
189  nh = BTOWCH;
190  if (det==BPRS)
191  nh=muEmc->getNPrsHits(det);
192  if (det==BSMDE || det==BSMDP)
193  nh=muEmc->getNSmdHits(det);
194  for(Int_t j=0;j<nh;j++)
195  {
196  ADC = 0;
197  if(det==BTOW) // towers have only ADC
198  {
199  ID = j+1;
200  ADC = muEmc->getTowerADC(ID,det);
201  mDecoder->GetDaqIdFromTowerId(ID,DAQ);
202  mDecoder->GetTowerCrateFromDaqId(DAQ,CRATE,INDEX);
203  CAP = 0;
204  }
205  if(det==BPRS)
206  {
207  StMuEmcHit* hit=muEmc->getPrsHit(j,det);
208  ID = hit->getId();
209  ADC = hit->getAdc();
210  CAP = hit->getCalType();
211  mDecoder->GetPsdRDO(ID,RDO,INDEX);
212  CRATE = RDO+1;
213  }
214  if(det==BSMDE || det==BSMDP) //smd
215  {
216  StMuEmcHit* hit=muEmc->getSmdHit(j,det);
217  ID = hit->getId();
218  ADC = hit->getAdc();
219  CAP = hit->getCalType();
220  geo->getBin(ID,m,e,s);
221  mDecoder->GetSmdRDO(det,m,e,s,RDO,INDEX);
222  CRATE = RDO+1;
223  }
224  S = makeHit(emc,det,ID,ADC,CRATE,CAP,E);
225  updateStats(det,S,ADC,E);
226  }
227  printStats(det);
228  }
229  return kTRUE;
230 }
int getId() const
Return Module number.
Definition: StMuEmcHit.h:18
Bool_t make(TDataSet *, StEvent *)
Make the BEMC detector from DAQ.
Definition: StBemcData.cxx:55
void emptyEmcCollection(StEmcCollection *)
empty current emcCollection
Definition: StBemcRaw.cxx:449
void printStats(Int_t)
Print statistics for detector &#39;det&#39;.
Definition: StBemcRaw.cxx:555
Int_t makeHit(StEmcCollection *, Int_t, Int_t, Int_t, Int_t, Int_t, Float_t &)
make StEmcRawHit
Definition: StBemcRaw.cxx:662
Definition: Crate.hh:193
void clearStats(Int_t)
Clear statistics for detector &#39;det&#39;.
Definition: StBemcRaw.cxx:522
void updateStats(Int_t, Int_t, Int_t, Float_t)
Update statistics for detector &#39;det&#39;.
Definition: StBemcRaw.cxx:534
int GetTowerCrateFromDaqId(int RDO, int &crate, int &sequence) const
Get crate number from Daq Id for towers.
int getAdc() const
Return ADC value.
Definition: StMuEmcHit.h:19
int GetPsdRDO(int softId, int &RDO, int &posInFiber) const
Get PSD fiber and position from id.
virtual ~StBemcData()
StBemcData destructor.
Definition: StBemcData.cxx:49
Int_t getBin(const Float_t phi, const Float_t eta, Int_t &m, Int_t &e, Int_t &s) const
Definition: StEmcGeom.h:321
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.