--- UserCode/kiesel/TreeWriter/treeWriter.cc 2013/04/24 13:24:30 1.22 +++ UserCode/kiesel/TreeWriter/treeWriter.cc 2013/04/25 18:17:04 1.27 @@ -70,10 +70,17 @@ std::vector* getVectorFromMap( map return vec; } +float deltaPhi( float phi1, float phi2) { + float result = phi1 - phi2; + while (result > M_PI) result -= 2*M_PI; + while (result <= -M_PI) result += 2*M_PI; + return result; +} + // useful functions float deltaR( const TLorentzVector& v1, const TLorentzVector& v2 ) { // deltaR = sqrt ( deltaEta^2 + deltaPhi^2 ) - return sqrt(pow(v1.Eta() - v2.Eta(), 2) + pow(v1.Phi() - v2.Phi(), 2) ); + return sqrt(pow(v1.Eta() - v2.Eta(), 2) + pow(deltaPhi(v1.Phi(),v2.Phi()), 2) ); } float effectiveAreaElectron( float eta ) { @@ -302,7 +309,6 @@ void TreeWriter::Loop() { bool loose_photon_barrel = thisphoton.pt>20 && it->isEB() - && it->passelectronveto && it->hadTowOverEm<0.05 && it->sigmaIetaIeta<0.012 && thisphoton.chargedIso<2.6 @@ -310,7 +316,6 @@ void TreeWriter::Loop() { && thisphoton.photonIso<1.3+0.005*thisphoton.pt; bool loose_photon_endcap = thisphoton.pt > 20 && it->isEE() - && it->passelectronveto && it->hadTowOverEm<0.05 && it->sigmaIetaIeta<0.034 && thisphoton.chargedIso<2.3 @@ -472,18 +477,19 @@ void TreeWriter::Loop() { tree::Particle thisGenParticle; for( std::vector::iterator it = event->genParticles.begin(); it != event->genParticles.end(); ++it ) { - if( it->status == 3 ) { // hard interaction - switch( std::abs(it->pdgId) ) { - thisGenParticle.pt = it->momentum.Pt(); - thisGenParticle.eta = it->momentum.Eta(); - thisGenParticle.phi = it->momentum.Phi(); - case 22: // photon - if( thisGenParticle.pt > 75 ) - genPhoton.push_back( thisGenParticle ); - case 11: // electron - if( thisGenParticle.pt > 20 ) // pt cut is lower to estimate fake rate in all pt bins - genElectron.push_back( thisGenParticle ); - } + if( it->momentum.Pt() < 20 ) continue; + thisGenParticle.pt = it->momentum.Pt(); + thisGenParticle.eta = it->momentum.Eta(); + thisGenParticle.phi = it->momentum.Phi(); + switch( std::abs(it->pdgId) ) { + case 22: // photon + genPhoton.push_back( thisGenParticle ); + break; + case 11: // electron + // Demand a W boson as mother particle of electron + if( abs(event->genParticles[it->motherIndex].pdgId) == 24 ) + genElectron.push_back( thisGenParticle ); + break; } }