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 StChain *chain=0;
8 
9 void rdSt2print(Int_t nevents=100){
10 
11  char * fname="/star/data09/reco/ppProductionTrans/FullField/dev/2006/129/7129060/st_physics_7129060_raw_1030002.event.root";
12 
13  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
14  loadSharedLibraries();
15  cout << " loading done " << endl;
16 
17  // Load my makers
18 
19  // create chain
20  chain = new StChain("bfc");
21  //chain->SetDebug();
22 
23  // Now we add Makers to the chain...
24 
25  // StIOMaker - to read files ...
26  StIOMaker* ioMaker = new StIOMaker();
27  //ioMaker->SetFile("photon_bemc.event.root");
28  ioMaker->SetFile(fname);
29  //ioMaker->SetDebug();
30  ioMaker->SetIOMode("r");
31  ioMaker->SetBranch("*",0,"0"); //deactivate all branches
32  ioMaker->SetBranch("geantBranch",0,"r"); //activate geant Branch
33  ioMaker->SetBranch("eventBranch",0,"r"); //activate Event Branch
34  ioMaker->SetIOMode("r");
35 
36  // StMcEventMaker
37  // StMcEventMaker *mcEventMaker = new StMcEventMaker();
38 
39  // My Makers
40  // StEmcTrigSimuMaker *myMk2=new StEmcTrigSimuMaker("eemcTrigMaker");
41 
42  // Now execute the chain Init functions
43  chain->PrintInfo();
44  chain->ls(3);
45  Int_t initStat = chain->Init(); // This should call the Init() method in ALL makers
46  if (initStat) chain->Fatal(initStat, "during Init()");
47 
48  int istat=0,iev=1;
49 
50  // Do the event loop
51  while(iev<=nevents && istat!=2) {
52  chain->Clear();
53  cout << "---------------------- Processing Event : " << iev << " ----------------------" << endl;
54  istat = chain->Make(iev); // This should call the Make() method in ALL makers
55  iev++;
56  if (istat == kStEOF || istat == kStFatal) break;
57 
58  StEvent* mEvent = (StEvent*)chain->GetInputDS("StEvent");
59  assert(mEvent);// fix your chain or open the right event file
60 
61  int nV=mEvent->numberOfPrimaryVertices();
62  if(nV==0) continue;
63  int iv;
64  printf("eveID=%d nPrimVert=%d\n", mEvent->id(),nV);
65  for(iv=0;iv<nV;iv++) {
66  StPrimaryVertex *V=mEvent->primaryVertex(iv);
67  assert(V);
68  StThreeVectorF &r=V->position();
69  StThreeVectorF &er=V->positionError();
70  printf("iv=%d Vz=%.2f +/-%.2f \n",iv,r.z(),er.z() );
71  printf(" nDaugh=%d , VFid=%d:: ntr=%d nCtb=%d nBemc=%d nEEmc=%d nTpc=%d sumPt=%.1f rank=%g xchi2=%g\n"
72  ,V->numberOfDaughters(), V->vertexFinderId() ,V->numTracksUsedInFinder() ,V->numMatchesWithCTB() ,V-> numMatchesWithBEMC() ,V->numMatchesWithEEMC() ,V->numTracksCrossingCentralMembrane() ,V->sumOfTrackPt() ,V->ranking(), V->chiSquared());
73  }
74 
75 
76  StEmcCollection* emcC =(StEmcCollection*)mEvent->emcCollection(); assert(emcC);
77 
78  //................... print Endcap hits in StEvent
79  // printETOW(emcC->detector(13));
80  // printEPRE(emcC->detector(14));
81  //printESMD(emcC->detector(15));
82  // printESMD(emcC->detector(16));
83 
84  // printRaw(emcC->eemcRawData());
85 
86  //................... print Barrel hits in StEvent
87  printRawBEMC(emcC->bemcRawData());
88 
89  } // Event Loop
90  chain->Finish();
91  // delete myMk2;
92 
93 
94 }
95 
96 // ****************************************************************************/
97 
98 void printRawBEMC(StEmcRawData *raw) {
99 
100 
101  if(!raw) return;
102 
103 /*
104 data banks
105 0 - tower
106 1-8 - SMD
107 9-12- PSD
108 */
109 
110  int NBANK = 13;
111 
112 
113 
114 //for the headers
115  for(int i = 0; i<NBANK;i++) {
116  int size = raw->sizeHeader(i);
117  printf("\n======\nBANK=%d headerSize=%d dataSize=%d\n",i,size,raw->sizeData(i));
118 
119  if(raw->header(i)) {
120  for(int j = 0;j<size;j++) {
121  if(j%16==0) printf("\n");
122  printf("0x%04x ",raw->header(i,j));
123  }
124  }
125  int tot=0;
126 #if 1
127  if(raw->data(i)) {
128  int size = raw->sizeData(i);
129  printf("\nBANK=%d data size=%d",i,size);
130  for(int j = 0;j<size;j++) {
131  if(j%16==0) printf("\n");
132  printf("0x%04x ",raw->data(i,j));
133  tot++;
134  }
135  }
136 #endif
137  printf("\n tot=%d\n",tot);
138  }
139 }
140 
141 
142 
143 //=============================================
144 //=============================================
145 //=============================================
146 
147 printRaw( StEmcRawData* raw) {
148 
149  printf("printRaw(%p)\n",raw);
150 
151  assert(raw);
152  int icr;
153  printf("nBlocks=%d\n",raw->getNBlocks());
154  EEfeeDataBlock block;
155  for(icr=0; icr<raw->getNBlocks();icr++) {
156  if(raw->sizeData(icr)<=0) continue;
157 
158  const UShort_t* head=raw->header(icr);
159  const UShort_t* data=raw->data(icr);
160  assert(head);
161  printf("icr=%d, size: head=%d data=%d\n",icr,raw->sizeHeader(icr),raw->sizeData(icr));
162 
163  int i;
164  block.clear();
165  block.setHead(raw->header(icr));
166  block.setDataArray(raw->data(icr),raw->sizeData(icr));
167  if(icr>=6) continue; // just towers
168  block.print(0);
169 
170  }
171 
172 }
173 //=============================================
174 //=============================================
175 //=============================================
176 
177 printETOW( StEmcDetector* det) {
178 
179  printf("printTw(%p)\n",det);
180  assert(det);
181  printf("towers nHit=%d nMod=%d\n",det->numberOfHits(),det->numberOfModules());
182  int nPos=0;
183  for(int mod=1;mod<=det->numberOfModules();mod++) {
184  StEmcModule* module=det->module(mod);
185  printf("ETOW sector=%d nHit=%d\n",mod,module->numberOfHits());
186  StSPtrVecEmcRawHit& hit= module->hits();
187  int ih;
188  for(ih=0;ih<hit.size();ih++){
189  StEmcRawHit *x=hit[ih];
190  int sec=x->module();
191  char sub='A'+x->sub()-1;
192  int eta=x->eta();
193  int adc=x->adc();
194  // if(adc>0) continue;
195  printf("ih=%d %02dT%c%02d -->adc=%d ener=%f\n",ih,sec,sub,eta,adc, x->energy());
196  if(adc>0) nPos++;
197  int adcX=1000+ (eta-1) + (sub-'A')*12 +(sec-1)*60;
198  // assert(adc==adcX );
199 
200  // printf("ih=%d, mod=%d eta=%d sub=%d adc=%d\n",ih,x->module(),x->eta(),x->sub(),x->adc());
201  }
202  printf("nPos=%d\n",nPos);
203  }
204  printf("total nPos=%d\n",nPos);
205  printf("nPos=%d of %d \n",nPos,det->numberOfHits());
206 
207 }
208 
209 
210 //=============================================
211 //=============================================
212 //=============================================
213 
214 printEPRE( StEmcDetector* det) {
215 
216  printf("printPre/post(%p)\n",det);
217  assert(det);
218  printf("pre/post nHit=%d nMod=%d\n",det->numberOfHits(),det->numberOfModules());
219  int nPos=0;
220  for(int imod=1;imod<=det->numberOfModules();imod++) {
221  StEmcModule* module=det->module(imod);
222  printf("EPRE sect=%d nHit=%d\n",imod, module->numberOfHits());
223  StSPtrVecEmcRawHit& hit= module->hits();
224  int ih;
225  for(ih=0;ih<hit.size();ih++){
226  StEmcRawHit *x=hit[ih];
227  int sec=x->module();
228  int ss=x->sub()-1;
229  char sub='A'+ss%5;
230  char preL='P'+ss/5;
231  int eta=x->eta();
232  int adc=x->adc();
233  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);
234  if(adc>0) nPos++;
235  int adcX= (eta-1) + (sub-'A')*12 +(sec-1)*60 + 1000*(preL-'P'+1);
236  // assert(adc==adcX );
237  }
238  printf("nPos=%d\n",nPos);
239  }
240  // printf("total nPos=%d\n",nPos);
241  printf("nPos=%d of %d \n",nPos,det->numberOfHits());
242 
243 }
244 
245 
246 
247 //=============================================
248 //=============================================
249 //=============================================
250 
251 printESMD( StEmcDetector* det) {
252 
253  printf("printSMD/post(%p)\n",det);
254  assert(det);
255  printf("U-SMD nHit=%d nMod=%d\n",det->numberOfHits(),det->numberOfModules());
256  int nPos=0;
257  for(int imod=1;imod<=det->numberOfModules();imod++) {
258  StEmcModule* module=det->module(imod);
259  printf("ESMD sector=%d nHit=%d\n",imod, module->numberOfHits());
260  StSPtrVecEmcRawHit& hit= module->hits();
261  int ih;
262  for(ih=0;ih<hit.size();ih++){
263  StEmcRawHit *x=hit[ih];
264  int sec=x->module();
265  int strip=x->eta();
266  int adc=x->adc();
267  printf("ih=%d %02dU%03d -->adc=%d ener=%f\n",ih,sec,strip,adc, x->energy());
268  if(adc>0) nPos++;
269  int adcX= 1000+(strip -1) +(sec-1)*300;
270  // assert(adc==adcX );
271  }
272  printf(" nPos=%d\n",nPos);
273  }
274  printf("nPos=%d of %d \n",nPos,det->numberOfHits());
275 
276 
277 }
278 
279 
280 
281 
282 
283 
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
virtual Int_t Finish()
Definition: StChain.cxx:85
virtual void ls(Option_t *option="") const
Definition: TDataSet.cxx:495
Definition: Stypes.h:43
virtual Int_t Make()
Definition: StChain.cxx:110