ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/kiesel/TreeWriter/treeWriter.cc
(Generate patch)

Comparing UserCode/kiesel/TreeWriter/treeWriter.cc (file contents):
Revision 1.22 by kiesel, Wed Apr 24 13:24:30 2013 UTC vs.
Revision 1.26 by kiesel, Thu Apr 25 17:37:32 2013 UTC

# Line 70 | Line 70 | std::vector<Type>* getVectorFromMap( map
70          return vec;
71   }
72  
73 + float deltaPhi( float phi1, float phi2) {
74 +        float result = phi1 - phi2;
75 +        while (result > M_PI) result -= 2*M_PI;
76 +        while (result <= -M_PI) result += 2*M_PI;
77 +        return result;
78 + }
79 +
80   // useful functions
81   float deltaR( const TLorentzVector& v1, const TLorentzVector& v2 ) {
82          // deltaR  = sqrt ( deltaEta^2 + deltaPhi^2 )
83 <        return sqrt(pow(v1.Eta() - v2.Eta(), 2) + pow(v1.Phi() - v2.Phi(), 2) );
83 >        return sqrt(pow(v1.Eta() - v2.Eta(), 2) + pow(deltaPhi(v1.Phi(),v2.Phi()), 2) );
84   }
85  
86   float effectiveAreaElectron( float eta ) {
# Line 472 | Line 479 | void TreeWriter::Loop() {
479  
480                  tree::Particle thisGenParticle;
481                  for( std::vector<susy::Particle>::iterator it = event->genParticles.begin(); it != event->genParticles.end(); ++it ) {
482 <                        if( it->status == 3 ) { // hard interaction
483 <                                switch( std::abs(it->pdgId) ) {
484 <                                        thisGenParticle.pt = it->momentum.Pt();
485 <                                        thisGenParticle.eta = it->momentum.Eta();
486 <                                        thisGenParticle.phi = it->momentum.Phi();
487 <                                        case 22: // photon
488 <                                                if( thisGenParticle.pt > 75 )
489 <                                                        genPhoton.push_back( thisGenParticle );
490 <                                        case 11: // electron
491 <                                                if( thisGenParticle.pt > 20 ) // pt cut is lower to estimate fake rate in all pt bins
492 <                                                        genElectron.push_back( thisGenParticle );
493 <                                }
482 >                        if( it->momentum.Pt() < 20 ) continue;
483 >                        thisGenParticle.pt = it->momentum.Pt();
484 >                        thisGenParticle.eta = it->momentum.Eta();
485 >                        thisGenParticle.phi = it->momentum.Phi();
486 >                        switch( std::abs(it->pdgId) ) {
487 >                                case 22: // photon
488 >                                        genPhoton.push_back( thisGenParticle );
489 >                                        break;
490 >                                case 11: // electron
491 >                                        // Demand a W boson as mother particle of electron
492 >                                        if( abs(event->genParticles[it->motherIndex].pdgId) == 24 )
493 >                                                genElectron.push_back( thisGenParticle );
494 >                                        break;
495                          }
496                  }
497  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines