#include "EnergyRescaler.h" #include #include #include #include #include #include #include #include using namespace std; namespace eg2011 { ///default constructor EnergyRescaler::EnergyRescaler() { //default seed SetRandomSeed(); } //destructor EnergyRescaler::~EnergyRescaler() { } void EnergyRescaler::SetRandomSeed( unsigned seed){ m_random3.SetSeed(seed); } bool EnergyRescaler::readCalibConstants(std::string fname) { if( corrVec.size()) { std::cout<<" WARNING having already "<>eta>>etaErr>>phi>> phiErr>>alpha>>err; if( !infile.good() ) break; myMap.eta= eta; myMap.etaBinSize =etaErr; myMap.phi = phi; myMap.phiBinSize = phiErr; myMap.alpha = alpha; myMap.alphaErr = err; corrVec.push_back(myMap); } return true; } double EnergyRescaler::applyEnergyCorrectionGeV(double eta, double phi, double energy, double et, int value, std::string ptype) const { double corrEnergy=-999.0; if(corrVec.size()==0) { std::cout<<"NO CORRECTIONS EXISTS, PLEASE EITHER SUPPLY A CORRECTION FILE OR USE THE DEFAULT CORRECTIONS"<=( corrVec.at(i).eta - corrVec.at(i).etaBinSize/2.) && eta< ( corrVec.at(i).eta+corrVec.at(i).etaBinSize/2.) && phi>=( corrVec.at(i).phi - corrVec.at(i).phiBinSize/2.) && phi< ( corrVec.at(i).phi+corrVec.at(i).phiBinSize/2.) ) { for(std::string::iterator p = ptype.begin(); ptype.end() != p; ++p) *p = toupper(*p); double er_up=-99,er_do=0; double scale=0.; switch (value) { default: { scale=corrVec.at(i).alpha; break; } case NOMINAL: { scale=corrVec.at(i).alpha; break; } case ERR_UP: { scale=corrVec.at(i).alpha; getErrorGeV(eta,et, er_up, er_do, ptype); scale+=er_do; break; } case ERR_DOWN: { scale=corrVec.at(i).alpha; getErrorGeV(eta,et, er_up, er_do, ptype); scale+=er_up; break; } } corrEnergy = energy/(1.+ scale); // std::cout<<" eta : "<boundaries[i] && fabs(eta)Gaus(0,sigma); double DeltaE0 = m_random3.Gaus(0,sigma); double cor0=(energy+DeltaE0)/energy; return cor0; } void EnergyRescaler::getErrorGeV(double cl_eta,double cl_et, double &er_up, double &er_do, std::string ptype,bool withXMAT,bool withPS) const { // Quick and dirty // Need to optimized er_up=-1; er_do=-1; static const int nbins=8; static double boundaries[nbins+1]={0,0.6,1.00,1.37,1.52,1.8,2.47,3.2,4.9}; //systematics static double stat[nbins] ={0.0010, 0.0020, 0.0020, 777, 0.0020, 0.0020, 0.005, 0.01}; static double sys_mcclosure[nbins] ={0.0010, 0.0010, 0.0010, 777, 0.0010, 0.0010, 0.002, 0.002}; static double sys_comparison[nbins] ={0.0010, 0.0010, 0.0010, 777, 0.0010, 0.0010, 0.01, 0.008}; static double sys_pileup[nbins] ={0.0010, 0.0010, 0.0010, 777, 0.0010, 0.0010, 0.001, 0.001}; //check forward? static double sys_medium2tight_up[nbins]={0.0010, 0.0010, 0.0010, 777, 0.0020, 0.0020, 0,0}; static double sys_loose2tight_forward[nbins] ={0.0000, 0.0000, 0.0000, 777, 0.0000, 0.0000, 0.012, 0.01}; static double sys_masscut[nbins] ={0.0010, 0.0010, 0.0010, 777, 0.0020, 0.0020, 0.002, 0.006}; static double sys_elecLin[nbins] ={0.0010, 0.0010, 0.0010, 777, 0.0010, 0.0010, 0.001, 0.001};//forward? static double sys_xtalkE1[nbins] ={0.0010, 0.0010, 0.0010, 777, 0.0010, 0.0010, 0.001, 0.001};//forward? static double sys_lowpt [nbins] ={0.0100, 0.0100, 0.0100, 777, 0.0100, 0.0100, 0.01, 0.01}; static double sys_HV [nbins] ={0.0000, 0.0000, 0.0000, 777, 0.0000, 0.0000, 0.006, 0.008}; static double PS_B[nbins]={-0.00025312, -0.0011569, -0.00211677, 777, -0.00175762*2, 000, 000, 000}; // static double PS_A[nbins]={ 0.00187341, 0.00840421, 0.016034 , 777, 0.0127718*2, 000, 000, 000}; //Material electron static double elec_XMAT_a[nbins] = {-0.0083, -0.013, -0.025, 777, -0.023, -0.019, -0.042, -0.014 }; static double elec_XMAT_b[nbins] = {-0.055, -0.019, -0.014, 777, -0.026, -0.019, -0.041, -0.016}; static double elec_XMAT_MAX[nbins]={ 0.003, 0.008, 0.015, 777, 0.010, 0.01 ,0.01, 0.01}; //Material photon static double pho_XMAT_MAX[nbins]={ 0.003, 0.005, 0.010, 777, 0.010, 0.01 ,0, 0.} ; static double pho_PS_shift[nbins] ={ 0.001, 0.002, 0.003, 777, 0.002*2, 0.000 ,0, 0.} ; int bin =-1; for(int i=0;i=boundaries[i] && fabs(cl_eta)=0) { PS_up=PS; PS_do=-PS; } else { PS_up=-PS; PS_do=PS; } } } //================================== //material //================================== double XMat_up = 0; double XMat_do = 0; if(withXMAT==true) { if(ptype=="ELECTRON") { double xmat= 0; // cout<0) { XMat_up=xmat; } else XMat_do=xmat; // if(XMat_up>elec_XMAT_MAX[bin]) // XMat_up=elec_XMAT_MAX[bin]; } else if(ptype=="UNCONVERTED_PHOTON" || ptype =="CONVERTED_PHOTON") //else if(ptype=="PHOTON") { XMat_up=pho_XMAT_MAX[bin]; XMat_do=0; // cout<