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;
25 cout << __func__ << endl;
58 objOut->SetLineColor(objIn->GetLineColor());
59 objOut->SetMarkerColor(objIn->GetMarkerColor());
60 objOut->SetFillColorAlpha(objIn->GetFillColor(), 0.2);
62 objOut->SetLineStyle(objIn->GetLineStyle());
63 objOut->SetMarkerStyle(objIn->GetMarkerStyle());
64 objOut->SetFillStyle(objIn->GetFillStyle());
66 objOut->SetLineWidth(objIn->GetLineWidth());
67 objOut->SetMarkerSize(objIn->GetMarkerSize());
73 vector<float>
x,
y, ex, ey;
75 for (
int i = 0;
i <
n - 1; ++
i) {
76 int currentRun = gIn->GetPointX(
i);
82 int nextRun = gIn->GetPointX(
i + 1);
85 x.push_back(lumi_edge + lumi_width / 2);
86 ex.push_back(lumi_width / 2);
88 auto point = gIn->GetPointY(
i),
error = gIn->GetErrorY(
i);
94 assert(
N ==
y.size() &&
N == ex.size() &&
N == ey.size());
95 TGraph* gOut =
new TGraphErrors(
N,
x.data(),
y.data(), ex.data(), ey.data());
96 gOut->SetTitle(gIn->GetTitle());
104 int N = hIn->GetNbinsX();
105 for (
int i = 1;
i <=
N; ++
i) {
106 auto nextRun = hIn->GetBinLowEdge(
i + 1);
112 edges.push_back(
operator()(nextRun));
114 auto content = hIn->GetBinContent(
i),
error = hIn->GetBinError(
i);
120 TString
name = hIn->GetName();
122 TH1* hOut =
new TH1F(
name, hIn->GetTitle(),
N,
edges.data());
123 for (
int i = 1;
i <=
N; ++
i) {
125 hOut->SetBinError(
i,
errors[
i - 1]);
139 const char* lumiAxisType)
142 lgd(0.7, 0.65, 0.97, 0.89,
"",
"NDC"),
145 lumiType(lumiAxisType) {
146 cout << __func__ << endl;
148 if (
JSON.count(
"CMSlabel"))
149 CMS = Form(
"#scale[1.1]{#bf{CMS}} #it{%s}",
JSON.get<
string>(
"CMSlabel").data());
151 if (
JSON.get_child(
"trends").count(
"TitleCanvas"))
152 lumi = Form(
"#scale[0.8]{%s}",
JSON.get_child(
"trends").get<
string>(
"TitleCanvas").
data());
156 if (
JSON.get_child(
"trends").count(
"plotUnit"))
157 plotUnit =
JSON.get_child(
"trends").get<
string>(
"plotUnit");
160 frame->GetYaxis()->SetTitleOffset(0.8);
161 frame->GetYaxis()->SetTickLength(0.01);
167 cout <<
"frame->GetXaxis()->GetLabelSize() = " <<
frame->GetXaxis()->GetLabelSize() << endl;
168 cout <<
"frame->GetXaxis()->GetTitleSize() = " <<
frame->GetXaxis()->GetTitleSize() << endl;
171 cout <<
"Plotting horizontal line at zero" << endl;
173 l.SetLineColor(kBlack);
174 l.SetLineStyle(kDashed);
175 l.DrawLine(0., 0.,
xmax, 0.);
179 c.SetRightMargin(0.015);
180 c.SetLeftMargin(0.07);
181 c.SetTopMargin(0.07);
184 pt::ptree
lines =
JSON.get_child(
"trends.lines");
186 auto line =
type.second.get_child_optional(
"line");
187 auto runs =
type.second.get_child_optional(
"runs");
193 auto style =
line->get_optional<
string>(
"style");
195 v->SetLineStyle(StyleParser(*
style));
197 auto color =
line->get_optional<
string>(
"color");
199 v->SetLineColor(ColorParser(*color));
201 auto width =
line->get_optional<
int>(
"width");
205 auto title =
line->get_optional<
string>(
"title");
210 auto currentRun =
run.second.get_value<
int>();
221 cout << __func__ << endl;
226 auto g =
dynamic_cast<TGraph*
>(
obj);
230 cout <<
" -> adding one point" << endl;
234 cout <<
" -> hole between end of graph and right edge" << endl;
236 g->Draw(
"same" + drawOpt);
238 auto h =
dynamic_cast<TH1*
>(
obj);
241 h->Draw(
"same" + drawOpt);
247 TString
name =
c.GetName();
248 name.ReplaceAll(
"vs_run",
"vs_lumi");
254 lgd.AddEntry(
obj,
"", lgdOpt);
258 cout << __func__ << endl;
263 float l =
c.GetLeftMargin(),
t =
c.GetTopMargin(),
r =
c.GetRightMargin(),
lumiTextOffset = 0.2;
267 latex.SetTextFont(42);
269 latex.SetTextAlign(11);
272 latex.SetTextAlign(31);
276 latex.SetTextAlign(13);
280 pt::ptree
lines =
JSON.get_child(
"trends.lines");
282 auto labels =
type.second.get_child_optional(
"labels");
283 auto runs =
type.second.get_child_optional(
"runs");
287 auto runIt =
runs->begin();
288 auto labelIt =
labels->begin();
289 while (runIt !=
runs->end() && labelIt !=
labels->end()) {
290 auto currentRun = runIt->second.get_value<
int>();
291 auto label = labelIt->second.get_value<
string>();
294 auto posX =
l + (
lumi / totLumi) / (
l + 1 +
r) + 0.02;
295 cout << currentRun << setw(20) <<
label << setw(20) <<
lumi << setw(20) <<
posX << endl;
306 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
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