1 Int_t TOFquickanal(Int_t eventNumber = 0)
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.
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
13 <img src="picts/TOFquickanal.gif">
17 // Author: F. Pierella , Bologna University 12-04-2001
18 // Updated to the new I/O by: A. De Caro, C. Zampolli
19 /////////////////////////////////////////////////////////////////////////
21 // Dynamically link some shared libs
22 if (gClassTable->GetID("AliRun") < 0) {
23 gROOT->LoadMacro("loadlibs.C");
29 AliRunLoader *rl =AliRunLoader::Open("galice.root",AliConfig::GetDefaultEventFolderName(),"update");
32 cerr << "Can't load RunLoader from file!\n";
38 gAlice=rl->GetAliRun();
42 cerr << "<TOFquickanal> AliRun object not found on file \n";
47 // Get the pointer to the TOF detector
48 AliLoader *tofl = rl->GetLoader("TOFLoader");
49 AliTOF * tof = (AliTOF*) gAlice->GetDetector("TOF");
50 if (tof == 0x0 || tofl == 0x0) {
51 cerr << "<TOFquickanal> Can not find TOF or TOFLoader\n";
56 //=======> Create histograms
57 //---> Time of Flight for Primary Particles (ns)
58 TH1F *htofprim = new TH1F("htofprim","Time of Flight for Primary Particles",100,0.,100.);
59 //--->Time of Flight for Secondary Particles (ns)
60 TH1F *htofsec = new TH1F("htofsec","Time of Flight for Secondary Particles",100,0.,100.);
62 //---> r (radius) coordinate of production in the ALICE frame for secondary particles that produce at
63 // least one TOF-hit (cm) - cylindrical coordinate system assumed, primary plus secondary-
64 TH1F *hradius = new TH1F("hradius","r (radius) coordinate at the production vertex for secondary particles with at least one TOF-Hit",50,0.,500.);
66 //---> Momentum of primary particles that produce (at least) one TOF-hit when the hit
67 // is produced (Gev/c)
68 TH1F *htofmom = new TH1F("htofmom","Momentum of primary particles when the Hit is produced",50,0.,5.);
70 //---> Momentum of primary particles that produce (at least) one TOF-hit at the production vertex
72 TH1F *hprodmom = new TH1F("hprodmom","Momentum of primary particles (with at least one TOF hit) at the production ",50,0.,5.);
74 //---> Theta of production for primary particles that produce (at least) one TOF-hit (deg)
75 TH1F *hprodthe = new TH1F("hprodthe","Theta of primary particles (with at least one TOF hit) at the production ",90,0.,180.);
77 //---> Phi of production for primary particles that produce (at least) one TOF-hit (deg)
78 TH1F *hprodphi = new TH1F("hprodphi","Phi of primary particles (with at least one TOF hit) at the production ",180,-180.,180.);
80 //---> z Coordinate of the TOF Hit (z beam axis) - primary plus secondary - (cm)
81 TH1F *hzcoor = new TH1F("hzcoor","z Coordinate of the TOF Hit",800,-400.,400.);
83 //---> Incidence Angle of the particle on the pad (or strip) (deg) - primary plus secondary -
84 TH1F *hincangle = new TH1F("hincangle","Incidence Angle of the particle on the strip",90,0.,180.);
86 printf ("Processing event %d \n", eventNumber);
87 rl->GetEvent(eventNumber);
89 // Get pointers to Alice detectors and Hits containers
91 TTree *TH = tofl->TreeH();
92 tof->SetTreeAddress();
94 cout << "<TOFquickanal> No hit tree found" << endl;
99 // Import the Kine Tree for the event eventNumber in the file
101 rl->LoadKinematics();
102 //AliStack * stack = rl->Stack();
104 Int_t ntracks = TH->GetEntries();
105 cout<<" ntracks = "<<ntracks<<endl;
109 // Start loop on tracks in the hits containers
110 for (Int_t track=0; track<ntracks;track++) {
115 for(tofHit=(AliTOFhitT0*)tof->FirstHit(track); tofHit; tofHit=(AliTOFhitT0*)tof->NextHit()) {
117 Float_t toflight = tofHit->GetTof();
118 toflight *= 1.E+09; // conversion from s to ns
119 Double_t tofmom = tofHit->GetMom();
121 Int_t ipart = tofHit->Track();
122 TParticle *particle = gAlice->Particle(ipart);
123 if (particle->GetFirstMother() < 0) {
124 htofprim->Fill(toflight);
125 htofmom->Fill(tofmom);
127 htofsec->Fill(toflight);
130 Double_t zcoor = tofHit->Z();
133 Double_t incangle = tofHit->GetIncA();
134 hincangle->Fill(incangle);
136 Double_t xcoor = particle->Vx();
137 Double_t ycoor = particle->Vy();
138 Double_t radius = TMath::Sqrt(xcoor*xcoor+ycoor*ycoor);
139 if (particle->GetFirstMother() >= 0) hradius->Fill(radius);
141 Double_t prodmom = particle->P();
143 Double_t dummy = (particle->Pz())/prodmom;
144 Double_t prodthe = TMath::ACos(dummy);
145 prodthe *= 57.29578; // conversion from rad to deg
146 if (particle->GetFirstMother() < 0) hprodthe->Fill(prodthe);
147 } // theta at production vertex
149 if (particle->GetFirstMother() < 0) {
150 hprodmom->Fill(prodmom);
151 Double_t dummypx = particle->Px();
152 Double_t dummypy = particle->Py();
153 Double_t prodphi = TMath::ATan2(dummypy,dummypx);
154 prodphi *= 57.29578; // conversion from rad to deg
155 hprodphi->Fill(prodphi);
156 } // phi at production vertex
157 } // close loop on TOF-hits
158 } // close loop on tracks in the hits containers
160 //Create canvas, set the view range, show histograms
161 TCanvas *c1 = new TCanvas("c1","Alice TOF hits quick analysis",400,10,600,700);
165 TCanvas *c2 = new TCanvas("c2","Alice TOF hits quick analysis",400,10,600,700);
169 TCanvas *c3 = new TCanvas("c3","Alice TOF hits quick analysis",400,10,600,700);
173 TCanvas *c4 = new TCanvas("c4","Alice TOF hits quick analysis",400,10,600,700);
177 TCanvas *c5 = new TCanvas("c5","Alice TOF hits quick analysis",400,10,600,700);
181 TCanvas *c6 = new TCanvas("c6","Alice TOF hits quick analysis",400,10,600,700);
185 TCanvas *c7 = new TCanvas("c7","Alice TOF hits quick analysis",400,10,600,700);
190 TCanvas *c8 = new TCanvas("c8","Alice TOF hits quick analysis",400,10,600,700);
194 TCanvas *c9 = new TCanvas("c9","Alice TOF hits quick analysis",400,10,600,700);
198 //tofl->UnloadHits();
199 //rl->UnloadHeader();
200 //rl->UnloadgAlice();
201 //rl->UnloadKinematics();