//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // drawFigure2 // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void drawFigure2() { gInterpreter->ExecuteMacro("WZPaperStyle.C"); gSystem->mkdir("pdf", kTRUE); gSystem->mkdir("png", kTRUE); DrawZPeak("7TeV"); DrawZPeak("8TeV"); }
int main(int argc, char** argv) { //Check if all nedeed arguments to parse are there if(argc != 2) { std::cerr << ">>> compareZPeaks::usage: " << argv[0] << " configFileName" << std::endl; return -1; } //---------------------- // Parse the config file parseConfigFile(argv[1]); std::string inputFilesDA = gConfigParser -> readStringOption("Input::inputFilesDA"); std::string inputFilesMC = gConfigParser -> readStringOption("Input::inputFilesMC"); std::string dataLabel = gConfigParser -> readStringOption("Options::dataLabel"); bool useShervinNtuple = gConfigParser -> readBoolOption("Options::useShervinNtuple"); int maxEntries = gConfigParser -> readIntOption("Options::maxEntries"); std::string MCGen = gConfigParser -> readStringOption("Options::MCGen"); bool runDepFlag = gConfigParser -> readBoolOption("Options::runDepFlag"); int runMin = gConfigParser -> readIntOption("Options::runMin"); int runMax = gConfigParser -> readIntOption("Options::runMax"); bool diagonalCatOnly = gConfigParser -> readBoolOption("Options::diagonalCatOnly"); std::string eleIDSelection = gConfigParser -> readStringOption("Options::eleIDSelection"); int eleIDBit = 1; if( eleIDSelection == "loose" ) eleIDBit = 2; if( eleIDSelection == "medium" ) eleIDBit = 6; if( eleIDSelection == "tight" ) eleIDBit = 14; if( eleIDSelection == "WP90PU" ) eleIDBit = 16; if( eleIDSelection == "WP80PU" ) eleIDBit = 48; bool applyPUWeight = gConfigParser -> readBoolOption("Options::applyPUWeight"); bool applyEnergyScaleCorr = gConfigParser -> readBoolOption("Options::applyEnergyScaleCorr"); bool applyEnergySmearing = gConfigParser -> readBoolOption("Options::applyEnergySmearing"); std::string enCorrType = gConfigParser -> readStringOption("Options::enCorrType"); std::string energyScaleCorrType = gConfigParser -> readStringOption("Options::energyScaleCorrType"); std::string energySmearingType = gConfigParser -> readStringOption("Options::energySmearingType"); std::string runRangeFile = gConfigParser -> readStringOption("Options::runRangeFile"); std::string ShervinScaleFile = gConfigParser -> readStringOption("Options::ShervinScaleFile"); std::string ShervinSmearingFile = gConfigParser -> readStringOption("Options::ShervinSmearingFile"); std::string IJazZGlobalFolder = gConfigParser -> readStringOption("Options::IJazZGlobalFolder"); std::string IJazZRunDepFolder = gConfigParser -> readStringOption("Options::IJazZRunDepFolder"); bool doVoigtianFit = gConfigParser -> readBoolOption("Options::doVoigtianFit"); bool doCrystalBallFit = gConfigParser -> readBoolOption("Options::doCrystalBallFit"); bool doEffectiveSigma = gConfigParser -> readBoolOption("Options::doEffectiveSigma"); std::string outFilePath = gConfigParser -> readStringOption("Output::outFilePath"); //------------------ // Set style options setTDRStyle(); gStyle->SetPadTopMargin(0.05); gStyle->SetPadBottomMargin(0.13); gStyle->SetPadLeftMargin(0.13); gStyle->SetPadRightMargin(0.17); gStyle->SetLabelSize(0.04,"XYZ"); gStyle->SetTitleSize(0.05,"XYZ"); gStyle->SetOptStat(0); gStyle->SetOptFit(0); //---------- // Get trees std::cout << ">>> Get trees" << std::endl; std::cout << std::endl; std::string treeName; if( !useShervinNtuple ) treeName = "simpleNtupleEoverP/SimpleNtupleEoverP"; else treeName = "selected"; TChain* ntu_MC = new TChain(treeName.c_str()); FillChain(ntu_MC,inputFilesMC); std::cout << ">>> MC: " << std::setw(8) << ntu_MC->GetEntries() << " entries" << std::endl; TChain* ntu_DA = new TChain(treeName.c_str()); FillChain(ntu_DA,inputFilesDA); std::cout << ">>> DATA: " << std::setw(8) << ntu_DA->GetEntries() << " entries" << std::endl; if( ntu_MC->GetEntries() == 0 || ntu_DA->GetEntries() == 0 ) { std::cout << ">>> compareZPeaks::Error: at least one file is empty" << std::endl; return -1; } //------------------------ // Define branch addresses std::cout << std::endl; std::cout << ">>> Define branch addresses" << std::endl; float scEta[2]; float scE[2]; float scERaw[2]; float scEReg[2]; float scETrue[2]; float R9[2]; int eleID[2]; int runId; int isZ; bool HLTfire; int timeStampHigh; float mZ, mZTrue; int isEB1,isEB2; float scEta1,scEta2; float scERaw1,scERaw2; float scE1,scE2; float scEReg1,scEReg2; float scETrue1,scETrue2; float E3x31,E3x32; float R91,R92; int seedIeta1,seedIeta2; int seedIphi1,seedIphi2; int seedIx1,seedIx2; int seedIy1,seedIy2; int seedIz1,seedIz2; int eleID1, eleID2; int nPU; if( !useShervinNtuple ) { HLTfire = true; ntu_DA -> SetBranchStatus("*",0); ntu_DA -> SetBranchStatus("runId", 1); ntu_DA -> SetBranchAddress("runId",&runId); ntu_DA -> SetBranchStatus("isZ", 1); ntu_DA -> SetBranchAddress("isZ",&isZ); ntu_DA -> SetBranchStatus("timeStampHigh", 1); ntu_DA -> SetBranchAddress("timeStampHigh",&timeStampHigh); ntu_DA -> SetBranchStatus("ele1ele2_scM", 1); ntu_DA -> SetBranchAddress("ele1ele2_scM",&mZ); ntu_DA -> SetBranchStatus("ele1_isEB", 1); ntu_DA -> SetBranchAddress("ele1_isEB",&isEB1); ntu_DA -> SetBranchStatus("ele2_isEB", 1); ntu_DA -> SetBranchAddress("ele2_isEB",&isEB2); ntu_DA -> SetBranchStatus("ele1_scEta", 1); ntu_DA -> SetBranchAddress("ele1_scEta",&scEta1); ntu_DA -> SetBranchStatus("ele2_scEta", 1); ntu_DA -> SetBranchAddress("ele2_scEta",&scEta2); ntu_DA -> SetBranchStatus("ele1_scERaw", 1); ntu_DA -> SetBranchAddress("ele1_scERaw",&scERaw1); ntu_DA -> SetBranchStatus("ele2_scERaw", 1); ntu_DA -> SetBranchAddress("ele2_scERaw",&scERaw2); ntu_DA -> SetBranchStatus("ele1_scE", 1); ntu_DA -> SetBranchAddress("ele1_scE",&scE1); ntu_DA -> SetBranchStatus("ele2_scE", 1); ntu_DA -> SetBranchAddress("ele2_scE",&scE2); if( enCorrType == "stdSC" ) { ntu_DA -> SetBranchStatus("ele1_scE",1); ntu_DA -> SetBranchAddress("ele1_scE",&scEReg1); ntu_DA -> SetBranchStatus("ele2_scE",1); ntu_DA -> SetBranchAddress("ele2_scE",&scEReg2); } if( enCorrType == "eleTunedReg" ) { ntu_DA -> SetBranchStatus("ele1_scE_regression",1); ntu_DA -> SetBranchAddress("ele1_scE_regression",&scEReg1); ntu_DA -> SetBranchStatus("ele2_scE_regression",1); ntu_DA -> SetBranchAddress("ele2_scE_regression",&scEReg2); } if( enCorrType == "phoTunedReg" ) { ntu_DA -> SetBranchStatus("ele1_scE_regression_PhotonTuned",1); ntu_DA -> SetBranchAddress("ele1_scE_regression_PhotonTuned",&scEReg1); ntu_DA -> SetBranchStatus("ele2_scE_regression_PhotonTuned",1); ntu_DA -> SetBranchAddress("ele2_scE_regression_PhotonTuned",&scEReg2); } ntu_DA -> SetBranchStatus("ele1_e3x3", 1); ntu_DA -> SetBranchAddress("ele1_e3x3",&E3x31); ntu_DA -> SetBranchStatus("ele2_e3x3", 1); ntu_DA -> SetBranchAddress("ele2_e3x3",&E3x32); ntu_DA -> SetBranchStatus("ele1_seedIeta", 1); ntu_DA -> SetBranchAddress("ele1_seedIeta",&seedIeta1); ntu_DA -> SetBranchStatus("ele2_seedIeta", 1); ntu_DA -> SetBranchAddress("ele2_seedIeta",&seedIeta2); ntu_DA -> SetBranchStatus("ele1_seedIphi", 1); ntu_DA -> SetBranchAddress("ele1_seedIphi",&seedIphi1); ntu_DA -> SetBranchStatus("ele2_seedIphi", 1); ntu_DA -> SetBranchAddress("ele2_seedIphi",&seedIphi2); ntu_DA -> SetBranchStatus("ele1_seedIx", 1); ntu_DA -> SetBranchAddress("ele1_seedIx",&seedIx1); ntu_DA -> SetBranchStatus("ele2_seedIx", 1); ntu_DA -> SetBranchAddress("ele2_seedIx",&seedIx2); ntu_DA -> SetBranchStatus("ele1_seedIy", 1); ntu_DA -> SetBranchAddress("ele1_seedIy",&seedIy1); ntu_DA -> SetBranchStatus("ele2_seedIy", 1); ntu_DA -> SetBranchAddress("ele2_seedIy",&seedIy2); ntu_DA -> SetBranchStatus("ele1_seedZside", 1); ntu_DA -> SetBranchAddress("ele1_seedZside",&seedIz1); ntu_DA -> SetBranchStatus("ele2_seedZside", 1); ntu_DA -> SetBranchAddress("ele2_seedZside",&seedIz2); ntu_MC -> SetBranchStatus("*",0); ntu_MC -> SetBranchStatus("isZ", 1); ntu_MC -> SetBranchAddress("isZ",&isZ); ntu_MC -> SetBranchStatus("timeStampHigh", 1); ntu_MC -> SetBranchAddress("timeStampHigh",&timeStampHigh); ntu_MC -> SetBranchStatus("ele1ele2_scM", 1); ntu_MC -> SetBranchAddress("ele1ele2_scM",&mZ); ntu_MC -> SetBranchStatus("ele1_isEB", 1); ntu_MC -> SetBranchAddress("ele1_isEB",&isEB1); ntu_MC -> SetBranchStatus("ele2_isEB", 1); ntu_MC -> SetBranchAddress("ele2_isEB",&isEB2); ntu_MC -> SetBranchStatus("ele1_scEta", 1); ntu_MC -> SetBranchAddress("ele1_scEta",&scEta1); ntu_MC -> SetBranchStatus("ele2_scEta", 1); ntu_MC -> SetBranchAddress("ele2_scEta",&scEta2); ntu_MC -> SetBranchStatus("ele1_scERaw", 1); ntu_MC -> SetBranchAddress("ele1_scERaw",&scERaw1); ntu_MC -> SetBranchStatus("ele2_scERaw", 1); ntu_MC -> SetBranchAddress("ele2_scERaw",&scERaw2); ntu_MC -> SetBranchStatus("ele1_scE", 1); ntu_MC -> SetBranchAddress("ele1_scE",&scE1); ntu_MC -> SetBranchStatus("ele2_scE", 1); ntu_MC -> SetBranchAddress("ele2_scE",&scE2); if( enCorrType == "stdSC" ) { ntu_MC -> SetBranchStatus("ele1_scE",1); ntu_MC -> SetBranchAddress("ele1_scE",&scEReg1); ntu_MC -> SetBranchStatus("ele2_scE",1); ntu_MC -> SetBranchAddress("ele2_scE",&scEReg2); } if( enCorrType == "eleTunedReg" ) { ntu_MC -> SetBranchStatus("ele1_scE_regression",1); ntu_MC -> SetBranchAddress("ele1_scE_regression",&scEReg1); ntu_MC -> SetBranchStatus("ele2_scE_regression",1); ntu_MC -> SetBranchAddress("ele2_scE_regression",&scEReg2); } if( enCorrType == "phoTunedReg" ) { ntu_MC -> SetBranchStatus("ele1_scE_regression_PhotonTuned",1); ntu_MC -> SetBranchAddress("ele1_scE_regression_PhotonTuned",&scEReg1); ntu_MC -> SetBranchStatus("ele2_scE_regression_PhotonTuned",1); ntu_MC -> SetBranchAddress("ele2_scE_regression_PhotonTuned",&scEReg2); } ntu_MC -> SetBranchStatus("ele1_e3x3", 1); ntu_MC -> SetBranchAddress("ele1_e3x3",&E3x31); ntu_MC -> SetBranchStatus("ele2_e3x3", 1); ntu_MC -> SetBranchAddress("ele2_e3x3",&E3x32); ntu_MC -> SetBranchStatus("ele1_seedIeta", 1); ntu_MC -> SetBranchAddress("ele1_seedIeta",&seedIeta1); ntu_MC -> SetBranchStatus("ele2_seedIeta", 1); ntu_MC -> SetBranchAddress("ele2_seedIeta",&seedIeta2); ntu_MC -> SetBranchStatus("ele1_seedIphi", 1); ntu_MC -> SetBranchAddress("ele1_seedIphi",&seedIphi1); ntu_MC -> SetBranchStatus("ele2_seedIphi", 1); ntu_MC -> SetBranchAddress("ele2_seedIphi",&seedIphi2); ntu_MC -> SetBranchStatus("ele1_seedIx", 1); ntu_MC -> SetBranchAddress("ele1_seedIx",&seedIx1); ntu_MC -> SetBranchStatus("ele2_seedIx", 1); ntu_MC -> SetBranchAddress("ele2_seedIx",&seedIx2); ntu_MC -> SetBranchStatus("ele1_seedIy", 1); ntu_MC -> SetBranchAddress("ele1_seedIy",&seedIy1); ntu_MC -> SetBranchStatus("ele2_seedIy", 1); ntu_MC -> SetBranchAddress("ele2_seedIy",&seedIy2); ntu_MC -> SetBranchStatus("ele1_seedZside", 1); ntu_MC -> SetBranchAddress("ele1_seedZside",&seedIz1); ntu_MC -> SetBranchStatus("ele2_seedZside", 1); ntu_MC -> SetBranchAddress("ele2_seedZside",&seedIz2); ntu_MC -> SetBranchStatus("PUit_TrueNumInteractions",1); ntu_MC -> SetBranchAddress("PUit_TrueNumInteractions",&nPU); } else { isZ = 1; ntu_MC -> SetBranchStatus("*",0); ntu_MC -> SetBranchStatus("HLTfire", 1); ntu_MC -> SetBranchAddress("HLTfire",&HLTfire); ntu_MC -> SetBranchStatus("runNumber", 1); ntu_MC -> SetBranchAddress("runNumber",&runId); ntu_MC -> SetBranchStatus("nPU", 1); ntu_MC -> SetBranchAddress("nPU",&nPU); ntu_MC -> SetBranchStatus("R9Ele", 1); ntu_MC -> SetBranchAddress("R9Ele",R9); ntu_MC -> SetBranchStatus("etaSCEle", 1); ntu_MC -> SetBranchAddress("etaSCEle",scEta); ntu_MC -> SetBranchStatus("rawEnergySCEle",1); ntu_MC -> SetBranchAddress("rawEnergySCEle",scERaw); ntu_MC -> SetBranchStatus("energyMCEle", 1); ntu_MC -> SetBranchAddress("energyMCEle",scETrue); ntu_MC -> SetBranchStatus("energySCEle", 1); ntu_MC -> SetBranchAddress("energySCEle",scE); if( enCorrType == "stdSC" ) { ntu_MC -> SetBranchStatus("energySCEle",1); ntu_MC -> SetBranchAddress("energySCEle",scEReg); } if( enCorrType == "eleTunedRegV3" ) { ntu_MC -> SetBranchStatus("energySCEle_regrCorr_ele",1); ntu_MC -> SetBranchAddress("energySCEle_regrCorr_ele",scEReg); } if( enCorrType == "phoTunedRegV3" ) { ntu_MC -> SetBranchStatus("energySCEle_regrCorr_pho",1); ntu_MC -> SetBranchAddress("energySCEle_regrCorr_pho",scEReg); } if( enCorrType == "eleTunedRegV4" ) { ntu_MC -> SetBranchStatus("energySCEle_regrCorrSemiParV4_ele",1); ntu_MC -> SetBranchAddress("energySCEle_regrCorrSemiParV4_ele",scEReg); } if( enCorrType == "phoTunedRegV4" ) { ntu_MC -> SetBranchStatus("energySCEle_regrCorrSemiParV4_pho",1); ntu_MC -> SetBranchAddress("energySCEle_regrCorrSemiParV4_pho",scEReg); } if( enCorrType == "eleTunedRegV5" ) { ntu_MC -> SetBranchStatus("energySCEle_regrCorrSemiParV5_ele",1); ntu_MC -> SetBranchAddress("energySCEle_regrCorrSemiParV5_ele",scEReg); } if( enCorrType == "phoTunedRegV5" ) { ntu_MC -> SetBranchStatus("energySCEle_regrCorrSemiParV5_pho",1); ntu_MC -> SetBranchAddress("energySCEle_regrCorrSemiParV5_pho",scEReg); } ntu_MC -> SetBranchStatus("invMass_SC",1); ntu_MC -> SetBranchAddress("invMass_SC",&mZ); ntu_MC -> SetBranchStatus("eleID", 1); ntu_MC -> SetBranchAddress("eleID",eleID); ntu_DA -> SetBranchStatus("*",0); ntu_DA -> SetBranchStatus("HLTfire", 1); ntu_DA -> SetBranchAddress("HLTfire",&HLTfire); ntu_DA -> SetBranchStatus("runNumber", 1); ntu_DA -> SetBranchAddress("runNumber",&runId); ntu_DA -> SetBranchStatus("R9Ele", 1); ntu_DA -> SetBranchAddress("R9Ele",R9); ntu_DA -> SetBranchStatus("etaSCEle", 1); ntu_DA -> SetBranchAddress("etaSCEle",scEta); ntu_DA -> SetBranchStatus("rawEnergySCEle",1); ntu_DA -> SetBranchAddress("rawEnergySCEle",scERaw); ntu_DA -> SetBranchStatus("energySCEle", 1); ntu_DA -> SetBranchAddress("energySCEle",scE); if( enCorrType == "stdSC" ) { ntu_DA -> SetBranchStatus("energySCEle",1); ntu_DA -> SetBranchAddress("energySCEle",scEReg); } if( enCorrType == "eleTunedRegV3" ) { ntu_DA -> SetBranchStatus("energySCEle_regrCorr_ele",1); ntu_DA -> SetBranchAddress("energySCEle_regrCorr_ele",scEReg); } if( enCorrType == "phoTunedRegV3" ) { ntu_DA -> SetBranchStatus("energySCEle_regrCorr_pho",1); ntu_DA -> SetBranchAddress("energySCEle_regrCorr_pho",scEReg); } if( enCorrType == "eleTunedRegV4" ) { ntu_DA -> SetBranchStatus("energySCEle_regrCorrSemiParV4_ele",1); ntu_DA -> SetBranchAddress("energySCEle_regrCorrSemiParV4_ele",scEReg); } if( enCorrType == "phoTunedRegV4" ) { ntu_DA -> SetBranchStatus("energySCEle_regrCorrSemiParV4_pho",1); ntu_DA -> SetBranchAddress("energySCEle_regrCorrSemiParV4_pho",scEReg); } if( enCorrType == "eleTunedRegV5" ) { ntu_DA -> SetBranchStatus("energySCEle_regrCorrSemiParV5_ele",1); ntu_DA -> SetBranchAddress("energySCEle_regrCorrSemiParV5_ele",scEReg); } if( enCorrType == "phoTunedRegV5" ) { ntu_DA -> SetBranchStatus("energySCEle_regrCorrSemiParV5_pho",1); ntu_DA -> SetBranchAddress("energySCEle_regrCorrSemiParV5_pho",scEReg); } ntu_DA -> SetBranchStatus("invMass_SC",1); ntu_DA -> SetBranchAddress("invMass_SC", &mZ); ntu_DA -> SetBranchStatus("eleID", 1); ntu_DA -> SetBranchAddress("eleID",eleID); } //------------------ // Define categories std::cout << std::endl; std::cout << ">>> Define categories" << std::endl; std::vector<std::string> categories; std::vector<std::string> categoryLabels; categories.push_back("EB-EB"); categoryLabels.push_back("EB-EB"); categories.push_back("EB-EB_hR9"); categoryLabels.push_back("EB-EB R9>0.94"); categories.push_back("EB-EB_lR9"); categoryLabels.push_back("EB-EB R9<0.94"); categories.push_back("EB-EB_eta>1"); categoryLabels.push_back("EB-EB |#eta|>1"); categories.push_back("EB-EB_eta<1"); categoryLabels.push_back("EB-EB |#eta|<1"); categories.push_back("EE-EE"); categoryLabels.push_back("EE-EE"); categories.push_back("EE-EE_hR9"); categoryLabels.push_back("EE-EE R9>0.94"); categories.push_back("EE-EE_lR9"); categoryLabels.push_back("EE-EE R9<0.94"); categories.push_back("EE-EE_eta>2"); categoryLabels.push_back("EE-EE |#eta|>2"); categories.push_back("EE-EE_eta<2"); categoryLabels.push_back("EE-EE |#eta|<2"); std::vector<float> etaBins; etaBins.push_back(0.0); etaBins.push_back(1.0); etaBins.push_back(1.5); etaBins.push_back(2.0); etaBins.push_back(2.5); int nEtaBins = int(etaBins.size()) - 1; std::vector<float> R9Bins; R9Bins.push_back(0.00); R9Bins.push_back(0.94); R9Bins.push_back(1.00); int nR9Bins = int(R9Bins.size()) - 1; std::vector<std::string> singleCats; std::vector<std::string> singleCatLabels; for(int etaBin = 0; etaBin < nEtaBins; ++etaBin) for(int R9Bin = 0; R9Bin < nR9Bins; ++R9Bin) { singleCats.push_back(Form("eta%1.1f-%1.1f_R9%1.2f-%1.2f",etaBins.at(etaBin),etaBins.at(etaBin+1),R9Bins.at(R9Bin),R9Bins.at(R9Bin+1))); singleCatLabels.push_back(Form("%1.1f<|#eta|<%1.1f %1.2f<R9<%1.2f",etaBins.at(etaBin),etaBins.at(etaBin+1),R9Bins.at(R9Bin),R9Bins.at(R9Bin+1))); } for(unsigned int i = 0; i < singleCats.size(); ++i) for(unsigned int j = i; j < singleCats.size(); ++j) { if( diagonalCatOnly && (j != i ) ) continue; categories.push_back(singleCats.at(i) + "__" + singleCats.at(j)); categoryLabels.push_back(Form("%s %s",singleCatLabels.at(i).c_str(),singleCatLabels.at(j).c_str())); std::cout << ">>>>>> " << singleCats.at(i) + "__" + singleCats.at(j) << std::endl; } //------------------ // Define histograms std::cout << std::endl; std::cout << ">>> Define histograms" << std::endl; for(unsigned int i = 0; i < categories.size(); ++i) { std::string category = categories.at(i); std::string histoName = "h_mZ_MC_"+category; h_mZ_MC[category] = new TH1F(histoName.c_str(),"",100,meeMin,meeMax); h_mZ_MC[category] -> Sumw2(); histoName = "h_mZFine_MC_"+category; h_mZFine_MC[category] = new TH1F(histoName.c_str(),"",int((meeFineMax-meeFineMin)/precision),meeFineMin,meeFineMax); h_mZFine_MC[category] -> Sumw2(); histoName = "h_mZRes_MC_"+category; h_mZRes_MC[category] = new TH1F(histoName.c_str(),"",10000,0.,2.); h_mZRes_MC[category] -> Sumw2(); histoName = "h_mZ_DA_"+category; h_mZ_DA[category] = new TH1F(histoName.c_str(),"",100,meeMin,meeMax); h_mZ_DA[category] -> Sumw2(); histoName = "h_mZFine_DA_"+category; h_mZFine_DA[category] = new TH1F(histoName.c_str(),"",int((meeFineMax-meeFineMin)/precision),meeFineMin,meeFineMax); h_mZFine_DA[category] -> Sumw2(); } //----------------------------- // Setup data scale corrections std::cout << std::endl; std::cout << ">>> Setup data scale corrections" << std::endl; ScaleCorrector* myScaleCorrector = new ScaleCorrector(runRangeFile); if( applyEnergyScaleCorr ) { if( energyScaleCorrType == "shervin" ) myScaleCorrector -> SetShervinRunDepScaleMap(ShervinScaleFile); if( energyScaleCorrType == "fabrice" ) myScaleCorrector -> SetIJazZGlobalScaleHisto(IJazZGlobalFolder); if( energyScaleCorrType == "fabrice" ) myScaleCorrector -> SetIJazZRunDepScaleHistoMap(IJazZRunDepFolder); } //----------------------- // Setup MC extrasmearing std::cout << std::endl; std::cout << ">>> Setup MC extrasmearing" << std::endl; Smearer* mySmearer = new Smearer(); if( applyEnergySmearing ) { if( energyScaleCorrType == "shervin" ) mySmearer -> SetShervinExtraSmearingMap(ShervinSmearingFile); if( energyScaleCorrType == "fabrice" ) mySmearer -> SetIJazZExtraSmearingHisto(IJazZGlobalFolder); } //-------------------------- // pileup reweighting for MC std::cout << std::endl; std::cout << ">>> Setup MC pileup reweighting" << std::endl; std::map<std::string, TH1F*>* PUWeights = ReadPUWeights(MCGen,runDepFlag,runMin,runMax); //------------------ // Loop over entries std::cout << std::endl; std::cout << ">>> Read data from MC sample" << std::endl; int nEntries_MC = ntu_MC -> GetEntriesFast(); for(int ientry = 0; ientry < nEntries_MC; ++ientry) { if( maxEntries != -1 && ientry == maxEntries ) break; if( ientry%100000 == 0 ) std::cout << ">>>>>> reading MC entry " << ientry << " / " << nEntries_MC << "\r"<< std::flush; ntu_MC -> GetEntry(ientry); // variables R91 = E3x31/scERaw1; R92 = E3x32/scERaw2; if( useShervinNtuple ) { R91 = R9[0]; R92 = R9[1]; scEta1 = scEta[0]; scEta2 = scEta[1]; scEReg1 = scEReg[0]; scEReg2 = scEReg[1]; scE1 = scE[0]; scE2 = scE[1]; eleID1 = eleID[0]; eleID2 = eleID[1]; scETrue1 = scETrue[0]; scETrue2 = scETrue[1]; } else { eleID1 = 7; eleID2 = 7; } // selections if( isZ != 1 ) continue; if( !HLTfire ) continue; if( fabs(scEta1) >= 2.5000 || fabs(scEta2) >= 2.5000 ) continue; if( fabs(scEta1) > 1.4442 && fabs(scEta1) < 1.5660 ) continue; if( fabs(scEta2) > 1.4442 && fabs(scEta2) < 1.5660 ) continue; if( R91 < 0.0 || R91 >= 1.0 ) continue; if( R92 < 0.0 || R92 >= 1.0 ) continue; if( ((eleID1 & eleIDBit) != eleIDBit) || ((eleID2 & eleIDBit) != eleIDBit) ) continue; if( applyEnergySmearing ) { float energySmearing1 = gRandom->Gaus(1.,mySmearer->GetExtraSmearing(scEta1,R91,dataLabel,energySmearingType)); float energySmearing2 = gRandom->Gaus(1.,mySmearer->GetExtraSmearing(scEta2,R92,dataLabel,energySmearingType)); scEReg1 *= energySmearing1; scEReg2 *= energySmearing2; } float ww = 1.; if( applyPUWeight ) { std::string periodLabel = getPeriodLabel(runId,runDepFlag,runMin,runMax); int ibin = (*PUWeights)[periodLabel] -> FindBin( nPU ); if( ibin <= 1 ) ibin = 1; if( ibin >= (*PUWeights)[periodLabel]->GetNbinsX() ) ibin = (*PUWeights)[periodLabel]->GetNbinsX(); ww *= (*PUWeights)[periodLabel]->GetBinContent(ibin); } // use regression energy mZTrue = mZ * sqrt( scETrue1/scE1 * scETrue2/scE2 ); mZ *= sqrt( scEReg1/scE1 * scEReg2/scE2 ); // fill EB histograms if( (fabs(scEta1) < 1.5) && (fabs(scEta2) < 1.5) ) { h_mZ_MC["EB-EB"] -> Fill( mZ,ww ); h_mZFine_MC["EB-EB"] -> Fill( mZ,ww ); h_mZRes_MC["EB-EB"] -> Fill( mZ/mZTrue,ww ); if( (R91 > 0.94) && (R92 > 0.94) ) { h_mZ_MC["EB-EB_hR9"] -> Fill( mZ,ww ); h_mZFine_MC["EB-EB_hR9"] -> Fill( mZ,ww ); h_mZRes_MC["EB-EB_hR9"] -> Fill( mZ/mZTrue,ww ); } if( (R91 < 0.94) && (R92 < 0.94) ) { h_mZ_MC["EB-EB_lR9"] -> Fill( mZ,ww ); h_mZFine_MC["EB-EB_lR9"] -> Fill( mZ,ww ); h_mZRes_MC["EB-EB_lR9"] -> Fill( mZ/mZTrue,ww ); } if( (fabs(scEta1) > 1.) && (fabs(scEta2) > 1.) ) { h_mZ_MC["EB-EB_eta>1"] -> Fill( mZ,ww ); h_mZFine_MC["EB-EB_eta>1"] -> Fill( mZ,ww ); h_mZRes_MC["EB-EB_eta>1"] -> Fill( mZ/mZTrue,ww ); } if( (fabs(scEta1) < 1.) && (fabs(scEta2) < 1.) ) { h_mZ_MC["EB-EB_eta<1"] -> Fill( mZ,ww ); h_mZFine_MC["EB-EB_eta<1"] -> Fill( mZ,ww ); h_mZRes_MC["EB-EB_eta<1"] -> Fill( mZ/mZTrue,ww ); } } // fill EE histograms if( (fabs(scEta1) > 1.5) && (fabs(scEta2) > 1.5) ) { h_mZ_MC["EE-EE"] -> Fill( mZ,ww ); h_mZFine_MC["EE-EE"] -> Fill( mZ,ww ); h_mZRes_MC["EE-EE"] -> Fill( mZ/mZTrue,ww ); if( (R91 > 0.94) && (R92 > 0.94) ) { h_mZ_MC["EE-EE_hR9"] -> Fill( mZ,ww ); h_mZFine_MC["EE-EE_hR9"] -> Fill( mZ,ww ); h_mZRes_MC["EE-EE_hR9"] -> Fill( mZ/mZTrue,ww ); } if( (R91 < 0.94) && (R92 < 0.94) ) { h_mZ_MC["EE-EE_lR9"] -> Fill( mZ,ww ); h_mZFine_MC["EE-EE_lR9"] -> Fill( mZ,ww ); h_mZRes_MC["EE-EE_lR9"] -> Fill( mZ/mZTrue,ww ); } if( (fabs(scEta1) > 2.) && (fabs(scEta2) > 2.) ) { h_mZ_MC["EE-EE_eta>2"] -> Fill( mZ,ww ); h_mZFine_MC["EE-EE_eta>2"] -> Fill( mZ,ww ); h_mZRes_MC["EE-EE_eta>2"] -> Fill( mZ/mZTrue,ww ); } if( (fabs(scEta1) < 2.) && (fabs(scEta2) < 2.) ) { h_mZ_MC["EE-EE_eta<2"] -> Fill( mZ,ww ); h_mZFine_MC["EE-EE_eta<2"] -> Fill( mZ,ww ); h_mZRes_MC["EE-EE_eta<2"] -> Fill( mZ/mZTrue,ww ); } } // fill all independent categories std::string catLabel = GetEtaR9CatLabel(fabs(scEta1),R91,fabs(scEta2),R92,etaBins,R9Bins,categories); if( catLabel != "undefined__undefined" ) { h_mZ_MC[catLabel] -> Fill( mZ,ww ); h_mZFine_MC[catLabel] -> Fill( mZ,ww ); h_mZRes_MC[catLabel] -> Fill( mZ/mZTrue,ww ); } } std::cout << std::endl; std::cout << ">>> Read data from DATA sample" << std::endl; int nEntries_DA = ntu_DA -> GetEntriesFast(); for(int ientry = 0; ientry < nEntries_DA; ++ientry) { if( maxEntries != -1 && ientry == maxEntries ) break; if( ientry%100000 == 0 ) std::cout << ">>>>>> reading DATA entry " << ientry << " / " << nEntries_DA << "\r" << std::flush; ntu_DA -> GetEntry(ientry); // variables R91 = E3x31/scERaw1; R92 = E3x32/scERaw2; if( useShervinNtuple ) { R91 = R9[0]; R92 = R9[1]; scEta1 = scEta[0]; scEta2 = scEta[1]; scEReg1 = scEReg[0]; scEReg2 = scEReg[1]; scE1 = scE[0]; scE2 = scE[1]; eleID1 = eleID[0]; eleID2 = eleID[1]; } else { eleID1 = 7; eleID2 = 7; } // selections if( isZ != 1 ) continue; if( !HLTfire ) continue; if( fabs(scEta1) >= 2.5000 || fabs(scEta2) >= 2.5000 ) continue; if( fabs(scEta1) > 1.4442 && fabs(scEta1) < 1.5660 ) continue; if( fabs(scEta2) > 1.4442 && fabs(scEta2) < 1.5660 ) continue; if( R91 < 0.0 || R91 >= 1.0 ) continue; if( R92 < 0.0 || R92 >= 1.0 ) continue; if( ((eleID1 & eleIDBit) != eleIDBit) || ((eleID2 & eleIDBit) != eleIDBit) ) continue; if( applyEnergyScaleCorr ) { scEReg1 *= myScaleCorrector->GetScaleCorrection(scEta1,R91,runId,dataLabel,energyScaleCorrType); scEReg2 *= myScaleCorrector->GetScaleCorrection(scEta2,R92,runId,dataLabel,energyScaleCorrType); } // use regression energy mZ *= sqrt( scEReg1/scE1 * scEReg2/scE2 ); // fill EB histograms if( (fabs(scEta1) < 1.5) && (fabs(scEta2) < 1.5) ) { h_mZ_DA["EB-EB"] -> Fill( mZ ); h_mZFine_DA["EB-EB"] -> Fill( mZ ); if( (R91 > 0.94) && (R92 > 0.94) ) { h_mZ_DA["EB-EB_hR9"] -> Fill( mZ ); h_mZFine_DA["EB-EB_hR9"] -> Fill( mZ ); } if( (R91 < 0.94) && (R92 < 0.94) ) { h_mZ_DA["EB-EB_lR9"] -> Fill( mZ ); h_mZFine_DA["EB-EB_lR9"] -> Fill( mZ ); } if( (fabs(scEta1) > 1.) && (fabs(scEta2) > 1.) ) { h_mZ_DA["EB-EB_eta>1"] -> Fill( mZ ); h_mZFine_DA["EB-EB_eta>1"] -> Fill( mZ ); } if( (fabs(scEta1) < 1.) && (fabs(scEta2) < 1.) ) { h_mZ_DA["EB-EB_eta<1"] -> Fill( mZ ); h_mZFine_DA["EB-EB_eta<1"] -> Fill( mZ ); } } // fill EE histograms if( (fabs(scEta1) > 1.5) && (fabs(scEta2) > 1.5) ) { h_mZ_DA["EE-EE"] -> Fill( mZ ); h_mZFine_DA["EE-EE"] -> Fill( mZ ); if( (R91 > 0.94) && (R92 > 0.94) ) { h_mZ_DA["EE-EE_hR9"] -> Fill( mZ ); h_mZFine_DA["EE-EE_hR9"] -> Fill( mZ ); } if( (R91 < 0.94) && (R92 < 0.94) ) { h_mZ_DA["EE-EE_lR9"] -> Fill( mZ ); h_mZFine_DA["EE-EE_lR9"] -> Fill( mZ ); } if( (fabs(scEta1) > 2.) && (fabs(scEta2) > 2.) ) { h_mZ_DA["EE-EE_eta>2"] -> Fill( mZ ); h_mZFine_DA["EE-EE_eta>2"] -> Fill( mZ ); } if( (fabs(scEta1) < 2.) && (fabs(scEta2) < 2.) ) { h_mZ_DA["EE-EE_eta<2"] -> Fill( mZ ); h_mZFine_DA["EE-EE_eta<2"] -> Fill( mZ ); } } // fill all independent categories std::string catLabel = GetEtaR9CatLabel(fabs(scEta1),R91,fabs(scEta2),R92,etaBins,R9Bins,categories); if( catLabel != "undefined__undefined" ) { h_mZ_DA[catLabel] -> Fill( mZ ); h_mZFine_DA[catLabel] -> Fill( mZ ); } } std::cout << std::endl; //--------- // Drawings std::cout << ">>> Drawings" << std::endl; std::string folderName = outFilePath + "/" + dataLabel + "/"; gSystem -> mkdir(folderName.c_str()); if( energySmearingType == "fabrice" ) folderName += IJazZGlobalFolder + "/"; gSystem -> mkdir(folderName.c_str()); std::string outFileName = folderName + "/compareZPeaks"; outFileName += "__" + enCorrType; outFileName += "__MC_" + MCGen; if( applyPUWeight ) outFileName += "__MC_PUweight"; if( applyEnergySmearing ) outFileName += "__MC_energySmearing_" + energySmearingType; if( applyEnergyScaleCorr ) outFileName += "__DA_energyScaleCorr_" + energyScaleCorrType; outFile = new TFile((outFileName+".root").c_str(),"RECREATE"); TCanvas* dummy = new TCanvas("dummy","",0,0,800,600); dummy -> Print((outFileName+"."+extension+"[").c_str(),extension.c_str()); for(unsigned int cat = 0; cat < categories.size(); ++cat) { std::string category = categories.at(cat); DrawZPeak(categories.at(cat),categoryLabels.at(cat),1,doVoigtianFit,doCrystalBallFit,doEffectiveSigma,"EBEE",outFileName); } outFile -> Close(); dummy -> Print((outFileName+"."+extension+"]").c_str(),extension.c_str());}