CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MuScleFitGenFilter.cc
Go to the documentation of this file.
1 //#define DEBUG
2 // System include files
3 // --------------------
4 #include <memory>
5 #include <vector>
6 #include <string>
7 
8 // User include files
9 // ------------------
16 
17 
18 // Collaborating Class Header
25 
26 #include "MuScleFitUtils.h"
27 
28 #include <CLHEP/Vector/LorentzVector.h>
29 
30 // Class declaration
31 // -----------------
32 
34  public:
35  explicit MuScleFitGenFilter(const edm::ParameterSet&);
37 
38  private:
39  virtual bool filter(edm::Event&, const edm::EventSetup&);
40  virtual void endJob() {};
41 
42  std::string genParticlesName_;
43  unsigned int totalEvents_;
45 };
46 
47 // Constructor
48 // -----------
50  genParticlesName_( iConfig.getUntrackedParameter<std::string>("GenParticlesName", "genParticles") ),
51  totalEvents_(0),
52  eventsPassingTheFilter_(0)
53 {
54  MuScleFitUtils::resfind = iConfig.getParameter<std::vector<int> >("resfind");
55 }
56 
57 // Destructor
58 // ----------
60 {
61  std::cout << "Total number of events = " << totalEvents_ << std::endl;
62  std::cout << "Events passing the filter = " << eventsPassingTheFilter_ << std::endl;
63 }
64 
65 // Method called for each event
66 // ----------------------------
68 {
69  ++totalEvents_;
70 
72 
73  std::pair<lorentzVector,lorentzVector> genPair;
74 
75  event.getByLabel( genParticlesName_, evtMC );
76  if( evtMC.isValid() ) {
77 
78  genPair = MuScleFitUtils::findGenMuFromRes(evtMC.product());
79  }
80  else {
82  event.getByLabel( genParticlesName_, genParticles );
83  if( genParticles.isValid() ) {
84 
85  genPair = MuScleFitUtils::findGenMuFromRes(genParticles.product());
86  }
87  else {
88  std::cout << "ERROR: no generator info found" << std::endl;
89  return false;
90  }
91  }
92  lorentzVector emptyVec(0.,0.,0.,0.);
93  if( (genPair.first == emptyVec) || (genPair.second == emptyVec) ) {
94  return false;
95  }
96 
98 
99  return true;
100 }
101 
T getParameter(std::string const &) const
static std::pair< lorentzVector, lorentzVector > findGenMuFromRes(const reco::GenParticleCollection *genParticles)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
reco::Particle::LorentzVector lorentzVector
Definition: GenMuonPair.h:9
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
bool isValid() const
Definition: HandleBase.h:76
unsigned int eventsPassingTheFilter_
T const * product() const
Definition: Handle.h:74
std::string genParticlesName_
tuple cout
Definition: gather_cfg.py:121
static std::vector< int > resfind
virtual bool filter(edm::Event &, const edm::EventSetup &)
MuScleFitGenFilter(const edm::ParameterSet &)