void CT_DataRSocketServ::DoCmdVersion(const TDesC& aSection) { INFO_PRINTF1(_L("Calling RSocketServ::Version()")); TVersion version = iSocketServ->Version(); TBuf<KMaxVersionName> versionName(version.Name()); INFO_PRINTF2(_L("Version name : %S"), &versionName); INFO_PRINTF2(_L("Version build : %d"), (TInt)version.iBuild); INFO_PRINTF2(_L("Version major : %d"), (TInt)version.iMajor); INFO_PRINTF2(_L("Version minor : %d"), (TInt)version.iMinor); TPtrC expectedVersionName; if( GetStringFromConfig(aSection, KExpectedVersionName(), expectedVersionName) ) { if( version.Name() != expectedVersionName ) { ERR_PRINTF3(_L("Expected Version Name (%S) != Actual Version Name (%S)"), &expectedVersionName, &versionName); SetBlockResult(EFail); } } TInt intTemp; if( GetIntFromConfig(aSection, KExpectedVersionBuild(), intTemp) ) { if( version.iBuild != intTemp ) { ERR_PRINTF3(_L("Expected Version Build (%d) != Actual Version Build (%d)"), &intTemp, version.iBuild); SetBlockResult(EFail); } } if( GetIntFromConfig(aSection, KExpectedVersionMajor(), intTemp) ) { if( version.iMajor != intTemp ) { ERR_PRINTF3(_L("Expected Version Major (%d) != Actual Version Major (%d)"), &intTemp, version.iMajor); SetBlockResult(EFail); } } if( GetIntFromConfig(aSection, KExpectedVersionMinor(), intTemp) ) { if( version.iMinor != intTemp ) { ERR_PRINTF3(_L("Expected Version Minor (%d) != Actual Version Minor (%d)"), &intTemp, version.iMinor); SetBlockResult(EFail); } } if (version.Name() == _L("") && version.iBuild == 0 && version.iMajor == 0 && version.iMinor == 0) { ERR_PRINTF1(_L("Some version fields are not set!")); SetBlockResult(EFail); } }
void studyDYeeCS(TVaried_t var= _varNone, int nSample=10, int doSave=0) { TVersion_t inpVer=_verEl3; //inpVer=_verEl3mb41; //inpVer=_verEl3mb42; inpVer=_verElMay2017; inpVer=_verElMay2017false; TString inpVerTag=versionName(inpVer); CrossSection_t eeCS("elCS",inpVerTag,_csPreFsrFullSp,inpVer); if (!eeCS.load("cs_DYee_13TeV_" + inpVerTag + ".root", inpVerTag)) { std::cout << "loading failed\n"; return; } if ((inpVer==_verEl3) || (inpVer==_verElMay2017) || (inpVer==_verElMay2017false)) { eeCS.nItersDetRes(21); eeCS.nItersFSR(21); eeCS.calcCrossSection(); } if (var==_varNone) { TCanvas *c= eeCS.plotCrossSection("cs"); if (!c) return; } else if (var==_varRhoSyst) { createSystFile(inpVer,eeCS,var,doSave); } else { std::cout << "perform study\n"; work(inpVer,eeCS,var,nSample,doSave); } std::cout << "macro ran with inpVerTag=" << inpVerTag << "\n"; }
void work(TVersion_t inpVer, CrossSection_t &eeCS, TVaried_t var, int nSample, int doSave) { std::vector<TH1D*> rndCSVec; int res=1; int removeNegativeSignal=1; if ((var!=_varRhoFile) && (var!=_varRhoSystFile) &&(var!=_varRhoSystFileSymm)) res=eeCS.sampleRndVec(var,nSample,removeNegativeSignal,rndCSVec); else if (var==_varRhoFile) { TString inpVerTag=versionName(inpVer); TString loadFName=Form("dir-Rho%s/dyee_rhoRndVec_%s_%d.root", inpVerTag.Data(),inpVerTag.Data(), nSample); RndVecInfo_t info(loadFName,"h1rho_var"); res=eeCS.sampleRndVec(var,nSample,info,removeNegativeSignal, rndCSVec); } else if (var==_varRhoSystFile) { TString inpVerTag=versionName(inpVer); TString loadFName=Form("dir-RhoSyst%s/dyee_rhoRndSystVec_%s_%d.root", inpVerTag.Data(),inpVerTag.Data(), nSample); RndVecInfo_t info(loadFName,"rhoRndSyst/h1rho_rnd"); res=eeCS.sampleRndVec(var,nSample,info,removeNegativeSignal, rndCSVec); } else if (var==_varRhoSystFileSymm) { TString inpVerTag=versionName(inpVer); TString loadFName=Form("dir-RhoSystSymm-%s/dyee_rhoRndSystVec_%s_%d.root", inpVerTag.Data(),inpVerTag.Data(), nSample); RndVecInfo_t info(loadFName,"rhoRndSyst/h1rho_rnd"); res=eeCS.sampleRndVec(var,nSample,info,removeNegativeSignal, rndCSVec); } else { std::cout << "code error: this branch should not be reached\n"; res=0; } if (!res) return; TH1D* h1Avg=NULL; TH2D* h2Cov=NULL; if (!eeCS.deriveCov(rndCSVec,&h1Avg,&h2Cov)) return; TString massLabel= niceMassAxisLabel(leptonIdx(inpVer),"",0); h2Cov->GetXaxis()->SetTitle(massLabel); h2Cov->GetYaxis()->SetTitle(massLabel); h2Cov->SetTitle("h2cov " + variedVarName(var)); PlotCovCorrOpt_t ccOpt; ccOpt.yTitleOffset=1.8; TCanvas *c= eeCS.plotCrossSection("cs"); if (!c) return; h1Avg->SetLineColor(kGreen+1); h1Avg->SetMarkerColor(kGreen+1); plotHistoSame(h1Avg,"cs","LPE","rnd avg"); printRatio(eeCS.h1PreFsrCS(), h1Avg); TH2D* h2Corr=NULL; TCanvas *cx= plotCovCorr(h2Cov,"ccov",ccOpt,&h2Corr); if (!cx) std::cout << "cx is null\n"; TH1D *h1uncFromCov= uncFromCov(h2Cov); TH1D *h1relUncFromCov= uncFromCov(h2Cov,eeCS.h1PreFsrCS()); if (!doSave) { std::cout << "Comparing uncertainty from covariance to the uncertainty " << "in the provided cross-section\n"; std::cout << "Expectation is that the covariance uncertainties will not " << "exceed those from the cross-section\n"; TH1D *h1CSUnc= errorAsCentral(eeCS.h1PreFsrCS(),0); TH1D *h1CSRelUnc= errorAsCentral(eeCS.h1PreFsrCS(),1); histoStyle(h1CSUnc,kBlue,24); histoStyle(h1CSRelUnc,kBlue,24); plotHisto(h1uncFromCov,"cUncCmp",1,1,"hist","uncFromCov"); plotHistoSame(h1CSUnc,"cUncCmp","P","csUnc"); plotHisto(h1relUncFromCov,"cRelUncCmp",1,1,"hist","rel.unc.from.cov"); plotHistoSame(h1CSRelUnc,"cRelUncCmp","P","cs.rel.unc"); } if (doSave) { TString fname="cov_ee_" + versionName(inpVer) + "_" + variedVarName(var) + Form("_%d.root",nSample); if ((inpVer==_verEl3mb41) || (inpVer==_verEl3mb42)) { fname.ReplaceAll("ee_",Form("ee%d_",DYtools::nMassBins)); } if (doSave==2) fname.ReplaceAll(".root","_slim.root"); if (var==_varFSRRes_Poisson) fname.ReplaceAll(".root","-Poisson.root"); TFile fout(fname,"RECREATE"); if (!fout.IsOpen()) { std::cout << "file <" << fname << "> could not be created\n"; return; } std::vector<TString> dirs; std::vector<std::vector<TH1D*>*> hVs; if (doSave!=2) { dirs.push_back("rnd_CStot"); hVs.push_back(&rndCSVec); } for (unsigned int iDir=0; iDir<dirs.size(); iDir++) { std::vector<TH1D*> *hV= hVs[iDir]; if (hV->size()) { fout.mkdir(dirs[iDir]); fout.cd(dirs[iDir]); for (unsigned int ih=0; ih<hV->size(); ih++) { hV->at(ih)->Write(); } fout.cd(""); } } if (eeCS.h1PreFsrCS()) eeCS.h1PreFsrCS()->Write("xsec"); if (eeCS.h1Theory()) eeCS.h1Theory()->Write("xsec_RC"); if (h1Avg) h1Avg->Write("h1xsecAvg"); if (h2Cov) h2Cov->Write("h2Cov"); if (h2Corr) h2Corr->Write("h2Corr"); if (h1uncFromCov) h1uncFromCov->Write("h1uncFromCov"); if (h1relUncFromCov) h1relUncFromCov->Write("h1relUncFromCov"); if (c) c->Write(); if (cx) cx->Write(); std::vector<TCanvas*> canvV; TString canvList; if (doSave==2) canvList=""; canvList+=" cVaried_" + variedVarName(var) + "_" + versionName(inpVer); std::cout << "canvList=" << canvList << "\n"; if (canvList.Length() && findCanvases(canvList,canvV)) { for (unsigned int ic=0; ic<canvV.size(); ic++) { canvV[ic]->Write(); } } TObjString timeTag(DayAndTimeTag(0)); timeTag.Write("timeTag"); fout.Close(); std::cout << "file <" << fout.GetName() << "> created\n"; } }
void createSystFile(TVersion_t inpVer, CrossSection_t &eeCS, TVaried_t var, int doSave) { std::cout << "createSystFile for inpVer=" << versionName(inpVer) << "\n"; if (var!=_varRhoSyst) { std::cout << "createSystFile is not ready for var=" << variedVarName(var) << "\n"; return; } TCanvas *c= eeCS.plotCrossSection("cs"); c->Update(); TH1D *h1cs_file= cloneHisto(eeCS.h1PreFsrCS(),"h1cs_file","h1cs_file"); std::vector<TH1D*> h1RhoV; TString fname="dyee-rho-syst2.root"; TFile fin(fname); if (!fin.IsOpen()) { std::cout << "failed to open the file <" << fin.GetName() << ">\n"; return; } for (TTnPSystType_t syst= _tnpSyst_none; syst!=_tnpSyst_last; next(syst)) { TString hname="h1rho_"; if (syst==_tnpSyst_none) hname.Append("stat"); else hname.Append(tnpSystName(syst,1)); TString newHName=hname; if (syst==_tnpSyst_none) newHName.ReplaceAll("stat","orig"); TH1D *h1= loadHisto(fin,hname,newHName,1,h1dummy); h1RhoV.push_back(h1); } fin.Close(); TCanvas *cRho=NULL; if (1) { //plotHisto(eeCS.h1Rho(),"cRho",1,0,"LPE","cs version"); h1RhoV[0]->GetYaxis()->SetTitleOffset(1.6); logAxis(h1RhoV[0],1,"M_{ee} [GeV]","","\\langle\\rho\\rangle\\text{ with alt.effs}"); cRho=plotHisto(h1RhoV[0],"cRho",1,0,"LP","orig"); setLeftRightMargins(cRho,0.14,0.05); for (unsigned int i=1; i<h1RhoV.size(); i++) { TString legStr=h1RhoV[i]->GetName(); legStr.ReplaceAll("h1rho_",""); plotHistoSame(h1RhoV[i],"cRho","LP",legStr); } moveLegend(cRho,0.45,0); } std::vector<TH1D*> h1rhoRelDiffV; int absValues=1; int relativeDiff=1; deriveRelSyst(NULL,h1RhoV,h1rhoRelDiffV,relativeDiff,absValues); if (0) { std::cout << " : " << h1RhoV.size() << ", " << h1rhoRelDiffV.size() << "\n"; for (unsigned int i=0; i<h1rhoRelDiffV.size(); i++) { printRatio(h1RhoV[0], h1RhoV[i+1]); printHisto(h1rhoRelDiffV[i]); } return; } TCanvas *cRhoSyst=NULL; if (1) { TString title="uncertainty"; if (relativeDiff) title.Prepend("relative "); //h1rhoRelDiffV[0]->SetTitle(title); h1rhoRelDiffV[0]->GetYaxis()->SetRangeUser(0,0.12); h1rhoRelDiffV[0]->GetYaxis()->SetTitleOffset(1.6); TString ytitle="\\delta\\langle\\rho\\rangle"; if (relativeDiff) ytitle= "(" + ytitle + ")_{rel}"; //h1rhoRelDiffV[0]->GetYaxis()->SetTitle(ytitle); logAxis(h1rhoRelDiffV[0],3,"M_{ee} [GeV]",ytitle,title); cRhoSyst=plotHisto(h1rhoRelDiffV[0],"cRhoRelDiff",1,0,"LP", tnpSystName(TTnPSystType_t(1),1)); setLeftRightMargins(cRhoSyst,0.14,0.05); for (TTnPSystType_t syst=TTnPSystType_t(2); syst!=_tnpSyst_last; next(syst)) { plotHistoSame(h1rhoRelDiffV[syst-1],"cRhoRelDiff","LP",tnpSystName(syst,1)); } moveLegend(cRhoSyst,0.45,0.47); } std::vector<TH1D*> h1csV; eeCS.var(_varRho); for (unsigned int i=0; i<h1RhoV.size(); i++) { eeCS.h1Rho(h1RhoV[i]); TString hname="h1cs_" + tnpSystName(TTnPSystType_t(i)); TH1D *h1cs= cloneHisto(eeCS.calcCrossSection(0),hname,hname); copyStyle(h1cs,h1RhoV[i]); h1csV.push_back(h1cs); } std::cout << "h1csV.size=" << h1csV.size() << "\n"; if (1) { TCanvas *cRhoCS= plotHisto(h1cs_file,"cRhoCS",1,1,"LP","cs_file"); for (unsigned int i=0; i<h1csV.size(); i++) { plotHistoSame(h1csV[i],"cRhoCS","LP",h1csV[i]->GetName()); } cRhoCS->Update(); } std::vector<TH1D*> h1csRelDiffV; deriveRelSyst(NULL,h1csV,h1csRelDiffV,relativeDiff,absValues); TCanvas *cCSRhoUnc=NULL; if (1) { logAxis(h1csRelDiffV[0],3,"M_{ee} [GeV]", "(\\delta\\sigma)_{\\langle\\rho\\rangle\\,syst;rel}", "relative uncertainty of the cross section"); h1csRelDiffV[0]->GetYaxis()->SetRangeUser(0,0.15); h1csRelDiffV[0]->GetYaxis()->SetTitleOffset(1.6); cCSRhoUnc= plotHisto(h1csRelDiffV[0],"cCSRhoUnc",1,0,"LP", tnpSystName(TTnPSystType_t(1),1)); setLeftRightMargins(cCSRhoUnc,0.14,0.05); for (TTnPSystType_t syst=TTnPSystType_t(2); syst!=_tnpSyst_last; next(syst)) { plotHistoSame(h1csRelDiffV[syst-1],"cCSRhoUnc","LP",tnpSystName(syst,1)); } moveLegend(cCSRhoUnc,0.45,0.47); } if (1) { for (unsigned int i=0; i<h1csRelDiffV.size(); i++) { std::cout << "\n\ni=" << i << "\n"; printRatio(h1csRelDiffV[i],h1rhoRelDiffV[i]); } } if (doSave) { TString fname="dyeeCS-rhoSyst2.root"; TFile fout(fname,"RECREATE"); if (!fout.IsOpen()) { std::cout << "failed to create a file <" << fout.GetName() << ">\n"; return; } for (unsigned int ih=0; ih<h1RhoV.size(); ih++) { h1RhoV[ih]->Write(); } for (unsigned int ih=0; ih<h1rhoRelDiffV.size(); ih++) { h1rhoRelDiffV[ih]->Write(); } for (unsigned int ih=0; ih<h1csRelDiffV.size(); ih++) { h1csRelDiffV[ih]->Write(); } if (cRho) cRho->Write(); if (cRhoSyst) cRhoSyst->Write(); if (cCSRhoUnc) cCSRhoUnc->Write(); TObjString timeTag(DayAndTimeTag(0)); timeTag.Write("timeTag"); fout.Close(); std::cout << "file <" << fout.GetName() << "> created\n"; } return; }
void processDYmm(Int_t maxEntries=-1) { std::cout << "DY range=" << DYtools::minMass << " .. " << DYtools::maxMass << "\n"; TVersion_t inpVersion=_verMu1; inpVersion=_verMu76X; inpVersion=_verMuApproved; if (inpVersion!=_verMu1) { if (DYtools::nMassBins!=DYtools::nMassBins43) { std::cout << "a potential DYbinning.h problem\n"; return; } } TString srcPath="/media/ssd/v20160214_1st_CovarianceMatrixInputs/"; srcPath="/mnt/sdb/andriusj/v20160214_1st_CovarianceMatrixInputs/"; TString dataFName=srcPath + "Input3/ROOTFile_ntuple_CovarianceMatrixInput.root"; if (inpVersion==_verMu76X) { srcPath="/mnt/sdb/andriusj/v20160527_1st_CovarianceMatrixInputs_76X/"; dataFName=srcPath + "Input3/ROOTFile_Input_CovarianceMatrix.root"; } else if (inpVersion==_verMuApproved) { srcPath="/mnt/sdb/andriusj/v20160915_CovInput_ApprovedResults/"; dataFName=srcPath + "ROOTFile_Input_CovarianceMatrix.root"; } DYmm13TeV_t data(dataFName); data.DeactivateBranches(); data.ActivateBranches("Momentum_postFSR_Lead Momentum_postFSR_Sub Momentum_preFSR_Lead Momentum_preFSR_Sub Weight_Norm Weight_Gen Weight_PU"); data.ActivateBranches("Flag_EventSelection"); TH1D *h1postFsrInAccSel_M= new TH1D("h1_postFsrInAccSel_M", "postFSR selected events in acceptance;M_{gen,postFSR} [GeV];count",DYtools::nMassBins,DYtools::massBinEdges); TH1D *h1postFsrInAccSel_MW= new TH1D("h1_postFsrInAccSel_MW", "postFSR selected events in acceptance (weighted);M_{gen,postFSR} [GeV];weighted count",DYtools::nMassBins,DYtools::massBinEdges); TH1D *h1postFsrInAccSel_MWPU= new TH1D("h1_postFsrInAccSel_MWPU", "postFSR selected events in acceptance (weighted wPU);M_{gen,postFSR} [GeV];weighted (wPU) count",DYtools::nMassBins,DYtools::massBinEdges); TH1D *h1postFsrInAcc_M= new TH1D("h1_postFsrInAcc_M", "postFSR in acceptace;M_{gen,postFSR} [GeV];count",DYtools::nMassBins, DYtools::massBinEdges); TH1D *h1postFsrInAcc_MW= new TH1D("h1_postFsrInAcc_Mweighted", "postFSR in acceptance;M_{gen,postFSR} [GeV];weighted count", DYtools::nMassBins, DYtools::massBinEdges); TH1D *h1postFsrInAcc_MWPU= new TH1D("h1_postFsrInAcc_MweightedPU", "postFSR in acceptance (weighted wPU);M_{gen,postFSR} [GeV];weighted (wPU) count", DYtools::nMassBins, DYtools::massBinEdges); TH1D *h1postFsr_M= new TH1D("h1_postFsr_M", "postFSR;M_{gen,postFSR} [GeV];count",DYtools::nMassBins, DYtools::massBinEdges); TH1D *h1postFsr_MW= new TH1D("h1_postFsr_Mweighted", "postFSR;M_{gen,postFSR} [GeV];weighted count", DYtools::nMassBins, DYtools::massBinEdges); TH1D *h1preFsr_M= new TH1D("h1_preFsr_M", "preFSR;M_{gen,preFSR} [GeV];count",DYtools::nMassBins, DYtools::massBinEdges); TH1D *h1preFsr_MW= new TH1D("h1_preFsr_Mweighted", "preFSR;M_{gen,preFSR} [GeV];weighted count", DYtools::nMassBins, DYtools::massBinEdges); prepareHisto(h1postFsrInAccSel_M); prepareHisto(h1postFsrInAccSel_MW); prepareHisto(h1postFsrInAccSel_MWPU); prepareHisto(h1postFsrInAcc_M); prepareHisto(h1postFsrInAcc_MW); prepareHisto(h1postFsrInAcc_MWPU); prepareHisto(h1postFsr_M); prepareHisto(h1postFsr_MW); prepareHisto(h1preFsr_M); prepareHisto(h1preFsr_MW); TH2D* h2FSRmig= new TH2D("h2FSRmig","FSR migration", DYtools::nMassBins, DYtools::massBinEdges, DYtools::nMassBins, DYtools::massBinEdges); h2FSRmig->Sumw2(); RooUnfoldResponse fsrResp(h1postFsr_MW,h1preFsr_MW,h2FSRmig,"rooUnf_fsrResp","fsrResp;M_{#mu#mu} [GeV];FSR unfolded yield"); fsrResp.UseOverflow(); TH2D* h2effAccFSRmig= new TH2D("h2effAccFSRmig","eff x Acc x FSR migration", DYtools::nMassBins, DYtools::massBinEdges, DYtools::nMassBins, DYtools::massBinEdges); h2effAccFSRmig->Sumw2(); RooUnfoldResponse effAccFsrResp(h1postFsrInAccSel_MW,h1preFsr_MW,h2effAccFSRmig,"rooUnf_effAccFsrResp","effAccFsrResp;M_{#mu#mu} [GeV];eff Acc FSR unfolded yield"); effAccFsrResp.UseOverflow(); UInt_t nEvents= data.GetEntries(); std::cout << "process data\n"; for (UInt_t iEntry=0; iEntry<nEvents; iEntry++) { if (data.GetEntry(iEntry)<0) break; if (iEntry%100000==0) std::cout << "iEntry=" << iEntry << Form("(%4.2lf%%)\n",iEntry*100/double(nEvents)); if ((maxEntries>0) && (iEntry>UInt_t(maxEntries))) { std::cout << "debug run\n"; break; } double w= data.Weight_Norm * data.Weight_Gen; if (iEntry<100) std::cout << "w=" << w << ": weight_norm=" << data.Weight_Norm << ", gen=" << data.Weight_Gen << "\n"; double mPostFsr= (*data.Momentum_postFSR_Lead + *data.Momentum_postFSR_Sub).M(); double mPreFsr= (*data.Momentum_preFSR_Lead + *data.Momentum_preFSR_Sub).M(); if (DYtools::InAcceptance_mm(data.Momentum_postFSR_Lead,data.Momentum_postFSR_Sub)) { if (data.Flag_EventSelection) { h1postFsrInAccSel_M->Fill( mPostFsr, 1. ); h1postFsrInAccSel_MW->Fill( mPostFsr, w ); h1postFsrInAccSel_MWPU->Fill( mPostFsr, w * data.Weight_PU ); } h1postFsrInAcc_M->Fill( mPostFsr, 1. ); h1postFsrInAcc_MW->Fill( mPostFsr, w ); h1postFsrInAcc_MWPU->Fill( mPostFsr, w * data.Weight_PU ); } h1postFsr_M->Fill( mPostFsr, 1. ); h1postFsr_MW->Fill( mPostFsr, w ); h1preFsr_M->Fill( mPreFsr, 1. ); h1preFsr_MW->Fill( mPreFsr, w ); h2FSRmig->Fill( mPostFsr, mPreFsr, w ); if (0) { if ( ! DYtools::InsideMassRange(mPreFsr) ) std::cout << "preFSR mass " << mPreFsr << ", postFSR mass " << mPostFsr << "\n"; } if ( ! DYtools::InsideMassRange(mPreFsr) && DYtools::InsideMassRange(mPostFsr) ) { std::cout << "fake detected\n"; fsrResp.Fake(mPostFsr,w); } else if ( DYtools::InsideMassRange(mPreFsr) && ! DYtools::InsideMassRange(mPostFsr) ) { fsrResp.Miss(mPreFsr,w); } else { fsrResp.Fill(mPostFsr,mPreFsr,w); } int sel=(DYtools::InAcceptance_mm(data.Momentum_postFSR_Lead,data.Momentum_postFSR_Sub) && data.Flag_EventSelection && DYtools::InsideMassRange(mPostFsr)) ? 1:0; if (sel) h2effAccFSRmig->Fill(mPostFsr,mPreFsr,w); if ( ! DYtools::InsideMassRange(mPreFsr) && sel ) { effAccFsrResp.Fake(mPostFsr,w); } else if ( DYtools::InsideMassRange(mPreFsr) && ! sel ) { effAccFsrResp.Miss(mPreFsr,w); } else { effAccFsrResp.Fill(mPostFsr,mPreFsr,w); } } RooUnfoldBayes bayesFSR( &fsrResp, h1postFsr_MW, 4 ); TH1D *h1preFsrUnf= (TH1D*) bayesFSR.Hreco()->Clone("h1preFsrUnf"); h1preFsrUnf->SetTitle("unfolded postFSR->preFSR"); h1preFsrUnf->SetDirectory(0); histoStyle(h1preFsrUnf,kRed,24); h1preFsrUnf->GetXaxis()->SetMoreLogLabels(); h1preFsrUnf->GetXaxis()->SetNoExponent(); TCanvas *cFSRTest=plotHisto(h1preFsrUnf,"cFSRTest",1,1,"LPE1"); plotHistoSame(h1preFsr_MW,"cFSRTest","LPE"); RooUnfoldBayes bayesEffAccFsr( &effAccFsrResp, h1postFsrInAccSel_MW, 4 ); TH1D *h1EffAccFsrUnf= (TH1D*) bayesEffAccFsr.Hreco()->Clone("h1EffAccFsrUnf"); h1EffAccFsrUnf->SetTitle("unfolded postFsrInAccSel -> preFSR"); h1EffAccFsrUnf->SetDirectory(0); histoStyle(h1EffAccFsrUnf,kRed,24); h1EffAccFsrUnf->GetXaxis()->SetMoreLogLabels(); h1EffAccFsrUnf->GetXaxis()->SetNoExponent(); TCanvas *cScaleToPreFsrTest= plotHisto(h1EffAccFsrUnf,"cScaleToPreFsrTest",1,1,"LPE1"); histoStyle(h1preFsr_MW,kBlue,5); plotHistoSame(h1preFsr_MW,"cScaleToPreFsrTest","LPE"); TH1D* h1Eff=(TH1D*)h1postFsrInAccSel_MW->Clone("h1Eff"); h1Eff->SetDirectory(0); if (!h1Eff->GetSumw2()) h1Eff->Sumw2(); h1Eff->SetTitle("Efficiency;M_{#mu#mu,GEN postFSR} [GeV];postFSR_inAcc_Sel/postFSR_inAcc"); h1Eff->Divide(h1postFsrInAccSel_MW,h1postFsrInAcc_MW,1,1,"B"); TH1D* h1EffPU=(TH1D*)h1postFsrInAccSel_MWPU->Clone("h1EffPU"); h1EffPU->SetDirectory(0); if (!h1EffPU->GetSumw2()) h1EffPU->Sumw2(); h1EffPU->SetTitle("Efficiency (wPU);M_{#mu#mu,GEN postFSR} [GeV];postFSR_inAcc_Sel(wPU)/postFSR_inAcc(wPU)"); h1EffPU->Divide(h1postFsrInAccSel_MWPU,h1postFsrInAcc_MWPU,1,1,"B"); histoStyle(h1EffPU,kBlue,24); TCanvas *cEffCmp=plotHisto(h1Eff,"cEff_noPU_vs_wPU",1,0,"LPE1"); plotHistoSame(h1EffPU,"cEff_noPU_vs_wPU","LPE"); TH1D* h1Acc=(TH1D*)h1postFsrInAcc_MW->Clone("h1Acc"); h1Acc->SetDirectory(0); if (!h1Acc->GetSumw2()) h1Acc->Sumw2(); h1Acc->SetTitle("Acceptance;M_{#mu#mu,GEN postFSR} [GeV];postFSR_inAcc/postFSR"); h1Acc->Divide(h1postFsrInAcc_MW,h1postFsr_MW,1,1,"B"); TH1D* h1EffPUAcc=(TH1D*)h1postFsrInAccSel_MWPU->Clone("h1EffPUAcc"); h1EffPUAcc->SetDirectory(0); if (!h1EffPUAcc->GetSumw2()) h1EffPUAcc->Sumw2(); h1EffPUAcc->SetTitle("Efficiency(wPU) x Acc;M_{#mu#mu,GEN postFSR} [GeV];postFSR_inAccSel(wPU)/h1postFsr_MW(noPU)"); h1EffPUAcc->Divide(h1postFsrInAccSel_MWPU,h1postFsr_MW,1,1,"B"); TH1D *h1FSRCorr_binByBin=(TH1D*)h1preFsr_MW->Clone("h1FSRCorr_binByBin"); h1FSRCorr_binByBin->SetDirectory(0); if (!h1FSRCorr_binByBin->GetSumw2()) h1FSRCorr_binByBin->Sumw2(); h1FSRCorr_binByBin->SetTitle("FSR correction bin-by-bin;M_{#mu#mu} [GeV];preFSR/postFSR"); h1FSRCorr_binByBin->Divide(h1preFsr_MW,h1postFsr_MW,1.,1.,"B"); TString fname="dymm_test_" + versionName(inpVersion) + TString(".root"); if (maxEntries>0) fname.ReplaceAll(".root","_debug.root"); TFile fout(fname,"RECREATE"); h1Eff->Write(); h1EffPU->Write(); h1Acc->Write(); h1EffPUAcc->Write(); h1FSRCorr_binByBin->Write(); fsrResp.Write(); effAccFsrResp.Write(); h1postFsrInAccSel_M->Write(); h1postFsrInAccSel_MW->Write(); h1postFsrInAcc_M->Write(); h1postFsrInAcc_MW->Write(); h1postFsr_M->Write(); h1postFsr_MW->Write(); h1preFsr_M->Write(); h1preFsr_MW->Write(); h1preFsrUnf->Write(); h2FSRmig->Write(); h1EffAccFsrUnf->Write(); h2effAccFSRmig->Write(); cEffCmp->Write(); cFSRTest->Write(); cScaleToPreFsrTest->Write(); TObjString timeTag(DayAndTimeTag(0)); timeTag.Write("timeTag"); fout.Close(); std::cout << "file <" << fout.GetName() << "> created\n"; }
void closureTestCSv2(int dataUnfold=0, int compareToTheory=0) { TVersion_t inpVer=_verEl2skim3; TString inpVerTag=versionName(inpVer); TString csOutFName="csClosure_DYee_13TeV_" + inpVerTag + ".root"; const TString tag_UseData="data"; const TString tag_UseTheory="theory"; const TString tag_UseUnity="unity"; const TString tag_UseZero="zero"; const TString tag_Load="combine:"; std::vector<TString> dataInput, theoryInput; addToVector(dataInput, "cs_DYee_13TeV_El2.root h1Yield h1Bkg"); addToVector(theoryInput, "theory13TeVmm.root h1cs_theory"); std::map<TVaried_t,TString> inpHistoNames; TCSType_t csType= _csPreFsrFullSp; TString inpFName="dyee_test_dressed_El2skim3.root"; inpHistoNames[_varYield] = "h1recoSel_MWPU"; //inpHistoNames[_varBkg] = tag_UseZero; inpHistoNames[_varDetRes]= "rooUnf_detResRespPU"; inpHistoNames[_varRho] = tag_UseUnity; inpHistoNames[_varEffAcc] = "h1EffPUAcc"; inpHistoNames[_varFSRRes] = "rooUnf_fsrResp"; inpHistoNames[_varLast] = "h1_preFsr_Mweighted"; if (1) inpHistoNames[_varEffAcc] = "h1EffPUEleMatchAcc"; if (dataUnfold) { inpHistoNames[_varYield] = "data"; //inpHistoNames[_varRho] = "h1rho"; //inpHistoNames[_varRho] = "h1rho_inPostFsrAcc"; } TH1D *h1Zero= new TH1D("h1Zero","h1Zero",DYtools::nMassBins,DYtools::massBinEdges); h1Zero->SetDirectory(0); TH1D *h1Unity= cloneHisto(h1Zero,"h1Unity","h1Unity"); for (int ibin=1; ibin<=h1Unity->GetNbinsX(); ibin++) { h1Unity->SetBinContent(ibin,1.); } CrossSection_t cs("cs",inpVerTag,csType,inpVer); for (std::map<TVaried_t,TString>::const_iterator it=inpHistoNames.begin(); it!=inpHistoNames.end(); it++) { TH1D *h1tmp=NULL, *h1tmp2=NULL; std::cout << "load " << variedVarName(it->first) << " named " << it->second << "\n"; switch(it->first) { case _varYield: if (it->second == tag_UseData) { h1tmp= loadHisto(dataInput[0],dataInput[1], "h1Yield",1,h1dummy); h1tmp2=loadHisto(dataInput[0],dataInput[2], "h1Bkg",1,h1dummy); double lumi=2316.97; if (h1tmp && h1tmp2) { h1tmp->Scale(1/lumi); h1tmp2->Scale(1/lumi); } } else { h1tmp= loadHisto(inpFName,it->second, "h1Yield",1,h1dummy); h1tmp2=h1Zero; } if (!h1tmp || !h1tmp2) return; cs.h1Yield(h1tmp); cs.h1Bkg(h1tmp2); break; case _varDetRes: { RooUnfoldResponse *r= loadRooUnfoldResponse(inpFName,it->second,"detRes"); if (!r) return; cs.detRes(*r); } break; case _varRho: if (it->second == tag_UseUnity) { h1tmp= h1Unity; } else { h1tmp= loadHisto(inpFName,it->second, "h1Rho",1,h1dummy); } if (!h1tmp) return; cs.h1Rho(h1tmp); break; case _varEff: h1tmp= loadHisto(inpFName,it->second, "h1Eff",1,h1dummy); if (!h1tmp) return; cs.h1Eff(h1tmp); break; case _varEffAcc: h1tmp= loadHisto(inpFName,it->second, "h1EffAcc",1,h1dummy); if (!h1tmp) return; cs.h1EffAcc(h1tmp); break; case _varAcc: h1tmp= loadHisto(inpFName,it->second, "h1Acc",1,h1dummy); if (!h1tmp) return; cs.h1Acc(h1tmp); break; case _varFSRRes: { RooUnfoldResponse *r= loadRooUnfoldResponse(inpFName,it->second,"fsrRes"); if (!r) return; cs.fsrRes(*r); } break; case _varLast: h1tmp2= loadHisto(inpFName,it->second, "h1theory",1,h1dummy); if (!h1tmp2) return; h1tmp= perMassBinWidth(h1tmp2); cs.h1Theory(h1tmp); break; default: std::cout << "unprepared case " << variedVarName(it->first) << "\n"; return; } } TH1D* h1cs= cs.calcCrossSection(); printRatio(h1cs,cs.h1Theory()); cs.plotCrossSection(); if (1) { // unfold in 1 step TH1D* h1reco=cloneHisto(cs.h1Yield(),"h1reco","h1reco"); RooUnfoldResponse *rFull= loadRooUnfoldResponse(inpFName,"rooUnf_detResEffAccFsrResp","fullResponse"); if (!h1reco || !rFull) return; RooUnfoldBayes bayesFull( rFull, h1reco, 4); TH1D *h1UnfFull=perMassBinWidth((TH1D*)bayesFull.Hreco()); histoStyle(h1UnfFull,kOrange,5,1); plotHistoSame(h1UnfFull,"cs","LPE1","fullUnf"); printRatio(h1UnfFull,cs.h1Theory()); std::cout << "\n\ndifferent unfoldings\n"; printRatio(h1UnfFull,cs.h1PreFsrCS()); } //cs.save(csOutFName); }