1 void MUONpadtest (Int_t evNumber1=0,Int_t evNumber2=1)
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 /////////////////////////////////////////////////////////////////////////
11 Int_t NpadX = 252; // number of pads on X
12 Int_t NpadY = 374; // number of pads on Y
14 Int_t Pad[NpadX][NpadY];
15 for (Int_t i=0;i<NpadX;i++) {
16 for (Int_t j=0;j<NpadY;j++) {
23 // Dynamically link some shared libs
25 if (gClassTable->GetID("AliRun") < 0) {
26 gSystem->Load("libGeant3Dummy.so"); // a dummy version of Geant3
27 gSystem->Load("PHOS/libPHOSdummy.so"); // the standard Alice classes
28 gSystem->Load("libgalice.so"); // the standard Alice classes
31 // Connect the Root Galice file containing Geometry, Kine and Hits
33 TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject("galice.root");
34 if (!file) file = new TFile("galice.root");
36 // Get AliRun object from file or create it if not on file
39 gAlice = (AliRun*)file->Get("gAlice");
40 if (gAlice) printf("AliRun object found on file\n");
41 if (!gAlice) gAlice = new AliRun("gAlice","Alice test program");
44 // Create some histograms
51 TH2F *hc = new TH2F("hc","Chamber1 signal distribution",NpadX,xmin,xmax,NpadY,ymin,ymax);
52 TH2F *h = new TH2F("h","Chamber1 hit distribution",100,-100,100,100,-100,100);
53 TH1F *charge = new TH1F("charge","Charge distribution",100,0.,1000.);
55 // Start loop over events
59 for (int nev=0; nev<= evNumber2; nev++) {
60 Int_t nparticles = gAlice->GetEvent(nev);
61 cout<<"nev "<<nev<<endl;
62 cout<<"nparticles "<<nparticles<<endl;
63 if (nev < evNumber1) continue;
64 if (nparticles <= 0) return;
66 // Get pointers to MUON detector and Hits containers
68 AliMUON *MUON = gAlice->GetDetector("MUON");
69 TTree *TH = gAlice->TreeH();
70 Int_t ntracks = TH->GetEntries();
72 // Start loop on tracks in the hits containers
76 for (Int_t track=0; track<ntracks;track++) {
77 // printf("ntracks %d\n",ntracks);
79 Int_t nbytes += TH->GetEvent(track);
81 TClonesArray *Clusters = MUON->Clusters(); // Cluster branch
82 TClonesArray *Hits = MUON->Hits(); // Hits branch
83 //printf("%d %d \n",Clusters,Hits);
85 //see hits distribution
86 Int_t nhits = Hits->GetEntriesFast();
88 // printf("nhits %d\n",nhits);
89 for (Int_t hit=0;hit<nhits;hit++) {
90 mHit = (AliMUONhit*) Hits->UncheckedAt(hit);
91 Int_t nch = mHit->fChamber; // chamber number
92 Float_t x = mHit->fX; // x-pos of hit
93 Float_t y = mHit->fY; // y-pos
94 // Fill the histograms
96 Float_t rhit=TMath::Sqrt(x*x+y*y);
97 if( rhit<= 55 ) Nh1+=nhits;
98 h->Fill(x,y,(float) 1);
101 // see signal distribution
102 Int_t nclust = Clusters->GetEntriesFast();
103 // printf("nclust %d\n",nclust);
106 for (Int_t hit=0;hit<nclust;hit++) {
107 padHit = (AliMUONcluster*) Clusters->UncheckedAt(hit);
108 Int_t nchamber = padHit->fChamber; // chamber number
109 Int_t nhit = padHit->fHitNumber; // hit number
110 Int_t qtot = padHit->fQ; // charge
111 Int_t ipx = padHit->fPadX; // pad number on X
112 Int_t ipy = padHit->fPadY; // pad number on Y
113 Int_t iqpad = padHit->fQpad; // charge per pad
114 Int_t rpad = padHit->fRpad; // R-position of pad
115 if (qtot > 0 && nchamber==1){
116 charge->Fill(qtot,(float) 1);
118 if(rpad <= 55 && nchamber==1) {
120 Pad[ipx+126][ipy+187]+=(iqpad);
121 hc->Fill(ipx,ipy,(float) iqpad);
126 // cout<<"Nh "<<Nh<<endl;
127 cout<<"Nc "<<Nc<<endl;
129 //Create a canvas, set the view range, show histograms
130 TCanvas *c1 = new TCanvas("c1","Alice MUON pad hits",400,10,600,700);
131 hc->SetXTitle("ix (npads)");
133 TCanvas *c2 = new TCanvas("c2","Alice MUON hits",400,10,600,700);
135 h->SetXTitle("x (cm)");
137 TCanvas *c3 = new TCanvas("c3","Charge distribution",400,10,600,700);
138 charge->SetFillColor(42);
139 charge->SetXTitle("ADC units");
143 // calculate the number of pads which give a signal
147 for (Int_t i=0;i< NpadX;i++) {
148 for (Int_t j=0;j< NpadY;j++) {
151 // cout<<"i, j "<<i<<" "<<j<<endl;
156 cout<<"The total number of pads which give a signal "<<Np<<endl;
157 cout<<"Nh "<<Nh<<endl;
158 cout<<"Nh1 "<<Nh1<<endl;