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->SetMarkerColor(objIn->GetMarkerColor());
58 objOut->SetFillColorAlpha(objIn->GetFillColor(), 0.2);
60 objOut->SetLineStyle(objIn->GetLineStyle());
61 objOut->SetMarkerStyle(objIn->GetMarkerStyle());
62 objOut->SetFillStyle(objIn->GetFillStyle());
64 objOut->SetLineWidth(objIn->GetLineWidth());
65 objOut->SetMarkerSize(objIn->GetMarkerSize());
71 vector<float>
x,
y, ex, ey;
73 for (
int i = 0;
i <
n - 1; ++
i) {
74 int currentRun = gIn->GetPointX(
i);
80 int nextRun = gIn->GetPointX(
i + 1);
83 x.push_back(lumi_edge + lumi_width / 2);
84 ex.push_back(lumi_width / 2);
86 auto point = gIn->GetPointY(
i),
error = gIn->GetErrorY(
i);
92 assert(
N ==
y.size() &&
N == ex.size() &&
N == ey.size());
93 TGraph* gOut =
new TGraphErrors(
N,
x.data(),
y.data(), ex.data(), ey.data());
94 gOut->SetTitle(gIn->GetTitle());
102 int N = hIn->GetNbinsX();
103 for (
int i = 1;
i <=
N; ++
i) {
104 auto nextRun = hIn->GetBinLowEdge(
i + 1);
110 edges.push_back(
operator()(nextRun));
112 auto content = hIn->GetBinContent(
i),
error = hIn->GetBinError(
i);
118 TString
name = hIn->GetName();
120 TH1* hOut =
new TH1F(
name, hIn->GetTitle(),
N,
edges.data());
121 for (
int i = 1;
i <=
N; ++
i) {
123 hOut->SetBinError(
i,
errors[
i - 1]);
137 const char* lumiAxisType)
140 lgd(0.7, 0.65, 0.97, 0.89,
"",
"NDC"),
143 lumiType(lumiAxisType) {
144 if (
JSON.count(
"CMSlabel"))
145 CMS = Form(
"#scale[1.1]{#bf{CMS}} #it{%s}",
JSON.get<
string>(
"CMSlabel").data());
147 if (
JSON.get_child(
"trends").count(
"TitleCanvas"))
148 lumi = Form(
"#scale[0.8]{%s}",
JSON.get_child(
"trends").get<
string>(
"TitleCanvas").
data());
152 if (
JSON.get_child(
"trends").count(
"plotUnit"))
153 plotUnit =
JSON.get_child(
"trends").get<
string>(
"plotUnit");
156 frame->GetYaxis()->SetTitleOffset(0.8);
157 frame->GetYaxis()->SetTickLength(0.01);
166 l.SetLineColor(kBlack);
167 l.SetLineStyle(kDashed);
168 l.DrawLine(0., 0.,
xmax, 0.);
172 c.SetRightMargin(0.015);
173 c.SetLeftMargin(0.07);
174 c.SetTopMargin(0.07);
177 pt::ptree
lines =
JSON.get_child(
"trends.lines");
179 auto line =
type.second.get_child_optional(
"line");
180 auto runs =
type.second.get_child_optional(
"runs");
186 auto style =
line->get_optional<
string>(
"style");
188 v->SetLineStyle(StyleParser(*
style));
190 auto color =
line->get_optional<
string>(
"color");
192 v->SetLineColor(ColorParser(*color));
194 auto width =
line->get_optional<
int>(
"width");
198 auto title =
line->get_optional<
string>(
"title");
203 auto currentRun =
run.second.get_value<
int>();
218 auto g =
dynamic_cast<TGraph*
>(
obj);
226 g->Draw(
"same" + drawOpt);
228 auto h =
dynamic_cast<TH1*
>(
obj);
231 h->Draw(
"same" + drawOpt);
237 TString
name =
c.GetName();
238 name.ReplaceAll(
"vs_run",
"vs_lumi");
244 lgd.AddEntry(
obj,
"", lgdOpt);
251 float l =
c.GetLeftMargin(),
t =
c.GetTopMargin(),
r =
c.GetRightMargin(),
lumiTextOffset = 0.2;
255 latex.SetTextFont(42);
257 latex.SetTextAlign(11);
260 latex.SetTextAlign(31);
264 latex.SetTextAlign(13);
268 pt::ptree
lines =
JSON.get_child(
"trends.lines");
270 auto labels =
type.second.get_child_optional(
"labels");
271 auto runs =
type.second.get_child_optional(
"runs");
275 auto runIt =
runs->begin();
276 auto labelIt =
labels->begin();
277 while (runIt !=
runs->end() && labelIt !=
labels->end()) {
278 auto currentRun = runIt->second.get_value<
int>();
279 auto label = labelIt->second.get_value<
string>();
282 auto posX =
l + (
lumi / totLumi) / (
l + 1 +
r) + 0.02;
294 c.SaveAs(Form(
"%s/%s.pdf",
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