コード例 #1
0
ファイル: Parameters.cpp プロジェクト: gkasieczka/Code
// matches a jet to the |eta| bin (jet outside acceptance are matched to highest |eta| bin or flagged as 'outside')
int MEM::eta_to_bin( const double& eta, bool mark_acceptance ){
  double ae = std::abs(eta);
  if (ae < 1.0) {
    return 0;
  } else if (ae < 2.5) {
    return 1;
  } else {
    if( mark_acceptance )
      return -1;
    else
      return eta_to_bin( 2.49 );
  }
}
コード例 #2
0
ファイル: rho_script.c プロジェクト: btcarlso/UserCode
double muonEff(double pt,double eta,string sys){

	bool print=0;
	int bin=eta_to_bin(eta); 
	if(bin<0) cout << "eta: " << eta << endl;
	if(bin<0) return 1; 
	
	//string name =Form("gEff_DATA_PT_AETA%d",bin); 
	string name= Form("gEff_nominal_AETA%d",bin);//nominal

	if(print) cout << name << endl; 
	fEffL1L2->cd();
	if(fEffL1L2->IsOpen()!=1 || fEffL3->IsOpen()!=1 || fEff->IsOpen()!=1) {
		cout << "Efficiency File not open. " << endl; 
		return 0; 
	}
		
	TGraph *grL1L2=(TGraph*)fEffL1L2->Get(name.c_str()); 
	TGraph *grL3=(TGraph*)fEffL3->Get(name.c_str()); 
	TGraph *gr=(TGraph*)fEff->Get(name.c_str()); 
	
	//double emu=grL1L2->Eval(pt)*grL3->Eval(pt); 
	double emu=gr->Eval(pt)*0.99/0.97;
	double RV=-9; 
	
	if(sys=="nom") RV=emu; 
	
	if(print) cout << "Pt: " << pt << "effmu: " << emu << endl; 
	

	delete grL1L2;
	delete grL3; 
	delete gr; 
	if(RV<0) cout << "return value <0" << endl; 
	return RV; 
}
コード例 #3
0
ファイル: Parameters.cpp プロジェクト: gkasieczka/Code
/////////////////////////////////
//   y    := observables
//   x    := gen level quantities
//   type := decides the TF
/////////////////////////////////
double MEM::transfer_function(double* y, double* x, const TFType::TFType& type, int& out_of_range, const double& cutoff, const int& debug){

  // return value
  double w{1.};

  // temporary values;
  double E, H;
  double m1,s1, m2, s2, f, rho, c1, c2;

  // parameters
  const double* par;

  switch( type ){
    
  case TFType::bReco:
    // x[0] = parton energy ; 
    // x[1] = parton eta;
    // y[0] = jet energy;
    E  = x[0];
    H  = x[1];
    par = TF_B_param[ eta_to_bin(H) ];    

    f  = par[10];
    m1 = par[0] + par[1]*E;
    m2 = par[5] + par[6]*E;
    s1 = E*TMath::Sqrt(par[2]*par[2] + par[3]*par[3]/E + par[4]*par[4]/E/E);
    s2 = E*TMath::Sqrt(par[7]*par[7] + par[8]*par[8]/E + par[9]*par[9]/E/E);
    c1 = Chi2(y[0], m1, s1);
    c2 = Chi2(y[0], m2, s2);
    if( c1>cutoff && c2>cutoff ) ++out_of_range;
    w *= (1./sqrt(2*PI) * (f/s1*TMath::Exp(-0.5*c1) + (1-f)/s2*TMath::Exp(-0.5*c2) ));
#ifdef DEBUG_MODE
    if( debug&DebugVerbosity::integration) 
      cout << "\t\ttransfer_function: Evaluate W(" << y[0] << " | E=" << E << ", y=" << H << ", TFType::bReco) = " << w << endl;
#endif
    break;
    
  case TFType::qReco:
    // x[0] = parton energy ; 
    // x[1] = parton eta;
    // y[0] = jet energy;
    E   = x[0];
    H   = x[1];
    par = TF_Q_param[ eta_to_bin(H) ];
    m1  = par[0] + par[1]*E;
    s1  = E*TMath::Sqrt(par[2]*par[2] + par[3]*par[3]/E + par[4]*par[4]/E/E);
    c1  = Chi2(y[0], m1, s1);
    if( c1>cutoff ) ++out_of_range;

    w *= (1./sqrt(2*PI)/s1*TMath::Exp(-0.5*c1));
#ifdef DEBUG_MODE
    if( debug&DebugVerbosity::integration) 
      cout << "\t\ttransfer_function: Evaluate W(" << y[0] << " | E=" << E << ", y=" << H << ", TFType::qReco) = " << w << endl;
#endif
    break;
    
  case TFType::MET:
    // x[0] = sum nu_x ; x[1] = sum nu_y
    // y[0] = MET_x    ; y[1] = MET_y

    par = TF_MET_param;
    s1  = par[0];
    s2  = par[1];
    rho = par[2];
    c1  = Chi2Corr(y[0]-x[0], y[1]-x[1], s1, s2, rho);

    if( c1/2>cutoff ) ++out_of_range;

    w *= 1./(2*PI)/s1/s2/sqrt(1.-rho*rho)*TMath::Exp( -0.5*c1 );
#ifdef DEBUG_MODE
    if( debug&DebugVerbosity::integration) 
      cout << "\t\ttransfer_function: Evaluate W(" << y[0] << "-" << x[0] << " , " << y[1] << "-" << x[1] << ", TFType::MET) = " << w << endl;
#endif
    break;

  case TFType::Recoil:
    // Sudakov factor
    // x[0] = pT
    // y[0] = rhoT if extra_jets==0, else  par[2]+1GeV 

    par = TF_RECOIL_param;    
    m1 = par[0];
    s1 = par[1];
    if( y[0] < par[2] )
      w *= TMath::Gaus( log(x[0]), m1, s1, 1 );
    else 
      w *= 1.;
#ifdef DEBUG_MODE
    if( debug&DebugVerbosity::integration) 
      cout << "\t\ttransfer_function: Evaluate W( log(" << x[0] << "); TFType::Recoil) = " << w << endl;
#endif
    break;

  case TFType::bLost:
  case TFType::qLost:
    // x[0]     = parton energy ;
    // x[1]     = parton eta;
    // y[0]     = jet energy
    // par: [0]-> eta acceptance, [1]-> pT cut, [2]-> E max, [3]->acceptance (cos*phi)

    if( TMath::Abs(x[1])>TF_ACC_param[0] ){
      w *= 1.;      
#ifdef DEBUG_MODE
      if( debug&DebugVerbosity::integration) 
	cout << "\t\ttransfer_function: Evaluate W(" << x[0] << ", " << x[1] << ", TFType::qLost) = " << w << endl;
#endif
    }
    else{
      // x[0]     = parton energy ; 
      // x[1]     = parton eta
      // y[0]     = 0.
      E   = x[0];
      H   = x[1];
      par = TF_Q_param[ eta_to_bin(H) ];
      double mean_e  = (par[0] + par[1]*E);
      double sigma_e = E*TMath::Sqrt(par[2]*par[2] + par[3]*par[3]/E + par[4]*par[4]/E/E);
      double sign    = (TF_ACC_param[1]*TMath::CosH(H) >= mean_e) ? +1. : -1.;
      c1 = Chi2( TF_ACC_param[1]*TMath::CosH(H), mean_e, sigma_e);
      if( c1>cutoff ) ++out_of_range;

      w *= 0.5*(TMath::Erf( sqrt(c1/2.)*sign ) + 1 ) ;    
#ifdef DEBUG_MODE
      if( debug&DebugVerbosity::integration) 
	cout << "\t\ttransfer_function: Evaluate W(" <<  TF_ACC_param[1] << " | " << E << ", " << H << ", TFType::qLost) = " << w << endl;
#endif
    }
    break;
  case TFType::Unknown:
    w *= 1.;
#ifdef DEBUG_MODE
    if( debug&DebugVerbosity::integration) 
      cout << "\t\ttransfer_function: Evaluate W = 1 " << endl;
#endif
    break;
  default:
    break;
  }

  return w;
}
コード例 #4
0
ファイル: rho_script_MC.c プロジェクト: btcarlso/UserCode
double muonEff(double pt,double eta,string sys){

	bool print=0;
	int bin=eta_to_bin(eta); 
	if(bin<0) cout << "eta: " << eta << endl;
	if(bin<0) return 1; 
	
	string name =Form("gEff_MC_PT_AETA%d",bin); 
	//string name= Form("gEff_nominal_AETA%d",bin);//nominal
	string nameP=Form("gEff_totsys_p_AETA%d",bin);
	string nameM=Form("gEff_totsys_m_AETA%d",bin);
	if(print) cout << name << endl; 
	fEff->cd();
	if(fEff->IsOpen()!=1) {
		cout << "Efficiency File not open. " << endl; 
		return 0; 
	}
	
	//TEfficiency *eff = (TEfficiency*)fEff->FindObjectAny(Form("totEff_MCTRUTH_PT_AETA%d",bin));
	
	TGraph *gr=(TGraph*)fEff->Get(name.c_str()); 
	//TGraph *grP=(TGraph*)fEff->Get(nameP.c_str()); 
	//TGraph *grM=(TGraph*)fEff->Get(nameM.c_str()); 
	
	double SF=-9; //data to MC scale factor
	double SFp=-9; //SF uncertainty 
	double SFm=-9; 
	
	if(bin!=1){
		SF=1.019;
		
	}
	
	if(bin==1){
		SF=1.032; 
		
	}
	
	//SF=0.99;
	//SFp=0.99;
	//SFm=0.99;
	
	double emu=gr->Eval(pt)*0.99; 
	//double emu=eff->GetEfficiency(eff->FindFixBin(pt)); 
	
	//double emuP=grP->Eval(pt)/SFp; // positive systematic 
	//double emuM=grM->Eval(pt)/SFm; // negative systematic 
	
	double RV=-9; 
	
	if(sys=="nom") RV=emu; 
	//if(sys=="minus") RV=emuM; 
	//if(sys=="plus") RV=emuP; 
	
	if(print) cout << "Pt: " << pt << "effmu: " << emu << endl; 
	

	delete gr;
	if(RV<0) cout << "return value <0" << endl; 
	return RV; 
}