Skip to content

Commit

Permalink
Merge pull request #13814 from hroskes/fix-consumes-alignment-80X
Browse files Browse the repository at this point in the history
Fix consumes for alignment validations
  • Loading branch information
cmsbuild committed Mar 28, 2016
2 parents 10d3272 + 8177566 commit 5e65373
Show file tree
Hide file tree
Showing 8 changed files with 864 additions and 892 deletions.
22 changes: 2 additions & 20 deletions Alignment/OfflineValidation/macros/PlotAlignmentValidation.C
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
//------------------------------------------------------------------------------
PlotAlignmentValidation::PlotAlignmentValidation(const char *inputFile,std::string legendName, int lineColor, int lineStyle)
{
setOutputDir("$TMPDIR");
setOutputDir(".");
setTreeBaseDir();
sourcelist = NULL;

Expand Down Expand Up @@ -91,6 +91,7 @@ void PlotAlignmentValidation::setOutputDir( std::string dir )
// we should check if this dir exsits...
std::cout <<"'"<< outputDir <<"' = "<< dir << std::endl;
outputDir = dir;
gSystem->mkdir(outputDir.data(), true);
}

//------------------------------------------------------------------------------
Expand Down Expand Up @@ -1048,25 +1049,6 @@ THStack* PlotAlignmentValidation::addHists(const TString& selection, const TStri
Long64_t nSel = 0;
if (histnamesfilled && histnames.size() > 0) {
nSel = (Long64_t)histnames.size();

//============================================================
//for compatibility - please remove this at some point
//it's now the end of August 2015
TH1 *firstHist = 0;
if (histnames[0].Contains("/")) {
firstHist = (TH1*)f->Get(histnames[0]);
} else {
TKey *histKey = f->FindKeyAny(histnames[0]);
if (histKey)
firstHist = (histKey ? static_cast<TH1*>(histKey->ReadObj()) : 0);
}
if (!firstHist) //then the validation was done with an older version of TrackerOfflineValidation
{ // ==> have to make the plots the old (long) way
histnamesfilled = false;
histnames.clear();
}
//============================================================

}
if (!histnamesfilled) {
// first loop on tree to find out which entries (i.e. modules) fulfill the selection
Expand Down
52 changes: 23 additions & 29 deletions Alignment/OfflineValidation/macros/trackSplitPlot.C
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ TCanvas *trackSplitPlot(Int_t nFiles,TString *files,TString *names,TString xvar,
const Int_t n = nFiles;

setTDRStyle();
gStyle->SetOptStat(0); //for histograms, the mean and rms are included in the legend if nFiles >= 2
//if nFiles == 1, there is no legend, so they're in the statbox
if ((type == Histogram || type == OrgHistogram) && nFiles == 1)
gStyle->SetOptStat(1110);
gStyle->SetOptStat(0); //for histograms, the mean and rms are included in the legend
//for a scatterplot, this is needed to show the z axis scale
//for non-pull histograms or when run number is on the x axis, this is needed so that 10^-? on the right is not cut off
if (type == ScatterPlot || (type == Histogram && !pull) || xvar == "runNumber")
Expand Down Expand Up @@ -461,35 +458,32 @@ TCanvas *trackSplitPlot(Int_t nFiles,TString *files,TString *names,TString xvar,
legend->AddEntry((TObject*)0,meansrmss[i],"");
}
}
if (n>=2)
if (legend->GetListOfPrimitives()->At(0) == 0)
{
if (legend->GetListOfPrimitives()->At(0) == 0)
{
stufftodelete->Clear();
deleteCanvas(c1);
return 0;
}
stufftodelete->Clear();
deleteCanvas(c1);
return 0;
}


c1->Update();
Double_t x1min = .98*gPad->GetUxmin() + .02*gPad->GetUxmax();
Double_t x2max = .02*gPad->GetUxmin() + .98*gPad->GetUxmax();
Double_t y1min = .98*gPad->GetUymin() + .02*gPad->GetUymax();
Double_t y2max = .02*gPad->GetUymin() + .98*gPad->GetUymax();
Double_t width = .4*(x2max-x1min);
Double_t height = (1./20)*legend->GetListOfPrimitives()->GetEntries()*(y2max-y1min);
if (type == Histogram || type == OrgHistogram)
{
width *= 2;
height /= 2;
legend->SetNColumns(2);
}
Double_t newy2max = placeLegend(legend,width,height,x1min,y1min,x2max,y2max);
maxp->GetYaxis()->SetRangeUser(gPad->GetUymin(),(newy2max-.02*gPad->GetUymin())/.98);

legend->SetFillStyle(0);
legend->Draw();
c1->Update();
Double_t x1min = .98*gPad->GetUxmin() + .02*gPad->GetUxmax();
Double_t x2max = .02*gPad->GetUxmin() + .98*gPad->GetUxmax();
Double_t y1min = .98*gPad->GetUymin() + .02*gPad->GetUymax();
Double_t y2max = .02*gPad->GetUymin() + .98*gPad->GetUymax();
Double_t width = .4*(x2max-x1min);
Double_t height = (1./20)*legend->GetListOfPrimitives()->GetEntries()*(y2max-y1min);
if (type == Histogram || type == OrgHistogram)
{
width *= 2;
height /= 2;
legend->SetNColumns(2);
}
Double_t newy2max = placeLegend(legend,width,height,x1min,y1min,x2max,y2max);
maxp->GetYaxis()->SetRangeUser(gPad->GetUymin(),(newy2max-.02*gPad->GetUymin())/.98);

legend->SetFillStyle(0);
legend->Draw();

if (saveas != "")
saveplot(c1,saveas);
Expand Down
Loading

0 comments on commit 5e65373

Please sign in to comment.