StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEEsoloPi0Maker.cxx
1 // *-- Author : Jan Balewski
2 //
3 // $Id: StEEsoloPi0Maker.cxx,v 1.14 2011/04/11 19:35:42 fisyak Exp $
4 
5 #include <TFile.h>
6 
7 #include "StEEsoloPi0Maker.h"
8 
9 #include "TChain.h"
10 #include "TClonesArray.h"
11 #include "StL0Trigger.h"
12 #include "StEventInfo.h"
13 #include "StEventSummary.h"
14 #include "StarClassLibrary/StThreeVectorF.hh"
15 #include "StMuDSTMaker/COMMON/StMuEvent.h"
16 #include "StMuDSTMaker/COMMON/StMuTrack.h"
17 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
18 #include "StMuDSTMaker/COMMON/StMuTriggerIdCollection.h"
19 #include "StEvent/StTriggerId.h"
20 
21 
22 #include "StEEmcUtil/database/EEmcDbItem.h"
23 #include "StEEmcUtil/database/StEEmcDb.h"
24 
25 #include <StMessMgr.h>
26 
27 ClassImp(StEEsoloPi0Maker)
28 
29 //________________________________________________
30 //________________________________________________
31 StEEsoloPi0Maker::StEEsoloPi0Maker(const char* self ,const char* muDstMakerName) : StMaker(self){
32  mMuDstMaker = (StMuDstMaker*)GetMaker(muDstMakerName);
33  assert(mMuDstMaker);
34  MCflag=0;// default off
35 
36 }
37 
38 
39 //___________________ _____________________________
40 //________________________________________________
41 StEEsoloPi0Maker::~StEEsoloPi0Maker(){
42  // Save all objects in this file
43  // hfile->Write();
44 }
45 
46 //________________________________________________
47 //________________________________________________
48 Int_t StEEsoloPi0Maker::InitRun(int runNo){
49  // call initRun() only once for M-C
50 
51  if( !MCflag) initRun(runNo);
52  static int first=1;
53  if(first) return kStOK;
54  initRun(runNo);
55  first=0;
56  return kStOK;
57 }
58 
59 //________________________________________________
60 //________________________________________________
61 Int_t StEEsoloPi0Maker::Init(){
62  eeDb = (StEEmcDb*)this->GetDataSet("StEEmcDb");
63  EEsoloPi0::init();
64  LOG_INFO << "has MCflag="<< MCflag<<endm;
65  return StMaker::Init();
66 }
67 
68 //________________________________________________
69 //________________________________________________
71  finish();
72  return kStOK;
73 }
74 
75 
76 
77 
78 //________________________________________________
79 //________________________________________________
81  clear();
82  static int n0=0,n1=0,n2=0,n3=0;
83  // printf("%s::Make() is called ..........n0,1,2,3= %d %d %d %d \n",StMaker::GetName(),n0,n1,n2,n3);
84  n0++;
85  //............. trigger sort
86  if( !MCflag&& !unpackMuTrig()) return kStOK;
87  n1++;
88 
89  //................. CTB sort
90  float sum=getCtbSum(); sum=sum;
91  //tmp if(sum<75 || sum > 800) return kStOK;
92  n2++;
93 
94  // ............. acquire EEMC data
95  if(!unpackMuEemc()) return kStOK;
96  n3++;
97 
98  findTowerClust();
99  findTowerPi0();
100 
101  return kStOK;
102 }
103 
104 
105 
106 //________________________________________________
107 //________________________________________________
108 bool StEEsoloPi0Maker::unpackMuTrig(){ // trigger filter, has wrongID
109 
110  // printf("%s::unpackMuTrig() is called ..........\n",StMaker::GetName());
111 
112  // Access to muDst .......................
113  StMuEvent* muEve = mMuDstMaker->muDst()->event();
114 
115  StMuTriggerIdCollection& trgIdColl=muEve->triggerIdCollection();
116 
117  const StTriggerId& oflTrgId=trgIdColl.nominal();
118  vector<unsigned int> trgId=oflTrgId.triggerIds();
119 
120 #if 0
121  StEventInfo &info=muEve->eventInfo();
122  int nPrim = mMuDstMaker->muDst()->primaryTracks()->GetEntries();
123  printf("\n\n ==================== processing eventID %d nPrim=%d nTrig=%d==============\n", info.id(),nPrim, trgId.size());
124 #endif
125 
126  bool isGood=false;
127  UInt_t i;
128  for(i = 0; i < trgId.size() ; i++){
129  // printf("i=%d trgId=%d\n",i,trgId[i]);
130 #if 0
131  //.......... minB trig in pp200 in 2004
132  if(trgId[i]==10) isGood=true;
133  if(trgId[i]==45010) isGood=true;
134  if(trgId[i]==45020) isGood=true;
135 #endif
136  //.......... some trigs in ppTrans in 2006
137  if(trgId[i]==127641) isGood=true; //e-http-l2gam
138  // if(trgId[i]==127652) isGood=true; //e-jp0-l2jet
139  // if(trgId[i]==127551) isGood=true; //e-jp0
140  }
141 
142 #if 0 // TPC vertex, not used (yet)
143  StEventSummary &smry=muEve->eventSummary();
144  StThreeVectorF ver=smry.primaryVertexPosition();
145 
146  b.zTpc=ver.z();
147  if( fabs(ver.x())<0.000001 &&fabs(ver.y())<0.000001 &&fabs(ver.z())<0.000001 ) b.zTpc=999;
148 #endif
149 
150  return isGood;
151 }
152 
153 //________________________________________________
154 //________________________________________________
155 bool StEEsoloPi0Maker::unpackMuEemc(){
156 
157  nInpEve++;
158  gMessMgr->Debug() <<GetName()<<"::unpackMuDst() is called "<<endm;
159 
160  // Access to muDst .......................
161  StMuEmcCollection* emc = mMuDstMaker->muDst()->muEmcCollection();
162  if (!emc) {
163  gMessMgr->Warning() <<"No EMC data for this event"<<endm; return false;
164  }
165 
166  int i, n1=0;
167  //printf("aaa %d %d \n",eeDb->mfirstSecID,eeDb->mlastSecID);
168  //......................... T O W E R S .....................
169  for (i=0; i< emc->getNEndcapTowerADC(); i++) {
170  int sec,eta,sub,val;
171  //muDst ranges:sec:1-12, sub:1-5, eta:1-12
172  emc->getEndcapTowerADC(i,val,sec,sub,eta);
173  assert(sec>0 && sec<=MaxSectors);// total corruption of muDst
174 
175  //tmp, for fasted analysis use only hits from sectors init in DB
176  if(sec<eeDb->getFirstSector() || sec>eeDb->getLastSector()) continue;
177 
178  const EEmcDbItem *x=eeDb->getTile(sec,'A'+sub-1,eta,'T');
179  assert(x); // it should never happened for muDst
180 
181  if(x->fail ) continue; // drop broken channels
182 
183  int iphi=(x->sec-1)*MaxSubSec+(x->sub-'A');
184  int ieta=x->eta-1;
185  assert(iphi>=0 && iphi<MaxPhiBins);
186  assert(ieta>=0 && ieta<MaxEtaBins);
187  int irad=iphi*MaxEtaBins+ieta; // unified spiral index
188  assert(irad>=0 && irad<EEsoloPi0::MxTw);
189 
190  float ene=-102;
191 
192  float rawAdc=val;
193  if(rawAdc<x->thr) continue;
194  float adc=rawAdc-x->ped;
195  if(x->gain) ene=adc/x->gain;
196 
197  if(MCflag) ene/=0.8; //fug factor for sampling fraction in M-C being ~4% insted of assumed 5%
198 
199  int ii=(x->sec-1)*60+(x->sub-'A')*12+x->eta-1;
200  assert(ii==irad);
201  // if(adc>0)
202  // printf("adc=%f ene/GeV=%f rawAdc=%f idG=%f,hSec=%d %s\n",adc,ene,rawAdc,mfixEmTgain[ieta],x->sec,x->name);
203 
204  //aa int iT=0;// for towers
205  //aa tileAdc[iT][ieta][iphi]=adc;// store towers
206  //aa tileThr[iT][ieta][iphi]=rawAdc>x->thr;
207 
208  n1++;
209  //aa tileEne[iT][ieta][iphi]=ene;
210  float recoEner=ene/scaleFactor; // ideal
211  // printf("new ii=%d ene=%f del=%f mcf=%d\n",idar,recoEner,recoEner-soloMip[irad].e,MCflag);
212  soloMip[irad].e= recoEner;
213 
214  }// end of loop over towers
215 
216  gMessMgr->Debug() <<GetName()<<"::unpackMuDst(), found total" <<n1<<" towers with ADC>thr"<<endm;
217 
218  return true;
219 }
220 
221 //________________________________________________
222 //________________________________________________
223 float StEEsoloPi0Maker::getCtbSum(){
224 
225  // printf("%s::getCtbSum() is called ..........\n",StMaker::GetName());
226 
227  // Access to muDst .......................
228  StMuEvent* muEve = mMuDstMaker->muDst()->event();
229  StCtbTriggerDetector* ctbDet = &(muEve->ctbTriggerDetector());
230 
231  assert(ctbDet);
232  float ctbSum = 0;
233  int nHit=0;
234  for (UInt_t slat = 0; slat < ctbDet->numberOfSlats(); slat++) {
235  for (UInt_t tray = 0; tray < ctbDet->numberOfTrays(); tray++) {
236  float adc = ctbDet->mips(tray,slat,0);
237  ctbSum += adc;
238  if(adc > 5) nHit++;
239  }
240  }
241  // printf("CTB %d hit ADC>5 sumADC=%f (all) \n",nHit, ctbSum);
242  hA[7]->Fill(ctbSum);
243  return ctbSum;
244 }
245 
246 
247 
248 
249 // $Log: StEEsoloPi0Maker.cxx,v $
250 // Revision 1.14 2011/04/11 19:35:42 fisyak
251 // Replace uint by UInt_t, use TMath
252 //
253 // Revision 1.13 2009/02/04 20:33:21 ogrebeny
254 // Moved the EEMC database functionality from StEEmcDbMaker to StEEmcUtil/database. See ticket http://www.star.bnl.gov/rt2/Ticket/Display.html?id=1388
255 //
256 // Revision 1.12 2007/10/19 23:18:42 balewski
257 // 2008 cleanup, now works only w/ regular muDst
258 //
259 // Revision 1.11 2004/10/27 18:07:50 balewski
260 // practical use of 'sim' flavor for M-C
261 //
262 // Revision 1.10 2004/10/21 13:31:25 balewski
263 // to match new name of emcCollection in muDst
264 //
265 // Revision 1.9 2004/09/29 18:04:44 balewski
266 // now it runs on M-C as well
267 //
268 // Revision 1.8 2004/09/03 04:50:52 balewski
269 // big clenup
270 //
271 // Revision 1.7 2004/08/26 04:39:40 balewski
272 // towards pi0
273 //
274 // Revision 1.6 2004/08/17 15:46:56 balewski
275 // clenup for pp200 in 2004
276 //
277 // Revision 1.5 2004/08/09 20:28:31 balewski
278 // add trig selection
279 //
280 // Revision 1.4 2004/05/07 21:38:38 balewski
281 // gamma finder with SMD
282 //
283 // Revision 1.3 2004/04/29 04:16:43 perev
284 // typo fixed. getTile not getTail
285 //
286 // Revision 1.2 2004/04/14 19:34:01 balewski
287 // access to trigger data
288 //
289 // Revision 1.1 2004/04/14 17:09:09 balewski
290 // new copy of pi0finder with towers only, should work on ezTree as well (after small cleanup)
291 //
StMuDst * muDst()
Definition: StMuDstMaker.h:425
Axample to access muDst and pass it to ezTree analyzis class.
virtual Int_t Finish()
static TObjArray * primaryTracks()
returns pointer to a list of tracks belonging to the selected primary vertex
Definition: StMuDst.h:301
static StMuEmcCollection * muEmcCollection()
returns pointer to current StMuEmcCollection
Definition: StMuDst.h:389
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)
Definition: StMuDst.h:320
virtual const char * GetName() const
special overload
Definition: StMaker.cxx:237
Definition: Stypes.h:40
Collection of trigger ids as stored in MuDst.
virtual Int_t Make()