CMS 3D CMS Logo

Functions
PVmerge.cc File Reference
#include <cstdlib>
#include <string>
#include <iostream>
#include <numeric>
#include <functional>
#include "exceptions.h"
#include "toolbox.h"
#include "Options.h"
#include "boost/filesystem.hpp"
#include "boost/property_tree/ptree.hpp"
#include "boost/property_tree/json_parser.hpp"
#include "boost/optional.hpp"
#include "TString.h"
#include "TASImage.h"
#include "Alignment/OfflineValidation/interface/CompareAlignments.h"
#include "Alignment/OfflineValidation/macros/FitPVResiduals.C"
#include "Alignment/OfflineValidation/interface/TkAlStyle.h"

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 
int merge (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 134 of file PVmerge.cc.

References dir2webdir::argc, and GCPpyPlots::argv.

134 { return exceptions<merge>(argc, argv); }

◆ merge()

int merge ( int  argc,
char *  argv[] 
)

Definition at line 28 of file PVmerge.cc.

References dir2webdir::argc, GCPpyPlots::argv, CUSTOM, NONE, AlcaSiPixelAliHarvester0T_cff::options, TkAlStyle::set(), jetUpdater_cfi::sort, AlCaHLTBitMon_QueryRunRegistry::string, and TkAlStyle::toStatus().

28  {
29  // parse the command line
30 
32  options.helper(argc, argv);
33  options.parser(argc, argv);
34 
35  //Read in AllInOne json config
36  pt::ptree main_tree;
37  pt::read_json(options.config, main_tree);
38 
39  pt::ptree alignments = main_tree.get_child("alignments");
40  pt::ptree validation = main_tree.get_child("validation");
41  pt::ptree global_style;
42  pt::ptree merge_style;
43  global_style = main_tree.count("style") ? main_tree.get_child("style") : global_style;
44  merge_style = global_style.count("PV") && global_style.get_child("PV").count("merge")
45  ? global_style.get_child("PV").get_child("merge")
46  : global_style;
47 
48  //Read all configure variables and set default for missing keys
49  bool doMaps = validation.count("doMaps") ? validation.get<bool>("doMaps") : false;
50  bool stdResiduals = validation.count("stdResiduals") ? validation.get<bool>("stdResiduals") : true;
51  bool autoLimits = validation.count("autoLimits") ? validation.get<bool>("autoLimits") : false;
52 
53  float m_dxyPhiMax = validation.count("m_dxyPhiMax") ? validation.get<float>("m_dxyPhiMax") : 40;
54  float m_dzPhiMax = validation.count("m_dzPhiMax") ? validation.get<float>("m_dzPhiMax") : 40;
55  float m_dxyEtaMax = validation.count("m_dxyEtaMax") ? validation.get<float>("m_dxyEtaMax") : 40;
56  float m_dzEtaMax = validation.count("m_dzEtaMax") ? validation.get<float>("m_dzEtaMax") : 40;
57  float m_dxyPhiNormMax = validation.count("m_dxyPhiNormMax") ? validation.get<float>("m_dxyPhiNormMax") : 0.5;
58  float m_dzPhiNormMax = validation.count("m_dzPhiNormMax") ? validation.get<float>("m_dzPhiNormMax") : 0.5;
59  float m_dxyEtaNormMax = validation.count("m_dxyEtaNormMax") ? validation.get<float>("m_dxyEtaNormMax") : 0.5;
60  float m_dzEtaNormMax = validation.count("m_dzEtaNormMax") ? validation.get<float>("m_dzEtaNormMax") : 0.5;
61  float w_dxyPhiMax = validation.count("w_dxyPhiMax") ? validation.get<float>("w_dxyPhiMax") : 150;
62  float w_dzPhiMax = validation.count("w_dzPhiMax") ? validation.get<float>("w_dzPhiMax") : 150;
63  float w_dxyEtaMax = validation.count("w_dxyEtaMax") ? validation.get<float>("w_dxyEtaMax") : 150;
64  float w_dzEtaMax = validation.count("w_dzEtaMax") ? validation.get<float>("w_dzEtaMax") : 1000;
65  float w_dxyPhiNormMax = validation.count("w_dxyPhiNormMax") ? validation.get<float>("w_dxyPhiNormMax") : 1.8;
66  float w_dzPhiNormMax = validation.count("w_dzPhiNormMax") ? validation.get<float>("w_dzPhiNormMax") : 1.8;
67  float w_dxyEtaNormMax = validation.count("w_dxyEtaNormMax") ? validation.get<float>("w_dxyEtaNormMax") : 1.8;
68  float w_dzEtaNormMax = validation.count("w_dzEtaNormMax") ? validation.get<float>("w_dzEtaNormMax") : 1.8;
69  int iov = validation.count("IOV") ? validation.get<int>("IOV") : 1;
70  std::string rlabel = validation.count("customrighttitle") ? validation.get<std::string>("customrighttitle") : "";
71  rlabel = merge_style.count("Rlabel") ? merge_style.get<std::string>("Rlabel") : rlabel;
72  std::string cmslabel = merge_style.count("CMSlabel") ? merge_style.get<std::string>("CMSlabel") : "INTERNAL";
73  if (TkAlStyle::toStatus(cmslabel) == CUSTOM)
74  TkAlStyle::set(CUSTOM, NONE, cmslabel, rlabel);
75  else
76  TkAlStyle::set(TkAlStyle::toStatus(cmslabel), NONE, "", rlabel);
77 
78  //Create plots
79  // initialize the plot y-axis ranges
80  thePlotLimits->init(m_dxyPhiMax, // mean of dxy vs Phi
81  m_dzPhiMax, // mean of dz vs Phi
82  m_dxyEtaMax, // mean of dxy vs Eta
83  m_dzEtaMax, // mean of dz vs Eta
84  m_dxyPhiNormMax, // mean of dxy vs Phi (norm)
85  m_dzPhiNormMax, // mean of dz vs Phi (norm)
86  m_dxyEtaNormMax, // mean of dxy vs Eta (norm)
87  m_dzEtaNormMax, // mean of dz vs Eta (norm)
88  w_dxyPhiMax, // width of dxy vs Phi
89  w_dzPhiMax, // width of dz vs Phi
90  w_dxyEtaMax, // width of dxy vs Eta
91  w_dzEtaMax, // width of dz vs Eta
92  w_dxyPhiNormMax, // width of dxy vs Phi (norm)
93  w_dzPhiNormMax, // width of dz vs Phi (norm)
94  w_dxyEtaNormMax, // width of dxy vs Eta (norm)
95  w_dzEtaNormMax // width of dz vs Eta (norm)
96  );
97 
98  //Load file list in user defined order
99  std::vector<std::pair<std::string, pt::ptree>> alignmentsOrdered;
100  for (const auto& childTree : alignments) {
101  alignmentsOrdered.push_back(childTree);
102  }
103  std::sort(alignmentsOrdered.begin(),
104  alignmentsOrdered.end(),
105  [](const std::pair<std::string, pt::ptree>& left, const std::pair<std::string, pt::ptree>& right) {
106  return left.second.get<int>("index") < right.second.get<int>("index");
107  });
108  for (const auto& childTree : alignmentsOrdered) {
109  if (childTree.second.get<bool>("isMC")) {
110  loadFileList(
111  (childTree.second.get<string>("file") + Form("/PVValidation_%s_%d.root", childTree.first.c_str(), 1)).c_str(),
112  "PVValidation",
113  childTree.second.get<string>("title"),
114  childTree.second.get<int>("color"),
115  childTree.second.get<int>("style"));
116  } else {
117  loadFileList(
118  (childTree.second.get<string>("file") + Form("/PVValidation_%s_%d.root", childTree.first.c_str(), iov))
119  .c_str(),
120  "PVValidation",
121  childTree.second.get<string>("title"),
122  childTree.second.get<int>("color"),
123  childTree.second.get<int>("style"));
124  }
125  }
126 
127  //And finally fit
128  FitPVResiduals("", stdResiduals, doMaps, "", autoLimits, cmslabel, rlabel);
129 
130  return EXIT_SUCCESS;
131 }
static void set(const PublicationStatus status, const Era era=NONE, const TString customTitle="", const TString customRightTitle="")
Definition: TkAlStyle.cc:240
Definition: TkAlStyle.h:43
static PublicationStatus toStatus(std::string _status)
Definition: TkAlStyle.cc:48