1 void MUONtestsim(Int_t ncham, Int_t evNumber1=0,Int_t evNumber2=0)
3 /////////////////////////////////////////////////////////////////////////
4 // This macro is a small example of a ROOT macro
5 // illustrating how to read the output of GALICE
6 // and do some analysis.
8 /////////////////////////////////////////////////////////////////////////
10 // Dynamically link some shared libs
13 if (gClassTable->GetID("AliRun") < 0) {
14 gROOT->LoadMacro("loadlibs.C");
18 // Connect the Root Galice file containing Geometry, Kine and Hits
20 TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject("galice.root");
24 printf("\n Creating galice.root \n");
25 file = new TFile("galice.root");
27 printf("\n galice.root found in file list");
31 // Get AliRun object from file or create it if not on file
33 gAlice = (AliRun*)(file->Get("gAlice"));
34 if (gAlice) printf("AliRun object found on file\n");
36 printf("\n create new gAlice object");
37 gAlice = new AliRun("gAlice","Alice test program");
41 // Create some histograms
44 TH1F *ccharge1 = new TH1F("ccharge1","Cluster Charge distribution"
46 TH1F *pcharge1 = new TH1F("pcharge1","Pad Charge distribution"
48 TH1F *xresid1 = new TH1F("xresid1","x-Residuals"
50 TH1F *yresid1 = new TH1F("yresid1","y-Residuals"
52 TH1F *npads1 = new TH1F("npads1" ,"Pads per Hit"
54 TH2F *xresys1 = new TH2F("xresys1","x-Residuals systematics"
55 ,50,-2.0,2.0,100,-1.0,1.0);
56 TH2F *yresys1 = new TH2F("yresys1","y-Residuals systematics"
57 ,50,-0.4,0.4,100,-0.1,0.1);
59 TH1F *ccharge2 = new TH1F("ccharge2","Cluster Charge distribution"
61 TH1F *pcharge2 = new TH1F("pcharge2","Pad Charge distribution"
63 TH1F *xresid2 = new TH1F("xresid2","x-Residuals"
65 TH1F *yresid2 = new TH1F("yresid2","y-Residuals"
67 TH1F *npads2 = new TH1F("npads2" ,"Pads per Hit"
69 TH2F *xresys2 = new TH2F("xresys2","x-Residuals systematics"
70 ,50,-2.0,2.0,100,-1.0,1.0);
71 TH2F *yresys2 = new TH2F("yresys2","y-Residuals systematics"
72 ,50,-0.4,0.4,100,-0.1,0.1);
75 AliMUONChamber* iChamber;
81 for (Int_t nev=0; nev<= evNumber2; nev++) {
82 cout << "nev " << nev <<endl;
83 Int_t nparticles = gAlice->GetEvent(nev);
84 cout << "nparticles " << nparticles <<endl;
85 if (nev < evNumber1) continue;
86 if (nparticles <= 0) return;
88 AliMUON *MUON = (AliMUON*) gAlice->GetDetector("MUON");
89 printf("\n track %d %d \n ", nev, MUON);
91 TTree *TH = gAlice->TreeH();
92 Int_t ntracks = TH->GetEntries();
95 Float_t Q[2], xmean[2],ymean[2],xres[2],yres[2], xonpad[2], yonpad[2];
99 for (Int_t track=0; track<ntracks;track++) {
102 Int_t nbytes += TH->GetEvent(track);
104 for(AliMUONHit* mHit=(AliMUONHit*)MUON->FirstHit(-1);
106 mHit=(AliMUONHit*)MUON->NextHit())
108 Int_t nch = mHit->fChamber; // chamber number
109 Float_t x = mHit->X(); // x-pos of hit
110 Float_t y = mHit->Y(); // y-pos
111 Float_t z = mHit->Z();
115 iChamber = & MUON->Chamber(nch-1);
116 response=iChamber->ResponseModel();
120 for (Int_t i=0; i<2; i++) {
127 for (AliMUONPadHit* mPad=
128 (AliMUONPadHit*)MUON->FirstPad(mHit,MUON->PadHits());
130 mPad=(AliMUONPadHit*)MUON->NextPad(MUON->PadHits()))
133 Int_t nseg = mPad->fCathode; // segmentation
134 Int_t nhit = mPad->fHitNumber; // hit number
135 Int_t qtot = mPad->fQ; // charge
136 Int_t ipx = mPad->fPadX; // pad number on X
137 Int_t ipy = mPad->fPadY; // pad number on Y
138 Int_t iqpad = mPad->fQpad; // charge per pad
139 Int_t secpad = mPad->fRSec; // r-pos of pad
142 segmentation=iChamber->SegmentationModel(nseg);
145 segmentation->GetPadC(ipx, ipy, xg, yg, zg);
146 Int_t sec = segmentation->Sector(ipx, ipy);
147 Float_t dpx=segmentation->Dpx(sec);
148 Float_t dpy=segmentation->Dpy(sec);
151 pcharge1->Fill(iqpad,(float) 1);
152 ccharge1->Fill(qtot ,(float) 1);
154 pcharge2->Fill(iqpad,(float) 1);
155 ccharge2->Fill(qtot ,(float) 1);
157 // Calculate centre of gravity
159 if (iqpad == 0 && ind==0) {
160 printf("\n attention iqpad 0");
166 segmentation->GetPadC(ipx,ipy,xc,yc,zc);
167 xmean[ind]+=Float_t(iqpad*xc);
168 ymean[ind]+=Float_t(iqpad*yc);
173 for (Int_t i=0; i<2; i++) {
174 segmentation = iChamber->SegmentationModel(i+1);
176 xmean[i] = xmean[i]/Q[i];
177 xres[i] = xmean[i]-x;
178 ymean[i] = ymean[i]/Q[i];
179 yres[i] = ymean[i]-y;
186 GetPadI(x,y,z,icx,icy);
188 GetPadC(icx,icy,xonpad[i],yonpad[i],zonpad);
193 xresid1->Fill(xres[0],(float) 1);
194 yresid1->Fill(yres[0],(float) 1);
195 npads1->Fill(npad[0],(float) 1);
196 if (npad[0] >=2 && Q[0] > 6 ) {
197 xresys1->Fill(xonpad[0],xres[0],(float) 1);
198 yresys1->Fill(yonpad[0],yres[0],(float) 1);
201 xresid2->Fill(xres[1],(float) 1);
202 yresid2->Fill(yres[1],(float) 1);
203 npads2->Fill(npad[1],(float) 1);
204 if (npad[1] >=2 && Q[1] > 6) {
205 xresys2->Fill(xonpad[1],xres[1],(float) 1);
206 yresys2->Fill(yonpad[1],yres[1],(float) 1);
214 //Create a canvas, set the view range, show histograms
215 TCanvas *c1 = new TCanvas("c1","Charge and Residuals (1)",400,10,600,700);
216 pad11 = new TPad("pad11"," ",0.01,0.51,0.49,0.99);
217 pad12 = new TPad("pad12"," ",0.51,0.51,0.99,0.99);
218 pad13 = new TPad("pad13"," ",0.01,0.01,0.49,0.49);
219 pad14 = new TPad("pad14"," ",0.51,0.01,0.99,0.49);
220 pad11->SetFillColor(11);
221 pad12->SetFillColor(11);
222 pad13->SetFillColor(11);
223 pad14->SetFillColor(11);
230 ccharge1->SetFillColor(42);
231 ccharge1->SetXTitle("ADC units");
235 pcharge1->SetFillColor(42);
236 pcharge1->SetXTitle("ADC units");
240 xresid1->SetFillColor(42);
244 yresid1->SetFillColor(42);
247 TCanvas *c2 = new TCanvas("c2","Cluster Size (1)",400,10,600,700);
248 pad21 = new TPad("pad21"," ",0.01,0.51,0.49,0.99);
249 pad22 = new TPad("pad22"," ",0.51,0.51,0.99,0.99);
250 pad23 = new TPad("pad23"," ",0.01,0.01,0.49,0.49);
251 pad24 = new TPad("pad24"," ",0.51,0.01,0.99,0.49);
252 pad21->SetFillColor(11);
253 pad22->SetFillColor(11);
254 pad23->SetFillColor(11);
255 pad24->SetFillColor(11);
262 npads1->SetFillColor(42);
263 npads1->SetXTitle("Cluster Size");
267 xresys1->SetXTitle("x on pad");
268 xresys1->SetYTitle("x-xcog");
272 yresys1->SetXTitle("y on pad");
273 yresys1->SetYTitle("y-ycog");
276 TCanvas *c3 = new TCanvas("c3","Charge and Residuals (2)",400,10,600,700);
277 pad31 = new TPad("pad31"," ",0.01,0.51,0.49,0.99);
278 pad32 = new TPad("pad32"," ",0.51,0.51,0.99,0.99);
279 pad33 = new TPad("pad33"," ",0.01,0.01,0.49,0.49);
280 pad34 = new TPad("pad34"," ",0.51,0.01,0.99,0.49);
281 pad31->SetFillColor(11);
282 pad32->SetFillColor(11);
283 pad33->SetFillColor(11);
284 pad34->SetFillColor(11);
291 ccharge2->SetFillColor(42);
292 ccharge2->SetXTitle("ADC units");
296 pcharge2->SetFillColor(42);
297 pcharge2->SetXTitle("ADC units");
301 xresid2->SetFillColor(42);
305 yresid2->SetFillColor(42);
308 TCanvas *c4 = new TCanvas("c4","Cluster Size (2)",400,10,600,700);
309 pad41 = new TPad("pad41"," ",0.01,0.51,0.49,0.99);
310 pad42 = new TPad("pad42"," ",0.51,0.51,0.99,0.99);
311 pad43 = new TPad("pad43"," ",0.01,0.01,0.49,0.49);
312 pad44 = new TPad("pad44"," ",0.51,0.01,0.99,0.49);
313 pad41->SetFillColor(11);
314 pad42->SetFillColor(11);
315 pad43->SetFillColor(11);
316 pad44->SetFillColor(11);
323 npads2->SetFillColor(42);
324 npads2->SetXTitle("Cluster Size");
328 xresys2->SetXTitle("x on pad");
329 xresys2->SetYTitle("x-xcog");
333 yresys2->SetXTitle("y on pad");
334 yresys2->SetYTitle("y-ycog");