Beispiel #1
0
void checkInputs()
{
  TFile fin("/mnt/sdc/andriusj/DY13TeV/DYanalysis-20160817/ElectronNtupler/test/Analysis_Codes/AccEff/dyee_preFSR_forAccEff_v1steps.root");
  TH1D *h1effPass_new= loadHisto(fin,"h1_eff_sumPass","h1effPass_new",1,h1dummy);
  TH1D *h1effPass_chk= loadHisto(fin,"h1_eff_sumPass_chk","h1effPass_chk",1,h1dummy);
  TH1D *h1effPass_noTrigNoPU= loadHisto(fin,"h1_eff_sumPass_noTrigNoPU","h1effPass_noTrigNoPU",1,h1dummy);
  TH1D *h1effTot_new= loadHisto(fin, "h1_eff_sumTot", "h1effTot_new",1,h1dummy);
  fin.Close();
  if (!h1effPass_new || !h1effPass_chk || !h1effPass_noTrigNoPU || !h1effTot_new) return;

  TFile fin2("/mnt/sdc/andriusj/DY13TeV/DYanalysis-20160817/ElectronNtupler/test/Analysis_Codes/AccEff/dyee_preFSR_forAccEff_v1.root");
  TH1D *h1effPass_old= loadHisto(fin2,"h1_eff_sumPass","h1effPass_old",1,h1dummy);
  TH1D *h1effTot_old= loadHisto(fin2,"h1_eff_sumTot","h1effTot_old",1,h1dummy);
  fin2.Close();
  if (!h1effPass_old || !h1effTot_old) return;

  histoStyle(h1effPass_chk,kRed,5,1);
  histoStyle(h1effPass_old,kBlue,7,1);

  plotHisto(h1effPass_new,"cCheck",1,0,"LPE1","new effPass");
  plotHistoSame(h1effPass_chk,"cCheck","LPE1","new effPass (control)");
  printRatio(h1effPass_chk,h1effPass_new);

  //plotHisto(h1effPass_noTrigNoPU,"cCmpOld",1,0,"LPE1","noTrigNoPU");
  //plotHistoSame(h1effPass_old,"cCmpOld","LPE1","old effPass");
  //printRatio(h1effPass_old,h1effPass_noTrigNoPU);

  plotHisto(h1effTot_new,"cCmpTot",1,0,"LPE1","new effTot");
  plotHistoSame(h1effTot_old,"cCmpTot","LPE1","old effTot");
  printRatio(h1effTot_old,h1effTot_new);
}
Beispiel #2
0
void plotSteps()
{

  //checkInputs(); return;

  TFile fin("/mnt/sdc/andriusj/DY13TeV/DYanalysis-20160817/ElectronNtupler/test/Analysis_Codes/AccEff/dyee_preFSR_forAccEff_v1steps.root");
  TH1D *h1effPass_new= loadHisto(fin,"h1_eff_sumPass","h1effPass_new",1,h1dummy);
  TH1D *h1effPass_noPU= loadHisto(fin,"h1_eff_sumPass_noPU","h1effPass_noPU",1,h1dummy);
  TH1D *h1effPass_noTrigObjMatching= loadHisto(fin,"h1_eff_sumPass_noTrigObjMatching","h1effPass_noTrigObjMatching",1,h1dummy);
  TH1D *h1effPass_matchDR3= loadHisto(fin,"h1_eff_sumPass_matchDR3","h1effPass_matchDR3",1,h1dummy);
  TH1D *h1effPass_noTrig= loadHisto(fin,"h1_eff_sumPass_noTrig","h1effPass_noTrig",1,h1dummy);
  TH1D *h1effPass_noTrigNoPU= loadHisto(fin,"h1_eff_sumPass_noTrigNoPU","h1effPass_noTrigNoPU",1,h1dummy);
  //TH1D *h1effTot_new= loadHisto(fin, "h1_eff_sumTot", "h1effTot_new",1,h1dummy);
  fin.Close();
  if (!h1effPass_new  || !h1effPass_noPU || !h1effPass_noTrigObjMatching ||
      !h1effPass_matchDR3 || !h1effPass_noTrig || !h1effPass_noTrigNoPU) {
    std::cout << "null ptr\n";
    return;
  }

  std::vector<TH1D*> h1InfoV;
  std::vector<TString> infoLabelV;

  histoStyle(h1effPass_noPU,kRed,5,1);
  histoStyle(h1effPass_noTrig,kBlue,7,2);
  histoStyle(h1effPass_matchDR3,kGreen+1,5,1);
  histoStyle(h1effPass_noTrigObjMatching,kOrange,20,2);

  std::cout << "\nwPU effect on new effPass distribution\n";
  plotHisto(h1effPass_new,"cPUnew",1,0,"LPE1","new wPU");
  plotHistoSame(h1effPass_noPU,"cPUnew","LPE1","new noPU");
  printRatio(h1effPass_new,h1effPass_noPU);
  addRatio(h1effPass_noPU,h1effPass_new,"no PU rew.",h1InfoV,infoLabelV);

  std::cout << "\nwPU effect on old effPass distribution\n";
  plotHisto(h1effPass_noTrig,"cPUold",1,0,"LPE1","old wPU");
  plotHistoSame(h1effPass_noTrigNoPU,"cPUold","LPE1","old noPU");
  printRatio(h1effPass_noTrig,h1effPass_noTrigNoPU);

  std::cout << "\ntriggering\n";
  plotHisto(h1effPass_new,"cTrig",1,0,"LPE1","new wPU");
  plotHistoSame(h1effPass_noTrig,"cTrig","LPE1","no event trigger");
  printRatio(h1effPass_new,h1effPass_noTrig);
  addRatio(h1effPass_noTrig,h1effPass_new,"no trigger",h1InfoV,infoLabelV);

  std::cout << "\ntrigger object matching\n";
  plotHisto(h1effPass_new,"cTrigObjMatch",1,0,"LPE1","new wPU");
  plotHistoSame(h1effPass_noTrigObjMatching,"cTrigObjMatch","LPE1","new, noTrigObjMatch");
  printRatio(h1effPass_new,h1effPass_noTrigObjMatching);
  addRatio(h1effPass_noTrigObjMatching,h1effPass_new,"no trig.obj.match.",h1InfoV,infoLabelV);

  std::cout << "\nDR effect on new effPass distribution\n";
  plotHisto(h1effPass_new,"cDR",1,0,"LPE1","new wPU, match DR1");
  plotHistoSame(h1effPass_matchDR3,"cDR","LPE1","new wPU, match DR3");
  printRatio(h1effPass_new,h1effPass_matchDR3);
  addRatio(h1effPass_matchDR3,h1effPass_new,"#DeltaR<0.3",h1InfoV,infoLabelV);

  //printLatex("effPassSteps.tex",h1InfoV,infoLabelV,1);
  plotRatios(h1InfoV,infoLabelV);
}
/*********************************************************************************************************
** Function name:           printThreeRatios
** Descriptions:            prints resistance ratio for debugging, this is private
*********************************************************************************************************/
void MutichannelGasSensor::printThreeRatios()
{
    printRatio(res[0], res0[0]);
    Serial.print(", ");
    printRatio(res[1], res0[1]);
    Serial.print(", ");
    printRatio(res[2], res0[2]);
}
Beispiel #4
0
 // Surprisingly expensive to call...
 void printRatio(uint64_t comp_size, const std::string& extra) {
   printRatio(comp_size, count, extra);
 }
Beispiel #5
0
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";
  }
}
Beispiel #6
0
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;
}
Beispiel #7
0
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);
}