CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
WMuNuProducer.cc
Go to the documentation of this file.
1 // //
3 // WMuNuCandidate Producer //
4 // //
6 // //
7 // Productor of WMuNuCandidates for Analysis //
8 // --> Creates a WMuNuCandidateCollection //
9 // --> One Candidate is created per muon in the event, combinig the information with a selected kind of Met //
10 // (met kind configurable via cfg) //
11 // --> All WMuNuCandidates are stored in the event, ordered by muon pt. //
12 // --> The WMuNuCandidate to be used for the Inclusive analysis is then the first one! (Highest Pt) //
13 // //
15 
16 
17 
22 #include "TH1D.h"
23 #include <map>
24 // system include files
25 #include <memory>
26 #include <vector>
27 
32 
33 
35 public:
38 
39 
40 private:
41 
42  virtual void produce(edm::Event&, const edm::EventSetup&) override;
43  virtual void beginJob() override;
44  virtual void endJob() override;
45 
48 
49  struct ComparePt {
51  double pt1 = w1.getMuon().pt();
52  double pt2 = w2.getMuon().pt();
53  return (pt1> pt2);
54  }
55  };
57 
58  unsigned int nall;
59 
60 
61 };
62 
66 
71 
74 
76 
78 
80 
81 
82 
83 
84 using namespace edm;
85 using namespace std;
86 using namespace reco;
87 
89  // Input collections
90  muonToken_(consumes<View<Muon> >(cfg.getUntrackedParameter<edm::InputTag> ("MuonTag", edm::InputTag("muons")))),
91  metToken_(consumes<View<MET> >(cfg.getUntrackedParameter<edm::InputTag> ("METTag", edm::InputTag("met"))))
92 {
93  produces< WMuNuCandidateCollection >();
94 }
95 
97 }
98 
100  LogTrace("")<<"WMuNuCandidateCollection Stored in the Event";
101 }
102 
103 
105 {
106 
107  // do anything here that needs to be done at desctruction time
108  // (e.g. close files, deallocate resources etc.)
109 
110 }
111 
112 
114 
115  // Muon collection
116  Handle<View<Muon> > muonCollection;
117  if (!ev.getByToken(muonToken_, muonCollection)) {
118  LogError("") << ">>> Muon collection does not exist !!!";
119  return;
120  }
121  int muonCollectionSize = muonCollection->size();
122 
123  // MET
124  Handle<View<MET> > metCollection;
125  if (!ev.getByToken(metToken_, metCollection)) {
126  LogError("") << ">>> MET collection does not exist !!!";
127  return;
128  }
129  //const MET& Met = metCollection->at(0);
130  edm::Ptr<reco::MET> met(metCollection,0);
131 
132 
133  if (muonCollectionSize<1) return;
134 
135  auto_ptr< WMuNuCandidateCollection > WMuNuCandidates(new WMuNuCandidateCollection );
136 
137 
138  // Fill Collection with n muons --> n W Candidates ordered by pt
139 
140  for (int indx=0; indx<muonCollectionSize; indx++){
141  edm::Ptr<reco::Muon> muon(muonCollection,indx);
142  if (!muon->isGlobalMuon()) continue;
143  if (muon->globalTrack().isNull()) continue;
144  if (muon->innerTrack().isNull()) continue;
145 
146  // Build WMuNuCandidate
147  LogTrace("")<<"Building WMuNu Candidate!";
148  WMuNuCandidate* WCand = new WMuNuCandidate(muon,met);
149  LogTrace("") << "\t... W mass, W_et: "<<WCand->massT()<<", "<<WCand->eT()<<"[GeV]";
150  LogTrace("") << "\t... W_px, W_py: "<<WCand->px()<<", "<< WCand->py() <<"[GeV]";
151  LogTrace("") << "\t... acop: " << WCand->acop();
152  LogTrace("") << "\t... Muon pt, px, py, pz: "<<WCand->getMuon().pt()<<", "<<WCand->getMuon().px()<<", "<<WCand->getMuon().py()<<", "<< WCand->getMuon().pz()<<" [GeV]";
153  LogTrace("") << "\t... Met met_et, met_px, met_py : "<<WCand->getNeutrino().pt()<<", "<<WCand->getNeutrino().px()<<", "<<WCand->getNeutrino().py()<<" [GeV]";
154  WMuNuCandidates->push_back(*WCand);
155  }
156 
157  std::sort(WMuNuCandidates->begin(),WMuNuCandidates->end(),ptComparator);
158 
159  ev.put(WMuNuCandidates);
160 
161 }
162 
tuple met
____________________________________________________________________________||
Definition: CaloMET_cfi.py:4
common ppss p3p6s2 common epss epspn46 common const1 w2
Definition: inclppp.h:1
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
edm::EDGetTokenT< edm::View< reco::MET > > metToken_
edm::EDGetTokenT< edm::View< reco::Muon > > muonToken_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual void beginJob() override
virtual double pz() const GCC11_FINAL
z coordinate of momentum vector
virtual double py() const GCC11_FINAL
y coordinate of momentum vector
virtual void produce(edm::Event &, const edm::EventSetup &) override
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
Definition: MET.h:39
double eT() const
virtual double px() const GCC11_FINAL
x coordinate of momentum vector
double acop() const
unsigned int nall
#define LogTrace(id)
std::vector< reco::WMuNuCandidate > WMuNuCandidateCollection
bool operator()(reco::WMuNuCandidate w1, reco::WMuNuCandidate w2) const
double massT() const
ComparePt ptComparator
bool isNull() const
Checks for null.
Definition: Ptr.h:148
WMuNuProducer(const edm::ParameterSet &)
virtual float pt() const GCC11_FINAL
transverse momentum
const reco::Muon & getMuon() const
const reco::MET & getNeutrino() const
virtual void endJob() override