CMS 3D CMS Logo

DiMuonVmerge.cc
Go to the documentation of this file.
1 #include <cstdlib>
2 #include <string>
3 #include <iostream>
4 #include <numeric>
5 #include <functional>
6 
7 #include "exceptions.h"
8 #include "toolbox.h"
9 #include "Options.h"
10 
11 #include "boost/filesystem.hpp"
12 #include "boost/property_tree/ptree.hpp"
13 #include "boost/property_tree/json_parser.hpp"
14 #include "boost/optional.hpp"
15 
16 #include "TString.h"
17 #include "TASImage.h"
18 #include "TGraph.h"
19 
20 #include "Alignment/OfflineValidation/macros/loopAndPlot.C"
22 
23 using namespace std;
24 using namespace AllInOneConfig;
25 
26 namespace pt = boost::property_tree;
27 
28 int merge(int argc, char* argv[]) {
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 
42  TString filesAndLabels;
43  for (const auto& childTree : alignments) {
44  // Print node name and its attributes
45  // std::cout << "Node: " << childTree.first << std::endl;
46  // for (const auto& attr : childTree.second) {
47  // std::cout << " Attribute: " << attr.first << " = " << attr.second.data() << std::endl;
48  // }
49 
50  std::string file = childTree.second.get<string>("file");
51  std::cout << file << std::endl;
52  std::cout << childTree.second.get<string>("title") << std::endl;
53 
54  // Check if the file contains "/eos/cms/" and add the prefix accordingly
55  std::string prefixToAdd = file.find("/eos/cms/") != std::string::npos ? "root://eoscms.cern.ch/" : "";
57  prefixToAdd + file + "/DiMuonVertexValidation.root=" + childTree.second.get<string>("title") + ",";
58  filesAndLabels += toAdd;
59  }
60 
61  if (filesAndLabels.Length() > 0) {
62  filesAndLabels.Remove(filesAndLabels.Length() - 1); // Remove the last character
63  }
64 
65  std::cout << "filesAndLabels: " << filesAndLabels << std::endl;
66 
67  loopAndPlot(filesAndLabels);
68 
69  return EXIT_SUCCESS;
70 }
71 
72 #ifndef DOXYGEN_SHOULD_SKIP_THIS
73 int main(int argc, char* argv[]) { return exceptions<merge>(argc, argv); }
74 #endif
int merge(int argc, char *argv[])
Definition: DiMuonVmerge.cc:28
int main(int argc, char *argv[])
Definition: DiMuonVmerge.cc:73