1 void MUONdigit (Int_t evNumber1=0,Int_t evNumber2=0,Int_t nCathode=1)
3 /////////////////////////////////////////////////////////////////////////
5 // This macros converts the pad-hit information into digits //
7 /////////////////////////////////////////////////////////////////////////
9 // Dynamically link some shared libs
11 if (gClassTable->GetID("AliRun") < 0) {
12 gSystem->Load("$ALITOP/cern.so/lib/libpdfDUMMY.so");
13 gSystem->Load("$ALITOP/cern.so/lib/libPythia.so");
14 gSystem->Load("$ROOTSYS/lib/libEG.so");
15 gSystem->Load("$ROOTSYS/lib/libEGPythia.so");
16 gSystem->Load("libGeant3Dummy.so"); //a dummy version of Geant3
17 gSystem->Load("PHOS/libPHOSdummy.so"); //the standard Alice classes
18 gSystem->Load("libgalice.so"); //the standard Alice classes
21 // Connect the Root Galice file containing Geometry, Kine and Hits
23 TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject("galice.root");
24 if (file) file->Close();
25 file = new TFile("galice.root","UPDATE");
29 printf ("\n File loaded !");
31 // Get AliRun object from file or create it if not on file
34 gAlice = (AliRun*)file->Get("gAlice");
35 if (gAlice) printf("\n AliRun object found on file\n");
36 if (!gAlice) gAlice = new AliRun("gAlice","Alice test program");
38 printf ("\n gAlice created !\n");
40 AliMUON *MUON = gAlice->GetDetector("MUON");
42 AliMUONchamber* iChamber;
43 AliMUONsegmentation* segmentation;
50 AliMUONlist *elem[10][1026][1026];
51 TObjArray *obj=new TObjArray;
59 trinfo=new TVector(2);
67 for (int nev=0; nev<= evNumber2; nev++) {
68 Int_t nparticles = gAlice->GetEvent(nev);
69 cout << "nev " <<nev<<endl;
70 cout << "nparticles " <<nparticles<<endl;
71 if (nev < evNumber1) continue;
72 if (nparticles <= 0) return;
74 TTree *TH = gAlice->TreeH();
75 Int_t ntracks = TH->GetEntries();
81 for (int icat=0; icat<nCathode; icat++) {
83 // initialize the array of pointers
84 printf("\n Initialize array of pointers \n");
85 for (int i=0; i<10; i++) {
86 for (int j=0; j<nymax; j++) {
87 for (int k=0; k<nxmax; k++) {
92 printf("\n Finished !\n");
97 printf("\n ntracks: %d",ntracks);
99 for (Int_t track=0; track<ntracks;track++) {
101 Int_t nbytes += TH->GetEvent(track);
103 for(AliMUONhit* mHit=(AliMUONhit*)MUON->FirstHit(-1);
105 mHit=(AliMUONhit*)MUON->NextHit())
107 Int_t nch = mHit->fChamber; // chamber number
108 Float_t x = mHit->fX; // x-pos of hit
109 Float_t y = mHit->fY; // y-pos
112 iChamber = &(MUON->Chamber(nch-1));
113 response=iChamber->GetResponseModel();
115 Int_t nsec=iChamber->Nsec();
116 Int_t rmin = (Int_t)iChamber->frMin;
117 Int_t rmax = (Int_t)iChamber->frMax;
118 if (nch > 10) continue;
122 for (AliMUONcluster* mPad=
123 (AliMUONcluster*)MUON->FirstPad(mHit);
125 mPad=(AliMUONcluster*)MUON->NextPad())
127 Int_t cathode = mPad->fCathode; // cathode number
128 Int_t nhit = mPad->fHitNumber; // hit number
129 Int_t qtot = mPad->fQ; // charge
130 Int_t ipx = mPad->fPadX; // pad X
131 Int_t ipy = mPad->fPadY; // pad Y
132 Int_t iqpad = mPad->fQpad; // charge per pad
133 Int_t rsec = mPad->fRSec; // sector#
136 if (cathode != (icat+1)) continue;
137 segmentation=iChamber->
138 GetSegmentationModel(cathode);
139 Int_t Npx[nch-1] = segmentation->Npx();
140 Int_t Npy[nch-1] = segmentation->Npy();
143 Int_t npx=Npx[nch-1];
144 Int_t npy=Npy[nch-1];
146 segmentation->GetPadCxy(ipx,ipy,thex,they);
148 Float_t rpad=TMath::Sqrt(thex*thex+they*they);
152 if (rpad < rmin || iqpad ==0 || rpad > rmax) continue;
154 // fill the info array
156 trinfo(0)=(Float_t)track;
157 trinfo(1)=(Float_t)iqpad;
163 // build the list of fired pads and update the info
165 AliMUONlist *pdigit=elem[nch-1][ipy+npy][ipx+npx];
169 new AliMUONlist(rpad,digits),counter);
171 Int_t last=obj->GetLast();
172 pdigit=(AliMUONlist*)obj->At(last);
173 elem[nch-1][ipy+npy][ipx+npx]=pdigit;
176 (TObjArray*)pdigit->TrackList();
180 (*pdigit).fSignal+=iqpad;
181 // update list of tracks
182 TObjArray* trlist=(TObjArray*)pdigit
184 Int_t nptracks=trlist->GetEntriesFast();
186 for (Int_t tr=0;tr<nptracks;tr++) {
187 TVector *ptrk=(TVector*)trlist->At(tr);
188 // TVector &vtrk = *ptrk;
189 Int_t entries=ptrk->GetNrows();
190 trk[tr]=Int_t(ptrk(0));
191 chtrk[tr]=Int_t(ptrk(1));
192 if (trk[tr]==track) {
194 trlist->RemoveAt(tr);
197 trlist->AddAt(trinfo,tr);
201 } // end loop over list of tracks for one pad
203 } //end loop over clust
210 cout<<"Start filling digits now !"<<endl;
211 const Int_t zero_supm = 6;
212 const Int_t adc_satm = 1024;
216 // start filling the digits
217 for (Int_t id=0; id<10; id++) {
219 for (Int_t iy=0;iy<nymax;iy++) {
220 for (Int_t ix=0;ix<nxmax;ix++) {
221 AliMUONlist *address=elem[id][iy][ix];
222 if (address==0) continue;
223 // do zero-suppression and signal truncation
224 Int_t q=address->fSignal;
226 if ( q <= zero_supm ) continue;
227 if ( q > adc_satm) q=adc_satm;
228 digits[0]=address->fPadX;
229 digits[1]=address->fPadY;
230 digits[2]=address->fSignal;
232 TObjArray* trlist=(TObjArray*)address->TrackList();
233 Int_t nptracks=trlist->GetEntriesFast();
234 // this was changed to accomodate the real number of tracks
236 cout<<"Attention - nptracks > 10 "<<nptracks<<endl;
239 for (Int_t tr=0;tr<nptracks;tr++) {
240 TVector *pp=(TVector*)trlist->At(tr);
241 Int_t entries=pp->GetNrows();
243 tracks[tr]=(Int_t)v2(0);
244 charges[tr]=(Int_t)v2(1);
245 } //end loop over list of tracks for one pad
248 MUON->AddDigits(id,tracks,charges,digits);
250 } // end loop over ix
251 } // end loop over iy
252 cout<<"I'm out of the loops over pads"<<endl;
253 cout<<" id nd "<<id<<" "<<nd<<endl;
254 } //loop over chambers
255 cout<<"I'm out of the loops for digitisation"<<endl;
257 gAlice->TreeD()->Fill();
258 TTree *TD=gAlice->TreeD();
259 int ndig=TD->GetEntries();
260 cout<<"number of digits "<<ndig<<endl;
263 for (int i=0;i<10;i++) {
264 fDch= MUON->DigitsAddress(i);
265 int ndig=fDch->GetEntriesFast();
266 printf (" i, ndig %d %d \n",i,ndig);
272 } //end loop over cathodes
275 sprintf(hname,"TreeD%d",nev);
276 gAlice->TreeD()->Write(hname);
285 cout<<"END digitisation "<<endl;