5 fill_pp -> store track info in ntuple root file
6 fill_good_tracks_pp -> store good track info in ntuple root file
7 print_pp -> print selected events from ntuple root file
8 plot_pp -> plot parts of selected events from ntuple root file
9 eval_pp -> simple evaluation of impact parameter cut effects
15 Fill ntuple with relevant pp event data
16 from the tracks files:
18 Ev is the event number to use
19 Path gives the path where you find the digit files (and possibly also l3transform.config)
20 Rfile gives the root file where the information will be added
21 Saveev will be Ev unless you specify something else (useful for storing the trigger event of pilup events)
24 void fill_pp(Int_t ev=0,Char_t *path="./",Char_t *rfile="pptracks.root",Int_t saveev=-1)
27 l.Set(AliL3Logger::kAll);
31 if(getenv("TRANSFORMCONFIGPATH")){
32 AliL3Transform::Init(getenv("TRANSFORMCONFIGPATH"));
33 } else AliL3Transform::Init(path);
35 TNtuple *ntuppel = new TNtuple("ntuppel","pptracks","pt:phi:eta:xvert:yvert:zvert:imp:nhits:px:py:pz:event:mc");
38 TFile file(rfile,"UPDATE");
41 AliL3Evaluate *eval=new AliL3Evaluate(path,63,63);
42 eval->LoadData(ev,-1);
45 AliL3TrackArray *a=eval->GetTracks();
54 Double_t xc,yc,zc,impact;
56 Int_t ntracks=a.GetNTracks();
57 for(Int_t i=0;i<ntracks;i++){
61 t.GetClosestPoint(&vertex,xc,yc,zc);
64 if(nhits<63) continue;
66 eta=t.GetPseudoRapidity();
70 //impact=TMath::fabs(zc);
71 impact=TMath::Sqrt(xc*xc+yc*yc+zc*zc);
89 cout << i << ": pt " << pt << " " << phi << " " << eta << " " << id << " nhits " << nhits << " impact " << impact << endl;
91 //if(id!=-1) cout << "mc " << id << " " << t.GetCenterX() << " " << t.GetCenterY() << " " << t.GetRadius() << " fst point " << t.GetFirstPointX() << " " << t.GetFirstPointY() << " " << t.GetFirstPointZ() << " tgl " << t.GetTgl() << endl;
94 if(saveev==-1) saveev=ev;
95 sprintf(name,"pptracks-%d",saveev);
103 /*--fill_good_tracks_pp--
105 Fill good tracks taken from offline into ntuple root file for later evaluation.
107 Evs is the event to start with
108 Eve is the last event to process
109 Path gives the path where the offline good_particles_tpc files are
110 Rfile specifies the recreated root file where the ntuples will be stored
113 void fill_good_tracks_pp(Int_t evs=0,Int_t eve=100,Char_t *path="./",Char_t *rfile="pp-good-tracks.root")
115 TFile file(rfile,"RECREATE");
116 if(!file.IsOpen()) return;
121 for(Int_t i=evs;i<eve;i++){
122 TNtuple *ntuppel = new TNtuple("ntuppel-goodtracks","good-pptracks","mc:pdg:px:py:pz:xvert:yvert:zvert:nhits:sector");
124 sprintf(name,"%s/good_tracks_tpc_%d",path,i);
125 FILE *f=fopen(name,"r");
126 cout << "Event " << i << " " << name << endl;
129 Int_t mc,pdg,nhits,sector;
130 Float_t px,py,pz,xv,yv,zv;
131 fscanf(f,"%d %d %f %f %f %f %f %f %d %d\n",&mc,&pdg,&px,&py,&pz,&xv,&yv,&zv,&nhits,§or);
133 if(nhits<63) continue;
134 if((px==0)&&(py==0)&&(pz==0)) continue;
135 if((xv==0)&&(yv==0)&&(zv==0)) continue;
137 //cout << mc << " " << pdg << " " << px << " " << py << " " << pz << " " << xv << " " << yv << " " << zv << " " << nhits << " " << sector << endl;
153 sprintf(name,"good-pptracks-%d",i);
154 ntuppel->Write(name);
162 Looping over event reading root file containing ntuples
163 and printing wanted information:
165 Pfile specifies the root file created with fill_pp
166 Evi gives the first event to print
167 Eve the last event to print
170 void print_pp(Char_t *pfile, Int_t evi=0, Int_t eve=-1)
172 TFile file1=TFile(pfile,"READ");
174 if(!file1.IsOpen()) return;
176 //"pt:phi:eta:xvert:yvert:zvert:imp:nhits:px:py:pz:event:mc")
177 Float_t pt1,phi1,eta1,xvert1,yvert1,zvert1,imp1,nhits1,px1,py1,pz1,event1,mc1; //pileup
178 Float_t pt2,phi2,eta2,xvert2,yvert2,zvert2,imp2,nhits2,px2,py2,pz2,event2,mc2; //pp
184 for(Int_t i=evi;i<=eve;i++){ //loop over pileup-events
185 sprintf(dummy,"pptracks-%d",i);
186 TNtuple *ntuppel1 = (TNtuple*)file1.Get(dummy);
187 ntuppel1->SetBranchAddress("pt",&pt1);
188 ntuppel1->SetBranchAddress("phi",&phi1);
189 ntuppel1->SetBranchAddress("eta",&eta1);
190 ntuppel1->SetBranchAddress("xvert",&xvert1);
191 ntuppel1->SetBranchAddress("yvert",&yvert1);
192 ntuppel1->SetBranchAddress("zvert",&zvert1);
193 ntuppel1->SetBranchAddress("imp",&imp1);
194 ntuppel1->SetBranchAddress("px",&px1);
195 ntuppel1->SetBranchAddress("py",&py1);
196 ntuppel1->SetBranchAddress("pz",&pz1);
197 ntuppel1->SetBranchAddress("event",&event1);
198 ntuppel1->SetBranchAddress("mc",&mc1);
200 nent1=ntuppel1->GetEntries();
201 cout << "Event: " << i << " " << nent1 << " tracks" << endl;
202 for(Int_t j=0;j<nent1;j++){
203 ntuppel1->GetEvent(j);
205 Float_t bt=TMath::Sqrt(xvert1*xvert1+yvert1*yvert1);
206 Float_t bz=TMath::fabs(zvert1);
209 cout << j << ": " << event1 << " " << pt1 << " " << phi1 << " " << eta1 << " mc " << mc1 << " bt " << bt << " bz " << bz << endl;
218 Plot some variables from the ntuples (currently impact parameter
219 but easily changeable.
221 Pfile is the root file containing the ntuples.
222 Evi and Eve are start and end event number to process
225 void plot_pp(Char_t *pfile, Int_t evi=0, Int_t eve=100)
227 TH1F *hist1=new TH1F("h1","test",100,0,1000);
229 TFile file1=TFile(pfile,"READ");
231 if(!file1.IsOpen()) return;
233 //"pt:phi:eta:xvert:yvert:zvert:imp:nhits:px:py:pz:event:mc")
234 Float_t pt1,phi1,eta1,xvert1,yvert1,zvert1,imp1,nhits1,px1,py1,pz1,event1,mc1; //pileup
235 Float_t pt2,phi2,eta2,xvert2,yvert2,zvert2,imp2,nhits2,px2,py2,pz2,event2,mc2; //pp
240 for(Int_t i=evi;i<eve;i++){ //loop over pileup-events
241 sprintf(dummy,"pptracks-%d",i);
242 TNtuple *ntuppel1 = (TNtuple*)file1.Get(dummy);
244 cerr << "Error getting ntuple from " << dummy<<endl;
247 ntuppel1->SetBranchAddress("pt",&pt1);
248 ntuppel1->SetBranchAddress("phi",&phi1);
249 ntuppel1->SetBranchAddress("eta",&eta1);
250 ntuppel1->SetBranchAddress("xvert",&xvert1);
251 ntuppel1->SetBranchAddress("yvert",&yvert1);
252 ntuppel1->SetBranchAddress("zvert",&zvert1);
253 ntuppel1->SetBranchAddress("imp",&imp1);
254 ntuppel1->SetBranchAddress("px",&px1);
255 ntuppel1->SetBranchAddress("py",&py1);
256 ntuppel1->SetBranchAddress("pz",&pz1);
257 ntuppel1->SetBranchAddress("event",&event1);
258 ntuppel1->SetBranchAddress("mc",&mc1);
260 nent1=ntuppel1->GetEntries();
261 cout << "Event: " << i << " " << nent1 << " tracks" << endl;
262 for(Int_t j=0;j<nent1;j++){
263 ntuppel1->GetEvent(j);
265 if(TMath::fabs(eta1)>0.9) continue;
266 if(pt1<0.1) continue;
268 Float_t bt=TMath::Sqrt(xvert1*xvert1+yvert1*yvert1);
269 Float_t bz=TMath::fabs(zvert1);
281 Little macro to play with pp pileup evaluation and do some
282 counting. See real trigger macro trigger.C instead.
284 Ev is the event number
285 Path is the path to the track arrays.
288 void eval_pp(Int_t ev=0,Char_t *path="./")
291 l.Set(AliL3Logger::kAll);
295 AliL3Evaluate *eval=new AliL3Evaluate(path,63,63);
296 eval->LoadData(ev,-1);
299 AliL3TrackArray *a=eval->GetTracks();
302 Float_t phi,pt,tgl,eta;
305 Int_t abspos=0,pos=0,absneg=0,neg=0;
306 //assume vertex around zero
308 Double_t xc,yc,zc,impact;
311 Int_t ntracks=a.GetNTracks();
312 for(Int_t i=0;i<ntracks;i++){
313 t.Set(a.GetTrack(i));
316 t.GetClosestPoint(&vertex,xc,yc,zc);
319 if(nhits<63) continue;
325 if(t.GetPy()!=0) phi=TMath::ATan(t.GetPy()/t.GetPx());
327 //impact=TMath::fabs(zc);
328 impact=TMath::Sqrt(xc*xc+yc*yc+zc*zc);
330 cout << i << ": pt " << pt << " " << phi << " " << tgl << " " << id << " nhits " << nhits << " impact " << impact << endl;
335 if(impact>10) continue;
340 cout << "Result: " << nents << " " << abspos << " " << absneg << endl;
341 cout << "After cut: " << pos << " " << neg << endl;
344 void simple_eff_pp(Char_t *pfile, Char_t *reffile, Int_t evi=0, Int_t eve=100,Int_t cut=-1)
346 //"pt:phi:eta:xvert:yvert:zvert:imp:nhits:px:py:pz:event:mc")
347 Float_t pt1,phi1,eta1,xvert1,yvert1,zvert1,imp1,nhits1,px1,py1,pz1,event1,mc1; //pileup
348 Float_t pt2,phi2,eta2,xvert2,yvert2,zvert2,imp2,nhits2,px2,py2,pz2,event2,mc2; //pp
350 Int_t countgoodevents=0;
363 TFile file1=TFile(pfile,"READ");
364 TFile file2=TFile(reffile,"READ");
365 if(!file1.IsOpen() || !file2.IsOpen()) return;
367 for(Int_t i=evi;i<eve;i++){ //loop over pileup-events
368 sprintf(dummy,"pptracks-%d",i);
369 TNtuple *ntuppel1 = (TNtuple*)file1.Get(dummy);
370 ntuppel1->SetBranchAddress("pt",&pt1);
371 ntuppel1->SetBranchAddress("phi",&phi1);
372 ntuppel1->SetBranchAddress("eta",&eta1);
373 ntuppel1->SetBranchAddress("xvert",&xvert1);
374 ntuppel1->SetBranchAddress("yvert",&yvert1);
375 ntuppel1->SetBranchAddress("zvert",&zvert1);
376 ntuppel1->SetBranchAddress("imp",&imp1);
377 ntuppel1->SetBranchAddress("px",&px1);
378 ntuppel1->SetBranchAddress("py",&py1);
379 ntuppel1->SetBranchAddress("pz",&pz1);
380 ntuppel1->SetBranchAddress("event",&event1);
381 ntuppel1->SetBranchAddress("mc",&mc1);
386 nent1=ntuppel1->GetEntries();
387 for(Int_t j=0;j<nent1;j++){
388 ntuppel1->GetEvent(j);
390 if(j==0){ //get info of triggered event from file2
392 sprintf(dummy,"good-pptracks-%d",event1);
393 TNtuple *ntuppel2 = (TNtuple*)file2.Get(dummy);
394 Float_t nhits2,pdg2,sector2;
396 ntuppel2->SetBranchAddress("mc",&mc2);
397 ntuppel2->SetBranchAddress("pdg",&pdg2);
398 ntuppel2->SetBranchAddress("px",&px2);
399 ntuppel2->SetBranchAddress("py",&py2);
400 ntuppel2->SetBranchAddress("pz",&pz2);
401 ntuppel2->SetBranchAddress("xvert",&xvert2);
402 ntuppel2->SetBranchAddress("yvert",&yvert2);
403 ntuppel2->SetBranchAddress("zvert",&zvert2);
404 ntuppel2->SetBranchAddress("nhits",&nhits2);
405 ntuppel2->SetBranchAddress("sector",§or2);
406 nent2=ntuppel2->GetEntries();
407 for(Int_t k=0;k<nent2;k++){
408 ntuppel2->GetEvent(k);
409 if(mc2<0)continue; //dont count fake tracks
410 //if(TMath::fabs(zvert2)>30) continue;
411 pt2=TMath::Sqrt(px2*px2+py2*py2);
412 if(nhits2<63) continue;
413 if(pt2<0.1) continue;
414 if((px2==0)&&(py2==0)&&(pz2==0)) continue;
415 Float_t p=TMath::Sqrt(px2*px2+py2*py2+pz2*pz2);
416 eta2=0.5*TMath::log((p+pz2)/(p-pz2));
417 if(TMath::fabs(eta2)>0.9) continue;
421 sprintf(dummy,"pptracks-%d",event1);
422 TNtuple *ntuppel2 = (TNtuple*)file2.Get(dummy);
424 ntuppel2->SetBranchAddress("pt",&pt2);
425 ntuppel2->SetBranchAddress("phi",&phi2);
426 ntuppel2->SetBranchAddress("eta",&eta2);
427 ntuppel2->SetBranchAddress("xvert",&xvert2);
428 ntuppel2->SetBranchAddress("yvert",&yvert2);
429 ntuppel2->SetBranchAddress("zvert",&zvert2);
430 ntuppel2->SetBranchAddress("imp",&imp2);
431 ntuppel2->SetBranchAddress("px",&px2);
432 ntuppel2->SetBranchAddress("py",&py2);
433 ntuppel2->SetBranchAddress("pz",&pz2);
434 ntuppel2->SetBranchAddress("event",&event2);
435 ntuppel2->SetBranchAddress("mc",&mc2);
437 nent2=ntuppel2->GetEntries();
438 for(Int_t k=0;k<nent2;k++){
439 ntuppel2->GetEvent(k);
440 if(mc2<0)continue; //dont count fake tracks
441 if(pt2<0.1) continue;
442 //if(TMath::fabs(zvert2)>30) continue;
443 if(TMath::fabs(eta2)>0.9) continue;
451 break; //triggered event has to have one track at least
454 if(pt1<0.1) continue;
455 if(TMath::fabs(eta1>0.9)) continue;
457 if(mc1<-1) continue; //dont count fake tracks
458 else if(mc1==-1) fnorm++; //count tracks from pileup
460 if((cut>0)&&(zvert1>cut)) continue;
461 pnorm++; //count real tracks
465 if(tnorm==0) continue; //break from above
466 if(pnorm>tnorm) pnorm=tnorm; //prob. multiple found tracks
467 countgoodevents++; //for normalization
471 pmean+=(Float_t)pnorm/(Float_t)tnorm;
472 fmean+=(Float_t)fnorm/(Float_t)tnorm;
479 peff=(Float_t)pcounts/tcounts;
480 feff=(Float_t)fcounts/tcounts;
481 pmean/=countgoodevents;
482 fmean/=countgoodevents;
483 cout << "Events used: " << countgoodevents << endl;
484 cout << "Good Eff " << peff << " " << pcounts << " " << tcounts << endl;
485 cout << "Fake Eff " << feff << " " << fcounts << " " << tcounts << endl;
486 cout << "Means are " << pmean << " " << fmean << endl;
489 //////////////////////////
490 // dont look below here //
491 //////////////////////////
495 Store certain amount of track
496 arrays in a root file for later
497 access - okay needs to many changes
498 in AliL3TrackArray and AliL3Track
499 classes so stopped working on it
500 (see fill_pp instead).
503 void store_pp(Int_t evs=0,Int_t eve=100,Char_t *path="./",Char_t *rfile="tracks.root")
506 l.Set(AliL3Logger::kAll);
510 if(getenv("TRANSFORMCONFIGPATH")){
511 AliL3Transform::Init(getenv("TRANSFORMCONFIGPATH"));
514 TFile file(rfile,"UPDATE");
517 for(Int_t i=evs;i<eve;i++){
518 AliL3Evaluate *eval=new AliL3Evaluate(path,63,63);
519 eval->LoadData(i,-1);
522 AliL3TrackArray *a=eval->GetTracks();
523 sprintf(name,"tracks-%d",i);
534 Loop over stored track arrays
535 and print content. Does not properly
539 void load_pp(Int_t evs=0,Int_t eve=100,Char_t *path="./")
542 l.Set(AliL3Logger::kAll);
546 if(getenv("TRANSFORMCONFIGPATH")){
547 AliL3Transform::Init(getenv("TRANSFORMCONFIGPATH"));
549 AliL3Transform::Init(path);
552 for(Int_t j=evs;j<eve;j++){
554 AliL3Evaluate *eval=new AliL3Evaluate(path,63,63);
555 eval->LoadData(j,-1); //load whole patch
558 AliL3TrackArray *a=eval->GetTracks();
561 Float_t phi,pt,tgl,eta;
566 Double_t xc,yc,zc,impact;
569 Int_t ntracks=a.GetNTracks();
570 for(Int_t i=0;i<ntracks;i++){
571 t.Set(a.GetTrack(i));
574 t.GetClosestPoint(&vertex,xc,yc,zc);
577 if(nhits<63) continue;
582 if(t.GetPy()!=0) phi=TMath::ATan(t.GetPy()/t.GetPx());
584 impact=TMath::fabs(zc);
585 //impact=TMath::Sqrt(xc*xc+yc*yc+zc*zc);
587 cout << i << ": pt " << pt << " " << phi << " " << tgl << " " << id << " nhits " << nhits << " impact " << impact << endl;