1 Int_t AliTOFanalyzeHits(Int_t numberOfEvents=0, Bool_t drawing=kFALSE)
4 /////////////////////////////////////////////////////////////////////////
6 // Analyzes TOF hits and fills QA-histograms
7 // and writes the histograms in the TOF_hitsQA.root file
11 // root [0] .L AliTOFanalyzeHits.C
12 // root [1] AliTOFanalyzeHits()
14 // By default, it analyzes hits for all the events in the header file
15 // and does not draw the histograms filled
17 // If you want analyze hits only the 1th event
18 // you can use the following line:
20 // root[0] .L AliTOFanalyzeHits.C
21 // root[1] AliTOFanalyzeHits(1)
23 // Updated to the new I/O: C. Zampolli
25 // Report problems to decaro@sa.infn.it
27 /////////////////////////////////////////////////////////////////////////
31 // Define the histograms
32 // x,y,z, rho, tof, padx, padz, sector, plate, strip, (x vs y)
35 TH2F *h2hitMap = new TH2F("h2hitMap","Hit Map (projection on the plane)",2500,-12500.,12500.,800,-400.,400.);
36 // time of flight distribution for primaries and secondaries
37 TH1F *htofp = new TH1F("htofp","Time of Flight (primaries)",800,0.,80.);
38 TH1F *htofs = new TH1F("htofs","Time of Flight (secondaries)",800,0.,80.);
39 // momentum when striking the TOF for primaries and secondaries
40 TH1F *htofmomp = new TH1F("htofmomp","Momentum at TOF (primaries)",100,0.,10.);
41 TH1F *htofmoms = new TH1F("htofmoms","Momentum at TOF (secondaries)",100,0.,10.);
43 TH1F *hsector = new TH1F("hsector","Sector",18,0.,18.);
44 TH1F *hplate = new TH1F("hplate","Plate ", 5,0., 5.);
45 TH1F *hstrip = new TH1F("hstrip","Strip ",20,0.,20.);
46 TH1F *hpadz = new TH1F("hpadz","Pad along z ",2,0.,2.);
47 TH1F *hpadx = new TH1F("hpadx","Pad along x",48,0.,48.);
48 // track length when striking the TOF (used by AliTOFT0)
49 TH1F *htrackLenp= new TH1F("htrackLenp","Track Length on TOF for Primaries",800,0.,800.);
51 // Histograms added to control the right TOF element numbering:
52 // it should be increasing with the azimuthal and polar angles
54 TH2F *hmoduleVStheta = new TH2F("hmoduleVStheta", "hmoduleVStheta", 180,0.,180.,5,0,5);
55 TH2F *hsectorVSphi = new TH2F("hsectorVSphi", "hsectorVSphi", 360,0.,360.,18,0,18);
56 TH2F *hstripVStheta = new TH2F("hstripVStheta", "hstripVStheta", 180,0.,180.,20,0,20);
57 //TH2F *hpadzVStheta = new TH2F("hpadzVStheta", "hpadzVStheta", 180,0.,180.,2,0,2);
58 TH2F *hpadxVSphi = new TH2F("hpadxVSphi", "hpadxVSphi", 360,0.,360.,48,0,48);
59 TH2F *hpadz2stripVStheta = new TH2F("hpadz2stripVStheta", "hpadz2stripVStheta", 180,0.,180.,40,0,40);
60 //TH2F *hdzVSpadz2strip = new TH2F("hdzVSpadz2strip", "hdzVSpadz2strip",40,0,40,70,-3.5,3.5);
62 // Dynamically link some shared libs
63 if (gClassTable->GetID("AliRun") < 0) {
64 gROOT->LoadMacro("loadlibs.C");
70 delete AliRunLoader::Instance();
75 AliRunLoader *rl = AliRunLoader::Open("galice.root",AliConfig::GetDefaultEventFolderName(),"read");
78 cerr<<"Can't load RunLoader from file! \n";
84 gAlice = rl->GetAliRun();
88 cerr << "<AliTOFanalyzeHits> AliRun object not found on file \n";
95 // Get the pointer to the TOF detector
96 AliLoader *tofl = rl->GetLoader("TOFLoader");
97 AliTOF *tof = (AliTOF *) gAlice->GetDetector("TOF");
98 if (tof == 0x0 || tofl == 0x0) {
99 cerr << "<AliTOFanalyzeHits> Can not find TOF or TOFLoader \n";
106 if (numberOfEvents==0) numberOfEvents=(Int_t)(rl->GetNumberOfEvents());
108 for (Int_t ievent=0; ievent<numberOfEvents; ievent++) {
109 printf ("Processing event %d \n", ievent);
110 rl->GetEvent(ievent);
112 // Get the pointer Hit tree
114 TTree *hitTree = tofl->TreeH();
115 tof->SetTreeAddress();
117 cout << "<AliTOFanalyzeHits> No TreeH found" << endl;
122 rl->LoadKinematics();
123 //AliStack* stack = rl->Stack(); // it is not necessary to use the stack!
125 // Get the number of entries in the hit tree
126 // (Number of primary particles creating a hit somewhere)
127 Int_t nTrack = (Int_t) hitTree->GetEntries();
128 cout << "<AliTOFanalyzeHits> Found " << nTrack
129 << " primary particles with hits \n";
131 Int_t nPrimaryOnTof = 0;
132 Int_t nSecondaryOnTof = 0;
139 // Loop through all entries in the tree
140 for (Int_t iTrack = 0; iTrack < nTrack; iTrack++) {
143 hitTree->GetEvent(iTrack);
145 // Loop through the TOF hits
146 AliTOFhitT0 *hit = (AliTOFhitT0 *) tof->FirstHit(-1);
151 Float_t x = hit->X();
152 Float_t y = hit->Y();
153 Float_t z = hit->Z();
154 Float_t phiAngle=TMath::Pi() + TMath::ATan2(-y,-x);
155 Float_t rhoRadius=TMath::Sqrt(x*x+y*y);
156 Float_t thetaAngle=TMath::Pi() + TMath::ATan2(-rhoRadius,-z);
157 Float_t dummy=rhoRadius*phiAngle;
158 h2hitMap->Fill(dummy,z);
160 phiAngle*=180./TMath::Pi();
161 thetaAngle*=180./TMath::Pi();
163 Float_t flightTime = hit->GetTof(); // [s]
164 flightTime *= 1.e+09; // convert in [ns]
165 Float_t angle = hit->GetIncA();
166 Float_t tofmom = hit->GetMom(); // [GeV/c]
167 Float_t trackLen = hit->GetLen(); // [cm]
170 Int_t sector = hit->GetSector(); // range [1-18]
171 Int_t plate = hit->GetPlate(); // range [1- 5]
172 Int_t strip = hit->GetStrip(); // range [1-20]
173 Int_t padz = hit->GetPadz(); // range [1- 2]
174 Int_t padx = hit->GetPadx(); // range [1-48]
175 // it is QA, then I perform QA!
177 Bool_t isHitBad = (sector<0 || sector>17 ||
178 plate<0 || plate>4 ||
181 ((strip<0 || strip>14) && plate == 2) ||
182 ((strip<0 || strip>18) && (plate == 1 || plate == 3)) ||
183 ((strip<0 || strip>19) && (plate == 0 || plate == 4)));
186 cout << "<AliTOFanalyzeHits> strange hit found \n";
187 cout << "sector = " << sector <<
188 " plate = " << plate <<
189 " strip = " << strip <<
190 " padx = " << padx <<
191 " padz = " << padz << endl;
196 hmoduleVStheta->Fill(thetaAngle,plate);
197 hstripVStheta->Fill(thetaAngle,strip);
198 hsectorVSphi->Fill(phiAngle,sector);
199 //hpadzVStheta->Fill(thetaAngle,padx);
200 hpadxVSphi->Fill(phiAngle,padx);
202 Float_t dummy2 = 2*strip + padz;
203 hpadz2stripVStheta->Fill(thetaAngle,dummy2);
207 if (hit->GetDz()<=0) dummy3 = hit->GetDz()-1.75;
208 else dummy3 = hit->GetDz()+1.75;
209 hdzVSpadz2strip->Fill(dummy2,dummy3);
212 // filling hit volume histos
213 hsector->Fill(sector);
219 Int_t track = hit->Track();
220 TParticle *part = gAlice->GetMCApp()->Particle(track);
222 // getting MC info for the current track
223 if (part->GetFirstMother()<0){
224 Int_t icod = TMath::Abs(part->GetPdgCode());
242 htofp->Fill(flightTime);
243 htofmomp->Fill(tofmom);
244 htrackLenp->Fill(trackLen);
246 htofs->Fill(flightTime);
247 htofmoms->Fill(tofmom);
251 hit = (AliTOFhitT0 *) tof->NextHit();
258 rl->UnloadKinematics();
260 cout << "<AliTOFanalyzeHits> Found " << countHits << " hits in total \n";
261 cout << npion << " primary pions reached the TOF detector \n";
262 cout << nkaon << " primary kaons reached the TOF detector \n";
263 cout << nproton << " primary protons reached the TOF detector \n";
264 cout << nelectron << " primary electrons reached the TOF detector \n";
265 cout << nmuon << " primary muons reached the TOF detector \n";
269 cout << "hpadx->GetEntries() = " << hpadx->GetEntries() << endl;
275 TCanvas *cHits = new TCanvas("cHits","AliTOFanalyzeHits hit volumes",50,50,900,900);
288 TCanvas *chitmap = new TCanvas("chitmap","AliTOFanalyzeHits Hit Map",50,50,600,600);
292 TCanvas *ctrackLen = new TCanvas("ctrackLen","AliTOFanalyzeHits Track Length for primaries on TOF",50,50,400,400);
296 TCanvas *ctofmom = new TCanvas("ctofmom","AliTOFanalyzeHits flight times",50,50,700,700);
297 ctofmom->Divide(2,2);
312 // save histos into file TOF_hitsQA.root
313 TFile *fout = new TFile("TOF_hitsQA.root","RECREATE");
326 hmoduleVStheta->Write();
327 hsectorVSphi->Write();
328 hstripVStheta->Write();
329 //hpadzVStheta->Write();
331 hpadz2stripVStheta->Write();
332 //hdzVSpadz2strip->Write();
336 cout << " Finished AliTOFanalizeHits \n";
340 delete AliRunLoader::Instance();