StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
rdSt2print.C
1 // *****************************************************************************
2 class StEmcDetector;
3 class StChain;
4 class StEmcRawData;
5 class EEfeeDataBlock;
6 class Collection;
7 class StSPtrVecTrackNodeIterator ;
9 class StFgtCollection;
10 
11 StChain *chain=0;
12 
13 void rdSt2print(char * fname="aa.event.root", Int_t nevents=4){
14 
15  fname="m1.event.root";
16 
17  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
18  loadSharedLibraries();
19  // assert( !gSystem->Load("StEEmcUtil.so"));
20 
21  cout << " loading done " << endl;
22 
23  // Load my makers
24 
25  // create chain
26  chain = new StChain("bfc");
27  //chain->SetDebug();
28 
29  // Now we add Makers to the chain...
30 
31  // StIOMaker - to read files ...
32  StIOMaker* ioMaker = new StIOMaker();
33  ioMaker->SetFile(fname);
34  //ioMaker->SetDebug();
35  ioMaker->SetIOMode("r");
36  ioMaker->SetBranch("*",0,"0"); //deactivate all branches
37  ioMaker->SetBranch("geantBranch",0,"r"); //activate geant Branch
38  ioMaker->SetBranch("eventBranch",0,"r"); //activate Event Branch
39  ioMaker->SetIOMode("r");
40 
41  // StMcEventMaker
42  // StMcEventMaker *mcEventMaker = new StMcEventMaker();
43 
44  // My Makers
45 
46  // Now execute the chain Init functions
47  chain->PrintInfo();
48  chain->ls(3);
49  Int_t initStat = chain->Init(); // This should call the Init() method in ALL makers
50  if (initStat) chain->Fatal(initStat, "during Init()");
51 
52  int istat=0,iev=0;
53 
54  // Do the event loop
55  while(1) {
56  if (iev>=nevents) break;
57  chain->Clear();
58  istat = chain->Make();
59  iev++;
60  if(istat) break;
61  cout << "---------------------- Processing Event : " << iev << " ---------------------- " << istat<<endl;
62 
63 
64  // if(iev<17) continue;
65  if (istat == kStEOF || istat == kStFatal) break;
66 
67  StEvent* mEvent = (StEvent*)chain->GetInputDS("StEvent");
68  assert(mEvent);// fix your chain or open the right event file
69  StTriggerIdCollection *tic=mEvent->triggerIdCollection();
70  assert(tic);
71 
72  // if(! isTrig(tic,trigM)) continue;
73  int nV=mEvent->numberOfPrimaryVertices();
74  int iv;
75  if(nV>1) printf("######\n");
76  printf("eveID=%d nPrimVert=%d\n", mEvent->id(),nV);
77 
78  // VERTEX INFO ........................
79  for(iv=0;iv<nV;iv++) {
80  StPrimaryVertex *V=mEvent->primaryVertex(iv);
81  assert(V);
82  StThreeVectorF &r=V->position();
83  StThreeVectorF &er=V->positionError();
84  printf("iv=%d Vz=%.2f +/-%.2f \n",iv,r.z(),er.z() );
85  printf(" nPrimTr=%d , VFid=%d:: ntrVF=%d nCtb=%d nBemc=%d nEEmc=%d nTpc=%d sumPt=%.1f rank=%g\n"
86  ,V->numberOfDaughters(), V->vertexFinderId() ,V->numTracksUsedInFinder() ,
87  V->numMatchesWithCTB() ,V-> numMatchesWithBEMC() ,V->numMatchesWithEEMC() ,
88  V->numTracksCrossingCentralMembrane() ,V->sumOfTrackPt() ,V->ranking());
89 
90  continue;
91  // TRACK INFO ..............
92  int nPrTr=0;
93  //.... access prim tracks for given vertex
94  int itr;
95  for(itr=0; itr<V->numberOfDaughters(); itr++) {
96  StTrack *track=V-> daughter(itr);
97  if(track==0) continue;
98  if (track->flag() <0 ) continue;
99  printf("itr=%d pT=%.1f eta=%.2f nFitP=%d DCA=%.1f\n",itr,
100  track->geometry()->momentum().mag(),
101  track->geometry()->momentum().pseudoRapidity(),
102  track->fitTraits().numberOfFitPoints(),
103  track->geometry()->helix().distance(V->position()));
104  nPrTr++;
105  }
106  printf(" counted nPrimTr=%d \n",nPrTr);
107  } // end of loop over vertices
108  // mEvent->ls(3);
109 
110  // FGT INFO .......
111  StFgtCollection* fgtColl= mEvent-> fgtCollection();
112 
113  printFgt(fgtColl);
114  //assert(9==0);
115  // EMC INFO ............
116  StEmcCollection* emcC =(StEmcCollection*)mEvent->emcCollection(); assert(emcC);
117  // print Endcap hits in StEvent
118  printETOW(emcC->detector(13));
119  // printEPRE(emcC->detector(14));
120  //printESMD(emcC->detector(15));
121  // printESMD(emcC->detector(16));
122  // printRaw(emcC->eemcRawData());
123  //printRawBEMC(emcC->bemcRawData());
124 
125  // if(iev<=2)
126 
127  } // Event Loop
128  chain->Finish();
129 
130 
131 
132 }
133 
134 // ****************************************************************************/
135 
136 void printRawBEMC(StEmcRawData *raw) {
137 
138 
139  if(!raw) return;
140 
141 /*
142 data banks
143 0 - tower
144 1-8 - SMD
145 9-12- PSD
146 */
147 
148  int NBANK = 13;
149 
150  int tot=0;
151 
152 //for the headers
153  for(int i = 0; i<NBANK;i++) {
154  if(raw->header(i)) {
155  int size = raw->sizeHeader(i);
156  printf("======BTOW BANK=%d size: head=%d, data=%d\n",i,size,raw->sizeData(i));
157  continue;
158  for(int j = 0;j<size;j++) {
159  if(j%16==0) printf("\n");
160  printf("0x%04x ",raw->header(i,j));
161  }
162  }StFgtEvent
163 
164  if(raw->data(i)) {
165  int size = raw->sizeData(i);
166  printf("\nBANK=%d data size=%d",i,size);
167  for(int j = 0;j<size;j++) {
168  if(j%16==0) printf("\n");
169  printf("0x%04x ",raw->data(i,j));
170  tot++;
171  }
172  }
173  printf("\n bank=%d tot=%d\n",i,tot);
174  }
175 }
176 
177 
178 
179 //=============================================
180 //=============================================
181 //=============================================
182 
183 printRaw( StEmcRawData* raw) {
184 
185  printf("printRaw(%p)\n",raw);
186 
187  assert(raw);
188  int icr;
189  printf("nBlocks=%d\n",raw->getNBlocks());
190  EEfeeDataBlock block;
191  for(icr=0; icr<raw->getNBlocks();icr++) {
192  if(raw->sizeData(icr)<=0) continue;
193 
194  const UShort_t* head=raw->header(icr);
195  const UShort_t* data=raw->data(icr);
196  assert(head);
197  printf("icr=%d, size: head=%d data=%d\n",icr,raw->sizeHeader(icr),raw->sizeData(icr));
198 
199  int i;
200  block.clear();
201  block.setHead(raw->header(icr));
202  block.setDataArray(raw->data(icr),raw->sizeData(icr));
203  continue;
204  if(icr>=6) continue; // just towers
205  block.print(0);
206 
207  }
208 
209 }
210 //=============================================
211 //=============================================
212 //=============================================
213 
214 printETOW( StEmcDetector* det) {
215 
216  printf("print ETOW Tw(%p)\n",det);
217  if(det==0) { printf("NULL ETOW pointer, skip\n"); return;}
218 
219  assert(det);
220  printf("towers nHit=%d nMod=%d\n",det->numberOfHits(),det->numberOfModules());
221  int nPos=0;
222  for(int mod=1;mod<=det->numberOfModules();mod++) {
223  StEmcModule* module=det->module(mod);
224  // printf("ETOW sector=%d nHit=%d\n",mod,module->numberOfHits());
225  StSPtrVecEmcRawHit& hit= module->hits();
226  int ih;
227  for(ih=0;ih<hit.size();ih++){
228  StEmcRawHit *x=hit[ih];
229  int sec=x->module();
230  char sub='A'+x->sub()-1;
231  int eta=x->eta();
232  int adc=x->adc();
233  if(adc<=0) continue;
234  printf("ih=%d %02dT%c%02d -->adc=%d ener=%f\n",ih,sec,sub,eta,adc, x->energy());
235  if(adc>0) nPos++;
236  int adcX=1000+ (eta-1) + (sub-'A')*12 +(sec-1)*60;
237  // assert(adc==adcX );
238 
239  // printf("ih=%d, mod=%d eta=%d sub=%d adc=%d\n",ih,x->module(),x->eta(),x->sub(),x->adc());
240  }
241  }
242  printf("total nPos=%d\n",nPos);
243  printf("nPos=%d of %d \n",nPos,det->numberOfHits());
244 
245 }
246 
247 
248 //=============================================
249 //=============================================
250 //=============================================
251 
252 printEPRE( StEmcDetector* det) {
253 
254  printf("printPre/post(%p)\n",det);
255  assert(det);
256  printf("pre/post nHit=%d nMod=%d\n",det->numberOfHits(),det->numberOfModules());
257  int nPos=0;
258  for(int imod=1;imod<=det->numberOfModules();imod++) {
259  StEmcModule* module=det->module(imod);
260  printf("EPRE sect=%d nHit=%d\n",imod, module->numberOfHits());
261  StSPtrVecEmcRawHit& hit= module->hits();
262  int ih;
263  for(ih=0;ih<hit.size();ih++){
264  StEmcRawHit *x=hit[ih];
265  int sec=x->module();
266  int ss=x->sub()-1;
267  char sub='A'+ss%5;
268  char preL='P'+ss/5;
269  int eta=x->eta();
270  int adc=x->adc();
271  printf("ih=%d %02d%c%c%02d ss=%d -->adc=%d ener=%f ss=%d\n",ih,sec,preL,sub,eta,ss,adc, x->energy(),ss);
272  if(adc>0) nPos++;
273  int adcX= (eta-1) + (sub-'A')*12 +(sec-1)*60 + 1000*(preL-'P'+1);
274  // assert(adc==adcX );
275  }
276  printf("nPos=%d\n",nPos);
277  }
278  // printf("total nPos=%d\n",nPos);
279  printf("nPos=%d of %d \n",nPos,det->numberOfHits());
280 
281 }
282 
283 
284 
285 //=============================================
286 //=============================================
287 //=============================================
288 
289 printESMD( StEmcDetector* det) {
290 
291  printf("printSMD/post(%p)\n",det);
292  assert(det);
293  printf("U-SMD nHit=%d nMod=%d\n",det->numberOfHits(),det->numberOfModules());
294  int nPos=0;
295  for(int imod=1;imod<=det->numberOfModules();imod++) {
296  StEmcModule* module=det->module(imod);
297  printf("ESMD sector=%d nHit=%d\n",imod, module->numberOfHits());
298  StSPtrVecEmcRawHit& hit= module->hits();
299  int ih;
300  for(ih=0;ih<hit.size();ih++){
301  StEmcRawHit *x=hit[ih];
302  int sec=x->module();
303  int strip=x->eta();
304  int adc=x->adc();
305  printf("ih=%d %02dU%03d -->adc=%d ener=%f\n",ih,sec,strip,adc, x->energy());
306  if(adc>0) nPos++;
307  int adcX= 1000+(strip -1) +(sec-1)*300;
308  // assert(adc==adcX );
309  }
310  printf(" nPos=%d\n",nPos);
311  }
312  printf("nPos=%d of %d \n",nPos,det->numberOfHits());
313 
314 
315 }
316 
317 //--------------------------------------
318 bool isTrig(StTriggerIdCollection *tic,int *trigL){
319  int i;
320  const StTriggerId *l1=tic->l1();
321 
322  for(i=0;trigL[i]>0;i++) {
323  // printf("%d tid=%d found=%d\n",i,trigL[i],l1->isTrigger(trigL[i]));
324  if(l1->isTrigger(trigL[i])) return true;
325  }
326  return false;
327 }
328 
329 
330 
331 
332 
333 //=============================================
334 //=============================================
335 //=============================================
336 
337 void printFgt(StFgtCollection* fgtColl ){
338  printf("print FGT (%p)\n",fgtColl );
339  if(fgtColl==0) { printf("NULL FGT pointer, skip\n"); return;}
340 
341  printf("FgtEvent: numDisk=%d\n",fgtColl->getNumDiscs());
342  for(int iDisc=0; iDisc <fgtColl->getNumDiscs(); iDisc++) {
343  printf(" content: ID=%d # of : strips=%d hits=%d \n" ,iDisc ,fgtColl ->getNumStrips(iDisc) ,fgtColl -> getNumHits( iDisc));
344  StFgtStripCollection *stripCollectionPtr= fgtColl->getStripCollection(iDisk);
345  StSPtrVecFgtStrip &stripVec = stripCollectionPtr->getStripVec();
346 
347 
348  for(int ih=0;ih<stripVec.size();ih++) {
349  StFgtStrip *strip=stripVec[i]);
350 
351  printf("iDisc=%d ih=%d geoId=%d ADC=%d\n",iDisc,ih,strip->getGeoId(),strip->getAdc());
352  }
353 #if 0
354  for(int ih=0;ih<pDisc->getNumClusters();ih++) {
355  StFgtCluster *cl=pDisc->getClusterArray().getClusterPtr(ih);
356  printf("iDisc=%d ic=%d layer=%c, pos/cm=%.2f charge=%f numStirp=%d\n",iDisc,ih,cl->getLayer(),cl->getPosition(), cl->getCharge(),cl->getNumStrips());
357  }
358 #endif
359 
360  }
361 
362 }
virtual void SetIOMode(Option_t *iomode="w")
number of transactions
Definition: StIOInterFace.h:35
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
double distance(const StThreeVector< double > &p, bool scanPeriods=true) const
minimal distance between point and helix
Definition: StHelix.cc:240
virtual Int_t Finish()
Definition: StChain.cxx:85
Collection of trigger ids as stored in StEvent.
virtual void ls(Option_t *option="") const
Definition: TDataSet.cxx:495
Definition: Stypes.h:43
virtual Int_t Make()
Definition: StChain.cxx:110