CMS 3D CMS Logo

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 
20 #include "TH1D.h"
21 #include <map>
22 // system include files
23 #include <memory>
24 #include <vector>
25 
30 
32 public:
34  ~WMuNuProducer() override;
35 
36 private:
37  void produce(edm::Event&, const edm::EventSetup&) override;
38  void beginJob() override;
39  void endJob() override;
40 
43 
44  struct ComparePt {
46  double pt1 = w1.getMuon().pt();
47  double pt2 = w2.getMuon().pt();
48  return (pt1 > pt2);
49  }
50  };
52 
53  unsigned int nall;
54 };
55 
59 
64 
67 
69 
71 
73 
74 using namespace edm;
75 using namespace std;
76 using namespace reco;
77 
79  : // Input collections
80  muonToken_(consumes<View<Muon> >(cfg.getUntrackedParameter<edm::InputTag>("MuonTag", edm::InputTag("muons")))),
81  metToken_(consumes<View<MET> >(cfg.getUntrackedParameter<edm::InputTag>("METTag", edm::InputTag("met")))) {
82  produces<WMuNuCandidateCollection>();
83 }
84 
86 
87 void WMuNuProducer::endJob() { LogTrace("") << "WMuNuCandidateCollection Stored in the Event"; }
88 
90  // do anything here that needs to be done at desctruction time
91  // (e.g. close files, deallocate resources etc.)
92 }
93 
95  // Muon collection
97  if (!ev.getByToken(muonToken_, muonCollection)) {
98  LogError("") << ">>> Muon collection does not exist !!!";
99  return;
100  }
101  int muonCollectionSize = muonCollection->size();
102 
103  // MET
105  if (!ev.getByToken(metToken_, metCollection)) {
106  LogError("") << ">>> MET collection does not exist !!!";
107  return;
108  }
109  //const MET& Met = metCollection->at(0);
111 
112  if (muonCollectionSize < 1)
113  return;
114 
115  unique_ptr<WMuNuCandidateCollection> WMuNuCandidates(new WMuNuCandidateCollection);
116 
117  // Fill Collection with n muons --> n W Candidates ordered by pt
118 
119  for (int indx = 0; indx < muonCollectionSize; indx++) {
121  if (!muon->isGlobalMuon())
122  continue;
123  if (muon->globalTrack().isNull())
124  continue;
125  if (muon->innerTrack().isNull())
126  continue;
127 
128  // Build WMuNuCandidate
129  LogTrace("") << "Building WMuNu Candidate!";
130  WMuNuCandidate* WCand = new WMuNuCandidate(muon, met);
131  LogTrace("") << "\t... W mass, W_et: " << WCand->massT() << ", " << WCand->eT() << "[GeV]";
132  LogTrace("") << "\t... W_px, W_py: " << WCand->px() << ", " << WCand->py() << "[GeV]";
133  LogTrace("") << "\t... acop: " << WCand->acop();
134  LogTrace("") << "\t... Muon pt, px, py, pz: " << WCand->getMuon().pt() << ", " << WCand->getMuon().px() << ", "
135  << WCand->getMuon().py() << ", " << WCand->getMuon().pz() << " [GeV]";
136  LogTrace("") << "\t... Met met_et, met_px, met_py : " << WCand->getNeutrino().pt() << ", "
137  << WCand->getNeutrino().px() << ", " << WCand->getNeutrino().py() << " [GeV]";
138  WMuNuCandidates->push_back(*WCand);
139  }
140 
141  std::sort(WMuNuCandidates->begin(), WMuNuCandidates->end(), ptComparator);
142 
143  ev.put(std::move(WMuNuCandidates));
144 }
145 
Phi.h
Handle.h
w2
common ppss p3p6s2 common epss epspn46 common const1 w2
Definition: inclppp.h:1
HLT_2018_cff.pt2
pt2
Definition: HLT_2018_cff.py:8552
Muon.h
MessageLogger.h
WMuNuCandidate.h
EDProducer.h
WMuNuProducer::muonToken_
edm::EDGetTokenT< edm::View< reco::Muon > > muonToken_
Definition: WMuNuProducer.cc:41
TriggerResults.h
WMuNuProducer::nall
unsigned int nall
Definition: WMuNuProducer.cc:53
muon
Definition: MuonCocktails.h:17
susyDQM_cfi.metCollection
metCollection
Definition: susyDQM_cfi.py:11
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
reco::WMuNuCandidate::acop
double acop() const
Definition: WMuNuCandidate.cc:42
WMuNuProducer::~WMuNuProducer
~WMuNuProducer() override
Definition: WMuNuProducer.cc:89
HLT_2018_cff.pt1
pt1
Definition: HLT_2018_cff.py:8550
WMuNuProducer::ComparePt::operator()
bool operator()(reco::WMuNuCandidate w1, reco::WMuNuCandidate w2) const
Definition: WMuNuProducer.cc:45
Jet.h
reco::LeafCandidate::pt
double pt() const final
transverse momentum
Definition: LeafCandidate.h:146
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
HLT_2018_cff.muon
muon
Definition: HLT_2018_cff.py:10349
edm::Handle
Definition: AssociativeIterator.h:50
WMuNuProducer::ptComparator
ComparePt ptComparator
Definition: WMuNuProducer.cc:51
Muon
Definition: Muon.py:1
BTaggingMonitor_cfi.met
met
Definition: BTaggingMonitor_cfi.py:84
WMuNuProducer::ComparePt
Definition: WMuNuProducer.cc:44
reco::WMuNuCandidateCollection
std::vector< reco::WMuNuCandidate > WMuNuCandidateCollection
Definition: WMuNuCandidate.h:46
reco::MET
Definition: MET.h:41
MakerMacros.h
Track.h
reco::WMuNuCandidate::massT
double massT() const
Definition: WMuNuCandidate.cc:31
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
BeamSpot.h
reco::LeafCandidate::py
double py() const final
y coordinate of momentum vector
Definition: LeafCandidate.h:142
Service.h
MuonFwd.h
reco::WMuNuCandidate::getMuon
const reco::Muon & getMuon() const
Definition: WMuNuCandidate.h:38
WMuNuProducer::WMuNuProducer
WMuNuProducer(const edm::ParameterSet &)
Definition: WMuNuProducer.cc:78
TFileService.h
reco::WMuNuCandidate::getNeutrino
const reco::MET & getNeutrino() const
Definition: WMuNuCandidate.h:39
edm::View
Definition: CaloClusterFwd.h:14
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
Event.h
WMuNuProducer
Definition: WMuNuProducer.cc:31
WMuNuProducer::metToken_
edm::EDGetTokenT< edm::View< reco::MET > > metToken_
Definition: WMuNuProducer.cc:42
edm::EventSetup
Definition: EventSetup.h:57
pdwgLeptonRecoSkim_cfi.muonCollection
muonCollection
Definition: pdwgLeptonRecoSkim_cfi.py:7
InputTag.h
edm::Ptr< reco::MET >
looper.cfg
cfg
Definition: looper.py:297
WMuNuProducer::beginJob
void beginJob() override
Definition: WMuNuProducer.cc:85
MET.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
reco::WMuNuCandidate
Definition: WMuNuCandidate.h:17
reco::WMuNuCandidate::eT
double eT() const
Definition: WMuNuCandidate.cc:25
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
edm::EDProducer
Definition: EDProducer.h:36
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
View.h
ParameterSet.h
WMuNuProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: WMuNuProducer.cc:94
WMuNuProducer::endJob
void endJob() override
Definition: WMuNuProducer.cc:87
edm::Event
Definition: Event.h:73
reco::LeafCandidate::px
double px() const final
x coordinate of momentum vector
Definition: LeafCandidate.h:140
reco::LeafCandidate::pz
double pz() const final
z coordinate of momentum vector
Definition: LeafCandidate.h:144
edm::InputTag
Definition: InputTag.h:15