* provided "as is" without express or implied warranty. *
**************************************************************************/
+
/* $Id$ */
//_________________________________________________________________________
fB = 10000000.;
fPrimThreshold = 0.01 ;
fSDigitsInRun = 0 ;
+ fSplitFile = 0 ;
}
//____________________________________________________________________________
fB = 10000000.;
fPrimThreshold = 0.01 ;
fSDigitsInRun = 0 ;
+ fSplitFile = 0 ;
Init();
}
+//____________________________________________________________________________
+AliPHOSSDigitizer::~AliPHOSSDigitizer()
+{
+ if (fSplitFile)
+ if ( fSplitFile->IsOpen() )
+ fSplitFile->Close() ;
+}
//____________________________________________________________________________
void AliPHOSSDigitizer::Init()
Bool_t phosfound = kFALSE, sdigitizerfound = kFALSE ;
while ( (branch = (static_cast<TBranch*>(next()))) && (!phosfound || !sdigitizerfound) ) {
- if ( (strcmp(branch->GetName(), "PHOS")==0) && (strcmp(branch->GetTitle(), GetName())==0) )
+ TString thisName( GetName() ) ;
+ TString branchName( branch->GetTitle() ) ;
+ branchName.Append(":") ;
+ if ( (strcmp(branch->GetName(), "PHOS")==0) && thisName.BeginsWith(branchName) )
phosfound = kTRUE ;
-
- else if ( (strcmp(branch->GetName(), "AliPHOSSDigitizer")==0) && (strcmp(branch->GetTitle(), GetName())==0) )
+ else if ( (strcmp(branch->GetName(), "AliPHOSSDigitizer")==0) && thisName.BeginsWith(branchName) )
sdigitizerfound = kTRUE ;
}
//Now make SDigits from hits, for PHOS it is the same, so just copy
+
Int_t Nprim = (Int_t) (gAlice->TreeH())->GetEntries();
// Attention Nprim is the number of primaries tracked by Geant and this number could be different to the number of Primaries in TreeK;
Int_t iprim;
nSdigits++ ;
}
+
} // loop over iprim
sdigits->Sort() ;
nSdigits = sdigits->GetEntriesFast() ;
fSDigitsInRun += nSdigits ;
sdigits->Expand(nSdigits) ;
+
Int_t i ;
for (i = 0 ; i < nSdigits ; i++) {
AliPHOSDigit * digit = dynamic_cast<AliPHOSDigit *>(sdigits->At(i)) ;
}
if(gAlice->TreeS() == 0)
- gAlice->MakeTree("S") ;
-
+ gAlice->MakeTree("S",fSplitFile);
+
//First list of sdigits
Int_t bufferSize = 32000 ;
TBranch * sdigitsBranch = gAlice->TreeS()->Branch("PHOS",&sdigits,bufferSize);
TBranch * sdigitizerBranch = gAlice->TreeS()->Branch("AliPHOSSDigitizer","AliPHOSSDigitizer",
&sd,bufferSize,splitlevel);
sdigitizerBranch->SetTitle(sdname);
+
sdigitsBranch->Fill() ;
-
+ sdigitizerBranch->Fill() ;
gAlice->TreeS()->AutoSave() ;
if(strstr(option,"deb"))
PrintSDigits(option) ;
-
+
}
+
+ if (fSplitFile)
+ if ( fSplitFile->IsOpen() )
+ fSplitFile->Close() ;
+
if(strstr(option,"tim")){
gBenchmark->Stop("PHOSSDigitizer");
cout << "AliPHOSSDigitizer:" << endl ;
}
//__________________________________________________________________
-void AliPHOSSDigitizer::SetSplitFile(const TString splitFileName) const
+void AliPHOSSDigitizer::SetSplitFile(const TString splitFileName)
{
// 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();
+
+ if ( !(gAlice->GetTreeSFileName() == splitFileName) ) {
+ if (gAlice->GetTreeSFile() )
+ gAlice->GetTreeSFile()->Close() ;
+ }
+
+ fSplitFile = gAlice->InitTreeFile("S",splitFileName.Data());
+ fSplitFile->cd() ;
+ if ( !fSplitFile->Get("gAlice") )
+ gAlice->Write();
TTree *treeE = gAlice->TreeE();
if (!treeE) {
- cerr<<"No TreeE found "<<endl;
+ cerr << "ERROR: AliPHOSSDigitizer::SetSPlitFile -> No TreeE found "<<endl;
abort() ;
}
// copy TreeE
- AliHeader *header = new AliHeader();
- treeE->SetBranchAddress("Header", &header);
- treeE->SetBranchStatus("*",1);
- TTree *treeENew = treeE->CloneTree();
- treeENew->Write();
-
+ if ( !fSplitFile->Get("TreeE") ) {
+ AliHeader *header = new AliHeader();
+ treeE->SetBranchAddress("Header", &header);
+ treeE->SetBranchStatus("*",1);
+ TTree *treeENew = treeE->CloneTree();
+ treeENew->Write();
+ }
+
// copy AliceGeom
- TGeometry *AliceGeom = static_cast<TGeometry*>(cwd->Get("AliceGeom"));
- if (!AliceGeom) {
- cerr<<"AliceGeom was not found in the input file "<<endl;
- abort() ;
+ if ( !fSplitFile->Get("AliceGeom") ) {
+ TGeometry *AliceGeom = static_cast<TGeometry*>(cwd->Get("AliceGeom"));
+ if (!AliceGeom) {
+ cerr << "ERROR: AliPHOSSDigitizer::SetSPlitFile -> AliceGeom was not found in the input file "<<endl;
+ abort() ;
+ }
+ AliceGeom->Write();
}
- AliceGeom->Write();
+
cwd->cd() ;
- gAlice->MakeTree("S",splitFile);
- cout << "INFO: AliPHOSSDigitizer::SetSPlitMode -> SDigits will be stored in " << splitFileName.Data() << endl ;
+ gAlice->MakeTree("S",fSplitFile);
+ cout << "INFO: AliPHOSSDigitizer::SetSPlitFile -> SDigits will be stored in " << splitFileName.Data() << endl ;
}
//__________________________________________________________________
// --- ROOT system ---
#include "TTask.h"
#include "TString.h"
+class TFile ;
+
// --- Standard library ---
// --- AliRoot header files ---
public:
AliPHOSSDigitizer() ; // ctor
AliPHOSSDigitizer(const char* HeaderFile,const char *SdigitsTitle = "Default") ;
- virtual ~AliPHOSSDigitizer(){} // dtor
+ virtual ~AliPHOSSDigitizer() ; // dtor
Float_t Calibrate(Int_t amp)const {return (amp - fA)/fB ; }
Int_t Digitize(Float_t Energy)const { return (Int_t ) ( fA + Energy*fB); }
const Int_t GetSDigitsInRun() const {return fSDigitsInRun ;}
virtual void Print(Option_t* option) const ;
void SetSDigitsBranch(const char * title ) ;
- void SetSplitFile(const TString splitFileName = "PHOS.SDigits.root") const ;
+ void SetSplitFile(const TString splitFileName = "PHOS.SDigits.root") ;
void UseHitsFrom(const char * filename) ;
Bool_t operator == (const AliPHOSSDigitizer & sd) const ;
Float_t fB ; // Slope Digitizition parameters
Float_t fPrimThreshold ; // To store primari if Elos > threshold
Int_t fSDigitsInRun ; //! Total number of sdigits in one run
+ TFile * fSplitFile ; //! file in which SDigits will eventually be stored
ClassDef(AliPHOSSDigitizer,1) // description