17 void hits(const TString& detName, const TString& detVersion)
23 // construct file names
24 TString top = getenv("ALICE_ROOT");
25 TString f1NameEnd = "test10.root";
26 TString f2NameEnd = "test20.root";
27 TString g3File1Name = top + "/test/" + f1NameEnd;
28 TString g3File2Name = top + "/test/" + f2NameEnd;
29 TString g4File1Name = top + "/AliGeant4/test/" + f1NameEnd;
30 TString g4File2Name = top + "/AliGeant4/test/" + f2NameEnd;
32 cout << "Files: " << endl;
33 cout << g3File1Name << endl;
34 cout << g3File2Name << endl;
35 cout << g4File1Name << endl;
36 cout << g4File2Name << endl;
39 if (gClassTable->GetID("AliRun") < 0) {
40 gROOT->LoadMacro("loadlibs.C");
43 cout << "AliRoot libraries were loaded." << endl;
45 // set histogram ranges
47 Int_t g3xmin; Int_t g4xmin; Int_t g3xmax; Int_t g4xmax;
48 Int_t g3ymin; Int_t g4ymin; Int_t g3ymax; Int_t g4ymax;
49 Int_t g3zmin; Int_t g4zmin; Int_t g3zmax; Int_t g4zmax;
50 SetHistogramRanges(detName, nbin,
51 g3xmin, g3xmax, g4xmin, g4xmax,
52 g3ymin, g3ymax, g4ymin, g4ymax,
53 g3zmin, g3zmax, g4zmin, g4zmax);
57 TH1F* g3x = new TH1F("g3x", g3 + detName + " hits per x", nbin, g3xmin, g3xmax);
58 TH1F* g3xh = new TH1F("g3xh", g3 + detName + " hits per x", nbin, g3xmin, g3xmax);
59 TH1F* g4x = new TH1F("g4x", g4 + detName + " hits per x", nbin, g4xmin, g4xmax);
60 TH1F* g4xh = new TH1F("g4xh", g4 + detName + " hits per x", nbin, g4xmin, g4xmax);
62 TH1F* g3z = new TH1F("g3z", g3 + detName + " hits per z", nbin, g3zmin, g3zmax);
63 TH1F* g3zh = new TH1F("g3zh", g3 + detName + " hits per z", nbin, g3zmin, g3zmax);
64 TH1F* g4z = new TH1F("g4z", g4 + detName + " hits per z", nbin, g4zmin, g4zmax);
65 TH1F* g4zh = new TH1F("g4zh", g4 + detName + " hits per z", nbin, g4zmin, g4zmax);
71 if (detName == "PHOS") {
72 TH1F* g3y = new TH1F("g3y", g3 + detName + " hits per y", nbin, g3ymin, g3ymax);
73 TH1F* g3yh = new TH1F("g3yh", g3 + detName + " hits per y", nbin, g3ymin, g3ymax);
74 TH1F* g4y = new TH1F("g4y", g4 + detName + " hits per y", nbin, g4ymin, g4ymax);
75 TH1F* g4yh = new TH1F("g4yh", g4 + detName + " hits per y", nbin, g4ymin, g4ymax);
78 cout << "Histograms were created." << endl;
81 AliDetector* detector;
83 if (detName != "PHOS") {
84 //detector = LoadDetector(g3File1Name, detName, g3);
85 //FillHitsHistogram(detector, g3, g3x, g3y, g3z);
87 detector = LoadDetector(g3File2Name, detName, g3);
88 FillHitsHistogram(detector, g3, g3xh, g3yh, g3zh);
90 detector = LoadDetector(g4File1Name, detName, g4);
91 FillHitsHistogram(detector, g4, g4x, g4y, g4z);
93 detector = LoadDetector(g4File2Name, detName, g4);
94 FillHitsHistogram(detector, g4, g4xh, g4yh, g4zh);
97 //LoadDetector(g3File1Name, detName, g3);
98 //FillDigitsHistogram("AliPHOSHit", "PHOSCH", g3, g3x, g3y, g3z);
100 LoadDetector(g3File2Name, detName, g3);
101 FillDigitsHistogram("AliPHOSHit", "PHOSCH", g3, g3xh, g3yh, g3zh);
103 LoadDetector(g4File1Name, detName, g4);
104 FillDigitsHistogram("AliPHOSHit", "PHOSCH", g4, g4x, g4y, g4z);
106 LoadDetector(g4File2Name, detName, g4);
107 FillDigitsHistogram("AliPHOSHit", "PHOSCH", g4, g4xh, g4yh, g4zh);
110 // compose picture name
111 TString gifNameBase = "hits" + detName + "v" + detVersion;
112 TString title = detName + " hits";
115 DrawHistograms(title, gifNameBase + "_x.gif", g3x, g4x, g3xh, g4xh);
116 DrawHistograms(title, gifNameBase + "_y.gif", g3y, g4y, g3yh, g4yh);
117 DrawHistograms(title, gifNameBase + "_z.gif", g3z, g4z, g3zh, g4zh);
120 void SetHistogramRanges(TString& detName, Int_t& nbin,
121 Int_t& g3xmin, Int_t& g3xmax,
122 Int_t& g4xmin, Int_t& g4xmax,
123 Int_t& g3ymin, Int_t& g3ymax,
124 Int_t& g4ymin, Int_t& g4ymax,
125 Int_t& g3zmin, Int_t& g3zmax,
126 Int_t& g4zmin, Int_t& g4zmax)
130 g3xmin = 0; g4xmin = g3xmin;
131 g3xmax = 1; g4xmax = g3xmax;
132 g3ymin = 0; g4ymin = g3xmin;
133 g3ymax = 1; g4ymax = g3xmax;
134 g3zmin = 0; g4zmin = g3zmin;
135 g3zmax = 1; g4zmax = g3zmax;
137 if (detName == "FMD") {
138 g3xmin = -70; g4xmin = g3xmin;
139 g3xmax = 70; g4xmax = g3xmax;
140 g3zmin = -300; g4zmin = g3zmin;
141 g3zmax = 300; g4zmax = g3zmax;
143 else if (detName == "ITS") {
144 g3xmin = -60; g4xmin = g3xmin;
145 g3xmax = 60; g4xmax = g3xmax;
146 g3zmin = -60; g4zmin = g3zmin;
147 g3zmax = 60; g4zmax = g3zmax;
149 else if (detName == "MUON") {
150 g3xmin = -450; g4xmin = g3xmin;
151 g3xmax = 450; g4xmax = g3xmax;
152 g3zmin = 400; g4zmin = g3zmin;
153 g3zmax = 1800; g4zmax = g3zmax;
155 else if (detName == "PHOS") {
156 g3xmin = -400; g4xmin = g3xmin;
157 g3xmax = 400; g4xmax = g3xmax;
158 g3ymin = -500; g4ymin = g3ymin;
159 g3ymax = -250; g4ymax = g3ymax;
160 g3zmin = -80; g4zmin = g3zmin;
161 g3zmax = 80; g4zmax = g3zmax;
163 else if (detName == "PMD") {
164 g3xmin = -200; g4xmin = g3xmin*10;
165 g3xmax = 200; g4xmax = g3xmax*10;
166 g3zmin = -582; g4zmin = g3zmin*10;
167 g3zmax = -578; g4zmax = g3zmax*10;
169 else if (detName == "START") {
170 g3xmin = -10; g4xmin = g3xmin;
171 g3xmax = 10; g4xmax = g3xmax;
172 g3zmin = -80; g4zmin = g3zmin;
173 g3zmax = 80; g4zmax = g3zmax;
175 else if (detName == "TOF") {
176 g3xmin = -400; g4xmin = g3xmin;
177 g3xmax = 400; g4xmax = g3xmax;
178 g3zmin = -400; g4zmin = g3zmin;
179 g3zmax = 400; g4zmax = g3zmax;
181 else if (detName == "TPC") {
182 g3xmin = -300; g4xmin = g3xmin;
183 g3xmax = 300; g4xmax = g3xmax;
184 g3zmin = -300; g4zmin = g3zmin;
185 g3zmax = 300; g4zmax = g3zmax;
189 AliDetector* LoadDetector(TString& fileName, TString& detName, TString& label)
191 // connect the Root files
192 TFile* file = new TFile(fileName);
194 cerr << "Root file was not found." << endl;
198 // get AliRun object from file
199 if (gAlice) delete gAlice;
201 gAlice = (AliRun*)file->Get("gAlice");
203 cerr << label << "AliRun object not found in a file." << endl;
207 // import the hits trees
208 Int_t nparticles = gAlice->GetEvent(0);
209 if (nparticles <= 0) {
210 cerr << label << "No particles in a file." << endl;
213 cout << label << "got nparticles = " << nparticles << endl;
216 AliDetector* detector = gAlice->GetDetector(detName);
218 cerr << label << "No detector " << detName << " in a file." << endl;
225 void FillHitsHistogram(AliDetector* detector, TString& label,
226 TH1F* hx, TH1F* hy, TH1F* hz)
229 // get number of primary tracks
230 Int_t ntracks = gAlice->TreeH()->GetEntries();
231 cout << label << "got ntracks = " << ntracks << endl;
233 // loop on tracks in the hits container
234 for (Int_t i=0; i<ntracks; i++)
236 for(AliHit* hit= detector->FirstHit(i); hit; hit=detector->NextHit()) {
237 Float_t x = hit->X();
238 Float_t y = hit->Y();
239 Float_t z = hit->Z();
246 cout << label << "filled " << nofHits << " hits" << endl;
249 void FillDigitsHistogram(TString& className, TString& branchName,
250 TString& label, TH1F* hx, TH1F* hy, TH1F* hz)
252 // get number of primary tracks
253 TClonesArray* tmpHits = new TClonesArray(className, 1000) ;
254 TBranch* branch = gAlice->TreeD()->GetBranch(branchName);
255 branch->SetAddress(&tmpHits);
257 Int_t ntracks = gAlice->TreeD()->GetEntries();
258 cout << label << "got ntracks = " << ntracks << endl;
261 // loop on tracks in the digits container
262 for (Int_t i=0; i<ntracks; i++) {
267 for (Int_t ih=0; ih<tmpHits->GetEntriesFast(); ih++) {
268 AliHit* hit = (AliHit*) tmpHits->UncheckedAt(ih);
269 Float_t x = hit->X();
270 Float_t y = hit->Y();
271 Float_t z = hit->Z();
279 cout << label << "filled " << nofHits << " hits" << endl;
282 void DrawHistograms(TString& title, TString& gifName,
283 TH1F* h1, TH1F* h2, TH1F* h3, TH1F* h4)
285 // Create canvas, set the view range, show histograms.
288 if (h1 && h2 && h3 && h4) {
290 //TCanvas* canvas = new TCanvas("c1",detName + " hits", 400, 10, 800, 600);
291 TCanvas* canvas = new TCanvas("c1", title, 400, 10, 800, 600);
295 canvas->cd(1); h1->Draw();
296 canvas->cd(2); h2->Draw();
297 canvas->cd(3); h3->Draw();
298 canvas->cd(4); h4->Draw();
301 //canvas->SaveAs(gifNameBase + "_x.gif");
302 canvas->SaveAs(gifName);