Commit 96ff8466 authored by Administrator's avatar Administrator
Browse files

Allow to use serveral ROOT parameter files as input

Add the posibility to have different ROOT parameter files for input and
output. Add the posibility to use several input ROOT files which are merged
on the fly.
parent c46602d5
......@@ -10,6 +10,7 @@
#include "CbmDigitization.h"
#include "CbmDigitizationSource.h"
#include "CbmFileUtils.h"
#include "CbmMuchDigitizeGem.h"
#include "CbmMvdDigitizer.h"
#include "CbmPsdSimpleDigitizer.h"
......@@ -30,6 +31,7 @@
#include "TClonesArray.h"
#include "TGeoManager.h"
#include "TKey.h"
#include "TObjString.h"
#include "TROOT.h"
......@@ -49,6 +51,7 @@ CbmDigitization::CbmDigitization()
, fSource(new CbmDigitizationSource())
, fOutFile()
, fParRootFile()
, fParInputRootFiles()
, fParAsciiFiles()
, fMoniFile()
, fOverwriteOutput(kFALSE)
......@@ -98,6 +101,19 @@ Bool_t CbmDigitization::AddParameterAsciiFile(TString fileName)
}
// --------------------------------------------------------------------------
// ----- Add a ROOT parameter file ------------------------------------
Bool_t CbmDigitization::AddParameterRootFile(TString fileName)
{
if (gSystem->AccessPathName(fileName.Data())) {
LOG(error) << fName << ": Parameter file " << fileName << " does not exist!";
return kFALSE;
}
fParInputRootFiles.Add(new TObjString(fileName.Data()));
LOG(info) << fName << ": Adding parameter file " << fileName;
return kTRUE;
}
// --------------------------------------------------------------------------
// ----- Check input file -----------------------------------------------
Int_t CbmDigitization::CheckInput()
......@@ -285,13 +301,33 @@ void CbmDigitization::DefaultInit()
word = (nDigis == 1 ? " digitiser" : " digitisers");
LOG(info) << fName << ": " << nDigis << word << " instantiated.";
// If there is a list of input parameter files use those.
// If the list is empty there is only one file defined by
// fParRootFile which is used for input and output of the
// parameter data
// Add this file to the empty list
LOG(info) << "Here I am";
if (fParInputRootFiles.IsEmpty()) { fParInputRootFiles.Add(new TObjString(fParRootFile.Data())); }
LOG(info) << "Here I am again";
// --- Extract needed information from runtime database
FairRuntimeDb* rtdb = FairRuntimeDb::instance();
FairParRootFileIo* parIoRoot = new FairParRootFileIo();
parIoRoot->open(fParRootFile.Data(), "READ");
rtdb->setFirstInput(parIoRoot);
fMergedParamFile = Cbm::File::MergeRootParamFiles(&fParInputRootFiles);
parIoRoot->open(fMergedParamFile, "READ");
// --- Delete TGeoManager which is opened when the file is merged
// This is a hack to work around the problem but we have to find
// the problem in our geometry to get rid of this problem
if (gROOT->GetVersionInt() >= 60602 && gGeoManager) {
gGeoManager->GetListOfVolumes()->Delete();
gGeoManager->GetListOfShapes()->Delete();
delete gGeoManager;
} //? ROOT version
rtdb->setFirstInput(parIoRoot);
// --- Get geometry from runtime database
rtdb->getContainer("FairGeoParSet");
......@@ -320,7 +356,6 @@ void CbmDigitization::DefaultInit()
delete rtdb;
delete parIoRoot;
// --- Delete TGeoManager (will be initialised again from FairRunAna)
if (gROOT->GetVersionInt() >= 60602) {
gGeoManager->GetListOfVolumes()->Delete();
......@@ -328,7 +363,6 @@ void CbmDigitization::DefaultInit()
delete gGeoManager;
} //? ROOT version
std::cout << std::endl << std::endl;
LOG(info) << "===================================================";
......@@ -401,19 +435,29 @@ void CbmDigitization::Run(Int_t event1, Int_t event2)
// --- Set runtime database
LOG(info) << fName << ": Setting runtime DB ";
LOG(info) << fName << ": ROOT I/O is " << fParRootFile;
FairRuntimeDb* rtdb = run->GetRuntimeDb();
FairParRootFileIo* parIoRoot = new FairParRootFileIo();
parIoRoot->open(fParRootFile.Data(), "UPDATE");
FairRuntimeDb* rtdb = run->GetRuntimeDb();
FairParRootFileIo* parIoRootIn = new FairParRootFileIo();
FairParRootFileIo* parIoRootOut = new FairParRootFileIo();
if (1 == fParInputRootFiles.GetEntries() && fParInputRootFiles.Contains(fParRootFile.Data()) ) {
LOG(info) << fName << ": ROOT parameter I/O is " << fParRootFile;
parIoRootIn->open(fParRootFile.Data(), "UPDATE");
}
else {
LOG(info) << fName << ": ROOT input parameter I/O is ";
parIoRootIn->open(fMergedParamFile, "READ");
parIoRootOut->open(fParRootFile.Data(), "UPDATE");
}
if (fParAsciiFiles.IsEmpty()) {
LOG(info) << fName << ": No ASCII input to parameter database";
rtdb->setFirstInput(parIoRoot);
rtdb->setFirstInput(parIoRootIn);
} //? ASCII parameter file list empty
else {
FairParAsciiFileIo* parIoAscii = new FairParAsciiFileIo();
parIoAscii->open(&fParAsciiFiles, "in");
rtdb->setFirstInput(parIoAscii);
rtdb->setSecondInput(parIoRoot);
rtdb->setSecondInput(parIoRootIn);
} //? ASCII parameter file list not empty
LOG(info) << "===================================================";
......@@ -423,7 +467,12 @@ void CbmDigitization::Run(Int_t event1, Int_t event2)
LOG(info) << "===================================================";
LOG(info) << fName << ": Initialising run...";
run->Init();
rtdb->setOutput(parIoRoot);
if (1 == fParInputRootFiles.GetEntries() && fParInputRootFiles.Contains(fParRootFile.Data()) ) {
rtdb->setOutput(parIoRootIn);
}
else {
rtdb->setOutput(parIoRootOut);
}
rtdb->saveOutput();
LOG(info) << fName << ": Initialising run...finished";
LOG(info) << "===================================================";
......@@ -567,5 +616,4 @@ CbmDigitizeBase* CbmDigitization::GetDigitizer(ECbmModuleId system)
}
// --------------------------------------------------------------------------
ClassImp(CbmDigitization);
......@@ -73,6 +73,16 @@ public:
Bool_t AddParameterAsciiFile(TString fileName);
/** @brief Add a ROOT parameter file as input
** @param fileName Name of parameter file
** @return kTRUE is file is found
**
** All ROOT parameter files will be concatenated and used
** as input to the runtime database.
*/
Bool_t AddParameterRootFile(TString fileName);
/** @brief Deactivate a system for digitisation
** @param system System ID (ECbmModuleId)
**
......@@ -179,10 +189,18 @@ public:
/** @brief Set the parameter file name
** @param fileName Name of output file
** @param fileName Name of input/output file
**/
void SetParameterRootFile(TString fileName);
/** @brief Set the parameter output file name
** @param fileName Name of output file
**/
void SetOutputParameterRootFile(TString fileName)
{
fParRootFile = fileName;
}
/** @brief Set production of inter-event noise
** @param Choice If kTRUE, the digitizer will produce noise
......@@ -240,6 +258,8 @@ private:
CbmDigitizationSource* fSource; ///< Input source
TString fOutFile; ///< Output data (digis)
TString fParRootFile; ///< ROOT parameter file
TList fParInputRootFiles; ///< ROOT parameter input files
TString fMergedParamFile; ///< Merged parameter file
TList fParAsciiFiles; ///< ASCII parameter files
TString fMoniFile; ///< Resource monitoring information
Bool_t fOverwriteOutput;
......@@ -290,7 +310,6 @@ private:
/** @brief Default settings for digitizers **/
void SetDefaultBranches();
ClassDef(CbmDigitization, 3);
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment