CMS 3D CMS Logo

SMPDQM.cc
Go to the documentation of this file.
2 
3 using namespace std;
4 using namespace reco;
5 
6 struct SortByPt
7 
8 {
9  bool operator()(const TLorentzVector& a, const TLorentzVector& b) const { return a.Pt() > b.Pt(); }
10 };
12  //now do what ever initialization is needed
13  muons_ = consumes<reco::MuonCollection>(iConfig.getParameter<edm::InputTag>("muonCollection"));
14  pvs_ = consumes<edm::View<reco::Vertex>>(iConfig.getParameter<edm::InputTag>("pvs"));
15 
16  elecs_ = consumes<reco::GsfElectronCollection>(iConfig.getParameter<edm::InputTag>("elecCollection"));
17  jets_ = consumes<edm::View<reco::PFJet>>(iConfig.getParameter<edm::InputTag>("jets"));
18 
19  for (edm::InputTag const& tag : iConfig.getParameter<std::vector<edm::InputTag>>("mets"))
20  mets_.push_back(consumes<edm::View<reco::MET>>(tag));
21 }
22 
24  // do anything here that needs to be done at desctruction time
25  // (e.g. close files, deallocate resources etc.)
26 }
27 // ------------ method called for each event ------------
29  bei.setCurrentFolder("Physics/SMP");
30 
31  NPV = bei.book1D("NPV", "Number of primary vertices", 40, 0., 80.);
32  MET = bei.book1D("MET", "MET", 100, 0.0, 200);
33  METphi = bei.book1D("METphi", "#phi(MET)", 50, -3.14, 3.14);
34 
35  pt_muons = bei.book1D("pt_muons", "p_{T}(muons)", 40, 0., 200.);
36  eta_muons = bei.book1D("eta_muons", "#eta(muons)", 50, -5., 5.);
37  phi_muons = bei.book1D("phi_muons", "#phi(muons)", 32, -3.2, 3.2);
38  muIso_CombRelIso03 = bei.book1D("muIso_CombRelIso03", "Iso_{rel}^{#mu}", 20, 0., 1.);
39  Nmuons = bei.book1D("Nmuons", "Number of muons", 20, 0., 10.);
40  isGlobalmuon = bei.book1D("isGlobalmuon", "isGlobalmuon", 2, 0, 1);
41  isTrackermuon = bei.book1D("isTrackermuon", "isTrackermuon", 2, 0, 1);
42  isStandalonemuon = bei.book1D("isStandalonemuon", "isStandalonemuon", 2, 0, 1);
43  isPFmuon = bei.book1D("isPFmuon", "isPFmuon", 2, 0, 1);
44  muIso_TrackerBased03 = bei.book1D("muIso_TrackerBased03", "Iso_{trk03}^{#mu}", 20, 0, 10);
45 
46  Nelecs = bei.book1D("Nelecs", "Number of electrons", 20, 0., 10.);
47  HoverE_elecs = bei.book1D("HoverE_elecs", "HoverE", 50, 0., 1.);
48  pt_elecs = bei.book1D("pt_elecs", "p_{T}(elecs)", 40, 0., 200.);
49  eta_elecs = bei.book1D("eta_elecs", "#eta(elecs)", 50, -5., 5.);
50  phi_elecs = bei.book1D("phi_elecs", "#phielecs)", 32, -3.2, 3.2);
51  elIso_cal = bei.book1D("elIso_cal", "Iso_{cal}^{el}", 21, -1., 20.);
52  elIso_trk = bei.book1D("elIso_trk", "Iso_{trk}^{el}", 21, -2., 40.);
53  elIso_CombRelIso = bei.book1D("elIso_CombRelIso", "Iso_{rel}^{el}", 20, 0., 1.);
54 
55  PFJetpt = bei.book1D("PFJetpt", "p_{T}(jets)", 100, 0.0, 100);
56  PFJeteta = bei.book1D("PFJeteta", "#eta(jets)", 50, -2.5, 2.5);
57  PFJetphi = bei.book1D("PFJetphi", "#phi(jets)", 50, -3.14, 3.14);
58  PFJetMulti = bei.book1D("PFJetMulti", "jet multiplicity", 5, -0.5, 4.5);
59  PFJetRapidity = bei.book1D("PFJetRapidity", "y(jets)", 50, -6.0, 6.0);
60  mjj = bei.book1D("mjj", "m_{jj}", 100, 0, 1000);
61  detajj = bei.book1D("detajj", "#Delta#etajj", 20, 0, 5);
62 
63  dphi_lepMET = bei.book1D("dphi_lepMET", "#Delta#phi(lep,MET)", 60, -3.2, 3.2);
64  mass_lepMET = bei.book1D("mass_lepMET", "m(lep,MET)", 200, 0, 200);
65  pt_lepMET = bei.book1D("pt_lepMET", "p_{T}(lep,MET)", 200, 0, 200);
66  detall = bei.book1D("detall", "#Delta#etall", 20, -5, 5);
67  dphill = bei.book1D("dphill", "#Delta#phill", 20, -6.4, 6.4);
68  mll = bei.book1D("mll", "mll", 200, 0, 200);
69  etall = bei.book1D("etall", "#Delta#etall", 60, -6, 6);
70  ptll = bei.book1D("ptll", "p_{T}ll", 200, 0, 200);
71  mjj = bei.book1D("mjj", "mjj", 100, 0, 1000);
72  detajj = bei.book1D("detajj", "#Delta#etajj", 20, 0, 5);
73 
74  dphi_lepjet1 = bei.book1D("dphi_lepjet1", "#Delta#phi(lep,jet1)", 60, -3.2, 3.2);
75 
76  dphi_lep1jet1 = bei.book1D("dphi_lep1jet1", "#Delta#phi(lep1,jet1)", 60, -3.2, 3.2);
77  dphi_lep2jet1 = bei.book1D("dphi_lep2jet1", "#Delta#phi(lep2,jet1)", 60, -3.2, 3.2);
78 }
79 void SMPDQM::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
80  std::vector<TLorentzVector> recoPFJets;
81  recoPFJets.clear();
82  TLorentzVector imet;
83  imet.Clear();
84  std::vector<TLorentzVector> selected_recoPFJets;
85  selected_recoPFJets.clear();
86  std::vector<TLorentzVector> selected_lep;
87  selected_lep.clear();
88 
89  for (std::vector<edm::EDGetTokenT<edm::View<reco::MET>>>::const_iterator met_ = mets_.begin(); met_ != mets_.end();
90  ++met_) {
92  if (!iEvent.getByToken(*met_, met))
93  continue;
94  if (met->begin() != met->end()) {
95  MET->Fill(met->begin()->et());
96  METphi->Fill(met->begin()->phi());
97  imet.SetPtEtaPhiM(met->begin()->et(), 0., met->begin()->phi(), 0.0);
98  }
99  }
100 
101  // Muons
102 
104  if (!iEvent.getByToken(pvs_, pvs)) {
105  return;
106  }
107 
108  unsigned int pvMult = 0;
109 
110  for (edm::View<reco::Vertex>::const_iterator pv = pvs->begin(); pv != pvs->end(); ++pv) {
111  if (pv->position().Rho() < 2 && abs(pv->position().z()) <= 24. && pv->ndof() > 4 && !pv->isFake()) {
112  pvMult++;
113  }
114  }
115  NPV->Fill(pvMult);
116 
118  iEvent.getByToken(muons_, muons);
119  reco::MuonCollection::const_iterator mu;
120  if (!muons.failedToGet()) {
121  Nmuons->Fill(muons->size());
122 
123  for (mu = muons->begin(); mu != muons->end(); ++mu) {
124  if (mu->pt() < 3.0)
125  continue;
126  TLorentzVector Mu;
127  Mu.SetPtEtaPhiM(mu->pt(), mu->eta(), mu->phi(), 0.0);
128  selected_lep.push_back(Mu);
129  pt_muons->Fill(mu->pt());
130  eta_muons->Fill(mu->eta());
131  phi_muons->Fill(mu->phi());
132  isGlobalmuon->Fill(mu->isGlobalMuon());
133  isTrackermuon->Fill(mu->isTrackerMuon());
134  isStandalonemuon->Fill(mu->isStandAloneMuon());
135  isPFmuon->Fill(mu->isPFMuon());
136 
137  reco::MuonIsolation muIso03 = mu->isolationR03();
138  double muonCombRelIso = 1.;
139 
140  muonCombRelIso = (muIso03.emEt + muIso03.hadEt + muIso03.hoEt + muIso03.sumPt) / mu->pt();
141 
142  muIso_TrackerBased03->Fill(muIso03.sumPt / mu->pt());
143  muIso_CombRelIso03->Fill(muonCombRelIso);
144 
145  } //size of muons
146 
147  } // muons
148 
149  // electrons
150 
152  iEvent.getByToken(elecs_, elecs);
153  reco::GsfElectronCollection::const_iterator elec;
154 
155  if (!elecs.failedToGet()) {
156  Nelecs->Fill(elecs->size());
157 
158  for (elec = elecs->begin(); elec != elecs->end(); ++elec) {
159  if (elec->pt() < 5.0)
160  continue;
161  TLorentzVector El;
162  El.SetPtEtaPhiM(elec->pt(), elec->eta(), elec->phi(), 0.0);
163  selected_lep.push_back(El);
164 
165  HoverE_elecs->Fill(elec->hcalOverEcal());
166  pt_elecs->Fill(elec->pt());
167  eta_elecs->Fill(elec->eta());
168  phi_elecs->Fill(elec->phi());
169 
170  reco::GsfTrackRef track = elec->gsfTrack();
171  reco::GsfElectron::IsolationVariables elecIso = elec->dr03IsolationVariables();
172 
173  double elecCombRelIso = 1.;
174 
175  elecCombRelIso = (elecIso.ecalRecHitSumEt + elecIso.hcalDepth1TowerSumEt + elecIso.tkSumPt) / elec->pt();
176  elIso_CombRelIso->Fill(elecCombRelIso);
177  elIso_cal->Fill(elecIso.ecalRecHitSumEt);
178  elIso_trk->Fill(elecIso.tkSumPt);
179  }
180 
181  } // electrons
182  // jets
183 
185  if (!iEvent.getByToken(jets_, jets)) {
186  return;
187  }
188 
189  for (edm::View<reco::PFJet>::const_iterator jet = jets->begin(); jet != jets->end(); ++jet) {
190  if (jet->pt() < 15.0)
191  continue;
192  TLorentzVector ijet;
193  ijet.SetPtEtaPhiM(jet->pt(), jet->eta(), jet->phi(), jet->mass());
194  recoPFJets.push_back(ijet);
195  }
196 
197  std::sort(recoPFJets.begin(), recoPFJets.end(), SortByPt());
198  std::sort(selected_lep.begin(), selected_lep.end(), SortByPt());
199 
200  for (unsigned int i = 0; i < recoPFJets.size(); i++) {
201  bool goodjet = false;
202  for (unsigned int j = 0; j < selected_lep.size(); j++) {
203  if (recoPFJets[i].DeltaR(selected_lep[j]) > 0.4) {
204  goodjet = true;
205  continue;
206  } else {
207  goodjet = false;
208  break;
209  }
210  }
211  if (goodjet) {
212  TLorentzVector temp;
213  temp.Clear();
214  temp.SetPtEtaPhiM(recoPFJets[i].Pt(), recoPFJets[i].Eta(), recoPFJets[i].Phi(), recoPFJets[i].M());
215  selected_recoPFJets.push_back(temp);
216  }
217  }
218 
219  std::sort(selected_recoPFJets.begin(), selected_recoPFJets.end(), SortByPt()); // for safety
220  int njet = 0;
221  for (unsigned int k = 0; k < selected_recoPFJets.size(); k++) {
222  if (k > 4)
223  break;
224  else {
225  njet++;
226  PFJetpt->Fill(selected_recoPFJets.at(k).Pt());
227  PFJeteta->Fill(selected_recoPFJets.at(k).Eta());
228  PFJetphi->Fill(selected_recoPFJets.at(k).Phi());
229  PFJetRapidity->Fill(selected_recoPFJets.at(k).Rapidity());
230  }
231  }
232  PFJetMulti->Fill(njet);
233 
234  // now we have selected jet and lepton collections
235 
236  if (selected_lep.size() > 1) {
237  detall->Fill(selected_lep[0].Eta() - selected_lep[1].Eta());
238  dphill->Fill(selected_lep[0].DeltaPhi(selected_lep[1]));
239  mll->Fill((selected_lep[0] + selected_lep[1]).M());
240  ptll->Fill((selected_lep[0] + selected_lep[1]).Pt());
241  etall->Fill((selected_lep[0] + selected_lep[1]).Eta());
242  if (!selected_recoPFJets.empty()) {
243  dphi_lep1jet1->Fill(selected_recoPFJets[0].DeltaPhi(selected_lep[0]));
244  dphi_lep2jet1->Fill(selected_recoPFJets[0].DeltaPhi(selected_lep[1]));
245  }
246  }
247 
248  else if (selected_lep.size() == 1) {
249  dphi_lepMET->Fill(selected_lep[0].DeltaPhi(imet));
250  mass_lepMET->Fill((selected_lep[0] + imet).M());
251  pt_lepMET->Fill((selected_lep[0] + imet).Pt());
252  if (!selected_recoPFJets.empty()) {
253  dphi_lepjet1->Fill(selected_recoPFJets[0].DeltaPhi(selected_lep[0]));
254  }
255  } // W case
256 
257  else {
258  // std::cout << "zero lepton case" << endl;
259  }
260  if (selected_recoPFJets.size() > 1) {
261  detajj->Fill(abs(selected_recoPFJets[0].Eta() - selected_recoPFJets[1].Eta()));
262  mjj->Fill((selected_recoPFJets[0] + selected_recoPFJets[1]).M());
263  }
264 
265 } // analyze
266 
267 //define this as a plug-in
268 //DEFINE_FWK_MODULE(SMPDQM);
269 
270 //dilepton eta,pt and phi using lorentz vectors
271 //first five jets
272 // dphi(lepton jet)
273 //vbf detajj, mjj
PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
edm::View::begin
const_iterator begin() const
mps_fire.i
i
Definition: mps_fire.py:428
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11779
SMPDQM::~SMPDQM
~SMPDQM() override
Definition: SMPDQM.cc:23
amptDefaultParameters_cff.mu
mu
Definition: amptDefaultParameters_cff.py:16
edm::Run
Definition: Run.h:45
reco::MuonIsolation::emEt
float emEt
ecal sum-Et
Definition: MuonIsolation.h:7
edm::EDGetTokenT
Definition: EDGetToken.h:33
SortByPt::operator()
bool operator()(const TLorentzVector &a, const TLorentzVector &b) const
Definition: SMPDQM.cc:9
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
SMPDQM::SMPDQM
SMPDQM(const edm::ParameterSet &)
Definition: SMPDQM.cc:11
edm::Handle
Definition: AssociativeIterator.h:50
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
reco::MuonIsolation
Definition: MuonIsolation.h:5
HLT_FULL_cff.DeltaPhi
DeltaPhi
Definition: HLT_FULL_cff.py:465
edm::Ref< GsfTrackCollection >
BTaggingMonitor_cfi.met
met
Definition: BTaggingMonitor_cfi.py:84
reco::MET
Definition: MET.h:41
njet
int njet
Definition: HydjetWrapper.h:89
reco::MuonIsolation::sumPt
float sumPt
sum-pt of tracks
Definition: MuonIsolation.h:6
reco::GsfElectron::IsolationVariables::tkSumPt
float tkSumPt
Definition: GsfElectron.h:511
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
SMPDQM::bookHistograms
void bookHistograms(DQMStore::IBooker &bei, edm::Run const &, edm::EventSetup const &) override
Definition: SMPDQM.cc:28
SMPDQM::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: SMPDQM.cc:79
reco::GsfElectron::IsolationVariables::hcalDepth1TowerSumEt
float hcalDepth1TowerSumEt
Definition: GsfElectron.h:514
singleTopDQM_cfi.elecs
elecs
Definition: singleTopDQM_cfi.py:41
VtxSmearedParameters_cfi.Phi
Phi
Definition: VtxSmearedParameters_cfi.py:112
dqmdumpme.k
k
Definition: dqmdumpme.py:60
reco::GsfElectron::IsolationVariables
Definition: GsfElectron.h:510
b
double b
Definition: hdecay.h:118
edm::View
Definition: CaloClusterFwd.h:14
edm::ParameterSet
Definition: ParameterSet.h:47
a
double a
Definition: hdecay.h:119
MetAnalyzer.pv
def pv(vc)
Definition: MetAnalyzer.py:7
iEvent
int iEvent
Definition: GenABIO.cc:224
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
RecoPFJets_cff.recoPFJets
recoPFJets
Definition: RecoPFJets_cff.py:45
SortByPt
Definition: FSQDQM.cc:77
edm::EventSetup
Definition: EventSetup.h:57
reco::MuonIsolation::hoEt
float hoEt
ho sum-Et
Definition: MuonIsolation.h:9
electronAnalyzer_cfi.DeltaR
DeltaR
Definition: electronAnalyzer_cfi.py:33
FSQDQM_cfi.pvs
pvs
Definition: FSQDQM_cfi.py:12
Mu
Definition: L1GtObject.h:29
std
Definition: JetResolutionObject.h:76
reco::MuonIsolation::hadEt
float hadEt
hcal sum-Et
Definition: MuonIsolation.h:8
metsig::jet
Definition: SignAlgoResolutions.h:47
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
dqm::implementation::IBooker
Definition: DQMStore.h:43
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
reco::GsfElectron::IsolationVariables::ecalRecHitSumEt
float ecalRecHitSumEt
Definition: GsfElectron.h:513
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
edm::Event
Definition: Event.h:73
SMPDQM.h
edm::InputTag
Definition: InputTag.h:15
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98