/*
$Log$
+Revision 1.18 2002/07/17 08:59:39 jchudoba
+Do not delete subtasks when AliRunDigitizer is deleted. Owner should delete them itself.
+
+Revision 1.17 2002/07/16 13:47:53 jchudoba
+Add methods to get access to names of files used in merging.
+
+Revision 1.16 2002/06/07 09:18:47 jchudoba
+Changes to enable merging of ITS fast rec points. Although this class should be responsible for a creation of digits only, other solutions would be more complicated.
+
+Revision 1.15 2002/04/09 13:38:47 jchudoba
+Add const to the filename argument
+
+Revision 1.14 2002/04/04 09:28:04 jchudoba
+Change default names of TPC trees. Use update instead of recreate for the output file. Overwrite the AliRunDigitizer object in the output if it exists.
+
+Revision 1.13 2002/02/13 09:03:32 jchudoba
+Pass option to subtasks. Delete input TTrees. Use gAlice from memory if it is present (user must delete the default one created by aliroot if he/she wants to use gAlice from the input file!). Add new data member to store name of the special TPC TTrees.
+
+Revision 1.12 2001/12/10 16:40:52 jchudoba
+Import gAlice from the signal file before InitGlobal() to allow detectors to use it during initialization
+
+Revision 1.11 2001/12/03 07:10:13 jchudoba
+Default ctor cannot create new objects, create dummy default ctor which leaves object in not well defined state - to be used only by root for I/O
+
+Revision 1.10 2001/11/15 11:07:25 jchudoba
+Set to zero new pointers to TPC and TRD special trees in the default ctor. Add const to all Get functions. Remove unused constant, rename constant according coding rules.
+
+Revision 1.9 2001/11/15 09:00:11 jchudoba
+Add special treatment for TPC and TRD, they use different trees than other detectors
+
Revision 1.8 2001/10/21 18:38:43 hristov
Several pointers were set to zero in the default constructors to avoid memory management problems
// and the I/O configured (you have to specify input files
// and an output file). The manager connects appropriate trees from
// the input files according a combination returned by AliMergeCombi
-// classcreates. It creates TreeD in the output and runs once per
+// class. It creates TreeD in the output and runs once per
// event Digitize method of all existing AliDetDigitizers
// (without any option). AliDetDigitizers ask manager
// for a TTree with input (manager->GetInputTreeS(Int_t i),
// The default output is to the signal file (stream 0). This can be
// changed with the SetOutputFile(TString fn) method.
//
-// Single input file is permitted. Maximum MAXSTREAMSTOMERGE can be merged.
+// Single input file is permitted. Maximum kMaxStreamsToMerge can be merged.
// Input from the memory (on-the-fly merging) is not yet
// supported, as well as access to the input data by invoking methods
// on the output data.
// same geometry in all input files), gAlice is taken from the first
// input file on the first stream.
//
-// Example with MUON digitizer:
+// Example with MUON digitizer, no merging, just digitization
+//
+// AliRunDigitizer * manager = new AliRunDigitizer(1,1);
+// manager->SetInputStream(0,"galice.root");
+// AliMUONDigitizer *dMUON = new AliMUONDigitizer(manager);
+// manager->Exec("");
+//
+// Example with MUON digitizer, merge all events from
+// galice.root (signal) file with events from bgr.root
+// (background) file. Number of merged events is
+// min(number of events in galice.root, number of events in bgr.root)
+//
+// AliRunDigitizer * manager = new AliRunDigitizer(2,1);
+// manager->SetInputStream(0,"galice.root");
+// manager->SetInputStream(1,"bgr.root");
+// AliMUONDigitizer *dMUON = new AliMUONDigitizer(manager);
+// manager->Exec("");
+//
+// Example with MUON digitizer, save digits in a new file digits.root,
+// process only 1 event
//
// AliRunDigitizer * manager = new AliRunDigitizer(2,1);
-// manager->SetInputStream(0,"1track_10events_phi45_60.root");
-// manager->SetInputStream(1,"1track_10events_phi120_135.root");
+// manager->SetInputStream(0,"galice.root");
+// manager->SetInputStream(1,"bgr.root");
// manager->SetOutputFile("digits.root");
// AliMUONDigitizer *dMUON = new AliMUONDigitizer(manager);
// manager->SetNrOfEventsToWrite(1);
ClassImp(AliRunDigitizer)
+////////////////////////////////////////////////////////////////////////
+AliRunDigitizer::AliRunDigitizer()
+{
+// root requires default ctor, where no new objects can be created
+// do not use this ctor, it is supplied only for root needs
+
+// just set all pointers - data members to 0
+ fOutput = 0;
+ fTreeD = 0;
+ fTreeR = 0;
+ fTreeDTPC = 0;
+ fTreeDTRD = 0;
+ fInputStreams = 0;
+ for (Int_t i=0;i<kMaxStreamsToMerge;i++) {
+ fArrayTreeS[i]=fArrayTreeH[i]=fArrayTreeTPCS[i]=fArrayTreeTRDS[i]=NULL;
+ fInputFiles[i]=0;
+ }
+ fCombi = 0;
+
+}
+
////////////////////////////////////////////////////////////////////////
AliRunDigitizer::AliRunDigitizer(Int_t nInputStreams, Int_t sperb) : TTask("AliRunDigitizer","The manager for Merging")
{
-// default ctor
+// ctor which should be used to create a manager for merging/digitization
if (nInputStreams == 0) {
Error("AliRunDigitizer","Specify nr of input streams");
return;
fNinputs = nInputStreams;
fOutputFileName = "";
fOutputDirName = ".";
- fCombination.Set(MAXSTREAMSTOMERGE);
- for (i=0;i<MAXSTREAMSTOMERGE;i++) {
- fArrayTreeS[i]=fArrayTreeH[i]=fArrayTreeTPCS[i]=NULL;
+ fCombination.Set(kMaxStreamsToMerge);
+ for (i=0;i<kMaxStreamsToMerge;i++) {
+ fArrayTreeS[i]=fArrayTreeH[i]=fArrayTreeTPCS[i]=fArrayTreeTRDS[i]=NULL;
fCombination[i]=-1;
}
fkMASKSTEP = 10000000;
fkMASK[0] = 0;
- for (i=1;i<MAXSTREAMSTOMERGE;i++) {
+ for (i=1;i<kMaxStreamsToMerge;i++) {
fkMASK[i] = fkMASK[i-1] + fkMASKSTEP;
}
fInputStreams = new TClonesArray("AliStream",nInputStreams);
// the first Input is open RW to be output as well
new(lInputStreams[0]) AliStream("UPDATE");
for (i=1;i<nInputStreams;i++) {
- new(lInputStreams[i]) AliStream();
+ new(lInputStreams[i]) AliStream("READ");
}
fOutput = 0;
fEvent = 0;
fCopyTreesFromInput = -1;
fCombi = new AliMergeCombi(nInputStreams,sperb);
fDebug = 0;
- if (GetDebug()>2)
- cerr<<"AliRunDigitizer::AliRunDigitizer() called"<<endl;
- //PH
fTreeD = 0;
- for (i=0; i<MAXSTREAMSTOMERGE; i++) fInputFiles[i]=0;
+ fTreeR = 0;
+ fTreeDTPC = 0;
+ fTreeDTRD = 0;
+ fTreeDTPCBaseName = "TreeD_75x40_100x60_150x60_";
+ fTreeTPCSBaseName = "TreeS_75x40_100x60_150x60_";
+
+ for (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");
+
if (fInputStreams) {
delete fInputStreams;
fInputStreams = 0;
this->Add(digitizer);
}
////////////////////////////////////////////////////////////////////////
-void AliRunDigitizer::SetInputStream(Int_t i, char *inputFile)
+void AliRunDigitizer::SetInputStream(Int_t i, const char *inputFile)
{
if (i > fInputStreams->GetLast()) {
Error("SetInputStream","Input stream number too high");
// get a new combination of inputs, connect input trees and loop
// over all digitizers
- if (!InitGlobal()) {
- cerr<<"False from InitGlobal"<<endl;
- return;
- }
// take gAlice from the first input file. It is needed to access
// geometry data
- if (!static_cast<AliStream*>(fInputStreams->At(0))->ImportgAlice()) {
- cerr<<"gAlice object not found in the first file of "
- <<"the 1st stream"<<endl;
+// 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;
}
Int_t eventsCreated = 0;
if (!ConnectInputTrees()) break;
InitEvent();
// loop over all registered digitizers and let them do the work
- ExecuteTasks("");
+ ExecuteTasks(option);
CleanTasks();
FinishEvent();
}
TTree *tree;
char treeName[50];
Int_t serialNr;
- Int_t eventNr[MAXSTREAMSTOMERGE], delta[MAXSTREAMSTOMERGE];
+ Int_t eventNr[kMaxStreamsToMerge], delta[kMaxStreamsToMerge];
fCombi->Combination(eventNr, delta);
for (Int_t i=0;i<fNinputs;i++) {
if (delta[i] == 1) {
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,"TreeS_75x40_100x60_%d",serialNr);
+ 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) {
Error("ConnectInputTrees","Only delta 0 or 1 is implemented");
TString fn;
fn = fOutputDirName + '/' + fOutputFileName;
- fOutput = new TFile(fn,"recreate");
+ fOutput = new TFile(fn,"update");
if (GetDebug()>2) {
cerr<<"AliRunDigitizer::InitOutputGlobal(): file "<<fn.Data()<<" was opened"<<endl;
}
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,"TreeD_75x40_100x60_%d",fEvent);
+ sprintf(treeName,"%s%d",fTreeDTPCBaseName,fEvent);
fTreeDTPC = static_cast<TTree*>(fOutput->Get(treeName));
if (!fTreeDTPC) {
fTreeDTPC = new TTree(treeName,"TPC_Digits");
{
// called at the end of loop over digitizers
+ Int_t i;
fOutput->cd();
if (fCopyTreesFromInput > -1) {
char treeName[20];
- Int_t i = fCopyTreesFromInput;
+ i = fCopyTreesFromInput;
sprintf(treeName,"TreeK%d",fCombination[i]);
fInputFiles[i]->Get(treeName)->Clone()->Write();
sprintf(treeName,"TreeH%d",fCombination[i]);
delete fTreeD;
fTreeD = 0;
}
+ if (fTreeR) {
+ delete fTreeR;
+ fTreeR = 0;
+ }
if (fTreeDTPC) {
delete fTreeDTPC;
fTreeDTPC = 0;
// save unique objects to the output file
fOutput->cd();
- this->Write();
+ this->Write(0,TObject::kOverwrite);
if (fCopyTreesFromInput > -1) {
fInputFiles[fCopyTreesFromInput]->Get("TE")->Clone()->Write();
gAlice->Write();
}
- fOutput->Close();
+ fOutput->Write();
}
////////////////////////////////////////////////////////////////////////
-Int_t AliRunDigitizer::GetNParticles(Int_t event)
+Int_t AliRunDigitizer::GetNParticles(Int_t event) const
{
// return number of particles in all input files for a given
// event (as numbered in the output file)
}
////////////////////////////////////////////////////////////////////////
-Int_t AliRunDigitizer::GetNParticles(Int_t event, Int_t input)
+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)
}
////////////////////////////////////////////////////////////////////////
-Int_t* AliRunDigitizer::GetInputEventNumbers(Int_t event)
+Int_t* AliRunDigitizer::GetInputEventNumbers(Int_t event) const
{
// return pointer to an int array with input event numbers which were
// merged in the output event event
// simplified for now, implement later
- Int_t * a = new Int_t[MAXSTREAMSTOMERGE];
+ Int_t * a = new Int_t[kMaxStreamsToMerge];
for (Int_t i = 0; i < fNinputs; i++) {
a[i] = event;
}
return a;
}
////////////////////////////////////////////////////////////////////////
-Int_t AliRunDigitizer::GetInputEventNumber(Int_t event, Int_t input)
+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
return event;
}
////////////////////////////////////////////////////////////////////////
-TParticle* AliRunDigitizer::GetParticle(Int_t i, Int_t event)
+TParticle* AliRunDigitizer::GetParticle(Int_t i, Int_t event) const
{
// return pointer to particle with index i (index with mask)
}
////////////////////////////////////////////////////////////////////////
-TParticle* AliRunDigitizer::GetParticle(Int_t i, Int_t input, Int_t event)
+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)
fHasExecuted = kTRUE;
return;
}
+////////////////////////////////////////////////////////////////////////
+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
+// returns empty string if such file does not exist
+// first input stream is 0
+// first file in the input stream is 0
+ TString fileName("");
+ if (input >= fNinputs) return fileName;
+ AliStream * stream = static_cast<AliStream*>(fInputStreams->At(input));
+ if (order > stream->GetNInputFiles()) return fileName;
+ fileName = stream->GetFileName(order);
+ return fileName;
+}
+////////////////////////////////////////////////////////////////////////