Tracks reconstruction using NewIO
[u/mrichter/AliRoot.git] / TOF / TOFquickanal.C
CommitLineData
b94fa26c 1void TOFquickanal(Int_t evNumber=0)
2{
3/////////////////////////////////////////////////////////////////////////
4// This macro is a small example of a ROOT macro
5// illustrating how to read the output of GALICE
6// and fill some histograms concerning the TOF Hit Tree.
7//
8// Root > .L TOFquickanal.C //this loads the macro in memory
9// Root > TOFquickanal(); //by default process first event
10// Root > TOFquickanal(2); //process third event
11//Begin_Html
12/*
13<img src="picts/TOFquickanal.gif">
14*/
15//End_Html
16//
17// Author: F. Pierella , Bologna University 12-04-2001
18/////////////////////////////////////////////////////////////////////////
19
20// Dynamically link some shared libs
21 if (gClassTable->GetID("AliRun") < 0) {
22 gROOT->LoadMacro("loadlibs.C");
23 loadlibs();
24 }
25
26 // Connect the Root Galice file containing Geometry, Kine and Hits
27 TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject("galice.root");
28 if (!file) file = new TFile("galice.root");
29
30 // Get AliRun object from file or create it if not on file
31 if (!gAlice) {
32 gAlice = (AliRun*)file->Get("gAlice");
33 if (gAlice) printf("AliRun object found on file\n");
34 if (!gAlice) gAlice = new AliRun("gAlice","Alice test program");
35 }
36
37 // Import the Kine and Hits Trees for the event evNumber in the file
38 Int_t nparticles = gAlice->GetEvent(evNumber);
39 if (nparticles <= 0) return;
40
41 Float_t tof,tofmom,incangle;
42 Double_t xcoor,ycoor,zcoor,radius,prodmom,prodthe,prodphi;
43 Int_t nbytes = 0;
44 Int_t j,hit,ipart;
45 Int_t nhits;
46 TParticle *particle;
47
48
49 // Get pointers to Alice detectors and Hits containers
50 AliDetector *TOF = gAlice->GetDetector("TOF");
51
52 Int_t ntracks = gAlice->TreeH()->GetEntries();
53
54 //=======> Create histograms
55 //---> Time of Flight for Primary Particles (ns)
56 TH1F *htofprim = new TH1F("htofprim","Time of Flight for Primary Particles",100,0.,100.);
57 //--->Time of Flight for Secondary Particles (ns)
58 TH1F *htofsec = new TH1F("htofsec","Time of Flight for Secondary Particles",100,0.,100.);
59
60 //---> r (radius) coordinate of production in the ALICE frame for secondary particles that produce at
61 // least one TOF-hit (cm) - cylindrical coordinate system assumed, primary plus secondary-
62 TH1F *hradius = new TH1F("hradius","r (radius) coordinate at the production vertex for secondary particles with at least one TOF-Hit",50,0.,500.);
63
64 //---> Momentum of primary particles that produce (at least) one TOF-hit when the hit
65 // is produced (Gev/c)
66 TH1F *htofmom = new TH1F("htofmom","Momentum of primary particles when the Hit is produced",50,0.,5.);
67
68 //---> Momentum of primary particles that produce (at least) one TOF-hit at the production vertex
69 // (Gev/c)
70 TH1F *hprodmom = new TH1F("hprodmom","Momentum of primary particles (with at least one TOF hit) at the production ",50,0.,5.);
71
72 //---> Theta of production for primary particles that produce (at least) one TOF-hit (deg)
73 TH1F *hprodthe = new TH1F("hprodthe","Theta of primary particles (with at least one TOF hit) at the production ",90,0.,180.);
74
75 //---> Phi of production for primary particles that produce (at least) one TOF-hit (deg)
76 TH1F *hprodphi = new TH1F("hprodphi","Phi of primary particles (with at least one TOF hit) at the production ",180,-180.,180.);
77
78 //---> z Coordinate of the TOF Hit (z beam axis) - primary plus secondary - (cm)
79 TH1F *hzcoor = new TH1F("hzcoor","z Coordinate of the TOF Hit",800,-400.,400.);
80
81 //---> Incidence Angle of the particle on the pad (or strip) (deg) - primary plus secondary -
82 TH1F *hincangle = new TH1F("hincangle","Incidence Angle of the particle on the strip",90,0.,180.);
83
84 AliTOFhit *tofHit;
85
86 // Start loop on tracks in the hits containers
87 for (Int_t track=0; track<ntracks;track++) {
88
89// printf("Track #%d\n",track);
90 if(TOF) {
91 // ======>Histogram TOF
92 for(tofHit=(AliTOFhit*)TOF->FirstHit(track); tofHit; tofHit=(AliTOFhit*)TOF->NextHit()) {
93
94 tof = tofHit->GetTof();
95 tof *= 1.E+09; // conversion from s to ns
96 tofmom = tofHit->GetMom();
97
98 ipart = tofHit->GetTrack();
99 particle = gAlice->Particle(ipart);
100
101 if (particle->GetFirstMother() < 0) {
102 htofprim->Fill(tof);
103 htofmom->Fill(tofmom);
104 } else {
105 htofsec->Fill(tof);
106 };
107
108 zcoor = tofHit->Z();
109 hzcoor->Fill(zcoor);
110
111 incangle= tofHit->GetIncA();
112 hincangle->Fill(incangle);
113
114 xcoor =particle->Vx();
115 ycoor =particle->Vy();
116 radius = TMath::Sqrt(xcoor*xcoor+ycoor*ycoor);
117 if (particle->GetFirstMother() >= 0) hradius->Fill(radius);
118
119 prodmom=particle->P();
120 if (prodmom!=0.) {
121 Double_t dummy = (particle->Pz())/prodmom;
122 prodthe = TMath::ACos(dummy);
123 prodthe *=57.29578; // conversion from rad to deg
124 if (particle->GetFirstMother() < 0) hprodthe->Fill(prodthe);
125 } // theta at production vertex
126
127 if (particle->GetFirstMother() < 0) {
128 hprodmom->Fill(prodmom);
129 Double_t dummypx=particle->Px();
130 Double_t dummypy=particle->Py();
131 prodphi = TMath::ATan2(dummypy,dummypx);
132 prodphi *=57.29578; // conversion from rad to deg
133 hprodphi->Fill(prodphi);
134 } // phi at production vertex
135
136 } // close if(TOF)
137 } // close loop on TOF-hits
138 } // close loop on tracks in the hits containers
139
140
141
142//Create canvas, set the view range, show histograms
143 TCanvas *c1 = new TCanvas("c1","Alice TOF hits quick analysis",400,10,600,700);
144 c1->cd();
145 hprodmom->Draw();
146
147 TCanvas *c2 = new TCanvas("c2","Alice TOF hits quick analysis",400,10,600,700);
148 c2->cd();
149 hprodthe->Draw();
150
151 TCanvas *c3 = new TCanvas("c3","Alice TOF hits quick analysis",400,10,600,700);
152 c3->cd();
153 hprodphi->Draw();
154
155 TCanvas *c4 = new TCanvas("c4","Alice TOF hits quick analysis",400,10,600,700);
156 c4->cd();
157 hzcoor->Draw();
158
159 TCanvas *c5 = new TCanvas("c5","Alice TOF hits quick analysis",400,10,600,700);
160 c5->cd();
161 hradius->Draw();
162
163 TCanvas *c6 = new TCanvas("c6","Alice TOF hits quick analysis",400,10,600,700);
164 c6->cd();
165 htofprim->Draw();
166
167 TCanvas *c7 = new TCanvas("c7","Alice TOF hits quick analysis",400,10,600,700);
168 c7->cd();
169 htofsec->Draw();
170
171
172 TCanvas *c8 = new TCanvas("c8","Alice TOF hits quick analysis",400,10,600,700);
173 c8->cd();
174 htofmom->Draw();
175
176 TCanvas *c9 = new TCanvas("c9","Alice TOF hits quick analysis",400,10,600,700);
177 c9->cd();
178 hincangle->Draw();
179
180}