18 #include "boost/filesystem.hpp" 19 #include "boost/algorithm/string.hpp" 20 #include "boost/property_tree/ptree.hpp" 21 #include "boost/property_tree/json_parser.hpp" 22 #include "boost/optional.hpp" 23 #include "fmt/printf.h" 33 namespace fs = boost::filesystem;
34 namespace bc = boost::container;
40 namespace pt = boost::property_tree;
51 pt::read_json(
options.config, main_tree);
53 pt::ptree alignments = main_tree.get_child(
"alignments");
54 pt::ptree
validation = main_tree.get_child(
"validation");
55 pt::ptree
style = main_tree.get_child(
"style");
58 string outputdir = main_tree.get<
string>(
"output");
62 TString lumiInputFile =
style.get_child(
"trends").count(
"lumiInputFile")
63 ?
style.get_child(
"trends").get<
string>(
"lumiInputFile")
64 :
"Alignment/OfflineValidation/data/lumiPerRun_Run2.txt";
66 fs::path lumiFile = lumiInputFile.Data();
69 if (!fs::exists(lumiFile)) {
72 pathToLumiFile = lumiFile;
74 if (!fs::exists(pathToLumiFile)) {
75 cout <<
"ERROR: lumi-per-run file (" << lumiFile.string().data() <<
") not found!" << endl
76 <<
"Please check!" << endl;
79 cout <<
"Found lumi-per-run file: " << pathToLumiFile.string().data() << endl;
82 string lumiAxisType =
"recorded";
83 if (lumiInputFile.Contains(
"delivered"))
84 lumiAxisType =
"delivered";
86 std::cout << Form(
"NOTE: using %s luminosity!", lumiAxisType.data()) << std::endl;
88 for (
auto const &childTreeAlignments : alignments) {
89 fs::create_directory(childTreeAlignments.first.c_str());
90 for (
auto const &childTreeIOV :
validation.get_child(
"IOV")) {
91 int iov = childTreeIOV.second.get_value<
int>();
92 TString
file = childTreeAlignments.second.get<
string>(
"file");
95 childTreeAlignments.first.c_str(),
98 "./%s/PVValidation_%s_%d.root", childTreeAlignments.first.c_str(), childTreeAlignments.first.c_str(), iov);
99 if (!fs::exists(link_dir) && fs::exists(
input_dir))
104 string labels_to_add =
"";
107 labels_to_add +=
"_";
108 labels_to_add +=
label.second.get_value<
string>();
119 float convertUnit =
style.get_child(
"trends").count(
"convertUnit")
120 ?
style.get_child(
"trends").get<
float>(
"convertUnit")
127 vector<string>
variables{
"dxy_phi_vs_run",
"dxy_eta_vs_run",
"dz_phi_vs_run",
"dz_eta_vs_run"};
129 vector<string>
titles{
"of impact parameter in transverse plane as a function of azimuth angle",
130 "of impact parameter in transverse plane as a function of pseudorapidity",
131 "of impact parameter along z-axis as a function of azimuth angle",
132 "of impact parameter along z-axis as a function of pseudorapidity"};
134 vector<string> ytitles{
135 "of d_{xy}(#phi) [#mum]",
"of d_{xy}(#eta) [#mum]",
"of d_{z}(#phi) [#mum]",
"of d_{z}(#eta) [#mum]"};
137 auto f = TFile::Open(
pname.c_str());
142 Form(
"mean %s", ytitles[
i].
data()),
147 lumiAxisType.data());
151 Form(
"RMS %s", ytitles[
i].
data()),
156 lumiAxisType.data());
157 mean.lgd.SetHeader(
"p_{T} (track) > 3 GeV");
158 RMS.lgd.SetHeader(
"p_{T} (track) > 3 GeV");
160 for (
auto const &
alignment : alignments) {
161 bool fullRange =
true;
162 if (
style.get_child(
"trends").count(
"earlyStops")) {
163 for (
auto const &earlyStop :
style.get_child(
"trends.earlyStops")) {
164 if (earlyStop.second.get_value<
string>() ==
alignment.first)
169 TString gname =
alignment.second.get<
string>(
"title");
170 gname.ReplaceAll(
" ",
"_");
172 auto gMean = Get<TGraph>(fmt::sprintf(
"mean_%s_%s", gname.Data(),
variables[
i].data()).c_str());
173 auto hRMS = Get<TH1>(fmt::sprintf(
"RMS_%s_%s", gname.Data(),
variables[
i].data()).c_str());
177 TString gtitle =
alignment.second.get<
string>(
"title");
178 gMean->SetTitle(gtitle);
180 gMean->SetMarkerSize(0.6);
181 int color =
alignment.second.get<
int>(
"color");
183 gMean->SetMarkerColor(color);
184 gMean->SetLineColor(color);
185 gMean->SetMarkerStyle(
style);
186 gMean->SetMarkerSize(1.6);
188 hRMS->SetTitle(gtitle);
190 hRMS->SetMarkerSize(0.6);
191 hRMS->SetMarkerColor(color);
192 hRMS->SetLineColor(color);
193 hRMS->SetMarkerStyle(
style);
195 mean(gMean,
"PZ",
"p", fullRange);
196 RMS(hRMS,
"",
"p", fullRange);
206 #ifndef DOXYGEN_SHOULD_SKIP_THIS static const int endRun2018
static const std::array< std::string, 5 > titles
std::string fullPath() const
int main(int argc, char *argv[])
void multiRunPVValidation(bool useRMS=true, TString lumiInputFile="", bool doUnitTest=false)
static const float defaultConvertScale
int trends(int argc, char *argv[])
static std::string to_string(const XMLCh *ch)
static const char * normal
char data[epos_bytes_allocation]
static const int startRun2016