void plotRatios(std::vector<TH1D*> &h1RatioV, const std::vector<TString> &labelV) { for (unsigned int ih=0; ih<h1RatioV.size(); ih++) { removeError(h1RatioV[ih]); h1RatioV[ih]->SetStats(0); } TH1D *h1=h1RatioV[0]; h1->SetTitle("Ratio of the modified selection to the new selection"); h1->SetTitleSize(24); h1->GetXaxis()->SetNoExponent(); h1->GetXaxis()->SetMoreLogLabels(); h1->GetXaxis()->SetTitleSize(0.05); h1->GetYaxis()->SetRangeUser(0.95,1.15); h1->GetYaxis()->SetTitle("ratio"); h1->GetYaxis()->SetTitleSize(0.05); h1->GetYaxis()->SetTitleOffset(1.38); TString cName="cRatio"; TCanvas *c=plotHisto(h1RatioV[0],cName,1,0,"LP",labelV[0]); gPad->SetGridx(); gPad->SetGridy(); for (unsigned int ih=1; ih<h1RatioV.size(); ih++) { plotHistoSame(h1RatioV[ih],cName,"LP",labelV[ih]); } }
static void testMalfunctionCentralRemoveNonExistent() { print("******************************************* testMalfunctionCentralRemoveNonExistent\r\n"); initMalfunctionCentral(); // this should not crash removeError(OBD_Engine_Coolant_Temperature_Circuit_Malfunction); }
TEST(misc, testMalfunctionCentral) { testMalfunctionCentralRemoveNonExistent(); testMalfunctionCentralSameElementAgain(); testMalfunctionCentralRemoveFirstElement(); print("******************************************* testMalfunctionCentral\r\n"); initMalfunctionCentral(); error_codes_set_s localCopy; // on start-up error storage should be empty getErrorCodes(&localCopy); ASSERT_EQ(0, localCopy.count); obd_code_e code = OBD_Engine_Coolant_Temperature_Circuit_Malfunction; // let's add one error and validate addError(code); getErrorCodes(&localCopy); ASSERT_EQ( 1, localCopy.count) << "count #1"; ASSERT_EQ(code, localCopy.error_codes[0]); // let's remove value which is not in the collection removeError((obd_code_e) 22); // element not present - nothing to removed ASSERT_EQ(1, localCopy.count); ASSERT_EQ(code, localCopy.error_codes[0]); code = OBD_Intake_Air_Temperature_Circuit_Malfunction; addError(code); getErrorCodes(&localCopy); // todo: ASSERT_EQ(2, localCopy.count); for (int code = 0; code < 100; code++) { addError((obd_code_e) code); } getErrorCodes(&localCopy); ASSERT_EQ(MAX_ERROR_CODES_COUNT, localCopy.count); // now we have full array and code below present removeError(code); getErrorCodes(&localCopy); ASSERT_EQ(MAX_ERROR_CODES_COUNT - 1, localCopy.count); }
static void testMalfunctionCentralRemoveFirstElement() { initMalfunctionCentral(); print("******************************************* testMalfunctionCentralRemoveFirstElement\r\n"); error_codes_set_s localCopy; obd_code_e firstElement = OBD_Engine_Coolant_Temperature_Circuit_Malfunction; addError(firstElement); obd_code_e secondElement = OBD_Intake_Air_Temperature_Circuit_Malfunction; addError(secondElement); getErrorCodes(&localCopy); ASSERT_EQ(2, localCopy.count); // let's remove first element - code removeError(firstElement); getErrorCodes(&localCopy); ASSERT_EQ(1, localCopy.count); ASSERT_EQ(secondElement, localCopy.error_codes[0]); }
void GitBrowser::init() { lastCommand = GitBrowser::Init; init_remote = repoParams->login+"@"+repoParams->url; QDir dir(repoFolder); if (!dir.exists()) { QDir root("/"); if (!root.mkpath(repoFolder)) { initFailure("Ошибка инициализации репозитория", "Невозможно создать каталог '"+repoFolder+"'. Проверьте наличие соответствующих прав у пользователя"); return; } } QFile gitFile(repoFolder+"/.git"); if (!gitFile.exists()) { syncWidget->showSynch("Инициализация локального репозитория...", true); syncWidget->setProgress(50); connect(&fileManager, SIGNAL(progressChanged(int)), this, SLOT(initRemoveProgressChanged(int))); connect(&fileManager, SIGNAL(removeSuccess()), this, SLOT(initRemoveSuccess())); connect(&fileManager, SIGNAL(removeError(QString,QString)), this, SLOT(initRemoveFailure(QString,QString))); fileManager.remove(repoFolder); } else
void setError(int flag, obd_code_e errorCode) { if (flag) addError(errorCode); else removeError(errorCode); }
int compareFinalCSRho_v2(int analysisIs2D=0, int stopAt=0, int saveCS=0) { if (!DYTools::setup(analysisIs2D)) return retCodeError; // ---------------------------------------- // Main part TH2D *h2UnfYield1_global=NULL; TH2D *h2UnfYield2_global=NULL; TH2D *hEffRho1_global=NULL; TH2D *hEffRho2_global=NULL; TH2D *hAcc1_global=NULL; TH2D *hAcc2_global=NULL; TMatrixD *fsrInvUnf1_global=NULL; TMatrixD *fsrInvUnf2_global=NULL; TString rhoCorrFName="../../Results-DYee/root_files_reg/constants/DY_j22_19712pb_egamma_Unregressed_energy/covRhoFileSF_nMB41_asymHLT_Unregressed_energy-allSyst_100_v2.root"; TH2D* hRho=LoadMatrixFields(rhoCorrFName,1,"scaleFactor","scaleFactorErr",1); if (!hRho) return retCodeError; // ---------------------------------------------------------- // Unfolding // ============================================ // ---------------------------------------- // load signal yield and unfold it if (1) { TString path="../../Results-DYee/root_files_reg/"; TString yieldFName="yield/DY_j22_19712pb_ApplyEscale/bg-subtracted_yield_1D__peak20140220.root"; TString yieldField="signalYieldDDbkg"; TH2D* h2SigYield=LoadHisto2D(yieldField,path+yieldFName,"",1); if (!h2SigYield) return retCodeError; TH2D *h2SigYield2=Clone(h2SigYield,"h2SigYield_divRho"); if (!multiplyHisto(h2SigYield2,hRho,0)) return retCodeError; //h2SigYield_global= Clone(h2SigYield,"h2SigYield_ini"); //if (!h2SigYield_global) return retCodeError; TMatrixD* UnfM1= loadMatrix(path+TString("constants/DY_j22_19712pb/detResponse_unfolding_constants1D.root"),"DetResponse",41,41,1); if (!UnfM1) return retCodeError; TH2D* detResp1= createHisto2D(*UnfM1,NULL, "detResponse_DYee","detResponse_DYee", _colrange_default,1,0.); if (!detResp1) return retCodeError; TMatrixD* UnfM2= new TMatrixD(*UnfM1); if (!UnfM2) return retCodeError; TH2D* detResp2= detResp1; if (!detResp2) return retCodeError; if (stopAt==1) { // compare the response matrices // ------------- begin inset TH2D* detRespDiff=Clone(detResp1,"detRespDiff"); detRespDiff->Add(detResp2,-1); detRespDiff->SetTitle("difference"); detResp1->GetZaxis()->SetRangeUser(0,1.); detResp2->GetZaxis()->SetRangeUser(0,1.); printProfileSums(detResp1); printProfileSums(detResp2); compareProfileSums(detResp1,detResp2); TCanvas *cdiff=new TCanvas("cdiff","cdiff",1200,400); cdiff->Divide(3,1); for (int i=1; i<3; ++i) { TPad *pad=(TPad*)cdiff->GetPad(i); pad->SetLogx(); pad->SetLogy(); } AdjustFor2DplotWithHeight(cdiff); cdiff->cd(1); detResp1->Draw("COLZ"); cdiff->cd(2); detResp2->Draw("COLZ"); cdiff->cd(3); //detRespDiff->GetZaxis()->SetRangeUser(-0.01,0.); detRespDiff->Draw("COLZ"); //UnfM->Draw("COLZ"); cdiff->Update(); return retCodeStop; // ------------- end inset } TMatrixD invUnf1(*UnfM1); TMatrixD invUnf2(*UnfM2); double det; invUnf1.Invert(&det); invUnf2.Invert(&det); if (stopAt==2) { // compare the inverted response matrices // ------------- begin inset TH2D* detInvResp1= createHisto2D(invUnf1,NULL, "detInvResponse_DYee","detInvResponse_DYee", _colrange_default,0,0.); TH2D* detInvResp2= createHisto2D(invUnf2,NULL, "detInvResponse","detInvResponse", _colrange_default,0,0.); TH2D* detInvRespDiff=Clone(detInvResp1,"detInvRespDiff"); detInvRespDiff->Add(detInvResp2,-1); detInvRespDiff->SetTitle("difference"); TCanvas *cdiff=new TCanvas("cdiff","cdiff",1200,400); cdiff->Divide(3,1); for (int i=1; i<3; ++i) { TPad *pad=(TPad*)cdiff->GetPad(i); pad->SetLogx(); pad->SetLogy(); } AdjustFor2DplotWithHeight(cdiff); cdiff->cd(1); detInvResp1->Draw("COLZ"); cdiff->cd(2); detInvResp2->Draw("COLZ"); cdiff->cd(3); detInvRespDiff->Draw("COLZ"); //UnfM->Draw("COLZ"); cdiff->Update(); return retCodeStop; // ------------- end inset } TH2D *h2Unf1=Clone(h2SigYield,"h2Unf_DYee"); TH2D *h2Unf2=Clone(h2SigYield,"h2Unf2"); if ( !unfold(h2Unf1, invUnf1, h2SigYield) || !unfold(h2Unf2, invUnf2, h2SigYield2) ) return retCodeError; h2UnfYield1_global=Clone(h2Unf1, "h2UnfYield1"); h2UnfYield2_global=Clone(h2Unf2, "h2UnfYield2"); if (!h2UnfYield1_global || !h2UnfYield2_global) return retCodeError; if (stopAt==3) { // ------------ begin inset TString label1="DYee"; TString label2="DYee (#rho corr)"; std::vector<int> colors; colors.push_back(kRed+1); colors.push_back(kBlue); // ---------------------------------- // Plot data TString yAxisLabel="unfolded yield"; std::vector<TH2D*> hV; std::vector<TString> labelV; hV.push_back(h2Unf1); labelV.push_back(label1); hV.push_back(h2Unf2); labelV.push_back(label2); TCanvas *cx= plotProfiles("cxUnf",hV,labelV,&colors,1, yAxisLabel); cx->Update(); // ---------------------------------- // Plot error std::vector<TH2D*> hErrV; for (unsigned int i=0; i<hV.size(); ++i) { TH2D* hErr=Clone(hV[i],hV[i]->GetName() + TString("_err")); swapContentAndError(hErr); removeError(hErr); hErrV.push_back(hErr); } TCanvas *cy= plotProfiles("cerrUnf",hErrV,labelV,&colors,1, yAxisLabel + TString(" error")); cy->Update(); // ------------------------ end inset } } // ---------------------------------------------------------- // Load corrective factors: EffRho, Acc // ============================================ if (1) { for (int iter=0; iter<2; ++iter) { TCompareCase_t theCase=(iter==0) ? _cmp_EffRho : _cmp_Acc; TH2D* h1=NULL, *h2=NULL, *h3=NULL; TH2D *h1Syst=NULL; TString fname1,field1,field1err; TString fname2,field2,field2err; TString fname3,field3,field3err; TString label1="DYee", label2="DYeeRho", label3="unknown"; TString path1="../../Results-DYee/root_files_reg/"; TString path2=path1; TString path3=path1; int loadText2=0; int is1Dhisto2=0, is1Dhisto3=0; TString yAxisLabel="y"; switch(theCase) { case _cmp_RawYield: fname1="yield/DY_j22_19712pb_ApplyEscale/bg-subtracted_yield_1D__peak20140220.root"; field1="Input/observedYield"; //fname2="raw_yield1D_EE.txt"; //loadText2=1; yAxisLabel="raw yield"; break; case _cmp_FakeBkg: fname1="yield/DY_j22_19712pb_ApplyEscale/bg-subtracted_yield_1D__peak20140220.root"; field1="Input/fakeBackgroundFromData"; field1err="Input/fakeBackgroundFromDataSyst"; //fname2="fakeBkg1D_EE.txt"; //loadText2=1; yAxisLabel="fake bkg"; break; case _cmp_TrueBkg: fname1="yield/DY_j22_19712pb_ApplyEscale/bg-subtracted_yield_1D__peak20140220.root"; field1="Input/true2eBackgroundFromData"; field1err="Input/true2eBackgroundFromDataSyst"; //fname2="trueBkg1D_EE.txt"; //loadText2=1; yAxisLabel="true bkg"; break; case _cmp_Eff: fname1="constants/DY_j22_19712pb/efficiency_1D.root"; field1="hEfficiency"; fname2=fname1; field2=field2; //fname2="efficiencyTotal1D_EE.txt"; //loadText2=1; //fname3="acceff.root"; //field3="eff_postFSRcorr"; //is1Dhisto3=1; //label3="Alexey (acceff.root)"; yAxisLabel="efficiency"; break; case _cmp_MCeff: fname1="constants/DY_j22_19712pb/efficiency_1D.root"; field1="hEfficiency"; //fname2="acceff.root"; //field2="eff_postFSRcorr"; //is1Dhisto2=1; //label2="Alexey (acceff.root)"; yAxisLabel="MC efficiency"; break; case _cmp_EffRho: fname1="constants/DY_j22_19712pb/efficiency_1D.root"; field1="hEfficiency"; fname2=fname1; field2=field1; //fname2="efficiencyTotal1D_EE.txt"; //loadText2=1; yAxisLabel="efficiency #times #rho"; break; case _cmp_Acc: fname1="constants/DY_j22_19712pb/acceptance_1D.root"; field1="hAcceptance"; fname2=fname1; field2=field1; //fname2="acceptance1D_EE.txt"; //loadText2=1; //fname3="acceff.root"; //field3="acc_postFSRcorr"; //is1Dhisto3=1; //label3="Alexey (acceff.root)"; yAxisLabel="acceptance"; break; default: std::cout << "Not ready for the case\n"; return retCodeError; } // ---------------------------------- // Load data h1=LoadHisto2D(field1,path1+fname1,"",1); if (!h1) return retCodeError; if (field1err.Length()) { h1Syst=LoadHisto2D(field1err,path1+fname1,"",1); if (!h1Syst) return retCodeError; h1->Add(h1Syst,1.); } if (loadText2) { h2=loadTextFile(path2+fname2,"h2"); if (!h2) return retCodeError; } else if (is1Dhisto2) h2= loadHisto1D_convert_TH2D(path2+fname2,field2); else h2=LoadHisto2D(field2,path2+fname2,"",1); if (fname3.Length()) { if (is1Dhisto3) h3= loadHisto1D_convert_TH2D(path3+fname3,field3); } // ---------------------------------- // Special adjustments if (theCase==_cmp_EffRho) { // load the scale factors int check=0; if (check) { printHisto(h1); printHisto(hRho); } if (!multiplyHisto(h1,hRho,1)) return retCodeError; if (check) printHisto(h1); if (0) { TH2D *rhoRelErr=getRelError(hRho,"rhoRelErr",0); printHisto(rhoRelErr); } } if (theCase==_cmp_EffRho) { hEffRho1_global=Clone(h1,"hEffRho_DYee"); hEffRho2_global=Clone(h2,"hEffRho_DYeeRho"); if (!hEffRho1_global || !hEffRho2_global) return retCodeError; } else if (theCase==_cmp_Acc) { hAcc1_global=Clone(h1,"hAcc_DYee"); hAcc2_global=Clone(h2,"hAcc_DYeeRho"); } if (stopAt==4) { // ---------------------------------- // Plot data std::vector<TH2D*> hV; std::vector<TString> labelV; hV.push_back(h1); labelV.push_back(label1); hV.push_back(h2); labelV.push_back(label2); if (h3) { hV.push_back(h3); labelV.push_back(label3); } TString cxName=Form("cxCorr_%d",iter); TCanvas *cx= plotProfiles(cxName,hV,labelV,NULL,1, yAxisLabel); cx->Update(); // ---------------------------------- // Plot error std::vector<TH2D*> hErrV; for (unsigned int i=0; i<hV.size(); ++i) { TH2D* hErr=Clone(hV[i],hV[i]->GetName() + TString("_err")); swapContentAndError(hErr); removeError(hErr); hErrV.push_back(hErr); } TString cyName=Form("cyCorr_%d",iter); TCanvas *cy= plotProfiles(cyName,hErrV,labelV,NULL,1, yAxisLabel + TString(" error")); cy->Update(); } } } // load corrective factors // ---------------------------------------------------------- // FSR unfolding // ============================================ if (1) { TFsrUnfCompareCase_t theCase=_cmp_fsrGood; // ---------------------------------- // Main part TString yAxisLabel="unfolded yield"; TString path="../../Results-DYee/root_files_reg/"; TString yieldFName="../../Results-DYee/root_files_reg/xsec/DY_j22_19712pb/xSec_preFsr_1DpostFsrFullSp.root"; TString yieldField="hpPostFsrFullSp_divLumi"; TH2D* h2PostFsrCS=LoadHisto2D(yieldField,path+yieldFName,"",1); if (!h2PostFsrCS) return retCodeError; TString fName=TString("constants/DY_j22_19712pb/detResponse_unfolding_constants1D.root"); TString tag; switch(theCase) { case _cmp_fsrGood: fName.ReplaceAll("detResponse","fsrGood"); tag="good"; break; case _cmp_fsrExact: fName.ReplaceAll("detResponse","fsrExact"); tag="exact"; break; default: std::cout << "macro is not ready for this case\n"; return retCodeError; } TMatrixD* UnfM1= loadMatrix(path+fName,"DetResponse",41,41,1); if (!UnfM1) return retCodeError; TString histoName1="detFSRResponse_DYee" + tag; TH2D* detResp1= createHisto2D(*UnfM1,NULL,histoName1,histoName1, _colrange_default,1,0.); detResp1->GetZaxis()->SetRangeUser(0,1); if (!detResp1) return retCodeError; TH2D* detResp2=detResp1; TMatrixD* UnfM2=UnfM1; if (stopAt==10) { // compare the response matrices // ------------- begin inset TH2D* detRespDiff=Clone(detResp1,"detRespDiff"); detRespDiff->Add(detResp2,-1); detRespDiff->SetTitle("difference"); TCanvas *cdiff=new TCanvas("cdiff","cdiff",1200,400); cdiff->Divide(3,1); AdjustFor2DplotWithHeight(cdiff); cdiff->cd(1); detResp1->Draw("COLZ"); cdiff->cd(2); detResp2->Draw("COLZ"); cdiff->cd(3); detRespDiff->Draw("COLZ"); //UnfM->Draw("COLZ"); cdiff->Update(); printHisto(detRespDiff); return retCodeStop; // ------------- end inset } TMatrixD invUnf1(*UnfM1); TMatrixD invUnf2(*UnfM2); double det; invUnf1.Invert(&det); invUnf2.Invert(&det); if (stopAt==11) { // compare the inverted response matrices // ------------- begin inset TH2D* detInvResp1= createHisto2D(invUnf1,NULL, "detInvResponse_DYee","detInvResponse_DYee", _colrange_default,0,0.); TH2D* detInvResp2= createHisto2D(invUnf2,NULL, "detInvResponse","detInvResponse", _colrange_default,0,0.); TH2D* detInvRespDiff=Clone(detInvResp1,"detInvRespDiff"); detInvRespDiff->Add(detInvResp2,-1); detInvRespDiff->SetTitle("difference"); TCanvas *cdiff=new TCanvas("cdiff","cdiff",1200,400); cdiff->Divide(3,1); AdjustFor2DplotWithHeight(cdiff); cdiff->cd(1); detInvResp1->Draw("COLZ"); cdiff->cd(2); detInvResp2->Draw("COLZ"); cdiff->cd(3); detInvRespDiff->Draw("COLZ"); //UnfM->Draw("COLZ"); cdiff->Update(); return retCodeStop; // ------------- end inset } TH2D *h2Unf1=Clone(h2PostFsrCS,"h2Unf_DYee"); TH2D *h2Unf2=Clone(h2PostFsrCS,"h2Unf2"); if ( !unfold(h2Unf1, invUnf1, h2PostFsrCS) || !unfold(h2Unf2, invUnf2, h2PostFsrCS) ) return retCodeError; fsrInvUnf1_global= new TMatrixD(invUnf1); fsrInvUnf2_global= new TMatrixD(invUnf2); if (!fsrInvUnf1_global || !fsrInvUnf2_global) return retCodeError; if (0) { // plot unfolded cross section TString label1="DYee"; TString label2="DYeeRho"; // ---------------------------------- // Plot data std::vector<TH2D*> hV; std::vector<TString> labelV; hV.push_back(h2Unf1); labelV.push_back(label1); hV.push_back(h2Unf2); labelV.push_back(label2); TCanvas *cx= plotProfiles("cxFsr",hV,labelV,NULL,1, yAxisLabel); cx->Update(); // ---------------------------------- // Plot error std::vector<TH2D*> hErrV; for (unsigned int i=0; i<hV.size(); ++i) { TH2D* hErr=Clone(hV[i],hV[i]->GetName() + TString("_err")); swapContentAndError(hErr); removeError(hErr); hErrV.push_back(hErr); } TCanvas *cy= plotProfiles("cyFsr",hErrV,labelV,NULL,1, yAxisLabel + TString(" error")); cy->Update(); } } // load FSR unfolding // ---------------------------------------------------------------- // ---------------------------------------------------------- // Final calculation // ============================================ if (1) { TH2D* h2UnfEffRhoYield1= Clone(h2UnfYield1_global,"h2UnfEffRhoYield_DYee"); TH2D* h2UnfEffRhoYield2= Clone(h2UnfYield2_global,"h2UnfEffRhoYield_DYeeRho"); int multiply=0; // 1 - multiply, 0 - divide if (!multiplyHisto(h2UnfEffRhoYield1, hEffRho1_global, multiply) || !multiplyHisto(h2UnfEffRhoYield2, hEffRho2_global, multiply)) { return retCodeError; } TH2D* h2PostFsrYield1= Clone(h2UnfEffRhoYield1, "h2PostFsrYield_DYee"); TH2D* h2PostFsrYield2= Clone(h2UnfEffRhoYield2, "h2PostFsrYield_DYeeRho"); if (!multiplyHisto(h2PostFsrYield1, hAcc1_global, multiply) || !multiplyHisto(h2PostFsrYield2, hAcc2_global, multiply)) { return retCodeError; } TH2D* h2PostFsrCS1= Clone(h2PostFsrYield1, "h2PostFsrCS_DYee"); TH2D* h2PostFsrCS2= Clone(h2PostFsrYield2, "h2PostFsrCS_DYeeRho"); h2PostFsrCS1->Scale(1/DYTools::lumiAtECMS); h2PostFsrCS2->Scale(1/DYTools::lumiAtECMS); TH2D* h2PreFsrCS1= Clone(h2PostFsrCS1, "h2PreFsrCS_DYee"); TH2D* h2PreFsrCS2= Clone(h2PostFsrCS2, "h2PreFsrCS_DYeeRho"); if ( !unfold(h2PreFsrCS1, *fsrInvUnf1_global, h2PostFsrCS1) || !unfold(h2PreFsrCS2, *fsrInvUnf2_global, h2PostFsrCS2) ) { return retCodeError; } if (saveCS) { TString fname="cmp_UnfRho-20140604.root"; TFile fout(fname,"recreate"); if (!saveHisto(fout,h2PreFsrCS1,"","") || !saveHisto(fout,h2PreFsrCS2,"","")) { return retCodeError; } writeBinningArrays(fout,"compareAlexey/compareFinalCSRho.C"); fout.Close(); std::cout << "file <" << fout.GetName() << "> created\n"; } const int plotSteps[4]= { 1, 1, 1, 1 }; for (int iCase=0; iCase<4; ++iCase) { if (!plotSteps[iCase]) continue; TH2D *h1=NULL, *h2=NULL; TString canvTitle="cx"; TString yAxisLabel="y"; switch(iCase) { case 0: h1=h2UnfEffRhoYield1; h2=h2UnfEffRhoYield2; canvTitle.Append("_unfEffRhoYield"); yAxisLabel="N_{u}/(#epsilon#rho)"; break; case 1: h1=h2PostFsrYield1; h2=h2PostFsrYield2; canvTitle.Append("_postFsrYield"); yAxisLabel="N_{u}/(A#epsilon#rho)"; break; case 2: h1=h2PostFsrCS1; h2=h2PostFsrCS2; canvTitle.Append("_postFsrCS"); yAxisLabel="#sigma_{postFsr}=N_{u}/(A#epsilon#rhoL) [pb]"; break; case 3: h1=h2PreFsrCS1; h2=h2PreFsrCS2; canvTitle.Append("_preFsrCS"); yAxisLabel="#sigma_{preFsr} [pb]"; break; default: std::cout << "not ready for iCase=" << iCase << "\n"; return retCodeError; } if (!h1 || !h2) { std::cout << "histos were not assigned\n"; return retCodeError; } TString label1="DYee"; TString label2="DYeeRho"; // ---------------------------------- // Plot data std::vector<TH2D*> hV; std::vector<TString> labelV; hV.push_back(h1); labelV.push_back(label1); hV.push_back(h2); labelV.push_back(label2); TCanvas *cx= plotProfiles(canvTitle,hV,labelV,NULL,1, yAxisLabel); cx->Update(); // ---------------------------------- // Plot error if (0) { std::vector<TH2D*> hErrV; for (unsigned int i=0; i<hV.size(); ++i) { TH2D* hErr=Clone(hV[i],hV[i]->GetName() + TString("_err")); swapContentAndError(hErr); removeError(hErr); hErrV.push_back(hErr); } TCanvas *cy= plotProfiles(canvTitle+TString("_err"),hErrV,labelV,NULL,1, yAxisLabel + TString(" error")); cy->Update(); } } } return retCodeOk; }
void setError(bool isError, obd_code_e errorCode) { if (isError) addError(errorCode); else removeError(errorCode); }
void plotXsec(const TString xsecConfFile, const TString xSecKindString, const TString crossSectionSet="_fsrUnfGood"){ // -------------------------------------------------------------- // Process input // -------------------------------------------------------------- XSecInputFileMgr_t inpMgr; if (!inpMgr.Load(xsecConfFile)) { std::cout << "failed to load file <" << xsecConfFile << ">\n"; return; } DYTools::TCrossSectionKind_t csKind=DYTools::_cs_None; if (xSecKindString.Contains("auto") || xSecKindString.Contains("default")) { if (DYTools::study2D==1) csKind=DYTools::_cs_preFsrDetNorm; else csKind=DYTools::_cs_preFsrNorm; } else { csKind=DetermineCrossSectionKind(xSecKindString); // auto-stop on failure } // -------------------------------------------------------------- // Prepare variables // -------------------------------------------------------------- TGaxis::SetMaxDigits(3); CPlot::sOutDir = TString("plots_") + DYTools::analysisTag + TString("_") + inpMgr.evtEffScaleTag(); TriggerSelection triggers(inpMgr.triggerSetName(),true,0); ComparisonPlot_t::TRatioType_t ratio= ComparisonPlot_t::_ratioPlain; // #1/#2 //ComparisonPlot_t::_ratioRel; // (#1-#2)/#1 TString ratioYLabel=(ratio==ComparisonPlot_t::_ratioPlain) ? "data/theory" : "(th-dt)/th"; if (DYTools::study2D) { ratioYLabel=(ratio==ComparisonPlot_t::_ratioPlain) ? "theory/data" : "(dt-th)/dt"; } ComparisonPlot_t compPlot(ratio, "check","", (DYTools::study2D) ? "rapidity |y|" : "m_{ee} [GeV]", CrossSectionKindLongName(csKind), ratioYLabel); //compPlot.SetRatioNdivisions(805); //compPlot.SetPrintValues(1); //compPlot.SetPrintRatios(1); compPlot.SetPrintRatioNames(1); int cWidth=600, cHeight=700; if (DYTools::study2D) { //double rdy=0.15; compPlot.SetRatioYRange(1-rdy,1+rdy); cWidth=400*(2+landscape); cHeight=400*(3-landscape); } else { compPlot.SetLogx(1); compPlot.SetLogy(1); //double rdy=0.15; compPlot.SetRatioYRange(1-rdy,1+rdy); cWidth=600; cHeight=700; } TString dataFName=TString("../root_files/") + inpMgr.evtEffScaleTag() + crossSectionSet + TString("/xSec"); if (!csPreFsr(csKind)) dataFName.Append("PostFsr"); if (csInDET(csKind)) dataFName.Append("DET"); dataFName.Append("_results_"); dataFName.Append(DYTools::analysisTag); if (!csPreFsr(csKind)) dataFName.Append(triggers.triggerConditionsName()); dataFName.Append(".root"); // -------------------------------------------------------------- // Prepare plots // -------------------------------------------------------------- TString canvasName=TString("cXsec_") + CrossSectionKindName(csKind) + TString("_") + DYTools::analysisTag; TCanvas *canvas=MakeCanvas(canvasName,canvasName,cWidth,cHeight); std::vector<ComparisonPlot_t*> compPlotsV; //std::vector<TH1F*> dataHistos; std::vector<TH1F*> histos; if (DYTools::study2D) { // 2D compPlot.Prepare6Pads(canvas,landscape); vector<TLatex*> massLabels; prepareMassRanges(massLabels,0.55,0.17, kBlue+2); // // data for (int i=0; i<6; ++i) { const int iM=i+1; // skip 1st mass bin ComparisonPlot_t *cp=new ComparisonPlot_t(compPlot,Form("compPlot_%d",i+1),""); compPlotsV.push_back(cp); std::vector<TH1F*> localHV; if ((csKind==DYTools::_cs_preFsrDet) || (csKind==DYTools::_cs_preFsrDetNorm)) { if (plot_theoryCT10) { TH1F* hTh=readTh2D_CT10(csKind, iM); hTh->SetMarkerStyle(27); hTh->SetMarkerSize(0.8); cp->AddHist1D(hTh,"CTEQ10W","L",kGreen+1,1,0,1); histos.push_back(hTh); localHV.push_back(hTh); } if (plot_theoryMSTW2008) { TH1F* hTh=readTh2D_MSTW2008(csKind, iM); hTh->SetMarkerStyle(24); hTh->SetMarkerSize(0.8); cp->AddHist1D(hTh,"MSTW2008","L",kBlue,1,0,1); histos.push_back(hTh); localHV.push_back(hTh); } } // data TH1F* hData=readData(triggers,csKind,iM,dataFName); histos.push_back(hData); localHV.push_back(hData); cp->AddHist1D(hData,"data","P",kBlack,1,0,1); cp->SetRefIdx(hData); for (unsigned int ii=0; ii<localHV.size(); ++ii) { localHV[ii]->GetYaxis()->SetTitleOffset(1.2); } // Plotting and beautifying int subpad=-1; cp->Draw6(canvas,landscape,i+1,false,"png",&subpad); canvas->cd(subpad); massLabels[iM]->Draw(); if (i==2) { cp->AddTextCMSPreliminary(); cp->AddTextLumi(0.55,0.27); } } } else { // 1D canvas->Divide(1,2); compPlot.PreparePads(canvas); // theory if ((csKind==DYTools::_cs_preFsr) || (csKind==DYTools::_cs_preFsrNorm)) { TH1F* hTh=readTh1D_MSTW2008(csKind); removeError(hTh); compPlot.AddHist1D(hTh,"NNLO, FEWZ+MSTW08","L",kBlue,1,0,0); compPlot.SkipInRatioPlots(hTh); // do not consider for ratios histos.push_back(hTh); } // theory: special set to calculate ratios if (csKind==DYTools::_cs_preFsrNorm) { int showLabel=-1; TString draw_opt=(showPoints) ? "P" : "P skip"; TH1F* hTh=readTh1D_MSTW2008(csKind,"_NNLO","default",_th2011_nnlo); hTh->SetMarkerSize(0.8); compPlot.AddHist1D(hTh,"NNLO, FEWZ+MSTW08 (40bins)",draw_opt,kBlue,1,0,showLabel); compPlot.SetRefIdx(hTh); // use to calculate ratios histos.push_back(hTh); } // data 1D TH1F* hData=readData(triggers,csKind,-1, dataFName); histos.push_back(hData); compPlot.AddHist1D(hData,"data","P",kBlack,1,0,1); } for (unsigned int i=0; i<histos.size(); i++) { histos[i]->SetDirectory(0); } // -------------------------------------------------------------- // Plot // -------------------------------------------------------------- if (DYTools::study2D) { } else { // 1D compPlot.Draw(canvas,false,"png"); canvas->cd(1); compPlot.AddTextCMSPreliminary(); compPlot.AddTextLumi(0.55,0.27); } canvas->Update(); canvas->cd(); SaveCanvas(canvas,canvas->GetName()); return; }