Skip to content

Commit

Permalink
implement merge step for MTS validation
Browse files Browse the repository at this point in the history
  • Loading branch information
mmusich committed Jan 12, 2024
1 parent 7455ac4 commit 1dddfe9
Show file tree
Hide file tree
Showing 5 changed files with 167 additions and 453 deletions.
1 change: 1 addition & 0 deletions Alignment/OfflineValidation/bin/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
<bin name="SplitVmerge" file="SplitVmerge.cc,Options.cc" />
<bin name="Zmumumerge" file="Zmumumerge.cc,Options.cc" />
<bin name="DiMuonVmerge" file="DiMuonVmerge.cc,Options.cc" />
<bin name="MTSmerge" file="MTSmerge.cc,Options.cc" />
<bin name="haddws" file="haddws.C" />
<bin name="jetHtPlotter" file="jetHtPlotter.cc,JetHtPlotConfiguration.cc,Options.cc" />
87 changes: 87 additions & 0 deletions Alignment/OfflineValidation/bin/MTSmerge.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#include <cstdlib>
#include <string>
#include <iostream>
#include <numeric>
#include <functional>

#include "exceptions.h"
#include "toolbox.h"
#include "Options.h"

#include "boost/filesystem.hpp"
#include "boost/property_tree/ptree.hpp"
#include "boost/property_tree/json_parser.hpp"
#include "boost/optional.hpp"

#include "TString.h"
#include "TASImage.h"

#include "Alignment/OfflineValidation/macros/trackSplitPlot.h"
#include "Alignment/OfflineValidation/macros/trackSplitPlot.C"
#include "Alignment/OfflineValidation/interface/TkAlStyle.h"

using namespace std;
using namespace AllInOneConfig;

namespace pt = boost::property_tree;

int merge(int argc, char* argv[]) {
// parse the command line

Options options;
options.helper(argc, argv);
options.parser(argc, argv);

//Read in AllInOne json config
pt::ptree main_tree;
pt::read_json(options.config, main_tree);

pt::ptree alignments = main_tree.get_child("alignments");
pt::ptree validation = main_tree.get_child("validation");
pt::ptree global_style;
pt::ptree merge_style;

int iov = validation.count("IOV") ? validation.get<int>("IOV") : 1;
std::string rlabel = validation.count("customrighttitle") ? validation.get<std::string>("customrighttitle") : "";
rlabel = merge_style.count("Rlabel") ? merge_style.get<std::string>("Rlabel") : rlabel;
std::string cmslabel = merge_style.count("CMSlabel") ? merge_style.get<std::string>("CMSlabel") : "INTERNAL";
if (TkAlStyle::toStatus(cmslabel) == CUSTOM)
TkAlStyle::set(CUSTOM, NONE, cmslabel, rlabel);
else
TkAlStyle::set(TkAlStyle::toStatus(cmslabel), NONE, "", rlabel);

TString filesAndLabels;
for (const auto& childTree : alignments) {
// Print node name and its attributes
std::cout << "Node: " << childTree.first << std::endl;
for (const auto& attr : childTree.second) {
std::cout << " Attribute: " << attr.first << " = " << attr.second.data() << std::endl;
}

//std::cout << childTree.second.get<string>("file") << std::endl;
//std::cout << childTree.second.get<string>("title") << std::endl;
//std::cout << childTree.second.get<int>("color") << std::endl;
//std::cout << childTree.second.get<int>("style") << std::endl;

std::string toAdd = childTree.second.get<string>("file") +
Form("/MTSValidation_%s_%d.root=", childTree.first.c_str(), iov) +
childTree.second.get<string>("title") +
Form("|%i|%i,", childTree.second.get<int>("color"), childTree.second.get<int>("style"));
filesAndLabels += toAdd;
}

std::cout << "filesAndLabels: " << filesAndLabels << std::endl;

TkAlStyle::legendheader = "";
TkAlStyle::legendoptions = "all";
outliercut = -1.0;
//fillmatrix();
subdetector = "PIXEL";
makePlots(filesAndLabels, "./");

return EXIT_SUCCESS;
}

#ifndef DOXYGEN_SHOULD_SKIP_THIS
int main(int argc, char* argv[]) { return exceptions<merge>(argc, argv); }
#endif
13 changes: 7 additions & 6 deletions Alignment/OfflineValidation/macros/trackSplitPlot.C
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Table Of Contents
5. Place Legend
***********************************/

using namespace std;
#include "trackSplitPlot.h"
#include "Alignment/OfflineValidation/interface/TkAlStyle.h"

