* provided "as is" without express or implied warranty. *
**************************************************************************/
+
/* $Id$ */
//_________________________________________________________________________
//____________________________________________________________________________
- AliPHOSSDigitizer::AliPHOSSDigitizer():TTask("","")
-{
+ AliPHOSSDigitizer::AliPHOSSDigitizer():TTask("","") {
// ctor
- fA = 0;
- fB = 10000000.;
- fPrimThreshold = 0.01 ;
- fSDigitsInRun = 0 ;
+ InitParameters() ;
+ fDefaultInit = kTRUE ;
}
//____________________________________________________________________________
AliPHOSSDigitizer::AliPHOSSDigitizer(const char * headerFile, const char * sDigitsTitle):TTask(sDigitsTitle, headerFile)
{
// ctor
- fA = 0;
- fB = 10000000.;
- fPrimThreshold = 0.01 ;
- fSDigitsInRun = 0 ;
+ InitParameters() ;
Init();
+ fDefaultInit = kFALSE ;
}
+//____________________________________________________________________________
+AliPHOSSDigitizer::~AliPHOSSDigitizer()
+{
+ // dtor
+ // fDefaultInit = kTRUE if SDigitizer created by default ctor (to get just the parameters)
+
+
+ if (!fDefaultInit) {
+ AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
+
+ // remove the task from the folder list
+ gime->RemoveTask("S",GetName()) ;
+
+ TString name(GetName()) ;
+ if (! name.IsNull() )
+ name.Remove(name.Index(":")) ;
+
+ // remove the Hits from the folder list
+ gime->RemoveObjects("H",name) ;
+
+ // remove the SDigits from the folder list
+ gime->RemoveObjects("S", name) ;
+
+ // Delete gAlice
+ gime->CloseFile() ;
+
+ }
+ fSplitFile = 0 ;
+}
//____________________________________________________________________________
void AliPHOSSDigitizer::Init()
if( strcmp(GetTitle(), "") == 0 )
SetTitle("galice.root") ;
-
+
AliPHOSGetter * gime = AliPHOSGetter::GetInstance(GetTitle(), GetName()) ;
if ( gime == 0 ) {
cerr << "ERROR: AliPHOSSDigitizer::Init -> Could not obtain the Getter object !" << endl ;
gime->PostSDigitizer(this) ;
}
+//____________________________________________________________________________
+void AliPHOSSDigitizer::InitParameters()
+{
+ fA = 0;
+ fB = 10000000.;
+ fPrimThreshold = 0.01 ;
+ fSDigitsInRun = 0 ;
+ fSplitFile = 0 ;
+}
+
//____________________________________________________________________________
void AliPHOSSDigitizer::Exec(Option_t *option)
{
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
-//******************** CHECK HERE
-//YS DOES NOT UNDERSTAND THE NEED FOR THE FOLLOWING LOOP
-// Int_t itrack ;
-// for (itrack=0; itrack < gAlice->GetNtrack(); itrack++){
-// //=========== Get the PHOS branch from Hits Tree for the Primary track itrack
-// gime->Track(itrack) ;
+ 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;
+ for (iprim=0; iprim<Nprim; iprim++) {
+ //=========== Get the PHOS branch from Hits Tree for the Primary iprim
+ gime->Track(iprim) ;
Int_t i;
for ( i = 0 ; i < hits->GetEntries() ; i++ ) {
AliPHOSHit * hit = dynamic_cast<AliPHOSHit *>(hits->At(i)) ;
nSdigits++ ;
}
-// } // loop over tracks
+
+ } // loop over iprim
sdigits->Sort() ;
nSdigits = sdigits->GetEntriesFast() ;
fSDigitsInRun += nSdigits ;
sdigits->Expand(nSdigits) ;
-// Int_t i ;
+
+ Int_t i ;
for (i = 0 ; i < nSdigits ; i++) {
AliPHOSDigit * digit = dynamic_cast<AliPHOSDigit *>(sdigits->At(i)) ;
digit->SetIndexInList(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(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() ;
+ gAlice->Write(0, TObject::kOverwrite);
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();
+ AliHeader *header = new AliHeader();
+ treeE->SetBranchAddress("Header", &header);
+ treeE->SetBranchStatus("*",1);
+ TTree *treeENew = treeE->CloneTree();
+ treeENew->Write(0, TObject::kOverwrite);
+
// copy AliceGeom
- TGeometry *AliceGeom = static_cast<TGeometry*>(cwd->Get("AliceGeom"));
- if (!AliceGeom) {
- cerr<<"AliceGeom was not found in the input file "<<endl;
- abort() ;
- }
- AliceGeom->Write();
+ 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(0, TObject::kOverwrite);
+
+ gAlice->MakeTree("S",fSplitFile);
cwd->cd() ;
- gAlice->MakeTree("S",splitFile);
cout << "INFO: AliPHOSSDigitizer::SetSPlitMode -> SDigits will be stored in " << splitFileName.Data() << endl ;
+
}
//__________________________________________________________________