9 std::cout <<
"Comparing using: >" << namesandlabels <<
"<" << std::endl;
13 gStyle->SetOptStat(111110);
14 gStyle->SetOptTitle(0);
16 Target = TFile::Open((
outPath +
"/result.root").c_str(),
"RECREATE");
20 int formatCounter = 1;
22 TObjArray *nameandlabelpairs = namesandlabels.Tokenize(
",");
23 for (Int_t
i = 0;
i < nameandlabelpairs->GetEntries(); ++
i) {
24 TObjArray *aFileLegPair = TString(nameandlabelpairs->At(
i)->GetName()).Tokenize(
"=");
26 if (aFileLegPair->GetEntries() == 2) {
27 TFile *currentFile = TFile::Open(aFileLegPair->At(0)->GetName());
28 if (currentFile !=
nullptr && !currentFile->IsZombie()) {
30 if (currentFile->Get(
"TrackerOfflineValidation/Pixel/P1PXBBarrel_1")) {
32 }
else if (currentFile->Get(
"TrackerOfflineValidation/Pixel/TPBBarrel_1")) {
35 std::cout <<
"Unknown phase for file " << aFileLegPair->At(0)->GetName() << std::endl;
38 if (TString(aFileLegPair->At(1)->GetName()).Contains(
"|")) {
39 TObjArray *formatedLegendEntry = TString(aFileLegPair->At(1)->GetName()).Tokenize(
"|");
40 LabelList->Add(formatedLegendEntry->At(0));
41 if (formatedLegendEntry->GetEntries() > 1) {
42 theColors.push_back(atoi(formatedLegendEntry->At(1)->GetName()));
44 if (formatedLegendEntry->GetEntries() > 2)
45 theStyles.push_back(atoi(formatedLegendEntry->At(2)->GetName()) % 100);
49 std::cout <<
"if you give a \"|\" in the legend name you will need to at least give a int for the color" 60 std::cout <<
"Could not open: " << aFileLegPair->At(0)->GetName() << std::endl;
63 std::cout <<
"Please give file name and legend entry in the following form:\n" 64 <<
" filename1=legendentry1,filename2=legendentry2[|color[|style]]" << std::endl;
93 if (sourcelist->GetSize() == 0) {
94 std::cout <<
"Cowardly refuse to merge empty SourceList! " << std::endl;
98 TString
path((
char *)strstr(
target->GetPath(),
":"));
101 TFile *first_source = (TFile *)sourcelist->First();
102 TObjString *first_label = (TObjString *)labellist->First();
104 first_source->cd(
path);
105 TDirectory *current_sourcedir = gDirectory;
107 Bool_t
status = TH1::AddDirectoryStatus();
108 TH1::AddDirectory(kFALSE);
112 TIter nextkey(current_sourcedir->GetListOfKeys());
113 TKey *
key, *oldkey =
nullptr;
114 while ((
key = (TKey *)nextkey())) {
116 if (oldkey && !strcmp(oldkey->GetName(),
key->GetName()))
120 first_source->cd(
path);
121 TObject *
obj =
key->ReadObj();
123 auto itphase =
phases.begin();
124 int firstfilephase = *itphase;
128 TCanvas
c(
obj->GetName(),
obj->GetName());
132 if (strstr(
obj->ClassName(),
"TH2") !=
nullptr)
134 TH1 *h1 =
static_cast<TH1 *
>(
obj);
137 TObjArray *histarray =
new TObjArray;
145 h1->GetYaxis()->SetTitleOffset(1.5);
146 if (strstr(h1->GetName(),
"summary") !=
nullptr)
153 double max = h1->GetMaximum();
158 h1->GetYaxis()->SetTitle(((TString(h1->GetYaxis()->GetTitle()) +
" [#times 10^{") += (
int)
power) +
"}]");
162 int nPlots = sourcelist->GetSize();
163 double legendY = 0.80;
165 legendY -= 0.01 * (nPlots - 3);
171 std::cerr <<
"Warning: Huge legend!" << std::endl;
174 TLegend leg(0.17, legendY, 0.85, 0.88);
180 leg.AddEntry(h1, first_label->String().Data(),
"L");
181 leg.SetBorderSize(0);
182 leg.SetFillColor(10);
185 TFile *nextsource = (TFile *)sourcelist->After(first_source);
186 TObjString *nextlabel = (TObjString *)labellist->After(labellist->First());
191 bool wrongphase =
false;
194 if (firstfilephase != *itphase &&
path.Contains(
"TrackerOfflineValidation/Pixel")) {
200 nextsource->cd(
path);
201 key2 = (TKey *)gDirectory->GetListOfKeys()->FindObject(h1->GetName());
205 TH1 *h2 = (TH1 *)key2->ReadObj();
213 std::stringstream newname;
214 newname << h2->GetName() <<
q;
217 h2->SetName(newname.str().c_str());
218 if (strstr(newname.str().c_str(),
"summary") !=
nullptr)
219 h2->DrawClone(
"x0*He1sames");
221 h2->DrawClone(
"sames");
223 h2->DrawClone(
"sames");
224 leg.AddEntry(
c.FindObject(h2->GetName()), nextlabel->String().Data(),
"L");
225 histarray->Add(
c.FindObject(h2->GetName()));
227 }
else if (wrongphase) {
230 std::cerr <<
"Histogram " <<
path <<
" is not present in file " << nextsource->GetName() << std::endl;
233 nextsource = (TFile *)sourcelist->After(nextsource);
234 nextlabel = (TObjString *)labellist->After(nextlabel);
240 if (strstr(h1->GetName(),
"summary") ==
nullptr)
252 for (std::vector<std::string>::const_iterator lowlevelit =
lowestlevels.begin(),
254 lowlevelit != lowlevelitend;
256 if (
dirname.find(*lowlevelit) != std::string::npos)
261 TDirectory *newdir =
target->mkdir(
obj->GetName(),
obj->GetTitle());
270 std::cout <<
"Unknown object type, name: " <<
obj->GetName() <<
" title: " <<
obj->GetTitle() << std::endl;
277 TH1::AddDirectory(
status);
302 Double_t fStatsX1 = 0.85, fStatsX2 = 1., fStatsY1 = 0.77, fStatsY2 = 0.92;
306 Double_t
x1 = fStatsX1,
x2 = fStatsX2,
y1 = fStatsY1,
y2 = fStatsY2;
307 for (Int_t iH = 0; iH <
hists->GetEntries(); ++iH) {
308 TH1 *
h =
static_cast<TH1 *
>(
hists->At(iH));
311 TObject *statObj =
h->GetListOfFunctions()->FindObject(
"stats");
313 TPaveStats *
stats =
static_cast<TPaveStats *
>(statObj);
314 stats->SetLineColor(static_cast<TH1 *>(
hists->At(iH))->GetLineColor());
315 stats->SetTextColor(static_cast<TH1 *>(
hists->At(iH))->GetLineColor());
316 stats->SetFillColor(10);
322 y1 =
y2 - (fStatsY2 - fStatsY1);
327 x1 =
x2 - (fStatsX2 - fStatsX1);
329 x1 = fStatsX1,
x2 = fStatsX2,
y1 = fStatsY1,
y2 = fStatsY2;
340 Double_t
min = 100000;
341 Double_t
max = -100000;
342 for (Int_t iH = 0; iH <
hists->GetEntries(); ++iH) {
343 TH1 *
h =
static_cast<TH1 *
>(
hists->At(iH));
346 for (
int i = 1;
i <=
h->GetNbinsX(); ++
i) {
347 if (
h->GetBinContent(
i) +
h->GetBinError(
i) >
max)
348 max =
h->GetBinContent(
i) +
h->GetBinError(
i);
349 if (
h->GetBinContent(
i) -
h->GetBinError(
i) <
min)
350 min =
h->GetBinContent(
i) -
h->GetBinError(
i);
354 TH1 *h_first =
static_cast<TH1 *
>(
hists->At(0));
355 h_first->SetMaximum(
max * 1.3);
358 h_first->SetMinimum(
min);
360 h_first->SetMinimum(
min -
min * 0.1);
void nicePad(Int_t logx, Int_t logy)
std::vector< int > theColors
void SetMinMaxRange(TObjArray *hists)
void ColourStatsBoxes(TObjArray *hists)
static void set(const PublicationStatus status, const Era era=NONE, const TString customTitle="", const TString customRightTitle="")
std::vector< int > theStyles
static void drawStandardTitle()
static TString legendheader
key
prepare the HTCondor submission files and eventually submit them
std::vector< std::string > lowestlevels
std::vector< int > phases
void doComparison(TString namesandlabels, TString legendheader="", TString lefttitle="", TString righttitle="", PublicationStatus status=INTERNAL, bool bigtext=false)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
void MergeRootfile(TDirectory *target, TList *sourcelist, TList *labellist, bool bigtext)