From: kkanaki Date: Thu, 14 Apr 2011 20:50:21 +0000 (+0000) Subject: - synchronized the overlay macro to the changes of the drawing one X-Git-Url: http://git.uio.no/git/?p=u%2Fmrichter%2FAliRoot.git;a=commitdiff_plain;h=38faad188d475761e8254898ff21c2d6a67d594a - synchronized the overlay macro to the changes of the drawing one (although draTHnSparse.C provides the same functionality) - changed the max Pt range according to the value defined in the CB task - added functionality to define the X axis range for overlaying histograms --- diff --git a/HLT/QA/tasks/macros/drawTHnSparse.C b/HLT/QA/tasks/macros/drawTHnSparse.C index b0c770766d5..37d7a754e2c 100644 --- a/HLT/QA/tasks/macros/drawTHnSparse.C +++ b/HLT/QA/tasks/macros/drawTHnSparse.C @@ -60,7 +60,7 @@ TString cutStudies( TString folder, THnSparse* htrackHLT, THnSparse* htrackOFF, float minCent, float maxCent ); void printStats(TH1D *hlt, TH1D *off); -void defineYaxisMax(TH1D *hlt, TH1D *off); +void defineYaxisMax(TH1D *h1, TH1D *h2); void printLegend(TH1D *hlt, TH1D *off); void plot2D( THnSparse* h, TText *hText, TString folder, double minEta, double maxEta, @@ -152,18 +152,18 @@ void drawTHnSparse(TString inputFile="HLT-OFFLINE-CentralBarrel-comparison.root" if(heventHLT->GetEntries()>0 || heventOFF->GetEntries()>0) plotEventQuantities(heventHLT,heventOFF,hText,folder); - int counter=0; + int counter = 0; // counts how many times the function cutStudies() is called // if more than once, then it creates and fills the canvas with the overlapping hlt distributions for the various sets of cuts TString s = ""; // eta mult pt DCAr DCAz TPCclus ITSclus vertexStatus |vertexZ| - s = cutStudies(folder, htrackHLT, htrackOFF, hText, -2, 2, 0, 2000, 0, 5, -10, 10, -10, 10, 0, 200, 0, 6, 2, 10, 0, 100); outputNames.push_back(s); counter++; + s = cutStudies(folder, htrackHLT, htrackOFF, hText, -2, 2, 0, 2000, 0, 10, -10, 10, -10, 10, 0, 200, 0, 6, 2, 10, 0, 100); outputNames.push_back(s); counter++; /* - s = cutStudies(folder, htrackHLT, htrackOFF, hText, -1, 1, 0, 2000, 0, 5, -10, 10, -10, 10, 0, 200, 0, 6, 2, 10, 0, 100); outputNames.push_back(s); counter++; - s = cutStudies(folder, htrackHLT, htrackOFF, hText, -1, 1, 0, 2000, 0, 5, -7, 7, -10, 10, 0, 200, 0, 6, 2, 10, 0, 100); outputNames.push_back(s); counter++; - s = cutStudies(folder, htrackHLT, htrackOFF, hText, -1, 1, 0, 2000, 0, 5, -7, 7, -7, 7, 0, 200, 0, 6, 2, 10, 0, 100); outputNames.push_back(s); counter++; - s = cutStudies(folder, htrackHLT, htrackOFF, hText, -1, 1, 0, 2000, 0.25, 5, -7, 7, -7, 7, 0, 200, 0, 6, 2, 10, 0, 100); outputNames.push_back(s); counter++; - s = cutStudies(folder, htrackHLT, htrackOFF, hText, -1, 1, 0, 2000, 0.25, 5, -3, 3, -3, 3, 0, 200, 0, 6, 2, 10, 0, 100); outputNames.push_back(s); counter++; + s = cutStudies(folder, htrackHLT, htrackOFF, hText, -1, 1, 0, 2000, 0, 10, -10, 10, -10, 10, 0, 200, 0, 6, 2, 10, 0, 100); outputNames.push_back(s); counter++; + s = cutStudies(folder, htrackHLT, htrackOFF, hText, -1, 1, 0, 2000, 0, 10, -7, 7, -10, 10, 0, 200, 0, 6, 2, 10, 0, 100); outputNames.push_back(s); counter++; + s = cutStudies(folder, htrackHLT, htrackOFF, hText, -1, 1, 0, 2000, 0, 10, -7, 7, -7, 7, 0, 200, 0, 6, 2, 10, 0, 100); outputNames.push_back(s); counter++; + s = cutStudies(folder, htrackHLT, htrackOFF, hText, -1, 1, 0, 2000, 0.25, 10, -7, 7, -7, 7, 0, 200, 0, 6, 2, 10, 0, 100); outputNames.push_back(s); counter++; + s = cutStudies(folder, htrackHLT, htrackOFF, hText, -1, 1, 0, 2000, 0.25, 10, -3, 3, -3, 3, 0, 200, 0, 6, 2, 10, 0, 100); outputNames.push_back(s); counter++; */ if(counter>=2){ @@ -627,20 +627,36 @@ void printStats(TH1D *hlt, TH1D *off){ st2->SetTextSize(7); st2->SetTextFont(8); st2->Draw(); + return; } -void defineYaxisMax(TH1D *hlt, TH1D *off){ - if(hlt->GetMaximum() > off->GetMaximum()) off->SetMaximum(1.1*hlt->GetMaximum()); - else hlt->SetMaximum(1.1*off->GetMaximum()); +void defineYaxisMax(TH1D *h1, TH1D *h2){ + //Y axis + if(h1->GetMaximum() > h2->GetMaximum()) h2->SetMaximum(1.1*h1->GetMaximum()); + else h1->SetMaximum(1.1*h2->GetMaximum()); + + h1->SetMinimum(0); + h2->SetMinimum(0); + + // X axis + double xmin, xmax; + if(h1->GetBinLowEdge(1) > h2->GetBinLowEdge(1)) xmin = h1->GetBinLowEdge(1); + else xmin = h2->GetBinLowEdge(1); + if(h1->GetBinLowEdge(h1->GetNbinsX()+1) > h2->GetBinLowEdge(h1->GetNbinsX()+1)) xmax = h1->GetBinLowEdge(h1->GetNbinsX()+1); + else xmax = h2->GetBinLowEdge(h2->GetNbinsX()+1); + + h2->SetAxisRange(xmin, xmax, "X"); + return; } void printLegend(TH1D *hlt, TH1D *off){ - TLegend *l = new TLegend(0.6,0.6,0.8,0.8); + TLegend *l = new TLegend(0.5,0.5,0.7,0.7); l->SetFillColor(10); l->SetLineColor(10); l->AddEntry(hlt, "HLT", "l"); l->AddEntry(off, "OFF", "l"); l->Draw("same"); + return; } TString fix1DTitle(const char* c){ diff --git a/HLT/QA/tasks/macros/overlayPlots.C b/HLT/QA/tasks/macros/overlayPlots.C index d718ab48de6..3010d2a9987 100644 --- a/HLT/QA/tasks/macros/overlayPlots.C +++ b/HLT/QA/tasks/macros/overlayPlots.C @@ -15,11 +15,12 @@ * @ingroup alihlt_qa * @author Kalliopi.Kanaki@ift.uib.no */ -void overlayPlots(string fi="files.txt", const char* option="HLT"/* or "OFF" */){ +void overlayPlots(const char* option="HLT"/* or "OFF" */, string fi="files.txt"){ gROOT->SetStyle("Plain"); gStyle->SetPalette(1); - + gStyle->SetTitleX(gStyle->GetPadLeftMargin()); + char filenames[100]; sprintf(filenames,"%s",fi.c_str()); ifstream in(filenames); @@ -33,7 +34,7 @@ void overlayPlots(string fi="files.txt", const char* option="HLT"/* or "OFF" */) in>>nr_textfile; if(!in.good()) break; - printf("Number of files: %d", nr_textfile); + printf("Number of files: %d\n", nr_textfile); const int nr_files = nr_textfile; TString file[nr_files]; @@ -51,14 +52,14 @@ void overlayPlots(string fi="files.txt", const char* option="HLT"/* or "OFF" */) } in.close(); - TCanvas *ca[nr_files]; - TFile *ff[nr_files]; - TPad *pad[12]; - TH1D *h[12][nr_files]; + TCanvas *ca; + TFile *ff; + TPad *pad; TH1D *g[nr_files]; TCanvas *d = new TCanvas("d",Form("%s cut studies",option),1100,900); d->Divide(3,3); + //d->Divide(3,2); TLegend *l = new TLegend(0.6,0.6,0.8,0.8); l->SetFillColor(10); @@ -66,26 +67,29 @@ void overlayPlots(string fi="files.txt", const char* option="HLT"/* or "OFF" */) char cut[100]; - for(int j=1; j<10; j++){ // not 13, last pad is empty (TODO) + //for(int j=1; j<7; j++){ + for(int j=1; j<10; j++){ for(int i=0; iIsZombie()){ + ff = TFile::Open(file[i].Data()); + if(!ff || ff->IsZombie()){ printf("Non-existent, corrupted or zombie file %s\n", file[i].Data()); return; } - ca[i] = (TCanvas*)ff[i]->GetObjectUnchecked("can1"); - if(!ca[i]){ + //ca = (TCanvas*)ff->GetObjectUnchecked("can0"); + ca = (TCanvas*)ff->GetObjectUnchecked("can3"); + if(!ca){ printf("Empty canvas in file %s.\n", file[i].Data()); continue; - } - - pad[j] = (TPad*)ca[i]->GetListOfPrimitives()->FindObject(Form("can1_%d",j)); - if(!pad[j]){ - printf("Empty pad in canvas %s.\n", ca[i]->GetName()); + } + //pad = (TPad*)ca->GetListOfPrimitives()->FindObject(Form("can0_%d",j)); + pad = (TPad*)ca->GetListOfPrimitives()->FindObject(Form("can3_%d",j)); + if(!pad){ + printf("Empty pad in canvas %s.\n", ca->GetName()); continue; } - g[i] =(TH1D*)pad[j]->FindObject(Form("fTrack%s_proj_%d",option,j-1)); + //g[i] =(TH1D*)pad->FindObject(Form("fEvent%s_proj_%d",option,j-1)); + g[i] =(TH1D*)pad->FindObject(Form("fTrack%s_proj_%d",option,j-1)); if(!g[i]){ printf("Empty histogram for i=%d, file %s.\n", i, file[i].Data()); continue; @@ -105,13 +109,14 @@ void overlayPlots(string fi="files.txt", const char* option="HLT"/* or "OFF" */) } if(i>0) printStats(g[i-1], g[i]); - ff[i]->Close(); + ff->Close(); sprintf( cut,"%s",cutnames[i].c_str() ); if(j==1) l->AddEntry(g[i],cut,"l"); else continue; } if(j==1) l->Draw("same"); } + return; } void printStats(TH1D *h1, TH1D *h2){ @@ -127,6 +132,7 @@ void printStats(TH1D *h1, TH1D *h2){ st2->SetTextColor(h2->GetLineColor()); st2->SetFillStyle(0); st2->Draw(); + return; } void defineYaxisMax(TH1D *h1, TH1D *h2){ @@ -145,4 +151,5 @@ void defineYaxisMax(TH1D *h1, TH1D *h2){ else xmax = h2->GetBinLowEdge(h2->GetNbinsX()+1); h2->SetAxisRange(xmin, xmax, "X"); + return; }