1 Int_t AliTOFSDigits2Digits(Int_t nev=5) {
3 // Adapted to the NewIO by I.Belikov (Jouri.Belikov@cern.ch)
5 // number 3 is a legacy from AliDigit object
8 delete gAlice->GetRunLoader();
9 delete gAlice;//if everything was OK here it is already NULL
13 AliRunLoader* rl = AliRunLoader::Open("galice.root");
15 cerr<<"Can not open session"<<endl;
19 if (rl->LoadgAlice()) {
20 cerr<<"Error occured while loading gAlice"<<endl;
24 AliLoader *tofl = rl->GetLoader("TOFLoader");
26 cerr<<"Can not get the TOF Loader"<<endl;
30 gAlice=rl->GetAliRun();
32 cerr<<"Can't get gAlice !\n";
36 tofl->LoadSDigits("read");
37 tofl->LoadDigits("recreate");
39 Int_t totndig=0; // total number of digits
40 Int_t tottracks=0; // total number of tracks contributing to totndig
42 if (nev>rl->GetNumberOfEvents()) nev=rl->GetNumberOfEvents();
44 TClonesArray *fSDigits=new TClonesArray("AliTOFSDigit", 1000);
45 TClonesArray *fDigits =new TClonesArray("AliTOFdigit", 1000);
46 TClonesArray &da=*fDigits;
48 for (Int_t ievent = 0; ievent < nev; ievent++) {
51 TTree *sTree=tofl->TreeS();
53 cerr<<"Can't get the sdigit tree !\n";
56 TBranch *branch=sTree->GetBranch("TOF");
58 cerr<<"Cant' get the branch !\n";
61 branch->SetAddress(&fSDigits);
63 TTree *dTree=tofl->TreeD();
68 branch=dTree->GetBranch("TOF");
69 if (!branch) dTree->Branch("TOF",&fDigits);
70 else branch->SetAddress(&fDigits);
72 Int_t nEntries = sTree->GetEntries();
73 for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {
74 sTree->GetEvent(iEntry);
76 Int_t ndig = fSDigits->GetEntriesFast();
77 cout << "----------------<AliTOFSDigits2Digits>----------------" << endl;
78 cout << "Found " << ndig << " TOF SDigits for event " << ievent << endl;
79 cout << "------------------------------------------------------" << endl;
81 for (Int_t k = 0; k < ndig; k++) {
82 Int_t vol[5]; // location for a digit
84 // Get the information for this digit
85 AliTOFSDigit *tofsdigit = (AliTOFSDigit *)fSDigits->UncheckedAt(k);
87 Int_t nslot=tofsdigit->GetNDigits(); // get the number of slots
90 // TOF sdigit volumes (always the same for all slots)
91 Int_t sector = tofsdigit->GetSector(); // range [1-18]
92 Int_t plate = tofsdigit->GetPlate(); // range [1- 5]
93 Int_t strip = tofsdigit->GetStrip(); // range [1-20]
94 Int_t padz = tofsdigit->GetPadz(); // range [1- 2]
95 Int_t padx = tofsdigit->GetPadx(); // range [1-48]
103 //--------------------- QA section ----------------------
104 // in the while, I perform QA
105 Bool_t isSDigitBad = (sector<1 || sector>18 ||
106 plate<1 || plate >5 ||
111 cout << "<AliTOFSDigits2Digits> strange sdigit found" << endl;
114 //-------------------------------------------------------
116 // start loop on number of slots for current sdigit
117 for (Int_t islot = 0; islot < nslot; islot++) {
118 Float_t digit[2]; // TOF digit variables
119 const Int_t kMAXDIGITS = 3;
120 Int_t tracknum[kMAXDIGITS];//contributing tracks for the current slot
122 Float_t tdc=tofsdigit->GetTdc(islot); digit[0]=tdc;
123 Float_t adc=tofsdigit->GetAdc(islot); digit[1]=adc;
125 tracknum[0]=tofsdigit->GetTrack(islot,0);
126 tracknum[1]=tofsdigit->GetTrack(islot,1);
127 tracknum[2]=tofsdigit->GetTrack(islot,2);
129 for (Int_t i = 0; i < kMAXDIGITS; i++) {
131 // search for the first empty location
138 // adding a TOF digit for each slot
140 Int_t ndigits=da.GetEntriesFast();
141 //cerr<<ndigits<<" ndig \n";
142 new (da[ndigits]) AliTOFdigit(tracknum, vol, digit);
148 } // end loop on sdigits
151 } // end loop on entries
154 tofl->WriteDigits("OVERWRITE");
159 } // end loop on events
164 cout << "----------------------------------------------------------" << endl;
165 cout << "<AliTOFSDigits2Digits> Summary" << endl;
166 cout << "contributing tracks to " << totndig << " digits: " << tottracks << endl;
167 cout << "----------------------------------------------------------" << endl;