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