Skip to content

Commit 90f0024

Browse files
committed
add Generic Validation as dataset validation tool
1 parent a3a7371 commit 90f0024

File tree

9 files changed

+455
-0
lines changed

9 files changed

+455
-0
lines changed

Alignment/OfflineValidation/bin/BuildFile.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<bin name="SplitVmerge" file="SplitVmerge.cc,Options.cc" />
1919
<bin name="Zmumumerge" file="Zmumumerge.cc,Options.cc" />
2020
<bin name="DiMuonVmerge" file="DiMuonVmerge.cc,Options.cc" />
21+
<bin name="GenericVmerge" file="GenericVmerge.cc,Options.cc" />
2122
<bin name="MTSmerge" file="MTSmerge.cc,Options.cc" />
2223
<bin name="haddws" file="haddws.C" />
2324
<bin name="jetHtPlotter" file="jetHtPlotter.cc,JetHtPlotConfiguration.cc,Options.cc" />
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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"
21+
#include "Alignment/OfflineValidation/interface/TkAlStyle.h"
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+
31+
Options options;
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/" : "";
56+
std::string toAdd = prefixToAdd + file + "/GenericValidation.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
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
import copy
2+
import os
3+
4+
def GenericV(config, validationDir):
5+
##List with all jobs
6+
jobs = []
7+
GenericVType = "single"
8+
9+
##List with all wished IOVs
10+
IOVs = []
11+
12+
##Start with single GenericV jobs
13+
if not GenericVType in config["validations"]["Generic"]:
14+
raise Exception("No 'single' key word in config for GenericV")
15+
16+
for singleName in config["validations"]["Generic"][GenericVType]:
17+
for IOV in config["validations"]["Generic"][GenericVType][singleName]["IOV"]:
18+
##Save IOV to loop later for merge jobs
19+
if not IOV in IOVs:
20+
IOVs.append(IOV)
21+
22+
for alignment in config["validations"]["Generic"][GenericVType][singleName]["alignments"]:
23+
##Work directory for each IOV
24+
workDir = "{}/GenericV/{}/{}/{}/{}".format(validationDir, GenericVType, singleName, alignment, IOV)
25+
26+
##Write local config
27+
local = {}
28+
local["output"] = "{}/{}/GenericV/{}/{}/{}/{}".format(config["LFS"], config["name"], GenericVType, alignment, singleName, IOV)
29+
local["alignment"] = copy.deepcopy(config["alignments"][alignment])
30+
local["validation"] = copy.deepcopy(config["validations"]["Generic"][GenericVType][singleName])
31+
local["validation"].pop("alignments")
32+
local["validation"]["IOV"] = IOV
33+
if "dataset" in local["validation"]:
34+
local["validation"]["dataset"] = local["validation"]["dataset"].format(IOV)
35+
if "goodlumi" in local["validation"]:
36+
local["validation"]["goodlumi"] = local["validation"]["goodlumi"].format(IOV)
37+
38+
##Write job info
39+
job = {
40+
"name": "GenericV_{}_{}_{}_{}".format(GenericVType, alignment, singleName, IOV),
41+
"dir": workDir,
42+
"exe": "cmsRun",
43+
"cms-config": "{}/src/Alignment/OfflineValidation/python/TkAlAllInOneTool/GenericV_cfg.py".format(os.environ["CMSSW_BASE"]),
44+
"run-mode": "Condor",
45+
"dependencies": [],
46+
"config": local,
47+
}
48+
49+
jobs.append(job)
50+
51+
##Do merge GenericV if wished
52+
if "merge" in config["validations"]["Generic"]:
53+
##List with merge jobs, will be expanded to jobs after looping
54+
mergeJobs = []
55+
GenericVType = "merge"
56+
57+
##Loop over all merge jobs/IOVs which are wished
58+
for mergeName in config["validations"]["Generic"][GenericVType]:
59+
for IOV in IOVs:
60+
##Work directory for each IOV
61+
workDir = "{}/GenericV/{}/{}/{}".format(validationDir, GenericVType, mergeName, IOV)
62+
63+
##Write job info
64+
local = {}
65+
66+
job = {
67+
"name": "GenericV_{}_{}_{}".format(GenericVType, mergeName, IOV),
68+
"dir": workDir,
69+
"exe": "GenericVmerge",
70+
"run-mode": "Condor",
71+
"dependencies": [],
72+
"config": local,
73+
}
74+
75+
for alignment in config["alignments"]:
76+
##Deep copy necessary things from global config
77+
local.setdefault("alignments", {})
78+
if alignment in config["validations"]["Generic"]["single"][mergeName]["alignments"]:
79+
local["alignments"][alignment] = copy.deepcopy(config["alignments"][alignment])
80+
local["validation"] = copy.deepcopy(config["validations"]["Generic"][GenericVType][mergeName])
81+
local["output"] = "{}/{}/GenericV/{}/{}/{}".format(config["LFS"], config["name"], GenericVType, mergeName, IOV)
82+
83+
##Loop over all single jobs
84+
for singleJob in jobs:
85+
##Get single job info and append to merge job if requirements fullfilled
86+
alignment, singleName, singleIOV = singleJob["name"].split("_")[2:]
87+
88+
if int(singleIOV) == IOV and singleName in config["validations"]["Generic"][GenericVType][mergeName]["singles"]:
89+
local["alignments"][alignment]["file"] = singleJob["config"]["output"]
90+
job["dependencies"].append(singleJob["name"])
91+
92+
mergeJobs.append(job)
93+
94+
jobs.extend(mergeJobs)
95+
96+
return jobs

0 commit comments

Comments
 (0)