StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEEsmdCalMaker.cxx
1 // *-- Author : Jan Balewski
2 //
3 // $Id: StEEsmdCalMaker.cxx,v 1.7 2009/02/04 20:33:23 ogrebeny Exp $
4 
5 #include <TFile.h>
6 #include <TH2.h>
7 
8 #include "StEEsmdCalMaker.h"
9 
10 #include "StMuDSTMaker/COMMON/StMuEvent.h"
11 #include "StMuDSTMaker/COMMON/StMuDst.h"
12 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
13 
14 #include <StMessMgr.h>
15 
16 #include "StEEmcUtil/database/EEmcDbItem.h"
17 #include "StEEmcUtil/database/StEEmcDb.h"
18 
19 
20 ClassImp(StEEsmdCalMaker)
21 
22 //________________________________________________
23 //________________________________________________
24 StEEsmdCalMaker::StEEsmdCalMaker( const char* self ,const char* muDstMakerName) : StMaker(self){
25  mMuDstMaker = (StMuDstMaker*)GetMaker(muDstMakerName);
26  assert(mMuDstMaker);
27  MCflag=0;// default off
28  // printf("constr of calib =%s=\n",GetName());
29 
30  //tmp, JB
31  // ideal calibration used by Fast simulator has eta dependent gains for towers and plain energy deposit for SMD,pre,post
32 
33  // towers are gain matched to fixed E_T
34  float maxAdc=4095;
35  float maxEtot=60; // in GeV
36  const float feta[MaxEtaBins]= {1.95,1.855,1.765,1.675,1.59,1.51,1.435,1.365,1.3,1.235,1.17,1.115};
37 
38  int i;
39 
40  mfixEmTgain=new float [MaxEtaBins];
41  for (i=0;i<MaxEtaBins;i++) {
42  mfixEmTgain[i]=maxAdc/maxEtot/cosh(feta[i]);
43  }
44  mfixSMDgain=23000;
45  mfixPgain=23000;
46 
47 }
48 
49 
50 //___________________ _____________________________
51 //________________________________________________
52 StEEsmdCalMaker::~StEEsmdCalMaker(){
53 }
54 
55 //________________________________________________
56 //________________________________________________
57 void StEEsmdCalMaker::SetSector(int sec){
58  setSector(sec);
59  TString name=GetName();
60  name+="-";
61  name+=sec;
62  // printf("change name to %s sec=%d\n", name.Data(),sec);
63  SetName(name);
64 }
65 
66 
67 //________________________________________________
68 //________________________________________________
69 Int_t StEEsmdCalMaker::Init(){
70  eeDb = (StEEmcDb*)this->GetDataSet("StEEmcDb");
71  //printf("%s got eeDb=%p\n",GetName(),eeDb);
72  EEsmdCal::init();
73  printf("%s has MCflag=%d\n",GetName(),MCflag);
74  return StMaker::Init();
75 }
76 
77 //________________________________________________
78 //________________________________________________
79 Int_t StEEsmdCalMaker::InitRun(int runNo){
80  if(runNo==0) {
81  gMessMgr->Message("","W")<<GetName()<<"::InitRun("<<runNo<<") ??? changed to 555, it s OK for M-C - perhaps, JB"<<endm;
82  runNo=555;
83  }
84  initRun(runNo);
85  return kStOK;
86 }
87 
88 
89 
90 //________________________________________________
91 //________________________________________________
93  finish(0); // do not draw
94  return kStOK;
95 }
96 
97 
98 //________________________________________________
99 //________________________________________________
101 
102  clear();
103  // ............. acuire EEMC data
104  if(unpackMuDst()<0) return kStOK;
105 
106  findSectorMip();// do real analysis
107 
108  return kStOK;
109 }
110 
111 
112 //________________________________________________
113 //________________________________________________
114 Int_t StEEsmdCalMaker::unpackMuDst(){
115 
116  nInpEve++;
117  gMessMgr->Message("","D") <<GetName()<<"::::getAdc() is called "<<endm;
118 
119  // Access to muDst .......................
120  StMuEmcCollection* emc = mMuDstMaker->muDst()->muEmcCollection();
121  if (!emc) {
122  gMessMgr->Message("","W") <<"No EMC data for this event"<<endm; return kStOK;
123  }
124 
125 
126  int i, n1=0,n2=0,n3=0;
127 
128  //......................... T O W E R S .....................
129  for (i=0; i< emc->getNEndcapTowerADC(); i++) {
130  int sec,eta,sub,val;
131  //muDst ranges:sec:1-12, sub:1-5, eta:1-12
132  emc->getEndcapTowerADC(i,val,sec,sub,eta);
133  assert(sec>0 && sec<=MaxSectors);// total corruption of muDst
134 
135  //tmp, for fasted analysis use only hits from sectors init in DB
136  if(sec<eeDb->getFirstSector() || sec>eeDb->getLastSector()) continue;
137 
138  const EEmcDbItem *x=eeDb->getTile(sec,'A'+sub-1,eta,'T');
139  assert(x); // it should never happened for muDst
140  if(x->fail ) continue; // drop broken channels
141 
142  int iphi=(x->sec-1)*MaxSubSec+(x->sub-'A');
143  int ieta=x->eta-1;
144  assert(iphi>=0 && iphi<MaxPhiBins);
145  assert(ieta>=0 && ieta<MaxEtaBins);
146 
147  float adc=-100, rawAdc=-101, ene=-102;
148 
149  if(MCflag) { // M-C & real data needs different handling
150  adc=val; // this is stored in muDst
151  rawAdc=adc+x->ped; // ped noise could be added
152  ene=adc/ mfixEmTgain[ieta];
153  } else {
154  rawAdc=val;
155  adc=rawAdc-x->ped;
156  if(x->gain) ene=adc/x->gain;
157  }
158 
159  int iT=0;// for towers
160 
161  // if(adc>0) printf("adc=%f ene/GeV=%f rawAdc=%f idG=%f,hSec=%d %s\n",adc,ene,rawAdc,mfixEmTgain[ieta],sectID,x->name);
162 
163  tileAdc[iT][ieta][iphi]=adc;// store towers
164  tileThr[iT][ieta][iphi]=rawAdc>x->thr;
165  if(rawAdc>x->thr) n1++;
166  if(x->gain<=0) continue;// drop channels w/o gains
167  tileEne[iT][ieta][iphi]=ene;
168 
169  }
170 
171 
172  //......................... P R E - P O S T .....................
173  int pNh= emc->getNEndcapPrsHits();
174  for (i=0; i<pNh; i++) {
175  int pre;
176  int sec,eta,sub;
177  //muDst ranges: sec:1-12, sub:1-5, eta:1-12 ,pre:1-3==>pre1/pre2/post
178  StMuEmcHit *hit=emc->getEndcapPrsHit(i,sec,sub,eta,pre);
179 
180  //tmp, for fasted analysis use only hits from sectors init in DB
181  if(sec<eeDb->getFirstSector() || sec>eeDb->getLastSector()) continue;
182 
183 
184  //Db ranges: sec=1-12,sub=A-E,eta=1-12,type=T,P-R ; slow method
185  const EEmcDbItem *x=eeDb-> getTile(sec,sub-1+'A', eta, pre-1+'P');
186  if(x==0) continue;
187  if(x->fail ) continue; // drop broken channels
188 
189  // accept this hit
190  int iphi=(x->sec-1)*MaxSubSec+(x->sub-'A');
191  int ieta=x->eta-1;
192  assert(iphi>=0 && iphi<MaxPhiBins);
193  assert(ieta>=0 && ieta<MaxEtaBins);
194  int iT=pre; // P,Q,R fall in to iT=1,2,3 <== there is no '+1' error, JB
195  assert(iT>0 && iT<mxTile);
196 
197  float val=hit->getAdc();
198  float adc=-100, rawAdc=-101, ene=-102;
199 
200  if(MCflag) {// val is Geant energy * const
201  adc=val;
202  rawAdc=adc+x->ped; // ped noise could be added
203  ene=val/mfixPgain; // (GeV) Geant energy deposit
204  } else {
205  rawAdc=val;
206  adc=rawAdc-x->ped;
207  if(x->gain) ene=adc/x->gain;
208  }
209  if(rawAdc>x->thr) n2++;
210  //if(adc>0) printf("adc=%f ene/GeV=%f hSec=%d %s g=%f\n",adc,ene,sectID,x->name, x->gain);
211 
212  tileAdc[iT][ieta][iphi]=adc;// // store P,Q,R depending on 'iT'
213  tileThr[iT][ieta][iphi]=rawAdc>x->thr;
214 
215  if(x->gain<=0) continue;// drop channels w/o gains
216  tileEne[iT][ieta][iphi]=ene;
217 
218  }
219 
220 
221  //....................... S M D ................................
222 
223  char uv='U';
224  for(uv='U'; uv<='V'; uv++) {
225  int sec,strip;
226  int nh= emc->getNEndcapSmdHits(uv);
227  //printf("pl=%c nH=%d secLim=%d %d\n",uv,nh,eeDb->mfirstSecID,eeDb->mlastSecID);
228  for (i=0; i<nh; i++) {
229  StMuEmcHit *hit=emc->getEndcapSmdHit(uv,i,sec,strip);
230  assert(sec>0 && sec<=MaxSectors);// total corruption of muDst
231 
232  //tmp, for fasted analysis use only hits from sectors init in DB
233  if(sec<eeDb->getFirstSector() || sec>eeDb->getLastSector()) continue;
234 
235  const EEmcDbItem *x=eeDb->getByStrip(sec,uv,strip);
236  assert(x); // it should never happened for muDst
237  if(x->fail ) continue; // drop broken channels
238 
239  float val=hit->getAdc();
240  float adc=-100, rawAdc=-101, ene=-102;
241 
242  // M-C & real data needs different handling
243  if(MCflag) {
244  adc=val;
245  rawAdc=adc+x->ped; // ped noise could be added
246  ene=val/mfixSMDgain; // (GeV) Geant energy deposit
247  }else {
248  rawAdc=val;
249  adc=rawAdc-x->ped;
250  if(x->gain) ene=adc/x->gain;
251  }
252  if(rawAdc>x->thr) n3++;
253  // if(adc>0) printf("adc=%f ene/GeV=%f hSec=%d %s\n",adc,ene,sectID,x->name);
254 
255  smdAdc[x->plane-'U'][x->strip-1]=adc;
256  if(x->gain<=0)continue; // drop channels w/o gains
257  smdEne[x->plane-'U'][x->strip-1]=ene;
258  }
259  }
260  // printf("nTw=%d nPQR=%d,nSmd=%d\n",n1,n2,n3);
261 
262  return n1;
263 }
264 
265 
266 // $Log: StEEsmdCalMaker.cxx,v $
267 // Revision 1.7 2009/02/04 20:33:23 ogrebeny
268 // Moved the EEMC database functionality from StEEmcDbMaker to StEEmcUtil/database. See ticket http://www.star.bnl.gov/rt2/Ticket/Display.html?id=1388
269 //
270 // Revision 1.6 2005/03/11 15:44:25 balewski
271 // works with muEzt, cucu200
272 //
273 // Revision 1.5 2004/10/21 13:31:31 balewski
274 // to match new name of emcCollection in muDst
275 //
276 // Revision 1.4 2004/07/27 21:59:47 balewski
277 // now runs on muDst as well
278 //
279 // Revision 1.3 2004/06/29 16:37:41 balewski
280 // towards SMD calib
281 //
282 // Revision 1.2 2004/06/22 23:31:11 balewski
283 // few more gadgets added
284 //
285 // Revision 1.1 2004/06/12 04:09:25 balewski
286 // start
287 //
288 // Revision 1.1 2004/06/06 04:54:08 balewski
289 // dual analyzis
290 //
StMuDst * muDst()
Definition: StMuDstMaker.h:425
virtual Int_t Make()
float smdAdc[MaxSmdPlains][MaxSmdStrips]
30 deg (only for this sector)
Definition: EEsmdCal.h:105
int getAdc() const
Return ADC value.
Definition: StMuEmcHit.h:19
virtual Int_t Finish()
void setSector(int x)
the same info, counted from 0
Definition: EEsmdCal.h:95
static StMuEmcCollection * muEmcCollection()
returns pointer to current StMuEmcCollection
Definition: StMuDst.h:389
virtual const char * GetName() const
special overload
Definition: StMaker.cxx:237
float tileAdc[mxTile][MaxEtaBins][MaxPhiBins]
Definition: EEsmdCal.h:100
Definition: Stypes.h:40
Access EEMC data &amp; DB from muDst in StRoot-framework Only muDst data are decoded by this class Uses E...