File indexing completed on 2024-04-06 11:56:55
0001 #include <cstdlib>
0002 #include <string>
0003 #include <iostream>
0004 #include <numeric>
0005 #include <functional>
0006
0007 #include "exceptions.h"
0008 #include "toolbox.h"
0009 #include "Options.h"
0010
0011 #include "boost/filesystem.hpp"
0012 #include "boost/property_tree/ptree.hpp"
0013 #include "boost/property_tree/json_parser.hpp"
0014 #include "boost/optional.hpp"
0015
0016 #include "TString.h"
0017 #include "TASImage.h"
0018
0019 #include "Alignment/OfflineValidation/interface/CompareAlignments.h"
0020 #include "Alignment/OfflineValidation/macros/FitPVResiduals.C"
0021 #include "Alignment/OfflineValidation/interface/TkAlStyle.h"
0022
0023 using namespace std;
0024 using namespace AllInOneConfig;
0025
0026 namespace pt = boost::property_tree;
0027
0028 int merge(int argc, char* argv[]) {
0029
0030
0031 Options options;
0032 options.helper(argc, argv);
0033 options.parser(argc, argv);
0034
0035
0036 pt::ptree main_tree;
0037 pt::read_json(options.config, main_tree);
0038
0039 pt::ptree alignments = main_tree.get_child("alignments");
0040 pt::ptree validation = main_tree.get_child("validation");
0041 pt::ptree global_style;
0042 pt::ptree merge_style;
0043 global_style = main_tree.count("style") ? main_tree.get_child("style") : global_style;
0044 merge_style = global_style.count("PV") && global_style.get_child("PV").count("merge")
0045 ? global_style.get_child("PV").get_child("merge")
0046 : global_style;
0047
0048
0049 bool doMaps = validation.count("doMaps") ? validation.get<bool>("doMaps") : false;
0050 bool stdResiduals = validation.count("stdResiduals") ? validation.get<bool>("stdResiduals") : true;
0051 bool autoLimits = validation.count("autoLimits") ? validation.get<bool>("autoLimits") : false;
0052
0053 float m_dxyPhiMax = validation.count("m_dxyPhiMax") ? validation.get<float>("m_dxyPhiMax") : 40;
0054 float m_dzPhiMax = validation.count("m_dzPhiMax") ? validation.get<float>("m_dzPhiMax") : 40;
0055 float m_dxyEtaMax = validation.count("m_dxyEtaMax") ? validation.get<float>("m_dxyEtaMax") : 40;
0056 float m_dzEtaMax = validation.count("m_dzEtaMax") ? validation.get<float>("m_dzEtaMax") : 40;
0057 float m_dxyPtMax = validation.count("m_dxyPtMax") ? validation.get<float>("m_dxyPtMax") : 40;
0058 float m_dzPtMax = validation.count("m_dzPtMax") ? validation.get<float>("m_dzPtMax") : 40;
0059 float m_dxyPhiNormMax = validation.count("m_dxyPhiNormMax") ? validation.get<float>("m_dxyPhiNormMax") : 0.5;
0060 float m_dzPhiNormMax = validation.count("m_dzPhiNormMax") ? validation.get<float>("m_dzPhiNormMax") : 0.5;
0061 float m_dxyEtaNormMax = validation.count("m_dxyEtaNormMax") ? validation.get<float>("m_dxyEtaNormMax") : 0.5;
0062 float m_dzEtaNormMax = validation.count("m_dzEtaNormMax") ? validation.get<float>("m_dzEtaNormMax") : 0.5;
0063 float m_dxyPtNormMax = validation.count("m_dxyPtNormMax") ? validation.get<float>("m_dxyPtNormMax") : 0.5;
0064 float m_dzPtNormMax = validation.count("m_dzPtNormMax") ? validation.get<float>("m_dzPtNormMax") : 0.5;
0065 float w_dxyPhiMax = validation.count("w_dxyPhiMax") ? validation.get<float>("w_dxyPhiMax") : 150;
0066 float w_dzPhiMax = validation.count("w_dzPhiMax") ? validation.get<float>("w_dzPhiMax") : 150;
0067 float w_dxyEtaMax = validation.count("w_dxyEtaMax") ? validation.get<float>("w_dxyEtaMax") : 150;
0068 float w_dzEtaMax = validation.count("w_dzEtaMax") ? validation.get<float>("w_dzEtaMax") : 1000;
0069 float w_dxyPtMax = validation.count("w_dxyPtMax") ? validation.get<float>("w_dxyPtMax") : 150;
0070 float w_dzPtMax = validation.count("w_dzPtMax") ? validation.get<float>("w_dzPtMax") : 150;
0071 float w_dxyPhiNormMax = validation.count("w_dxyPhiNormMax") ? validation.get<float>("w_dxyPhiNormMax") : 1.8;
0072 float w_dzPhiNormMax = validation.count("w_dzPhiNormMax") ? validation.get<float>("w_dzPhiNormMax") : 1.8;
0073 float w_dxyEtaNormMax = validation.count("w_dxyEtaNormMax") ? validation.get<float>("w_dxyEtaNormMax") : 1.8;
0074 float w_dzEtaNormMax = validation.count("w_dzEtaNormMax") ? validation.get<float>("w_dzEtaNormMax") : 1.8;
0075 float w_dxyPtNormMax = validation.count("w_dxyPtNormMax") ? validation.get<float>("w_dxyPtNormMax") : 1.8;
0076 float w_dzPtNormMax = validation.count("w_dzPtNormMax") ? validation.get<float>("w_dzPtNormMax") : 1.8;
0077 int iov = validation.count("IOV") ? validation.get<int>("IOV") : 1;
0078 std::string rlabel = validation.count("customrighttitle") ? validation.get<std::string>("customrighttitle") : "";
0079 rlabel = merge_style.count("Rlabel") ? merge_style.get<std::string>("Rlabel") : rlabel;
0080 std::string cmslabel = merge_style.count("CMSlabel") ? merge_style.get<std::string>("CMSlabel") : "INTERNAL";
0081 if (TkAlStyle::toStatus(cmslabel) == CUSTOM)
0082 TkAlStyle::set(CUSTOM, NONE, cmslabel, rlabel);
0083 else
0084 TkAlStyle::set(TkAlStyle::toStatus(cmslabel), NONE, "", rlabel);
0085
0086
0087
0088 thePlotLimits->init(m_dxyPhiMax,
0089 m_dzPhiMax,
0090 m_dxyEtaMax,
0091 m_dzEtaMax,
0092 m_dxyPtMax,
0093 m_dzPtMax,
0094 m_dxyPhiNormMax,
0095 m_dzPhiNormMax,
0096 m_dxyEtaNormMax,
0097 m_dzEtaNormMax,
0098 m_dxyPtNormMax,
0099 m_dzPtNormMax,
0100 w_dxyPhiMax,
0101 w_dzPhiMax,
0102 w_dxyEtaMax,
0103 w_dzEtaMax,
0104 w_dxyPtMax,
0105 w_dzPtMax,
0106 w_dxyPhiNormMax,
0107 w_dzPhiNormMax,
0108 w_dxyEtaNormMax,
0109 w_dzEtaNormMax,
0110 w_dxyPtNormMax,
0111 w_dzPtNormMax
0112 );
0113
0114
0115 std::vector<std::pair<std::string, pt::ptree>> alignmentsOrdered;
0116 for (const auto& childTree : alignments) {
0117 alignmentsOrdered.push_back(childTree);
0118 }
0119 std::sort(alignmentsOrdered.begin(),
0120 alignmentsOrdered.end(),
0121 [](const std::pair<std::string, pt::ptree>& left, const std::pair<std::string, pt::ptree>& right) {
0122 return left.second.get<int>("index") < right.second.get<int>("index");
0123 });
0124 for (const auto& childTree : alignmentsOrdered) {
0125 if (childTree.second.get<bool>("isMC")) {
0126 loadFileList(
0127 (childTree.second.get<string>("file") + Form("/PVValidation_%s_%d.root", childTree.first.c_str(), 1)).c_str(),
0128 "PVValidation",
0129 childTree.second.get<string>("title"),
0130 childTree.second.get<int>("color"),
0131 childTree.second.get<int>("style"));
0132 } else {
0133 loadFileList(
0134 (childTree.second.get<string>("file") + Form("/PVValidation_%s_%d.root", childTree.first.c_str(), iov))
0135 .c_str(),
0136 "PVValidation",
0137 childTree.second.get<string>("title"),
0138 childTree.second.get<int>("color"),
0139 childTree.second.get<int>("style"));
0140 }
0141 }
0142
0143
0144 FitPVResiduals("", stdResiduals, doMaps, "", autoLimits, cmslabel, rlabel);
0145
0146 return EXIT_SUCCESS;
0147 }
0148
0149 #ifndef DOXYGEN_SHOULD_SKIP_THIS
0150 int main(int argc, char* argv[]) { return exceptions<merge>(argc, argv); }
0151 #endif