star-travex
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
StiScanPrgOptions.cxx
Go to the documentation of this file.
1 #include <iostream>
2 #include <fstream>
3 
4 #include "TFile.h"
5 
6 #include "travex/utils.h"
8 
9 
11 
12 
13 StiScanPrgOptions::StiScanPrgOptions(int argc, char **argv, const std::string& stiTreeName, const std::string& geantStepTreeName) :
14  PrgOptionProcessor(argc, argv, stiTreeName), fDoGeantStepTree(false), fDoAutoHistRange(true),
15  fGeantStepChain(new TChain(geantStepTreeName.c_str(), "READ")),
16  fHistZMin(0), fHistZMax(0),
17  fHistRMin(0), fHistRMax(0)
18 {
19  fOptions.add_options()
20  ("geant-step-tree,t", "In addition to Sti tree process tree with info from geant steps")
21  ("z-min", po::value<double>(&fHistZMin)->default_value(fHistZMin), "If provided the minimum limit along z will be overwritten by this value in the output histograms")
22  ("z-max", po::value<double>(&fHistZMax)->default_value(fHistZMax), "If provided the maximum limit along z will be overwritten by this value in the output histograms")
23  ("r-min", po::value<double>(&fHistRMin)->default_value(fHistRMin), "If provided the minimum limit in radial direction will be overwritten by this value in the output histograms")
24  ("r-max", po::value<double>(&fHistRMax)->default_value(fHistRMax), "If provided the maximum limit in radial direction will be overwritten by this value in the output histograms")
25  ;
26 }
27 
28 
30 {
31  delete fGeantStepChain; fGeantStepChain = nullptr;
32 }
33 
34 
36 {
38 
39  if (fOptionsValues.count("geant-step-tree") )
40  fDoGeantStepTree = true;
41 
43  fDoAutoHistRange = false;
44 }
45 
46 
53 void StiScanPrgOptions::AddToInputChains(std::string stiTreeRootFileName)
54 {
55  PrgOptionProcessor::AddToInputChains(stiTreeRootFileName);
56 
57  if (!fDoGeantStepTree) return;
58 
59  TString geantStepRootFileName(stiTreeRootFileName.c_str());
60  geantStepRootFileName.ReplaceAll("stiscan.root", "track_history.root");
61 
62  TFile file( geantStepRootFileName.Data() );
63 
64  if ( file.IsZombie() )
65  TVX_FATAL("Input file is not a valid root file: %s", geantStepRootFileName.Data());
66 
67  fGeantStepChain->AddFile( geantStepRootFileName.Data() );
68  TVX_INFO("Found valid ROOT file with Geant info: %s", geantStepRootFileName.Data());
69 }
virtual void AddToInputChains(std::string stiTreeRootFileName)
Processes and controls user options provided in the command line.
virtual void AddToInputChains(std::string stiTreeRootFileName)
This private method takes a path to a valid ROOT file as input.
bool fDoGeantStepTree
A flag to process geant tree if set.
virtual void VerifyOptions()
Processes and controls user options provided in the command line.
bool fDoAutoHistRange
A flag to find optimal range for histogram axises automatically.
virtual void VerifyOptions()