19 int first = ceil(division);
20 int second = round(division);
21 cout <<
"createCanvas: " << picpercan <<
" : " << first <<
"/" << second << endl;
22 TCanvas* newCan =
new TCanvas();
23 newCan->Divide(second, first);
30 for (
int i = 0;
i < histos.size();
i++){
31 if (histos[
i]->GetMaximum() > oldMax){
32 oldMax = histos[
i]->GetMaximum();
48 std::vector<fileData> listOfFiles;
50 std::string parameter;
53 std::ifstream in(inputFile);
54 while(in >> fileName >> parameter >> scalingFactor){
55 listOfFiles.push_back(
fileData(fileName, parameter, scalingFactor));
60 int comp_multiFiles(std::string listOfFiles_File =
"inputFiles.txt",
int picpercan = 9) {
62 std::vector<TCanvas*> canvasses;
63 std::string filter =
"";
65 std::vector<fileData> fileNames =
GetFileNames(listOfFiles_File);
66 std::vector<TFile*>
files;
67 for (
auto name : fileNames){
68 files.push_back(
new TFile(
name.fFileName.c_str(),
"READ"));
71 auto maxScalingFactor = std::max_element(fileNames.begin(), fileNames.end(), [](
fileData const& lhs,
fileData const& rhs){
return lhs.
fScalingFactor < rhs.fScalingFactor;});
72 double maxScaling = maxScalingFactor->fScalingFactor;
74 std::cout <<
"Max Scaling Factor: " << maxScalingFactor->fScalingFactor << std::endl;
80 TIter
next(f->GetListOfKeys());
84 Int_t actualCanvas = 0;
87 while ((key = (TKey*)
next())) {
89 TObject *
obj = key->ReadObj();
91 std::cout << name << std::endl;
92 if (!name.Contains(filter.c_str()))
continue;
94 actualCanvas = TMath::Floor((
double)yy / picpercan);
95 actualPad = (yy % picpercan) + 1;
96 cout << yy <<
" : " << actualCanvas <<
"/" << actualPad << endl;
97 if (!(canvasses.size() > actualCanvas)){
98 cout <<
"New canvas" << endl;
101 canvasses[actualCanvas]->cd(actualPad);
105 if (obj->InheritsFrom(
"TH1")){
107 h->Scale(maxScaling/fileNames[0].fScalingFactor);
111 for (
int i = 1; i < files.size(); i++){
112 TH1* currentHisto = (TH1*)files[i]->
Get(name);
113 currentHisto->Scale(maxScaling/fileNames[i].fScalingFactor);
114 histos.push_back(currentHisto);
115 currentHisto->SetLineColor(i);
116 currentHisto->SetLineWidth(2);
120 TLegend* theLegend =
new TLegend(0.5,0.55,0.9,0.75);
121 histos[maxHisto]->Draw();
122 theLegend->AddEntry(histos[maxHisto], fileNames[maxHisto].fParameter.c_str(),
"l");
123 for (
int j = 0; j < histos.size(); j++){
125 histos[j]->Draw(
"same");
126 theLegend->AddEntry(histos[j], fileNames[j].fParameter.c_str(),
"l");
132 if (obj->InheritsFrom(
"TGraph")){
134 TLegend* aLegend =
new TLegend(0.5,0.55,0.9,0.75);
135 TGraph*
g = (TGraph*)obj;
136 g->SetMarkerStyle(6);
138 aLegend->AddEntry(g, fileNames[0].fParameter.c_str(),
"l");
139 std::vector<TGraph*>
graphs;
141 for (
int i = 1; i < files.size(); i++){
142 TGraph* currentGraph = (TGraph*)files[i]->
Get(name);
143 graphs.push_back(currentGraph);
144 currentGraph->SetMarkerStyle(6);
145 currentGraph->SetMarkerColor(i+1);
146 currentGraph->SetLineColor(i+1);
147 currentGraph->Draw(
"L");
148 aLegend->AddEntry(currentGraph, fileNames[i].fParameter.c_str(),
"l");
fileData(std::string fileName, std::string parameter, double scaling)
static T Sqrt(const T &x)
std::map< int, TString > files
int comp_multiFiles(std::string listOfFiles_File="inputFiles.txt", int picpercan=9)
TCanvas * createCanvas(int picpercan)
int GetMaxHisto(std::vector< TH1 * > histos)
file Get("FairBaseParSet")
std::vector< fileData > GetFileNames(std::string inputFile)