From 58404acf873b5df6a2dd30c072adbe3085feff11 Mon Sep 17 00:00:00 2001 From: usarica Date: Mon, 31 Aug 2015 20:44:52 +0200 Subject: [PATCH 1/9] Merge Zmumutool --- .../TkAlAllInOneTool/zMuMuValidation.py | 7 +- .../zMuMuValidationTemplates.py | 26 +- .../OfflineValidation/test/zmumuValidate.ini | 127 +++ .../test/Macros/RooFit/FitSlices.cc | 8 +- .../test/Macros/RooFit/MultiHistoOverlap_Z.C | 805 +++++++++--------- .../test/Macros/RooFit/tdrstyle.C | 2 +- 6 files changed, 567 insertions(+), 408 deletions(-) create mode 100644 Alignment/OfflineValidation/test/zmumuValidate.ini diff --git a/Alignment/OfflineValidation/python/TkAlAllInOneTool/zMuMuValidation.py b/Alignment/OfflineValidation/python/TkAlAllInOneTool/zMuMuValidation.py index 29aad20e4b3cf..8714a4fc8a9a9 100644 --- a/Alignment/OfflineValidation/python/TkAlAllInOneTool/zMuMuValidation.py +++ b/Alignment/OfflineValidation/python/TkAlAllInOneTool/zMuMuValidation.py @@ -42,12 +42,15 @@ def createCrabCfg(self, path): return GenericValidationData.createCrabCfg(self, path, self.crabCfgBaseName) def getRepMap(self, alignment = None): + if alignment == None: + alignment = self.alignmentToValidate repMap = GenericValidationData.getRepMap(self, alignment) repMap.update({ "nEvents": self.general["maxevents"], -# "outputFile": "zmumuHisto.root" "outputFile": ("0_zmumuHisto.root" ",genSimRecoPlots.root" - ",FitParameters.txt") + ",FitParameters.txt"), + "eosdir": os.path.join(self.general["eosdir"], "%s/%s/%s" % (self.outputBaseName, self.name, alignment.name)), + "plotsdir": ".oO[datadir]Oo./%s/%s/%s/plots" % (self.outputBaseName, self.name, alignment.name), }) return repMap diff --git a/Alignment/OfflineValidation/python/TkAlAllInOneTool/zMuMuValidationTemplates.py b/Alignment/OfflineValidation/python/TkAlAllInOneTool/zMuMuValidationTemplates.py index ffc92ef89ed93..5efb9e10455fa 100644 --- a/Alignment/OfflineValidation/python/TkAlAllInOneTool/zMuMuValidationTemplates.py +++ b/Alignment/OfflineValidation/python/TkAlAllInOneTool/zMuMuValidationTemplates.py @@ -14,8 +14,8 @@ .oO[datasetDefinition]Oo. # process.load("Alignment.OfflineValidation..oO[dataset]Oo._cff") -process.load("Geometry.CMSCommonData.cmsIdealGeometryXML_cfi") -process.load("Geometry.CommonDetUnit.globalTrackingGeometry_cfi") +#process.load("Geometry.CMSCommonData.cmsIdealGeometryXML_cfi") +#process.load("Geometry.CommonDetUnit.globalTrackingGeometry_cfi") process.load("RecoMuon.DetLayers.muonDetLayerGeometry_cfi") process.load("Geometry.MuonNumbering.muonNumberingInitialization_cfi") process.load("RecoMuon.TrackingTools.MuonServiceProxy_cff") @@ -218,7 +218,6 @@ cwd=`pwd` cd .oO[CMSSW_BASE]Oo./src -# export SCRAM_ARCH=slc5_amd64_gcc462 export SCRAM_ARCH=.oO[SCRAM_ARCH]Oo. eval `scram runtime -sh` cd $cwd @@ -244,11 +243,6 @@ ls -lh . -source /afs/cern.ch/sw/lcg/external/gcc/4.8.1/x86_64-slc6/setup.sh -source /afs/cern.ch/sw/lcg/app/releases/ROOT/5.34.10/x86_64-slc6-gcc48-opt/root/bin/thisroot.sh - -# cd .oO[CMSSW_BASE]Oo./src/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit -# ln -fs .oO[workdir]Oo./0_zmumuHisto.root . cp .oO[CMSSW_BASE]Oo./src/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/CompareBiasZValidation.cc . cp .oO[CMSSW_BASE]Oo./src/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/Legend.h . cp .oO[CMSSW_BASE]Oo./src/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/FitMassSlices.cc . @@ -257,26 +251,24 @@ cp .oO[CMSSW_BASE]Oo./src/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/FitWithRooFit.cc . cp .oO[CMSSW_BASE]Oo./src/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/FitMass1D.cc . -root -q -b "CompareBiasZValidation.cc+(\\\"\\\")" - - -# mv BiasCheck.root .oO[workdir]Oo. +root -q -b -ls "CompareBiasZValidation.cc+(\\\"\\\")" -# cd .oO[workdir]Oo. cp .oO[CMSSW_BASE]Oo./src/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/tdrstyle.C . cp .oO[CMSSW_BASE]Oo./src/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/MultiHistoOverlap_.oO[resonance]Oo..C . -# ln -fs /afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN2/TMP_EM/ZMuMu/data/MC/BiasCheck_DYToMuMu_Summer11_TkAlZMuMu_IDEAL.root ./BiasCheck_Reference.root + if [[ .oO[zmumureference]Oo. == *store* ]]; then cmsStage -f .oO[zmumureference]Oo. BiasCheck_Reference.root; else ln -fs .oO[zmumureference]Oo. ./BiasCheck_Reference.root; fi -root -q -b MultiHistoOverlap_.oO[resonance]Oo..C +root -q -b -l MultiHistoOverlap_.oO[resonance]Oo..C -cmsMkdir /store/caf/user/$USER/.oO[eosdir]Oo. +cmsMkdir /store/caf/user/$USER/.oO[eosdir]Oo./plots/ for RootOutputFile in $(ls *root ) do cmsStage -f ${RootOutputFile} /store/caf/user/$USER/.oO[eosdir]Oo./ done +mkdir -p .oO[plotsdir]Oo. for PngOutputFile in $(ls *png ); do - rfcp ${PngOutputFile} .oO[datadir]Oo. + cmsStage -f ${PngOutputFile} /store/caf/user/$USER/.oO[eosdir]Oo./plots/ + rfcp ${PngOutputFile} .oO[plotsdir]Oo. done diff --git a/Alignment/OfflineValidation/test/zmumuValidate.ini b/Alignment/OfflineValidation/test/zmumuValidate.ini new file mode 100644 index 0000000000000..182549f165f72 --- /dev/null +++ b/Alignment/OfflineValidation/test/zmumuValidate.ini @@ -0,0 +1,127 @@ +############################################################################### +# general settings applying to all validations +# - one can override `jobmode` in the individual validation's section +[general] +jobmode = lxBatch, -q cmscaf1nd +#datadir = /afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/data/commonValidation/results/$USER/TkAlWeek2012/laEffect +# if you want your root files stored in a subdirectory on eos, put it here: +# eosdir = Test +# if you want your logs to be stored somewhere else, put it here: +# logdir = /afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/data/commonValidation/results/$USER/log + + +############################################################################### +# configuration of several alignments + +[alignment:alignment_defgt] +title=alignment_{Default GT} +globaltag = GR_P_V56 +condition SiStripBackPlaneCorrectionRcd = frontier://FrontierProd/CMS_CONDITIONS,SiStripBackPlaneCorrection_deco_GR10_v4_offline,deconvolution +condition SiStripLorentzAngleRcd = frontier://FrontierProd/CMS_CONDITIONS,SiStripLorentzAngleDeco_v3_offline,deconvolution +color = 633 +style = 1 + +[alignment:alignment_hp1394] +title=alignment_hp1394 +globaltag = GR_P_V56 +condition TrackerAlignmentRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN2/HIP/cayou/CMSSW_7_4_6_patch5/src/Alignment/HIPAlignmentAlgorithm/hp1394/alignments_iter20.db, Alignments +condition TrackerAlignmentErrorExtendedRcd = zeroAPE +condition SiStripBackPlaneCorrectionRcd = frontier://FrontierProd/CMS_CONDITIONS,SiStripBackPlaneCorrection_deco_GR10_v4_offline,deconvolution +condition SiStripLorentzAngleRcd = frontier://FrontierProd/CMS_CONDITIONS,SiStripLorentzAngleDeco_v3_offline,deconvolution +color = 633 +style = 1 + +[alignment:alignment_mp1819] +title=alignment_mp1819 +globaltag = GR_P_V56 +condition TrackerAlignmentRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/MP/MPproduction/mp1819/jobData/jobm/alignments_MP.db, Alignments +condition TrackerSurfaceDeformationRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/MP/MPproduction/mp1819/jobData/jobm/alignments_MP.db, Deformations +condition TrackerAlignmentErrorExtendedRcd = zeroAPE +condition SiStripBackPlaneCorrectionRcd = frontier://FrontierProd/CMS_CONDITIONS,SiStripBackPlaneCorrection_deco_GR10_v4_offline,deconvolution +condition SiStripLorentzAngleRcd = frontier://FrontierProd/CMS_CONDITIONS,SiStripLorentzAngleDeco_v3_offline,deconvolution +color = 633 +style = 1 + +[alignment:alignment_mp1820] +title=alignment_mp1820 +globaltag = GR_P_V56 +condition TrackerAlignmentRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/MP/MPproduction/mp1820/jobData/jobm/alignments_MP.db, Alignments +condition TrackerSurfaceDeformationRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/MP/MPproduction/mp1820/jobData/jobm/alignments_MP.db, Deformations +condition TrackerAlignmentErrorExtendedRcd = zeroAPE +condition SiStripBackPlaneCorrectionRcd = frontier://FrontierProd/CMS_CONDITIONS,SiStripBackPlaneCorrection_deco_GR10_v4_offline,deconvolution +condition SiStripLorentzAngleRcd = frontier://FrontierProd/CMS_CONDITIONS,SiStripLorentzAngleDeco_v3_offline,deconvolution +color = 633 +style = 1 + +[alignment:alignment_0] +title=alignment_{0} +globaltag = FT_R_53_V6C::All +condition TrackerAlignmentRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/MP/MPproduction/mp1183/jobData/jobm/alignments_MP.db, Alignments +condition TrackerAlignmentErrorExtendedRcd = zeroAPE +# `zeroAPE` is a shorthand for the following commented line +# condition TrackerAlignmentErrorExtendedRcd = frontier://FrontierProd/CMS_COND_31X_FROM21X, TrackerIdealGeometryErrors210_mc +condition SiStripConfObjectRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/MP/MPproduction/mp1025/SiStripShiftAndCrosstalk_GR10_v2_offline_BPCorrected.db,SiStripShiftAndCrosstalk_GR10_v2_offline_BPCorrected +condition SiStripLorentzAngleRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/MP/MPproduction/mp1025/SiStripLorentzAngleDeco_GR10_v1_offline_BPCorrected.db,SiStripLorentzAngleDeco_GR10_v1_offline_BPCorrected, deconvolution +condition SiPixelTemplateDBObjectRcd = frontier://FrontierProd/CMS_COND_31X_PIXEL,SiPixelTemplateDBObject_38T_v4_mc +color = 419 +style = 2 + +[alignment:alignment_1] +title=alignment_{1} +globaltag = GR_P_V56 +#condition TrackerAlignmentRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/MP/MPproduction/mp1206/jobData/jobm/alignments_MP.db, Alignments +#condition SiPixelTemplateDBObjectRcd = frontier://FrontierProd/CMS_COND_31X_PIXEL,SiPixelTemplateDBObject_38T_v4_mc +color = 633 +style = 1 + +[alignment:mp1260baseline] +globaltag = FT_R_53_V6C::All +condition TrackerAlignmentRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/MP/MPproduction/mp1260/jobData/jobm/alignments_MP.db, Alignments +condition TrackerAlignmentErrorExtendedRcd = zeroAPE +condition TrackerSurfaceDeformationRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/MP/MPproduction/mp1260/jobData/jobm/alignments_MP.db, Deformations +color = 600 +style = 2 + +[alignment:mp1260m1] +globaltag = FT_R_53_V6C::All +condition TrackerAlignmentRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/MP/MPproduction/mp1260/jobData/jobm1/alignments_MP.db, Alignments +condition TrackerAlignmentErrorExtendedRcd = zeroAPE +condition TrackerSurfaceDeformationRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/MP/MPproduction/mp1260/jobData/jobm1/alignments_MP.db, Deformations +color = 4 +style = 1 + + +############################################################################### +# configuration of individual validations + +[zmumu:zmumu_test] +etamaxneg = 2.4 +etaminneg = -2.4 +etamaxpos = 2.4 +etaminpos = -2.4 +maxevents = -1 +firstRun=251604 +lastRun=251642 +#cmssw = /afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/data/commonValidation/CMSSW_5_3_4_patch2 +dataset = /DoubleMuon/Run2015B-TkAlZMuMu-PromptReco-v1/ALCARECO + +[zmumu:Run2015B_ALCARECO_251604-251642] +etamaxneg = 2.4 +etaminneg = -2.4 +etamaxpos = 2.4 +etaminpos = -2.4 +maxevents = -1 +firstRun=251604 +lastRun=251642 +dataset = /DoubleMuon/Run2015B-TkAlZMuMu-PromptReco-v1/ALCARECO + + +############################################################################### +# configure which validation to run on which alignment + +[validation] +#compare Tracker: mp1260m1 1, mp1260baseline +#zmumu Run2015B_ALCARECO_251604-251642 : alignment_defgt +zmumu Run2015B_ALCARECO_251604-251642 : alignment_hp1394 +#zmumu Run2015B_ALCARECO_251604-251642 : alignment_mp1819 +#zmumu Run2015B_ALCARECO_251604-251642 : alignment_mp1820 diff --git a/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/FitSlices.cc b/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/FitSlices.cc index 59f4226699b31..66e807e31645d 100644 --- a/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/FitSlices.cc +++ b/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/FitSlices.cc @@ -4,6 +4,8 @@ #include "FitXslices.cc" #include "TFile.h" #include "TH1F.h" +#include "TH2F.h" +#include "TH3F.h" #include "TROOT.h" /** @@ -83,8 +85,8 @@ class FitSlices // std::cout<< "number of bins in z (and tempHisto) --> "< twoDprojection; for(unsigned int z=1;zGetZaxis()->SetRange(z,z); - TH2*tempHisto= (TH2*)histo3D->Project3D("xy"); + TAxis* ax_tmp = const_cast(histo3D->GetZaxis());ax_tmp->SetRange(z, z); + TH2* tempHisto= (TH2*)histo3D->Project3D("xy"); std::stringstream ss; ss << z; tempHisto->SetName(TString(tempHisto->GetName())+ss.str()); @@ -93,7 +95,7 @@ class FitSlices twoDprojection.insert(std::make_pair(z,tempHisto)); } unsigned int xbins, ybins; - TH3* rebinned3D= new TH3(TString(histo3D->GetName())+"_rebinned",histo3D->GetTitle(), + TH3* rebinned3D = (TH3*) new TH3F(TString(histo3D->GetName())+"_rebinned",histo3D->GetTitle(), xbins,histo3D->GetXaxis()->GetXmin(),histo3D->GetXaxis()->GetXmax(), ybins,histo3D->GetYaxis()->GetXmin(),histo3D->GetYaxis()->GetXmax(), zbins,histo3D->GetZaxis()->GetXmin(),histo3D->GetZaxis()->GetXmax() ); diff --git a/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/MultiHistoOverlap_Z.C b/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/MultiHistoOverlap_Z.C index 9ef1ab30714c0..8be3e5eae9d25 100644 --- a/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/MultiHistoOverlap_Z.C +++ b/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/MultiHistoOverlap_Z.C @@ -1,387 +1,422 @@ -{ +#include "TROOT.h" +#include "TH1F.h" +#include "TH1D.h" +#include "TF1.h" +#include "TMath.h" +#include "TNtuple.h" +#include "TLegend.h" +#include "TCanvas.h" +#include "TCutG.h" +#include "TFile.h" +#include "TString.h" +#include "TH2.h" +#include "TPad.h" +#include "TPaveText.h" +#include "tdrstyle.C" + + +using namespace ROOT::Math; + +void MultiHistoOverlap_Z(bool switchONfitEta = false, bool switchONfit = false){ gROOT->Reset(); - - #include "TH1F.h" - #include "TNtuple.h" - #include "TLegend.h" - #include "TCanvas.h" - #include "TCutG.h" - #include "TFile.h" - #include "TH2.h" - #include "TPad.h" - //#include "MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/tdrstyle.C" - - using namespace ROOT::Math; - - // gSystem->Load("libRooFit"); - // using namespace RooFit; - // preamble - TPaveText *cmsprel = new TPaveText(0.19, 0.95, 0.95, 0.99, "NDC"); - cmsprel->SetTextSize(0.03); - cmsprel->SetTextFont(42); - cmsprel->SetFillColor(0); - cmsprel->SetBorderSize(0); - cmsprel->SetMargin(0.01); - cmsprel->SetTextAlign(12); // align left - TString text = "CMS Preliminary 2012"; - cmsprel->AddText(0.01,0.5,text); - TString text2 = "#sqrt{s} = 8 TeV Run2012A TkAlZMuMu |#eta_{#mu}|<2.4"; - cmsprel->AddText(0.4, 0.6, text2); - - TFile *file1 = new TFile("./BiasCheck.root"); - TFile *file2 = new TFile("./BiasCheck_Reference.root"); - - bool switchONfit= false; - bool switchONfitEta= false; - - gROOT->LoadMacro("MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/tdrstyle.C"); - setTDRStyle(); - - TCanvas* c0 = new TCanvas("c0", "c0",50, 20, 800,600); - TCanvas* c1 = new TCanvas("c1", "c1",50, 20, 800,600); - TCanvas* c2 = new TCanvas("c2", "c2",50, 20, 800,600); - TCanvas* c3 = new TCanvas("c3", "c3",50, 20, 800,600); - TCanvas* c4 = new TCanvas("c4", "c4",50, 20, 800,600); - TCanvas* c5 = new TCanvas("c5", "c5",50, 20, 800,600); - TCanvas* c6 = new TCanvas("c6", "c6",50, 20, 800,600); - - - leg = new TLegend(0.65,0.8,0.93,0.9); // upper right - leg->SetBorderSize(1); - leg->SetFillColor(0); - leg->SetTextFont(42); - - //----------------- CANVAS C0 --------------// - c0->SetFillColor(0); - c0->cd(); - -// Mass VS muon phi plus ------------------------------- - histo1=(TH1D*)file1->Get("MassVsPhiPlus/allHistos/meanHisto"); - histo1->SetLineColor(1); - histo1->SetMarkerColor(1); - histo1->SetMarkerStyle(20); //r.c. - histo1->SetMarkerSize(1.5); - histo1->GetXaxis()->SetTitle("positive muon #phi (rad) "); - histo1->GetYaxis()->SetTitle("M_{#mu#mu} (GeV)"); - histo1->GetYaxis()->SetRangeUser(89.5,92.0); - histo1->GetXaxis()->SetRangeUser(-3.14,3.14); - histo1->Draw(); - leg->AddEntry(histo1,"this validation","L"); - //--- fit ---------------------------------------------- - TF1 * f1 = new TF1("cosinusoidal1", "[0]+[1]*cos(x+[2])", -3.14, 3.14); - f1->SetParameter(0, 90.5); - f1->SetParameter(1, 1.); - f1->SetParameter(2, 1.); - f1->SetLineColor(1); - if (switchONfit){ - histo1->Fit(f1,"R","same", -3.14, 3.14); - f1->Draw("same"); - } - - //---- 2------------------------------- - histo2=(TH1D*)file2->Get("MassVsPhiPlus/allHistos/meanHisto"); - histo2->SetLineColor(2); - histo2->SetMarkerColor(2); - histo2->Draw("same"); - leg->AddEntry(histo2,"reference","L"); - //--- fit ---------------------------------------------- - TF1 * f2 = new TF1("cosinusoidal2", "[0]+[1]*cos(x+[2])", -3.14, 3.14); - f2->SetParameter(0, 90.5); - f2->SetParameter(1, 1.); - f2->SetParameter(2, 1.); - f2->SetLineColor(2); - if (switchONfit){ - histo2->Fit(f2,"R","same", -3.14, 3.14); - f2->Draw("same"); - } - - - cmsprel->Draw("same"); - leg->Draw("same"); - - c0->SaveAs("MassVsPhiPlus_ALL.png"); - - //----------------- CANVAS C1 --------------// - c1->SetFillColor(0); - c1->cd(); - -// Mass VS muon phi minus ------------------------------- - histo1=(TH1D*)file1->Get("MassVsPhiMinus/allHistos/meanHisto"); - histo1->SetLineColor(1); - histo1->SetMarkerColor(1); - histo1->SetMarkerStyle(20); //r.c. - histo1->SetMarkerSize(1.5); //r.c. - histo1->GetXaxis()->SetTitle("negative muon #phi"); - histo1->GetYaxis()->SetTitle("M_{#mu#mu} (GeV)"); - histo1->GetYaxis()->SetRangeUser(89.5,92.0); - histo1->GetXaxis()->SetRangeUser(-3.14,3.14); - histo1->Draw(); - //--- fit ---------------------------------------------- - f1 = new TF1("cosinusoidal1", "[0]+[1]*cos(x+[2])", -3.14, 3.14); - f1->SetParameter(0, 90.5); - f1->SetParameter(1, 1.); - f1->SetParameter(2, 1.); - f1->SetLineColor(1); - if (switchONfit){ - histo1->Fit(f1,"R","same", -3.14, 3.14); - f1->Draw("same"); - } - - - //---- 2------------------------------- - histo2=(TH1D*)file2->Get("MassVsPhiMinus/allHistos/meanHisto"); - histo2->SetLineColor(2); - histo2->SetMarkerColor(2); - histo2->Draw("same"); - //--- fit ---------------------------------------------- - f2 = new TF1("cosinusoidal2", "[0]+[1]*cos(x+[2])", -3.14, 3.14); - f2->SetParameter(0, 90.5); - f2->SetParameter(1, 1.); - f2->SetParameter(2, 1.); - f2->SetLineColor(2); - if (switchONfit){ - histo2->Fit(f2,"R","same", -3.14, 3.14); - f2->Draw("same"); - } - - cmsprel->Draw("same"); - leg->Draw("same"); - - c1->SaveAs("MassVsPhiMinus_ALL.png"); - - //----------------- CANVAS C2 --------------// - c2->SetFillColor(0); - c2->cd(); - -// Mass VS muon eta plus ------------------------------- - histo1=(TH1D*)file1->Get("MassVsEtaPlus/allHistos/meanHisto"); - histo1->SetLineColor(1); - histo1->SetMarkerColor(1); - histo1->SetMarkerStyle(20); //r.c. - histo1->SetMarkerSize(1.5); //r.c. - histo1->GetXaxis()->SetTitle("positive muon #eta"); - histo1->GetYaxis()->SetTitle("M_{#mu#mu} (GeV)"); - histo1->GetYaxis()->SetRangeUser(89.5,92.0); - histo1->GetXaxis()->SetRangeUser(-2.6,2.6); - histo1->Draw(); - //--- fit ---------------------------------------------- - f1 = new TF1("linear1", "[0]+[1]*x", -2.6, 2.6); - f1->SetParameter(0, 90.5); - f1->SetParameter(1, 1.); - f1->SetLineColor(1); - if (switchONfitEta){ - histo1->Fit(f1,"R","same", -2.6, 2.6); - f1->Draw("same"); - } - - - //---- 2------------------------------- - histo2=(TH1D*)file2->Get("MassVsEtaPlus/allHistos/meanHisto"); - histo2->SetLineColor(2); - histo2->SetMarkerColor(2); - histo2->Draw("same"); - //--- fit ---------------------------------------------- - f2 = new TF1("linear2", "[0]+[1]*x", -2.6, 2.6); - f2->SetParameter(0, 90.5); - f2->SetParameter(1, 1.); - f2->SetLineColor(2); - if (switchONfitEta){ - histo2->Fit(f2,"R","same", -2.6, 2.6); - f2->Draw("same"); - } - - cmsprel->Draw("same"); - leg->Draw("same"); - - c2->SaveAs("MassVsEtaPlus_ALL.png"); - - //----------------- CANVAS C3 --------------// - c3->SetFillColor(0); - c3->cd(); - -// Mass VS muon eta minus ------------------------------- - histo1=(TH1D*)file1->Get("MassVsEtaMinus/allHistos/meanHisto"); - histo1->SetLineColor(1); - histo1->SetMarkerColor(1); - histo1->SetMarkerStyle(20); - histo1->SetMarkerSize(1.5); - histo1->GetXaxis()->SetTitle("negative muon #eta"); - histo1->GetYaxis()->SetTitle("M_{#mu#mu} (GeV)"); - histo1->GetYaxis()->SetRangeUser(89.5,92.0); - histo1->GetXaxis()->SetRangeUser(-2.6,2.6); - histo1->Draw(); - //--- fit ---------------------------------------------- - f1 = new TF1("linear1", "[0]+[1]*x", -2.6, 2.6); - f1->SetParameter(0, 0.); - f1->SetParameter(1, 0.); - f1->SetLineColor(1); - if (switchONfitEta){ - histo1->Fit(f1,"R","same", -2.6, 2.6); - f1->Draw("same"); - } - - - //---- 2------------------------------- - histo2=(TH1D*)file2->Get("MassVsEtaMinus/allHistos/meanHisto"); - histo2->SetLineColor(2); - histo2->SetMarkerColor(2); - histo2->Draw("same"); - //--- fit ---------------------------------------------- - f2 = new TF1("linear2", "[0]+[1]*x", -2.6, 2.6); - f2->SetParameter(0, 0.); - f2->SetParameter(1, 0.); - f2->SetLineColor(2); - if (switchONfitEta){ - histo2->Fit(f2,"R","same", -2.6, 2.6); - f2->Draw("same"); - } - - cmsprel->Draw("same"); - leg->Draw("same"); - - c3->SaveAs("MassVsEtaMinus_ALL.png"); - - //----------------- CANVAS C4 --------------// - c4->SetFillColor(0); - c4->cd(); - -// Mass VS muon eta plus - eta minus ------------------------------- - histo1=(TH1D*)file1->Get("MassVsEtaPlusMinusDiff/allHistos/meanHisto"); - histo1->SetLineColor(1); - histo1->SetMarkerColor(1); - histo1->SetMarkerStyle(20); - histo1->SetMarkerSize(1.5); - histo1->GetXaxis()->SetTitle("#eta pos - #eta neg"); - histo1->GetYaxis()->SetTitle("M_{#mu#mu} (GeV)"); - histo1->GetYaxis()->SetRangeUser(89.5,92.0); - histo1->GetXaxis()->SetRangeUser(-3.2,3.2); - histo1->Draw(); - //--- fit ---------------------------------------------- - f1 = new TF1("linear1", "[0]+[1]*x", -3.2, 3.2); - f1->SetParameter(0, 0.); - f1->SetParameter(1, 0.); - f1->SetLineColor(1); - if (switchONfitEta){ - histo1->Fit(f1,"R","same", -3.2, 3.2); - f1->Draw("same"); - } - - - //---- 2------------------------------- - histo2=(TH1D*)file2->Get("MassVsEtaPlusMinusDiff/allHistos/meanHisto"); - histo2->SetLineColor(2); - histo2->SetMarkerColor(2); - histo2->Draw("same"); - //--- fit ---------------------------------------------- - f2 = new TF1("linear1", "[0]+[1]*x", -3.2, 3.2); - f2->SetParameter(0, 0.); - f2->SetParameter(1, 0.); - f2->SetLineColor(2); - if (switchONfitEta){ - histo2->Fit(f2,"R","same", -3.2, 3.2); - f2->Draw("same"); - } - - cmsprel->Draw("same"); - leg->Draw("same"); - - c4->SaveAs("MassVsDeltaEta_ALL.png"); - - - //----------------- CANVAS C5 --------------// - c5->SetFillColor(0); - c5->cd(); - -// Mass VS muon cos(theta_CS) ------------------------------- - histo1=(TH1D*)file1->Get("MassVsCosThetaCS/allHistos/meanHisto"); - histo1->SetLineColor(1); - histo1->SetMarkerColor(1); - histo1->SetMarkerStyle(20); - histo1->SetMarkerSize(1.5); - histo1->GetXaxis()->SetTitle("cos#theta_{CS}"); - histo1->GetYaxis()->SetTitle("M_{#mu#mu} (GeV)"); - histo1->GetYaxis()->SetRangeUser(89.5,92); - histo1->GetXaxis()->SetRangeUser(-1.1,1.1); - histo1->Draw(); - //--- fit ---------------------------------------------- - f1 = new TF1("cosinusoidal1", "[0]+[1]*cos(x+[2])", -1.1, 1.1); - f1->SetParameter(0, 90.5); - f1->SetParameter(1, 1.); - f1->SetParameter(2, 1.); - f1->SetLineColor(6); - if (switchONfit){ - histo1->Fit(f1,"R","same", -1.1, 1.1); - f1->Draw("same"); - } - - - //---- 2------------------------------- - histo2=(TH1D*)file2->Get("MassVsCosThetaCS/allHistos/meanHisto"); - histo2->SetLineColor(2); - histo2->SetMarkerColor(2); - histo2->Draw("same"); - //--- fit ---------------------------------------------- - f2 = new TF1("cosinusoidal2", "[0]+[1]*cos(x+[2])", -1.1, 1.1); - f2->SetParameter(0, 90.5); - f2->SetParameter(1, 1.); - f2->SetParameter(2, 1.); - f2->SetLineColor(2); - if (switchONfit){ - histo2->Fit(f2,"R","same", -1.1, 1.1); - f2->Draw("same"); - } - - cmsprel->Draw("same"); - leg->Draw("same"); - - c5->SaveAs("MassVsCosThetaCS_ALL.png"); - - //----------------- CANVAS C6 --------------// - c6->SetFillColor(0); - c6->cd(); - -// Mass VS muon cos(theta_CS) ------------------------------- - histo1=(TH1D*)file1->Get("MassVsPhiCS/allHistos/meanHisto"); - histo1->SetLineColor(1); - histo1->SetMarkerColor(1); - histo1->SetMarkerStyle(20); - histo1->SetMarkerSize(1.5); - histo1->GetXaxis()->SetTitle("#phi_{CS}"); - histo1->GetYaxis()->SetTitle("M_{#mu#mu} (GeV)"); - histo1->GetYaxis()->SetRangeUser(89.5,92); - histo1->GetXaxis()->SetRangeUser(-3.14,3.14); - histo1->Draw(); - //--- fit ---------------------------------------------- - f1 = new TF1("cosinusoidal1", "[0]+[1]*cos(x+[2])", -3.14, 3.14); - f1->SetParameter(0, 90.5); - f1->SetParameter(1, 1.); - f1->SetParameter(2, 1.); - f1->SetLineColor(6); - if (switchONfit){ - histo1->Fit(f1,"R","same", -3.14, 3.14); - f1->Draw("same"); - } - - - //---- 2------------------------------- - histo2=(TH1D*)file2->Get("MassVsPhiCS/allHistos/meanHisto"); - histo2->SetLineColor(2); - histo2->SetMarkerColor(2); - histo2->Draw("same"); - //--- fit ---------------------------------------------- - f2 = new TF1("cosinusoidal2", "[0]+[1]*cos(x+[2])", -3.14, 3.14); - f2->SetParameter(0, 90.5); - f2->SetParameter(1, 1.); - f2->SetParameter(2, 1.); - f2->SetLineColor(2); - if (switchONfit){ - histo2->Fit(f2,"R","same", -3.14, 3.14); - f2->Draw("same"); - } - - cmsprel->Draw("same"); - leg->Draw("same"); - - c6->SaveAs("MassVsPhiCS_ALL.png"); - + setTDRStyle(); + + TString strValidation_label = "Run 2015B (251604-251642)"; + TString strReference_label = "DY 2012 Ideal"; + + // preamble + TPaveText *cmsPlotTitle = new TPaveText(0.15, 0.93, 0.85, 1, "brNDC"); + cmsPlotTitle->SetBorderSize(0); + cmsPlotTitle->SetFillStyle(0); + cmsPlotTitle->SetTextAlign(12); + cmsPlotTitle->SetTextFont(42); + cmsPlotTitle->SetTextSize(0.045); + TText* text = cmsPlotTitle->AddText(0.025, 0.45, "#font[61]{CMS}"); + text->SetTextSize(0.044); + text = cmsPlotTitle->AddText(0.165, 0.42, "#font[52]{Preliminary}"); + text->SetTextSize(0.0315); + TString cErgTev = "#font[42]{ TkAl Z#rightarrow#mu#mu (|#eta_{#mu}|<2.4) 13 TeV}"; + text = cmsPlotTitle->AddText(0.537, 0.40, cErgTev); + text->SetTextSize(0.0315); + + TFile* file[2]; + file[0] = new TFile("./BiasCheck.root", "read"); + file[1] = new TFile("./BiasCheck_Reference.root", "read"); + + int pIndex; + TH1D* histo[2][7]; + TF1* hfit[2][7]; + TCanvas* c[7]; + for (int i=0; i<7; i++){ + TString cname = Form("c%i", i); + c[i] = new TCanvas(cname, cname, 8, 30, 800, 800); + gStyle->SetOptStat(0); + c[i]->SetFillColor(0); + c[i]->SetBorderMode(0); + c[i]->SetBorderSize(2); + c[i]->SetTickx(1); + c[i]->SetTicky(1); + c[i]->SetLeftMargin(0.17); + c[i]->SetRightMargin(0.05); + c[i]->SetTopMargin(0.07); + c[i]->SetBottomMargin(0.13); + c[i]->SetFrameFillStyle(0); + c[i]->SetFrameBorderMode(0); + c[i]->SetFrameFillStyle(0); + c[i]->SetFrameBorderMode(0); + } + + float lxmin = 0.22, lxwidth = 0.38; + float lymax = 0.9, lywidth = 0.15; + float lxmax = lxmin + lxwidth; + float lymin = lymax - lywidth; + TLegend* leg = new TLegend(lxmin, lymin, lxmax, lymax); + leg->SetBorderSize(0); + leg->SetTextFont(42); + leg->SetTextSize(0.04); + leg->SetLineColor(1); + leg->SetLineStyle(1); + leg->SetLineWidth(1); + leg->SetFillColor(0); + leg->SetFillStyle(0); + + //----------------- CANVAS C0 --------------// + pIndex=0; + c[pIndex]->cd(); + + TString histoName[7] ={ + "MassVsPhiPlus/allHistos/meanHisto", + "MassVsPhiMinus/allHistos/meanHisto", + "MassVsEtaPlus/allHistos/meanHisto", + "MassVsEtaMinus/allHistos/meanHisto", + "MassVsEtaPlusMinusDiff/allHistos/meanHisto", + "MassVsCosThetaCS/allHistos/meanHisto", + "MassVsPhiCS/allHistos/meanHisto" + }; + double minmax_plot[7][2]={ { 0 } }; + for (int iP=0; iP<7; iP++){ + double absMin=9e9; + double absMax = -9e9; + for (int f=0; f<2; f++){ + histo[f][iP]=(TH1D*)file[f]->Get(histoName[iP]); + + histo[f][iP]->SetTitle(""); + histo[f][iP]->GetXaxis()->SetLabelFont(42); + histo[f][iP]->GetXaxis()->SetLabelOffset(0.007); + histo[f][iP]->GetXaxis()->SetLabelSize(0.04); + histo[f][iP]->GetXaxis()->SetTitleSize(0.06); + histo[f][iP]->GetXaxis()->SetTitleOffset(0.9); + histo[f][iP]->GetXaxis()->SetTitleFont(42); + histo[f][iP]->GetYaxis()->SetNdivisions(505); + histo[f][iP]->GetYaxis()->SetLabelFont(42); + histo[f][iP]->GetYaxis()->SetLabelOffset(0.007); + histo[f][iP]->GetYaxis()->SetLabelSize(0.04); + histo[f][iP]->GetYaxis()->SetTitleSize(0.06); + histo[f][iP]->GetYaxis()->SetTitleOffset(1.2); + histo[f][iP]->GetYaxis()->SetTitleFont(42); + + histo[f][iP]->GetYaxis()->SetTitle("M_{#mu#mu} (GeV)"); + histo[f][iP]->SetLineWidth(1); + histo[f][iP]->SetMarkerSize(1.2); + if (f==0){ + histo[f][iP]->SetLineColor(kBlack); + histo[f][iP]->SetMarkerColor(kBlack); + histo[f][iP]->SetMarkerStyle(20); + } + else{ + histo[f][iP]->SetLineColor(kRed); + histo[f][iP]->SetMarkerColor(kRed); + histo[f][iP]->SetMarkerStyle(1); + } + for (int bin=1; bin<=histo[f][iP]->GetNbinsX(); bin++){ + double bincontent = histo[f][iP]->GetBinContent(bin); + double binerror = histo[f][iP]->GetBinError(bin); + if (binerror==0 && bincontent==0) continue; + absMin = min(absMin, bincontent - binerror); + absMax = max(absMax, bincontent + binerror); + } + } + minmax_plot[iP][0] = absMin/1.1; + minmax_plot[iP][1] = absMax*1.1; + for (int f=0; f<2; f++) histo[f][iP]->GetYaxis()->SetRangeUser(minmax_plot[iP][0], minmax_plot[iP][1]); + } + + // Mass VS muon phi plus ------------------------------- + histo[0][pIndex]->GetXaxis()->SetTitle("#phi_{#mu+}"); + histo[0][pIndex]->GetXaxis()->SetRangeUser(-TMath::Pi(), TMath::Pi()); + histo[0][pIndex]->Draw(); + leg->AddEntry(histo[0][pIndex], strValidation_label, "l"); + //--- fit ---------------------------------------------- + hfit[0][pIndex] = new TF1("cosinusoidal1", "[0]+[1]*cos(x+[2])", -TMath::Pi(), TMath::Pi()); + hfit[0][pIndex]->SetParameter(0, 90.5); + hfit[0][pIndex]->SetParameter(1, 1.); + hfit[0][pIndex]->SetParameter(2, 1.); + hfit[0][pIndex]->SetLineColor(1); + if (switchONfit){ + histo[0][pIndex]->Fit(hfit[0][pIndex], "R", "same", -TMath::Pi(), TMath::Pi()); + hfit[0][pIndex]->Draw("same"); + } + + //---- 2------------------------------- + histo[1][pIndex]->Draw("same"); + leg->AddEntry(histo[1][pIndex], strReference_label, "l"); + //--- fit ---------------------------------------------- + hfit[1][pIndex] = new TF1("cosinusoidal2", "[0]+[1]*cos(x+[2])", -TMath::Pi(), TMath::Pi()); + hfit[1][pIndex]->SetParameter(0, 90.5); + hfit[1][pIndex]->SetParameter(1, 1.); + hfit[1][pIndex]->SetParameter(2, 1.); + hfit[1][pIndex]->SetLineColor(2); + if (switchONfit){ + histo[1][pIndex]->Fit(hfit[1][pIndex], "R", "same", -TMath::Pi(), TMath::Pi()); + hfit[1][pIndex]->Draw("same"); + } + + leg->Draw("same"); + cmsPlotTitle->Draw("same"); + c[pIndex]->RedrawAxis(); + c[pIndex]->Modified(); + c[pIndex]->Update(); + c[pIndex]->SaveAs("MassVsPhiPlus_ALL.png"); + + //----------------- CANVAS C1 --------------// + pIndex=1; + c[pIndex]->cd(); + + // Mass VS muon phi minus ------------------------------- + histo[0][pIndex]->GetXaxis()->SetTitle("#phi_{#mu-}"); + histo[0][pIndex]->GetXaxis()->SetRangeUser(-TMath::Pi(), TMath::Pi()); + histo[0][pIndex]->Draw(); + //--- fit ---------------------------------------------- + hfit[0][pIndex] = new TF1("cosinusoidal1", "[0]+[1]*cos(x+[2])", -TMath::Pi(), TMath::Pi()); + hfit[0][pIndex]->SetParameter(0, 90.5); + hfit[0][pIndex]->SetParameter(1, 1.); + hfit[0][pIndex]->SetParameter(2, 1.); + hfit[0][pIndex]->SetLineColor(1); + if (switchONfit){ + histo[0][pIndex]->Fit(hfit[0][pIndex], "R", "same", -TMath::Pi(), TMath::Pi()); + hfit[0][pIndex]->Draw("same"); + } + + + //---- 2------------------------------- + histo[1][pIndex]->Draw("same"); + //--- fit ---------------------------------------------- + hfit[1][pIndex] = new TF1("cosinusoidal2", "[0]+[1]*cos(x+[2])", -TMath::Pi(), TMath::Pi()); + hfit[1][pIndex]->SetParameter(0, 90.5); + hfit[1][pIndex]->SetParameter(1, 1.); + hfit[1][pIndex]->SetParameter(2, 1.); + hfit[1][pIndex]->SetLineColor(2); + if (switchONfit){ + histo[1][pIndex]->Fit(hfit[1][pIndex], "R", "same", -TMath::Pi(), TMath::Pi()); + hfit[1][pIndex]->Draw("same"); + } + + leg->Draw("same"); + cmsPlotTitle->Draw("same"); + c[pIndex]->RedrawAxis(); + c[pIndex]->Modified(); + c[pIndex]->Update(); + c[pIndex]->SaveAs("MassVsPhiMinus_ALL.png"); + + //----------------- CANVAS C2 --------------// + pIndex=2; + c[pIndex]->cd(); + + // Mass VS muon eta plus ------------------------------- + histo[0][pIndex]->GetXaxis()->SetTitle("#eta_{#mu+}"); + histo[0][pIndex]->GetXaxis()->SetRangeUser(-2.6, 2.6); + histo[0][pIndex]->Draw(); + //--- fit ---------------------------------------------- + hfit[0][pIndex] = new TF1("linear1", "[0]+[1]*x", -2.6, 2.6); + hfit[0][pIndex]->SetParameter(0, 90.5); + hfit[0][pIndex]->SetParameter(1, 1.); + hfit[0][pIndex]->SetLineColor(1); + if (switchONfitEta){ + histo[0][pIndex]->Fit(hfit[0][pIndex], "R", "same", -2.6, 2.6); + hfit[0][pIndex]->Draw("same"); + } + + + //---- 2------------------------------- + histo[1][pIndex]->Draw("same"); + //--- fit ---------------------------------------------- + hfit[1][pIndex] = new TF1("linear2", "[0]+[1]*x", -2.6, 2.6); + hfit[1][pIndex]->SetParameter(0, 90.5); + hfit[1][pIndex]->SetParameter(1, 1.); + hfit[1][pIndex]->SetLineColor(2); + if (switchONfitEta){ + histo[1][pIndex]->Fit(hfit[1][pIndex], "R", "same", -2.6, 2.6); + hfit[1][pIndex]->Draw("same"); + } + + leg->Draw("same"); + cmsPlotTitle->Draw("same"); + c[pIndex]->RedrawAxis(); + c[pIndex]->Modified(); + c[pIndex]->Update(); + c[pIndex]->SaveAs("MassVsEtaPlus_ALL.png"); + + //----------------- CANVAS C3 --------------// + pIndex=3; + c[pIndex]->cd(); + + // Mass VS muon eta minus ------------------------------- + histo[0][pIndex]->GetXaxis()->SetTitle("#eta_{#mu-}"); + histo[0][pIndex]->GetXaxis()->SetRangeUser(-2.6, 2.6); + histo[0][pIndex]->Draw(); + //--- fit ---------------------------------------------- + hfit[0][pIndex] = new TF1("linear1", "[0]+[1]*x", -2.6, 2.6); + hfit[0][pIndex]->SetParameter(0, 0.); + hfit[0][pIndex]->SetParameter(1, 0.); + hfit[0][pIndex]->SetLineColor(1); + if (switchONfitEta){ + histo[0][pIndex]->Fit(hfit[0][pIndex], "R", "same", -2.6, 2.6); + hfit[0][pIndex]->Draw("same"); + } + + + //---- 2------------------------------- + histo[1][pIndex]->Draw("same"); + //--- fit ---------------------------------------------- + hfit[1][pIndex] = new TF1("linear2", "[0]+[1]*x", -2.6, 2.6); + hfit[1][pIndex]->SetParameter(0, 0.); + hfit[1][pIndex]->SetParameter(1, 0.); + hfit[1][pIndex]->SetLineColor(2); + if (switchONfitEta){ + histo[1][pIndex]->Fit(hfit[1][pIndex], "R", "same", -2.6, 2.6); + hfit[1][pIndex]->Draw("same"); + } + + leg->Draw("same"); + cmsPlotTitle->Draw("same"); + c[pIndex]->RedrawAxis(); + c[pIndex]->Modified(); + c[pIndex]->Update(); + c[pIndex]->SaveAs("MassVsEtaMinus_ALL.png"); + + //----------------- CANVAS C4 --------------// + pIndex=4; + c[pIndex]->cd(); + + // Mass VS muon eta plus - eta minus ------------------------------- + histo[0][pIndex]->GetXaxis()->SetTitle("#eta_{#mu+} - #eta_{#mu-}"); + histo[0][pIndex]->GetXaxis()->SetRangeUser(-3.2, 3.2); + histo[0][pIndex]->Draw(); + //--- fit ---------------------------------------------- + hfit[0][pIndex] = new TF1("linear1", "[0]+[1]*x", -3.2, 3.2); + hfit[0][pIndex]->SetParameter(0, 0.); + hfit[0][pIndex]->SetParameter(1, 0.); + hfit[0][pIndex]->SetLineColor(1); + if (switchONfitEta){ + histo[0][pIndex]->Fit(hfit[0][pIndex], "R", "same", -3.2, 3.2); + hfit[0][pIndex]->Draw("same"); + } + + + //---- 2------------------------------- + histo[1][pIndex]->Draw("same"); + //--- fit ---------------------------------------------- + hfit[1][pIndex] = new TF1("linear1", "[0]+[1]*x", -3.2, 3.2); + hfit[1][pIndex]->SetParameter(0, 0.); + hfit[1][pIndex]->SetParameter(1, 0.); + hfit[1][pIndex]->SetLineColor(2); + if (switchONfitEta){ + histo[1][pIndex]->Fit(hfit[1][pIndex], "R", "same", -3.2, 3.2); + hfit[1][pIndex]->Draw("same"); + } + + leg->Draw("same"); + cmsPlotTitle->Draw("same"); + c[pIndex]->RedrawAxis(); + c[pIndex]->Modified(); + c[pIndex]->Update(); + c[pIndex]->SaveAs("MassVsDeltaEta_ALL.png"); + + + //----------------- CANVAS C5 --------------// + pIndex=5; + c[pIndex]->cd(); + + // Mass VS muon cos(theta_CS) ------------------------------- + histo[0][pIndex]->GetXaxis()->SetTitle("cos #theta_{CS}"); + histo[0][pIndex]->GetXaxis()->SetRangeUser(-1.1, 1.1); + histo[0][pIndex]->Draw(); + //--- fit ---------------------------------------------- + hfit[0][pIndex] = new TF1("cosinusoidal1", "[0]+[1]*cos(x+[2])", -1.1, 1.1); + hfit[0][pIndex]->SetParameter(0, 90.5); + hfit[0][pIndex]->SetParameter(1, 1.); + hfit[0][pIndex]->SetParameter(2, 1.); + hfit[0][pIndex]->SetLineColor(6); + if (switchONfit){ + histo[0][pIndex]->Fit(hfit[0][pIndex], "R", "same", -1.1, 1.1); + hfit[0][pIndex]->Draw("same"); + } + + + //---- 2------------------------------- + histo[1][pIndex]->Draw("same"); + //--- fit ---------------------------------------------- + hfit[1][pIndex] = new TF1("cosinusoidal2", "[0]+[1]*cos(x+[2])", -1.1, 1.1); + hfit[1][pIndex]->SetParameter(0, 90.5); + hfit[1][pIndex]->SetParameter(1, 1.); + hfit[1][pIndex]->SetParameter(2, 1.); + hfit[1][pIndex]->SetLineColor(2); + if (switchONfit){ + histo[1][pIndex]->Fit(hfit[1][pIndex], "R", "same", -1.1, 1.1); + hfit[1][pIndex]->Draw("same"); + } + + leg->Draw("same"); + cmsPlotTitle->Draw("same"); + c[pIndex]->RedrawAxis(); + c[pIndex]->Modified(); + c[pIndex]->Update(); + c[pIndex]->SaveAs("MassVsCosThetaCS_ALL.png"); + + //----------------- CANVAS C6 --------------// + pIndex=6; + c[pIndex]->cd(); + + // Mass VS muon cos(theta_CS) ------------------------------- + histo[0][pIndex]->GetXaxis()->SetTitle("#phi_{CS}"); + histo[0][pIndex]->GetXaxis()->SetRangeUser(-TMath::Pi(), TMath::Pi()); + histo[0][pIndex]->Draw(); + //--- fit ---------------------------------------------- + hfit[0][pIndex] = new TF1("cosinusoidal1", "[0]+[1]*cos(x+[2])", -TMath::Pi(), TMath::Pi()); + hfit[0][pIndex]->SetParameter(0, 90.5); + hfit[0][pIndex]->SetParameter(1, 1.); + hfit[0][pIndex]->SetParameter(2, 1.); + hfit[0][pIndex]->SetLineColor(6); + if (switchONfit){ + histo[0][pIndex]->Fit(hfit[0][pIndex], "R", "same", -TMath::Pi(), TMath::Pi()); + hfit[0][pIndex]->Draw("same"); + } + + + //---- 2------------------------------- + histo[1][pIndex]->Draw("same"); + //--- fit ---------------------------------------------- + hfit[1][pIndex] = new TF1("cosinusoidal2", "[0]+[1]*cos(x+[2])", -TMath::Pi(), TMath::Pi()); + hfit[1][pIndex]->SetParameter(0, 90.5); + hfit[1][pIndex]->SetParameter(1, 1.); + hfit[1][pIndex]->SetParameter(2, 1.); + hfit[1][pIndex]->SetLineColor(2); + if (switchONfit){ + histo[1][pIndex]->Fit(hfit[1][pIndex], "R", "same", -TMath::Pi(), TMath::Pi()); + hfit[1][pIndex]->Draw("same"); + } + + leg->Draw("same"); + cmsPlotTitle->Draw("same"); + c[pIndex]->RedrawAxis(); + c[pIndex]->Modified(); + c[pIndex]->Update(); + c[pIndex]->SaveAs("MassVsPhiCS_ALL.png"); + + for (int i=0; i<7; i++){ + c[i]->Close(); + for (int j=0; j<2; j++) delete hfit[j][i]; + } + delete leg; + for(int f=1;f>=0;f--) file[f]->Close(); } diff --git a/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/tdrstyle.C b/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/tdrstyle.C index 7df9f132d7a32..5798bd26991ff 100644 --- a/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/tdrstyle.C +++ b/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/tdrstyle.C @@ -1,7 +1,7 @@ #include "TStyle.h" // tdrGrid: Turns the grid lines on (true) or off (false) -extern TStyle* tdrStyle; +TStyle* tdrStyle; void tdrGrid(bool gridOn) { tdrStyle->SetPadGridX(gridOn); From b7e9777c8503c6b614927981ae37847ac8ef2c22 Mon Sep 17 00:00:00 2001 From: usarica Date: Thu, 3 Sep 2015 03:59:44 +0200 Subject: [PATCH 2/9] Fix contingency of fits in different slices --- .../TkAlAllInOneTool/zMuMuValidation.py | 1 + .../zMuMuValidationTemplates.py | 5 +- .../test/Macros/RooFit/FitSlices.cc | 101 +++--- .../test/Macros/RooFit/FitWithRooFit.cc | 249 +++++++++------ .../test/Macros/RooFit/FitXslices.cc | 255 ++++++++------- .../Macros/RooFit/MultiHistoOverlapAll_Z.C | 298 ++++++++++++++++++ 6 files changed, 633 insertions(+), 276 deletions(-) create mode 100644 MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/MultiHistoOverlapAll_Z.C diff --git a/Alignment/OfflineValidation/python/TkAlAllInOneTool/zMuMuValidation.py b/Alignment/OfflineValidation/python/TkAlAllInOneTool/zMuMuValidation.py index 8714a4fc8a9a9..6567201d585a1 100644 --- a/Alignment/OfflineValidation/python/TkAlAllInOneTool/zMuMuValidation.py +++ b/Alignment/OfflineValidation/python/TkAlAllInOneTool/zMuMuValidation.py @@ -51,6 +51,7 @@ def getRepMap(self, alignment = None): ",genSimRecoPlots.root" ",FitParameters.txt"), "eosdir": os.path.join(self.general["eosdir"], "%s/%s/%s" % (self.outputBaseName, self.name, alignment.name)), + "workingdir": ".oO[datadir]Oo./%s/%s/%s" % (self.outputBaseName, self.name, alignment.name), "plotsdir": ".oO[datadir]Oo./%s/%s/%s/plots" % (self.outputBaseName, self.name, alignment.name), }) return repMap diff --git a/Alignment/OfflineValidation/python/TkAlAllInOneTool/zMuMuValidationTemplates.py b/Alignment/OfflineValidation/python/TkAlAllInOneTool/zMuMuValidationTemplates.py index 5efb9e10455fa..de7da5eb6400a 100644 --- a/Alignment/OfflineValidation/python/TkAlAllInOneTool/zMuMuValidationTemplates.py +++ b/Alignment/OfflineValidation/python/TkAlAllInOneTool/zMuMuValidationTemplates.py @@ -223,7 +223,7 @@ cd $cwd rfmkdir -p .oO[datadir]Oo. - +rfmkdir -p .oO[workingdir]Oo. rfmkdir -p .oO[logdir]Oo. rm -f .oO[logdir]Oo./*.stdout rm -f .oO[logdir]Oo./*.stderr @@ -251,7 +251,7 @@ cp .oO[CMSSW_BASE]Oo./src/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/FitWithRooFit.cc . cp .oO[CMSSW_BASE]Oo./src/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/FitMass1D.cc . -root -q -b -ls "CompareBiasZValidation.cc+(\\\"\\\")" +root -q -b -l "CompareBiasZValidation.cc+(\\\"\\\")" cp .oO[CMSSW_BASE]Oo./src/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/tdrstyle.C . cp .oO[CMSSW_BASE]Oo./src/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/MultiHistoOverlap_.oO[resonance]Oo..C . @@ -263,6 +263,7 @@ for RootOutputFile in $(ls *root ) do cmsStage -f ${RootOutputFile} /store/caf/user/$USER/.oO[eosdir]Oo./ + rfcp ${RootOutputFile} .oO[workingdir]Oo. done mkdir -p .oO[plotsdir]Oo. diff --git a/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/FitSlices.cc b/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/FitSlices.cc index 66e807e31645d..029db7d8dc411 100644 --- a/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/FitSlices.cc +++ b/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/FitSlices.cc @@ -26,41 +26,40 @@ class FitSlices // const TString & histoBaseName = "hRecBestResVSMu", const TString & histoBaseTitle = "MassVs") = 0; void fitSlice(const TString & histoName, const TString & dirName, - const double & xMean, const double & xMin, const double & xMax, - const double & sigma, const double & sigmaMin, const double & sigmaMax, - const TString & signalType, const TString & backgroundType, - TFile * inputFile, TDirectory * outputFile) + const double & xMean, const double & xMin, const double & xMax, + const double & sigma, const double & sigmaMin, const double & sigmaMax, + const TString & signalType, const TString & backgroundType, + TFile * inputFile, TDirectory * outputFile) { FitXslices fitXslices; fitXslices.fitter()->useChi2_ = useChi2; - fitXslices.fitter()->initMean( xMean, xMin, xMax ); - fitXslices.fitter()->initSigma( sigma, sigmaMin, sigmaMax ); - fitXslices.fitter()->initSigma2( sigma2, sigma2Min, sigma2Max ); + fitXslices.fitter()->initMean(xMean, xMin, xMax); + fitXslices.fitter()->initSigma(sigma, sigmaMin, sigmaMax); + fitXslices.fitter()->initSigma2(sigma2, sigma2Min, sigma2Max); fitXslices.fitter()->initAlpha(1.5, 0.05, 10.); fitXslices.fitter()->initN(1, 0.01, 100.); fitXslices.fitter()->initFGCB(0.4, 0., 1.); std::cout << "Fit slices: initialization complete" << std::endl; - + //r.c. patch -------------- if (histoName=="hRecBestResVSMu_MassVSEtaPhiPlus" || histoName=="hRecBestResVSMu_MassVSEtaPhiMinus" || - histoName=="hRecBestResVSMu_MassVSPhiPlusPhiMinus" || histoName=="hRecBestResVSMu_MassVSEtaPlusEtaMinus" - ) - { - TH3* histoPt3 = (TH3*)inputFile->FindObjectAny(histoName); - outputFile->mkdir(dirName); - outputFile->cd(dirName); + histoName=="hRecBestResVSMu_MassVSPhiPlusPhiMinus" || histoName=="hRecBestResVSMu_MassVSEtaPlusEtaMinus") + { + TH3* histoPt3 = (TH3*)inputFile->FindObjectAny(histoName); + outputFile->mkdir(dirName); + outputFile->cd(dirName); - // histoPt3 = rebin3D(histoPt3); - fitXslices(histoPt3, xMin, xMax, signalType, backgroundType, rebinZ); + // histoPt3 = rebin3D(histoPt3); + fitXslices(histoPt3, xMin, xMax, signalType, backgroundType, rebinZ); - // histoPt3->RebinX(rebinX); - // histoPt3->RebinY(rebinX); - // histoPt3->RebinY(rebinY); - // (histoPt3->DoProject2D())->RebinX(rebinX); - // (histoPt3->DoProject2D())->RebinY(rebinY); - } + // histoPt3->RebinX(rebinX); + // histoPt3->RebinY(rebinX); + // histoPt3->RebinY(rebinY); + // (histoPt3->DoProject2D())->RebinX(rebinX); + // (histoPt3->DoProject2D())->RebinY(rebinY); + } else { TH2* histoPt2 = (TH2*)inputFile->FindObjectAny(histoName); histoPt2->RebinX(rebinX); @@ -70,9 +69,8 @@ class FitSlices outputFile->mkdir(dirName); outputFile->cd(dirName); fitXslices(histoPt2, xMin, xMax, signalType, backgroundType, rebinZ); - } - - } + } + } unsigned int rebinX; unsigned int rebinY; unsigned int rebinZ; @@ -84,46 +82,45 @@ class FitSlices unsigned int zbins=histo3D->GetNbinsZ(); // std::cout<< "number of bins in z (and tempHisto) --> "< twoDprojection; - for(unsigned int z=1;z(histo3D->GetZaxis());ax_tmp->SetRange(z, z); + for (unsigned int z=1; z(histo3D->GetZaxis()); ax_tmp->SetRange(z, z); TH2* tempHisto= (TH2*)histo3D->Project3D("xy"); std::stringstream ss; ss << z; tempHisto->SetName(TString(tempHisto->GetName())+ss.str()); tempHisto->RebinX(rebinX); tempHisto->RebinY(rebinY); - twoDprojection.insert(std::make_pair(z,tempHisto)); + twoDprojection.insert(std::make_pair(z, tempHisto)); } unsigned int xbins, ybins; - TH3* rebinned3D = (TH3*) new TH3F(TString(histo3D->GetName())+"_rebinned",histo3D->GetTitle(), - xbins,histo3D->GetXaxis()->GetXmin(),histo3D->GetXaxis()->GetXmax(), - ybins,histo3D->GetYaxis()->GetXmin(),histo3D->GetYaxis()->GetXmax(), - zbins,histo3D->GetZaxis()->GetXmin(),histo3D->GetZaxis()->GetXmax() ); - if(twoDprojection.size()!=0) + TH3* rebinned3D = (TH3*) new TH3F(TString(histo3D->GetName())+"_rebinned", histo3D->GetTitle(), + xbins, histo3D->GetXaxis()->GetXmin(), histo3D->GetXaxis()->GetXmax(), + ybins, histo3D->GetYaxis()->GetXmin(), histo3D->GetYaxis()->GetXmax(), + zbins, histo3D->GetZaxis()->GetXmin(), histo3D->GetZaxis()->GetXmax()); + if (twoDprojection.size()!=0) + { + xbins=twoDprojection[1]->GetNbinsX(); + ybins=twoDprojection[1]->GetNbinsY(); + //std::cout<< "number of bins in x --> "< "<GetNbinsX(); - ybins=twoDprojection[1]->GetNbinsY(); - //std::cout<< "number of bins in x --> "< "< "< "<Fill(x,y,twoDprojection[z]->GetBinContent(x,y)); - } - - } + for (unsigned int y=1; y "< "<Fill(x, y, twoDprojection[z]->GetBinContent(x, y)); + } + + } - } } + } return rebinned3D; } - }; #endif diff --git a/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/FitWithRooFit.cc b/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/FitWithRooFit.cc index 26334e6285146..a4582089ed2cb 100644 --- a/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/FitWithRooFit.cc +++ b/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/FitWithRooFit.cc @@ -56,11 +56,14 @@ class FitWithRooFit public: FitWithRooFit() : - useChi2_(false), mean_(0), mean2_(0), mean3_(0), sigma_(0), sigma2_(0), sigma3_(0), gamma_(0), gaussFrac_(0), gaussFrac2_(0), + useChi2_(false), + mean_(0), mean2_(0), mean3_(0), + sigma_(0), sigma2_(0), sigma3_(0), + gamma_(0), gaussFrac_(0), gaussFrac2_(0), expCoeffa0_(0), expCoeffa1_(0), expCoeffa2_(0), fsig_(0), - a0_(0), a1_(0), a2_(0), a3_(0), a4_(0), a5_(0), a6_(0), alpha_(0), n_(0), fGCB_(0) - { - } + a0_(0), a1_(0), a2_(0), a3_(0), a4_(0), a5_(0), a6_(0), + alpha_(0), n_(0), fGCB_(0) + {} // Import TH1 histogram into a RooDataHist rooPair importTH1(TH1 * histo, const double & inputXmin, const double & inputXmax) @@ -85,7 +88,7 @@ class FitWithRooFit RooDataHist * dh = imported.second; // Make plot of binned dataset showing Poisson error bars (RooFit default) - RooPlot* frame = x.frame(RooFit::Title("Imported TH1 with Poisson error bars")) ; + RooPlot* frame = x.frame(RooFit::Title("Imported TH1 with Poisson error bars")); frame->SetName(TString(histo->GetName())+"_frame"); dh->plotOn(frame); @@ -97,13 +100,9 @@ class FitWithRooFit // Fit the composite model // ----------------------- // Fit with likelihood - if( !useChi2_ ) { - if( sumW2Error ) { - model->fitTo(*dh, RooFit::Save(), RooFit::SumW2Error(kTRUE)); - } - else { - model->fitTo(*dh); - } + if (!useChi2_) { + if (sumW2Error) model->fitTo(*dh, RooFit::Save(), RooFit::SumW2Error(kTRUE)); + else model->fitTo(*dh); } // Fit with chi^2 else { @@ -128,8 +127,8 @@ class FitWithRooFit // If histogram has custom error (i.e. its contents is does not originate from a Poisson process // but e.g. is a sum of weighted events) you can data with symmetric 'sum-of-weights' error instead // (same error bars as shown by ROOT) - RooPlot* frame2 = x.frame(RooFit::Title("Imported TH1 with internal errors")) ; - dh->plotOn(frame2,RooFit::DataError(RooAbsData::SumW2)) ; + RooPlot* frame2 = x.frame(RooFit::Title("Imported TH1 with internal errors")); + dh->plotOn(frame2, RooFit::DataError(RooAbsData::SumW2)); model->plotOn(frame2); model->plotOn(frame2, RooFit::Components(backgroundType), RooFit::LineColor(kRed)); model->paramOn(frame2, RooFit::Label("fit result"), RooFit::Format("NEU", RooFit::AutoPrecision(2))); @@ -159,240 +158,262 @@ class FitWithRooFit { if( mean_ != 0 ) delete mean_; mean_ = new RooRealVar(name, title, value, min, max); + initVal_mean = value; } - void initMean2(const double & value, const double & min, const double & max, const TString & name = "mean2", const TString & title = "mean2") { if( mean2_ != 0 ) delete mean2_; mean2_ = new RooRealVar(name, title, value, min, max); + initVal_mean2 = value; } - void initMean3(const double & value, const double & min, const double & max, const TString & name = "mean3", const TString & title = "mean3") { if( mean3_ != 0 ) delete mean3_; mean3_ = new RooRealVar(name, title, value, min, max); + initVal_mean3 = value; } - - void initSigma(const double & value, const double & min, const double & max, const TString & name = "sigma", const TString & title = "sigma") { if( sigma_ != 0 ) delete sigma_; sigma_ = new RooRealVar(name, title, value, min, max); + initVal_sigma = value; } - void initSigma2(const double & value, const double & min, const double & max, const TString & name = "sigma2", const TString & title = "sigma2") { if( sigma2_ != 0 ) delete sigma2_; sigma2_ = new RooRealVar(name, title, value, min, max); + initVal_sigma2 = value; } - - void initSigma3(const double & value, const double & min, const double & max, const TString & name = "sigma3", const TString & title = "sigma3") { if( sigma3_ != 0 ) delete sigma3_; sigma3_ = new RooRealVar(name, title, value, min, max); + initVal_sigma3 = value; } - void initGamma(const double & value, const double & min, const double & max, const TString & name = "gamma", const TString & title = "gamma") { if( gamma_ != 0 ) delete gamma_; gamma_ = new RooRealVar(name, title, value, min, max); + initVal_gamma = value; } - void initGaussFrac(const double & value, const double & min, const double & max, const TString & name = "GaussFrac", const TString & title = "GaussFrac") { if( gaussFrac_ != 0 ) delete gaussFrac_; gaussFrac_ = new RooRealVar(name, title, value, min, max); + initVal_gaussFrac = value; } - void initGaussFrac2(const double & value, const double & min, const double & max, const TString & name = "GaussFrac2", const TString & title = "GaussFrac2") { if( gaussFrac2_ != 0 ) delete gaussFrac2_; gaussFrac2_ = new RooRealVar(name, title, value, min, max); + initVal_gaussFrac2 = value; } - void initExpCoeffA0(const double & value, const double & min, const double & max, const TString & name = "expCoeffa0", const TString & title = "expCoeffa0") { if( expCoeffa0_ != 0 ) delete expCoeffa0_; expCoeffa0_ = new RooRealVar(name, title, value, min, max); + initVal_expCoeffa0 = value; } void initExpCoeffA1(const double & value, const double & min, const double & max, const TString & name = "expCoeffa1", const TString & title = "expCoeffa1") { if( expCoeffa1_ != 0 ) delete expCoeffa1_; expCoeffa1_ = new RooRealVar(name, title, value, min, max); + initVal_expCoeffa1 = value; } void initExpCoeffA2(const double & value, const double & min, const double & max, const TString & name = "expCoeffa2", const TString & title = "expCoeffa2") { if( expCoeffa2_ != 0 ) delete expCoeffa2_; expCoeffa2_ = new RooRealVar(name, title, value, min, max); + initVal_expCoeffa2 = value; } - void initFsig(const double & value, const double & min, const double & max, const TString & name = "fsig", const TString & title = "signal fraction") { if( fsig_ != 0 ) delete fsig_; fsig_ = new RooRealVar(name, title, value, min, max); + initVal_fsig = value; } - void initA0(const double & value, const double & min, const double & max, const TString & name = "a0", const TString & title = "a0") { if( a0_ != 0 ) delete a0_; a0_ = new RooRealVar(name, title, value, min, max); + initVal_a0 = value; } - void initA1(const double & value, const double & min, const double & max, const TString & name = "a1", const TString & title = "a1") { if( a1_ != 0 ) delete a1_; a1_ = new RooRealVar(name, title, value, min, max); + initVal_a1 = value; } - void initA2(const double & value, const double & min, const double & max, const TString & name = "a2", const TString & title = "a2") { if( a2_ != 0 ) delete a2_; a2_ = new RooRealVar(name, title, value, min, max); + initVal_a2 = value; } - void initA3(const double & value, const double & min, const double & max, const TString & name = "a3", const TString & title = "a3") { if( a3_ != 0 ) delete a3_; a3_ = new RooRealVar(name, title, value, min, max); + initVal_a3 = value; } - void initA4(const double & value, const double & min, const double & max, const TString & name = "a4", const TString & title = "a4") { if( a4_ != 0 ) delete a4_; a4_ = new RooRealVar(name, title, value, min, max); + initVal_a4 = value; } - void initA5(const double & value, const double & min, const double & max, const TString & name = "a5", const TString & title = "a5") { if( a5_ != 0 ) delete a5_; a5_ = new RooRealVar(name, title, value, min, max); + initVal_a5 = value; } - void initA6(const double & value, const double & min, const double & max, const TString & name = "a6", const TString & title = "a6") { if( a6_ != 0 ) delete a6_; a6_ = new RooRealVar(name, title, value, min, max); + initVal_a6 = value; } - void initAlpha(const double & value, const double & min, const double & max, const TString & name = "alpha", const TString & title = "alpha") { if( alpha_ != 0 ) delete alpha_; alpha_ = new RooRealVar(name, title, value, min, max); + initVal_alpha = value; } - void initN(const double & value, const double & min, const double & max, const TString & name = "n", const TString & title = "n") { if( n_ != 0 ) delete n_; n_ = new RooRealVar(name, title, value, min, max); + initVal_n = value; } - void initFGCB(const double & value, const double & min, const double & max, const TString & name = "fGCB", const TString & title = "fGCB") { if( fGCB_ != 0 ) delete fGCB_; fGCB_ = new RooRealVar(name, title, value, min, max); - } - - inline RooRealVar * mean() + initVal_fGCB = value; + } + + void reinitializeParameters(){ + if (mean_!=0) mean_->setVal(initVal_mean); + if (mean2_!=0) mean2_->setVal(initVal_mean2); + if (mean3_!=0) mean3_->setVal(initVal_mean3); + if (sigma_!=0) sigma_->setVal(initVal_sigma); + if (sigma2_!=0) sigma2_->setVal(initVal_sigma2); + if (sigma3_!=0) sigma3_->setVal(initVal_sigma3); + if (gamma_!=0) gamma_->setVal(initVal_gamma); + if (gaussFrac_!=0) gaussFrac_->setVal(initVal_gaussFrac); + if (gaussFrac2_!=0) gaussFrac2_->setVal(initVal_gaussFrac2); + if (expCoeffa0_!=0) expCoeffa0_->setVal(initVal_expCoeffa0); + if (expCoeffa1_!=0) expCoeffa1_->setVal(initVal_expCoeffa1); + if (expCoeffa2_!=0) expCoeffa2_->setVal(initVal_expCoeffa2); + if (fsig_!=0) fsig_->setVal(initVal_fsig); + if (a0_!=0) a0_->setVal(initVal_a0); + if (a1_!=0) a1_->setVal(initVal_a1); + if (a2_!=0) a2_->setVal(initVal_a2); + if (a3_!=0) a3_->setVal(initVal_a3); + if (a4_!=0) a4_->setVal(initVal_a4); + if (a5_!=0) a5_->setVal(initVal_a5); + if (a6_!=0) a6_->setVal(initVal_a6); + if (alpha_!=0) alpha_->setVal(initVal_alpha); + if (n_!=0) n_->setVal(initVal_n); + if (fGCB_!=0) fGCB_->setVal(initVal_fGCB); + } + + inline RooRealVar* mean() { return mean_; } - - inline RooRealVar * mean2() + inline RooRealVar* mean2() { return mean2_; } - - inline RooRealVar * mean3() + inline RooRealVar* mean3() { return mean3_; } - - inline RooRealVar * sigma() + inline RooRealVar* sigma() { return sigma_; } - - inline RooRealVar * sigma2() + inline RooRealVar* sigma2() { return sigma2_; } - - inline RooRealVar * gamma() + inline RooRealVar* sigma3() + { + return sigma3_; + } + inline RooRealVar* gamma() { return gamma_; } - - inline RooRealVar * expCoeffa0() + inline RooRealVar* gaussFrac() + { + return gaussFrac_; + } + inline RooRealVar* gaussFrac2() + { + return gaussFrac2_; + } + inline RooRealVar* expCoeffa0() { return expCoeffa0_; } - inline RooRealVar * expCoeffa1() + inline RooRealVar* expCoeffa1() { return expCoeffa1_; } - inline RooRealVar * expCoeffa2() + inline RooRealVar* expCoeffa2() { return expCoeffa2_; } - - inline RooRealVar * fsig() + inline RooRealVar* fsig() { return fsig_; } - - inline RooRealVar * a0() + inline RooRealVar* a0() { return a0_; } - - inline RooRealVar * a1() + inline RooRealVar* a1() { return a1_; } - - inline RooRealVar * a2() + inline RooRealVar* a2() { return a2_; } - - inline RooRealVar * a3() + inline RooRealVar* a3() { return a3_; } - - inline RooRealVar * a4() + inline RooRealVar* a4() { return a4_; } - - inline RooRealVar * a5() + inline RooRealVar* a5() { return a5_; } - - inline RooRealVar * a6() + inline RooRealVar* a6() { return a6_; } - - inline RooRealVar * alpha() + inline RooRealVar* alpha() { return alpha_; } - - inline RooRealVar * n() + inline RooRealVar* n() { return n_; } - - inline RooRealVar * fGCB() + inline RooRealVar* fGCB() { return fGCB_; } /// Build the model for the specified signal type - RooAbsPdf * buildSignalModel(RooRealVar * x, const TString & signalType) + RooAbsPdf * buildSignalModel(RooRealVar* x, const TString & signalType) { RooAbsPdf * signal = 0; if( signalType == "gaussian" ) { @@ -517,7 +538,7 @@ class FitWithRooFit } /// Build the model for the specified background type - RooAbsPdf * buildBackgroundModel(RooRealVar * x, const TString & backgroundType) + RooAbsPdf * buildBackgroundModel(RooRealVar* x, const TString & backgroundType) { RooAbsPdf * background = 0; if( backgroundType == "exponential" ) { @@ -576,7 +597,7 @@ class FitWithRooFit } /// Build the model to fit - RooAbsPdf * buildModel(RooRealVar * x, const TString & signalType, const TString & backgroundType) + RooAbsPdf * buildModel(RooRealVar* x, const TString & signalType, const TString & backgroundType) { RooAbsPdf * model = 0; @@ -608,29 +629,55 @@ class FitWithRooFit protected: // Declare all variables - RooRealVar * mean_; - RooRealVar * mean2_; - RooRealVar * mean3_; - RooRealVar * sigma_; - RooRealVar * sigma2_; - RooRealVar * sigma3_; - RooRealVar * gamma_; - RooRealVar * gaussFrac_; - RooRealVar * gaussFrac2_; - RooRealVar * expCoeffa0_; - RooRealVar * expCoeffa1_; - RooRealVar * expCoeffa2_; - RooRealVar * fsig_; - RooRealVar * a0_; - RooRealVar * a1_; - RooRealVar * a2_; - RooRealVar * a3_; - RooRealVar * a4_; - RooRealVar * a5_; - RooRealVar * a6_; - RooRealVar * alpha_; - RooRealVar * n_; - RooRealVar * fGCB_; + RooRealVar* mean_; + RooRealVar* mean2_; + RooRealVar* mean3_; + RooRealVar* sigma_; + RooRealVar* sigma2_; + RooRealVar* sigma3_; + RooRealVar* gamma_; + RooRealVar* gaussFrac_; + RooRealVar* gaussFrac2_; + RooRealVar* expCoeffa0_; + RooRealVar* expCoeffa1_; + RooRealVar* expCoeffa2_; + RooRealVar* fsig_; + RooRealVar* a0_; + RooRealVar* a1_; + RooRealVar* a2_; + RooRealVar* a3_; + RooRealVar* a4_; + RooRealVar* a5_; + RooRealVar* a6_; + RooRealVar* alpha_; + RooRealVar* n_; + RooRealVar* fGCB_; + + // Initial values + double initVal_mean; + double initVal_mean2; + double initVal_mean3; + double initVal_sigma; + double initVal_sigma2; + double initVal_sigma3; + double initVal_gamma; + double initVal_gaussFrac; + double initVal_gaussFrac2; + double initVal_expCoeffa0; + double initVal_expCoeffa1; + double initVal_expCoeffa2; + double initVal_fsig; + double initVal_a0; + double initVal_a1; + double initVal_a2; + double initVal_a3; + double initVal_a4; + double initVal_a5; + double initVal_a6; + double initVal_alpha; + double initVal_n; + double initVal_fGCB; + }; #endif diff --git a/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/FitXslices.cc b/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/FitXslices.cc index 8456054dda576..e198af0acf4b5 100644 --- a/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/FitXslices.cc +++ b/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/FitXslices.cc @@ -76,52 +76,52 @@ class FitXslices gDirectory->cd("allHistos"); gStyle->SetPalette(1); - // Loop on all X bins, project on Y and fit the resulting TH1 + // Loop on all X bins, project on Y and fit the resulting TH1 TString name = histo->GetName(); unsigned int binsX = histo->GetNbinsX(); // The canvas for the results of the fit (the mean values for the gaussians +- errors) - TCanvas * meanCanvas = new TCanvas("meanCanvas", "meanCanvas", 1000, 800); - TH1D * meanHisto = new TH1D("meanHisto", "meanHisto", binsX, histo->GetXaxis()->GetXmin(), histo->GetXaxis()->GetXmax()); + TCanvas* meanCanvas = new TCanvas("meanCanvas", "meanCanvas", 1000, 800); + TH1D* meanHisto = new TH1D("meanHisto", "meanHisto", binsX, histo->GetXaxis()->GetXmin(), histo->GetXaxis()->GetXmax()); - TCanvas * sigmaCanvas = new TCanvas("sigmaCanvas", "sigmaCanvas", 1000, 800); - TH1D * sigmaHisto = new TH1D("sigmaHisto", "sigmaHisto", binsX, histo->GetXaxis()->GetXmin(), histo->GetXaxis()->GetXmax()); + TCanvas* sigmaCanvas = new TCanvas("sigmaCanvas", "sigmaCanvas", 1000, 800); + TH1D* sigmaHisto = new TH1D("sigmaHisto", "sigmaHisto", binsX, histo->GetXaxis()->GetXmin(), histo->GetXaxis()->GetXmax()); - TCanvas * backgroundCanvas = new TCanvas("backgroundCanvas", "backgroundCanvas", 1000, 800); - TH1D * backgroundHisto = new TH1D("backgroundHisto", "backgroundHisto", binsX, histo->GetXaxis()->GetXmin(), histo->GetXaxis()->GetXmax()); + TCanvas* backgroundCanvas = new TCanvas("backgroundCanvas", "backgroundCanvas", 1000, 800); + TH1D* backgroundHisto = new TH1D("backgroundHisto", "backgroundHisto", binsX, histo->GetXaxis()->GetXmin(), histo->GetXaxis()->GetXmax()); - TCanvas * backgroundCanvas2 = new TCanvas("backgroundCanvas2", "backgroundCanvas2", 1000, 800); - TH1D * backgroundHisto2 = new TH1D("backgroundHisto2", "exp a1", binsX, histo->GetXaxis()->GetXmin(), histo->GetXaxis()->GetXmax()); + TCanvas* backgroundCanvas2 = new TCanvas("backgroundCanvas2", "backgroundCanvas2", 1000, 800); + TH1D* backgroundHisto2 = new TH1D("backgroundHisto2", "exp a1", binsX, histo->GetXaxis()->GetXmin(), histo->GetXaxis()->GetXmax()); - TCanvas * backgroundCanvas3 = new TCanvas("backgroundCanvas3", "backgroundCanvas3", 1000, 800); - TH1D * backgroundHisto3 = new TH1D("backgroundHisto3", "exp a2", binsX, histo->GetXaxis()->GetXmin(), histo->GetXaxis()->GetXmax()); + TCanvas* backgroundCanvas3 = new TCanvas("backgroundCanvas3", "backgroundCanvas3", 1000, 800); + TH1D* backgroundHisto3 = new TH1D("backgroundHisto3", "exp a2", binsX, histo->GetXaxis()->GetXmin(), histo->GetXaxis()->GetXmax()); - TCanvas * signalFractionCanvas = new TCanvas("signalFractionCanvas", "signalFractionCanvas", 1000, 800); - TH1D * signalFractionHisto = new TH1D("signalFractionHisto", "signalFractionHisto", binsX, histo->GetXaxis()->GetXmin(), histo->GetXaxis()->GetXmax()); + TCanvas* signalFractionCanvas = new TCanvas("signalFractionCanvas", "signalFractionCanvas", 1000, 800); + TH1D* signalFractionHisto = new TH1D("signalFractionHisto", "signalFractionHisto", binsX, histo->GetXaxis()->GetXmin(), histo->GetXaxis()->GetXmax()); - TCanvas * probChi2Canvas = new TCanvas("probChi2Canvas", "probChi2Canvas", 1000, 800); - TH1D * probChi2Histo = new TH1D("probChi2Histo", "probChi2Histo", binsX, histo->GetXaxis()->GetXmin(), histo->GetXaxis()->GetXmax()); + TCanvas* probChi2Canvas = new TCanvas("probChi2Canvas", "probChi2Canvas", 1000, 800); + TH1D* probChi2Histo = new TH1D("probChi2Histo", "probChi2Histo", binsX, histo->GetXaxis()->GetXmin(), histo->GetXaxis()->GetXmax()); // Store all the non-empty slices std::map< unsigned int, TH1 *> slices; - for( unsigned int x=1; x<=binsX; ++x ) { + for (unsigned int x=1; x<=binsX; ++x) { std::stringstream ss; ss << x; - TH1 * sliceHisto = histo->ProjectionY(name+ss.str(), x, x); - if( sliceHisto->GetEntries() != 0 ) { - // std::cout << "filling for x = " << x << endl; - slices.insert(std::make_pair(x, sliceHisto)); - sliceHisto->Rebin(rebinY); + TH1* sliceHisto = histo->ProjectionY(name+ss.str(), x, x); + if (sliceHisto->GetEntries() != 0) { + // std::cout << "filling for x = " << x << endl; + slices.insert(std::make_pair(x, sliceHisto)); + sliceHisto->Rebin(rebinY); } } // Create the canvas for all the fits - TCanvas * fitsCanvas = new TCanvas("fitsCanvas", "fits canvas", 1000, 800); + TCanvas* fitsCanvas = new TCanvas("fitsCanvas", "fits canvas", 1000, 800); // cout << "slices.size = " << slices.size() << endl; unsigned int x = sqrt(slices.size()); unsigned int y = x; - if( x*y < slices.size() ) { + if (x*y < slices.size()) { x += 1; y += 1; } @@ -130,57 +130,56 @@ class FitXslices // Loop on the saved slices and fit std::map::iterator it = slices.begin(); unsigned int i=1; - for( ; it != slices.end(); ++it, ++i ) { + for (; it != slices.end(); ++it, ++i) { fitsCanvas->cd(i); fitter_.fit(it->second, signalType, backgroundType, xMin, xMax); // fitsCanvas->GetPad(i)->SetLogy(); // FIXME: prob(chi2) needs to be computed properly inside FitWithRooFit.cc // probChi2Histo->SetBinContent(it->first, mean->getVal()); - RooRealVar * mean = fitter_.mean(); - + RooRealVar* mean = fitter_.mean(); + meanHisto->SetBinContent(it->first, mean->getVal()); meanHisto->SetBinError(it->first, mean->getError()); - RooRealVar * sigma = fitter_.sigma(); + RooRealVar* sigma = fitter_.sigma(); sigmaHisto->SetBinContent(it->first, sigma->getVal()); sigmaHisto->SetBinError(it->first, sigma->getError()); - + std::cout << "backgroundType = " << backgroundType << std::endl; - if( backgroundType == "exponential" ) { - RooRealVar * expCoeff = fitter_.expCoeffa1(); - backgroundHisto->SetBinContent(it->first, expCoeff->getVal()); - backgroundHisto->SetBinError(it->first, expCoeff->getError()); - + if (backgroundType == "exponential") { + RooRealVar* expCoeff = fitter_.expCoeffa1(); + backgroundHisto->SetBinContent(it->first, expCoeff->getVal()); + backgroundHisto->SetBinError(it->first, expCoeff->getError()); } - else if( backgroundType == "exponentialpol" ) { - RooRealVar * expCoeffa0 = fitter_.expCoeffa0(); - backgroundHisto->SetBinContent(it->first, expCoeffa0->getVal()); - backgroundHisto->SetBinError(it->first, expCoeffa0->getError()); - - RooRealVar * expCoeffa1 = fitter_.expCoeffa1(); - backgroundHisto2->SetBinContent(it->first, expCoeffa1->getVal()); - backgroundHisto2->SetBinError(it->first, expCoeffa1->getError()); - - RooRealVar * expCoeffa2 = fitter_.expCoeffa2(); - backgroundHisto3->SetBinContent(it->first, expCoeffa2->getVal()); - backgroundHisto3->SetBinError(it->first, expCoeffa2->getError()); + else if (backgroundType == "exponentialpol") { + RooRealVar* expCoeffa0 = fitter_.expCoeffa0(); + backgroundHisto->SetBinContent(it->first, expCoeffa0->getVal()); + backgroundHisto->SetBinError(it->first, expCoeffa0->getError()); + + RooRealVar* expCoeffa1 = fitter_.expCoeffa1(); + backgroundHisto2->SetBinContent(it->first, expCoeffa1->getVal()); + backgroundHisto2->SetBinError(it->first, expCoeffa1->getError()); + + RooRealVar* expCoeffa2 = fitter_.expCoeffa2(); + backgroundHisto3->SetBinContent(it->first, expCoeffa2->getVal()); + backgroundHisto3->SetBinError(it->first, expCoeffa2->getError()); } - else if( backgroundType == "linear" ) { - RooRealVar * linearTerm = fitter_.a1(); - backgroundHisto->SetBinContent(it->first, linearTerm->getVal()); - backgroundHisto->SetBinError(it->first, linearTerm->getError()); - - RooRealVar * constant = fitter_.a0(); - backgroundHisto2->SetBinContent(it->first, constant->getVal()); - backgroundHisto2->SetBinError(it->first, constant->getError()); + else if (backgroundType == "linear") { + RooRealVar* linearTerm = fitter_.a1(); + backgroundHisto->SetBinContent(it->first, linearTerm->getVal()); + backgroundHisto->SetBinError(it->first, linearTerm->getError()); + + RooRealVar* constant = fitter_.a0(); + backgroundHisto2->SetBinContent(it->first, constant->getVal()); + backgroundHisto2->SetBinError(it->first, constant->getError()); } - RooRealVar * fsig = fitter_.fsig(); - signalFractionHisto->SetBinContent(it->first, fsig->getVal()); - signalFractionHisto->SetBinError(it->first, fsig->getError()); - + RooRealVar* fsig = fitter_.fsig(); + signalFractionHisto->SetBinContent(it->first, fsig->getVal()); + signalFractionHisto->SetBinError(it->first, fsig->getError()); + fitter_.reinitializeParameters(); } // Go back to the main dir before saving the canvases gDirectory->GetMotherDir()->cd(); @@ -190,11 +189,11 @@ class FitXslices sigmaHisto->Draw(); backgroundCanvas->cd(); backgroundHisto->Draw(); - if( backgroundType == "linear" ) { + if (backgroundType == "linear") { backgroundCanvas2->cd(); backgroundHisto2->Draw(); } - if( backgroundType == "exponentialpol" ) { + if (backgroundType == "exponentialpol") { backgroundCanvas2->cd(); backgroundHisto2->Draw(); backgroundCanvas3->cd(); @@ -210,12 +209,19 @@ class FitXslices sigmaCanvas->Write(); backgroundCanvas->Write(); signalFractionCanvas->Write(); - if( backgroundType == "linear" ) { + if (backgroundType == "linear") { backgroundCanvas2->Write(); } probChi2Canvas->Write(); - // fitSlices(slices, xMin, xMax, signalType, backgroundType, false); ///DEVO PASSARGLI xMin, xMax e il resto.... + fitsCanvas->Close(); + probChi2Canvas->Close(); + signalFractionCanvas->Close(); + backgroundCanvas3->Close(); + backgroundCanvas2->Close(); + backgroundCanvas->Close(); + sigmaCanvas->Close(); + meanCanvas->Close(); } void operator()(TH3 * histo, const double & xMin, const double & xMax, const TString & signalType, const TString & backgroundType, unsigned int rebinZ) @@ -224,7 +230,7 @@ class FitXslices gDirectory->mkdir("allHistos"); gDirectory->cd("allHistos"); - // Loop on all X bins, project on Y and fit the resulting TH2 + // Loop on all X bins, project on Y and fit the resulting TH2 TString name = histo->GetName(); unsigned int binsX = histo->GetNbinsX(); unsigned int binsY = histo->GetNbinsY(); @@ -233,46 +239,46 @@ class FitXslices // std::cout<< "number of bins in y --> "<GetXaxis()->GetXmin(), histo->GetXaxis()->GetXmax(), binsY, histo->GetYaxis()->GetXmin(), histo->GetYaxis()->GetXmax()); - TCanvas * errorMeanCanvas = new TCanvas("errorMeanCanvas", "errorMeanCanvas", 1000, 800); + TCanvas* errorMeanCanvas = new TCanvas("errorMeanCanvas", "errorMeanCanvas", 1000, 800); TH2D * errorMeanHisto = new TH2D("errorMeanHisto", "errorMeanHisto", binsX, histo->GetXaxis()->GetXmin(), histo->GetXaxis()->GetXmax(), binsY, histo->GetYaxis()->GetXmin(), histo->GetYaxis()->GetXmax()); - TCanvas * sigmaCanvas = new TCanvas("sigmaCanvas", "sigmaCanvas", 1000, 800); - TH2D * sigmaHisto = new TH2D("sigmaHisto", "sigmaHisto", binsX, histo->GetXaxis()->GetXmin(), histo->GetXaxis()->GetXmax(),binsY, histo->GetYaxis()->GetXmin(), histo->GetYaxis()->GetXmax()); + TCanvas* sigmaCanvas = new TCanvas("sigmaCanvas", "sigmaCanvas", 1000, 800); + TH2D * sigmaHisto = new TH2D("sigmaHisto", "sigmaHisto", binsX, histo->GetXaxis()->GetXmin(), histo->GetXaxis()->GetXmax(), binsY, histo->GetYaxis()->GetXmin(), histo->GetYaxis()->GetXmax()); - TCanvas * backgroundCanvas = new TCanvas("backgroundCanvas", "backgroundCanvas", 1000, 800); + TCanvas* backgroundCanvas = new TCanvas("backgroundCanvas", "backgroundCanvas", 1000, 800); TH2D * backgroundHisto = new TH2D("backgroundHisto", "backgroundHisto", binsX, histo->GetXaxis()->GetXmin(), histo->GetXaxis()->GetXmax(), binsY, histo->GetYaxis()->GetXmin(), histo->GetYaxis()->GetXmax()); - TCanvas * backgroundCanvas2 = new TCanvas("backgroundCanvas2", "backgroundCanvas2", 1000, 800); + TCanvas* backgroundCanvas2 = new TCanvas("backgroundCanvas2", "backgroundCanvas2", 1000, 800); TH2D * backgroundHisto2 = new TH2D("backgroundHisto2", "a1", binsX, histo->GetXaxis()->GetXmin(), histo->GetXaxis()->GetXmax(), binsY, histo->GetYaxis()->GetXmin(), histo->GetYaxis()->GetXmax()); - TCanvas * backgroundCanvas3 = new TCanvas("backgroundCanvas3", "backgroundCanvas3", 1000, 800); + TCanvas* backgroundCanvas3 = new TCanvas("backgroundCanvas3", "backgroundCanvas3", 1000, 800); TH2D * backgroundHisto3 = new TH2D("backgroundHisto3", "a2", binsX, histo->GetXaxis()->GetXmin(), histo->GetXaxis()->GetXmax(), binsY, histo->GetYaxis()->GetXmin(), histo->GetYaxis()->GetXmax()); - TCanvas * signalFractionCanvas = new TCanvas("signalFractionCanvas", "signalFractionCanvas", 1000, 800); + TCanvas* signalFractionCanvas = new TCanvas("signalFractionCanvas", "signalFractionCanvas", 1000, 800); TH2D * signalFractionHisto = new TH2D("signalFractionHisto", "signalFractionHisto", binsX, histo->GetXaxis()->GetXmin(), histo->GetXaxis()->GetXmax(), binsY, histo->GetYaxis()->GetXmin(), histo->GetYaxis()->GetXmax()); // Store all the non-empty slices std::map slices; - for( unsigned int x=1; x<=binsX; ++x ) { - for( unsigned int y=1; y<=binsY; ++y ) { - std::stringstream ss; - ss << x << "_" << y; - TH1 * sliceHisto = histo->ProjectionZ(name+ss.str(), x, x, y, y); - if( sliceHisto->GetEntries() != 0 ) { - sliceHisto->Rebin(rebinZ); - // std::cout << "filling for x = " << x << endl; - slices.insert(std::make_pair(x+(binsX+1)*y, sliceHisto)); - } + for (unsigned int x=1; x<=binsX; ++x) { + for (unsigned int y=1; y<=binsY; ++y) { + std::stringstream ss; + ss << x << "_" << y; + TH1* sliceHisto = histo->ProjectionZ(name+ss.str(), x, x, y, y); + if (sliceHisto->GetEntries() != 0) { + sliceHisto->Rebin(rebinZ); + // std::cout << "filling for x = " << x << endl; + slices.insert(std::make_pair(x+(binsX+1)*y, sliceHisto)); + } } } - // Create the canvas for all the fits - TCanvas * fitsCanvas = new TCanvas("fitsCanvas", "fits canvas", 1000, 800); + // Create the canvas for all the fits + TCanvas* fitsCanvas = new TCanvas("fitsCanvas", "canvas of all fits", 1000, 800); // cout << "slices.size = " << slices.size() << endl; unsigned int x = sqrt(slices.size()); unsigned int y = x; - if( x*y < slices.size() ) { + if (x*y < slices.size()) { x += 1; y += 1; } @@ -281,12 +287,12 @@ class FitXslices // Loop on the saved slices and fit std::map::iterator it = slices.begin(); unsigned int i=1; - for( ; it != slices.end(); ++it, ++i ) { + for (; it != slices.end(); ++it, ++i) { fitsCanvas->cd(i); fitter_.fit(it->second, signalType, backgroundType, xMin, xMax); - - RooRealVar * mean = fitter_.mean(); + + RooRealVar* mean = fitter_.mean(); meanHisto->SetBinContent(it->first%(binsX+1), int(it->first/(binsX+1)), mean->getVal()); errorMeanHisto->SetBinContent(it->first%(binsX+1), int(it->first/(binsX+1)), mean->getError()); // meanHisto->SetBinError(it->first%binsX, int(it->first/binsX), mean->getError()); @@ -294,65 +300,65 @@ class FitXslices //std::cout<< " it->first%(binsX+1) --> "<first%(binsX+1)<first/(binsX+1) --> "<first/(binsX+1))<SetBinContent(it->first%binsX, int(it->first/binsX), sigma->getVal()); sigmaHisto->SetBinError(it->first%binsX, int(it->first/binsX), sigma->getError()); - + std::cout << "backgroundType = " << backgroundType << std::endl; - if( backgroundType == "exponential" ) { - RooRealVar * expCoeff = fitter_.expCoeffa1(); - backgroundHisto->SetBinContent(it->first%binsX, int(it->first/binsX), expCoeff->getVal()); - backgroundHisto->SetBinError(it->first%binsX, int(it->first/binsX), expCoeff->getError()); + if (backgroundType == "exponential") { + RooRealVar* expCoeff = fitter_.expCoeffa1(); + backgroundHisto->SetBinContent(it->first%binsX, int(it->first/binsX), expCoeff->getVal()); + backgroundHisto->SetBinError(it->first%binsX, int(it->first/binsX), expCoeff->getError()); } - else if( backgroundType == "exponentialpol" ) { - RooRealVar * expCoeffa0 = fitter_.expCoeffa0(); - backgroundHisto->SetBinContent(it->first%binsX, int(it->first/binsX), expCoeffa0->getVal()); - backgroundHisto->SetBinError(it->first%binsX, int(it->first/binsX), expCoeffa0->getError()); - - RooRealVar * expCoeffa1= fitter_.expCoeffa1(); - backgroundHisto2->SetBinContent(it->first%binsX, int(it->first/binsX), expCoeffa1->getVal()); - backgroundHisto2->SetBinError(it->first%binsX, int(it->first/binsX), expCoeffa1->getError()); - - RooRealVar * expCoeffa2= fitter_.expCoeffa2(); - backgroundHisto3->SetBinContent(it->first%binsX, int(it->first/binsX), expCoeffa2->getVal()); - backgroundHisto3->SetBinError(it->first%binsX, int(it->first/binsX), expCoeffa2->getError()); + else if (backgroundType == "exponentialpol") { + RooRealVar* expCoeffa0 = fitter_.expCoeffa0(); + backgroundHisto->SetBinContent(it->first%binsX, int(it->first/binsX), expCoeffa0->getVal()); + backgroundHisto->SetBinError(it->first%binsX, int(it->first/binsX), expCoeffa0->getError()); + + RooRealVar* expCoeffa1= fitter_.expCoeffa1(); + backgroundHisto2->SetBinContent(it->first%binsX, int(it->first/binsX), expCoeffa1->getVal()); + backgroundHisto2->SetBinError(it->first%binsX, int(it->first/binsX), expCoeffa1->getError()); + + RooRealVar* expCoeffa2= fitter_.expCoeffa2(); + backgroundHisto3->SetBinContent(it->first%binsX, int(it->first/binsX), expCoeffa2->getVal()); + backgroundHisto3->SetBinError(it->first%binsX, int(it->first/binsX), expCoeffa2->getError()); } - else if( backgroundType == "linear" ) { - RooRealVar * linearTerm = fitter_.a1(); - backgroundHisto->SetBinContent(it->first%binsX, int(it->first/binsX), linearTerm->getVal()); - backgroundHisto->SetBinError(it->first%binsX, int(it->first/binsX), linearTerm->getError()); - - RooRealVar * constant = fitter_.a0(); - backgroundHisto2->SetBinContent(it->first%binsX, int(it->first/binsX), constant->getVal()); - backgroundHisto2->SetBinError(it->first%binsX, int(it->first/binsX), constant->getError()); + else if (backgroundType == "linear") { + RooRealVar* linearTerm = fitter_.a1(); + backgroundHisto->SetBinContent(it->first%binsX, int(it->first/binsX), linearTerm->getVal()); + backgroundHisto->SetBinError(it->first%binsX, int(it->first/binsX), linearTerm->getError()); + + RooRealVar* constant = fitter_.a0(); + backgroundHisto2->SetBinContent(it->first%binsX, int(it->first/binsX), constant->getVal()); + backgroundHisto2->SetBinError(it->first%binsX, int(it->first/binsX), constant->getError()); } - - RooRealVar * fsig = fitter_.fsig(); + RooRealVar* fsig = fitter_.fsig(); signalFractionHisto->SetBinContent(it->first%binsX, int(it->first/binsX), fsig->getVal()); signalFractionHisto->SetBinError(it->first%binsX, int(it->first/binsX), fsig->getError()); + fitter_.reinitializeParameters(); } // Go back to the main dir before saving the canvases gDirectory->GetMotherDir()->cd(); meanCanvas->cd(); - meanHisto->GetXaxis()->SetRangeUser(-3.14,3.14); - meanHisto->GetYaxis()->SetRangeUser(-2.5,2.5); + meanHisto->GetXaxis()->SetRangeUser(-3.14, 3.14); + meanHisto->GetYaxis()->SetRangeUser(-2.5, 2.5); meanHisto->GetXaxis()->SetTitle("#phi (rad)"); meanHisto->GetYaxis()->SetTitle("#eta"); meanHisto->Draw("COLZ"); sigmaCanvas->cd(); - sigmaHisto->GetXaxis()->SetRangeUser(-3.14,3.14); - sigmaHisto->GetYaxis()->SetRangeUser(-2.5,2.5); + sigmaHisto->GetXaxis()->SetRangeUser(-3.14, 3.14); + sigmaHisto->GetYaxis()->SetRangeUser(-2.5, 2.5); sigmaHisto->GetXaxis()->SetTitle("#phi (rad)"); sigmaHisto->GetYaxis()->SetTitle("#eta"); sigmaHisto->Draw("COLZ"); backgroundCanvas->cd(); backgroundHisto->Draw("COLZ"); - if( backgroundType == "linear" ) { + if (backgroundType == "linear") { backgroundCanvas2->cd(); backgroundHisto2->Draw("COLZ"); } @@ -364,11 +370,18 @@ class FitXslices sigmaCanvas->Write(); backgroundCanvas->Write(); signalFractionCanvas->Write(); - if( backgroundType == "linear" ) { + if (backgroundType == "linear") { backgroundCanvas2->Write(); } - // fitSlices(slices, xMin, xMax, signalType, backgroundType, true); + fitsCanvas->Close(); + signalFractionCanvas->Close(); + backgroundCanvas3->Close(); + backgroundCanvas2->Close(); + backgroundCanvas->Close(); + sigmaCanvas->Close(); + errorMeanCanvas->Close(); + meanCanvas->Close(); } protected: diff --git a/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/MultiHistoOverlapAll_Z.C b/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/MultiHistoOverlapAll_Z.C new file mode 100644 index 0000000000000..9bcf4b535c381 --- /dev/null +++ b/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/MultiHistoOverlapAll_Z.C @@ -0,0 +1,298 @@ +#include +#include +#include "TROOT.h" +#include "TH1F.h" +#include "TH1D.h" +#include "TF1.h" +#include "TMath.h" +#include "TNtuple.h" +#include "TLegend.h" +#include "TCanvas.h" +#include "TCutG.h" +#include "TFile.h" +#include "TString.h" +#include "TH2.h" +#include "TPad.h" +#include "TPaveText.h" +#include "tdrstyle.C" + + +using namespace ROOT::Math; + +void splitOption(string rawoption, string& wish, string& value, char delimiter){ + size_t posEq = rawoption.find(delimiter); + if (posEq!=string::npos){ + wish=rawoption; + value=rawoption.substr(posEq+1); + wish.erase(wish.begin()+posEq, wish.end()); + } + else{ + wish=""; + value=rawoption; + } +} +void splitOptionRecursive(string rawoption, vector& splitoptions, char delimiter){ + string suboption=rawoption, result=rawoption; + string remnant; + while (result!=""){ + splitOption(suboption, result, remnant, delimiter); + if (result!="") splitoptions.push_back(result); + suboption = remnant; + } + if (remnant!="") splitoptions.push_back(remnant); +} +void MultiHistoOverlapAll_Z(string files, string labels, bool switchONfitEta = false, bool switchONfit = false){ + gROOT->Reset(); + setTDRStyle(); + + vector strValidation_file; + vector strValidation_label; + splitOptionRecursive(files, strValidation_file, ','); + splitOptionRecursive(labels, strValidation_label, ','); + int nfiles = strValidation_file.size(); + int nlabels = strValidation_label.size(); + if (nlabels!=nfiles){ + cout << "nlabels!=nfiles" << endl; + return; + } + + TPaveText *cmsPlotTitle = new TPaveText(0.15, 0.93, 0.85, 1, "brNDC"); + cmsPlotTitle->SetBorderSize(0); + cmsPlotTitle->SetFillStyle(0); + cmsPlotTitle->SetTextAlign(12); + cmsPlotTitle->SetTextFont(42); + cmsPlotTitle->SetTextSize(0.045); + TText* text = cmsPlotTitle->AddText(0.025, 0.45, "#font[61]{CMS}"); + text->SetTextSize(0.044); + text = cmsPlotTitle->AddText(0.165, 0.42, "#font[52]{Preliminary}"); + text->SetTextSize(0.0315); + TString cErgTev = "#font[42]{ TkAl Z#rightarrow#mu#mu (|#eta_{#mu}|<2.4) 13 TeV}"; + text = cmsPlotTitle->AddText(0.537, 0.40, cErgTev); + text->SetTextSize(0.0315); + + TH1D** histo[7]; + TF1** hfit[7]; + TFile** file = new TFile*[nfiles]; + for (int c=0; c<7; c++){ + histo[c] = new TH1D*[nfiles]; + hfit[c] = new TF1*[nfiles]; + } + + for (int f=0; fSetOptStat(0); + c[i]->SetFillColor(0); + c[i]->SetBorderMode(0); + c[i]->SetBorderSize(2); + c[i]->SetTickx(1); + c[i]->SetTicky(1); + c[i]->SetLeftMargin(0.17); + c[i]->SetRightMargin(0.05); + c[i]->SetTopMargin(0.07); + c[i]->SetBottomMargin(0.13); + c[i]->SetFrameFillStyle(0); + c[i]->SetFrameBorderMode(0); + c[i]->SetFrameFillStyle(0); + c[i]->SetFrameBorderMode(0); + } + + float lxmin = 0.22, lxwidth = 0.38; + float lymax = 0.9, lywidth = 0.15*nfiles/3; + float lxmax = lxmin + lxwidth; + float lymin = lymax - lywidth; + TLegend* leg = new TLegend(lxmin, lymin, lxmax, lymax); + leg->SetBorderSize(0); + leg->SetTextFont(42); + leg->SetTextSize(0.04); + leg->SetLineColor(1); + leg->SetLineStyle(1); + leg->SetLineWidth(1); + leg->SetFillColor(0); + leg->SetFillStyle(0); + + //----------------- CANVAS C0 --------------// + pIndex=0; + c[pIndex]->cd(); + + TString histoName[7] ={ + "MassVsPhiPlus/allHistos/meanHisto", + "MassVsPhiMinus/allHistos/meanHisto", + "MassVsEtaPlus/allHistos/meanHisto", + "MassVsEtaMinus/allHistos/meanHisto", + "MassVsEtaPlusMinusDiff/allHistos/meanHisto", + "MassVsCosThetaCS/allHistos/meanHisto", + "MassVsPhiCS/allHistos/meanHisto" + }; + TString xtitle[7] ={ + "#phi_{#mu+}", + "#phi_{#mu-}", + "#eta_{#mu+}", + "#eta_{#mu-}", + "#eta_{#mu+} - #eta_{#mu-}", + "cos #theta_{CS}", + "#phi_{CS}" + }; + TString plotname[7] ={ + "MassVsPhiPlus_ALL", + "MassVsPhiMinus_ALL", + "MassVsEtaPlus_ALL", + "MassVsEtaMinus_ALL", + "MassVsDeltaEta_ALL", + "MassVsCosThetaCS_ALL", + "MassVsPhiCS_ALL" + }; + TString fitFormula[7]={ + "[0]+[1]*cos(x+[2])", + "[0]+[1]*cos(x+[2])", + "[0]+[1]*x", + "[0]+[1]*x", + "[0]+[1]*x", + "[0]+[1]*cos(x+[2])", + "[0]+[1]*cos(x+[2])" + }; + double plot_xmax[7]={ + TMath::Pi(), + TMath::Pi(), + 2.4, + 2.4, + 4.8, + 1, + TMath::Pi() + }; + + for (int iP=0; iP<7; iP++){ + double absMin=9e9; + double absMax = -9e9; + for (int f=0; fGet(histoName[iP]); + + histo[iP][f]->SetTitle(""); + histo[iP][f]->GetXaxis()->SetLabelFont(42); + histo[iP][f]->GetXaxis()->SetLabelOffset(0.007); + histo[iP][f]->GetXaxis()->SetLabelSize(0.04); + histo[iP][f]->GetXaxis()->SetTitleSize(0.06); + histo[iP][f]->GetXaxis()->SetTitleOffset(0.9); + histo[iP][f]->GetXaxis()->SetTitleFont(42); + histo[iP][f]->GetYaxis()->SetNdivisions(505); + histo[iP][f]->GetYaxis()->SetLabelFont(42); + histo[iP][f]->GetYaxis()->SetLabelOffset(0.007); + histo[iP][f]->GetYaxis()->SetLabelSize(0.04); + histo[iP][f]->GetYaxis()->SetTitleSize(0.06); + histo[iP][f]->GetYaxis()->SetTitleOffset(1.2); + histo[iP][f]->GetYaxis()->SetTitleFont(42); + + histo[iP][f]->GetYaxis()->SetTitle("M_{#mu#mu} (GeV)"); + histo[iP][f]->SetLineWidth(1); + histo[iP][f]->SetMarkerSize(1.2); + + if (strValidation_label.at(f).find("reference")!=string::npos || strValidation_label.at(f).find("Reference")!=string::npos) histo[iP][f]->SetMarkerStyle(1); + else histo[iP][f]->SetMarkerStyle(20); + + if (f==0){ + histo[iP][f]->SetLineColor(kBlack); + histo[iP][f]->SetMarkerColor(kBlack); + } + else if (f==(nfiles-1)){ + histo[iP][f]->SetLineColor(kViolet); + histo[iP][f]->SetMarkerColor(kViolet); + } + else if (f==1){ + histo[iP][f]->SetLineColor(kBlue); + histo[iP][f]->SetMarkerColor(kBlue); + } + else if (f==2){ + histo[iP][f]->SetLineColor(kRed); + histo[iP][f]->SetMarkerColor(kRed); + } + else if (f==3){ + histo[iP][f]->SetLineColor(kGreen+2); + histo[iP][f]->SetMarkerColor(kGreen+2); + } + else if (f==4){ + histo[iP][f]->SetLineColor(kOrange+3); + histo[iP][f]->SetMarkerColor(kOrange+3); + } + else if (f==5){ + histo[iP][f]->SetLineColor(kGreen); + histo[iP][f]->SetMarkerColor(kGreen); + } + else if (f==6){ + histo[iP][f]->SetLineColor(kYellow); + histo[iP][f]->SetMarkerColor(kYellow); + } + else if (f==7){ + histo[iP][f]->SetLineColor(kPink+9); + histo[iP][f]->SetMarkerColor(kPink+9); + } + else if (f==8){ + histo[iP][f]->SetLineColor(kCyan); + histo[iP][f]->SetMarkerColor(kCyan); + } + else if (f==9){ + histo[iP][f]->SetLineColor(kGreen+3); + histo[iP][f]->SetMarkerColor(kGreen+3); + } + for (int bin=1; bin<=histo[iP][f]->GetNbinsX(); bin++){ + double bincontent = histo[iP][f]->GetBinContent(bin); + double binerror = histo[iP][f]->GetBinError(bin); + if (binerror==0 && bincontent==0) continue; + absMin = min(absMin, bincontent - binerror); + absMax = max(absMax, bincontent + binerror); + } + + if (iP==0) leg->AddEntry(histo[iP][f], (strValidation_label.at(f)).c_str(), "lp"); + } + minmax_plot[iP][0] = absMin/1.1; + minmax_plot[iP][1] = absMax*1.1; + for (int f=0; f<2; f++) histo[iP][f]->GetYaxis()->SetRangeUser(minmax_plot[iP][0], minmax_plot[iP][1]); + } + + for (int pIndex=0; pIndex<7; pIndex++){ + for (int f=0; fcd(); + histo[pIndex][f]->GetXaxis()->SetTitle(xtitle[pIndex]); + histo[pIndex][f]->GetXaxis()->SetRangeUser(-plot_xmax[pIndex], plot_xmax[pIndex]); + if (f==0) histo[pIndex][f]->Draw(); + else histo[pIndex][f]->Draw("same"); + + hfit[pIndex][f] = new TF1(Form("fit_%i_%i", pIndex, f), fitFormula[pIndex], -plot_xmax[pIndex], plot_xmax[pIndex]); + hfit[pIndex][f]->SetParameter(0, 90.5); + hfit[pIndex][f]->SetParameter(1, 0); + if (fitFormula[pIndex].Contains("[2]")) hfit[pIndex][f]->SetParameter(2, 0); + hfit[pIndex][f]->SetLineColor(1); + if (switchONfit){ + histo[pIndex][f]->Fit(hfit[pIndex][f], "R", "same", -plot_xmax[pIndex], plot_xmax[pIndex]); + hfit[pIndex][f]->Draw("same"); + } + } + leg->Draw("same"); + cmsPlotTitle->Draw("same"); + c[pIndex]->RedrawAxis(); + c[pIndex]->Modified(); + c[pIndex]->Update(); + c[pIndex]->SaveAs(Form("%s%s", plotname[pIndex].Data(), ".png")); + c[pIndex]->SaveAs(Form("%s%s", plotname[pIndex].Data(), ".pdf")); + + for (int f=0; fClose(); + } + + delete leg; + for(int f=nfiles-1;f>=0;f--) file[f]->Close(); + + delete[] file; + for (int c=0; c<7; c++){ + delete[] hfit[c]; + delete[] histo[c]; + } +} From b8863785b8e2e052cb7af12ee1bfad2f9fa2d016 Mon Sep 17 00:00:00 2001 From: usarica Date: Thu, 3 Sep 2015 21:40:10 +0200 Subject: [PATCH 3/9] Latest additions for plotting, bkg model --- .../zMuMuValidationTemplates.py | 2 +- .../Macros/RooFit/CompareBiasZValidation.cc | 7 +++-- .../Macros/RooFit/MultiHistoOverlapAll_Z.C | 29 +++++++++++++++---- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/Alignment/OfflineValidation/python/TkAlAllInOneTool/zMuMuValidationTemplates.py b/Alignment/OfflineValidation/python/TkAlAllInOneTool/zMuMuValidationTemplates.py index de7da5eb6400a..9b19c145473ae 100644 --- a/Alignment/OfflineValidation/python/TkAlAllInOneTool/zMuMuValidationTemplates.py +++ b/Alignment/OfflineValidation/python/TkAlAllInOneTool/zMuMuValidationTemplates.py @@ -251,7 +251,7 @@ cp .oO[CMSSW_BASE]Oo./src/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/FitWithRooFit.cc . cp .oO[CMSSW_BASE]Oo./src/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/FitMass1D.cc . -root -q -b -l "CompareBiasZValidation.cc+(\\\"\\\")" +root -q -b -l "CompareBiasZValidation.cc+()" cp .oO[CMSSW_BASE]Oo./src/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/tdrstyle.C . cp .oO[CMSSW_BASE]Oo./src/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/MultiHistoOverlap_.oO[resonance]Oo..C . diff --git a/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/CompareBiasZValidation.cc b/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/CompareBiasZValidation.cc index a9de423073b4d..2c9942152bd73 100644 --- a/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/CompareBiasZValidation.cc +++ b/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/CompareBiasZValidation.cc @@ -13,7 +13,7 @@ class CompareBiasZValidation { public: - CompareBiasZValidation(const TString& leg) + CompareBiasZValidation(const int rebinXphi = 4, const int rebinXetadiff = 2, const int rebinXeta = 2, const int rebinXpt = 8) { @@ -36,7 +36,10 @@ class CompareBiasZValidation fitter.sigma2 = 1.; double Mmin(75), Mmax(105); - fitter.fit(inputFileName, outputFileName, "breitWignerTimesCB", "exponentialpol", 91, Mmin, Mmax, 2, 0.1, 10); + fitter.fit( + inputFileName, outputFileName, "breitWignerTimesCB", "exponentialpol", 91, Mmin, Mmax, 2, 0.1, 10, + rebinXphi, rebinXetadiff, rebinXeta, rebinXpt + ); FitMass1D fitMass1D; //fitMass1D.rebinX = 10; diff --git a/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/MultiHistoOverlapAll_Z.C b/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/MultiHistoOverlapAll_Z.C index 9bcf4b535c381..13fe611a7b691 100644 --- a/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/MultiHistoOverlapAll_Z.C +++ b/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/MultiHistoOverlapAll_Z.C @@ -167,8 +167,13 @@ void MultiHistoOverlapAll_Z(string files, string labels, bool switchONfitEta = f }; for (int iP=0; iP<7; iP++){ - double absMin=9e9; + double absMin = 9e9; double absMax = -9e9; + double rangeMaxReduction = 0.02; + + double avgM = 0; + double sigmaM = 0; + for (int f=0; fGet(histoName[iP]); @@ -238,18 +243,32 @@ void MultiHistoOverlapAll_Z(string files, string labels, bool switchONfitEta = f histo[iP][f]->SetLineColor(kGreen+3); histo[iP][f]->SetMarkerColor(kGreen+3); } + + if (iP==0) leg->AddEntry(histo[iP][f], (strValidation_label.at(f)).c_str(), "lp"); + for (int bin=1; bin<=histo[iP][f]->GetNbinsX(); bin++){ double bincontent = histo[iP][f]->GetBinContent(bin); double binerror = histo[iP][f]->GetBinError(bin); if (binerror==0 && bincontent==0) continue; absMin = min(absMin, bincontent - binerror); absMax = max(absMax, bincontent + binerror); + avgM += bincontent/pow(binerror, 2); + sigmaM += 1./pow(binerror, 2); } - - if (iP==0) leg->AddEntry(histo[iP][f], (strValidation_label.at(f)).c_str(), "lp"); } - minmax_plot[iP][0] = absMin/1.1; - minmax_plot[iP][1] = absMax*1.1; + avgM /= sigmaM; + sigmaM = sqrt(1./sigmaM); + for (int f=0; fGetNbinsX(); bin++){ + double bincontent = histo[iP][f]->GetBinContent(bin); + double binerror = histo[iP][f]->GetBinError(bin); + if (binerror==0 && bincontent==0) continue; + if ((bincontent + binerror)>1.05*avgM) rangeMaxReduction = 0; + } + } + + minmax_plot[iP][0] = absMin/1.01; + minmax_plot[iP][1] = absMax*(1.05-rangeMaxReduction); for (int f=0; f<2; f++) histo[iP][f]->GetYaxis()->SetRangeUser(minmax_plot[iP][0], minmax_plot[iP][1]); } From 021fc1cc29f1e03b3728899b265d22709672fe48 Mon Sep 17 00:00:00 2001 From: usarica Date: Fri, 4 Sep 2015 03:53:44 +0200 Subject: [PATCH 4/9] Improve plotting scripts furter for range --- .../test/Macros/RooFit/CompareBiasZValidation.cc | 2 +- .../test/Macros/RooFit/MultiHistoOverlapAll_Z.C | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/CompareBiasZValidation.cc b/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/CompareBiasZValidation.cc index 2c9942152bd73..6485dd6e88f0f 100644 --- a/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/CompareBiasZValidation.cc +++ b/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/CompareBiasZValidation.cc @@ -37,7 +37,7 @@ class CompareBiasZValidation double Mmin(75), Mmax(105); fitter.fit( - inputFileName, outputFileName, "breitWignerTimesCB", "exponentialpol", 91, Mmin, Mmax, 2, 0.1, 10, + inputFileName, outputFileName, "breitWignerTimesCB", "exponential", 91, Mmin, Mmax, 2, 0.1, 10, rebinXphi, rebinXetadiff, rebinXeta, rebinXpt ); diff --git a/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/MultiHistoOverlapAll_Z.C b/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/MultiHistoOverlapAll_Z.C index 13fe611a7b691..1fdb20c252fb8 100644 --- a/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/MultiHistoOverlapAll_Z.C +++ b/MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/MultiHistoOverlapAll_Z.C @@ -166,10 +166,19 @@ void MultiHistoOverlapAll_Z(string files, string labels, bool switchONfitEta = f TMath::Pi() }; + // Magic numbers + int nfileslimit = 4; + double rangeFactor[2]={ 1.01, 1.05 }; + double dampingFactor = 0; + double deviationThreshold = 1.04; + if (nfiles>nfileslimit) dampingFactor = 0.07/nfileslimit*(nfiles-nfileslimit); + for (int iP=0; iP<7; iP++){ double absMin = 9e9; double absMax = -9e9; double rangeMaxReduction = 0.02; + if (nfiles>nfileslimit) rangeMaxReduction = rangeMaxReduction*nfileslimit/nfiles; + double dampingFactorEff = dampingFactor; double avgM = 0; double sigmaM = 0; @@ -263,12 +272,13 @@ void MultiHistoOverlapAll_Z(string files, string labels, bool switchONfitEta = f double bincontent = histo[iP][f]->GetBinContent(bin); double binerror = histo[iP][f]->GetBinError(bin); if (binerror==0 && bincontent==0) continue; - if ((bincontent + binerror)>1.05*avgM) rangeMaxReduction = 0; + if ((bincontent + binerror)>deviationThreshold*avgM) rangeMaxReduction = 0; } } + if (nfiles>nfileslimit && rangeMaxReduction!=0) dampingFactorEff = dampingFactorEff*0.7; - minmax_plot[iP][0] = absMin/1.01; - minmax_plot[iP][1] = absMax*(1.05-rangeMaxReduction); + minmax_plot[iP][0] = absMin/rangeFactor[0]; + minmax_plot[iP][1] = absMax*(rangeFactor[1]+dampingFactorEff-rangeMaxReduction); for (int f=0; f<2; f++) histo[iP][f]->GetYaxis()->SetRangeUser(minmax_plot[iP][0], minmax_plot[iP][1]); } From caf68c48b388b1684fe002e015567790e82d37f7 Mon Sep 17 00:00:00 2001 From: usarica Date: Tue, 8 Sep 2015 16:51:55 +0200 Subject: [PATCH 5/9] Example file for Zmumu --- .../OfflineValidation/test/zmumuValidate.ini | 195 +++++++++++++----- 1 file changed, 148 insertions(+), 47 deletions(-) diff --git a/Alignment/OfflineValidation/test/zmumuValidate.ini b/Alignment/OfflineValidation/test/zmumuValidate.ini index 182549f165f72..6f46617a5d2eb 100644 --- a/Alignment/OfflineValidation/test/zmumuValidate.ini +++ b/Alignment/OfflineValidation/test/zmumuValidate.ini @@ -13,6 +13,7 @@ jobmode = lxBatch, -q cmscaf1nd ############################################################################### # configuration of several alignments + [alignment:alignment_defgt] title=alignment_{Default GT} globaltag = GR_P_V56 @@ -21,90 +22,180 @@ condition SiStripLorentzAngleRcd = frontier://FrontierProd/CMS_CONDITIONS,SiStri color = 633 style = 1 +[alignment:alignment_PCL] +title=alignment_PCL +globaltag = GR_P_V56 +#condition TrackerAlignmentErrorExtendedRcd = zeroAPE +condition TrackerAlignmentRcd = sqlite_file:/afs/cern.ch/work/c/chmartin/public/pp3.8T_2015_Alignment/Local_DB/TkAlignment.db,testTag +condition TrackerSurfaceDeformationRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN2/HIP/xiaomeng/Inflate/CMSSW_7_4_0_pre6/src/Alignment/HIPAlignmentAlgorithm/MP1700_sd.db,Deformations_mp +condition SiStripBackPlaneCorrectionRcd = frontier://FrontierProd/CMS_CONDITIONS,SiStripBackPlaneCorrection_deco_GR10_v4_offline,deconvolution +condition SiStripLorentzAngleRcd = frontier://FrontierProd/CMS_CONDITIONS,SiStripLorentzAngleDeco_v3_offline,deconvolution +condition SiPixelLorentzAngleRcd = frontier://FrontierProd/CMS_CONDITIONS,SiPixelLorentzAngle_2015_v2_hltvalidation +condition SiPixelTemplateDBObjectRcd = frontier://FrontierProd/CMS_CONDITIONS,SiPixelTemplateDBObject_38T_2015_v1_hltvalidation +#condition SiPixelTemplateDBObjectRcd = sqlite_file:/afs/cern.ch/user/d/dkotlins/public/CMSSW/DB/310815/SiPixelTemplateDBObject_38T_2015_v3.db,SiPixelTemplateDBObject38Tv10 +color = 633 +style = 1 + [alignment:alignment_hp1394] title=alignment_hp1394 globaltag = GR_P_V56 +#condition TrackerAlignmentErrorExtendedRcd = zeroAPE condition TrackerAlignmentRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN2/HIP/cayou/CMSSW_7_4_6_patch5/src/Alignment/HIPAlignmentAlgorithm/hp1394/alignments_iter20.db, Alignments -condition TrackerAlignmentErrorExtendedRcd = zeroAPE +condition TrackerSurfaceDeformationRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN2/HIP/xiaomeng/Inflate/CMSSW_7_4_0_pre6/src/Alignment/HIPAlignmentAlgorithm/MP1700_sd.db,Deformations_mp condition SiStripBackPlaneCorrectionRcd = frontier://FrontierProd/CMS_CONDITIONS,SiStripBackPlaneCorrection_deco_GR10_v4_offline,deconvolution condition SiStripLorentzAngleRcd = frontier://FrontierProd/CMS_CONDITIONS,SiStripLorentzAngleDeco_v3_offline,deconvolution +condition SiPixelLorentzAngleRcd = frontier://FrontierProd/CMS_CONDITIONS,SiPixelLorentzAngle_2015_v2_hltvalidation +condition SiPixelTemplateDBObjectRcd = frontier://FrontierProd/CMS_CONDITIONS,SiPixelTemplateDBObject_38T_2015_v1_hltvalidation +#condition SiPixelTemplateDBObjectRcd = sqlite_file:/afs/cern.ch/user/d/dkotlins/public/CMSSW/DB/310815/SiPixelTemplateDBObject_38T_2015_v3.db,SiPixelTemplateDBObject38Tv10 +color = 633 +style = 1 + +[alignment:alignment_hp1398] +title=alignment_hp1398 +globaltag = GR_P_V56 +#condition TrackerAlignmentErrorExtendedRcd = zeroAPE +condition TrackerAlignmentRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN2/HIP/cayou/CMSSW_7_4_6_patch5/src/Alignment/HIPAlignmentAlgorithm/hp1398_2/alignments_iter15.db, Alignments +condition TrackerSurfaceDeformationRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN2/HIP/xiaomeng/Inflate/CMSSW_7_4_0_pre6/src/Alignment/HIPAlignmentAlgorithm/MP1700_sd.db,Deformations_mp +condition SiStripBackPlaneCorrectionRcd = frontier://FrontierProd/CMS_CONDITIONS,SiStripBackPlaneCorrection_deco_GR10_v4_offline,deconvolution +condition SiStripLorentzAngleRcd = frontier://FrontierProd/CMS_CONDITIONS,SiStripLorentzAngleDeco_v3_offline,deconvolution +condition SiPixelLorentzAngleRcd = frontier://FrontierProd/CMS_CONDITIONS,SiPixelLorentzAngle_2015_v2_hltvalidation +condition SiPixelTemplateDBObjectRcd = frontier://FrontierProd/CMS_CONDITIONS,SiPixelTemplateDBObject_38T_2015_v1_hltvalidation +#condition SiPixelTemplateDBObjectRcd = sqlite_file:/afs/cern.ch/user/d/dkotlins/public/CMSSW/DB/310815/SiPixelTemplateDBObject_38T_2015_v3.db,SiPixelTemplateDBObject38Tv10 +color = 633 +style = 1 + +[alignment:alignment_hp1400] +title=alignment_hp1400 +globaltag = GR_P_V56 +#condition TrackerAlignmentErrorExtendedRcd = zeroAPE +condition TrackerAlignmentRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN2/HIP/cayou/CMSSW_7_4_6_patch5/src/Alignment/HIPAlignmentAlgorithm/hp1400/alignments_iter20.db, Alignments +condition TrackerSurfaceDeformationRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN2/HIP/xiaomeng/Inflate/CMSSW_7_4_0_pre6/src/Alignment/HIPAlignmentAlgorithm/MP1700_sd.db,Deformations_mp +condition SiStripBackPlaneCorrectionRcd = frontier://FrontierProd/CMS_CONDITIONS,SiStripBackPlaneCorrection_deco_GR10_v4_offline,deconvolution +condition SiStripLorentzAngleRcd = frontier://FrontierProd/CMS_CONDITIONS,SiStripLorentzAngleDeco_v3_offline,deconvolution +condition SiPixelLorentzAngleRcd = frontier://FrontierProd/CMS_CONDITIONS,SiPixelLorentzAngle_2015_v2_hltvalidation +#condition SiPixelTemplateDBObjectRcd = frontier://FrontierProd/CMS_CONDITIONS,SiPixelTemplateDBObject_38T_2015_v1_hltvalidation +condition SiPixelTemplateDBObjectRcd = sqlite_file:/afs/cern.ch/user/d/dkotlins/public/CMSSW/DB/310815/SiPixelTemplateDBObject_38T_2015_v3.db,SiPixelTemplateDBObject38Tv10 +color = 633 +style = 1 + +[alignment:alignment_hp1401] +title=alignment_hp1401 +globaltag = GR_P_V56 +#condition TrackerAlignmentErrorExtendedRcd = zeroAPE +condition TrackerAlignmentRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN2/HIP/cayou/CMSSW_7_4_6_patch5/src/Alignment/HIPAlignmentAlgorithm/hp1401/alignments_iter30.db, Alignments +condition TrackerSurfaceDeformationRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN2/HIP/xiaomeng/Inflate/CMSSW_7_4_0_pre6/src/Alignment/HIPAlignmentAlgorithm/MP1700_sd.db,Deformations_mp +condition SiStripBackPlaneCorrectionRcd = frontier://FrontierProd/CMS_CONDITIONS,SiStripBackPlaneCorrection_deco_GR10_v4_offline,deconvolution +condition SiStripLorentzAngleRcd = frontier://FrontierProd/CMS_CONDITIONS,SiStripLorentzAngleDeco_v3_offline,deconvolution +condition SiPixelLorentzAngleRcd = frontier://FrontierProd/CMS_CONDITIONS,SiPixelLorentzAngle_2015_v2_hltvalidation +#condition SiPixelTemplateDBObjectRcd = frontier://FrontierProd/CMS_CONDITIONS,SiPixelTemplateDBObject_38T_2015_v1_hltvalidation +condition SiPixelTemplateDBObjectRcd = sqlite_file:/afs/cern.ch/user/d/dkotlins/public/CMSSW/DB/310815/SiPixelTemplateDBObject_38T_2015_v3.db,SiPixelTemplateDBObject38Tv10 color = 633 style = 1 [alignment:alignment_mp1819] title=alignment_mp1819 globaltag = GR_P_V56 +#condition TrackerAlignmentErrorExtendedRcd = zeroAPE condition TrackerAlignmentRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/MP/MPproduction/mp1819/jobData/jobm/alignments_MP.db, Alignments condition TrackerSurfaceDeformationRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/MP/MPproduction/mp1819/jobData/jobm/alignments_MP.db, Deformations -condition TrackerAlignmentErrorExtendedRcd = zeroAPE condition SiStripBackPlaneCorrectionRcd = frontier://FrontierProd/CMS_CONDITIONS,SiStripBackPlaneCorrection_deco_GR10_v4_offline,deconvolution condition SiStripLorentzAngleRcd = frontier://FrontierProd/CMS_CONDITIONS,SiStripLorentzAngleDeco_v3_offline,deconvolution +condition SiPixelLorentzAngleRcd = frontier://FrontierProd/CMS_CONDITIONS,SiPixelLorentzAngle_2015_v2_hltvalidation +condition SiPixelTemplateDBObjectRcd = frontier://FrontierProd/CMS_CONDITIONS,SiPixelTemplateDBObject_38T_2015_v1_hltvalidation +#condition SiPixelTemplateDBObjectRcd = sqlite_file:/afs/cern.ch/user/d/dkotlins/public/CMSSW/DB/310815/SiPixelTemplateDBObject_38T_2015_v3.db,SiPixelTemplateDBObject38Tv10 color = 633 style = 1 [alignment:alignment_mp1820] title=alignment_mp1820 globaltag = GR_P_V56 +#condition TrackerAlignmentErrorExtendedRcd = zeroAPE condition TrackerAlignmentRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/MP/MPproduction/mp1820/jobData/jobm/alignments_MP.db, Alignments condition TrackerSurfaceDeformationRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/MP/MPproduction/mp1820/jobData/jobm/alignments_MP.db, Deformations -condition TrackerAlignmentErrorExtendedRcd = zeroAPE condition SiStripBackPlaneCorrectionRcd = frontier://FrontierProd/CMS_CONDITIONS,SiStripBackPlaneCorrection_deco_GR10_v4_offline,deconvolution condition SiStripLorentzAngleRcd = frontier://FrontierProd/CMS_CONDITIONS,SiStripLorentzAngleDeco_v3_offline,deconvolution +condition SiPixelLorentzAngleRcd = frontier://FrontierProd/CMS_CONDITIONS,SiPixelLorentzAngle_2015_v2_hltvalidation +condition SiPixelTemplateDBObjectRcd = frontier://FrontierProd/CMS_CONDITIONS,SiPixelTemplateDBObject_38T_2015_v1_hltvalidation +#condition SiPixelTemplateDBObjectRcd = sqlite_file:/afs/cern.ch/user/d/dkotlins/public/CMSSW/DB/310815/SiPixelTemplateDBObject_38T_2015_v3.db,SiPixelTemplateDBObject38Tv10 +color = 633 +style = 1 + +[alignment:alignment_mp1823p4] +title=alignment_mp1823p4 +globaltag = GR_P_V56 +#condition TrackerAlignmentErrorExtendedRcd = zeroAPE +condition TrackerAlignmentRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/MP/MPproduction/mp1823/jobData/jobm4/alignments_MP.db, Alignments +condition TrackerSurfaceDeformationRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/MP/MPproduction/mp1823/jobData/jobm4/alignments_MP.db, Deformations +condition SiStripBackPlaneCorrectionRcd = frontier://FrontierProd/CMS_CONDITIONS,SiStripBackPlaneCorrection_deco_GR10_v4_offline,deconvolution +condition SiStripLorentzAngleRcd = frontier://FrontierProd/CMS_CONDITIONS,SiStripLorentzAngleDeco_v3_offline,deconvolution +condition SiPixelLorentzAngleRcd = frontier://FrontierProd/CMS_CONDITIONS,SiPixelLorentzAngle_2015_v2_hltvalidation +condition SiPixelTemplateDBObjectRcd = frontier://FrontierProd/CMS_CONDITIONS,SiPixelTemplateDBObject_38T_2015_v1_hltvalidation +#condition SiPixelTemplateDBObjectRcd = sqlite_file:/afs/cern.ch/user/d/dkotlins/public/CMSSW/DB/310815/SiPixelTemplateDBObject_38T_2015_v3.db,SiPixelTemplateDBObject38Tv10 color = 633 style = 1 -[alignment:alignment_0] -title=alignment_{0} -globaltag = FT_R_53_V6C::All -condition TrackerAlignmentRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/MP/MPproduction/mp1183/jobData/jobm/alignments_MP.db, Alignments -condition TrackerAlignmentErrorExtendedRcd = zeroAPE -# `zeroAPE` is a shorthand for the following commented line -# condition TrackerAlignmentErrorExtendedRcd = frontier://FrontierProd/CMS_COND_31X_FROM21X, TrackerIdealGeometryErrors210_mc -condition SiStripConfObjectRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/MP/MPproduction/mp1025/SiStripShiftAndCrosstalk_GR10_v2_offline_BPCorrected.db,SiStripShiftAndCrosstalk_GR10_v2_offline_BPCorrected -condition SiStripLorentzAngleRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/MP/MPproduction/mp1025/SiStripLorentzAngleDeco_GR10_v1_offline_BPCorrected.db,SiStripLorentzAngleDeco_GR10_v1_offline_BPCorrected, deconvolution -condition SiPixelTemplateDBObjectRcd = frontier://FrontierProd/CMS_COND_31X_PIXEL,SiPixelTemplateDBObject_38T_v4_mc -color = 419 -style = 2 - -[alignment:alignment_1] -title=alignment_{1} +[alignment:alignment_mp1826p2] +title=alignment_mp1826p2 globaltag = GR_P_V56 -#condition TrackerAlignmentRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/MP/MPproduction/mp1206/jobData/jobm/alignments_MP.db, Alignments -#condition SiPixelTemplateDBObjectRcd = frontier://FrontierProd/CMS_COND_31X_PIXEL,SiPixelTemplateDBObject_38T_v4_mc +#condition TrackerAlignmentErrorExtendedRcd = zeroAPE +condition TrackerAlignmentRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/MP/MPproduction/mp1826/jobData/jobm2/alignments_MP.db, Alignments +#condition TrackerSurfaceDeformationRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/MP/MPproduction/mp1826/jobData/jobm2/alignments_MP.db, Deformations +condition SiStripBackPlaneCorrectionRcd = frontier://FrontierProd/CMS_CONDITIONS,SiStripBackPlaneCorrection_deco_GR10_v4_offline,deconvolution +condition SiStripLorentzAngleRcd = frontier://FrontierProd/CMS_CONDITIONS,SiStripLorentzAngleDeco_v3_offline,deconvolution +condition SiPixelLorentzAngleRcd = frontier://FrontierProd/CMS_CONDITIONS,SiPixelLorentzAngle_2015_v2_hltvalidation +condition SiPixelTemplateDBObjectRcd = frontier://FrontierProd/CMS_CONDITIONS,SiPixelTemplateDBObject_38T_2015_v1_hltvalidation +#condition SiPixelTemplateDBObjectRcd = sqlite_file:/afs/cern.ch/user/d/dkotlins/public/CMSSW/DB/310815/SiPixelTemplateDBObject_38T_2015_v3.db,SiPixelTemplateDBObject38Tv10 color = 633 style = 1 -[alignment:mp1260baseline] -globaltag = FT_R_53_V6C::All -condition TrackerAlignmentRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/MP/MPproduction/mp1260/jobData/jobm/alignments_MP.db, Alignments -condition TrackerAlignmentErrorExtendedRcd = zeroAPE -condition TrackerSurfaceDeformationRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/MP/MPproduction/mp1260/jobData/jobm/alignments_MP.db, Deformations -color = 600 -style = 2 - -[alignment:mp1260m1] -globaltag = FT_R_53_V6C::All -condition TrackerAlignmentRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/MP/MPproduction/mp1260/jobData/jobm1/alignments_MP.db, Alignments -condition TrackerAlignmentErrorExtendedRcd = zeroAPE -condition TrackerSurfaceDeformationRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/MP/MPproduction/mp1260/jobData/jobm1/alignments_MP.db, Deformations -color = 4 +# No Zmumu +[alignment:alignment_mp1826p1] +title=alignment_mp1826p1 +globaltag = GR_P_V56 +#condition TrackerAlignmentErrorExtendedRcd = zeroAPE +condition TrackerAlignmentRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/MP/MPproduction/mp1826/jobData/jobm1/alignments_MP.db, Alignments +condition TrackerSurfaceDeformationRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/MP/MPproduction/mp1826/jobData/jobm1/alignments_MP.db, Deformations +condition SiStripBackPlaneCorrectionRcd = frontier://FrontierProd/CMS_CONDITIONS,SiStripBackPlaneCorrection_deco_GR10_v4_offline,deconvolution +condition SiStripLorentzAngleRcd = frontier://FrontierProd/CMS_CONDITIONS,SiStripLorentzAngleDeco_v3_offline,deconvolution +condition SiPixelLorentzAngleRcd = frontier://FrontierProd/CMS_CONDITIONS,SiPixelLorentzAngle_2015_v2_hltvalidation +condition SiPixelTemplateDBObjectRcd = frontier://FrontierProd/CMS_CONDITIONS,SiPixelTemplateDBObject_38T_2015_v1_hltvalidation +#condition SiPixelTemplateDBObjectRcd = sqlite_file:/afs/cern.ch/user/d/dkotlins/public/CMSSW/DB/310815/SiPixelTemplateDBObject_38T_2015_v3.db,SiPixelTemplateDBObject38Tv10 +color = 633 +style = 1 + +[alignment:alignment_mp1834p0] +title=alignment_mp1834p0 +globaltag = GR_P_V56 +#condition TrackerAlignmentErrorExtendedRcd = zeroAPE +condition TrackerAlignmentRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/MP/MPproduction/mp1834/jobData/jobm/alignments_MP.db, Alignments +#condition TrackerSurfaceDeformationRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/MP/MPproduction/mp1834/jobData/jobm/alignments_MP.db, Deformations +condition SiStripBackPlaneCorrectionRcd = frontier://FrontierProd/CMS_CONDITIONS,SiStripBackPlaneCorrection_deco_GR10_v4_offline,deconvolution +condition SiStripLorentzAngleRcd = frontier://FrontierProd/CMS_CONDITIONS,SiStripLorentzAngleDeco_v3_offline,deconvolution +condition SiPixelLorentzAngleRcd = frontier://FrontierProd/CMS_CONDITIONS,SiPixelLorentzAngle_2015_v2_hltvalidation +#condition SiPixelTemplateDBObjectRcd = frontier://FrontierProd/CMS_CONDITIONS,SiPixelTemplateDBObject_38T_2015_v1_hltvalidation +condition SiPixelTemplateDBObjectRcd = sqlite_file:/afs/cern.ch/user/d/dkotlins/public/CMSSW/DB/310815/SiPixelTemplateDBObject_38T_2015_v3.db,SiPixelTemplateDBObject38Tv10 +color = 633 +style = 1 + +# No Zmumu +[alignment:alignment_mp1834p1] +title=alignment_mp1834p1 +globaltag = GR_P_V56 +#condition TrackerAlignmentErrorExtendedRcd = zeroAPE +condition TrackerAlignmentRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/MP/MPproduction/mp1834/jobData/jobm1/alignments_MP.db, Alignments +#condition TrackerSurfaceDeformationRcd = sqlite_file:/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/MP/MPproduction/mp1834/jobData/jobm1/alignments_MP.db, Deformations +condition SiStripBackPlaneCorrectionRcd = frontier://FrontierProd/CMS_CONDITIONS,SiStripBackPlaneCorrection_deco_GR10_v4_offline,deconvolution +condition SiStripLorentzAngleRcd = frontier://FrontierProd/CMS_CONDITIONS,SiStripLorentzAngleDeco_v3_offline,deconvolution +condition SiPixelLorentzAngleRcd = frontier://FrontierProd/CMS_CONDITIONS,SiPixelLorentzAngle_2015_v2_hltvalidation +#condition SiPixelTemplateDBObjectRcd = frontier://FrontierProd/CMS_CONDITIONS,SiPixelTemplateDBObject_38T_2015_v1_hltvalidation +condition SiPixelTemplateDBObjectRcd = sqlite_file:/afs/cern.ch/user/d/dkotlins/public/CMSSW/DB/310815/SiPixelTemplateDBObject_38T_2015_v3.db,SiPixelTemplateDBObject38Tv10 +color = 633 style = 1 ############################################################################### # configuration of individual validations -[zmumu:zmumu_test] -etamaxneg = 2.4 -etaminneg = -2.4 -etamaxpos = 2.4 -etaminpos = -2.4 -maxevents = -1 -firstRun=251604 -lastRun=251642 -#cmssw = /afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/data/commonValidation/CMSSW_5_3_4_patch2 -dataset = /DoubleMuon/Run2015B-TkAlZMuMu-PromptReco-v1/ALCARECO - [zmumu:Run2015B_ALCARECO_251604-251642] etamaxneg = 2.4 etaminneg = -2.4 @@ -120,8 +211,18 @@ dataset = /DoubleMuon/Run2015B-TkAlZMuMu-PromptReco-v1/ALCARECO # configure which validation to run on which alignment [validation] -#compare Tracker: mp1260m1 1, mp1260baseline #zmumu Run2015B_ALCARECO_251604-251642 : alignment_defgt -zmumu Run2015B_ALCARECO_251604-251642 : alignment_hp1394 +#zmumu Run2015B_ALCARECO_251604-251642 : alignment_PCL +#zmumu Run2015B_ALCARECO_251604-251642 : alignment_hp1394 +#zmumu Run2015B_ALCARECO_251604-251642 : alignment_hp1398 +#zmumu Run2015B_ALCARECO_251604-251642 : alignment_hp1400 +#zmumu Run2015B_ALCARECO_251604-251642 : alignment_hp1401 #zmumu Run2015B_ALCARECO_251604-251642 : alignment_mp1819 #zmumu Run2015B_ALCARECO_251604-251642 : alignment_mp1820 +#zmumu Run2015B_ALCARECO_251604-251642 : alignment_mp1823p4 +#zmumu Run2015B_ALCARECO_251604-251642 : alignment_mp1826p1 +#zmumu Run2015B_ALCARECO_251604-251642 : alignment_mp1826p2 +zmumu Run2015B_ALCARECO_251604-251642 : alignment_mp1834p0 +zmumu Run2015B_ALCARECO_251604-251642 : alignment_mp1834p1 +#zmumu Run2015B_ALCARECO_251604-251642 : alignment_mp1835p0 +#zmumu Run2015B_ALCARECO_251604-251642 : alignment_mp1835p1 From 62bc6a946cea0e19ba5f163a43cb749052025a60 Mon Sep 17 00:00:00 2001 From: Heshy Roskes Date: Fri, 4 Sep 2015 12:02:45 +0200 Subject: [PATCH 6/9] - don't delete the validation job directory - random number in geometry comparison filename is no longer necessary because the run number is part of the name --- .../TkAlAllInOneTool/geometryComparison.py | 15 +++++---------- .../scripts/validateAlignments.py | 19 +------------------ 2 files changed, 6 insertions(+), 28 deletions(-) diff --git a/Alignment/OfflineValidation/python/TkAlAllInOneTool/geometryComparison.py b/Alignment/OfflineValidation/python/TkAlAllInOneTool/geometryComparison.py index 4fd9db01f7c66..ff69e90769477 100644 --- a/Alignment/OfflineValidation/python/TkAlAllInOneTool/geometryComparison.py +++ b/Alignment/OfflineValidation/python/TkAlAllInOneTool/geometryComparison.py @@ -11,7 +11,7 @@ class GeometryComparison(GenericValidation): Object representing a geometry comparison job. """ def __init__( self, valName, alignment, referenceAlignment, - config, copyImages = True, randomWorkdirPart = None): + config, copyImages = True): """ Constructor of the GeometryComparison class. @@ -24,9 +24,6 @@ def __init__( self, valName, alignment, referenceAlignment, configuration of the validations - `copyImages`: Boolean which indicates whether png- and pdf-files should be copied back from the batch farm - - `randomWorkDirPart`: If this option is ommitted a random number is - generated to create unique path names for the - individual validation instances. """ defaults = { "3DSubdetector1":"1", @@ -37,8 +34,6 @@ def __init__( self, valName, alignment, referenceAlignment, GenericValidation.__init__(self, valName, alignment, config, "compare", addDefaults=defaults, addMandatories = mandatories) - if not randomWorkdirPart == None: - self.randomWorkdirPart = randomWorkdirPart self.referenceAlignment = referenceAlignment referenceName = "IDEAL" if not self.referenceAlignment == "IDEAL": @@ -82,14 +77,14 @@ def getRepMap(self, alignment = None): def createConfiguration(self, path ): # self.__compares repMap = self.getRepMap() - cfgFileName = "TkAlCompareToNTuple.%s.%s_cfg.py"%( - self.alignmentToValidate.name, self.randomWorkdirPart) + cfgFileName = "TkAlCompareToNTuple.%s_cfg.py"%( + self.alignmentToValidate.name) cfgs = {cfgFileName: configTemplates.intoNTuplesTemplate} repMaps = {cfgFileName: repMap} if not self.referenceAlignment == "IDEAL": referenceRepMap = self.getRepMap( self.referenceAlignment ) - cfgFileName = "TkAlCompareToNTuple.%s.%s_cfg.py"%( - self.referenceAlignment.name, self.randomWorkdirPart ) + cfgFileName = "TkAlCompareToNTuple.%s_cfg.py"%( + self.referenceAlignment.name ) cfgs[cfgFileName] = configTemplates.intoNTuplesTemplate repMaps[cfgFileName] = referenceRepMap diff --git a/Alignment/OfflineValidation/scripts/validateAlignments.py b/Alignment/OfflineValidation/scripts/validateAlignments.py index 4d47da58ff235..28568a80646f5 100755 --- a/Alignment/OfflineValidation/scripts/validateAlignments.py +++ b/Alignment/OfflineValidation/scripts/validateAlignments.py @@ -109,22 +109,10 @@ def __getValidation( self, valType, name, alignments, config, options ): secondAlign = Alignment( secondAlignName, self.__config, secondRun ) secondAlignName = secondAlign.name - # check if alignment was already compared previously - try: - randomWorkdirPart = \ - globalDictionaries.alignRandDict[firstAlignName] - except KeyError: - randomWorkdirPart = None validation = GeometryComparison( name, firstAlign, secondAlign, self.__config, - self.__commandLineOptions.getImages, - randomWorkdirPart ) - globalDictionaries.alignRandDict[firstAlignName] = \ - validation.randomWorkdirPart - if not secondAlignName == "IDEAL": - globalDictionaries.alignRandDict[secondAlignName] = \ - validation.randomWorkdirPart + self.__commandLineOptions.getImages) elif valType == "offline": validation = OfflineValidation( name, Alignment( alignments.strip(), self.__config ), self.__config ) @@ -506,11 +494,6 @@ def main(argv = None): config.set("general","logdir",os.path.join(general["logdir"],options.Name) ) config.set("general","eosdir",os.path.join("AlignmentValidation", general["eosdir"], options.Name) ) - # clean up of log directory to avoid cluttering with files with different - # random numbers for geometry comparison - if os.path.isdir( outPath ): - shutil.rmtree( outPath ) - if not os.path.exists( outPath ): os.makedirs( outPath ) elif not os.path.isdir( outPath ): From 4e38868212653d065981be811ef5f52bf1ae161b Mon Sep 17 00:00:00 2001 From: Heshy Roskes Date: Tue, 8 Sep 2015 17:18:23 +0200 Subject: [PATCH 7/9] Easier kind of preexistingvalidation, just put * in front --- .../python/TkAlAllInOneTool/preexistingValidation.py | 3 ++- .../OfflineValidation/scripts/validateAlignments.py | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Alignment/OfflineValidation/python/TkAlAllInOneTool/preexistingValidation.py b/Alignment/OfflineValidation/python/TkAlAllInOneTool/preexistingValidation.py index cb270eabcd3a0..f2a7ceda5ac03 100644 --- a/Alignment/OfflineValidation/python/TkAlAllInOneTool/preexistingValidation.py +++ b/Alignment/OfflineValidation/python/TkAlAllInOneTool/preexistingValidation.py @@ -42,6 +42,7 @@ def __init__(self, valName, config, valType, config.checkInput("preexisting"+valType+":"+self.name, knownSimpleOptions = knownOpts, ignoreOptions = ignoreOpts) + self.jobmode = None def getRepMap(self): result = self.general @@ -74,7 +75,7 @@ def getCompareStrings( self, requestId = None, plain = False ): def createFiles(self, *args, **kwargs): raise AllInOneError("Shouldn't be here...") def createConfiguration(self, *args, **kwargs): - raise AllInOneError("Shouldn't be here...") + pass def createScript(self, *args, **kwargs): raise AllInOneError("Shouldn't be here...") def createCrabCfg(self, *args, **kwargs): diff --git a/Alignment/OfflineValidation/scripts/validateAlignments.py b/Alignment/OfflineValidation/scripts/validateAlignments.py index 28568a80646f5..03a6d7f97590e 100755 --- a/Alignment/OfflineValidation/scripts/validateAlignments.py +++ b/Alignment/OfflineValidation/scripts/validateAlignments.py @@ -67,6 +67,11 @@ def __init__( self, validation, config, options ): self.__valName = valString[1] self.__commandLineOptions = options self.__config = config + self.__preexisting = ("preexisting" in self.__valType) + if self.__valType[0] == "*": + self.__valType = self.__valType[1:] + self.__preexisting = True + # workaround for intermediate parallel version if self.__valType == "offlineParallel": print ("offlineParallel and offline are now the same. To run an offline parallel validation,\n" @@ -136,13 +141,14 @@ def __getValidation( self, valType, name, alignments, config, options ): Alignment( alignments.strip(), self.__config ), self.__config ) else: raise AllInOneError, "Unknown validation mode '%s'"%valType - self.preexisting = ("preexisting" in valType) return validation def __createJob( self, jobMode, outpath ): """This private method creates the needed files for the validation job. """ self.validation.createConfiguration( outpath ) + if self.__preexisting: + return self.__scripts = sum([addIndex(script, self.validation.NJobs) for script in self.validation.createScript( outpath )], []) if jobMode.split( ',' )[0] == "crab": self.validation.createCrabCfg( outpath ) @@ -150,13 +156,11 @@ def __createJob( self, jobMode, outpath ): def createJob(self): """This is the method called to create the job files.""" - if self.preexisting: - return self.__createJob( self.validation.jobmode, os.path.abspath( self.__commandLineOptions.Name) ) def runJob( self ): - if self.preexisting: + if self.__preexisting: log = "> " + self.validation.name + " is already validated." print log return log From fce6e5bc8eb54a7d10f9fd5685f5763562752342 Mon Sep 17 00:00:00 2001 From: Heshy Roskes Date: Tue, 8 Sep 2015 17:19:13 +0200 Subject: [PATCH 8/9] Surface deformations by default for preexisting offline --- .../python/TkAlAllInOneTool/preexistingValidation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Alignment/OfflineValidation/python/TkAlAllInOneTool/preexistingValidation.py b/Alignment/OfflineValidation/python/TkAlAllInOneTool/preexistingValidation.py index f2a7ceda5ac03..7f8001c763dd8 100644 --- a/Alignment/OfflineValidation/python/TkAlAllInOneTool/preexistingValidation.py +++ b/Alignment/OfflineValidation/python/TkAlAllInOneTool/preexistingValidation.py @@ -89,7 +89,7 @@ def __init__(self, valName, config, "DMRMinimum":"30", "DMROptions":"", "OfflineTreeBaseDir":"TrackHitFilter", - "SurfaceShapes":"none" + "SurfaceShapes":"coarse", } defaults.update(addDefaults) PreexistingValidation.__init__(self, valName, config, "offline", From 3dd9eb0947df0b529a722d2beaa31abbe0bbac43 Mon Sep 17 00:00:00 2001 From: usarica Date: Thu, 10 Sep 2015 14:59:42 +0200 Subject: [PATCH 9/9] Compatibility with #10477 --- .../zMuMuValidationTemplates.py | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/Alignment/OfflineValidation/python/TkAlAllInOneTool/zMuMuValidationTemplates.py b/Alignment/OfflineValidation/python/TkAlAllInOneTool/zMuMuValidationTemplates.py index 9b19c145473ae..b642fe37f82eb 100644 --- a/Alignment/OfflineValidation/python/TkAlAllInOneTool/zMuMuValidationTemplates.py +++ b/Alignment/OfflineValidation/python/TkAlAllInOneTool/zMuMuValidationTemplates.py @@ -23,11 +23,11 @@ ########### standard includes ############################## process.load("Configuration.StandardSequences..oO[magneticField]Oo._cff") process.load("Configuration.StandardSequences.Reconstruction_cff") -process.load("Configuration.Geometry.GeometryDB_cff") +process.load("Configuration.Geometry.GeometryRecoDB_cff") ########### DATABASE conditions ############################ -process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff") +process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_condDBv2_cff") process.GlobalTag.globaltag = ".oO[GlobalTag]Oo." .oO[condLoad]Oo. @@ -114,10 +114,14 @@ parSmear = cms.vdouble(), ### taken from J/Psi ######################### - ResolFitType = cms.int32(14), - parResol = cms.vdouble(0.007,0.015, -0.00077, 0.0063, 0.0018, 0.0164), - parResolFix = cms.vint32(0, 0, 0,0, 0,0), - parResolOrder = cms.vint32(0, 0, 0, 0, 0, 0), +# ResolFitType = cms.int32(14), +# parResol = cms.vdouble(0.007,0.015, -0.00077, 0.0063, 0.0018, 0.0164), +# parResolFix = cms.vint32(0, 0, 0,0, 0,0), +# parResolOrder = cms.vint32(0, 0, 0, 0, 0, 0), + ResolFitType = cms.int32(0), + parResol = cms.vdouble(0), + parResolFix = cms.vint32(0), + parResolOrder = cms.vint32(0), # -------------------- # @@ -125,10 +129,14 @@ # -------------------- # # ----------------------------------------------------------------------------------- - ScaleFitType = cms.int32(18), - parScaleOrder = cms.vint32(0, 0, 0, 0), - parScaleFix = cms.vint32(0, 0, 0, 0), - parScale = cms.vdouble(1, 1, 1, 1), +# ScaleFitType = cms.int32(18), +# parScaleOrder = cms.vint32(0, 0, 0, 0), +# parScaleFix = cms.vint32(0, 0, 0, 0), +# parScale = cms.vdouble(1, 1, 1, 1), + ScaleFitType = cms.int32(0), + parScaleOrder = cms.vint32(0), + parScaleFix = cms.vint32(0), + parScale = cms.vdouble(0),