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 
19 #include "Alignment/OfflineValidation/macros/loopAndPlot.C"
21 
22 using namespace std;
23 using namespace AllInOneConfig;
24 
25 namespace pt = boost::property_tree;
26 
27 int merge(int argc, char* argv[]) {
28  // parse the command line
29 
31  options.helper(argc, argv);
32  options.parser(argc, argv);
33 
34  //Read in AllInOne json config
35  pt::ptree main_tree;
36  pt::read_json(options.config, main_tree);
37 
38  pt::ptree alignments = main_tree.get_child("alignments");
39  pt::ptree validation = main_tree.get_child("validation");
40 
41  TString filesAndLabels;
42  for (const auto& childTree : alignments) {
43  // Print node name and its attributes
44  // std::cout << "Node: " << childTree.first << std::endl;
45  // for (const auto& attr : childTree.second) {
46  // std::cout << " Attribute: " << attr.first << " = " << attr.second.data() << std::endl;
47  // }
48 
49  std::string file = childTree.second.get<string>("file");
50  std::cout << file << std::endl;
51  std::cout << childTree.second.get<string>("title") << std::endl;
52 
53  // Check if the file contains "/eos/cms/" and add the prefix accordingly
54  std::string prefixToAdd = file.find("/eos/cms/") != std::string::npos ? "root://eoscms.cern.ch/" : "";
56  prefixToAdd + file + "/DiMuonVertexValidation.root=" + childTree.second.get<string>("title") + ",";
57  filesAndLabels += toAdd;
58  }
59 
60  if (filesAndLabels.Length() > 0) {
61  filesAndLabels.Remove(filesAndLabels.Length() - 1); // Remove the last character
62  }
63 
64  std::cout << "filesAndLabels: " << filesAndLabels << std::endl;
65 
66  loopAndPlot(filesAndLabels);
67 
68  return EXIT_SUCCESS;
69 }
70 
71 #ifndef DOXYGEN_SHOULD_SKIP_THIS
72 int main(int argc, char* argv[]) { return exceptions<merge>(argc, argv); }
73 #endif
int merge(int argc, char *argv[])
Definition: DiMuonVmerge.cc:27
int main(int argc, char *argv[])
Definition: DiMuonVmerge.cc:72