1 Int_t AliTOFSDigits2Digits(Int_t nev = 1) {
3 // Adapted to the NewIO by I.Belikov (Jouri.Belikov@cern.ch)
4 // number 3 is a legacy from AliDigit object
10 delete gAlice->GetRunLoader();
15 AliRunLoader* rl = AliRunLoader::Open("galice.root");
18 cerr<<"Can not open session"<<endl;
25 cerr<<"Error occured while loading gAlice"<<endl;
30 AliLoader *tofl = rl->GetLoader("TOFLoader");
33 cerr<<"Can not get the TOF Loader"<<endl;
38 gAlice=rl->GetAliRun();
41 cerr<<"Can't get gAlice !\n";
46 tofl->LoadSDigits("read");
47 tofl->LoadDigits("recreate");
49 Int_t totndig=0; // total number of digits
50 Int_t tottracks=0; // total number of tracks contributing to totndig
52 if (nev>rl->GetNumberOfEvents()) nev=rl->GetNumberOfEvents();
54 TClonesArray *fSDigits=new TClonesArray("AliTOFSDigit", 1000);
55 TClonesArray *fDigits =new TClonesArray("AliTOFdigit", 1000);
56 TClonesArray &da=*fDigits;
58 for (Int_t ievent = 0; ievent < nev; ievent++) {
61 TTree *sTree=tofl->TreeS();
64 cerr<<"Can't get the sdigit tree !\n";
68 TBranch *branch=sTree->GetBranch("TOF");
71 cerr<<"Cant' get the branch !\n";
75 branch->SetAddress(&fSDigits);
77 TTree *dTree=tofl->TreeD();
82 branch=dTree->GetBranch("TOF");
83 if (!branch) dTree->Branch("TOF",&fDigits);
84 else branch->SetAddress(&fDigits);
86 Int_t nEntries = sTree->GetEntries();
87 for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {
88 sTree->GetEvent(iEntry);
90 Int_t ndig = fSDigits->GetEntriesFast();
91 cout << "----------------<AliTOFSDigits2Digits>----------------" << endl;
92 cout << "Found " << ndig << " TOF SDigits for event " << ievent << endl;
93 cout << "------------------------------------------------------" << endl;
95 for (Int_t k = 0; k < ndig; k++) {
96 Int_t vol[5]; // location for a digit
98 // Get the information for this digit
99 AliTOFSDigit *tofsdigit = (AliTOFSDigit *)fSDigits->UncheckedAt(k);
101 Int_t nslot=tofsdigit->GetNDigits(); // get the number of slots
102 // for current sdigit
104 // TOF sdigit volumes (always the same for all slots)
105 Int_t sector = tofsdigit->GetSector(); // range [1-18]
106 Int_t plate = tofsdigit->GetPlate(); // range [1- 5]
107 Int_t strip = tofsdigit->GetStrip(); // range [1-20]
108 Int_t padz = tofsdigit->GetPadz(); // range [1- 2]
109 Int_t padx = tofsdigit->GetPadx(); // range [1-48]
117 //--------------------- QA section ----------------------
118 // in the while, I perform QA
119 Bool_t isSDigitBad = (sector<1 || sector>18 ||
120 plate<1 || plate >5 ||
126 cout << "<AliTOFSDigits2Digits> strange sdigit found" << endl;
130 //-------------------------------------------------------
132 // start loop on number of slots for current sdigit
133 for (Int_t islot = 0; islot < nslot; islot++) {
134 Float_t digit[2]; // TOF digit variables
135 const Int_t kMAXDIGITS = 3;
136 Int_t tracknum[kMAXDIGITS];//contributing tracks for the current slot
138 Float_t tdc=tofsdigit->GetTdc(islot); digit[0]=tdc;
139 Float_t adc=tofsdigit->GetAdc(islot); digit[1]=adc;
141 tracknum[0]=tofsdigit->GetTrack(islot,0);
142 tracknum[1]=tofsdigit->GetTrack(islot,1);
143 tracknum[2]=tofsdigit->GetTrack(islot,2);
145 for (Int_t i = 0; i < kMAXDIGITS; i++) {
147 // search for the first empty location
154 // adding a TOF digit for each slot
156 Int_t ndigits=da.GetEntriesFast();
157 new (da[ndigits]) AliTOFdigit(tracknum, vol, digit);
163 } // end loop on sdigits
166 } // end loop on entries
169 tofl->WriteDigits("OVERWRITE");
174 } // end loop on events
179 tofl->UnloadDigits();
180 tofl->UnloadSDigits();
184 cout << "----------------------------------------------------------" << endl;
185 cout << "<AliTOFSDigits2Digits> Summary" << endl;
186 cout << "contributing tracks to " << totndig << " digits: " << tottracks << endl;
187 cout << "----------------------------------------------------------" << endl;
191 delete gAlice->GetRunLoader();