Expand Down Expand Up @@ -1869,12 +1870,12 @@ void makePlots(TString file,
Bool_t matrix[xsize][ysize]) {
setupcolors();
file.Remove(TString::kTrailing, ',');
int n = file.CountChar(',') + 1;
unsigned int n = file.CountChar(',') + 1;
TString *files = new TString[n];
TString *names = new TString[n];
vector<Color_t> tempcolors = colors;
vector<Style_t> tempstyles = styles;
for (int i = 0; i < n; i++) {
for (unsigned int i = 0; i < n; i++) {
TString thisfile = nPart(i + 1, file, ",");
int numberofpipes = thisfile.CountChar('|');
if (numberofpipes >= 0 && nPart(numberofpipes + 1, thisfile, "|").IsDigit()) {
Expand Down Expand Up @@ -1951,12 +1952,12 @@ void makePlots(TString file,
TString yvar) {
setupcolors();
file.Remove(TString::kTrailing, ',');
int n = file.CountChar(',') + 1;
unsigned int n = file.CountChar(',') + 1;
TString *files = new TString[n];
TString *names = new TString[n];
vector<Color_t> tempcolors = colors;
vector<Style_t> tempstyles = styles;
for (int i = 0; i < n; i++) {
for (unsigned int i = 0; i < n; i++) {
TString thisfile = nPart(i + 1, file, ",");
int numberofpipes = thisfile.CountChar('|');
if (numberofpipes >= 0 && nPart(numberofpipes + 1, thisfile, "|").IsDigit()) {
Expand Down Expand Up @@ -2008,12 +2009,12 @@ void makePlots(Int_t nFiles, TString *files, TString *names, TString directory)
void makePlots(TString file, TString misalignment, Double_t *values, Double_t *phases, TString directory) {
setupcolors();
file.Remove(TString::kTrailing, ',');
int n = file.CountChar(',') + 1;
unsigned int n = file.CountChar(',') + 1;
TString *files = new TString[n];
TString *names = new TString[n];
vector<Color_t> tempcolors = colors;
vector<Style_t> tempstyles = styles;
for (int i = 0; i < n; i++) {
for (unsigned int i = 0; i < n; i++) {
TString thisfile = nPart(i + 1, file, ",");
int numberofpipes = thisfile.CountChar('|');
if (numberofpipes >= 0 && nPart(numberofpipes + 1, thisfile, "|").IsDigit()) {
Expand Down
14 changes: 7 additions & 7 deletions Alignment/OfflineValidation/macros/trackSplitPlot.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ enum PlotType { ScatterPlot, Profile, Histogram, OrgHistogram, Resolution };
enum Statistic { Minimum, Maximum, Average, RMS };

const Double_t pi = TMath::Pi();
vector<Color_t> colors;
vector<Style_t> styles;
std::vector<Color_t> colors;
std::vector<Style_t> styles;
bool colorsset = false;
Int_t minrun = -1;
Int_t maxrun = -1;
Expand Down Expand Up @@ -67,7 +67,7 @@ Table Of Contents

#include "trackSplitPlot.h"

ofstream devnull("/dev/null");
std::ofstream devnull("/dev/null");
template <typename T>
T identity(T t) {
return t;
Expand All @@ -86,15 +86,15 @@ TCanvas *trackSplitPlot(Int_t nFiles,
Bool_t resolution = false,
Bool_t pull = false,
TString saveas = "",
ostream &summaryfile = devnull);
std::ostream &summaryfile = devnull);
TCanvas *trackSplitPlot(Int_t nFiles,
TString *files,
TString *names,
TString var,
Bool_t relative = false,
Bool_t pull = false,
TString saveas = "",
ostream &summaryfile = devnull);
std::ostream &summaryfile = devnull);
TCanvas *trackSplitPlot(TString file,
TString xvar,
TString yvar,
Expand All @@ -103,13 +103,13 @@ TCanvas *trackSplitPlot(TString file,
Bool_t resolution = false,
Bool_t pull = false,
TString saveas = "",
ostream &summaryfile = devnull);
std::ostream &summaryfile = devnull);
TCanvas *trackSplitPlot(TString file,
TString var,
Bool_t relative = false,
Bool_t pull = false,
TString saveas = "",
ostream &summaryfile = devnull);
std::ostream &summaryfile = devnull);
void placeholder(TString saveas = "", Bool_t wide = false);
void saveplot(TCanvas *c1, TString saveas);
void deleteCanvas(TObject *canvas);
Expand Down
Loading

0 comments on commit 1dddfe9

Please sign in to comment.