* provided "as is" without express or implied warranty. *
**************************************************************************/
-/* $Header$ */
+/* $Id$ */
-////////////////////////////////////////////////////////////////////////
+//_______________________________________________________________________
//
// AliRunDigitizer.cxx
//
// manager->SetNrOfEventsToWrite(1);
// manager->Exec("");
//
-////////////////////////////////////////////////////////////////////////
+//_______________________________________________________________________
// system includes
#include "AliDigitizer.h"
#include "AliMergeCombi.h"
+#include "AliRunLoader.h"
+#include "AliLoader.h"
#include "AliRun.h"
#include "AliRunDigitizer.h"
#include "AliStream.h"
+#include "AliHeader.h"
ClassImp(AliRunDigitizer)
+const TString AliRunDigitizer::fgkDefOutFolderName("Output");
+const TString AliRunDigitizer::fgkBaseInFolderName("Input");
+
+
//_______________________________________________________________________
AliRunDigitizer::AliRunDigitizer():
- fkMASKSTEP(0),
- fOutputFileName(0),
- fOutputDirName(0),
- fOutput(0),
- fEvent(0),
- fNrOfEventsToWrite(0),
- fNrOfEventsWritten(0),
- fCopyTreesFromInput(0),
- fTreeD(0),
- fTreeDTPC(0),
- fTreeDTRD(0),
- fTreeR(0),
- fNinputs(0),
- fNinputsGiven(0),
- fInputStreams(0),
- fTreeDTPCBaseName(0),
- fTreeTPCSBaseName(0),
- fCombi(0),
- fCombination(0),
- fCombinationFileName(0),
- fDebug(0)
+ fkMASKSTEP(0),
+ fOutputFileName(0),
+ fOutputDirName(0),
+ fEvent(0),
+ fNrOfEventsToWrite(0),
+ fNrOfEventsWritten(0),
+ fCopyTreesFromInput(0),
+ fNinputs(0),
+ fNinputsGiven(0),
+ fInputStreams(0x0),
+ fOutRunLoader(0x0),
+ fOutputInitialized(kFALSE),
+ fCombi(0),
+ fCombination(0),
+ fCombinationFileName(0),
+ fDebug(0)
{
- //
- // default ctor, where no new objects can be created
- // do not use this ctor, it is supplied only for root needs
- //
- for (Int_t i=0;i<kMaxStreamsToMerge;i++) {
- fArrayTreeS[i]=fArrayTreeH[i]=fArrayTreeTPCS[i]=fArrayTreeTRDS[i]=NULL;
- fInputFiles[i]=0;
- }
+// root requires default ctor, where no new objects can be created
+// do not use this ctor, it is supplied only for root needs
+
+// fOutputStream = 0x0;
}
//_______________________________________________________________________
+AliRunDigitizer::AliRunDigitizer(Int_t nInputStreams, Int_t sperb):
+ TTask("AliRunDigitizer","The manager for Merging"),
+ fkMASKSTEP(10000000),
+ fOutputFileName(""),
+ fOutputDirName("."),
+ fEvent(0),
+ fNrOfEventsToWrite(-1),
+ fNrOfEventsWritten(0),
+ fCopyTreesFromInput(-1),
+ fNinputs(nInputStreams),
+ fNinputsGiven(0),
+ fInputStreams(new TClonesArray("AliStream",nInputStreams)),
+ fOutRunLoader(0x0),
+ fOutputInitialized(kFALSE),
+ fCombi(new AliMergeCombi(nInputStreams,sperb)),
+ fCombination(kMaxStreamsToMerge),
+ fCombinationFileName(0),
+ fDebug(0)
+
+{
+// ctor which should be used to create a manager for merging/digitization
+ if (nInputStreams == 0)
+ {//kidding
+ Fatal("AliRunDigitizer","Specify nr of input streams");
+ return;
+ }
+ Int_t i;
+
+ fkMASK[0] = 0;
+
+ for (i=1;i<kMaxStreamsToMerge;i++)
+ {
+ fkMASK[i] = fkMASK[i-1] + fkMASKSTEP;
+ }
+
+ TClonesArray &lInputStreams = *fInputStreams;
+
+ for (i=0;i<nInputStreams;i++) {
+ new(lInputStreams[i]) AliStream(fgkBaseInFolderName+(Long_t)i,"READ");
+ }
+}
+//_______________________________________________________________________
+
AliRunDigitizer::AliRunDigitizer(const AliRunDigitizer& dig):
- TTask(dig),
- fkMASKSTEP(0),
- fOutputFileName(0),
- fOutputDirName(0),
- fOutput(0),
- fEvent(0),
- fNrOfEventsToWrite(0),
- fNrOfEventsWritten(0),
- fCopyTreesFromInput(0),
- fTreeD(0),
- fTreeDTPC(0),
- fTreeDTRD(0),
- fTreeR(0),
- fNinputs(0),
- fNinputsGiven(0),
- fInputStreams(0),
- fTreeDTPCBaseName(0),
- fTreeTPCSBaseName(0),
- fCombi(0),
- fCombination(0),
- fCombinationFileName(0),
- fDebug(0)
+ TTask(dig),
+ fkMASKSTEP(0),
+ fOutputFileName(0),
+ fOutputDirName(0),
+ fEvent(0),
+ fNrOfEventsToWrite(0),
+ fNrOfEventsWritten(0),
+ fCopyTreesFromInput(0),
+ fNinputs(0),
+ fNinputsGiven(0),
+ fInputStreams(0x0),
+ fOutRunLoader(0x0),
+ fOutputInitialized(kFALSE),
+ fCombi(0),
+ fCombination(0),
+ fCombinationFileName(0),
+ fDebug(0)
{
//
// Copy ctor
//
dig.Copy(*this);
}
-
//_______________________________________________________________________
+
void AliRunDigitizer::Copy(AliRunDigitizer&) const
{
Fatal("Copy","Not installed\n");
}
-
//_______________________________________________________________________
-AliRunDigitizer::AliRunDigitizer(Int_t nInputStreams, Int_t sperb):
- TTask("AliRunDigitizer","The manager for Merging"),
- fkMASKSTEP(10000000),
- fOutputFileName(""),
- fOutputDirName("."),
- fOutput(0),
- fEvent(0),
- fNrOfEventsToWrite(-1),
- fNrOfEventsWritten(0),
- fCopyTreesFromInput(-1),
- fTreeD(0),
- fTreeDTPC(0),
- fTreeDTRD(0),
- fTreeR(0),
- fNinputs(nInputStreams),
- fNinputsGiven(0),
- fInputStreams(new TClonesArray("AliStream",nInputStreams)),
- fTreeDTPCBaseName("TreeD_75x40_100x60_150x60_"),
- fTreeTPCSBaseName("TreeS_75x40_100x60_150x60_"),
- fCombi(new AliMergeCombi(nInputStreams,sperb)),
- fCombination(kMaxStreamsToMerge),
- fCombinationFileName(0),
- fDebug(0)
-{
- //
- // ctor which should be used to create a manager for merging/digitization
- //
- if (nInputStreams == 0) {
- Error("AliRunDigitizer","Specify nr of input streams");
- return;
- }
- for (Int_t i=0;i<kMaxStreamsToMerge;i++) {
- fArrayTreeS[i]=fArrayTreeH[i]=fArrayTreeTPCS[i]=fArrayTreeTRDS[i]=NULL;
- fCombination[i]=-1;
- }
- fkMASK[0] = 0;
- for (Int_t i=1;i<kMaxStreamsToMerge;i++) {
- fkMASK[i] = fkMASK[i-1] + fkMASKSTEP;
- }
-
- TClonesArray &lInputStreams = *fInputStreams;
-// the first Input is open RW to be output as well
- new(lInputStreams[0]) AliStream("UPDATE");
- for (Int_t i=1;i<nInputStreams;i++) {
- new(lInputStreams[i]) AliStream("READ");
- }
-
- for (Int_t i=0; i<kMaxStreamsToMerge; i++) fInputFiles[i]=0;
-}
-//_______________________________________________________________________
AliRunDigitizer::~AliRunDigitizer() {
// dtor
-
-// do not delete subtasks, let the creator delete them
if (GetListOfTasks())
GetListOfTasks()->Clear("nodelete");
-
- delete fInputStreams;
- delete fCombi;
+ delete fInputStreams;
+ delete fCombi;
+ delete fOutRunLoader;
}
-
//_______________________________________________________________________
void AliRunDigitizer::AddDigitizer(AliDigitizer *digitizer)
{
// add digitizer to the list of active digitizers
this->Add(digitizer);
}
-
//_______________________________________________________________________
-void AliRunDigitizer::SetInputStream(Int_t i, const char *inputFile)
+void AliRunDigitizer::SetInputStream(Int_t i, const char *inputFile, TString foldername)
{
- //
- // Sets the name of the input file
- //
+//
+// Sets the name of the input file
+//
if (i > fInputStreams->GetLast()) {
Error("SetInputStream","Input stream number too high");
return;
}
- static_cast<AliStream*>(fInputStreams->At(i))->AddFile(inputFile);
+ AliStream * stream = static_cast<AliStream*>(fInputStreams->At(i)) ;
+ if ( !foldername.IsNull() ) {
+ if ( i > 0 )
+ foldername += i ; // foldername should stay unchanged for the default output
+ stream->SetFolderName(foldername) ;
+ }
+ stream->AddFile(inputFile);
}
//_______________________________________________________________________
void AliRunDigitizer::Digitize(Option_t* option)
{
-// get a new combination of inputs, connect input trees and loop
-// over all digitizers
+// get a new combination of inputs, loads events to folders
// take gAlice from the first input file. It is needed to access
// geometry data
// If gAlice is already in memory, use it
- if (!gAlice) {
- if (!static_cast<AliStream*>(fInputStreams->At(0))->ImportgAlice()) {
- cerr<<"gAlice object not found in the first file of "
- <<"the 1st stream"<<endl;
- return;
- }
- }
- if (!InitGlobal()) {
- cerr<<"False from InitGlobal"<<endl;
- return;
- }
+ SetDebug(10);
+
+ if (gAlice == 0x0)
+ {
+ if (!static_cast<AliStream*>(fInputStreams->At(0))->ImportgAlice())
+ {
+ Error("Digitize","Error occured while getting gAlice from Input 0");
+ return;
+ }
+ }
+
+ if (!InitGlobal()) //calls Init() for all (sub)digitizers
+ {
+ Error("Digitize","InitGlobal returned error");
+ return;
+ }
+
Int_t eventsCreated = 0;
// loop until there is anything on the input in case fNrOfEventsToWrite < 0
- while ((eventsCreated++ < fNrOfEventsToWrite) || (fNrOfEventsToWrite < 0)) {
- if (!ConnectInputTrees()) break;
- InitEvent();
-// loop over all registered digitizers and let them do the work
- ExecuteTasks(option);
- CleanTasks();
- FinishEvent();
- }
+ while ((eventsCreated++ < fNrOfEventsToWrite) || (fNrOfEventsToWrite < 0))
+ {
+ if (!ConnectInputTrees()) break;
+ InitEvent();//this must be after call of Connect Input tress.
+ if (fOutRunLoader)
+ {
+ fOutRunLoader->SetEventNumber(eventsCreated-1);
+ }
+ static_cast<AliStream*>(fInputStreams->At(0))->ImportgAlice(); // use gAlice of the first input stream
+ ExecuteTasks(option);// loop over all registered digitizers and let them do the work
+ FinishEvent();
+ CleanTasks();
+ }
FinishGlobal();
}
//_______________________________________________________________________
Bool_t AliRunDigitizer::ConnectInputTrees()
{
-// fill arrays fArrayTreeS, fArrayTreeH and fArrayTreeTPCS with
-// pointers to the correct events according fCombination values
-// null pointers can be in the output, AliDigitizer has to check it
-
- TTree *tree;
- char treeName[50];
- Int_t serialNr;
+//loads events
Int_t eventNr[kMaxStreamsToMerge], delta[kMaxStreamsToMerge];
fCombi->Combination(eventNr, delta);
- for (Int_t i=0;i<fNinputs;i++) {
- if (delta[i] == 1) {
- AliStream *iStream = static_cast<AliStream*>(fInputStreams->At(i));
- if (!iStream->NextEventInStream(serialNr)) return kFALSE;
- fInputFiles[i]=iStream->CurrentFile();
- sprintf(treeName,"TreeS%d",serialNr);
- tree = static_cast<TTree*>(iStream->CurrentFile()->Get(treeName));
- if (fArrayTreeS[i]) {
- delete fArrayTreeS[i];
- fArrayTreeS[i] = 0;
- }
- fArrayTreeS[i] = tree;
- sprintf(treeName,"TreeH%d",serialNr);
- tree = static_cast<TTree*>(iStream->CurrentFile()->Get(treeName));
- if (fArrayTreeH[i]) {
- delete fArrayTreeH[i];
- fArrayTreeH[i] = 0;
- }
- fArrayTreeH[i] = tree;
- sprintf(treeName,"%s%d",fTreeTPCSBaseName,serialNr);
- tree = static_cast<TTree*>(iStream->CurrentFile()->Get(treeName));
- if (fArrayTreeTPCS[i]) {
- delete fArrayTreeTPCS[i];
- fArrayTreeTPCS[i] = 0;
- }
- fArrayTreeTPCS[i] = tree;
- sprintf(treeName,"TreeS%d_TRD",serialNr);
- tree = static_cast<TTree*>(iStream->CurrentFile()->Get(treeName));
- if (fArrayTreeTRDS[i]) {
- delete fArrayTreeTRDS[i];
- fArrayTreeTRDS[i] = 0;
- }
- fArrayTreeTRDS[i] = tree;
- } else if (delta[i] != 0) {
+ for (Int_t i=0;i<fNinputs;i++)
+ {
+ if (delta[i] == 1)
+ {
+ AliStream *iStream = static_cast<AliStream*>(fInputStreams->At(i));//gets the "i" defined in combination
+ if (!iStream->NextEventInStream()) return kFALSE; //sets serial number
+ }
+ else if (delta[i] != 0)
+ {
Error("ConnectInputTrees","Only delta 0 or 1 is implemented");
return kFALSE;
- }
- }
+ }
+ }
+
return kTRUE;
}
Bool_t AliRunDigitizer::InitGlobal()
{
// called once before Digitize() is called, initialize digitizers and output
-
- TList* subTasks = GetListOfTasks();
+ fOutputInitialized = kFALSE;
+ TList* subTasks = this->GetListOfTasks();
if (subTasks) {
- subTasks->ForEach(AliDigitizer,Init)();
- }
+ TIter next(subTasks);
+ while (AliDigitizer * dig = (AliDigitizer *) next())
+ dig->Init();
+ }
return kTRUE;
}
//_______________________________________________________________________
+
void AliRunDigitizer::SetOutputFile(TString fn)
{
- // the output will be to separate file, not to the signal file
+// the output will be to separate file, not to the signal file
+ //here should be protection to avoid setting the same file as any input
+ Info("SetOutputFile","Setting Output File Name %s ",fn.Data());
fOutputFileName = fn;
- (static_cast<AliStream*>(fInputStreams->At(0)))->ChangeMode("READ");
- InitOutputGlobal();
+// InitOutputGlobal();
}
//_______________________________________________________________________
Bool_t AliRunDigitizer::InitOutputGlobal()
{
// Creates the output file, called by InitEvent()
-
- TString fn;
- fn = fOutputDirName + '/' + fOutputFileName;
- fOutput = new TFile(fn,"update");
- if (GetDebug()>2) {
- cerr<<"AliRunDigitizer::InitOutputGlobal(): file "<<fn.Data()<<" was opened"<<endl;
- }
- if (fOutput) return kTRUE;
- Error("InitOutputGlobal","Could not create output file.");
- return kFALSE;
+//Needs to be called after all inputs are opened
+ if (fOutputInitialized) return kTRUE;
+
+ if ( !fOutputFileName.IsNull())
+ {
+ fOutRunLoader = AliRunLoader::Open(fOutputFileName,fgkDefOutFolderName,"recreate");
+
+ if (fOutRunLoader == 0x0)
+ {
+ Error("InitOutputGlobal","Can not open ooutput");
+ return kFALSE;
+ }
+ Info("InitOutputGlobal", " 1 %s = ", GetInputFolderName(0).Data()) ;
+ AliRunLoader* inrl = AliRunLoader::GetRunLoader(GetInputFolderName(0));
+ if (inrl == 0x0)
+ {
+ Error("InitOutputGlobal","Can not get Run Loader Input 0. Maybe yet not initialized?");
+ return kFALSE;
+ }
+ Info("InitOutputGlobal", " 2 %#x = ", inrl) ;
+
+ //Copy all detector loaders from input 0 to output
+ const TObjArray* inloaders = inrl->GetArrayOfLoaders();
+ TIter next(inloaders);
+ AliLoader *loader;
+ while((loader = (AliLoader*)next()))
+ {
+ AliLoader* cloneloader = (AliLoader*)loader->Clone();
+ cloneloader->Register(fOutRunLoader->GetEventFolder());//creates folders for this loader in Output Folder Structure
+ GetOutRunLoader()->AddLoader(cloneloader);//adds a loader for output
+ }
+
+ fOutRunLoader->MakeTree("E");
+
+ if (GetDebug()>2) Info("InitOutputGlobal","file %s was opened.",fOutputFileName.Data());
+ }
+ fOutputInitialized = kTRUE;
+ return kTRUE;
}
-
-
//_______________________________________________________________________
+
void AliRunDigitizer::InitEvent()
{
-// Creates TreeDxx in the output file, called from Digitize() once for
-// each event. xx = fEvent
-
- if (GetDebug()>2)
- cerr<<"AliRunDigitizer::InitEvent: fEvent = "<<fEvent<<endl;
-
-// if fOutputFileName was not given, write output to signal file
- if (fOutputFileName == "") {
- fOutput = (static_cast<AliStream*>(fInputStreams->At(0)))->CurrentFile();
- }
- fOutput->cd();
- char treeName[30];
- sprintf(treeName,"TreeD%d",fEvent);
- fTreeD = static_cast<TTree*>(fOutput->Get(treeName));
- if (!fTreeD) {
- fTreeD = new TTree(treeName,"Digits");
- fTreeD->Write(0,TObject::kOverwrite);
- }
-
-// tree for ITS fast points
- sprintf(treeName,"TreeR%d",fEvent);
- fTreeR = static_cast<TTree*>(fOutput->Get(treeName));
- if (!fTreeR) {
- fTreeR = new TTree(treeName,"Reconstruction");
- fTreeR->Write(0,TObject::kOverwrite);
- }
-
-// special tree for TPC
- sprintf(treeName,"%s%d",fTreeDTPCBaseName,fEvent);
- fTreeDTPC = static_cast<TTree*>(fOutput->Get(treeName));
- if (!fTreeDTPC) {
- fTreeDTPC = new TTree(treeName,"TPC_Digits");
- fTreeDTPC->Write(0,TObject::kOverwrite);
- }
-
-// special tree for TRD
- sprintf(treeName,"TreeD%d_TRD",fEvent);
- fTreeDTRD = static_cast<TTree*>(fOutput->Get(treeName));
- if (!fTreeDTRD) {
- fTreeDTRD = new TTree(treeName,"TRD_Digits");
- fTreeDTRD->Write(0,TObject::kOverwrite);
- }
-
+//redirects output properly
+ if (GetDebug()>2)
+ {
+ Info("InitEvent","fEvent = %d",fEvent);
+ Info("InitEvent","fOutputFileName \"%s\"",fOutputFileName.Data());
+ }
+ if (fOutputInitialized == kFALSE) InitOutputGlobal();
+
+// if fOutputFileName was not given, write output to signal directory
}
-
//_______________________________________________________________________
+
void AliRunDigitizer::FinishEvent()
{
// called at the end of loop over digitizers
- Int_t i;
- fOutput->cd();
- if (fCopyTreesFromInput > -1) {
- char treeName[20];
- i = fCopyTreesFromInput;
- sprintf(treeName,"TreeK%d",fCombination[i]);
- fInputFiles[i]->Get(treeName)->Clone()->Write();
- sprintf(treeName,"TreeH%d",fCombination[i]);
- fInputFiles[i]->Get(treeName)->Clone()->Write();
- }
+
+ if (GetOutRunLoader() == 0x0)
+ {
+ Error("FinishEvent","fOutRunLoader is null");
+ return;
+ }
+
fEvent++;
fNrOfEventsWritten++;
- if (fTreeD) {
- delete fTreeD;
- fTreeD = 0;
- }
- if (fTreeR) {
- delete fTreeR;
- fTreeR = 0;
- }
- if (fTreeDTPC) {
- delete fTreeDTPC;
- fTreeDTPC = 0;
- }
- if (fTreeDTRD) {
- delete fTreeDTRD;
- fTreeDTRD = 0;
- }
+
+ if (fOutRunLoader)
+ {
+ AliRunLoader* inrl = AliRunLoader::GetRunLoader(GetInputFolderName(0));
+ AliHeader* outheader = fOutRunLoader->GetHeader();
+ AliHeader* inheader = inrl->GetHeader();
+ if (inheader == 0x0)
+ {
+ inrl->LoadHeader();
+ inheader = inrl->GetHeader();
+ if (inheader == 0x0) Fatal("FinishEvent","Can not get header from input 0");
+ }
+
+ outheader->SetNprimary(inheader->GetNprimary());
+ outheader->SetNtrack(inheader->GetNtrack());
+ outheader->SetEvent(inheader->GetEvent());
+ outheader->SetEventNrInRun(inheader->GetEventNrInRun());
+ outheader->SetNvertex(inheader->GetNvertex());
+ fOutRunLoader->TreeE()->Fill();
+ }
+
+ if (fCopyTreesFromInput > -1)
+ {
+ //this is sensless since no information would be coherent in case of merging
+ //
+ cout<<"Copy trees from input: Copy or link files manually"<<endl;
+ return;
+ }
}
-
//_______________________________________________________________________
+
void AliRunDigitizer::FinishGlobal()
{
// called at the end of Exec
// save unique objects to the output file
- fOutput->cd();
- this->Write(0,TObject::kOverwrite);
- if (fCopyTreesFromInput > -1) {
- fInputFiles[fCopyTreesFromInput]->Get("TE")->Clone()->Write();
- gAlice->Write();
- }
- fOutput->Write();
+ if (GetOutRunLoader() == 0x0)
+ {
+ Error("FinishGlobal","Can not get RunLoader from Output Stream folder");
+ return;
+ }
+ TFile* file = TFile::Open(fOutputDirName + "/digitizer.root", "recreate");
+ this->Write();
+ file->Close();
+ delete file;
+ if (fOutRunLoader)
+ {
+ fOutRunLoader->WriteHeader("OVERWRITE");
+ fOutRunLoader->WriteRunLoader("OVERWRITE");
+ TFolder* outfolder = fOutRunLoader->GetEventFolder();
+ if (outfolder == 0x0)
+ {
+ Error("FinishEvent","Can not get Event Folder");
+ return;
+ }
+
+ AliRunLoader* inRN = AliRunLoader::GetRunLoader(GetInputFolderName(0));
+ outfolder->Add(inRN->GetAliRun());
+ fOutRunLoader->WriteAliRun("OVERWRITE");
+ }
+
+ if (fCopyTreesFromInput > -1)
+ {
+ //copy files manually
+ }
}
-
-
//_______________________________________________________________________
+
Int_t AliRunDigitizer::GetNParticles(Int_t event) const
{
// return number of particles in all input files for a given
}
return sum;
}
-
//_______________________________________________________________________
-Int_t AliRunDigitizer::GetNParticles(Int_t /* event */, Int_t /* input */) const
+
+Int_t AliRunDigitizer::GetNParticles(Int_t /*event*/, Int_t /*input*/) const
{
// return number of particles in input file input for a given
// event (as numbered in this input file)
return -1;
-/*
- TFile *file = ConnectInputFile(input);
- if (!file) {
- Error("GetNParticles","Cannot open input file");
- return -1;
- }
-
-// find the header and get Nprimaries and Nsecondaries
- TTree* tE = (TTree *)file->Get("TE") ;
- if (!tE) {
- Error("GetNParticles","input file does not contain TE");
- return -1;
- }
- AliHeader* header;
- header = 0;
- tE->SetBranchAddress("Header", &header);
- if (!tE->GetEntry(event)) {
- Error("GetNParticles","event %d not found",event);
- return -1;
- }
- if (GetDebug()>2) {
- cerr<<"Nprimary: "<< header->GetNprimary()<<endl;
- cerr<<"Nsecondary: "<<header->GetNsecondary()<<endl;
- }
- return header->GetNprimary() + header->GetNsecondary();
-*/
}
//_______________________________________________________________________
}
return a;
}
-
//_______________________________________________________________________
-Int_t AliRunDigitizer::GetInputEventNumber(Int_t event, Int_t /* input */) const
+Int_t AliRunDigitizer::GetInputEventNumber(Int_t event, Int_t /*input*/) const
{
// return an event number of an eventInput from input file input
// which was merged to create output event event
// simplified for now, implement later
return event;
}
-
//_______________________________________________________________________
TParticle* AliRunDigitizer::GetParticle(Int_t i, Int_t event) const
{
}
//_______________________________________________________________________
-TParticle* AliRunDigitizer::GetParticle(Int_t /* i */, Int_t /* input */,
- Int_t /* event */) const
+TParticle* AliRunDigitizer::GetParticle(Int_t /*i*/, Int_t /*input*/, Int_t /*event*/) const
{
// return pointer to particle with index i in the input file input
// (index without mask)
// Must be revised in the version with AliStream
return 0;
-/*
- TFile *file = ConnectInputFile(input);
- if (!file) {
- Error("GetParticle","Cannot open input file");
- return 0;
- }
-
-// find the header and get Nprimaries and Nsecondaries
- TTree* tE = (TTree *)file->Get("TE") ;
- if (!tE) {
- Error("GetParticle","input file does not contain TE");
- return 0;
- }
- AliHeader* header;
- header = 0;
- tE->SetBranchAddress("Header", &header);
- if (!tE->GetEntry(event)) {
- Error("GetParticle","event %d not found",event);
- return 0;
- }
-
-// connect TreeK
- char treeName[30];
- sprintf(treeName,"TreeK%d",event);
- TTree* tK = static_cast<TTree*>(file->Get(treeName));
- if (!tK) {
- Error("GetParticle","input file does not contain TreeK%d",event);
- return 0;
- }
- TParticle *particleBuffer;
- particleBuffer = 0;
- tK->SetBranchAddress("Particles", &particleBuffer);
-
-
-// algorithmic way of getting entry index
-// (primary particles are filled after secondaries)
- Int_t entry;
- if (i<header->GetNprimary())
- entry = i+header->GetNsecondary();
- else
- entry = i-header->GetNprimary();
- Int_t bytesRead = tK->GetEntry(entry);
-// new ((*fParticles)[nentries]) TParticle(*fParticleBuffer);
- if (bytesRead)
- return particleBuffer;
- return 0;
-*/
}
//_______________________________________________________________________
}
//_______________________________________________________________________
+const TString& AliRunDigitizer::GetInputFolderName(Int_t i) const
+{
+ AliStream* stream = dynamic_cast<AliStream*>(fInputStreams->At(i));
+ if (stream == 0x0)
+ {
+ Fatal("GetInputFolderName","Can not get the input stream. Index = %d. Exiting",i);
+ }
+ return stream->GetFolderName();
+}
+//_______________________________________________________________________
+
+const char* AliRunDigitizer::GetOutputFolderName()
+{
+ return GetOutRunLoader()->GetEventFolder()->GetName();
+}
+//_______________________________________________________________________
+
+AliRunLoader* AliRunDigitizer::GetOutRunLoader()
+{
+ if (fOutRunLoader) return fOutRunLoader;
+
+ if ( fOutputFileName.IsNull() )
+ {//guard that sombody calls it without settting file name
+ cout<<"Output file name is empty. Using Input 0 for output\n";
+ return AliRunLoader::GetRunLoader(GetInputFolderName(0));
+ }
+// InitOutputGlobal();
+ return fOutRunLoader;
+}
+//_______________________________________________________________________
+
TString AliRunDigitizer::GetInputFileName(const Int_t input, const Int_t order) const
{
// returns file name of the order-th file in the input stream input