CMS 3D CMS Logo

Functions
DMRmerge.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 "Alignment/OfflineValidation/interface/CompareAlignments.h"
#include "Alignment/OfflineValidation/interface/PlotAlignmentValidation.h"
#include "Alignment/OfflineValidation/interface/TkAlStyle.h"

Go to the source code of this file.

Functions

std::string getVecTokenized (pt::ptree &tree, const std::string &name, const std::string &token)
 
int main (int argc, char *argv[])
 
int merge (int argc, char *argv[])
 

Function Documentation

◆ getVecTokenized()

std::string getVecTokenized ( pt::ptree &  tree,
const std::string &  name,
const std::string &  token 
)

Definition at line 27 of file DMRmerge.cc.

References Skims_PA_cff::name, alignCSCRings::s, AlCaHLTBitMon_QueryRunRegistry::string, and unpackBuffers-CaloStage2::token.

Referenced by merge().

27  {
28  std::string s;
29 
30  for (const auto& childTree : tree.get_child(name)) {
31  s += childTree.second.get_value<std::string>() + token;
32  }
33 
34  return s.substr(0, s.size() - token.size());
35 }
Definition: tree.py:1

◆ main()

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

Definition at line 137 of file DMRmerge.cc.

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

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

◆ merge()

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

Definition at line 37 of file DMRmerge.cc.

References dir2webdir::argc, GCPpyPlots::argv, CUSTOM, CompareAlignments::doComparison(), getVecTokenized(), TkAlStyle::legendheader, TkAlStyle::legendoptions, NONE, AlcaSiPixelAliHarvester0T_cff::options, mkLumiAveragedPlots::plotter, TkAlStyle::set(), jetUpdater_cfi::sort, AlCaHLTBitMon_QueryRunRegistry::string, TkAlStyle::toStatus(), and DMR_cfg::useFit.

Referenced by CaloTowersCreationAlgo::assignHitHcal(), edm::EventProcessor::beginJob(), edm::SubProcess::keepOnlyConsumedUnscheduledModules(), tmtt::HTrphi::mergedCell(), DDI::LogicalPart::mergedSpecificsV(), DDExpandedView::mergedSpecificsV(), DAClusterizerInZ::vertices(), DAClusterizerInZ_vect::vertices(), DAClusterizerInZT_vect::vertices(), and DAClusterizerInZ_vect::vertices_in_blocks().

