11 #include "boost/regex.hpp" 12 #include "boost/filesystem.hpp" 13 #include "boost/algorithm/string.hpp" 14 #include "boost/container/vector.hpp" 15 #include "boost/property_tree/ptree.hpp" 16 #include "boost/property_tree/json_parser.hpp" 19 #include "Alignment/OfflineValidation/scripts/visualizationTracker.C" 20 #include "Alignment/OfflineValidation/macros/makeArrowPlots.C" 28 namespace pt = boost::property_tree;
29 namespace fs = boost::filesystem;
30 namespace bc = boost::container;
34 TString
outDir =
"outputDir/",
35 TString alignmentName =
"Alignment",
36 TString referenceName =
"Ideal") {
38 fs::create_directories(
outDir.Data());
40 TString modulesToPlot =
"all";
41 TString transDir =
outDir +
"/Translations";
42 TString rotDir =
outDir +
"/Rotations";
43 fs::create_directories(transDir.Data());
44 fs::create_directories(rotDir.Data());
46 bool plotOnlyGlobal = GCPoptions.count(
"plotOnlyGlobal") ? GCPoptions.get<
bool>(
"plotOnlyGlobal") :
false;
47 bool plotPng = GCPoptions.count(
"plotPng") ? GCPoptions.get<
bool>(
"plotPng") :
false;
48 bool makeProfilePlots = GCPoptions.count(
"makeProfilePlots") ? GCPoptions.get<
bool>(
"makeProfilePlots") :
true;
52 inFile, transDir, modulesToPlot, alignmentName, referenceName, plotOnlyGlobal, makeProfilePlots, 0);
56 vector<TString>
x{
"r",
"phi",
"z"};
57 vector<TString>
y{
"dr",
"dz",
"rdphi",
"dx",
"dy"};
58 vector<TString> xmean{
"x",
"y",
"z",
"r"};
60 trans->SetBranchUnits(
"x",
"cm");
61 trans->SetBranchUnits(
"y",
"cm");
62 trans->SetBranchUnits(
"z",
"cm");
63 trans->SetBranchUnits(
"r",
"cm");
64 trans->SetBranchUnits(
"phi",
"rad");
65 trans->SetBranchUnits(
"dx",
"#mum");
66 trans->SetBranchUnits(
"dy",
"#mum");
67 trans->SetBranchUnits(
"dz",
"#mum");
68 trans->SetBranchUnits(
"dr",
"#mum");
69 trans->SetBranchUnits(
"rdphi",
"#mum rad");
71 trans->SetBranchSF(
"dx", 10000);
72 trans->SetBranchSF(
"dy", 10000);
73 trans->SetBranchSF(
"dz", 10000);
74 trans->SetBranchSF(
"dr", 10000);
75 trans->SetBranchSF(
"rdphi", 10000);
78 trans->MakePlots(
x,
y, GCPoptions);
82 trans->SetPrintOption(
"png");
83 trans->MakePlots(
x,
y, GCPoptions);
86 trans->MakeTables(xmean,
y, GCPoptions);
90 inFile, rotDir, modulesToPlot, alignmentName, referenceName, plotOnlyGlobal, makeProfilePlots, 2);
94 vector<TString>
b{
"dalpha",
"dbeta",
"dgamma"};
96 rot->SetBranchUnits(
"z",
"cm");
97 rot->SetBranchUnits(
"r",
"cm");
98 rot->SetBranchUnits(
"phi",
"rad");
99 rot->SetBranchUnits(
"dalpha",
"mrad");
100 rot->SetBranchUnits(
"dbeta",
"mrad");
101 rot->SetBranchUnits(
"dgamma",
"mrad");
103 rot->SetBranchSF(
"dalpha", 1000);
104 rot->SetBranchSF(
"dbeta", 1000);
105 rot->SetBranchSF(
"dgamma", 1000);
108 rot->SetPrintOption(
"pdf");
109 rot->MakePlots(
x,
b, GCPoptions);
111 rot->SetPrintOption(
"png");
112 rot->MakePlots(
x,
b, GCPoptions);
126 int subdetector1 = 1;
127 int subdetector2 = 2;
133 float sclfmodulesizex = 1;
134 float sclfmodulesizey = 1;
135 float sclfmodulesizez = 1;
137 float piperadius = 2.25;
139 float pipexcoord = 0;
140 float pipeycoord = 0;
142 float linexcoord = 0;
143 float lineycoord = 0;
175 std::cout <<
" ----- GCP validation plots -----" << std::endl;
176 std::cout <<
" --- Digesting configuration" << std::endl;
179 pt::read_json(
options.config, main_tree);
181 pt::ptree alignments = main_tree.get_child(
"alignments");
182 pt::ptree
validation = main_tree.get_child(
"validation");
184 pt::ptree GCPoptions =
validation.get_child(
"GCP");
187 bool doUnitTest = GCPoptions.count(
"doUnitTest") ? GCPoptions.get<
bool>(
"doUnitTest") :
false;
190 bool useDefaultRange = GCPoptions.count(
"useDefaultRange") ? GCPoptions.get<
bool>(
"useDefaultRange") :
false;
191 if (useDefaultRange) {
193 pt::ptree default_range;
194 bc::vector<fs::path> possible_base_paths;
195 boost::split(possible_base_paths, std::getenv(
"CMSSW_SEARCH_PATH"), boost::is_any_of(
":"));
197 fs::path default_range_file =
"Alignment/OfflineValidation/data/GCP/GCP_defaultRange.json";
199 if (fs::exists(
path / default_range_file)) {
200 default_range_path =
path / default_range_file;
203 assert((fs::exists(default_range_path)) &&
204 "Check if 'Alignment/OfflineValidation/test/GCP_defaultRange.json' exists");
205 pt::read_json(default_range_path.c_str(), default_range);
207 for (pair<string, pt::ptree>
it : default_range) {
208 if (GCPoptions.count(
it.first) < 1) {
209 GCPoptions.put(
it.first,
it.second.data());
214 pt::ptree comAl = alignments.get_child(
"comp");
215 pt::ptree refAl = alignments.get_child(
"ref");
220 TString modulesToPlot =
"all";
221 TString alignmentName = comAl.get<
std::string>(
"title");
222 TString referenceName = refAl.get<
std::string>(
"title");
224 std::cout <<
" --- Running comparison script" << std::endl;
229 std::cout <<
" --- Running visualization script" << std::endl;
233 std::cout <<
" --- Skipping visualization script for unit test purpose" << std::endl;
236 std::cout <<
" --- Running arrow plot script" << std::endl;
238 TString arrowDir =
outDir +
"/ArrowPlots";
239 makeArrowPlots(
inFile.Data(), arrowDir.Data());
241 std::cout <<
" --- Finished running GCP.cpp" << std::endl;
245 #ifndef DOXYGEN_SHOULD_SKIP_THIS void comparisonScript(pt::ptree GCPoptions, TString inFile, TString outDir="outputDir/", TString alignmentName="Alignment", TString referenceName="Ideal")
int main(int argc, char *argv[])
int GCP(int argc, char *argv[])
def split(sequence, size)
void vizualizationScript(TString inFile, TString outDir, TString alignmentName, TString referenceName)