X-Git-Url: http://git.uio.no/git/?p=u%2Fmrichter%2FAliRoot.git;a=blobdiff_plain;f=PHOS%2FAliPHOSDigitizer.cxx;h=a01511fad926e258dc1bfb6304963b35f480a728;hp=ccf5eef1f78ef407c5b237a45f3fae57a60c6d8e;hb=03358e3b9509850826e6ac36991df780d3b49f07;hpb=7b7c15335990bc27772c67f9ee7bc90cc48bc9a3 diff --git a/PHOS/AliPHOSDigitizer.cxx b/PHOS/AliPHOSDigitizer.cxx index ccf5eef1f78..a01511fad92 100644 --- a/PHOS/AliPHOSDigitizer.cxx +++ b/PHOS/AliPHOSDigitizer.cxx @@ -192,10 +192,10 @@ void AliPHOSDigitizer::Digitize(const Int_t event) TString eventS ; eventS += event ; while ( (folder = (TFolder*)next()) ) { - if ( (strcmp(folder->GetTitle(), eventS.Data()) == 0) || (strcmp(folder->GetTitle(), "") == 0) ) { + if ( (strcmp(folder->GetTitle(), eventS.Data()) == 0) || (strcmp(folder->GetTitle(), "") == 0) ) { Int_t numberoffiles = 0 ; if ( (sdigits = (TClonesArray*)folder->FindObject(GetName()) ) ) { - cout << "INFO: AliPHOSDigitizer::Exec -> Adding SDigits " << GetName() << " from " << folder->GetName() << endl ; + cout << "INFO: AliPHOSDigitizer::Digitize -> Adding SDigits " << GetName() << " from " << folder->GetName() << endl ; numberoffiles++ ; Int_t index ; AliPHOSDigit * curSDigit ; @@ -279,17 +279,18 @@ void AliPHOSDigitizer::Exec(Option_t *option) for(ievent = 0; ievent < nevents; ievent++){ + gAlice->GetEvent(ievent); + gAlice->SetEvent(ievent) ; if(!ReadSDigits(ievent)) //read sdigits event(s) evaluated by Combinator() from file(s) - return ; + continue ; Digitize(ievent) ; //Add prepared SDigits to digits and add the noise WriteDigits(ievent) ; - } - if(strstr(option,"deb")) - PrintDigits(option); - + if(strstr(option,"deb")) + PrintDigits(option); + } if(strstr(option,"tim")){ gBenchmark->Stop("PHOSDigitizer"); @@ -378,47 +379,47 @@ void AliPHOSDigitizer::MixWith(const char* headerFile) return ; } } - Int_t nevent = (Int_t)((TTree*)file->Get("TE"))->GetEntries() ; - Int_t ievent ; - for (ievent = 0; ievent < nevent; ievent++) { - TString tsname("TreeS") ; - tsname += ievent ; - TTree * ts = (TTree*)file->Get(tsname.Data()) ; - if ( !ts ) { - cerr << "ERROR: AliPHOSDigitizer::MixWith -> TreeS0 " << " does not exist in " << headerFile << endl ; - return ; - } + + // Read the first event with SDigits from the file-to-mix and post it to SDigits folder + + Int_t ievent =0 ; + TString tsname("TreeS") ; + tsname += ievent ; + TTree * ts = (TTree*)file->Get(tsname.Data()) ; + if ( !ts ) { + cerr << "ERROR: AliPHOSDigitizer::MixWith -> TreeS0 " << " does not exist in " << headerFile << endl ; + return ; + } - TObjArray * lob = (TObjArray*)ts->GetListOfBranches() ; - TIter next(lob) ; - TBranch * branch = 0 ; - TBranch * sdigitsbranch = 0 ; - TBranch * sdigitizerbranch = 0 ; - Bool_t phosfound = kFALSE, sdigitizerfound = kFALSE ; + TObjArray * lob = (TObjArray*)ts->GetListOfBranches() ; + TIter next(lob) ; + TBranch * branch = 0 ; + TBranch * sdigitsbranch = 0 ; + TBranch * sdigitizerbranch = 0 ; + Bool_t phosfound = kFALSE, sdigitizerfound = kFALSE ; - while ( (branch = (TBranch*)next()) && (!phosfound || !sdigitizerfound) ) { - if ( (strcmp(branch->GetName(), "PHOS")==0) && (strcmp(branch->GetTitle(), sDigitsTitle)==0) ) { - sdigitsbranch = branch ; - phosfound = kTRUE ; - } - else if ( (strcmp(branch->GetName(), "AliPHOSSDigitizer")==0) && (strcmp(branch->GetTitle(), sDigitsTitle)==0) ) { - sdigitizerbranch = branch ; - sdigitizerfound = kTRUE ; - } + while ( (branch = (TBranch*)next()) && (!phosfound || !sdigitizerfound) ) { + if ( (strcmp(branch->GetName(), "PHOS")==0) && (strcmp(branch->GetTitle(), sDigitsTitle)==0) ) { + sdigitsbranch = branch ; + phosfound = kTRUE ; } + else if ( (strcmp(branch->GetName(), "AliPHOSSDigitizer")==0) && (strcmp(branch->GetTitle(), sDigitsTitle)==0) ) { + sdigitizerbranch = branch ; + sdigitizerfound = kTRUE ; + } + } - if ( !phosfound || !sdigitizerfound ) { - cerr << "WARNING: AliPHOSDigitizer::MixWith -> Cannot find SDigits and/or SDigitizer with name " << sDigitsTitle << endl ; - return ; - } + if ( !phosfound || !sdigitizerfound ) { + cerr << "WARNING: AliPHOSDigitizer::MixWith -> Cannot find SDigits and/or SDigitizer with name " << sDigitsTitle << endl ; + return ; + } - // post the new SDigits to the White Board - AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; - gime->Post(headerFile, "S", sDigitsTitle, ievent ) ; - TClonesArray * sdigits = gime->SDigits(sDigitsTitle, headerFile) ; - sdigitsbranch->SetAddress(&sdigits) ; - sdigitsbranch->GetEvent(0) ; - } + // post the new SDigits to the White Board + AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; + gime->Post(headerFile, "S", sDigitsTitle) ; + TClonesArray * sdigits = gime->SDigits(sDigitsTitle, headerFile) ; + sdigitsbranch->SetAddress(&sdigits) ; + sdigitsbranch->GetEvent(0) ; } //__________________________________________________________________ @@ -461,7 +462,7 @@ void AliPHOSDigitizer::PrintDigits(Option_t * option){ AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; TClonesArray * digits = gime->Digits() ; - cout << "AliPHOSDigitiser:"<< endl ; + cout << "AliPHOSDigitiser: event " << gAlice->GetEvNumber() << endl ; cout << " Number of entries in Digits list " << digits->GetEntriesFast() << endl ; cout << endl ; if(strstr(option,"all")){ @@ -503,58 +504,74 @@ Bool_t AliPHOSDigitizer::ReadSDigits(Int_t event) AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; - TFile * file = (TFile*)gROOT->GetFile(GetTitle()); - file->cd() ; + // loop over all opened files and read their SDigits to the White Board + TCollection * folderslist = ((TFolder*)gROOT->FindObjectAny("YSAlice/WhiteBoard/SDigits/PHOS"))->GetListOfFolders() ; + TIter next(folderslist) ; + TFolder * folder = 0 ; + TClonesArray * sdigits = 0 ; + while ( (folder = (TFolder*)next()) ) { + TFile * file = (TFile*)gROOT->GetFile(folder->GetName()); + file->cd() ; -// Get SDigits Tree header from file - TString treeName("TreeS") ; - treeName += event ; - TTree * treeS = (TTree*)file->Get(treeName.Data()); - - if(treeS==0){ - cerr << "ERROR: AliPHOSDigitizer::ReadSDigits There is no SDigit Tree" << endl; - return kFALSE; - } + // Get SDigits Tree header from file + TString treeName("TreeS") ; + treeName += event ; + TTree * treeS = (TTree*)file->Get(treeName.Data()); + + if(treeS==0){ + cerr << "ERROR: AliPHOSDigitizer::ReadSDigits There is no SDigit Tree" << endl; + return kFALSE; + } - //set address of the SDigits and SDigitizer - TBranch * sdigitsBranch = 0; - TBranch * sdigitizerBranch = 0; - TObjArray * lob = (TObjArray*)gAlice->TreeS()->GetListOfBranches() ; - TIter next(lob) ; - TBranch * branch = 0 ; - Bool_t phosfound = kFALSE, sdigitizerfound = kFALSE ; - - while ( (branch = (TBranch*)next()) && (!phosfound || !sdigitizerfound) ) { - if ( (strcmp(branch->GetName(), "PHOS")==0) && (strcmp(branch->GetTitle(), GetName())==0) ) { - phosfound = kTRUE ; - sdigitsBranch = branch ; + //set address of the SDigits and SDigitizer + TBranch * sdigitsBranch = 0; + TBranch * sdigitizerBranch = 0; + TBranch * branch = 0 ; + TObjArray * lob = (TObjArray*)treeS->GetListOfBranches() ; + TIter next(lob) ; + Bool_t phosfound = kFALSE, sdigitizerfound = kFALSE ; + + while ( (branch = (TBranch*)next()) && (!phosfound || !sdigitizerfound) ) { + if ( (strcmp(branch->GetName(), "PHOS")==0) && (strcmp(branch->GetTitle(), GetName())==0) ) { + phosfound = kTRUE ; + sdigitsBranch = branch ; + } + + else if ( (strcmp(branch->GetName(), "AliPHOSSDigitizer")==0) && (strcmp(branch->GetTitle(), GetName())==0) ) { + sdigitizerfound = kTRUE ; + sdigitizerBranch = branch ; + } } + if ( !phosfound || !sdigitizerfound ) { + cerr << "WARNING: AliPHOSDigitizer::ReadSDigits -> Digits and/or Digitizer branch with name " << GetName() + << " not found" << endl ; + return kFALSE ; + } - else if ( (strcmp(branch->GetName(), "AliPHOSSDigitizer")==0) && (strcmp(branch->GetTitle(), GetName())==0) ) { - sdigitizerfound = kTRUE ; - sdigitizerBranch = branch ; + + if ( (sdigits = (TClonesArray*)folder->FindObject(GetName()) ) ) { + sdigitsBranch->SetAddress(&sdigits) ; + sdigits->Clear(); + + AliPHOSSDigitizer * sdigitizer = gime->SDigitizer() ; + sdigitizerBranch->SetAddress(&sdigitizer) ; + + sdigitsBranch->GetEntry(0) ; + sdigitizerBranch->GetEntry(0) ; + + fPedestal = sdigitizer->GetPedestalParameter() ; + fSlope = sdigitizer->GetCalibrationParameter() ; } - } - if ( !phosfound || !sdigitizerfound ) { - cerr << "WARNING: AliPHOSDigitizer::ReadSDigits -> Digits and/or Digitizer branch with name " << GetName() - << " not found" << endl ; - return kFALSE ; - } - - - TClonesArray * sdigits = gime->SDigits() ; - sdigitsBranch->SetAddress(&sdigits) ; - - AliPHOSSDigitizer * sdigitizer = gime->SDigitizer() ; - sdigitizerBranch->SetAddress(&sdigitizer) ; + } - sdigitsBranch->GetEntry(0) ; - sdigitizerBranch->GetEntry(0) ; - - fPedestal = sdigitizer->GetPedestalParameter() ; - fSlope = sdigitizer->GetCalibrationParameter() ; - - return kTRUE ; + // After SDigits have been read from all files, return to the first one + + next.Reset(); + folder = (TFolder*)next(); + TFile * file = (TFile*)gROOT->GetFile(folder->GetName()); + file->cd() ; + + return kTRUE ; } @@ -587,8 +604,6 @@ void AliPHOSDigitizer::WriteDigits(Int_t event) AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; TClonesArray * digits = gime->Digits() ; - - gAlice->GetEvent(event) ; if(gAlice->TreeD()==0) gAlice->MakeTree("D") ; @@ -601,7 +616,6 @@ void AliPHOSDigitizer::WriteDigits(Int_t event) } TDirectory *cwd = gDirectory; - // -- create Digits branch Int_t bufferSize = 32000 ; TBranch * digitsBranch = gAlice->TreeD()->Branch("PHOS",&digits,bufferSize); @@ -638,5 +652,3 @@ void AliPHOSDigitizer::WriteDigits(Int_t event) gAlice->TreeD()->Write(0,kOverwrite) ; } - -