12 #include "TGraphErrors.h" 15 #include "Alignment/OfflineValidation/plugins/ColorParser.C" 16 #include "Alignment/OfflineValidation/plugins/StyleParser.C" 20 namespace fs = boost::filesystem;
21 namespace pt = boost::property_tree;
56 objOut->SetLineColor(objIn->GetLineColor());
57 objOut->SetLineColor(objIn->GetMarkerColor());
58 objOut->SetMarkerColor(objIn->GetMarkerColor());
59 objOut->SetFillColorAlpha(objIn->GetFillColor(), 0.2);
61 objOut->SetLineStyle(objIn->GetLineStyle());
62 objOut->SetMarkerStyle(objIn->GetMarkerStyle());
63 objOut->SetFillStyle(objIn->GetFillStyle());
65 objOut->SetLineWidth(objIn->GetLineWidth());
66 objOut->SetMarkerSize(objIn->GetMarkerSize());
72 vector<float>
x,
y, ex, ey;
74 for (
int i = 0;
i <
n - 1; ++
i) {
75 int currentRun = gIn->GetPointX(
i);
81 int nextRun = gIn->GetPointX(
i + 1);
84 x.push_back(lumi_edge + lumi_width / 2);
85 ex.push_back(lumi_width / 2);
87 auto point = gIn->GetPointY(
i),
error = gIn->GetErrorY(
i);
93 assert(
N ==
y.size() &&
N == ex.size() &&
N == ey.size());
94 TGraph* gOut =
new TGraphErrors(
N,
x.data(),
y.data(), ex.data(), ey.data());
95 gOut->SetTitle(gIn->GetTitle());
103 int N = hIn->GetNbinsX();
104 for (
int i = 1;
i <=
N; ++
i) {
105 auto nextRun = hIn->GetBinLowEdge(
i + 1);
111 edges.push_back(
operator()(nextRun));
113 auto content = hIn->GetBinContent(
i),
error = hIn->GetBinError(
i);
119 TString
name = hIn->GetName();
121 TH1* hOut =
new TH1F(
name, hIn->GetTitle(),
N,
edges.data());
122 for (
int i = 1;
i <=
N; ++
i) {
124 hOut->SetBinError(
i,
errors[
i - 1]);
138 const char* lumiAxisType)
141 lgd(0.7, 0.65, 0.97, 0.89,
"",
"NDC"),
144 lumiType(lumiAxisType) {
145 if (
JSON.count(
"CMSlabel"))
146 CMS = Form(
"#scale[1.1]{#bf{CMS}} #it{%s}",
JSON.get<
string>(
"CMSlabel").data());
148 if (
JSON.get_child(
"trends").count(
"TitleCanvas"))
149 lumi = Form(
"#scale[0.8]{%s}",
JSON.get_child(
"trends").get<
string>(
"TitleCanvas").
data());
153 if (
JSON.get_child(
"trends").count(
"plotUnit"))
154 plotUnit =
JSON.get_child(
"trends").get<
string>(
"plotUnit");
157 frame->GetYaxis()->SetTitleOffset(0.8);
158 frame->GetYaxis()->SetTickLength(0.01);
167 l.SetLineColor(kBlack);
168 l.SetLineStyle(kDashed);
169 l.DrawLine(0., 0.,
xmax, 0.);
173 c.SetRightMargin(0.015);
174 c.SetLeftMargin(0.07);
175 c.SetTopMargin(0.07);
178 pt::ptree
lines =
JSON.get_child(
"trends.lines");
180 auto line =
type.second.get_child_optional(
"line");
181 auto runs =
type.second.get_child_optional(
"runs");
187 auto style =
line->get_optional<
string>(
"style");
189 v->SetLineStyle(StyleParser(*
style));
191 auto color =
line->get_optional<
string>(
"color");
193 v->SetLineColor(ColorParser(*color));
195 auto width =
line->get_optional<
int>(
"width");
199 auto title =
line->get_optional<
string>(
"title");
204 auto currentRun =
run.second.get_value<
int>();
219 auto g =
dynamic_cast<TGraph*
>(
obj);
227 g->Draw(
"same" + drawOpt);
229 auto h =
dynamic_cast<TH1*
>(
obj);
232 h->Draw(
"same" + drawOpt);
238 TString
name =
c.GetName();
239 name.ReplaceAll(
"vs_run",
"vs_lumi");
245 lgd.AddEntry(
obj,
"", lgdOpt);
252 float l =
c.GetLeftMargin(),
t =
c.GetTopMargin(),
r =
c.GetRightMargin(),
lumiTextOffset = 0.2;
256 latex.SetTextFont(42);
258 latex.SetTextAlign(11);
261 latex.SetTextAlign(31);
265 latex.SetTextAlign(13);
269 pt::ptree
lines =
JSON.get_child(
"trends.lines");
271 auto labels =
type.second.get_child_optional(
"labels");
272 auto runs =
type.second.get_child_optional(
"runs");
276 auto runIt =
runs->begin();
277 auto labelIt =
labels->begin();
278 while (runIt !=
runs->end() && labelIt !=
labels->end()) {
279 auto currentRun = runIt->second.get_value<
int>();
280 auto label = labelIt->second.get_value<
string>();
283 auto posX =
l + (
lumi / totLumi) / (
l + 1 +
r) + 0.02;
295 c.SaveAs(Form(
"%s/%s.pdf",
outputDir,
c.GetName()), Form(
"Title:%s",
c.GetTitle()));
296 c.SaveAs(Form(
"%s/%s.png",
outputDir,
c.GetName()), Form(
"Title:%s",
c.GetTitle()));
void operator()(TObject *obj, TString drawOpt, TString lgdOpt, bool fullRange=true)
Run2Lumi(boost::filesystem::path file, int first, int last, float convertUnit)
const int lastRun
last run (excluded!), starting at the max lumi on the x-axis of the trend
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
std::map< int, float > runs
couples of run and corresponding luminosity
float operator()() const
Sums luminosity for [firstRun, lastRun[.
Struct holding legacy CMS convention for process types.
const boost::property_tree::ptree JSON
contains coordinate for vertical lines
float operator()(int run) const
Sums luminosity for [firstRun, run[.
const int firstRun
first run, starting at lumi = 0 on the x-axis of the trend
Trend(const char *name, const char *dir, const char *title, const char *ytitle, float ymin, float ymax, boost::property_tree::ptree &json, const Run2Lumi &GetLumiFunctor, const char *lumiAxisType)
< constructor, prepares canvas and frame
char data[epos_bytes_allocation]
const Run2Lumi & GetLumi
functor to get luminosity for given subrange
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
void CopyStyle(T *objIn, T *objOut)
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point