]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RICH/RICHgainvar.C
Do not create treeD anymore.
[u/mrichter/AliRoot.git] / RICH / RICHgainvar.C
1 void RICHgainvar (Int_t evNumber1=0,Int_t evNumber2=0) 
2 {
3
4   gClassTable->GetID("AliRun");
5
6
7   // Dynamically link some shared libs
8  
9   if (gClassTable->GetID("AliRun") < 0) {
10     gROOT->LoadMacro("loadlibs.C");
11     loadlibs();
12   }else {
13     delete gAlice;
14     gAlice = 0;
15   }
16   
17   gAlice=0;
18   
19   // Connect the Root Galice file containing Geometry, Kine and Hits
20   
21   TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject("galice.root");
22   if (!file) file = new TFile("galice.root","UPDATE");
23   
24   // Get AliRun object from file or create it if not on file
25   
26   if (!gAlice) {
27     gAlice = (AliRun*)file->Get("gAlice");
28     if (gAlice) printf("AliRun object found on file\n");
29     if (!gAlice) gAlice = new AliRun("gAlice","Alice test program");
30   }
31   else {
32     delete gAlice;
33     gAlice = (AliRun*)file->Get("gAlice");
34     if (gAlice) printf("AliRun object found on file\n");
35     if (!gAlice) gAlice = new AliRun("gAlice","Alice test program");
36   }
37   
38   AliRICH *RICH  = (AliRICH*)gAlice->GetDetector("RICH");
39   
40   TH1F *gainX = new TH1F("gainX","Gain along the wires",40,0,40);
41   TH1F *gainIn = new TH1F("gainIn","Gain near the center of photocathode",300,0,300);
42   TH1F *gainOut = new TH1F("gainOut","Gain near the edge of photocathode",300,0,300);
43   TH1F *gainPhi1 = new TH1F("gainPhi1","Gain variation along wires, 0-30 degrees",300,0,300);
44   TH1F *gainPhi2 = new TH1F("gainPhi2","Gain variation along wires, 30-60 degrees",300,0,300);
45   TH1F *gainPhi3 = new TH1F("gainPhi3","Gain variation along wires, 60-90 degrees",300,0,300);
46   TH1F *gainPhi4 = new TH1F("gainPhi4","Gain variation along wires, 90-120 degrees",300,0,300);
47   TH1F *gainPhi5 = new TH1F("gainPhi5","Gain variation along wires, 120-150 degrees",300,0,300);
48   TH1F *gainPhi6 = new TH1F("gainPhi6","Gain variation along wires, 150-180 degrees",300,0,300);
49   TH1F *gainPhi7 = new TH1F("gainPhi7","Gain variation along wires, 180-210 degrees",300,0,300);
50   TH1F *gainPhi8 = new TH1F("gainPhi8","Gain variation along wires, 210-240 degrees",300,0,300);
51   TH1F *gainPhi9 = new TH1F("gainPhi9","Gain variation along wires, 240-270 degrees",300,0,300);
52   TH1F *gainPhi10 = new TH1F("gainPhi10","Gain variation along wires, 270-300 degrees",300,0,300);
53   TH1F *gainPhi11 = new TH1F("gainPhi11","Gain variation along wires, 300-330 degrees",300,0,300);
54   TH1F *gainPhi12 = new TH1F("gainPhi12","Gain variation along wires, 330-360 degrees",300,0,300);
55   TH1F *gainPhi = new TH1F("gainPhi","Gain variation along phi",36,0,360);
56
57   //   Start loop over events 
58
59   for (int nev=0; nev<= evNumber2; nev++) {
60     Int_t nparticles = gAlice->GetEvent(nev);
61     
62     
63     printf ("\n**********************************\nProcessing Event: %d\n",nev);
64     printf ("Particles       : %d\n\n",nparticles);
65     if (nev < evNumber1) continue;
66     if (nparticles <= 0) return;
67        
68     // Get pointers to RICH detector and Hits containers
69        
70     
71     TTree *TH = gAlice->TreeH(); 
72     Int_t ntracks = TH->GetEntries();
73     Int_t nent=(Int_t)gAlice->TreeR()->GetEntries();
74     gAlice->TreeR()->GetEvent(nent-1);
75     TClonesArray *Rawclusters = RICH->RawClustAddress(2);    //  Raw clusters branch
76     //printf ("Rawclusters:%p",Rawclusters);
77     Int_t nrawclusters = Rawclusters->GetEntriesFast();
78     //printf (" nrawclusters:%d\n",nrawclusters);
79     
80     
81     // Start loop on tracks in the hits containers
82     Int_t Nc=0;
83     for (Int_t track=0; track<ntracks;track++) {
84       printf ("\nProcessing Track: %d\n",track);
85       gAlice->ResetHits();
86       Int_t nbytes += TH->GetEvent(track);
87       if (RICH)
88         TClonesArray *Hits = RICH->Hits();            // Hits branch
89       //see hits distribution
90       
91       Int_t nhits = Hits->GetEntriesFast();
92       printf("Hits            : %d\n",nhits);
93       for (Int_t hit=0;hit<nhits;hit++) {
94         mHit = (AliRICHHit*) Hits->UncheckedAt(hit);
95         Float_t mx  = mHit->X();                    // x-pos of hit
96         Float_t my  = mHit->Z();                    // y-pos
97       }
98
99
100       if (nrawclusters) {
101         printf("Raw Clusters    : %d\n",nrawclusters);
102         for (Int_t hit=0;hit<nrawclusters;hit++) {
103           rcHit = (AliRICHRawCluster*) Rawclusters->UncheckedAt(hit);
104           //Int_t nchamber = rcHit->fChamber;     // chamber number
105           //Int_t nhit = cHit->fHitNumber;        // hit number
106           Int_t qtot = rcHit->fQ;                 // charge
107           Int_t fx  =  rcHit->fX;                 // x-position
108           Int_t fy  =  rcHit->fY;                 // y-position
109           Int_t mult = rcHit->fMultiplicity;      // How many pads form the cluster
110                             
111           Float_t radfid = TMath::Sqrt((TMath::Power(fx-mx,2)+(TMath::Power(fy-my,2))));
112           //printf("Radius:%f\n", radfid);
113           
114           
115           if(qtot<200 && radfid>=9 && radfid<=15)
116             {
117               if (fy>=0)
118                 gainX->Fill(fy-40,(float) qtot);
119               else
120                 gainX->Fill(fy+40,(float) qtot);
121               
122               if(fy<=0 && fy>=-4)
123                 gainOut->Fill(qtot,(float) 1);
124               if(fy<=-11 && fy>=-15)
125                 gainIn->Fill(qtot,(float) 1);
126               
127               Float_t phi = TMath::ATan2(fx-mx, fy-my);
128               Float_t phi_deg = phi/TMath::Pi()*180;
129               
130               if ((fx-mx)<0)
131                 {
132                   phi_deg = 360+phi_deg;
133                   //printf("X:%f, Y:%f, Phi:%f\n",-fy+my,fx-mx,phi_deg);
134                 }
135               else
136                 {
137                   //printf("X:%f, Y:%f, Phi:%f\n",-fy+my,fx-mx,phi_deg);
138                 }
139               
140               
141               if (phi_deg>=0 && phi_deg<30)
142                 gainPhi1->Fill(qtot,(float) 1);
143               if (phi_deg>=30 && phi_deg<60)
144                 gainPhi2->Fill(qtot,(float) 1);
145               if (phi_deg>=60 && phi_deg<90)
146                 gainPhi3->Fill(qtot,(float) 1);
147               if (phi_deg>=90 && phi_deg<120)
148                 gainPhi4->Fill(qtot,(float) 1);
149               if (phi_deg>=120 && phi_deg<150)
150                 gainPhi5->Fill(qtot,(float) 1);
151               if (phi_deg>=150 && phi_deg<180)
152                 gainPhi6->Fill(qtot,(float) 1);
153               if (phi_deg>=180 && phi_deg<210)
154                 gainPhi7->Fill(qtot,(float) 1);
155               if (phi_deg>=210 && phi_deg<240)
156                 gainPhi8->Fill(qtot,(float) 1);
157               if (phi_deg>=240 && phi_deg<270)
158                 gainPhi9->Fill(qtot,(float) 1);
159               if (phi_deg>=270 && phi_deg<300)
160                 gainPhi10->Fill(qtot,(float) 1);
161               if (phi_deg>=300 && phi_deg<330)
162                 gainPhi11->Fill(qtot,(float) 1);
163               if (phi_deg>=330 && phi_deg<360)
164                 gainPhi12->Fill(qtot,(float) 1);
165               
166             }
167           
168           //printf("Y:%d, Q:%d %d in %d\n",fy, qtot,hit,nrawclusters);
169         }
170       }
171     }
172   }
173
174   
175   TCanvas *c16 = new TCanvas("c16","Gain Variation over Phi",50,50,1200,700);
176   c16->Divide(4,3);
177   //c16->SetFillColor(42);
178   
179   c16->cd(1);
180   c16_1->SetLogy();
181   gainPhi1->SetFillColor(5);
182   gainPhi1->SetXTitle("ADC counts");
183   gainPhi1->Fit("expo","M");
184   expo->SetLineColor(2);
185   expo->SetLineWidth(3);
186   Float_t inv_slope1 = -1/expo->GetParameter(1);
187   gainPhi->Fill(15, (float) inv_slope1);
188   gainPhi1->Draw();
189   
190   c16->cd(2);
191   c16_2->SetLogy();
192   gainPhi2->SetFillColor(5);
193   gainPhi2->SetXTitle("ADC counts");
194   gainPhi2->Fit("expo","M");
195   expo->SetLineColor(2);
196   expo->SetLineWidth(3);
197   Float_t inv_slope2 = -1/expo->GetParameter(1);
198   gainPhi->Fill(45, (float) inv_slope2);
199   gainPhi2->Draw();
200   
201   c16->cd(3);
202   c16_3->SetLogy();
203   gainPhi3->SetFillColor(5);
204   gainPhi3->SetXTitle("ADC counts");
205   gainPhi3->Fit("expo","M");
206   expo->SetLineColor(2);
207   expo->SetLineWidth(3);
208   Float_t inv_slope3 = -1/expo->GetParameter(1);
209   gainPhi->Fill(75, (float) inv_slope3);
210   gainPhi3->Draw();
211   
212   c16->cd(4);
213   c16_4->SetLogy();
214   gainPhi4->SetFillColor(5);
215   gainPhi4->SetXTitle("ADC counts");
216   gainPhi4->Fit("expo","M");
217   expo->SetLineColor(2);
218   expo->SetLineWidth(3);
219   Float_t inv_slope4 = -1/expo->GetParameter(1);
220   gainPhi->Fill(105, (float) inv_slope4);
221   gainPhi4->Draw();
222   
223   c16->cd(5);
224   c16_5->SetLogy();
225   gainPhi5->SetFillColor(5);
226   gainPhi5->SetXTitle("ADC counts");
227   gainPhi5->Fit("expo","M");
228   expo->SetLineColor(2);
229   expo->SetLineWidth(3);
230   Float_t inv_slope5 = -1/expo->GetParameter(1);
231   gainPhi->Fill(135, (float) inv_slope5);
232   gainPhi5->Draw();
233   
234   c16->cd(6);
235   c16_6->SetLogy();
236   gainPhi6->SetFillColor(5);
237   gainPhi6->SetXTitle("ADC counts");
238   gainPhi6->Fit("expo","M");
239   expo->SetLineColor(2);
240   expo->SetLineWidth(3);
241   Float_t inv_slope6 = -1/expo->GetParameter(1);
242   gainPhi->Fill(165, (float) inv_slope6);
243   gainPhi6->Draw();
244   
245   c16->cd(7);
246   c16_7->SetLogy();
247   gainPhi7->SetFillColor(5);
248   gainPhi7->SetXTitle("ADC counts");
249   gainPhi7->Fit("expo","M");
250   expo->SetLineColor(2);
251   expo->SetLineWidth(3);
252   Float_t inv_slope7 = -1/expo->GetParameter(1);
253   gainPhi->Fill(195, (float) inv_slope7);
254   gainPhi7->Draw();
255   
256   c16->cd(8);
257   c16_8->SetLogy();
258   gainPhi8->SetFillColor(5);
259   gainPhi8->SetXTitle("ADC counts");
260   gainPhi8->Fit("expo","M");
261   expo->SetLineColor(2);
262   expo->SetLineWidth(3);
263   Float_t inv_slope8 = -1/expo->GetParameter(1);
264   gainPhi->Fill(225, (float) inv_slope8);
265   gainPhi8->Draw();
266   
267   c16->cd(9);
268   c16_9->SetLogy();
269   gainPhi9->SetFillColor(5);
270   gainPhi9->SetXTitle("ADC counts");
271   gainPhi9->Fit("expo","M");
272   expo->SetLineColor(2);
273   expo->SetLineWidth(3);
274   Float_t inv_slope9 = -1/expo->GetParameter(1);
275   gainPhi->Fill(255, (float) inv_slope9);
276   c16->Update();
277   gainPhi9->Draw();
278   
279   
280   c16->cd(10);
281   c16_10->SetLogy();
282   gainPhi10->SetFillColor(5);
283   gainPhi10->SetXTitle("ADC counts");
284   gainPhi10->Fit("expo","M");
285   expo->SetLineColor(2);
286   expo->SetLineWidth(3);
287   Float_t inv_slope10 = -1/expo->GetParameter(1);
288   gainPhi->Fill(285, (float) inv_slope10);
289   gainPhi10->Draw();
290   
291   c16->cd(11);
292   c16_11->SetLogy();
293   gainPhi11->SetFillColor(5);
294   gainPhi11->SetXTitle("ADC counts");
295   gainPhi11->Fit("expo","M");
296   expo->SetLineColor(2);
297   expo->SetLineWidth(3);
298   Float_t inv_slope11 = -1/expo->GetParameter(1);
299   gainPhi->Fill(315, (float) inv_slope11);
300   gainPhi11->Draw();
301   
302   c16->cd(12);
303   c16_12->SetLogy();
304   gainPhi12->SetFillColor(5);
305   gainPhi12->SetXTitle("ADC counts");
306   gainPhi12->Fit("expo","M");
307   expo->SetLineColor(2);
308   expo->SetLineWidth(3);
309   Float_t inv_slope12 = -1/expo->GetParameter(1);
310   gainPhi->Fill(335, (float) inv_slope12);
311   gainPhi12->Draw();
312   
313   TCanvas *c17 = new TCanvas("c17","Gain Variation",50,50,600,700);
314   c17->Divide(2,2);
315   
316   //c11->SetFillColor(42);
317   
318   c17->cd(1);
319   c17_1->SetLogy();
320   gainIn->SetFillColor(5);
321   gainIn->SetXTitle("ADC counts");
322   gainIn->Fit("expo","M");
323   expo->SetLineColor(2);
324   expo->SetLineWidth(3);
325   gainIn->Draw();
326   
327   c17->cd(2);
328   c17_2->SetLogy();
329   gainOut->SetFillColor(5);
330   gainOut->SetXTitle("ADC counts");
331   gainOut->Fit("expo","M");
332   expo->SetLineColor(2);
333   expo->SetLineWidth(3);
334   gainOut->Draw();
335   
336   c17->cd(3);
337   gainX->SetFillColor(5);
338   gainX->SetYTitle("Total ADC counts");
339   gainX->SetXTitle("(pads)");
340   gainX->Draw();
341   
342   c17->cd(4);
343   gainPhi->SetFillColor(5);
344   gainPhi->SetYTitle("Gain (ADC)");
345   gainPhi->SetXTitle("phi (degrees)");
346   gainPhi->Draw();
347
348   printf("\nEnd of macro\n");
349   printf("**********************************\n");
350   
351 }