18 : fRootFile(0), fMakePermanent(0),
19 fMapFile(0), fEnableMapFile(kFALSE),
28 TString mapfilename =
"/dev/shm/";
37 mapfilename +=
"/QwMemMapFile.map";
42 QwError <<
"Memory-mapped file " << mapfilename
47 QwMessage <<
"================== RealTime Producer Memory Map File =================" <<
QwLog::endl;
49 QwMessage <<
"======================================================================" <<
QwLog::endl;
54 TString hostname = gSystem -> HostName();
56 TString localRootFileName = gSystem->Getenv(
"QW_ROOTFILES_LOCAL");
64 if (localRootFileName.IsNull()) {
67 rootfilename = localRootFileName;
81 rootfilename += Form(
"/%s%s.%s.%d.root",
83 hostname.Data(), pid);
84 fRootFile =
new TFile(rootfilename,
"RECREATE",
"QWeak ROOT file");
86 QwError <<
"ROOT file " << rootfilename
91 TString run_condition_name = Form(
"%s_condition", run_label.Data());
92 TList *run_cond_list = (TList*) fRootFile -> FindObjectAny(run_condition_name);
93 if (not run_cond_list) {
102 run_condition.GetName()
130 TString rootfilename =
fRootFile->GetName();
143 err =
remove( rootfilename.Data() );
156 std::map< const std::string, std::vector<QwRootTree*> >::iterator map_iter;
157 std::vector<QwRootTree*>::iterator vec_iter;
159 for (vec_iter = map_iter->second.begin(); vec_iter != map_iter->second.end(); vec_iter++) {
174 "stem of the output ROOT filename");
179 "enable output to memory-mapped file");
184 "disable output to all trees");
187 "disable output to all histograms");
192 "disable helicity window output");
195 "disable helicity pattern output");
198 "disable burst tree");
201 "disable slow control tree");
205 (
"num-mps-accepted-events", po::value<int>()->default_value(0),
206 "number of accepted consecutive MPS events");
208 (
"num-mps-discarded-events", po::value<int>()->default_value(0),
209 "number of discarded consecutive MPS events");
211 (
"num-hel-accepted-events", po::value<int>()->default_value(0),
212 "number of accepted consecutive pattern events");
214 (
"num-hel-discarded-events", po::value<int>()->default_value(0),
215 "number of discarded consecutive pattern events");
217 (
"mapfile-update-interval", po::value<int>()->default_value(400),
218 "Events between a map file update");
221 options.
AddOptions(
"ROOT performance options")
222 (
"autoflush", po::value<int>()->default_value(0),
224 options.
AddOptions(
"ROOT performance options")
225 (
"autosave", po::value<int>()->default_value(300000000),
227 options.
AddOptions(
"ROOT performance options")
228 (
"basket-size", po::value<int>()->default_value(16000),
229 "TTree basket size");
230 options.
AddOptions(
"ROOT performance options")
231 (
"circular-buffer", po::value<int>()->default_value(0),
232 "TTree circular buffer");
233 options.
AddOptions(
"ROOT performance options")
234 (
"compression-level", po::value<int>()->default_value(1),
235 "TFile compression level");
278 if ((ROOT_VERSION_CODE < ROOT_VERSION(5,26,00)) && fAutoFlush != -30000000){
280 QwWarning <<
"QwRootFile::ProcessOptions: "
281 <<
"The 'autoflush' flag is not supported by ROOT version "
297 if (!d)
return false;
298 TList* l = d->GetListOfKeys();
300 for(
int i=0; i < l->GetEntries(); ++i) {
301 const char* name = l->At(i)->GetName();
302 TObject* obj = d->FindObjectAny(name);
308 if ( TString(name).Contains(
"parameter_file") )
continue;
309 if ( TString(name).Contains(
"mapfile") )
continue;
310 if ( TString(name).Contains(
"_condition") )
continue;
312 if ( TString(name).Contains(
"Slow_Tree") )
continue;
315 if (obj->IsA()->InheritsFrom(
"TDirectory" ))
316 if (this->
HasAnyFilled( (TDirectory*)obj ))
return true;
318 if (obj->IsA()->InheritsFrom(
"TTree" ))
319 if ( ((TTree*) obj)->GetEntries() )
return true;
321 if (obj->IsA()->InheritsFrom(
"TH1" ))
322 if ( ((TH1*) obj)->GetEntries() )
return true;
#define QwMessage
Predefined log drain for regular messages.
UInt_t fNumMpsEventsToSave
#define default_bool_value(b)
UInt_t fNumHelEventsToSkip
const TString getenv_safe_TString(const char *name)
TMapFile * fMapFile
Map file.
void DisableHisto(const TString ®exp)
Add regexp to list of disabled histogram directories.
UInt_t fNumMpsEventsToSkip
Prescaling of events written to tree.
QwRootFile()
Private default constructor.
UInt_t fNumHelEventsToSave
char ** GetArgv()
Get the vector of command line arguments.
po::options_description_easy_init AddOptions(const std::string &blockname="Specialized options")
Add an option to a named block or create new block.
TString fRootFileStem
ROOT file stem.
virtual ~QwRootFile()
Destructor.
T GetValue(const std::string &key)
Get a templated value.
UInt_t fCircularBufferSize
static std::string fDefaultRootFileStem
Default ROOT file stem.
Int_t WriteObject(const T *obj, const char *name, Option_t *option="", Int_t bufsize=0)
Write any object to the ROOT file (only valid for TFile)
TFile * fRootFile
ROOT file.
Bool_t HasAnyFilled(void)
Search for non-empty trees or histograms in the file.
std::map< const std::string, std::vector< QwRootTree * > > fTreeByName
Tree names, addresses, and types.
int GetArgc()
Get the number of command line arguments.
static const Long64_t kMaxTreeSize
Maximum tree size.
static std::ostream & endl(std::ostream &)
End of the line.
static const Int_t kMaxMapFileSize
void ProcessOptions(QwOptions &options)
Process the configuration options.
void DisableTree(const TString ®exp)
Add regexp to list of disabled trees names.
#define QwWarning
Predefined log drain for warnings.
static void DefineOptions(QwOptions &options)
Define the configuration options.
#define QwError
Predefined log drain for errors.