X-Git-Url: http://git.uio.no/git/?p=u%2Fmrichter%2FAliRoot.git;a=blobdiff_plain;f=STEER%2FAliRunDigitizer.cxx;h=027c19b811c3b248c080328282ab5c344df19c81;hp=14e9fc001b1fb19963cc66e91bab3318ec3bde0d;hb=50f3bbf4766e42ffeb4c8480fb4d26009bd9c720;hpb=47b5729a8bc7ccc5942f60b4fa192c465a794000 diff --git a/STEER/AliRunDigitizer.cxx b/STEER/AliRunDigitizer.cxx index 14e9fc001b1..027c19b811c 100644 --- a/STEER/AliRunDigitizer.cxx +++ b/STEER/AliRunDigitizer.cxx @@ -48,7 +48,7 @@ // 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 kMaxStreamsToMerge can be merged. +// Single input file is permitted. Maximum MAXSTREAMSTOMERGE 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. @@ -90,24 +90,21 @@ // system includes -#include - // ROOT includes -#include "TFile.h" -#include "TList.h" -#include "TTree.h" +#include +class TList; // AliROOT includes +#include "AliLog.h" #include "AliDigitizer.h" -#include "AliMergeCombi.h" -#include "AliRunLoader.h" +#include "AliHeader.h" #include "AliLoader.h" +#include "AliMergeCombi.h" #include "AliRun.h" #include "AliRunDigitizer.h" -#include "AliStream.h" -#include "AliHeader.h" +#include "AliRunLoader.h" ClassImp(AliRunDigitizer) @@ -116,7 +113,7 @@ const TString AliRunDigitizer::fgkBaseInFolderName("Input"); //_______________________________________________________________________ -AliRunDigitizer::AliRunDigitizer(): +AliRunDigitizer::AliRunDigitizer(): TTask("AliRunDigitizer","The manager for Merging"), fkMASKSTEP(0), fOutputFileName(0), fOutputDirName(0), @@ -131,13 +128,11 @@ AliRunDigitizer::AliRunDigitizer(): fOutputInitialized(kFALSE), fCombi(0), fCombination(0), - fCombinationFileName(0), - fDebug(0) + fCombinationFileName(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; + // + // root requires default ctor, where no new objects can be created + // do not use this ctor, it is supplied only for root needs } //_______________________________________________________________________ @@ -156,22 +151,24 @@ AliRunDigitizer::AliRunDigitizer(Int_t nInputStreams, Int_t sperb): fOutRunLoader(0x0), fOutputInitialized(kFALSE), fCombi(new AliMergeCombi(nInputStreams,sperb)), - fCombination(kMaxStreamsToMerge), - fCombinationFileName(0), - fDebug(0) + fCombination(MAXSTREAMSTOMERGE), + fCombinationFileName(0) { -// ctor which should be used to create a manager for merging/digitization + // + // ctor which should be used to create + // a manager for merging/digitization + // if (nInputStreams == 0) {//kidding - Fatal("AliRunDigitizer","Specify nr of input streams"); + AliFatal("Specify nr of input streams"); return; } Int_t i; fkMASK[0] = 0; - for (i=1;iAdd(digitizer); } //_______________________________________________________________________ @@ -237,7 +241,7 @@ void AliRunDigitizer::SetInputStream(Int_t i, const char *inputFile, TString fol // Sets the name of the input file // if (i > fInputStreams->GetLast()) { - Error("SetInputStream","Input stream number too high"); + AliError("Input stream number too high"); return; } AliStream * stream = static_cast(fInputStreams->At(i)) ; @@ -257,17 +261,16 @@ void AliRunDigitizer::Digitize(Option_t* option) // take gAlice from the first input file. It is needed to access // geometry data // If gAlice is already in memory, use it - SetDebug(10); if (!static_cast(fInputStreams->At(0))->ImportgAlice()) { - Error("Digitize","Error occured while getting gAlice from Input 0"); + AliError("Error occured while getting gAlice from Input 0"); return; } if (!InitGlobal()) //calls Init() for all (sub)digitizers { - Error("Digitize","InitGlobal returned error"); + AliError("InitGlobal returned error"); return; } @@ -292,8 +295,10 @@ void AliRunDigitizer::Digitize(Option_t* option) //_______________________________________________________________________ Bool_t AliRunDigitizer::ConnectInputTrees() { -//loads events - Int_t eventNr[kMaxStreamsToMerge], delta[kMaxStreamsToMerge]; + // + // loads events + // + Int_t eventNr[MAXSTREAMSTOMERGE], delta[MAXSTREAMSTOMERGE]; fCombi->Combination(eventNr, delta); for (Int_t i=0;iGetListOfTasks(); if (subTasks) { @@ -330,18 +338,23 @@ Bool_t AliRunDigitizer::InitGlobal() void AliRunDigitizer::SetOutputFile(TString fn) { -// 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()); + // + // 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 + // + AliInfo(Form("Setting Output File Name %s ",fn.Data())); fOutputFileName = fn; -// InitOutputGlobal(); + // InitOutputGlobal(); } //_______________________________________________________________________ Bool_t AliRunDigitizer::InitOutputGlobal() { -// Creates the output file, called by InitEvent() -//Needs to be called after all inputs are opened + // + // Creates the output file, called by InitEvent() + // Needs to be called after all inputs are opened + // if (fOutputInitialized) return kTRUE; if ( !fOutputFileName.IsNull()) @@ -350,17 +363,17 @@ Bool_t AliRunDigitizer::InitOutputGlobal() if (fOutRunLoader == 0x0) { - Error("InitOutputGlobal","Can not open ooutput"); + AliError("Can not open output"); 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?"); + AliError("Can not get Run Loader Input 0. Maybe yet not initialized?"); return kFALSE; } - Info("InitOutputGlobal", " 2 %#x = ", inrl) ; + AliDebug(2, Form(" 2 %#x = ", inrl)) ; //Copy all detector loaders from input 0 to output const TObjArray* inloaders = inrl->GetArrayOfLoaders(); @@ -375,7 +388,7 @@ Bool_t AliRunDigitizer::InitOutputGlobal() fOutRunLoader->MakeTree("E"); - if (GetDebug()>2) Info("InitOutputGlobal","file %s was opened.",fOutputFileName.Data()); + AliDebug(3,Form("file %s was opened.",fOutputFileName.Data())); } fOutputInitialized = kTRUE; return kTRUE; @@ -384,26 +397,26 @@ Bool_t AliRunDigitizer::InitOutputGlobal() void AliRunDigitizer::InitEvent() { -//redirects output properly - if (GetDebug()>2) - { - Info("InitEvent","fEvent = %d",fEvent); - Info("InitEvent","fOutputFileName \"%s\"",fOutputFileName.Data()); - } + // + // redirects output properly + // + AliDebug(3,Form("fEvent = %d",fEvent)); + AliDebug(3,Form("fOutputFileName \"%s\"",fOutputFileName.Data())); if (fOutputInitialized == kFALSE) InitOutputGlobal(); -// if fOutputFileName was not given, write output to signal directory + // if fOutputFileName was not given, write output to signal directory } //_______________________________________________________________________ void AliRunDigitizer::FinishEvent() { -// called at the end of loop over digitizers - + // + // called at the end of loop over digitizers + // if (GetOutRunLoader() == 0x0) { - Error("FinishEvent","fOutRunLoader is null"); + AliError("fOutRunLoader is null"); return; } @@ -419,7 +432,7 @@ void AliRunDigitizer::FinishEvent() { inrl->LoadHeader(); inheader = inrl->GetHeader(); - if (inheader == 0x0) Fatal("FinishEvent","Can not get header from input 0"); + if (inheader == 0x0) AliFatal("Can not get header from input 0"); } outheader->SetNprimary(inheader->GetNprimary()); @@ -434,7 +447,7 @@ void AliRunDigitizer::FinishEvent() { //this is sensless since no information would be coherent in case of merging // - cout<<"Copy trees from input: Copy or link files manually"<Write(); - file->Close(); - delete file; + GetOutRunLoader()->CdGAFile(); + this->Write(NULL, TObject::kOverwrite); if (fOutRunLoader) { fOutRunLoader->WriteHeader("OVERWRITE"); @@ -461,7 +473,7 @@ void AliRunDigitizer::FinishGlobal() TFolder* outfolder = fOutRunLoader->GetEventFolder(); if (outfolder == 0x0) { - Error("FinishEvent","Can not get Event Folder"); + AliError("Can not get Event Folder"); return; } @@ -513,7 +525,7 @@ Int_t* AliRunDigitizer::GetInputEventNumbers(Int_t event) const // merged in the output event event // simplified for now, implement later - Int_t * a = new Int_t[kMaxStreamsToMerge]; + Int_t * a = new Int_t[MAXSTREAMSTOMERGE]; for (Int_t i = 0; i < fNinputs; i++) { a[i] = event; } @@ -554,8 +566,9 @@ TParticle* AliRunDigitizer::GetParticle(Int_t /*i*/, Int_t /*input*/, Int_t /*ev //_______________________________________________________________________ void AliRunDigitizer::ExecuteTask(Option_t* option) { -// overwrite ExecuteTask to do Digitize only - + // + // overwrite ExecuteTask to do Digitize only + // if (!IsActive()) return; Digitize(option); fHasExecuted = kTRUE; @@ -565,28 +578,35 @@ void AliRunDigitizer::ExecuteTask(Option_t* option) //_______________________________________________________________________ const TString& AliRunDigitizer::GetInputFolderName(Int_t i) const { + // + // Get the input Folder Name + // AliStream* stream = dynamic_cast(fInputStreams->At(i)); if (stream == 0x0) - { - Fatal("GetInputFolderName","Can not get the input stream. Index = %d. Exiting",i); - } + AliFatal(Form("Can not get the input stream. Index = %d. Exiting",i)); return stream->GetFolderName(); } //_______________________________________________________________________ const char* AliRunDigitizer::GetOutputFolderName() { + // + // Get output folder name + // return GetOutRunLoader()->GetEventFolder()->GetName(); } //_______________________________________________________________________ AliRunLoader* AliRunDigitizer::GetOutRunLoader() { + // + // Returns Run Loader + // 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"; + AliDebug(1,"Output file name is empty. Using Input 0 for output"); return AliRunLoader::GetRunLoader(GetInputFolderName(0)); } // InitOutputGlobal();