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 
29 
30 
32 public:
35 
36 
37 private:
38 
39  virtual void produce(edm::Event&, const edm::EventSetup&);
40  virtual void beginJob();
41  virtual void endJob();
42 
46 
47  struct ComparePt {
49  double pt1 = w1.getMuon().pt();
50  double pt2 = w2.getMuon().pt();
51  return (pt1> pt2);
52  }
53  };
55 
56  unsigned int nall;
57 
58 
59 };
60 
64 
69 
74 
76 
78 
80 
81 
82 
83 
84 using namespace edm;
85 using namespace std;
86 using namespace reco;
87 
89  // Input collections
90  muonTag_(cfg.getUntrackedParameter<edm::InputTag> ("MuonTag", edm::InputTag("muons"))),
91  metTag_(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.getByLabel(muonTag_, 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.getByLabel(metTag_, 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 
common ppss p3p6s2 common epss epspn46 common const1 w2
Definition: inclppp.h:1
const std::string WMuNuCollectionTag_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual void endJob()
virtual double pz() const GCC11_FINAL
z coordinate of momentum vector
virtual double py() const GCC11_FINAL
y coordinate of momentum vector
virtual void beginJob()
edm::InputTag metTag_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
double eT() const
virtual double px() const GCC11_FINAL
x coordinate of momentum vector
double acop() const
unsigned int nall
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
#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 &)
edm::InputTag muonTag_
virtual float pt() const GCC11_FINAL
transverse momentum
const reco::Muon & getMuon() const
const reco::MET & getNeutrino() const
virtual void produce(edm::Event &, const edm::EventSetup &)