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 
10 StChain *chain=0;
11 //Run 6151011 :
12 int trigB[5]={96211,96233,96201,96222,0};
13 int trigE[5]={96261,96282,96251,96272,0};
14 int trigZ[2]={96300,0}; // zerobias
15 int trigM[2]={96011,0}; // minBias
16 int trigJ[2]={20,0}; // J/Psi
17 
18 void rdSt2print(char * fname="aa.event.root", Int_t nevents=10){
19 
20  fname="outPPV-G/st_physics_6151011_raw_2020001.event.root";// daq1
21  char * fname="/star/institutions/iucf/balewski/2006-ppv-eval/test10/st_physics_adc_7118049_raw_1070001.event.root";
22 
23  char *outF="res.dat";
24  FILE *fd=fopen(outF,"w"); assert(fd);
25 
26  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
27  loadSharedLibraries();
28  assert( !gSystem->Load("StEEmcUtil.so"));
29 
30  cout << " loading done " << endl;
31 
32  // Load my makers
33 
34  // create chain
35  chain = new StChain("bfc");
36  //chain->SetDebug();
37 
38  // Now we add Makers to the chain...
39 
40  // StIOMaker - to read files ...
41  StIOMaker* ioMaker = new StIOMaker();
42  //ioMaker->SetFile("photon_bemc.event.root");
43  ioMaker->SetFile(fname);
44  //ioMaker->SetDebug();
45  ioMaker->SetIOMode("r");
46  ioMaker->SetBranch("*",0,"0"); //deactivate all branches
47  ioMaker->SetBranch("geantBranch",0,"r"); //activate geant Branch
48  ioMaker->SetBranch("eventBranch",0,"r"); //activate Event Branch
49  ioMaker->SetIOMode("r");
50 
51  // StMcEventMaker
52  // StMcEventMaker *mcEventMaker = new StMcEventMaker();
53 
54  // My Makers
55  // StEmcTrigSimuMaker *myMk2=new StEmcTrigSimuMaker("eemcTrigMaker");
56 
57  // Now execute the chain Init functions
58  chain->PrintInfo();
59  chain->ls(3);
60  Int_t initStat = chain->Init(); // This should call the Init() method in ALL makers
61  if (initStat) chain->Fatal(initStat, "during Init()");
62 
63  int istat=0,iev=0;
64 
65  // Do the event loop
66  while(1) {
67  if (iev>=nevents) break;
68  chain->Clear();
69  istat = chain->Make();
70  iev++;
71  if(istat) break;
72  cout << "---------------------- Processing Event : " << iev << " ---------------------- " << istat<<endl;
73 
74 
75  // if(iev<17) continue;
76  if (istat == kStEOF || istat == kStFatal) break;
77 
78  StEvent* mEvent = (StEvent*)chain->GetInputDS("StEvent");
79  assert(mEvent);// fix your chain or open the right event file
80  StTriggerIdCollection *tic=mEvent->triggerIdCollection();
81  assert(tic);
82 
83  // if(! isTrig(tic,trigM)) continue;
84  isTrig(tic,trigB);
85  isTrig(tic,trigE);
86  isTrig(tic,trigZ);
87  isTrig(tic,trigM);
88  isTrig(tic,trigJ);
89  int nV=mEvent->numberOfPrimaryVertices();
90  int iv;
91  if(nV>1) printf("######\n");
92  printf("eveID=%d nPrimVert=%d\n", mEvent->id(),nV);
93  fprintf(fd,"%5d %5d %d%d%d%d%d %2d ",iev,mEvent->id(),
94  isTrig(tic,trigB),isTrig(tic,trigE),isTrig(tic,trigZ),
95  isTrig(tic,trigM), isTrig(tic,trigJ), nV);
96 
97  for(iv=0;iv<nV;iv++) {
98  StPrimaryVertex *V=mEvent->primaryVertex(iv);
99  assert(V);
100  StThreeVectorF &r=V->position();
101  StThreeVectorF &er=V->positionError();
102  printf("iv=%d Vz=%.2f +/-%.2f \n",iv,r.z(),er.z() );
103  fprintf(fd,"%.1f %d ",r.z(),V->numberOfDaughters());
104  printf(" nPrimTr=%d , VFid=%d:: ntrVF=%d nCtb=%d nBemc=%d nEEmc=%d nTpc=%d sumPt=%.1f rank=%g\n"
105  ,V->numberOfDaughters(), V->vertexFinderId() ,V->numTracksUsedInFinder() ,
106  V->numMatchesWithCTB() ,V-> numMatchesWithBEMC() ,V->numMatchesWithEEMC() ,
107  V->numTracksCrossingCentralMembrane() ,V->sumOfTrackPt() ,V->ranking());
108 
109  continue;
110  int nPrTr=0;
111  //.... access prim tracks for given vertex
112  int itr;
113  for(itr=0; itr<V->numberOfDaughters(); itr++) {
114  StTrack *track=V-> daughter(itr);
115  if(track==0) continue;
116  if (track->flag() <0 ) continue;
117  printf("itr=%d pT=%.1f eta=%.2f nFitP=%d DCA=%.1f\n",itr,
118  track->geometry()->momentum().mag(),
119  track->geometry()->momentum().pseudoRapidity(),
120  track->fitTraits().numberOfFitPoints(),
121  track->geometry()->helix().distance(V->position()));
122  nPrTr++;
123  }
124 
125  printf(" counted nPrimTr=%d \n",nPrTr);
126  } // end of loop over vertices
127  fprintf(fd,"\n");
128  StEmcCollection* emcC =(StEmcCollection*)mEvent->emcCollection(); assert(emcC);
129  // print Endcap hits in StEvent
130  // printETOW(emcC->detector(13));
131  // printEPRE(emcC->detector(14));
132  //printESMD(emcC->detector(15));
133  // printESMD(emcC->detector(16));
134 
135  printRaw(emcC->eemcRawData());
136 
137  printRawBEMC(emcC->bemcRawData());
138 
139  // if(iev<=2)
140 
141  } // Event Loop
142  chain->Finish();
143  // delete myMk2;
144  fclose(fd);
145 
146 }
147 
148 // ****************************************************************************/
149 
150 void printRawBEMC(StEmcRawData *raw) {
151 
152 
153  if(!raw) return;
154 
155 /*
156 data banks
157 0 - tower
158 1-8 - SMD
159 9-12- PSD
160 */
161 
162  int NBANK = 13;
163 
164  int tot=0;
165 
166 //for the headers
167  for(int i = 0; i<NBANK;i++) {
168  if(raw->header(i)) {
169  int size = raw->sizeHeader(i);
170  printf("======BTOW BANK=%d size: head=%d, data=%d\n",i,size,raw->sizeData(i));
171  continue;
172  for(int j = 0;j<size;j++) {
173  if(j%16==0) printf("\n");
174  printf("0x%04x ",raw->header(i,j));
175  }
176  }
177 
178  if(raw->data(i)) {
179  int size = raw->sizeData(i);
180  printf("\nBANK=%d data size=%d",i,size);
181  for(int j = 0;j<size;j++) {
182  if(j%16==0) printf("\n");
183  printf("0x%04x ",raw->data(i,j));
184  tot++;
185  }
186  }
187  printf("\n bank=%d tot=%d\n",i,tot);
188  }
189 }
190 
191 
192 
193 //=============================================
194 //=============================================
195 //=============================================
196 
197 printRaw( StEmcRawData* raw) {
198 
199  printf("printRaw(%p)\n",raw);
200 
201  assert(raw);
202  int icr;
203  printf("nBlocks=%d\n",raw->getNBlocks());
204  EEfeeDataBlock block;
205  for(icr=0; icr<raw->getNBlocks();icr++) {
206  if(raw->sizeData(icr)<=0) continue;
207 
208  const UShort_t* head=raw->header(icr);
209  const UShort_t* data=raw->data(icr);
210  assert(head);
211  printf("icr=%d, size: head=%d data=%d\n",icr,raw->sizeHeader(icr),raw->sizeData(icr));
212 
213  int i;
214  block.clear();
215  block.setHead(raw->header(icr));
216  block.setDataArray(raw->data(icr),raw->sizeData(icr));
217  continue;
218  if(icr>=6) continue; // just towers
219  block.print(0);
220 
221  }
222 
223 }
224 //=============================================
225 //=============================================
226 //=============================================
227 
228 printETOW( StEmcDetector* det) {
229 
230  printf("printTw(%p)\n",det);
231  assert(det);
232  printf("towers nHit=%d nMod=%d\n",det->numberOfHits(),det->numberOfModules());
233  int nPos=0;
234  for(int mod=1;mod<=det->numberOfModules();mod++) {
235  StEmcModule* module=det->module(mod);
236  printf("ETOW sector=%d nHit=%d\n",mod,module->numberOfHits());
237  StSPtrVecEmcRawHit& hit= module->hits();
238  int ih;
239  for(ih=0;ih<hit.size();ih++){
240  StEmcRawHit *x=hit[ih];
241  int sec=x->module();
242  char sub='A'+x->sub()-1;
243  int eta=x->eta();
244  int adc=x->adc();
245  // if(adc>0) continue;
246  printf("ih=%d %02dT%c%02d -->adc=%d ener=%f\n",ih,sec,sub,eta,adc, x->energy());
247  if(adc>0) nPos++;
248  int adcX=1000+ (eta-1) + (sub-'A')*12 +(sec-1)*60;
249  // assert(adc==adcX );
250 
251  // printf("ih=%d, mod=%d eta=%d sub=%d adc=%d\n",ih,x->module(),x->eta(),x->sub(),x->adc());
252  }
253  printf("nPos=%d\n",nPos);
254  }
255  printf("total nPos=%d\n",nPos);
256  printf("nPos=%d of %d \n",nPos,det->numberOfHits());
257 
258 }
259 
260 
261 //=============================================
262 //=============================================
263 //=============================================
264 
265 printEPRE( StEmcDetector* det) {
266 
267  printf("printPre/post(%p)\n",det);
268  assert(det);
269  printf("pre/post nHit=%d nMod=%d\n",det->numberOfHits(),det->numberOfModules());
270  int nPos=0;
271  for(int imod=1;imod<=det->numberOfModules();imod++) {
272  StEmcModule* module=det->module(imod);
273  printf("EPRE sect=%d nHit=%d\n",imod, module->numberOfHits());
274  StSPtrVecEmcRawHit& hit= module->hits();
275  int ih;
276  for(ih=0;ih<hit.size();ih++){
277  StEmcRawHit *x=hit[ih];
278  int sec=x->module();
279  int ss=x->sub()-1;
280  char sub='A'+ss%5;
281  char preL='P'+ss/5;
282  int eta=x->eta();
283  int adc=x->adc();
284  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);
285  if(adc>0) nPos++;
286  int adcX= (eta-1) + (sub-'A')*12 +(sec-1)*60 + 1000*(preL-'P'+1);
287  // assert(adc==adcX );
288  }
289  printf("nPos=%d\n",nPos);
290  }
291  // printf("total nPos=%d\n",nPos);
292  printf("nPos=%d of %d \n",nPos,det->numberOfHits());
293 
294 }
295 
296 
297 
298 //=============================================
299 //=============================================
300 //=============================================
301 
302 printESMD( StEmcDetector* det) {
303 
304  printf("printSMD/post(%p)\n",det);
305  assert(det);
306  printf("U-SMD nHit=%d nMod=%d\n",det->numberOfHits(),det->numberOfModules());
307  int nPos=0;
308  for(int imod=1;imod<=det->numberOfModules();imod++) {
309  StEmcModule* module=det->module(imod);
310  printf("ESMD sector=%d nHit=%d\n",imod, module->numberOfHits());
311  StSPtrVecEmcRawHit& hit= module->hits();
312  int ih;
313  for(ih=0;ih<hit.size();ih++){
314  StEmcRawHit *x=hit[ih];
315  int sec=x->module();
316  int strip=x->eta();
317  int adc=x->adc();
318  printf("ih=%d %02dU%03d -->adc=%d ener=%f\n",ih,sec,strip,adc, x->energy());
319  if(adc>0) nPos++;
320  int adcX= 1000+(strip -1) +(sec-1)*300;
321  // assert(adc==adcX );
322  }
323  printf(" nPos=%d\n",nPos);
324  }
325  printf("nPos=%d of %d \n",nPos,det->numberOfHits());
326 
327 
328 }
329 
330 //--------------------------------------
331 bool isTrig(StTriggerIdCollection *tic,int *trigL){
332  int i;
333  const StTriggerId *l1=tic->l1();
334 
335  for(i=0;trigL[i]>0;i++) {
336  // printf("%d tid=%d found=%d\n",i,trigL[i],l1->isTrigger(trigL[i]));
337  if(l1->isTrigger(trigL[i])) return true;
338  }
339  return false;
340 }
341 
342 
343 
344 
345 
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