StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
rdMuDst2print.C
1 class StChain;
4 StChain *chain=0;
5 
6 
7 
8 int rdMuDst2print(
9  char* file = "st_physics_12033050_raw_4010001.MuDst.root",
10  int nEve=10,
11  char* inDir = "./"
12  )
13 {
14  Int_t nFiles = 1;
15 
16  inDir="/star/data05/scratch/balewski/stW-2012A/data/";
17  file="st_W_13078014_raw_4360001.MuDst.root";
18 
19 
20  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
21  loadSharedLibraries();
22 
23  cout << " loading done " << endl;
24 
25 
26  // create chain
27  chain = new StChain("StChain");
28 
29  // Now we add Makers to the chain...
30  muMk = new StMuDstMaker(0,0,inDir,file,"MuDst.root",nFiles);
31  TChain* tree=muMk->chain(); assert(tree);
32  int nEntries=(int) tree->GetEntries();
33  printf("total eve in muDst chain =%d\n",nEntries); // return ;
34  if(nEntries<0) return;
35 
36 
37  chain->Init();
38  chain->ls(3);
39 
40  h1=new TH1F("nP","# of prim tracks per vertex",100,0,200);
41  h2=new TH1F("vR","PPV Vertex rank; rank", 300, -1.2e6, 1.2e6); h2->SetLineColor(kRed);
42  h3=new TH1F("vRL","PPV Vertex rank, funny X-axis; X=Log10(rank-1e6)+ offset", 150, -9,21);
43  h2->GetXaxis()->SetTitleSize(.043);
44  h2->GetXaxis()->SetTitleSize(.043);
45 
46  h4=new TH1F("trPhi"," prim tracks phi if PT>1.0 GeV/c; phi (rad)",50,-3.2,3.2);
47  h5=new TH1F("zVerTrg"," Z trg-vertex , rank>0; Z (cm)", 50,-200,200);
48  h6=new TH1F("zVerPlp"," Z pileup-vertex , rank<0; Z (cm)", 50,-200,200);
49  h7=new TH1F("nPrV","# of prim tr used by PPV; rank>0",15,0,30);
50  //---------------------------------------------------
51  int eventCounter=0;
52  int t1=time(0);
53 
54  for (Int_t iev=0;iev<nEntries; iev++) {
55  if(eventCounter>=nEve) break;
56  chain->Clear();
57  int stat = chain->Make();
58  if(stat) break; // EOF or input error
59  eventCounter++;
60 
61  // Access to muDst .......................
62  StMuEvent* muEve = muMk->muDst()->event();
63 
64  StEventInfo &info=muEve->eventInfo();
65  int nPrimV=muMk->muDst()->numberOfPrimaryVertices();
66 
67  StMuTriggerIdCollection *tic=&(muEve->triggerIdCollection());
68  int trigID=380305; // EHT1*L2EW in 2012
69  bool isL2EW=tic->nominal().isTrigger(trigID);
70 
71  Int_t nGlobTrAll=muMk->muDst()->GetNGlobalTrack();
72 
73  TArrayI& l2Array = muEve->L2Result();
74 
75  if(eventCounter%1==0) {
76  printf("ieve=%d eventID %d nPrimV=%d nGlobTrAll=%d =============\n", eventCounter,info.id(),nPrimV,nGlobTrAll);
77  printf("TrigID=%d fired=%d\n",trigID,isL2EW);
78  }
79  printL0Trig(tic);
80  printL2Trig(l2Array);
81 
82  int iv;
83  if(0)for(iv=0;iv<nPrimV;iv++) {
84  StMuPrimaryVertex* V= muMk->muDst()->primaryVertex(iv);
85  assert(V);
86  muMk->muDst()->setVertexIndex(iv);
87  StThreeVectorF &r=V->position();
88  StThreeVectorF &er=V->posError();
89  printf("iv=%d Vz=%.2f +/-%.2f \n",iv,r.z(),er.z() );
90  // count prim tracks for this vert
91  int nPrimTr =0;
92  int itr;
93  Int_t nPrimTrAll=muMk->muDst()->GetNPrimaryTrack();
94  for(itr=0;itr<nPrimTrAll;itr++) {
95  StMuTrack *pr_track=muMk->muDst()->primaryTracks(itr);
96  if(pr_track->flag()<=0) continue;
97  nPrimTr ++;
98  }
99  if(nPrimV>0)h1->Fill(nPrimTr);
100  float rank=V->ranking();
101  h2->Fill(rank);
102  if(rank>1e6) h3->Fill(log(rank-1e6)+10);
103  else if(rank>0) h3->Fill(log(rank));
104  else h3->Fill(log(rank+1e6)-10);
105 
106  if(1)printf(" nPrimTr=%d , Z=%.1f VFid=%d:: ntrVF=%d nCtb=%d nBemc=%d nEEmc=%d nTpc=%d sumPt=%.1f rank=%g\n"
107  ,nPrimTr,r.z(), V->vertexFinderId() ,V->nTracksUsed() ,V->nCTBMatch() ,V-> nBEMCMatch() ,V->nEEMCMatch() ,V->nCrossCentralMembrane() ,V->sumTrackPt() ,V->ranking());
108  if (rank>0) h5->Fill(r.z());
109  if (rank>0) h7->Fill(V->nTracksUsed());
110  if (rank<0) h6->Fill(r.z());
111  }
112 
113  if(0) // do NOT print prim tracks
114  for(iv=0;iv<nPrimV;iv++) {
115  muMk->muDst()->setVertexIndex(iv);
116  Int_t nPrimTrAll=muMk->muDst()->GetNPrimaryTrack();
117  cout<<"\n Prim "<<nPrimTrAll<<" tracks belonging to "<<iv<<"-th prim vertex"<<endl;
118 
119  int itr;
120  int ntr=0;
121 
122  for(itr=0;itr<nPrimTrAll;itr++) {
123  StMuTrack *pr_track=muMk->muDst()->primaryTracks(itr);
124  if(pr_track->flag()<=0) continue;
125  ntr++;
126  cout << "\nPrimary track " << ntr << " momentum(P vect) " << pr_track->p() << " PT="<<pr_track->pt()<< " recoCharge="<<pr_track->charge()<< endl; cout << "\t flag=" << pr_track->flag() << " nHits=" << pr_track->nHits()<< " vertID="<< pr_track->vertexIndex()<< endl;
127  cout << "\t primV("<<iv<<") primDCA=" << pr_track->dca(iv) << endl;
128  if(pr_track->dca(iv).mag()>5) cout << "^^^^^ 3D DCA magnitude="<<pr_track->dca(iv).mag()<<endl;
129  // cout << "\t first point " << pr_track->firstPoint() << endl;
130  // cout << "\t last point " << pr_track->lastPoint() << endl;
131  if(pr_track->pt()>1.0) h4->Fill(pr_track->phi());
132 
133  } // end of loop over tracks
134 
135  }// end of loop over vertices
136 
137  continue;
138 
139  StMuEmcCollection* emc = muMk->muDst()->muEmcCollection();
140  if (!emc) {
141  printf(" No EMC data for this event\n");
142  return kStOK;
143  }
144  //printEEtower(emc);
145  // printEEpre(emc);
146  // printEEsmd(emc);
147  printBEtower(emc);
148  //printBEpre(emc);
149  //printBEsmd(emc);
150 
151 
152  }
153  printf("****************************************** \n");
154  // return;
155  int t2=time(0);
156  if(t2==t1) t2=t1+1;
157  float tMnt=(t2-t1)/60.;
158  float rate=1.*eventCounter/(t2-t1);
159  printf("sorting done %d of nEve=%d, CPU rate=%.1f Hz, total time %.1f minute(s) \n\n",eventCounter,nEntries,rate,tMnt);
160  c=new TCanvas(); c->Divide(2,2);
161  c->cd(1); h5->Fit("gaus"); //h5->Draw();
162  c->cd(3); h6->Fit("gaus"); //h5->Draw();
163  c->cd(2); h3->Draw();
164  c->cd(4); h7->Draw();
165 
166  return;
167 
168 }
169 
170 
171 //===========================================
172 //===========================================
173 printEEtower( StMuEmcCollection* emc ) {
174  int sec,eta,sub,adc;
175  StMuEmcHit *hit;
176 
177  int i, nh;
178 
179  printf("\Total %d hits in Tower (only ADC>0)\n",emc->getNEndcapTowerADC());
180  nh=0;
181  for (i=0; i< emc->getNEndcapTowerADC(); i++) {
182  emc->getEndcapTowerADC(i,adc,sec,sub,eta);
183  if (adc<=0) continue; // print only non-zero values
184  nh++;
185  printf("i=%d Tower %2.2dT%c%2.2d adc=%4d\n",i,sec,sub+'A'-1,eta,adc );
186  // printf(" Tower isec=%d ieta=%d isub=%d adc=%4d\n",sec,eta, sub,adc );
187  int adcX=1000+ (eta-1) + (sub-1)*12 +(sec-1)*60;
188  // assert(adc==adcX );
189 }
190  printf(" Total %d towers with ADC>0\n",nh);
191 }
192 
193 
194 //===========================================
195 //===========================================
196 printEEpre( StMuEmcCollection* emc ) {
197  int sec,eta,sub,pre,adc;
198  StMuEmcHit *hit;
199 
200  int i, nh;
201  nh= emc->getNEndcapPrsHits();
202  printf("\nTotal %d hits in pre1+2+post\n",nh);
203  for (i=0; i<nh; i++) {
204  hit=emc->getEndcapPrsHit(i,sec,sub,eta,pre);
205  int ss=sub + 5*(pre-1);
206  adc=hit->getAdc();
207  printf("i=%d pre/post(%d) %2.2d%c%c%2.2d : energy=%f adc=%d\n",i,pre,sec,pre+'P'-1,sub+'A'-1,eta,hit->getEnergy(),adc);
208  int adcX= (eta-1) + (sub-1) *12 +(sec-1)*60 + 1000*pre;
209 
210  // assert(adc==adcX );
211 
212  }
213 }
214 
215 
216 //===========================================
217 //===========================================
218 printEEsmd( StMuEmcCollection* emc ) {
219  int sec,strip,adc;
220  char uv='U';
221 
222  for(uv='U'; uv<='V'; uv++) {
223  int nh= emc->getNEndcapSmdHits(uv);
224  printf("\nTotal %d hits in SMD-%c\n",nh,uv);
225  for (int i=0; i<nh; i++) {
226  hit=emc->getEndcapSmdHit(uv,i,sec,strip);
227  adc=hit->getAdc();
228  printf(" SMD-%c %2.2d%c%3.3d : energy=%f adc=%d\n",uv,sec,uv,strip,hit->getEnergy(),adc);
229  int adcX= 1000 + strip-1 +(sec-1)*300;
230  // assert(adc==adcX );
231  }
232  }
233 }
234 
235 //===========================================
236 //===========================================
237 printBEtower( StMuEmcCollection* emc ) {
238  int sec,eta,sub,adc;
239  StMuEmcHit *hit;
240 
241  int i, nh;
242 
243  printf("\Total hits in Tower (only ADC>0)\n");
244  nh=0;
245  for (i=0; i< 4800; i++) {
246  int adc = emc->getTowerADC(i);
247  if (adc<=1000) continue; // print only non-zero values
248  nh++;
249  printf(" Tower id=%d adc=%4d\n",i,adc );
250  // assert(adc==adcX );
251 }
252  printf(" --> %d towers with ADC>thr\n",nh);
253 }
254 
255 
256 
257 
258 //===========================================
259 //===========================================
260 printBEpre( StMuEmcCollection* emc ) {
261 
262  int i, nh;
263  nh = emc->getNPrsHits();
264  printf("\nTotal %d hits in pre1\n",nh);
265 
266  int n1=0;
267  for (i=0; i<nh; i++) {
268  StMuEmcHit * hit = emc->getPrsHit(i);
269  int adc = hit->getAdc();
270  int id=hit->getId();
271  if(adc<4) continue;
272  n1++;
273  printf("BPRS i=%d, id=%d adc = %d\n",i,id,adc);
274  }
275  printf(" --> %d BPRS hits with ADC>thr\n",n1);
276 }
277 
278 //===========================================
279 //===========================================
280 printBEsmd( StMuEmcCollection* emc ) {
281 
282  int n1=0,n2=0;
283  int nh = emc->getNSmdHits(3);
284  printf("\nTotal %d hits in SMDE\n",nh);
285  for (int i=0; i<nh; i++) {
286  StMuEmcHit * hit = emc->getSmdHit(i,3);
287  adc = hit->getAdc();
288  int id=hit->getId();
289  if(adc<4) continue;
290  n1++;
291  printf("BSMDE i=%d, id=%d adc = %d\n",i,id,adc);
292  }
293 
294  int nh = emc->getNSmdHits(4);
295  printf("\nTotal %d hits in SMDP\n",nh);
296  for (int i=0; i<nh; i++) {
297  hit = emc->getSmdHit(i,4);
298  adc = hit->getAdc();
299  int id=hit->getId();
300  if(adc<4) continue;
301  n2++;
302  printf("BSMDP i=%d,id=%d adc = %d\n",i,id,adc);
303  }
304 
305  printf(" --> %d BSMD-E & %d BSMD-P hits with ADC>thr\n",n1,n2);
306 }
307 
308 //=======================================
309 printL2Trig( TArrayI& l2Array) {
310 
311  printf("AccessL2Decision() from regular muDst: L2Ar-size=%d\n",l2Array.GetSize());
312  unsigned int *l2res=(unsigned int *)l2Array.GetArray();
313  for(int i=0;i<l2Array.GetSize();i++){
314  if(l2res[i]==0) continue;
315  printf("i=%d val=0x%08x\n",i,l2res[i]);
316  }
317 }
318 
319 
320 //--------------------------------------
321 void printL0Trig(StMuTriggerIdCollection *tic){
322 
323  const StTriggerId &l1=tic->l1();
324  vector<unsigned int> idL=l1.triggerIds();
325  printf("nTrig=%d, trigID: ",idL.size());
326  for(unsigned int i=0;i<idL.size(); i++){
327  printf("%d, ",idL[i]);
328  }
329  printf("\n dump L2Array:");
330 
331  //const int EEMCW_off=35; // valid only for 2011 run
332 
333 
334 
335 
336 }
337 
static StMuPrimaryVertex * primaryVertex()
return pointer to current primary vertex
Definition: StMuDst.h:322
int getId() const
Return Module number.
Definition: StMuEmcHit.h:18
Int_t vertexIndex() const
Returns index of associated primary vertex.
Definition: StMuTrack.cxx:600
float getEnergy() const
Return Hit energy.
Definition: StMuEmcHit.h:21
StMuDst * muDst()
Definition: StMuDstMaker.h:425
Double_t pt() const
Returns pT at point of dca to primary vertex.
Definition: StMuTrack.h:256
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
int getAdc() const
Return ADC value.
Definition: StMuEmcHit.h:19
short flag() const
Returns flag, (see StEvent manual for type information)
Definition: StMuTrack.h:230
Short_t charge() const
Returns charge.
Definition: StMuTrack.h:255
const StThreeVectorF & p() const
Returns 3-momentum at dca to primary vertex.
Definition: StMuTrack.h:259
virtual void ls(Option_t *option="") const
Definition: TDataSet.cxx:495
static TObjArray * primaryTracks()
returns pointer to a list of tracks belonging to the selected primary vertex
Definition: StMuDst.h:301
virtual Int_t Make()
Definition: StChain.cxx:110
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
Definition: Stypes.h:40
UShort_t nHits() const
Bingchu.
Definition: StMuTrack.h:237
StThreeVectorF dca(Int_t vtx_id=-1) const
Returns 3D distance of closest approach to primary vertex.
Definition: StMuTrack.cxx:359
TChain * chain()
In read mode, returns pointer to the chain of .MuDst.root files that where selected.
Definition: StMuDstMaker.h:426
Double_t phi() const
Returns phi at point of dca to primary vertex.
Definition: StMuTrack.h:258
static void setVertexIndex(Int_t vtx_id)
Set the index number of the current primary vertex (used by both primaryTracks() functions and for St...
Definition: StMuDst.cxx:273
Collection of trigger ids as stored in MuDst.