CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EFilter.cc
Go to the documentation of this file.
1 // system include files
2 #include <memory>
3 #include <iostream>
4 
5 // user include files
7 // #include "FWCore/Framework/interface/EDFilter.h"
8 
13 
14 // #include "FWCore/ParameterSet/interface/ParameterSet.h"
15 
17 
18 
19 // #include "FastSimulation/Event/interface/FSimEvent.h"
20 // #include "FastSimulation/Event/interface/FSimTrack.h"
21 // #include "FastSimulation/Event/interface/FSimVertex.h"
22 
23 // #include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h"
24 // #include "FastSimulation/Particle/interface/ParticleTable.h"
25 
27 // #include "SimDataFormats/HepMCProduct/interface/HepMCProduct.h"
28 
29 
30 using namespace edm;
31 using namespace std;
32 
34  //now do what ever initialization is needed
35 
36  inputTagParticles_ = consumes<std::vector<reco::PFSimParticle> >(iConfig.getParameter<InputTag>("particles"));
37 
38  minE_ = iConfig.getUntrackedParameter<double>("minE",-1);
39  maxE_ = iConfig.getUntrackedParameter<double>("maxE",999999);
40  minEt_ = iConfig.getUntrackedParameter<double>("minEt",-1);
41  maxEt_ = iConfig.getUntrackedParameter<double>("maxEt",999999);
42 
43  LogWarning("PFProducer")<<"EFilter : will filter particles with "
44  <<minE_<<" < E < "<<maxE_<<" and "<<minEt_<<" < Et <"<<maxEt_<<endl;
45 
46 }
47 
48 
50 
51  // do anything here that needs to be done at desctruction time
52  // (e.g. close files, deallocate resources etc.)
53  // delete mySimEvent;
54 
55 
56 }
57 
58 
59 bool
61  const edm::EventSetup& iSetup) {
62 
63 
64 
66  iEvent.getByToken(inputTagParticles_, particles);
67 
68  if( !particles->empty() ) {
69  // take first trajectory point of first particle (the mother)
70  const reco::PFTrajectoryPoint& tp = (*particles)[0].trajectoryPoint(0);
71 
72  const math::XYZTLorentzVector& mom = tp.momentum();
73 
74  double e = mom.E();
75  double et = mom.Et();
76 
77  if( e >= minE_ && e<= maxE_ &&
78  et>= minEt_ && et<= maxEt_ ) {
79  cout<<"ok "<<e<<endl;
80  return true;
81  }
82  else {
83  cout<<"bad "<<e<<endl;
84  return false;
85  }
86  }
87 
88 
89 
90  return true;
91 }
92 
T getParameter(std::string const &) const
virtual bool filter(edm::Event &, const edm::EventSetup &) override
Definition: EFilter.cc:60
T getUntrackedParameter(std::string const &, T const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
~EFilter()
Definition: EFilter.cc:49
int iEvent
Definition: GenABIO.cc:230
EFilter(const edm::ParameterSet &)
Definition: EFilter.cc:33
const math::XYZTLorentzVector & momentum() const
4-momenta quadrivector
tuple cout
Definition: gather_cfg.py:121
A PFTrack holds several trajectory points, which basically contain the position and momentum of a tra...