CMS 3D CMS Logo

Trend.h
Go to the documentation of this file.
1 #ifndef ALIGNMENT_OFFLINEVALIDATION_TREND_H
2 #define ALIGNMENT_OFFLINEVALIDATION_TREND_H
3 
4 #include "boost/filesystem.hpp"
5 #include "boost/property_tree/ptree.hpp"
6 #include "boost/property_tree/json_parser.hpp"
7 
8 #include "TROOT.h"
9 #include "TCanvas.h"
10 #include "TLegend.h"
11 #include "TGraph.h"
12 
22 struct Run2Lumi {
23  const int firstRun,
24  lastRun;
25  const float convertUnit;
26 
27 private:
28  std::map<int, float> runs;
29 
30 public:
39  int first,
40  int last,
41  float convertUnit
42  );
43 
46  float operator()(int run1, int run2) const;
47 
50  float operator()(int run) const;
51 
54  float operator()() const;
55 
60  TGraph* operator()(TGraph* gIn) const;
61 
68  TH1* operator()(TH1* hIn) const;
69 };
70 
78 struct Trend {
79  TString CMS = "#scale[1.1]{#bf{CMS}} #it{Internal}";
80  TString lumi =
81  "#scale[0.8]{pp collisions (2016+2017+2018)}";
83 
84  float fontsize = 0.04;
85 
86  TCanvas c;
87  const char* outputDir; //directory for plots
88  TLegend lgd;
89 
90  const boost::property_tree::ptree JSON;
91  const Run2Lumi& GetLumi;
92  const char* lumiType; //specify whether luminosity is recorded or delivered
93 
94  Trend
95  (const char* name,
96  const char* dir, //directory for plots
97  const char* title,
98  const char* ytitle,
99  float ymin,
100  float ymax,
101  boost::property_tree::ptree& json,
102  const Run2Lumi& GetLumiFunctor,
103  const char* lumiAxisType //specify whether luminosity is recorded or delivered
104  );
105 
109  void operator()(TObject* obj,
110  TString drawOpt,
111  TString lgdOpt,
112  bool fullRange = true
113  );
114 
118  ~Trend();
119 };
120 
121 template <typename T, typename... Args>
122 inline T* Get(Args... args) {
123  return dynamic_cast<T*>(gDirectory->Get(args...));
124 }
125 
126 #endif // ALIGNMENT_OFFLINEVALIDATION_TREND_H
nlohmann::json json
Definition: Trend.h:22
void operator()(TObject *obj, TString drawOpt, TString lgdOpt, bool fullRange=true)
Definition: Trend.cc:220
const char * lumiType
Definition: Trend.h:92
Run2Lumi(boost::filesystem::path file, int first, int last, float convertUnit)
Definition: Trend.cc:23
const int lastRun
last run (excluded!), starting at the max lumi on the x-axis of the trend
Definition: Trend.h:23
float fontsize
Definition: Trend.h:84
std::map< int, float > runs
couples of run and corresponding luminosity
Definition: Trend.h:28
float operator()() const
Sums luminosity for [firstRun, lastRun[.
Definition: Trend.cc:54
Definition: Trend.h:78
TCanvas c
Definition: Trend.h:86
Struct holding legacy CMS convention for process types.
std::string plotUnit
Definition: Trend.h:82
const boost::property_tree::ptree JSON
contains coordinate for vertical lines
Definition: Trend.h:90
const char * outputDir
Definition: Trend.h:87
const int firstRun
first run, starting at lumi = 0 on the x-axis of the trend
Definition: Trend.h:23
const float convertUnit
Definition: Trend.h:25
const Run2Lumi & GetLumi
functor to get luminosity for given subrange
Definition: Trend.h:91
~Trend()
Definition: Trend.cc:257
TLegend lgd
Definition: Trend.h:88
long double T
T * Get(Args... args)
Definition: Trend.h:122