37  {
38  // parse the command line
40  options.helper(argc, argv);
41  options.parser(argc, argv);
42 
43  //Read in AllInOne json config
44  pt::ptree main_tree;
45  pt::read_json(options.config, main_tree);
46 
47  pt::ptree alignments = main_tree.get_child("alignments");
48  pt::ptree validation = main_tree.get_child("validation");
49  pt::ptree global_style;
50  pt::ptree merge_style;
51  global_style = main_tree.count("style") ? main_tree.get_child("style") : global_style;
52  merge_style = global_style.count("DMR") && global_style.get_child("DMR").count("merge")
53  ? global_style.get_child("DMR").get_child("merge")
54  : global_style;
55 
56  //Read all configure variables and set default for missing keys
57  std::string methods = validation.count("methods") ? getVecTokenized(validation, "methods", ",") : "median,rmsNorm";
58  std::string curves = validation.count("curves") ? getVecTokenized(validation, "curves", ",") : "plain";
59  std::string rlabel = validation.count("customrighttitle") ? validation.get<std::string>("customrighttitle") : "";
60  rlabel = merge_style.count("Rlabel") ? merge_style.get<std::string>("Rlabel") : rlabel;
61  std::string cmslabel = merge_style.count("CMSlabel") ? merge_style.get<std::string>("CMSlabel") : "INTERNAL";
62 
63  int minimum = validation.count("minimum") ? validation.get<int>("minimum") : 15;
64 
65  bool useFit = validation.count("usefit") ? validation.get<bool>("usefit") : false;
66  bool bigText = validation.count("bigtext") ? validation.get<bool>("bigtext") : false;
67 
68  TkAlStyle::legendheader = validation.count("legendheader") ? validation.get<std::string>("legendheader") : "";
70  validation.count("legendoptions") ? getVecTokenized(validation, "legendoptions", " ") : "mean rms";
71  if (TkAlStyle::toStatus(cmslabel) == CUSTOM)
72  TkAlStyle::set(CUSTOM, NONE, cmslabel, rlabel);
73  else
74  TkAlStyle::set(TkAlStyle::toStatus(cmslabel), NONE, "", rlabel);
75 
76  std::vector<int> moduleids;
77  if (validation.count("moduleid")) {
78  for (const auto& childTree : validation.get_child("moduleid")) {
79  moduleids.push_back(childTree.second.get_value<int>());
80  }
81  }
82 
83  //Set configuration string for CompareAlignments class in user defined order
84  TString filesAndLabels;
85  std::vector<std::pair<std::string, pt::ptree>> alignmentsOrdered;
86  for (const auto& childTree : alignments) {
87  alignmentsOrdered.push_back(childTree);
88  }
89  std::sort(alignmentsOrdered.begin(),
90  alignmentsOrdered.end(),
91  [](const std::pair<std::string, pt::ptree>& left, const std::pair<std::string, pt::ptree>& right) {
92  return left.second.get<int>("index") < right.second.get<int>("index");
93  });
94  for (const auto& childTree : alignmentsOrdered) {
95  filesAndLabels +=
96  childTree.second.get<std::string>("file") + "/DMR.root=" + childTree.second.get<std::string>("title") + "|" +
97  childTree.second.get<std::string>("color") + "|" + childTree.second.get<std::string>("style") + " , ";
98  }
99  filesAndLabels.Remove(filesAndLabels.Length() - 3);
100 
101  //Do file comparisons
102  CompareAlignments comparer(main_tree.get<std::string>("output"));
103  if (TkAlStyle::toStatus(cmslabel) == CUSTOM)
104  comparer.doComparison(filesAndLabels, "", cmslabel, rlabel, CUSTOM);
105  else
106  comparer.doComparison(filesAndLabels, "", "", rlabel, TkAlStyle::toStatus(cmslabel));
107 
108  //Create plots in user defined order
109  gStyle->SetTitleH(0.07);
110  gStyle->SetTitleW(1.00);
111  gStyle->SetTitleFont(132);
112 
114 
115  for (const auto& childTree : alignmentsOrdered) {
116  plotter.loadFileList((childTree.second.get<std::string>("file") + "/DMR.root").c_str(),
117  childTree.second.get<std::string>("title"),
118  childTree.second.get<int>("color"),
119  childTree.second.get<int>("style"));
120  }
121 
122  plotter.setOutputDir(main_tree.get<std::string>("output"));
123  plotter.useFitForDMRplots(useFit);
124  plotter.setTreeBaseDir("TrackHitFilter");
125  plotter.plotDMR(methods, minimum, curves);
126  plotter.plotSurfaceShapes("coarse");
127  plotter.plotChi2((main_tree.get<std::string>("output") + "/" + "result.root").c_str());
128 
129  for (const int& moduleid : moduleids) {
130  plotter.residual_by_moduleID(moduleid);
131  }
132 
133  return EXIT_SUCCESS;
134 }
static void set(const PublicationStatus status, const Era era=NONE, const TString customTitle="", const TString customRightTitle="")
Definition: TkAlStyle.cc:240
static TString legendheader
Definition: TkAlStyle.h:91
static TString legendoptions
Definition: TkAlStyle.h:92
Class PlotAlignmentValidation Class used as the last step for Offline Track Validation tool...
std::string getVecTokenized(pt::ptree &tree, const std::string &name, const std::string &token)
Definition: DMRmerge.cc:27
Definition: TkAlStyle.h:43
static PublicationStatus toStatus(std::string _status)
Definition: TkAlStyle.cc:48