コード例 #1
0
ファイル: makeTable.C プロジェクト: geonmo/cmg-cmssw
void makeTable(int nbins = 40, const string label = "HFhits", const char * tag = "Preliminary_NoEffCor_AMPT_d1107", const char* dataset = "DATA"){

  bool DATA = false;
  bool SIM = true;
  bool MC = false;
  double EFF = 1;
  double MXS = 1. - EFF;

   // Retrieving data
  int maxEvents = -200;
  vector<int> runnums;
  
  //  const char* infileName = Form("/net/hisrv0001/home/yetkin/hidsk0001/analysis/prod/%s_RECO_391/test.root",dataset);
  const char* infileName = Form("/net/hisrv0001/home/yetkin/hidsk0001/centrality/prod/%s/test.root",dataset);

  //  TFile* infile = new TFile(infileName,"read");
  TChain* t = new TChain("HltTree");
  //  TChain* t = new TChain("hltanalysis/HltTree");

  t->Add(infileName);

  // Creating output table
  TFile* outFile = new TFile("tables_d1108.root","update");
   TDirectory* dir = outFile->mkdir(tag);
   dir->cd();
   TNtuple* nt = new TNtuple("nt","","hf:bin:b:npart:ncoll:nhard");
   CentralityBins* bins = new CentralityBins("noname","Test tag", nbins);
   bins->table_.reserve(nbins);

  TH1D::SetDefaultSumw2();

  int runMC = 1;
  TFile * inputMCfile;
  CentralityBins* inputMCtable;
  
  if(DATA){
    inputMCfile = new TFile("tables_d1103.root","read");
    inputMCtable = (CentralityBins*)inputMCfile->Get("CentralityTable_HFhits40_AMPT2760GeV_v1_mc_MC_38Y_V12/run1");
  }

  // Setting up variables & branches
  double binboundaries[nbinsMax+1];
  vector<float> values;

  float b,npart,ncoll,nhard,hf,hfhit,eb,ee,etmr,parameter;
  int npix,ntrks;
  //  TTree* t = (TTree*)infile->Get("HltTree");
  int run;

  if(SIM){
    t->SetBranchAddress("b",&b);
    t->SetBranchAddress("Npart",&npart);
    t->SetBranchAddress("Ncoll",&ncoll);
    t->SetBranchAddress("Nhard",&nhard);
  }

  t->SetBranchAddress("hiHFhit",&hfhit);
  t->SetBranchAddress("hiHF",&hf);
  t->SetBranchAddress("hiEB",&eb);
  t->SetBranchAddress("hiEE",&ee);
  t->SetBranchAddress("hiET",&etmr);
  t->SetBranchAddress("hiNpix",&npix);
  t->SetBranchAddress("hiNtracks",&ntrks);
  t->SetBranchAddress("Run",&run);

  bool binNpart = label.compare("Npart") == 0;
  bool binNcoll = label.compare("Ncoll") == 0;
  bool binNhard = label.compare("Nhard") == 0;
  bool binB = label.compare("b") == 0;
  bool binHF = label.compare("HFtowers") == 0;
  bool binHFhit = label.compare("HFhits") == 0;
  bool binEB = label.compare("EB") == 0;
  bool binEE = label.compare("EE") == 0;
  bool binETMR = label.compare("ETMR") == 0;
  bool binNpix = label.compare("PixelHits") == 0;
  bool binNtrks = label.compare("Ntracks") == 0;

  // Determining bins of cross section
  // loop over events
  unsigned int events=t->GetEntries();
  for(unsigned int iev = 0; iev < events && (maxEvents < 0 || iev< maxEvents); ++iev){
    if( iev % 100 == 0 ) cout<<"Processing event : "<<iev<<endl;
    t->GetEntry(iev);

    if(binNpart) parameter = npart;
    if(binNcoll) parameter = ncoll;
    if(binNhard) parameter = nhard;
    if(binB) parameter = b;
    if(binHF) parameter = hf;
    if(binHFhit) parameter = hfhit;
    if(binEB) parameter = eb;
    if(binEE) parameter = ee;
    if(binETMR) parameter = etmr;
    if(binNpix) parameter = npix;
    if(binNtrks) parameter = ntrks;
 
    values.push_back(parameter);
    if(runnums.size() == 0 || runnums[runnums.size()-1] != run) runnums.push_back(run);
  }
  
  if(label.compare("b") == 0) sort(values.begin(),values.end(),descend);
  else sort(values.begin(),values.end());

  double max = values[events-1];
  binboundaries[nbins] = max;

  cout<<"-------------------------------------"<<endl;
  cout<<label.data()<<" based cuts are : "<<endl;
  cout<<"(";

  int bin = 0;
  double dev = events;
  for(int i = 0; i< nbins; ++i){
     // Find the boundary 
    int entry = (int)(i*(dev/nbins));
    binboundaries[i] = values[entry];

     cout<<" "<<binboundaries[i];
     if(i < nbins - 1) cout<<",";
     else cout<<")"<<endl;
  }

  cout<<"-------------------------------------"<<endl;

  if(!DATA){

  // Determining Glauber results in various bins
  dir->cd();
  TH2D* hNpart = new TH2D("hNpart","",nbins,binboundaries,500,0,500);
  TH2D* hNcoll = new TH2D("hNcoll","",nbins,binboundaries,2000,0,2000);
  TH2D* hNhard = new TH2D("hNhard","",nbins,binboundaries,250,0,250);
  TH2D* hb = new TH2D("hb","",nbins,binboundaries,300,0,30);

  for(unsigned int iev = 0; iev < events && (maxEvents < 0 || iev< maxEvents); ++iev){
     if( iev % 100 == 0 ) cout<<"Processing event : "<<iev<<endl;
     t->GetEntry(iev);
     if(binNpart) parameter = npart;
     if(binNcoll) parameter = ncoll;
     if(binNhard) parameter = nhard;
     if(binB) parameter = b;
     if(binHF) parameter = hf;
     if(binHFhit) parameter = hfhit;
     if(binEB) parameter = eb;
     if(binEE) parameter = ee;
     if(binETMR) parameter = etmr;
     if(binNpix) parameter = npix;
     if(binNtrks) parameter = ntrks;
    
     hNpart->Fill(parameter,npart);
     hNcoll->Fill(parameter,ncoll);
     hNhard->Fill(parameter,nhard);
     hb->Fill(parameter,b);
     int bin = hNpart->GetXaxis()->FindBin(parameter) - 1;
     if(bin < 0) bin = 0;
     if(bin >= nbins) bin = nbins - 1;
     nt->Fill(hf,bin,b,npart,ncoll,nhard);
  }

  // Fitting Glauber distributions in bins to get mean and sigma values

  dir->cd();
  TF1* fGaus = new TF1("fb","gaus(0)",0,2); 
  fGaus->SetParameter(0,1);
  fGaus->SetParameter(1,0.04);
  fGaus->SetParameter(2,0.02); 
  
  fitSlices(hNpart,fGaus);
  fitSlices(hNcoll,fGaus);
  fitSlices(hNhard,fGaus);
  fitSlices(hb,fGaus);

  TH1D* hNpartMean = (TH1D*)gDirectory->Get("hNpart_1");
  TH1D* hNpartSigma = (TH1D*)gDirectory->Get("hNpart_2");
  TH1D* hNcollMean = (TH1D*)gDirectory->Get("hNcoll_1");
  TH1D* hNcollSigma = (TH1D*)gDirectory->Get("hNcoll_2");
  TH1D* hNhardMean = (TH1D*)gDirectory->Get("hNhard_1");
  TH1D* hNhardSigma = (TH1D*)gDirectory->Get("hNhard_2");
  TH1D* hbMean = (TH1D*)gDirectory->Get("hb_1");
  TH1D* hbSigma = (TH1D*)gDirectory->Get("hb_2");

  cout<<"-------------------------------------"<<endl;
  cout<<"# Bin NpartMean NpartSigma NcollMean NcollSigma bMean bSigma BinEdge"<<endl;

  // Enter values in table
  for(int i = 0; i < nbins; ++i){
     int ii = nbins-i;
     bins->table_[i].n_part_mean = hNpartMean->GetBinContent(ii);
     bins->table_[i].n_part_var = hNpartSigma->GetBinContent(ii);
     bins->table_[i].n_coll_mean = hNcollMean->GetBinContent(ii);
     bins->table_[i].n_coll_var = hNcollSigma->GetBinContent(ii);
     bins->table_[i].b_mean = hbMean->GetBinContent(ii);
     bins->table_[i].b_var = hbSigma->GetBinContent(ii);
     bins->table_[i].n_hard_mean = hNhardMean->GetBinContent(ii);
     bins->table_[i].n_hard_var = hNhardSigma->GetBinContent(ii);
     bins->table_[i].bin_edge = binboundaries[ii-1];

     cout<<i<<" "
	 <<hNpartMean->GetBinContent(ii)<<" "
	 <<hNpartSigma->GetBinContent(ii)<<" "
	 <<hNcollMean->GetBinContent(ii)<<" "
	 <<hNcollSigma->GetBinContent(ii)<<" "
	 <<hbMean->GetBinContent(ii)<<" "
	 <<hbSigma->GetBinContent(ii)<<" "
	 <<binboundaries[ii]<<" "
	 <<endl;
  }
  cout<<"-------------------------------------"<<endl;

  // Save the table in output file
  if(onlySaveTable){

     hNpart->Delete();
     hNpartMean->Delete();
     hNpartSigma->Delete();
     hNcoll->Delete();
     hNcollMean->Delete();
     hNcollSigma->Delete();
     hNhard->Delete();
     hNhardMean->Delete();
     hNhardSigma->Delete();
     hb->Delete();
     hbMean->Delete();
     hbSigma->Delete();
  }
 
  }else{
    cout<<"-------------------------------------"<<endl;
    cout<<"# Bin NpartMean NpartSigma NcollMean NcollSigma bMean bSigma BinEdge"<<endl;

    // Enter values in table
    for(int i = 0; i < nbins; ++i){
      int ii = nbins-i;
      bins->table_[i].n_part_mean = inputMCtable->NpartMeanOfBin(i);
      bins->table_[i].n_part_var = inputMCtable->NpartSigmaOfBin(i);
      bins->table_[i].n_coll_mean = inputMCtable->NcollMeanOfBin(i);
      bins->table_[i].n_coll_var = inputMCtable->NcollSigmaOfBin(i);
      bins->table_[i].b_mean = inputMCtable->bMeanOfBin(i);
      bins->table_[i].b_var = inputMCtable->bSigmaOfBin(i);
      bins->table_[i].n_hard_mean = inputMCtable->NhardMeanOfBin(i);
      bins->table_[i].n_hard_var = inputMCtable->NhardSigmaOfBin(i);
      bins->table_[i].bin_edge = binboundaries[ii-1];

      cout<<i<<" "
	  <<bins->table_[i].n_part_mean<<" "
          <<bins->table_[i].n_part_var<<" "
          <<bins->table_[i].n_coll_mean<<" "
          <<bins->table_[i].n_coll_var<<" "
          <<bins->table_[i].b_mean<<" "
          <<bins->table_[i].b_var<<" "
          <<bins->table_[i].n_hard_mean<<" "
          <<bins->table_[i].n_hard_var<<" "
          <<bins->table_[i].bin_edge<<" "<<endl;

    }
    cout<<"-------------------------------------"<<endl;

  }


  outFile->cd(); 
  dir->cd();

  bins->SetName(Form("run%d",1));
  bins->Write();
  nt->Write();  
  bins->Delete();
  outFile->Write();
  
}
コード例 #2
0
ファイル: makeCentralityTable.C プロジェクト: KiSooLee/TnP_B
void makeCentralityTable(int nbins = 40, const string label = "hf", const char * tag = "HFhitBins", double MXS = 0.){

   // This macro assumes all inefficiency is in the most peripheral bin.
   double EFF = 1. - MXS;

   // Retrieving data
  int nFiles = 1;
  vector<string> infiles;
  //  TFile* infile = new TFile("/net/hisrv0001/home/yetkin/pstore02/ana/Hydjet_MinBias_d20100222/Hydjet_MinBias_4TeV_runs1to300.root");
  //  fwlite::Event event(infile);
  infiles.push_back("~/hibat0007/aod/JulyExercise/MinBias0707/MinBias0707_runs1to10.root");
  //  infiles.push_back("~/hibat0007/aod/JulyExercise/MinBias0707/MinBias0707_runs11to20.root");
  infiles.push_back("~/hibat0007/aod/JulyExercise/MinBias0707/MinBias0707_runs21to30.root");
  infiles.push_back("~/hibat0007/aod/JulyExercise/MinBias0707/MinBias0707_runs31to40.root");
  infiles.push_back("~/hibat0007/aod/JulyExercise/MinBias0707/MinBias0707_runs41to50.root");
  infiles.push_back("~/hibat0007/aod/JulyExercise/MinBias0707/MinBias0707_runs51to60.root");
  //  infiles.push_back("~/hibat0007/aod/JulyExercise/MinBias0707/MinBias0707_runs61to70.root");
  //  infiles.push_back("~/hibat0007/aod/JulyExercise/MinBias0707/MinBias0707_runs71to80.root");
  //  infiles.push_back("~/hibat0007/aod/JulyExercise/MinBias0707/MinBias0707_runs81to90.root")
  //  infiles.push_back("~/hibat0007/aod/JulyExercise/MinBias0707/MinBias0707_runs91to100.root");

  fwlite::ChainEvent event(infiles);

  vector<int> runnums;

  // Creating output table
  TFile* outFile = new TFile("tables.root","update");
   TDirectory* dir = outFile->mkdir(tag);
   dir->cd();

  TH1D::SetDefaultSumw2();
  CentralityBins* bins = new CentralityBins("noname","Test tag", nbins);
  bins->table_.reserve(nbins);

  // Setting up variables & branches
  double binboundaries[nbinsMax+1];
  vector<float> values;

  // Determining bins of cross section
  // loop over events
  unsigned int events=0;
  for(event.toBegin(); !event.atEnd(); ++event, ++events){
     edm::EventBase const & ev = event;
    if( events % 100 == 0 ) cout<<"Processing event : "<<events<<endl;
    edm::Handle<edm::GenHIEvent> mc;
    ev.getByLabel(edm::InputTag("heavyIon"),mc);
    edm::Handle<reco::Centrality> cent;
    ev.getByLabel(edm::InputTag("hiCentrality"),cent);

    double b = mc->b();
    double npart = mc->Npart();
    double ncoll = mc->Ncoll();
    double nhard = mc->Nhard();

    double hf = cent->EtHFhitSum();
    double hftp = cent->EtHFtowerSumPlus();
    double hftm = cent->EtHFtowerSumMinus();
    double eb = cent->EtEBSum();
    double eep = cent->EtEESumPlus();
    double eem = cent->EtEESumMinus();

    double parameter = 0;
    if(label.compare("npart") == 0) parameter = npart;
    if(label.compare("ncoll") == 0) parameter = ncoll;
    if(label.compare("nhard") == 0) parameter = nhard;
    if(label.compare("b") == 0) parameter = b;
    if(label.compare("hf") == 0) parameter = hf;
    if(label.compare("hft") == 0) parameter = hftp + hftm;
    if(label.compare("eb") == 0) parameter = eb;
    if(label.compare("ee") == 0) parameter = eep+eem;

    values.push_back(parameter);
    
    int run = event.id().run();
    if(runnums.size() == 0 || runnums[runnums.size()-1] != run) runnums.push_back(run);
  }
  
  if(label.compare("b") == 0) sort(values.begin(),values.end(),descend);
  else sort(values.begin(),values.end());

  double max = values[events-1];
  binboundaries[nbins] = max;

  cout<<"-------------------------------------"<<endl;
  cout<<label.data()<<" based cuts are : "<<endl;
  cout<<"(";

  int bin = 0;
  for(int i = 0; i< nbins; ++i){
     // Find the boundary 
     int offset = (int)(MXS*events);
     double xsec = events*(1 + MXS);
     // Below should be replaced with an integral
     // when inefficiency is better parametrized 
     // than a step function.

     int entry = (int)(i*(xsec/nbins)) - offset;
     binboundaries[i] = values[entry];

     cout<<" "<<binboundaries[i];
     if(i < nbins - 1) cout<<",";
     else cout<<")"<<endl;
  }
  cout<<"-------------------------------------"<<endl;

  // Determining Glauber results in various bins
  TH2D* hNpart = new TH2D("hNpart","",nbins,binboundaries,500,0,500);
  TH2D* hNcoll = new TH2D("hNcoll","",nbins,binboundaries,2000,0,2000);
  TH2D* hNhard = new TH2D("hNhard","",nbins,binboundaries,250,0,250);
  TH2D* hb = new TH2D("hb","",nbins,binboundaries,300,0,30);

  for(event.toBegin(); !event.atEnd(); ++event){
     edm::EventBase const & ev = event;
     edm::Handle<edm::GenHIEvent> mc;
     ev.getByLabel(edm::InputTag("heavyIon"),mc);
     edm::Handle<reco::Centrality> cent;
     ev.getByLabel(edm::InputTag("hiCentrality"),cent);

     double b = mc->b();
     double npart = mc->Npart();
     double ncoll = mc->Ncoll();
     double nhard = mc->Nhard();

     double hf = cent->EtHFhitSum();
     double hftp = cent->EtHFtowerSumPlus();
     double hftm = cent->EtHFtowerSumMinus();
     double eb = cent->EtEBSum();
     double eep = cent->EtEESumPlus();
     double eem = cent->EtEESumMinus();

     double parameter = 0;

     if(label.compare("npart") == 0) parameter = npart;
     if(label.compare("ncoll") == 0) parameter = ncoll;
     if(label.compare("nhard") == 0) parameter = nhard;
     if(label.compare("b") == 0) parameter = b;
     if(label.compare("hf") == 0) parameter = hf;
     if(label.compare("hft") == 0) parameter = hftp + hftm;
     if(label.compare("eb") == 0) parameter = eb;
     if(label.compare("ee") == 0) parameter = eep+eem;
    
     hNpart->Fill(parameter,npart);
     hNcoll->Fill(parameter,ncoll);
     hNhard->Fill(parameter,nhard);
     hb->Fill(parameter,b);
  }

  // Fitting Glauber distributions in bins to get mean and sigma values


  TF1* fGaus = new TF1("fb","gaus(0)",0,2); 
  fGaus->SetParameter(0,1);
  fGaus->SetParameter(1,0.04);
  fGaus->SetParameter(2,0.02); 
  
  fitSlices(hNpart,fGaus);
  fitSlices(hNcoll,fGaus);
  fitSlices(hNhard,fGaus);
  fitSlices(hb,fGaus);

 /*
  hNpart->FitSlicesY();
  hNcoll->FitSlicesY();
  hNhard->FitSlicesY();
  hb->FitSlicesY();
 */

  TH1D* hNpartMean = (TH1D*)gDirectory->Get("hNpart_1");
  TH1D* hNpartSigma = (TH1D*)gDirectory->Get("hNpart_2");
  TH1D* hNcollMean = (TH1D*)gDirectory->Get("hNcoll_1");
  TH1D* hNcollSigma = (TH1D*)gDirectory->Get("hNcoll_2");
  TH1D* hNhardMean = (TH1D*)gDirectory->Get("hNhard_1");
  TH1D* hNhardSigma = (TH1D*)gDirectory->Get("hNhard_2");
  TH1D* hbMean = (TH1D*)gDirectory->Get("hb_1");
  TH1D* hbSigma = (TH1D*)gDirectory->Get("hb_2");

  cout<<"-------------------------------------"<<endl;
  cout<<"# Bin NpartMean NpartSigma NcollMean NcollSigma bMean bSigma BinEdge"<<endl;


  // Enter values in table
  for(int i = 0; i < nbins; ++i){
     bins->table_[nbins-i-1].n_part_mean = hNpartMean->GetBinContent(i);
     bins->table_[nbins-i-1].n_part_var = hNpartSigma->GetBinContent(i);
     bins->table_[nbins-i-1].n_coll_mean = hNcollMean->GetBinContent(i);
     bins->table_[nbins-i-1].n_coll_var = hNcollSigma->GetBinContent(i);
     bins->table_[nbins-i-1].b_mean = hbMean->GetBinContent(i);
     bins->table_[nbins-i-1].b_var = hbSigma->GetBinContent(i);
     bins->table_[nbins-i-1].n_hard_mean = hNhardMean->GetBinContent(i);
     bins->table_[nbins-i-1].n_hard_var = hNhardSigma->GetBinContent(i);
     bins->table_[nbins-i-1].bin_edge = binboundaries[i];

     cout<<i<<" "
	 <<hNpartMean->GetBinContent(i)<<" "
	 <<hNpartSigma->GetBinContent(i)<<" "
	 <<hNcollMean->GetBinContent(i)<<" "
	 <<hNcollSigma->GetBinContent(i)<<" "
	 <<hbMean->GetBinContent(i)<<" "
	 <<hbSigma->GetBinContent(i)<<" "
	 <<binboundaries[i]<<" "
	 <<endl;
  }
  cout<<"-------------------------------------"<<endl;

  // Save the table in output file

  if(onlySaveTable){

     TH1D* hh = (TH1D*)gDirectory->Get("hNpart_0");
     hh->Delete();
     hh = (TH1D*)gDirectory->Get("hNcoll_0");
     hh->Delete();
     hh = (TH1D*)gDirectory->Get("hNhard_0");
     hh->Delete();
     hh = (TH1D*)gDirectory->Get("hb_0");
     hh->Delete();

     hNpart->Delete();
     hNpartMean->Delete();
     hNpartSigma->Delete();
     hNcoll->Delete();
     hNcollMean->Delete();
     hNcollSigma->Delete();
     hNhard->Delete();
     hNhardMean->Delete();
     hNhardSigma->Delete();
     hb->Delete();
     hbMean->Delete();
     hbSigma->Delete();
  }
  
  for(int i = 0; i < runnums.size(); ++i){
     CentralityBins* binsForRun = (CentralityBins*) bins->Clone();
     binsForRun->SetName(Form("run%d",runnums[i]));
     binsForRun->Write();
  }
  
  bins->Delete();
  outFile->Write();
  
}
コード例 #3
0
HardRecoil_Manager::HardRecoil_Manager(const char* parameter_filename) {

  PParameterReader parm(parameter_filename);
  std::cout << "HardRecoil_Manager Initialization" << std::endl;

  ptnbins = parm.GetInt("HardRecoil_pTbins");
  ptbins = parm.GetVDouble("HardRecoil_pTbins_edges");
  zbsetmodel = parm.GetBool("HardRecoil_zbsetmodel", kFALSE);
  run3bool = parm.GetBool("Run3");
  run4bool = parm.GetBool("Run4");

 if (run3bool == run4bool && zbsetmodel) {
    std::cout << "ERROR:  HardRecoil_Manager can only process Run3 or Run4 at a time.  Set only one of the Run3 and Run4 parameters at top of parameters file to true." << std::endl;
    exit(0);
  }

  if(zbsetmodel){
    ptnbinsset = parm.GetInt("HardRecoil_pTbinsSET");
    ptbinsset = parm.GetVDouble("HardRecoil_pTbinsSET_edges");
    luminbins = parm.GetInt("HardRecoil_lumibins");
    lumibins = parm.GetVDouble("HardRecoil_lumibins_edges");
    dphinbins = parm.GetInt("HardRecoil_dphibins");
    dphibins = parm.GetVDouble("HardRecoil_dphibins_edges");

    zphirespnbins = parm.GetInt("HardRecoil_zphirespbins");
    zphirespbins = parm.GetVDouble("HardRecoil_zphirespbins_edges");
    if(run3bool){
      zphirespA = parm.GetVDouble("HardRecoil_zphiresp_ParameterA");
      zphirespB = parm.GetVDouble("HardRecoil_zphiresp_ParameterB");
      zphirespC = parm.GetVDouble("HardRecoil_zphiresp_ParameterC");
      zphirespD = parm.GetVDouble("HardRecoil_zphiresp_ParameterD");
      zphirespMean = parm.GetVDouble("HardRecoil_zphiresp_Mean");
    }else{
      zphirespA = parm.GetVDouble("HardRecoil_zphiresp_ParameterA_run4");
      zphirespB = parm.GetVDouble("HardRecoil_zphiresp_ParameterB_run4");
      zphirespC = parm.GetVDouble("HardRecoil_zphiresp_ParameterC_run4");
      zphirespD = parm.GetVDouble("HardRecoil_zphiresp_ParameterD_run4");
      zphirespMean = parm.GetVDouble("HardRecoil_zphiresp_Mean_run4");
    }
  }else{
    ptnbinsset = ptnbins;
    ptbinsset = ptbins;
  }

  flipped = false;

  if(parm.GetInt("EtFlowFudge")==8){//so don't grab file for old versions of etflow, like option 3
    TString etflow_fname(parm.GetChar("EtFlowFile"));
    TFile* etflow_binned_file = new TFile(etflow_fname);
    etflow_binned3 = (TH1D*) etflow_binned_file->Get("etflow_run2b3");
    etflow_binned4 = (TH1D*) etflow_binned_file->Get("etflow_run2b4");
    etflow_binned3->SetDirectory(0);
    etflow_binned4->SetDirectory(0);
    etflow_binned_file->Close();
  }


  // hard recoil library file
  if (getenv("HRLibraryRootPath") == NULL ) {
    std::cout << "ERROR:  HRLibraryRootPath is not defined" << std::endl;
    exit(0);
  }
 
  TString hrLibraryRootPath(getenv("HRLibraryRootPath"));
  TString model_filename = "";
  if(run3bool) model_filename = hrLibraryRootPath + '/' + parm.GetChar("HardRecoil_FileName"); 
  else{
    if (zbsetmodel) model_filename = hrLibraryRootPath + '/' + parm.GetChar("HardRecoil_FileName_run4"); 
    else model_filename = hrLibraryRootPath + '/' + parm.GetChar("HardRecoil_FileName"); //backwards compatibility
  }
  std::cout << model_filename << " will be used for hard recoil model" << std::endl;
  TFile* tf = new TFile(model_filename);
    
  for (Int_t j=0; j<ptnbins; j++) {
    
    if(! zbsetmodel){
      TH2D* HRHist = (TH2D*) tf->Get(TString::Format("recoil_resp_hist_bin_%d", j));
      resp_pdf.push_back(new TH2rclsa(*HRHist));
      HRHist->Delete();
      resp_pdf[j]->SetDirectory(0);
      resp_pdf[j]->ComputeYIntegral();
      resp_pdf[j]->ComputeIntegral();  
     
    }else{ //we will assign histograms below to be resp_pdf and resp_zbset_pdf later in the code
      //dphi model is in true phi bins, other two in true zpt bins (and others)
     
      if(luminbins !=7 || dphinbins !=6) {
	std::cout<<"settings for number of lumi or dphi bins is not correct.  HardRecoil_Manager code must be altered for other binning."<<std::endl;
	exit(0);
      }

      TH2D* HRHist0 = (TH2D*) tf->Get(TString::Format("recoil_resp_hist_truephi0_bin_%d", j)); //0th
      resp_pdf0.push_back(new TH2rclsa(*HRHist0));
      HRHist0->Delete();
      resp_pdf0[j]->SetDirectory(0);
      
      TH2D* HRHist1 = (TH2D*) tf->Get(TString::Format("recoil_resp_hist_truephi1_bin_%d", j));
      resp_pdf1.push_back(new TH2rclsa(*HRHist1));
      HRHist1->Delete();
      resp_pdf1[j]->SetDirectory(0);
      
      TH2D* HRHist2 = (TH2D*) tf->Get(TString::Format("recoil_resp_hist_truephi2_bin_%d", j));
      resp_pdf2.push_back(new TH2rclsa(*HRHist2));
      HRHist2->Delete();
      resp_pdf2[j]->SetDirectory(0);
       
      TH2D* HRHist3 = (TH2D*) tf->Get(TString::Format("recoil_resp_hist_truephi3_bin_%d", j));
      resp_pdf3.push_back(new TH2rclsa(*HRHist3));
      HRHist3->Delete();
      resp_pdf3[j]->SetDirectory(0);
 
      TH2D* HRHist4 = (TH2D*) tf->Get(TString::Format("recoil_resp_hist_truephi4_bin_%d", j));
      resp_pdf4.push_back(new TH2rclsa(*HRHist4));
      HRHist4->Delete();
      resp_pdf4[j]->SetDirectory(0);
        
      TH2D* HRHist5 = (TH2D*) tf->Get(TString::Format("recoil_resp_hist_truephi5_bin_%d", j));
      resp_pdf5.push_back(new TH2rclsa(*HRHist5));
      HRHist5->Delete();
      resp_pdf5[j]->SetDirectory(0);
        
      TH2D* HRZBHist0 = (TH2D*) tf->Get(TString::Format("recoil_resp_zbset_hist_lumibin0_bin_%d", j));
      resp_zbset_pdf0.push_back(new TH2rclsa(*HRZBHist0));
      HRZBHist0->Delete();
      resp_zbset_pdf0[j]->SetDirectory(0);
            
      TH2D* HRZBHist1 = (TH2D*) tf->Get(TString::Format("recoil_resp_zbset_hist_lumibin1_bin_%d", j));
      resp_zbset_pdf1.push_back(new TH2rclsa(*HRZBHist1));
      HRZBHist1->Delete();
      resp_zbset_pdf1[j]->SetDirectory(0);
     
      TH2D* HRZBHist2 = (TH2D*) tf->Get(TString::Format("recoil_resp_zbset_hist_lumibin2_bin_%d", j));
      resp_zbset_pdf2.push_back(new TH2rclsa(*HRZBHist2));
      HRZBHist2->Delete();
      resp_zbset_pdf2[j]->SetDirectory(0);
        
      TH2D* HRZBHist3 = (TH2D*) tf->Get(TString::Format("recoil_resp_zbset_hist_lumibin3_bin_%d", j));
      resp_zbset_pdf3.push_back(new TH2rclsa(*HRZBHist3));
      HRZBHist3->Delete();
      resp_zbset_pdf3[j]->SetDirectory(0);
      
      TH2D* HRZBHist4 = (TH2D*) tf->Get(TString::Format("recoil_resp_zbset_hist_lumibin4_bin_%d", j));
      resp_zbset_pdf4.push_back(new TH2rclsa(*HRZBHist4));
      HRZBHist4->Delete();
      resp_zbset_pdf4[j]->SetDirectory(0);
      
      TH2D* HRZBHist5 = (TH2D*) tf->Get(TString::Format("recoil_resp_zbset_hist_lumibin5_bin_%d", j));
      resp_zbset_pdf5.push_back(new TH2rclsa(*HRZBHist5));
      HRZBHist5->Delete();
      resp_zbset_pdf5[j]->SetDirectory(0);

      TH2D* HRZBHist6 = (TH2D*) tf->Get(TString::Format("recoil_resp_zbset_hist_lumibin6_bin_%d", j));
      resp_zbset_pdf6.push_back(new TH2rclsa(*HRZBHist6));
      HRZBHist6->Delete();
      resp_zbset_pdf6[j]->SetDirectory(0);
    }//IF ZBSET MODEL
  }//PTBINS
  
  for (Int_t j=0; j<ptnbinsset; j++) {
    TH2D* SETHist = (TH2D*) tf->Get(TString::Format("set_ut_hist_bin_%d", j));
    set_ut_pdf.push_back(new TH2rclsa(*SETHist));
    SETHist->Delete();
    set_ut_pdf[j]->SetDirectory(0);
  }//PTBINS FOR SET
  
  if(!zbsetmodel){
    TH2D* PhiHist = (TH2D*) tf->Get("phi_hist");     
    phi_pdf = new TH2rclsa(*PhiHist);
    phi_pdf->SetDirectory(0);
    phi_pdf->ComputeYMaximum();
  }
  
  
  tf->Close();
  
  std::cout << "HardRecoil_Manager initialization: DONE" << std::endl;
  
}