Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:56:53

0001 #include <cstdlib>
0002 #include <string>
0003 #include <iostream>
0004 #include <numeric>
0005 #include <functional>
0006 
0007 #include "exceptions.h"
0008 #include "toolbox.h"
0009 #include "Options.h"
0010 
0011 #include "boost/filesystem.hpp"
0012 #include "boost/property_tree/ptree.hpp"
0013 #include "boost/property_tree/json_parser.hpp"
0014 #include "boost/optional.hpp"
0015 
0016 #include "TString.h"
0017 #include "TASImage.h"
0018 #include "TGraph.h"
0019 
0020 #include "Alignment/OfflineValidation/macros/loopAndPlot.C"
0021 #include "Alignment/OfflineValidation/interface/TkAlStyle.h"
0022 
0023 using namespace std;
0024 using namespace AllInOneConfig;
0025 
0026 namespace pt = boost::property_tree;
0027 
0028 int merge(int argc, char* argv[]) {
0029   // parse the command line
0030 
0031   Options options;
0032   options.helper(argc, argv);
0033   options.parser(argc, argv);
0034 
0035   //Read in AllInOne json config
0036   pt::ptree main_tree;
0037   pt::read_json(options.config, main_tree);
0038 
0039   pt::ptree alignments = main_tree.get_child("alignments");
0040   pt::ptree validation = main_tree.get_child("validation");
0041 
0042   TString filesAndLabels;
0043   for (const auto& childTree : alignments) {
0044     // Print node name and its attributes
0045     // std::cout << "Node: " << childTree.first << std::endl;
0046     // for (const auto& attr : childTree.second) {
0047     //   std::cout << "  Attribute: " << attr.first << " = " << attr.second.data() << std::endl;
0048     // }
0049 
0050     std::string file = childTree.second.get<string>("file");
0051     std::cout << file << std::endl;
0052     std::cout << childTree.second.get<string>("title") << std::endl;
0053 
0054     // Check if the file contains "/eos/cms/" and add the prefix accordingly
0055     std::string prefixToAdd = file.find("/eos/cms/") != std::string::npos ? "root://eoscms.cern.ch/" : "";
0056     std::string toAdd =
0057         prefixToAdd + file + "/DiMuonVertexValidation.root=" + childTree.second.get<string>("title") + ",";
0058     filesAndLabels += toAdd;
0059   }
0060 
0061   if (filesAndLabels.Length() > 0) {
0062     filesAndLabels.Remove(filesAndLabels.Length() - 1);  // Remove the last character
0063   }
0064 
0065   std::cout << "filesAndLabels: " << filesAndLabels << std::endl;
0066 
0067   loopAndPlot(filesAndLabels);
0068 
0069   return EXIT_SUCCESS;
0070 }
0071 
0072 #ifndef DOXYGEN_SHOULD_SKIP_THIS
0073 int main(int argc, char* argv[]) { return exceptions<merge>(argc, argv); }
0074 #endif