24 std::cout <<
"Usage of the program : GCPtrends [gcp_trend_config.json]" << std::endl;
25 std::cout <<
"gcp_trend_config.json : file with configuration in json format" << std::endl;
31 boost::property_tree::ptree config_root;
32 boost::property_tree::read_json(lumi_file, config_root);
38 bool usebadmodules = config_root.get<
bool>(
"usebadmodules",
true);
40 bool splitpixel = config_root.get<
bool>(
"splitpixel",
false);
42 Int_t trackerphase = config_root.get<
int>(
"trackerphase");
44 TString lumitype = config_root.get<
std::string>(
"trends.lumitype");
46 Int_t
firstrun = config_root.get<
int>(
"trends.firstrun");
48 Int_t
lastrun = config_root.get<
int>(
"trends.lastrun");
51 std::ifstream lumifile(lumibyrunfile);
55 std::map<TString, Int_t> comparison_map;
57 TString
path = comparison.first;
58 Int_t run_label = comparison.second.get_value<
int>();
60 comparison_map[
path] = run_label;
64 TFile *file_out = TFile::Open(
outputdir +
"GCPTrends.root",
"RECREATE");
70 std::map<Int_t, TString> Sublevel_Subdetector_Map = {
71 {1,
"PXB"}, {2,
"PXF"}, {3,
"TIB"}, {4,
"TID"}, {5,
"TOB"}, {6,
"TEC"}};
74 const std::map<Int_t, std::map<Int_t, Int_t>> Phase_Subdetector_Layers_Map = {
75 {0, {{1, 3}, {2, 2}}}, {1, {{1, 4}, {2, 3}}}, {2, {{1, 4}, {2, 12}}}};
81 for (
auto &sub_layer : Phase_Subdetector_Layers_Map.at(trackerphase)) {
82 for (
int iLayer = 1; iLayer <= sub_layer.second; iLayer++) {
84 if (sub_layer.first % 2 != 0) {
85 Sublevel_Subdetector_Map[100 * sub_layer.first + iLayer] =
86 Sublevel_Subdetector_Map[sub_layer.first] +
"Layer" + TString(
std::to_string(iLayer));
89 Sublevel_Subdetector_Map[100 * sub_layer.first + (1 - 1) * sub_layer.second + iLayer] =
90 Sublevel_Subdetector_Map[sub_layer.first] +
"Wheel" + TString(
std::to_string(iLayer)) +
"Side1";
91 Sublevel_Subdetector_Map[100 * sub_layer.first + (2 - 1) * sub_layer.second + iLayer] =
92 Sublevel_Subdetector_Map[sub_layer.first] +
"Wheel" + TString(
std::to_string(iLayer)) +
"Side2";
99 const std::map<Int_t, TString> Index_Variable_Map = {
100 {0,
"DX"}, {1,
"DY"}, {2,
"DZ"}, {3,
"DAlpha"}, {4,
"DBeta"}, {5,
"DGamma"}};
101 const std::map<TString, TString> Variable_Name_Map = {{
"DX",
"#Delta x"},
104 {
"DAlpha",
"#Delta #alpha"},
105 {
"DBeta",
"#Delta #beta"},
106 {
"DGamma",
"#Delta #gamma"}};
108 const std::map<Int_t, TString> Index_Estimator_Map = {{0,
"Mean"}, {1,
"Sigma"}};
109 const std::map<TString, TString> Estimator_Name_Map = {{
"Mean",
"#mu"}, {
"Sigma",
"#sigma"}};
112 const int convert_cm_to_mum = 10000;
113 const int convert_rad_to_mrad = 1000;
116 std::cout <<
" ==> " << comparison_map.size() <<
" GCPs to be processed in configuration file ... " << std::endl;
120 TH1::StatOverflows(kTRUE);
121 std::map<Int_t, std::map<Int_t, std::map<Int_t, TGraphErrors *>>> Graphs;
122 std::map<Int_t, std::map<Int_t, TH1D *>>
Histos;
123 for (
auto &
level : Sublevel_Subdetector_Map) {
124 for (
auto &
variable : Index_Variable_Map) {
128 for (
auto &
estimator : Index_Estimator_Map) {
135 for (
auto &path_run_map : comparison_map) {
136 TChain Events(
"alignTree",
"alignTree");
137 Events.Add(path_run_map.first);
141 std::cout <<
" --> processing GCPtree file: " << path_run_map.first << std::endl;
143 TTreeReader Reader(&Events);
146 TTreeReaderValue<Int_t>
id = {Reader,
"id"};
147 TTreeReaderValue<Int_t> badModuleQuality = {Reader,
"badModuleQuality"};
148 TTreeReaderValue<Int_t> inModuleList = {Reader,
"inModuleList"};
149 TTreeReaderValue<Int_t>
level = {Reader,
"level"};
150 TTreeReaderValue<Int_t> mid = {Reader,
"mid"};
151 TTreeReaderValue<Int_t> mlevel = {Reader,
"mlevel"};
152 TTreeReaderValue<Int_t> sublevel = {Reader,
"sublevel"};
153 TTreeReaderValue<Float_t>
x = {Reader,
"x"};
154 TTreeReaderValue<Float_t>
y = {Reader,
"y"};
155 TTreeReaderValue<Float_t>
z = {Reader,
"z"};
156 TTreeReaderValue<Float_t>
r = {Reader,
"r"};
157 TTreeReaderValue<Float_t>
phi = {Reader,
"phi"};
158 TTreeReaderValue<Float_t>
eta = {Reader,
"eta"};
159 TTreeReaderValue<Float_t>
alpha = {Reader,
"alpha"};
160 TTreeReaderValue<Float_t>
beta = {Reader,
"beta"};
161 TTreeReaderValue<Float_t>
gamma = {Reader,
"gamma"};
162 TTreeReaderValue<Float_t>
dx = {Reader,
"dx"};
163 TTreeReaderValue<Float_t>
dy = {Reader,
"dy"};
164 TTreeReaderValue<Float_t>
dz = {Reader,
"dz"};
165 TTreeReaderValue<Float_t>
dr = {Reader,
"dr"};
166 TTreeReaderValue<Float_t> dphi = {Reader,
"dphi"};
167 TTreeReaderValue<Float_t> dalpha = {Reader,
"dalpha"};
168 TTreeReaderValue<Float_t> dbeta = {Reader,
"dbeta"};
169 TTreeReaderValue<Float_t> dgamma = {Reader,
"dgamma"};
170 TTreeReaderValue<Float_t> du = {Reader,
"du"};
171 TTreeReaderValue<Float_t> dv = {Reader,
"dv"};
172 TTreeReaderValue<Float_t> dw = {Reader,
"dw"};
173 TTreeReaderValue<Float_t>
da = {Reader,
"da"};
174 TTreeReaderValue<Float_t>
db = {Reader,
"db"};
175 TTreeReaderValue<Float_t> dg = {Reader,
"dg"};
176 TTreeReaderValue<Int_t> useDetId = {Reader,
"useDetId"};
177 TTreeReaderValue<Int_t> detDim = {Reader,
"detDim"};
178 TTreeReaderArray<Int_t> identifiers = {Reader,
"identifiers"};
181 while (Reader.Next()) {
183 if (*badModuleQuality.Get())
186 Int_t sublevel_idx = *sublevel.Get();
188 Histos[sublevel_idx][0]->Fill(*
dx.Get() * convert_cm_to_mum);
189 Histos[sublevel_idx][1]->Fill(*
dy.Get() * convert_cm_to_mum);
190 Histos[sublevel_idx][2]->Fill(*
dz.Get() * convert_cm_to_mum);
191 Histos[sublevel_idx][3]->Fill(*dalpha.Get() * convert_rad_to_mrad);
192 Histos[sublevel_idx][4]->Fill(*dbeta.Get() * convert_rad_to_mrad);
193 Histos[sublevel_idx][5]->Fill(*dgamma.Get() * convert_rad_to_mrad);
195 if (splitpixel && sublevel_idx <= 2) {
198 if (sublevel_idx % 2 != 0)
199 layer_index = 100 * sublevel_idx + identifiers[2];
201 layer_index = 100 * sublevel_idx +
202 (identifiers[4] - 1) * Phase_Subdetector_Layers_Map.at(trackerphase).at(sublevel_idx) +
205 Histos[layer_index][0]->Fill(*
dx.Get() * convert_cm_to_mum);
206 Histos[layer_index][1]->Fill(*
dy.Get() * convert_cm_to_mum);
207 Histos[layer_index][2]->Fill(*
dz.Get() * convert_cm_to_mum);
208 Histos[layer_index][3]->Fill(*dalpha.Get() * convert_rad_to_mrad);
209 Histos[layer_index][4]->Fill(*dbeta.Get() * convert_rad_to_mrad);
210 Histos[layer_index][5]->Fill(*dgamma.Get() * convert_rad_to_mrad);
214 for (
auto &
level : Sublevel_Subdetector_Map) {
215 for (
auto &
variable : Index_Variable_Map) {
220 if (std::fabs(
mean) > Graphs[
level.first][
variable.first][0]->GetMaximum() && std::fabs(
mean) > 0.) {
226 if (sigma > Graphs[
level.first][
variable.first][1]->GetMaximum() && sigma > 0.) {
237 for (
auto &
level : Sublevel_Subdetector_Map) {
238 for (
auto &
variable : Index_Variable_Map) {
239 for (
auto &
estimator : Index_Estimator_Map) {
243 TString
units =
"mrad";
250 Estimator_Name_Map.at(
estimator.second) +
"_{" + Variable_Name_Map.at(
variable.second) +
"} [" +
260 trend.lgd.SetHeader(
level.second,
"center");
261 trend.lgd.AddEntry(Graphs[
level.first][
variable.first][
estimator.first],
"Average over all modules",
"pl");
static std::string to_string(const XMLCh *ch)
Container::value_type value_type
TString units(TString variable, Char_t axis)