star-travex
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
StiHifyRootFile.cxx
Go to the documentation of this file.
1 #include <boost/filesystem.hpp>
2 #include <boost/regex.hpp>
3 
4 #include "StiHifyRootFile.h"
5 
6 #include "TH1.h"
7 
11 
12 
13 StiHifyRootFile::StiHifyRootFile(StiHifyPrgOptions& prgOpts, Option_t *option, const char *ftitle, Int_t compress) :
14  tvx::RootFile(prgOpts, option, ftitle, compress)
15 {
16  treeMaker = new StiHifyAnalysisTreeMaker(prgOpts);
17 
18  Add( new StiHifyHistContainer(prgOpts, "sti_hit_any_node", this) );
19  Add( new StiHifyHistContainer(prgOpts, "sti_hit_accepted", this) );
20  Add( new StiHifyHistContainer(prgOpts, "sti_hit_rejected", this) );
21 }
22 
23 
25 {
29 
30  hc<StiHifyHistContainer>("sti_hit_any_node")->FillHists(event, StiNodeHitStatus::Any);
31  hc<StiHifyHistContainer>("sti_hit_accepted")->FillHists(event, StiNodeHitStatus::Accepted);
32  hc<StiHifyHistContainer>("sti_hit_rejected")->FillHists(event, StiNodeHitStatus::Rejected);
33 }
34 
35 
40 {
41  tvx::RootFile::Finalize();
42 
43  StiHifyRatiosHistContainer *ratios = new StiHifyRatiosHistContainer("sti_hit_ratio", this);
44  Add(ratios);
45 
46 
47  const tvx::HistMap& hists = hc("sti_hit_any_node")->GetHists();
48 
49  for (const auto& hist_iter : hists)
50  {
51  std::string hist_name = hist_iter.first;
52 
53  // We select only histograms with names matching the following regex
54  bool matched = boost::regex_match(hist_name, boost::regex("^hActiveLayerCounts.*$"));
55 
56  if (!matched) continue;
57 
58  const tvx::HistContainer& hitsNumer( *hc("sti_hit_accepted") );
59  const tvx::HistContainer& hitsDenom( *hc("sti_hit_any_node") );
60 
61  const TH1& hitsAcc = hitsNumer[hist_name];
62  const TH1& hitsAll = hitsDenom[hist_name];
63 
64  ratios->CreateRatioHist(&hitsAcc, &hitsAll);
65  }
66 
67 }
void Finalize()
Create ratios for all histograms whose name starts with hActiveLayerCounts.
void FillTree(const StiHifyEvent &event, StiNodeHitStatus hitStatus=StiNodeHitStatus::Any, bool onlyNodesWithCandidates=false)
void FillHists(const StiHifyEvent &event)
Processes and controls user options provided in the command line.
void CreateRatioHist(const TH1 *hNumer, const TH1 *hDenom)
StiHifyRootFile(StiHifyPrgOptions &prgOpts, Option_t *option="", const char *ftitle="", Int_t compress=1)
StiHifyAnalysisTreeMaker * treeMaker