From 106fc2fa65fb6014bb8e5b9af304ed87154048d3 Mon Sep 17 00:00:00 2001 From: schutz Date: Wed, 29 May 2002 07:00:24 +0000 Subject: [PATCH] Added SetSplitFile method that initialises things to divert SDigits un a file different from the hits file. --- EMCAL/AliEMCALSDigitizer.cxx | 187 ++++++++++++++++++----------------- EMCAL/AliEMCALSDigitizer.h | 3 +- PHOS/AliPHOSSDigitizer.cxx | 78 ++++++++------- PHOS/AliPHOSSDigitizer.h | 14 +-- 4 files changed, 149 insertions(+), 133 deletions(-) diff --git a/EMCAL/AliEMCALSDigitizer.cxx b/EMCAL/AliEMCALSDigitizer.cxx index 032323db000..8dd3962d9a8 100644 --- a/EMCAL/AliEMCALSDigitizer.cxx +++ b/EMCAL/AliEMCALSDigitizer.cxx @@ -53,12 +53,14 @@ #include "TSystem.h" #include "TROOT.h" #include "TFolder.h" +#include "TGeometry.h" #include "TBenchmark.h" // --- Standard library --- #include // --- AliRoot header files --- #include "AliRun.h" +#include "AliHeader.h" #include "AliEMCALDigit.h" #include "AliEMCALHit.h" #include "AliEMCALSDigitizer.h" @@ -242,111 +244,84 @@ void AliEMCALSDigitizer::Exec(Option_t *option) { sdigits->Sort() ; nSdigits = sdigits->GetEntriesFast() ; - sdigits->Expand(nSdigits) ; - - // Int_t i ; - const AliEMCALGeometry * geom = gime->EMCALGeometry() ; - - Int_t lastPreShowerIndex = nSdigits - 1 ; - if (!(dynamic_cast(sdigits->At(lastPreShowerIndex))->IsInPreShower())) - lastPreShowerIndex = -2; - Int_t firstPreShowerIndex = 100000 ; - Int_t index ; - AliEMCALDigit * sdigit = 0 ; - for ( index = 0; index < nSdigits ; index++) { - sdigit = dynamic_cast(sdigits->At(index) ) ; - if (sdigit->IsInPreShower() ){ - firstPreShowerIndex = index ; - break ; - } - } - - AliEMCALDigit * preshower ; - AliEMCALDigit * tower ; - Int_t lastIndex = lastPreShowerIndex +1 ; - - - for (index = firstPreShowerIndex ; index <= lastPreShowerIndex; index++) { - preshower = dynamic_cast(sdigits->At(index) ); - Bool_t towerFound = kFALSE ; - Int_t jndex ; - for (jndex = 0; jndex < firstPreShowerIndex; jndex++) { - tower = dynamic_cast(sdigits->At(jndex) ); - if ( (preshower->GetId() - (geom->GetNZ() * geom->GetNPhi()) ) == tower->GetId() ) { - Float_t towerEnergy = static_cast(tower->GetAmp()) ; - Float_t preshoEnergy = static_cast(preshower->GetAmp()) ; - towerEnergy +=preshoEnergy ; - *tower = *tower + *preshower ; // and add preshower multiplied by layer ratio to tower - tower->SetAmp(static_cast(TMath::Ceil(towerEnergy))) ; - towerFound = kTRUE ; + if (nSdigits > 0) { + sdigits->Expand(nSdigits) ; + + // Int_t i ; + const AliEMCALGeometry * geom = gime->EMCALGeometry() ; + + Int_t lastPreShowerIndex = nSdigits - 1 ; + if (!(dynamic_cast(sdigits->At(lastPreShowerIndex))->IsInPreShower())) + lastPreShowerIndex = -2; + Int_t firstPreShowerIndex = 100000 ; + Int_t index ; + AliEMCALDigit * sdigit = 0 ; + for ( index = 0; index < nSdigits ; index++) { + sdigit = dynamic_cast(sdigits->At(index) ) ; + if (sdigit->IsInPreShower() ){ + firstPreShowerIndex = index ; + break ; + } + } + + AliEMCALDigit * preshower ; + AliEMCALDigit * tower ; + Int_t lastIndex = lastPreShowerIndex +1 ; + + + for (index = firstPreShowerIndex ; index <= lastPreShowerIndex; index++) { + preshower = dynamic_cast(sdigits->At(index) ); + Bool_t towerFound = kFALSE ; + Int_t jndex ; + for (jndex = 0; jndex < firstPreShowerIndex; jndex++) { + tower = dynamic_cast(sdigits->At(jndex) ); + if ( (preshower->GetId() - (geom->GetNZ() * geom->GetNPhi()) ) == tower->GetId() ) { + Float_t towerEnergy = static_cast(tower->GetAmp()) ; + Float_t preshoEnergy = static_cast(preshower->GetAmp()) ; + towerEnergy +=preshoEnergy ; + *tower = *tower + *preshower ; // and add preshower multiplied by layer ratio to tower + tower->SetAmp(static_cast(TMath::Ceil(towerEnergy))) ; + towerFound = kTRUE ; + } + } + if ( !towerFound ) { + + new((*sdigits)[lastIndex]) AliEMCALDigit(*preshower); + AliEMCALDigit * temp = dynamic_cast(sdigits->At(lastIndex)) ; + temp->SetId(temp->GetId() - (geom->GetNZ() * geom->GetNPhi()) ) ; + lastIndex++ ; + } + } + + sdigits->Sort() ; + Int_t NPrimarymax = -1 ; + for (i = 0 ; i < sdigits->GetEntriesFast() ; i++) { + sdigit = dynamic_cast(sdigits->At(i)) ; + sdigit->SetIndexInList(i) ; + } + + for (i = 0 ; i < sdigits->GetEntriesFast() ; i++) { + if (((dynamic_cast(sdigits->At(i)))->GetNprimary()) > NPrimarymax) + NPrimarymax = ((dynamic_cast(sdigits->At(i)))->GetNprimary()) ; } } - if ( !towerFound ) { - - new((*sdigits)[lastIndex]) AliEMCALDigit(*preshower); - AliEMCALDigit * temp = dynamic_cast(sdigits->At(lastIndex)) ; - temp->SetId(temp->GetId() - (geom->GetNZ() * geom->GetNPhi()) ) ; - lastIndex++ ; - } - } - - sdigits->Sort() ; - Int_t NPrimarymax = -1 ; - for (i = 0 ; i < sdigits->GetEntriesFast() ; i++) { - sdigit = dynamic_cast(sdigits->At(i)) ; - sdigit->SetIndexInList(i) ; - } - - for (i = 0 ; i < sdigits->GetEntriesFast() ; i++) { - if (((dynamic_cast(sdigits->At(i)))->GetNprimary()) > NPrimarymax) - NPrimarymax = ((dynamic_cast(sdigits->At(i)))->GetNprimary()) ; - } - if(gAlice->TreeS() == 0) + if(gAlice->TreeS() == 0) gAlice->MakeTree("S") ; - //Make (if necessary) branches - char * file =0; - if(gSystem->Getenv("CONFIG_SPLIT_FILE")){ //generating file name - file = new char[strlen(gAlice->GetBaseFile())+20] ; - sprintf(file,"%s/EMCAL.SDigits.root",gAlice->GetBaseFile()) ; - } - - TDirectory *cwd = gDirectory; - //First list of sdigits Int_t bufferSize = 32000 ; TBranch * sdigitsBranch = gAlice->TreeS()->Branch("EMCAL",&sdigits,bufferSize); sdigitsBranch->SetTitle(sdname); - if (file) { - sdigitsBranch->SetFile(file); - TIter next( sdigitsBranch->GetListOfBranches()); - TBranch * subbr; - while ((subbr=(TBranch*)next())) { - subbr->SetFile(file); - } - cwd->cd(); - } - //second - SDigitizer Int_t splitlevel = 0 ; AliEMCALSDigitizer * sd = this ; TBranch * sdigitizerBranch = gAlice->TreeS()->Branch("AliEMCALSDigitizer","AliEMCALSDigitizer", &sd,bufferSize,splitlevel); sdigitizerBranch->SetTitle(sdname); - if (file) { - sdigitizerBranch->SetFile(file); - TIter next( sdigitizerBranch->GetListOfBranches()); - TBranch * subbr ; - while ((subbr=(TBranch*)next())) { - subbr->SetFile(file); - } - cwd->cd(); - delete file; - } gAlice->TreeS()->Fill() ; - gAlice->TreeS()->Write(0,TObject::kOverwrite) ; + gAlice->TreeS()->AutoSave() ; if(strstr(option,"deb")) PrintSDigits(option) ; @@ -392,6 +367,42 @@ void AliEMCALSDigitizer::SetSDigitsBranch(const char * title ){ } + +//__________________________________________________________________ +void AliEMCALSDigitizer::SetSplitFile(const TString splitFileName) const +{ + // Diverts the SDigits in a file separate from the hits file + + TDirectory * cwd = gDirectory ; + TFile * splitFile = gAlice->InitTreeFile("S",splitFileName.Data()); + splitFile->cd() ; + gAlice->Write(); + + TTree *treeE = gAlice->TreeE(); + if (!treeE) { + cerr<<"No TreeE found "<SetBranchAddress("Header", &header); + treeE->SetBranchStatus("*",1); + TTree *treeENew = treeE->CloneTree(); + treeENew->Write(); + + // copy AliceGeom + TGeometry *AliceGeom = static_cast(cwd->Get("AliceGeom")); + if (!AliceGeom) { + cerr<<"AliceGeom was not found in the input file "<Write(); + cwd->cd() ; + gAlice->MakeTree("S",splitFile); + cout << "INFO: AliEMCALSDigitizer::SetSPlitMode -> SDigits will be stored in " << splitFileName.Data() << endl ; +} + //__________________________________________________________________ void AliEMCALSDigitizer::Print(Option_t* option)const{ cout << "------------------- "<< GetName() << " -------------" << endl ; diff --git a/EMCAL/AliEMCALSDigitizer.h b/EMCAL/AliEMCALSDigitizer.h index 7d1bb60e724..daaaf4f6c31 100644 --- a/EMCAL/AliEMCALSDigitizer.h +++ b/EMCAL/AliEMCALSDigitizer.h @@ -36,7 +36,7 @@ public: Float_t GetPedestalParameter()const {return fA;} Float_t GetCalibrationParameter()const{return fB;} char * GetSDigitsBranch()const{return (char*) fSDigitsTitle.Data();} - + void SetSplitFile(const TString splitFileName = "EMCAL.SDigits.root" ) const ; virtual void Print(Option_t* option) const ; void SetPedestalParameter(Float_t A){fA = A ;} @@ -52,6 +52,7 @@ private: void Init() ; void PrintSDigits(Option_t * option) ; Int_t Layer2TowerID(Int_t,Bool_t) ; + private: Float_t fA ; //Pedestal parameter Float_t fB ; //Slope Digitizition parameters diff --git a/PHOS/AliPHOSSDigitizer.cxx b/PHOS/AliPHOSSDigitizer.cxx index 99cf7158cf0..8616449e2e3 100644 --- a/PHOS/AliPHOSSDigitizer.cxx +++ b/PHOS/AliPHOSSDigitizer.cxx @@ -57,11 +57,14 @@ #include "TROOT.h" #include "TFolder.h" #include "TBenchmark.h" +#include "TGeometry.h" + // --- Standard library --- #include // --- AliRoot header files --- #include "AliRun.h" +#include "AliHeader.h" #include "AliPHOSDigit.h" #include "AliPHOSGeometry.h" #include "AliPHOSGetter.h" @@ -89,7 +92,7 @@ AliPHOSSDigitizer::AliPHOSSDigitizer(const char * headerFile, const char * sDigi fA = 0; fB = 10000000.; fPrimThreshold = 0.01 ; - fSDigitsInRun = 0 ; + fSDigitsInRun = 0 ; Init(); } @@ -120,7 +123,6 @@ void AliPHOSSDigitizer::Init() sdname.Append(GetTitle() ) ; SetName(sdname) ; gime->PostSDigitizer(this) ; - } //____________________________________________________________________________ @@ -212,32 +214,14 @@ void AliPHOSSDigitizer::Exec(Option_t *option) AliPHOSDigit * digit = dynamic_cast(sdigits->At(i)) ; digit->SetIndexInList(i) ; } - - if(gAlice->TreeS() == 0) - gAlice->MakeTree("S") ; - - //Make (if necessary) branches - char * file =0; - if(gSystem->Getenv("CONFIG_SPLIT_FILE")){ //generating file name - file = new char[strlen(gAlice->GetBaseFile())+20] ; - sprintf(file,"%s/PHOS.SDigits.root",gAlice->GetBaseFile()) ; - } - - TDirectory *cwd = gDirectory; + if(gAlice->TreeS() == 0) + gAlice->MakeTree("S") ; + //First list of sdigits Int_t bufferSize = 32000 ; TBranch * sdigitsBranch = gAlice->TreeS()->Branch("PHOS",&sdigits,bufferSize); sdigitsBranch->SetTitle(sdname); - if (file) { - sdigitsBranch->SetFile(file); - TIter next( sdigitsBranch->GetListOfBranches()); - TBranch * subbr; - while ((subbr=static_cast(next()))) { - subbr->SetFile(file); - } - cwd->cd(); - } //Next - SDigitizer Int_t splitlevel = 0 ; @@ -245,18 +229,8 @@ void AliPHOSSDigitizer::Exec(Option_t *option) TBranch * sdigitizerBranch = gAlice->TreeS()->Branch("AliPHOSSDigitizer","AliPHOSSDigitizer", &sd,bufferSize,splitlevel); sdigitizerBranch->SetTitle(sdname); - if (file) { - sdigitizerBranch->SetFile(file); - TIter next( sdigitizerBranch->GetListOfBranches()); - TBranch * subbr ; - while ((subbr=static_cast(next()))) { - subbr->SetFile(file); - } - cwd->cd(); - delete [] file; - } - sdigitsBranch->Fill() ; + gAlice->TreeS()->AutoSave() ; if(strstr(option,"deb")) @@ -274,6 +248,7 @@ void AliPHOSSDigitizer::Exec(Option_t *option) } + //__________________________________________________________________ void AliPHOSSDigitizer::SetSDigitsBranch(const char * title ) { @@ -302,6 +277,41 @@ void AliPHOSSDigitizer::SetSDigitsBranch(const char * title ) gime->PostSDigits( title, GetTitle()) ; } +//__________________________________________________________________ +void AliPHOSSDigitizer::SetSplitFile(const TString splitFileName) const +{ + // Diverts the SDigits in a file separate from the hits file + + TDirectory * cwd = gDirectory ; + TFile * splitFile = gAlice->InitTreeFile("S",splitFileName.Data()); + splitFile->cd() ; + gAlice->Write(); + + TTree *treeE = gAlice->TreeE(); + if (!treeE) { + cerr<<"No TreeE found "<SetBranchAddress("Header", &header); + treeE->SetBranchStatus("*",1); + TTree *treeENew = treeE->CloneTree(); + treeENew->Write(); + + // copy AliceGeom + TGeometry *AliceGeom = static_cast(cwd->Get("AliceGeom")); + if (!AliceGeom) { + cerr<<"AliceGeom was not found in the input file "<Write(); + cwd->cd() ; + gAlice->MakeTree("S",splitFile); + cout << "INFO: AliPHOSSDigitizer::SetSPlitMode -> SDigits will be stored in " << splitFileName.Data() << endl ; +} + //__________________________________________________________________ void AliPHOSSDigitizer::Print(Option_t* option)const { diff --git a/PHOS/AliPHOSSDigitizer.h b/PHOS/AliPHOSSDigitizer.h index 77ab00fbfaf..5dd854ff639 100644 --- a/PHOS/AliPHOSSDigitizer.h +++ b/PHOS/AliPHOSSDigitizer.h @@ -29,19 +29,14 @@ public: Float_t Calibrate(Int_t amp)const {return (amp - fA)/fB ; } Int_t Digitize(Float_t Energy)const { return (Int_t ) ( fA + Energy*fB); } - virtual void Exec(Option_t *option); - const char * GetSDigitsBranch()const{return GetName();} const Int_t GetSDigitsInRun() const {return fSDigitsInRun ;} - virtual void Print(Option_t* option) const ; - - void SetSDigitsBranch(const char * title ) ; - - void UseHitsFrom(const char * filename) ; - - Bool_t operator == (const AliPHOSSDigitizer & sd) const ; + void SetSDigitsBranch(const char * title ) ; + void SetSplitFile(const TString splitFileName = "PHOS.SDigits.root") const ; + void UseHitsFrom(const char * filename) ; + Bool_t operator == (const AliPHOSSDigitizer & sd) const ; private: void Init() ; @@ -54,7 +49,6 @@ private: Float_t fPrimThreshold ; // To store primari if Elos > threshold Int_t fSDigitsInRun ; //! Total number of sdigits in one run - ClassDef(AliPHOSSDigitizer,1) // description }; -- 2.39.3