StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
EemcHitList.cxx
1 #include <string.h>
2 #include <assert.h>
3 #include <cmath>
4 
5 #include <St_base/StMessMgr.h>
6 #include "St_db_Maker/St_db_Maker.h"
7 
8 #include "StGenericVertexMaker/StiPPVertex/EemcHitList.h"
9 
10 #include "StChain/StMaker.h"
11 #include "StEEmcUtil/database/StEEmcDb.h"
12 #include "StEEmcUtil/database/EEmcDbItem.h"
13 #include "StEEmcUtil/EEmcGeom/EEmcGeomSimple.h"
14 
15 
16 #include "StEvent/StEmcDetector.h"
17 #include "StEvent/StEmcModule.h"
18 #include "StEvent/StEmcRawHit.h"
19 
20 
21 //Z=270, 288,306 cm
22 
23 
24 //==========================================================
25 //==========================================================
26 EemcHitList::EemcHitList(StEEmcDb* x, unsigned int y, EEmcGeomSimple *z) :
27  ScintHitList(-M_PI/60.,M_PI/30,60, 999,999,8,(char *) "Eemc",4,0.75) {
28  eeDb = x ? x : new StEEmcDb();
29  killStatEEmc=y ;
30  geomE = z ? z : new EEmcGeomSimple();
31  assert(eeDb);
32  assert(geomE);
33  assert(nEta<=MaxEtaBins);
34  float kSigPed=5.0;
35  eeDb-> setThreshold( kSigPed);
36  // the first 13 entries mark the bounds of the 12 eta Bins.
37  etaHL= geomE->getEtaBinRangeArray();
38  gMessMgr->Message("","I")
39  <<" EemcHitList::use kSigPed="<<kSigPed
40  <<endm;
41 }
42 
43 
44 //==========================================================
45 //==========================================================
46 void
47 EemcHitList::initRun(St_db_Maker* db_maker){
48  gMessMgr->Message("","D") <<" EemcHitList::initRun()"<<endm;
49  ScintHitList::initRun();
50 
51  // clear old lookup table
52  int sec,sub,etaB;
53  for(sec=0;sec<MaxSectors;sec++)
54  for(sub=0;sub<MaxSubSec;sub++)
55  for(etaB=0;etaB<MaxEtaBins;etaB++)
56  name2bin[sec][sub][etaB]=-1;
57 
58  eeDb->loadTables(db_maker);
59 
60  // fill in new association
61  int nB=0,nA=0;
62  for(sec=1;sec<=MaxSectors;sec++)
63  for(sub='A';sub<='E';sub++)
64  for(etaB=1;etaB<=MaxEtaBins;etaB++) {
65  //Db ranges: sec=1-12,sub=A-E,eta=1-12; slow method
66  const EEmcDbItem *x=eeDb->getT(sec,sub,etaB);
67  if(x==0) continue;
68  nB++;
69  if(x->fail ) continue; // drop broken channels
70  if(x->stat & killStatEEmc) continue; // other problems
71 
72  int ieta=x->eta-1; // typical endcap bin numbering
73  int isec=x->sec-1, isub=x->sub-'A';
74  float eta=geomE->getEtaMean(ieta);
75  float phi=geomE->getPhiMean(isec,isub); // // -pi <= phi < pi
76  if( phi<0) phi+=2*M_PI; // I want phi in [0,2Pi]
77 
78  //........... convert it to private bins
79  int iEta=etaBin(eta); // unique vertx finder bin numbering
80  int iPhi=phiBin(phi);
81  //printf("EE eta=%.3f iEta=%d , phi/deg=%.1f iPhi=%d name=%s\n",eta,iEta,phi/3.1416*180,iPhi,x->name);// x->print();
82  if(iEta<0) continue; // out of assumed sensitivity range
83 
84  //printf("EE tower is good\n");
85 
86  assert( iEta<nEta);
87  assert( iPhi>=0);
88 
89  int iBin=iPhiEta2bin(iPhi,iEta);
90  assert(name2bin[isec][isub][ieta]==-1); //tmp, to check ETOW code
91  name2bin[isec][isub][ieta]=iBin;
92 
93  //tmp
94  assert(iBin>=0);
95  assert(iBin<nBin);
96  assert( active[iBin]==0 );
97  // tmp end
98 
99  setActive(iBin);
100  nA++;
101  }
102 
103  LOG_INFO <<" EemcHitList::initRun() done, active="<<nA<<" of "<<nB<<" ETOW towers (only 8 upper eta rings are used) " <<endm;
104 
105 }
106 
107 //==========================================================
108 //==========================================================
109 void
110 EemcHitList::clear(){
111  ScintHitList::clear();
112 }
113 
114 //==========================================================
115 //==========================================================
116 int
117 EemcHitList::etaBin(float eta){
118 
119  // in this aplication only 'nBin' ,counted from eta=1. --> eta=2., are condidered to be valid. nBin should be ~8, since no tracking is expected at eta >1.6
120 
121  if(eta <etaHL[12]) return -1; // missed EEMC
122  int i;
123  for(i=0;i<nEta;i++) {
124  if(eta< etaHL[11-i]) return i;
125  }
126  return -1;
127 }
128 //==========================================================
129 //==========================================================
130 float
131 EemcHitList::bin2EtaLeft(int iEta){
132  assert(iEta>=0);
133  assert(iEta<nEta);
134  float etaF= etaHL[11-iEta] ;
135  return etaF;
136 }
137 
138 
139 //==========================================================
140 //==========================================================
141 EemcHitList::~EemcHitList(){
142 
143 }
144 
145 //==========================================================
146 //==========================================================
147 void
148 EemcHitList::build ( StEmcDetector*det, float adcMin){
149  for(unsigned int mod=1;mod<=det->numberOfModules();mod++) {
150  StEmcModule* module=det->module(mod);
151  //printf("ETOW sector=%d nHit=%d\n",mod,module->numberOfHits());
152  StSPtrVecEmcRawHit& hit= module->hits();
153  int sec=mod; // range 1-12
154  for(unsigned int ih=0;ih<hit.size();ih++){ // over cesctors
155  StEmcRawHit *h=hit[ih];
156  char sub='A'+h->sub()-1;// range A-E
157  int eta=h->eta();// range 1-12
158  int rawAdc=h->adc();
159  //Db ranges: sec=1-12,sub=A-E,eta=1-12; slow method
160  const EEmcDbItem *x=eeDb->getT(sec,sub,eta);
161  if(x==0) continue;
162  if(x->fail ) continue; // drop broken channels
163  if(x->stat & killStatEEmc) continue; // other problems
164  // functioning chan
165 
166  int iBin=name2bin[sec-1][sub-'A'][eta-1];
167  if ( getActive(iBin)<0) continue;
168 
169  if(rawAdc< x->thr) continue; // still only ped
170  float adc=rawAdc - x->ped ;
171  if(adc < adcMin) continue; // too low response for MIP
172  // printf("add Eemc hit %s adc=%.1f\n",x->name,adc);
173 
174  setFired(iBin);
175  } // end of sector
176  // printf("sect=%d so far: nActive=%d nHit=%d\n",sec,nAct,nHit);
177  }
178 };
179 
Float_t getPhiMean(UInt_t sec) const
EEMC simple geometry.
void loadTables(StMaker *anyMaker)
to access STAR-DB
Definition: StEEmcDb.cxx:211
Float_t getEtaMean(UInt_t eta) const