CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ZllArbitrator.cc
Go to the documentation of this file.
1 // Includes
8 
11 
20 
22 
23 #include <memory>
24 #include <vector>
25 #include <sstream>
26 
27 
29 // class definition
31 template<typename T1>
33 {
34 public:
35  // construction/destruction
36  ZllArbitrator(const edm::ParameterSet& iConfig);
37  virtual ~ZllArbitrator();
38 
39  // member functions
40  void produce(edm::Event& iEvent,const edm::EventSetup& iSetup) override;
41  void endJob() override;
42 
43 private:
44  // member data
46 };
47 
48 
49 
51 // construction/destruction
53 
54 //______________________________________________________________________________
55 template<typename T1>
57  : srcZCand_(consumes<std::vector<T1> >(iConfig.getParameter<edm::InputTag>("ZCandidateCollection")))
58 {
59  produces<std::vector<T1> >();
60 }
61 
62 
63 //______________________________________________________________________________
64 template<typename T1>
66 
68 // implementation of member functions
70 
71 //______________________________________________________________________________
72 template<typename T1>
74 {
75  std::stringstream ss ;
76 
77  std::auto_ptr<std::vector<T1> > TheBestZ(new std::vector<T1 >);
78 
79  edm::Handle< std::vector<T1> > ZCandidatesHandle;
80  iEvent.getByToken(srcZCand_,ZCandidatesHandle);
81 
82  if( ZCandidatesHandle->size() == 0 )
83  {
84  iEvent.put(TheBestZ);
85  return ;
86  }
87 
88  double ZmassPDG = 91.18;
89  double DeltaMass = 10000;
90 
91  typename std::vector<T1>::const_iterator ZCandIt ;
92  typename std::vector<T1>::const_iterator bestZCand ;
93 
94  for (ZCandIt = ZCandidatesHandle->begin(); ZCandIt != ZCandidatesHandle->end(); ++ZCandIt) {
95 
96  if( fabs(ZCandIt->mass()-ZmassPDG) < DeltaMass ){
97  DeltaMass = fabs(ZCandIt->mass()-ZmassPDG) ;
98  bestZCand = ZCandIt;
99  }
100  }
101 
102  TheBestZ->push_back( *bestZCand );
103  iEvent.put(TheBestZ);
104 
105 }
106 
107 template<typename T1>
109 {
110 }
111 
113 
ZllArbitrator(const edm::ParameterSet &iConfig)
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
ZllArbitrator< reco::CompositeCandidate > BestMassZArbitrationProducer
virtual ~ZllArbitrator()
return((rh^lh)&mask)
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
edm::EDGetTokenT< std::vector< T1 > > srcZCand_
void endJob() override