CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/FastSimulation/Event/src/KineParticleFilter.cc

Go to the documentation of this file.
00001 #include "FastSimulation/Event/interface/KineParticleFilter.h"
00002 
00003 //Framework Headers
00004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00005 
00006 #include <vector>
00007 #include <iterator>
00008 
00009 KineParticleFilter::KineParticleFilter(const edm::ParameterSet& kine) 
00010   : BaseRawParticleFilter() 
00011 {
00012 
00013   // Set the kinematic cuts
00014   // Upper abs(eta) bound
00015   etaMax = kine.getParameter<double>("etaMax"); 
00016   // Lower pT  bound (charged, in GeV/c)
00017   pTMin  = kine.getParameter<double>("pTMin");
00018   // Lower E  bound - reject (all, in GeV)
00019   EMin   = kine.getParameter<double>("EMin");
00020   // Lower E  bound - accept (all, in GeV)
00021   EMax   = kine.getParameter<double>("EProton");
00022 
00023   // pdg codes of the particles to be removed from the events
00024   // ParameterSet cannot handle sets, only vectors
00025   std::vector<int> tmpcodes 
00026     = kine.getUntrackedParameter< std::vector<int> >
00027     ("forbiddenPdgCodes", std::vector<int>() );
00028   
00029   std::copy(tmpcodes.begin(), 
00030             tmpcodes.end(),  
00031             std::insert_iterator< std::set<int> >(forbiddenPdgCodes,
00032                                                   forbiddenPdgCodes.begin() ));
00033   
00034   if( !forbiddenPdgCodes.empty() ) {
00035     std::cout<<"KineParticleFilter : Forbidden PDG codes : ";
00036     copy(forbiddenPdgCodes.begin(), forbiddenPdgCodes.end(), 
00037          std::ostream_iterator<int>(std::cout, " "));
00038   }  
00039 
00040   // Change eta cuts to cos**2(theta) cuts (less CPU consuming)
00041   if ( etaMax > 20. ) etaMax = 20.; // Protection against paranoid people.
00042   double cosMax = (std::exp(2.*etaMax)-1.) / (std::exp(2.*etaMax)+1.);
00043   cos2Max = cosMax*cosMax;
00044 
00045   double etaPreshMin = 1.479;
00046   double etaPreshMax = 1.594;
00047   double cosPreshMin = (std::exp(2.*etaPreshMin)-1.) / (std::exp(2.*etaPreshMin)+1.);
00048   double cosPreshMax = (std::exp(2.*etaPreshMax)-1.) / (std::exp(2.*etaPreshMax)+1.);
00049   cos2PreshMin = cosPreshMin*cosPreshMin;
00050   cos2PreshMax = cosPreshMax*cosPreshMax;
00051 
00052   // Change pt cut to pt**2 cut (less CPU consuming)
00053   pTMin *= pTMin;
00054 
00055 }
00056 
00057 bool KineParticleFilter::isOKForMe(const RawParticle* p) const
00058 {
00059 
00060   // Do not consider quarks, gluons, Z, W, strings, diquarks
00061   // ... and supesymmetric particles
00062   int pId = abs(p->pid());
00063 
00064   // Vertices are coming with pId = 0
00065   if ( pId != 0 ) { 
00066     bool particleCut = ( pId > 10  && pId != 12 && pId != 14 && 
00067                          pId != 16 && pId != 18 && pId != 21 &&
00068                          (pId < 23 || pId > 40  ) &&
00069                          (pId < 81 || pId > 100 ) && pId != 2101 &&
00070                          pId != 3101 && pId != 3201 && pId != 1103 &&
00071                          pId != 2103 && pId != 2203 && pId != 3103 &&
00072                          pId != 3203 && pId != 3303 );
00073     //    particleCut = particleCut || pId == 0;
00074 
00075 
00076     if ( !particleCut ) return false;
00077 
00078     // Keep protons with energy in excess of 5 TeV
00079     bool protonTaggers =  (pId == 2212 && p->E() >= EMax) ;
00080     if ( protonTaggers ) return true;
00081 
00082     std::set<int>::iterator is = forbiddenPdgCodes.find(pId);
00083     if( is != forbiddenPdgCodes.end() ) return false;
00084 
00085   //  bool kineCut = pId == 0;
00086   // Cut on kinematic properties
00087     // Cut on the energy of all particles
00088     bool eneCut = p->E() >= EMin;
00089     if (!eneCut) return false;
00090 
00091     // Cut on the transverse momentum of charged particles
00092     bool pTCut = p->charge()==0 || p->Perp2()>=pTMin;
00093     if (!pTCut) return false;
00094 
00095     // Cut on eta if the origin vertex is close to the beam
00096     //    bool etaCut = (p->vertex()-mainVertex).perp()>5. || fabs(p->eta())<=etaMax;
00097     bool etaCut = (p->vertex()-mainVertex).Perp2()>25. || p->cos2Theta()<= cos2Max;
00098 
00099     /*
00100     if ( etaCut != etaCut2 ) 
00101       cout << "WANRNING ! etaCut != etaCut2 " 
00102            << etaCut << " " 
00103            << etaCut2 << " "
00104            << (p->eta()) << " " << etaMax << " " 
00105            << p->vect().cos2Theta() << " " << cos2Max << endl; 
00106     */
00107     if (!etaCut) return false;
00108 
00109     // Cut on the origin vertex position (prior to the ECAL for all 
00110     // particles, except for muons  ! Just modified: Muons included as well !
00111     double radius2 = p->R2();
00112     double zed = fabs(p->Z());
00113     double cos2Tet = p->cos2ThetaV();
00114     // Ecal entrance
00115     bool ecalAcc = ( (radius2<129.01*129.01 && zed<317.01) ||
00116                      (cos2Tet>cos2PreshMin && cos2Tet<cos2PreshMax 
00117                       && radius2<171.11*171.11 && zed<317.01) );
00118 
00119     return ecalAcc;
00120 
00121   } else { 
00122     // Cut for vertices
00123     double radius2 = p->Perp2();
00124     double zed = fabs(p->Pz());
00125     double cos2Tet = p->cos2Theta();
00126 
00127     // Vertices must be before the Ecal entrance
00128     bool ecalAcc = ( (radius2<129.01*129.01 && zed<317.01) ||
00129                      (cos2Tet>cos2PreshMin && cos2Tet<cos2PreshMax 
00130                       && radius2<171.11*171.11 && zed<317.01) );
00131 
00132     return ecalAcc;
00133 
00134   }
00135 
00136 }