Int_t AliTOFSDigits2Digits(Int_t nev=5) { // Adapted to the NewIO by I.Belikov (Jouri.Belikov@cern.ch) // number 3 is a legacy from AliDigit object if (gAlice) { delete gAlice->GetRunLoader(); delete gAlice;//if everything was OK here it is already NULL gAlice = 0x0; } AliRunLoader* rl = AliRunLoader::Open("galice.root"); if (rl == 0x0) { cerr<<"Can not open session"<LoadgAlice()) { cerr<<"Error occured while loading gAlice"<GetLoader("TOFLoader"); if (tofl == 0x0) { cerr<<"Can not get the TOF Loader"<GetAliRun(); if (!gAlice) { cerr<<"Can't get gAlice !\n"; return 1; } tofl->LoadSDigits("read"); tofl->LoadDigits("recreate"); Int_t totndig=0; // total number of digits Int_t tottracks=0; // total number of tracks contributing to totndig if (nev>rl->GetNumberOfEvents()) nev=rl->GetNumberOfEvents(); TClonesArray *fSDigits=new TClonesArray("AliTOFSDigit", 1000); TClonesArray *fDigits =new TClonesArray("AliTOFdigit", 1000); TClonesArray &da=*fDigits; for (Int_t ievent = 0; ievent < nev; ievent++) { rl->GetEvent(ievent); TTree *sTree=tofl->TreeS(); if (sTree == 0) { cerr<<"Can't get the sdigit tree !\n"; return 1; } TBranch *branch=sTree->GetBranch("TOF"); if (!branch) { cerr<<"Cant' get the branch !\n"; return 1; } branch->SetAddress(&fSDigits); TTree *dTree=tofl->TreeD(); if (dTree == 0) { tofl->MakeTree("D"); dTree=tofl->TreeD(); } branch=dTree->GetBranch("TOF"); if (!branch) dTree->Branch("TOF",&fDigits); else branch->SetAddress(&fDigits); Int_t nEntries = sTree->GetEntries(); for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) { sTree->GetEvent(iEntry); Int_t ndig = fSDigits->GetEntriesFast(); cout << "--------------------------------" << endl; cout << "Found " << ndig << " TOF SDigits for event " << ievent << endl; cout << "------------------------------------------------------" << endl; for (Int_t k = 0; k < ndig; k++) { Int_t vol[5]; // location for a digit // Get the information for this digit AliTOFSDigit *tofsdigit = (AliTOFSDigit *)fSDigits->UncheckedAt(k); Int_t nslot=tofsdigit->GetNDigits(); // get the number of slots // for current sdigit // TOF sdigit volumes (always the same for all slots) Int_t sector = tofsdigit->GetSector(); // range [1-18] Int_t plate = tofsdigit->GetPlate(); // range [1- 5] Int_t strip = tofsdigit->GetStrip(); // range [1-20] Int_t padz = tofsdigit->GetPadz(); // range [1- 2] Int_t padx = tofsdigit->GetPadx(); // range [1-48] vol[0] = sector; vol[1] = plate; vol[2] = strip; vol[3] = padx; vol[4] = padz; //--------------------- QA section ---------------------- // in the while, I perform QA Bool_t isSDigitBad = (sector<1 || sector>18 || plate<1 || plate >5 || padz<1 || padz>2 || padx<1 || padx>48); if (isSDigitBad) { cout << " strange sdigit found" << endl; return 3; } //------------------------------------------------------- // start loop on number of slots for current sdigit for (Int_t islot = 0; islot < nslot; islot++) { Float_t digit[2]; // TOF digit variables const Int_t kMAXDIGITS = 3; Int_t tracknum[kMAXDIGITS];//contributing tracks for the current slot Float_t tdc=tofsdigit->GetTdc(islot); digit[0]=tdc; Float_t adc=tofsdigit->GetAdc(islot); digit[1]=adc; tracknum[0]=tofsdigit->GetTrack(islot,0); tracknum[1]=tofsdigit->GetTrack(islot,1); tracknum[2]=tofsdigit->GetTrack(islot,2); for (Int_t i = 0; i < kMAXDIGITS; i++) { tottracks++; // search for the first empty location if(tracknum[i]==-1){ tottracks--; break; } } // adding a TOF digit for each slot { Int_t ndigits=da.GetEntriesFast(); //cerr<Clear(); } // end loop on entries dTree->Fill(); tofl->WriteDigits("OVERWRITE"); // free used memory fDigits->Clear(); } // end loop on events delete fSDigits; delete fDigits; cout << "----------------------------------------------------------" << endl; cout << " Summary" << endl; cout << "contributing tracks to " << totndig << " digits: " << tottracks << endl; cout << "----------------------------------------------------------" << endl; return 0; }