#include <ElectronSmearer.h>
Inheritance diagram for Atlfast::ElectronSmearer:
Public Member Functions | |
ElectronSmearer (const int aseed, const int lumi, MsgStream &log) | |
virtual | ~ElectronSmearer () |
virtual HepLorentzVector | smear (const HepMC::GenParticle &) |
virtual HepLorentzVector | smear (const HepLorentzVector &avec) |
virtual int | setSmearParameters (const std::vector< double > &smearValues) |
virtual int | setSmearParamSchema (const int smearSchema) |
Private Member Functions | |
RandGauss * | randGauss () |
RandFlat * | randFlat () |
Private Attributes | |
int | m_lumi |
std::vector< double > | m_smearParams |
int | m_smearParamSchema |
MsgStream & | m_log |
Privately inherits from the DefaultSmearer class to use its implementation of random number services etc. ElectronSmearer can run with TDR parameterisation (m_smearParamSchema==1) or with CSC parameterisation (m_smearParamSchema==2)
Definition at line 40 of file ElectronSmearer.h.
Atlfast::ElectronSmearer::ElectronSmearer | ( | const int | aseed, | |
const int | lumi, | |||
MsgStream & | log | |||
) | [inline] |
Constructor taking a random number seed and luminosity
Definition at line 48 of file ElectronSmearer.h.
00048 : 00049 ISmearer(), DefaultSmearer(aseed), m_lumi(lumi), m_log(log){}
virtual Atlfast::ElectronSmearer::~ElectronSmearer | ( | ) | [inline, virtual] |
HepLorentzVector Atlfast::ElectronSmearer::smear | ( | const HepMC::GenParticle & | ) | [virtual] |
Smear method for HepMC::GenParticle
Reimplemented from Atlfast::DefaultSmearer.
Definition at line 25 of file ElectronSmearer.cxx.
00025 { 00026 return smear(particle.momentum()); 00027 }
HepLorentzVector Atlfast::ElectronSmearer::smear | ( | const HepLorentzVector & | avec | ) | [virtual] |
Smear method for HepLorentzVector
Reimplemented from Atlfast::DefaultSmearer.
Definition at line 29 of file ElectronSmearer.cxx.
00029 { 00030 00031 double rpilup = 0.0; 00032 double aa, bb, sigph1, sigph, sigpu; 00033 //Make sure momentum, aenergy units are Gev 00034 double ene = avec.e()/GeV ; 00035 double sqrtene = sqrt(ene); 00036 double pt = avec.perp()/GeV ; 00037 double vEta = fabs(avec.pseudoRapidity()); 00038 HepLorentzVector bvec(0,0,0,0); 00039 00040 if(m_smearParamSchema==1){ // TDR-style smearing 00041 00042 // do the smearing, copied verbatim (except for ROOT dependencies) 00043 // from electronmaker codein Atlfast++ 00044 // 00045 // This code has not otherwise been altered which is why it is all very 00046 // procedural 00047 // 00048 // Parametrisation was by L.Poggioli 00049 00050 while (1) { 00051 aa=randGauss()->fire(); 00052 //bb=randGauss()->fire(); 00053 sigph1 = aa*m_smearParams[0]/sqrtene; 00054 if (1.0 + sigph1 <= 0.0) continue; 00055 sigph = sigph1; 00056 if (vEta < 1.4) { 00057 while (1) { 00058 aa=randGauss()->fire(); 00059 bb=randGauss()->fire(); 00060 sigph1 = aa*m_smearParams[1]/pt + bb*m_smearParams[2]; 00061 if (1.0+sigph1 > 0) break; 00062 } 00063 } else { 00064 while (1) { 00065 aa=randGauss()->fire(); 00066 bb=randGauss()->fire(); 00067 sigph1 = aa*m_smearParams[3]*((m_smearParams[4]-vEta)+m_smearParams[5])/ene + bb*m_smearParams[6]; 00068 // sigph1 = aa*0.306*((2.4-vEta)+0.228)/ene + bb*0.007; 00069 if (1.0+sigph1 > 0) break; 00070 } 00071 } 00072 sigph += sigph1; 00073 if (m_lumi == 2) { 00074 if (vEta < 0.6) rpilup = 0.32; 00075 if (vEta > 0.6 && vEta < 1.4) rpilup = 0.295; 00076 if (vEta > 1.4) rpilup = 0.27; 00077 while (1) { 00078 aa=randGauss()->fire(); 00079 //bb=randGauss()->fire(); 00080 sigpu = aa*rpilup/pt; 00081 if (1.0+sigpu > 0) break; 00082 } 00083 sigph += sigpu; 00084 } 00085 if (1.0 + sigph > 0) break; 00086 } 00087 00088 //now sigph is the electron "sigma" and we do the following a la Atlfast++ electron maker: 00089 bvec.set(avec.px()*(1.0+sigph), avec.py()*(1.0+sigph), avec.pz()*(1.0+sigph), avec.e() *(1.0+sigph)); 00090 00091 } else if (m_smearParamSchema==2){ // Smearing based on CSC sample tuning 00092 00093 double vE = avec.e(); 00094 00095 double vLimEta=EtaElectron[NbEtaElectron-1]+(EtaElectron[NbEtaElectron-1]-EtaElectron[NbEtaElectron-2])*0.5; 00096 00097 if( vEta>vLimEta ) 00098 { 00099 m_log<<MSG::DEBUG<<"No calibration : "<<vEta<<endreq; 00100 return avec; 00101 } 00102 00103 int iEnergy=0; 00104 m_log<<MSG::DEBUG<<vE<<" > "<<vEnergiesElectron[iEnergy]<<" "; 00105 while(iEnergy<NbEnergiesElectron&&vE>vEnergiesElectron[iEnergy]*1000) 00106 { 00107 m_log<<MSG::DEBUG<<vEnergiesElectron[iEnergy]<<" "; 00108 iEnergy++; 00109 } 00110 m_log<<MSG::DEBUG<<endreq; 00111 if(iEnergy==0)iEnergy++; 00112 double ratioEnergy=(vE*0.001-vEnergiesElectron[iEnergy-1])/(vEnergiesElectron[iEnergy]-vEnergiesElectron[iEnergy-1]); 00113 00114 int iEta=0; 00115 m_log<<MSG::DEBUG<<vEta<<" > "<<EtaElectron[iEta]<<" "; 00116 while(iEta<NbEtaElectron&&vEta>EtaElectron[iEta]) 00117 { 00118 m_log<<MSG::DEBUG<<EtaElectron[iEta]<<" "; 00119 iEta++; 00120 } 00121 m_log<<MSG::DEBUG<<endreq; 00122 00123 if(iEta==0)iEta++; 00124 double ratioEta=(vEta-EtaElectron[iEta-1])/(EtaElectron[iEta]-EtaElectron[iEta-1]); 00125 00126 int iPos; 00127 double sigma,sigma1,sigma2; 00128 00129 iPos=iEnergy-1; 00130 sigma1=CorrFactorElectronSigma[iPos][iEta-1]+ratioEta*(CorrFactorElectronSigma[iPos][iEta]-CorrFactorElectronSigma[iPos][iEta-1]); 00131 iPos=iEnergy; 00132 sigma2=CorrFactorElectronSigma[iPos][iEta-1]+ratioEta*(CorrFactorElectronSigma[iPos][iEta]-CorrFactorElectronSigma[iPos][iEta-1]); 00133 00134 sigma=sigma1+ratioEnergy*(sigma2-sigma1); 00135 00136 m_log<<MSG::DEBUG<<" -> interpolation sigma "<<sigma1<<" "<<sigma2<<" "<<sigma<<endreq; 00137 00138 double alpha=1.0; 00139 double vrandom=alpha; 00140 00141 int iCmpt=int(randFlat()->fire()*20); 00142 for(int i=0; i<iCmpt; i++) 00143 vrandom=randGauss()->fire(1.0,sigma); 00144 00145 m_log<<MSG::DEBUG<<" -> Energie : "<<vEnergiesElectron[iEnergy]<<" Eta : "<<vEnergiesElectron[iEnergy-1]<<" < "<<vE<<" < "<<vEnergiesElectron[iEnergy]<<endreq; 00146 m_log<<MSG::DEBUG<<" -> Energie : "<<vEnergiesElectron[iEnergy]<<" Eta : "<<EtaElectron[iEta-1]<<" < "<<vEta<<" < "<<EtaElectron[iEta]<<endreq; 00147 m_log<<MSG::DEBUG<<" calib mean-sigma "<<alpha<<" "<<sigma<<" -> "<<vrandom<<endreq; 00148 00149 bvec.set(avec.px()*vrandom, avec.py()*vrandom, avec.pz()*vrandom, vE*vrandom); 00150 00151 m_log<<MSG::DEBUG<<"-> HepLorentzVector calibration "<<vEta<<" "<<avec<<" -> "<<bvec<<endreq; 00152 00153 } 00154 00155 return bvec; 00156 } //end of smear method
int Atlfast::ElectronSmearer::setSmearParameters | ( | const std::vector< double > & | smearValues | ) | [virtual] |
Sets the smearing parameters
Reimplemented from Atlfast::DefaultSmearer.
Definition at line 159 of file ElectronSmearer.cxx.
00159 { 00160 m_smearParams=smearValues; 00161 return 0; 00162 }
int Atlfast::ElectronSmearer::setSmearParamSchema | ( | const int | smearSchema | ) | [virtual] |
Sets the smearing schema
Reimplemented from Atlfast::DefaultSmearer.
Definition at line 165 of file ElectronSmearer.cxx.
00165 { 00166 m_smearParamSchema=smearSchema; 00167 return 0; 00168 }
RandGauss* Atlfast::DefaultSmearer::randGauss | ( | ) | [inline, inherited] |
Hook for subclasses etc. to get their hands on a randGauss object
Definition at line 65 of file DefaultSmearer.h.
00065 { return m_randGauss;}
RandFlat* Atlfast::DefaultSmearer::randFlat | ( | ) | [inline, inherited] |
Hook for subclasses etc. to get their hands on a randFlat object
Definition at line 71 of file DefaultSmearer.h.
00071 { return m_randFlat;}
int Atlfast::ElectronSmearer::m_lumi [private] |
luminosity option
Definition at line 73 of file ElectronSmearer.h.
std::vector<double> Atlfast::ElectronSmearer::m_smearParams [private] |
Definition at line 75 of file ElectronSmearer.h.
int Atlfast::ElectronSmearer::m_smearParamSchema [private] |
Definition at line 76 of file ElectronSmearer.h.
MsgStream& Atlfast::ElectronSmearer::m_log [private] |
Definition at line 77 of file ElectronSmearer.h.