1 Int_t AliTOFSDigits2Digits(Int_t numberOfEvents = 0) {
3 /////////////////////////////////////////////////////////////////////////
5 // Creates TOF digits from the summable digits for all event in the header file
10 // root[0] .L AliTOFSDigits2Digits.C
11 // root[1] AliTOFSDigits2Digits()
13 // By default, it creates digits for all the events in the header file.
15 // If you want create digits only the firts event
16 // you can use the following lines:
18 // root[0] .L AliTOFSDigits2Digits.C
19 // root[1] AliTOFSDigits2Digits(1)
21 // Created by: F. Pierella
22 // Updated to the new I/O: I.Belikov (Jouri.Belikov@cern.ch)
24 // Report problems to decaro@sa.infn.it
26 /////////////////////////////////////////////////////////////////////////
32 delete AliRunLoader::Instance();
37 AliRunLoader* rl = AliRunLoader::Open("galice.root");
40 cerr<<"Can not open session"<<endl;
47 cerr<<"Error occured while loading gAlice \n";
52 AliLoader *tofl = rl->GetLoader("TOFLoader");
55 cerr<<"Can not get the TOF Loader \n";
60 gAlice=rl->GetAliRun();
63 cerr<<"Can't get gAlice !\n";
68 tofl->LoadSDigits("read");
69 tofl->LoadDigits("recreate");
71 Int_t totndig=0; // total number of digits
72 Int_t tottracks=0; // total number of tracks contributing to totndig
74 if (numberOfEvents==0) numberOfEvents=rl->GetNumberOfEvents();
76 TClonesArray *fSDigits=new TClonesArray("AliTOFSDigit", 1000);
77 TClonesArray *fDigits =new TClonesArray("AliTOFdigit", 1000);
78 TClonesArray &da=*fDigits;
80 for (Int_t ievent = 0; ievent < numberOfEvents; ievent++) {
83 TTree *sTree=tofl->TreeS();
86 cerr<<"Can't get the sdigit tree !\n";
90 TBranch *branch=sTree->GetBranch("TOF");
93 cerr<<"Cant' get the branch !\n";
97 branch->SetAddress(&fSDigits);
99 TTree *dTree=tofl->TreeD();
104 branch=dTree->GetBranch("TOF");
105 if (!branch) dTree->Branch("TOF",&fDigits);
106 else branch->SetAddress(&fDigits);
108 Int_t nEntries = sTree->GetEntries();
109 for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {
110 sTree->GetEvent(iEntry);
112 Int_t ndig = fSDigits->GetEntriesFast();
113 cout << "----------------<AliTOFSDigits2Digits>---------------- \n";
114 cout << "Found " << ndig << " TOF SDigits for event " << ievent << endl;
115 cout << "------------------------------------------------------ \n";
117 for (Int_t k = 0; k < ndig; k++) {
118 Int_t vol[5]; // location for a digit
120 // Get the information for this digit
121 AliTOFSDigit *tofsdigit = (AliTOFSDigit *)fSDigits->UncheckedAt(k);
123 Int_t nslot=tofsdigit->GetNDigits(); // get the number of slots
124 // for current sdigit
126 // TOF sdigit volumes (always the same for all slots)
127 Int_t sector = tofsdigit->GetSector(); // range [0-17]
128 Int_t plate = tofsdigit->GetPlate(); // range [0- 4]
129 Int_t strip = tofsdigit->GetStrip(); // range [0-19]
130 Int_t padz = tofsdigit->GetPadz(); // range [0- 1]
131 Int_t padx = tofsdigit->GetPadx(); // range [0-47]
139 //--------------------- QA section ----------------------
140 // in the while, I perform QA
141 Bool_t isSDigitBad = (sector<0 || sector>17 ||
142 plate<0 || plate >4 ||
148 cout << "<AliTOFSDigits2Digits> strange sdigit found \n";
152 //-------------------------------------------------------
154 // start loop on number of slots for current sdigit
155 for (Int_t islot = 0; islot < nslot; islot++) {
156 Float_t digit[2]; // TOF digit variables
157 const Int_t kMAXDIGITS = 3; // number 3 is a legacy from AliDigit object
159 Int_t tracknum[kMAXDIGITS]; //contributing tracks for the current slot
161 Float_t tdc=tofsdigit->GetTdc(islot); digit[0]=tdc;
162 Float_t adc=tofsdigit->GetAdc(islot); digit[1]=adc;
164 tracknum[0]=tofsdigit->GetTrack(islot,0);
165 tracknum[1]=tofsdigit->GetTrack(islot,1);
166 tracknum[2]=tofsdigit->GetTrack(islot,2);
168 for (Int_t i = 0; i < kMAXDIGITS; i++) {
170 // search for the first empty location
177 // adding a TOF digit for each slot
179 Int_t ndigits=da.GetEntriesFast();
180 new (da[ndigits]) AliTOFdigit(tracknum, vol, digit);
185 } // end loop on sdigits
188 } // end loop on entries
191 tofl->WriteDigits("OVERWRITE");
196 } // end loop on events
201 tofl->UnloadDigits();
202 tofl->UnloadSDigits();
206 cout << "---------------------------------------------------------- \n";
207 cout << "<AliTOFSDigits2Digits> Summary \n";
208 cout << "contributing tracks to " << totndig << " digits: " << tottracks << endl;
209 cout << "---------------------------------------------------------- \n";
213 delete AliRunLoader::Instance();