StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
rdMu2Plot.C
1 class StChain;
3 StChain *chain=0;
4 const int mxv=4;
5 TH1F *hA[8], *hT[4], *hF[4];
6 
7 TFile *hf=0;
8 
9 int rdMu2PrimTr(
10  char* file = "st_physics_6145042_raw_2040013.MuDst.root",
11  Int_t nFiles = 2,
12  char* inDir = "out1/",
13  int nEve=100) {
14 
15  initHisto();
16  // inDir="out0/";
17  // file="R6145042.lis";
18 
19  inDir="/star/data04/sim/balewski/tmp2/";
20  file="st_physics_6111024_raw_1040001.MuDst.root";
21 
22  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
23  loadSharedLibraries();
24  cout << " loading done " << endl;
25 
26 
27 // create chain
28  chain = new StChain("StChain");
29 
30 // Now we add Makers to the chain...
31  muMk = new StMuDstMaker(0,0,inDir,file,"MuDst.root",nFiles);
32  TChain* tree=muMk->chain(); assert(tree);
33  int nEntries=(int)tree->GetEntries();
34  printf("total eve in chain =%d\n",nEntries);
35  printf("in=%s%s=\n",inDir,file);
36 
37  chain->Init();
38  chain->ls(3);
39 
40  int eventCounter=0;
41  int stat=0;
42 
43  //---------------------------------------------------
44  while ( stat==0 ) {// loop over events
45  if(eventCounter>=nEve) break;
46  chain->Clear();
47  stat = chain->Make();
48  if(stat) break; // EOF or input error
49  // printf("stat=%d\n", stat);
50  eventCounter++;
51 
52  // Access to muDst .......................
53  StMuEvent* muEve = muMk->muDst()->event();
54 
55  StEventInfo &info=muEve->eventInfo();
56  int nPrimV=muMk->muDst()->numberOfPrimaryVertices();
57  StMuTriggerIdCollection &tic=muEve->triggerIdCollection();
58 
59  int trigID=96211;
60  bool fired=tic.nominal().isTrigger(trigID);
61 
62  Int_t nPrimTrAll=muMk->muDst()->GetNPrimaryTrack();
63  Int_t nGlobTrAll=muMk->muDst()->GetNGlobalTrack();
64 
65  if(eventCounter%1000==0) printf("\n\n ====================%d processing eventID %d nPrimV=%d nPrimTr=%d nGlobTrAll=%d =============\n", eventCounter,info.id(),nPrimV,nPrimTrAll,nGlobTrAll);
66  // printf("TrigID=%d fired=%d\n",trigID,fired);
67 
68  // if(nPrimV>1) printf("######\n");
69 
70  hA[0]->Fill(nPrimV);
71  int iv;
72  for(iv=0;iv<nPrimV;iv++) {
73  StMuPrimaryVertex* V= muMk->muDst()->primaryVertex(iv);
74  assert(V);
75  StThreeVectorF &r=V->position();
76  StThreeVectorF &er=V->posError();
77  // printf("iv=%d Vz=%.2f +/-%.2f \n",iv,r.z(),er.z() );
78  // count prim tracks for this vert
79 
80  float rank1K=V->ranking()/1000.;
81  hA[5]->Fill(er.z() );
82  ((TH2F*) hA[6])->Fill(er.z() ,rank1K);
83 
84  if(nPrimV==1 && iv==0) hA[1]->Fill(rank1K);
85  if(nPrimV>1){
86  if(iv==0)hA[2]->Fill(rank1K);
87  if(iv==1)hA[3]->Fill(rank1K);
88  if(iv==2)hA[4]->Fill(rank1K);
89  if(iv==1)hA[7]->Fill(rank1K/muMk->muDst()->primaryVertex(0)->ranking()*1000.);
90 
91  }
92  int nPrimTr =0;
93  int itr;
94  for(itr=0;itr<nPrimTrAll;itr++) {
95  StMuTrack *pr_track=muMk->muDst()->primaryTracks(itr);
96  if(pr_track->vertexIndex()!=iv) continue;
97  if(pr_track->flag()<=0) continue;
98  if(iv<mxv) {
99  if(pr_track->topologyMap().trackTpcOnly()) hT[iv]->Fill(pr_track->nHitsFit());
100  if(pr_track->topologyMap().trackFtpc()) hF[iv]->Fill(pr_track->nHitsFit());
101  }
102  nPrimTr ++;
103  }
104  continue;
105  printf(" nPrimTr=%d , VFid=%d:: ntrVF=%d nCtb=%d nBemc=%d nEEmc=%d nTpc=%d sumPt=%.1f rank=%g\n"
106  ,nPrimTr, V->vertexFinderId() ,V->nTracksUsed() ,V->nCTBMatch() ,V-> nBEMCMatch() ,V->nEEMCMatch() ,V->nCrossCentralMembrane() ,V->sumTrackPt() ,V->ranking());
107  }
108 
109  continue; // do NOT print prim tracks for each vertex
110 
111  for(iv=0;iv<nPrimV;iv++) {
112  printf(" Prim tracks belonging to %d prim vertex:\n",iv);
113  int itr;
114  int ntr=0;
115  for(itr=0;itr<nPrimTrAll;itr++) {
116  StMuTrack *pr_track=muMk->muDst()->primaryTracks(itr);
117  if(pr_track->vertexIndex()!=iv) continue;
118  if(pr_track->flag()<=0) continue;
119  ntr++;
120  cout << "\nPrimary track " << ntr << " momentum " << pr_track->p() << endl; cout << "\t flag=" << pr_track->flag() << " nHits=" << pr_track->nHits()<< " vertID="<< pr_track->vertexIndex()<< endl;
121  cout << "\t primV("<<iv<<") primDCA=" << pr_track->dca(iv) << endl;
122  if(pr_track->dca(iv).mag()>5) cout << "^^^^^ 3D DCA magnitude="<<pr_track->dca(iv).mag()<<endl;
123  // cout << "\t first point " << pr_track->firstPoint() << endl;
124  // cout << "\t last point " << pr_track->lastPoint() << endl;
125  } // end of loop over tracks
126  }// end of loop over vertices
127 
128  continue;
129  }
130  hf->Write();
131 
132 }
133 
134 //===========================================
135 //===========================================
136 void initHisto() {
137  hf=new TFile("out.hist.root","recreate");
138  hA[0]=new TH1F("nV","# of prim vertices per eve; # vertex",10,-0.5,9.5);
139  int iv;
140  for(iv=0;iv<mxv;iv++) {
141  char tt1[100], tt2[300];
142  sprintf(tt1,"nPTv%d",iv);
143  sprintf(tt2,"nFitPoint for TPC prim tracks for vertex%d",iv);
144  hT[iv]=new TH1F(tt1,tt2,50,-0.5,49.5);
145 
146  sprintf(tt1,"nPFv%d",iv);
147  sprintf(tt2,"nFitPoint for FTPC prim tracks for vertex%d",iv);
148  hF[iv]=new TH1F(tt1,tt2,50,-0.5,49.5);
149  }
150 
151  hA[1]=new TH1F("L11","vertex rank of 1st vertex if only one found; vertex rank/1000",100,0,20);
152  hA[2]=new TH1F("Ln1","vertex rank of 1st vertex if more than one found; vertex rank/1000",100,0,20);
153  hA[3]=new TH1F("Ln2","vertex rank of 2nd vertex if more than one found; vertex rank/1000",100,0,10);
154  hA[4]=new TH1F("Ln3","vertex rank of 3rd vertex if more than one found; vertex rank/1000",100,0,10);
155  hA[5]=new TH1F("zEr","vertex Z-error; error Z (cm)",1000,0,1.);
156  TH2F *h2=new TH2F("zErL","Rank vs. vertex Z-error ; error Z (cm); rank/1000",100,0,0.5,100,0,20.);
157  hA[6]=(TH1F*) h2;
158  hA[7]=new TH1F("Ln2d1","ratio of vertex rank 2nd/1st ; rank2/rank1",100,0,1.);
159 }
160 
161 
162 //===============================================
163 pl(int page=1){
164 
165  fd=new TFile("out.hist.root");
166  assert(fd->IsOpen());
167  fd->ls();
168 
169  TString tt;
170 
171 
172  switch(page){
173  case 1:{
174  tt="nPTv";
175  } break;
176 
177  case 2:{
178  tt="nPFv";
179  } break;
180 
181  default:;
182  }
183 
184  c=new TCanvas();
185  c->Divide(2,2);
186  int iv;
187  for(iv=0;iv<4;iv++){
188  TString tt1=tt;
189  tt1+=iv;
190  printf("=%s=\n",tt1.Data());
191 
192  h=(TH1F*)fd->Get(tt1); assert(h);
193  c->cd(iv+1);
194  h->Draw();
195  }
196 
197 }
static StMuPrimaryVertex * primaryVertex()
return pointer to current primary vertex
Definition: StMuDst.h:322
Int_t vertexIndex() const
Returns index of associated primary vertex.
Definition: StMuTrack.cxx:600
StMuDst * muDst()
Definition: StMuDstMaker.h:425
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
UShort_t nHitsFit() const
Return total number of hits used in fit.
Definition: StMuTrack.h:239
short flag() const
Returns flag, (see StEvent manual for type information)
Definition: StMuTrack.h:230
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 StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)
Definition: StMuDst.h:320
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
Collection of trigger ids as stored in MuDst.
StTrackTopologyMap topologyMap() const
Returns topology map.
Definition: StMuTrack.h:254