CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TopHLTDiLeptonOfflineDQM.cc
Go to the documentation of this file.
1 //#include <algorithm>
8 /*Originally from DQM/Physics by R. Wolf and J. Andrea*/
9 
10 namespace TopDiLeptonOffline {
11 
12  MonitorEnsemble::MonitorEnsemble(const char* label, const edm::ParameterSet& cfg) :
13  label_(label), eidPattern_(0), elecIso_(0), elecSelect_(0), muonIso_(0), muonSelect_(0), jetIDSelect_(0),
14  lowerEdge_(-1.), upperEdge_(-1.), elecMuLogged_(0), diMuonLogged_(0), diElecLogged_(0)
15  {
16  // sources have to be given; this PSet is not optional
17  edm::ParameterSet sources=cfg.getParameter<edm::ParameterSet>("sources");
18  muons_= sources.getParameter<edm::InputTag>("muons");
19  elecs_= sources.getParameter<edm::InputTag>("elecs");
20  jets_ = sources.getParameter<edm::InputTag>("jets" );
21  mets_ = sources.getParameter<std::vector<edm::InputTag> >("mets" );
22 
23  // elecExtras are optional; they may be omitted or empty
24  if( cfg.existsAs<edm::ParameterSet>("elecExtras") ){
25  edm::ParameterSet elecExtras=cfg.getParameter<edm::ParameterSet>("elecExtras");
26  // select is optional; in case it's not found no
27  // selection will be applied
28  if( elecExtras.existsAs<std::string>("select") ){
29  elecSelect_= new StringCutObjectSelector<reco::GsfElectron>(elecExtras.getParameter<std::string>("select"));
30  }
31  // isolation is optional; in case it's not found no
32  // isolation will be applied
33  if( elecExtras.existsAs<std::string>("isolation") ){
34  elecIso_= new StringCutObjectSelector<reco::GsfElectron>(elecExtras.getParameter<std::string>("isolation"));
35  }
36  // electronId is optional; in case it's not found the
37  // InputTag will remain empty
38  if( elecExtras.existsAs<edm::ParameterSet>("electronId") ){
39  edm::ParameterSet elecId=elecExtras.getParameter<edm::ParameterSet>("electronId");
40  electronId_= elecId.getParameter<edm::InputTag>("src");
41  eidPattern_= elecId.getParameter<int>("pattern");
42  }
43  }
44  // muonExtras are optional; they may be omitted or empty
45  if( cfg.existsAs<edm::ParameterSet>("muonExtras") ){
46  edm::ParameterSet muonExtras=cfg.getParameter<edm::ParameterSet>("muonExtras");
47  // select is optional; in case it's not found no
48  // selection will be applied
49  if( muonExtras.existsAs<std::string>("select") ){
50  muonSelect_= new StringCutObjectSelector<reco::Muon>(muonExtras.getParameter<std::string>("select"));
51  }
52  // isolation is optional; in case it's not found no
53  // isolation will be applied
54  if( muonExtras.existsAs<std::string>("isolation") ){
55  muonIso_= new StringCutObjectSelector<reco::Muon>(muonExtras.getParameter<std::string>("isolation"));
56  }
57  }
58  // jetExtras are optional; they may be omitted or empty
59  if( cfg.existsAs<edm::ParameterSet>("jetExtras") ){
60  edm::ParameterSet jetExtras=cfg.getParameter<edm::ParameterSet>("jetExtras");
61  // jetCorrector is optional; in case it's not found
62  // the InputTag will remain empty
63  if( jetExtras.existsAs<std::string>("jetCorrector") ){
64  jetCorrector_= jetExtras.getParameter<std::string>("jetCorrector");
65  }
66  // read jetID information if it exists
67  if(jetExtras.existsAs<edm::ParameterSet>("jetID")){
69  jetIDLabel_ =jetID.getParameter<edm::InputTag>("label");
70  jetIDSelect_= new StringCutObjectSelector<reco::JetID>(jetID.getParameter<std::string>("select"));
71  }
72  // select is optional; in case it's not found no
73  // selection will be applied (only implemented for
74  // CaloJets at the moment)
75  if( jetExtras.existsAs<std::string>("select") ){
76  jetSelect_= jetExtras.getParameter<std::string>("select");
77  }
78  }
79  // triggerExtras are optional; they may be omitted or empty
80  if( cfg.existsAs<edm::ParameterSet>("triggerExtras") ){
81  edm::ParameterSet triggerExtras=cfg.getParameter<edm::ParameterSet>("triggerExtras");
82  triggerTable_=triggerExtras.getParameter<edm::InputTag>("src");
83  elecMuPaths_ =triggerExtras.getParameter<std::vector<std::string> >("pathsELECMU");
84  diMuonPaths_ =triggerExtras.getParameter<std::vector<std::string> >("pathsDIMUON");
85  }
86  // massExtras is optional; in case it's not found no mass
87  // window cuts are applied for the same flavor monitor
88  // histograms
89  if( cfg.existsAs<edm::ParameterSet>("massExtras") ){
90  edm::ParameterSet massExtras=cfg.getParameter<edm::ParameterSet>("massExtras");
91  lowerEdge_= massExtras.getParameter<double>("lowerEdge");
92  upperEdge_= massExtras.getParameter<double>("upperEdge");
93  }
94 
95  // setup the verbosity level for booking histograms;
96  // per default the verbosity level will be set to
97  // STANDARD. This will also be the chosen level in
98  // the case when the monitoring PSet is not found
99  verbosity_=STANDARD;
100  if( cfg.existsAs<edm::ParameterSet>("monitoring") ){
101  edm::ParameterSet monitoring=cfg.getParameter<edm::ParameterSet>("monitoring");
102  if(monitoring.getParameter<std::string>("verbosity") == "DEBUG" )
103  verbosity_= DEBUG;
104  if(monitoring.getParameter<std::string>("verbosity") == "VERBOSE" )
105  verbosity_= VERBOSE;
106  if(monitoring.getParameter<std::string>("verbosity") == "STANDARD")
107  verbosity_= STANDARD;
108  }
109  // and don't forget to do the histogram booking
110  book(cfg.getParameter<std::string>("directory"));
111  }
112 
113  void
114  MonitorEnsemble::book(std::string directory)
115  {
116  //set up the current directory path
117  std::string current(directory); current+=label_;
118  store_=edm::Service<DQMStore>().operator->();
119  store_->setCurrentFolder(current);
120 
121  // determine number of bins for trigger monitoring
122  unsigned int nElecMu=elecMuPaths_.size();
123  unsigned int nDiMuon=diMuonPaths_.size();
124 
125  // --- [STANDARD] --- //
126  //Run Number
127  hists_["RunNumb_" ] = store_->book1D("RunNumber" , "Run Nr." , 1.e4, 1.5e5, 3.e5);
128  // invariant mass of opposite charge lepton pair (only filled for same flavor)
129  hists_["invMass_" ] = store_->book1D("InvMass" , "M(lep1, lep2)" , 80, 0., 320.);
130  // invariant mass of opposite charge lepton pair (only filled for same flavor)
131  hists_["invMassLog_" ] = store_->book1D("InvMassLog" , "log_{10}(M(lep1, lep2))" , 80, .1, 2.5);
132  // invariant mass of same charge lepton pair (log10 for low mass region, only filled for same flavor)
133  hists_["invMassWC_" ] = store_->book1D("InvMassWC" , "M_{WC}(L1, L2)" , 80, 0., 320.);
134  // invariant mass of same charge lepton pair (log10 for low mass region, only filled for same flavor)
135  hists_["invMassWCLog_"] = store_->book1D("InvMassLogWC", "log_{10}(M_{WC})" , 80, .1, 2.5);
136  // decay channel [1]: muon/muon, [2]:elec/elec, [3]:elec/muon
137  hists_["decayChannel_"] = store_->book1D("DecayChannel", "Decay Channel" , 3, 0, 3);
138  // trigger efficiency estimates for the electron muon channel
139  hists_["elecMuEff_" ] = store_->book1D("ElecMuEff" , "Eff(e/#mu paths)" , nElecMu, 0., nElecMu);
140  // monitored trigger occupancy for the electron muon channel
141  hists_["elecMuMon_" ] = store_->book1D("ElecMuMon" , "Mon(e/#mu paths)" , nElecMu, 0., nElecMu);
142  // trigger efficiency estimates for the di muon channel
143  hists_["diMuonEff_" ] = store_->book1D("DiMuonEff" , "Eff(#mu/#mu paths)" , nDiMuon, 0., nDiMuon);
144  // monitored trigger occupancy for the di muon channel
145  hists_["diMuonMon_" ] = store_->book1D("DiMuonMon" , "Mon(#mu/#mu paths)" , nDiMuon, 0., nDiMuon);
146  // pt of the leading lepton
147  hists_["lep1Pt_" ] = store_->book1D("Lep1Pt" , "pt(lep1)" , 50, 0., 200.);
148  // pt of the 2. leading lepton
149  hists_["lep2Pt_" ] = store_->book1D("Lep2Pt" , "pt(lep2)" , 50, 0., 200.);
150  // multiplicity of jets with pt>30 (corrected to L2+L3)
151  hists_["jetMult_" ] = store_->book1D("JetMult" , "N_{30}(jet)" , 21, -0.5, 20.5);
152  // MET (calo)
153  hists_["metCalo_" ] = store_->book1D("METCalo" , "MET_{Calo}" , 50, 0., 200.);
154 
155  // set bin labels for trigger monitoring
156  triggerBinLabels(std::string("elecMu"), elecMuPaths_);
157  triggerBinLabels(std::string("diMuon"), diMuonPaths_);
158  // set bin labels for decayChannel_
159  hists_["decayChannel_"]->setBinLabel( 1, "#mu e" , 1);
160  hists_["decayChannel_"]->setBinLabel( 2, "#mu #mu", 1);
161  hists_["decayChannel_"]->setBinLabel( 3, "e e" , 1);
162 
163  if( verbosity_==STANDARD) return;
164 
165  // --- [VERBOSE] --- //
166  // mean eta of the candidate leptons
167  hists_["sumEtaL1L2_" ] = store_->book1D("SumEtaL1L2" , "<#eta>(lep1, lep2)" , 100, -5., 5.);
168  // deltaEta between the 2 candidate leptons
169  hists_["dEtaL1L2_" ] = store_->book1D("DEtaL1L2" , "#Delta#eta(lep1,lep2)" , 80, -4., 4.);
170  // deltaPhi between the 2 candidate leptons
171  hists_["dPhiL1L2_" ] = store_->book1D("DPhiL1L2" , "#Delta#phi(lep1,lep2)" , 64, -3.2, 3.2);
172  // pt of the candidate electron (depending on the decay channel)
173  hists_["elecPt_" ] = store_->book1D("ElecPt" , "pt(e)" , 50, 0., 200.);
174  // relative isolation of the candidate electron (depending on the decay channel)
175  hists_["elecRelIso_" ] = store_->book1D("ElecRelIso" , "Iso_{Rel}(e)" , 50, 0., 1.);
176  // pt of the canddiate muon (depending on the decay channel)
177  hists_["muonPt_" ] = store_->book1D("MuonPt" , "pt(#mu)" , 50, 0., 200.);
178  // relative isolation of the candidate muon (depending on the decay channel)
179  hists_["muonRelIso_" ] = store_->book1D("MuonRelIso" , "Iso_{Rel}(#mu)" , 50, 0., 1.);
180  // pt of the 1. leading jet (corrected to L2+L3)
181  hists_["jet1Pt_" ] = store_->book1D("Jet1Pt" , "pt_{L2L3}(jet1)" , 60, 0., 300.);
182  // pt of the 2. leading jet (corrected to L2+L3)
183  hists_["jet2Pt_" ] = store_->book1D("Jet2Pt" , "pt_{L2L3}(jet2)" , 60, 0., 300.);
184  // MET (PF)
185  hists_["metPflow_" ] = store_->book1D("METPflow" , "MET_{Pflow}" , 50, 0., 200.);
186  // MET (TC)
187  hists_["metTC_" ] = store_->book1D("METTC" , "MET_{TC}" , 50, 0., 200.);
188  // dz for muons (to suppress cosmis)
189  hists_["muonDelZ_" ] = store_->book1D("MuonDelZ" , "d_{z}(#mu)" , 50, -25., 25.);
190  // dxy for muons (to suppress cosmics)
191  hists_["muonDelXY_" ] = store_->book2D("MuonDelXY" , "d_{xy}(#mu)" , 50, -1., 1., 50, -1., 1.);
192  // lepton multiplicity after std isolation
193  hists_["lepMultIso_" ] = store_->book2D("LepMultIso" , "N_{Iso}(e) vs N_{Iso}(#mu)" , 5, 0., 5., 5, 0., 5.);
194 
195  // set axes titles for dxy for muons
196  hists_["muonDelXY_" ]->setAxisTitle( "x [cm]", 1); hists_["muonDelXY_" ]->setAxisTitle( "y [cm]", 2);
197  // set axes titles for lepton multiplicity after std isolation
198  hists_["lepMultIso_" ]->setAxisTitle( "N_{Iso}(#mu)", 1); hists_["lepMultIso_" ]->setAxisTitle( "N_{Iso}(elec)", 2);
199 
200  if( verbosity_==VERBOSE) return;
201 
202  // --- [DEBUG] --- //
203  // electron multiplicity after std isolation
204  hists_["elecMultIso_" ] = store_->book1D("ElecMultIso" , "N_{Iso}(e)" , 11, -0.5, 10.5);
205  // muon multiplicity after std isolation
206  hists_["muonMultIso_" ] = store_->book1D("MuonMultIso" , "N_{Iso}(#mu)" , 11, -0.5, 10.5);
207  // calo isolation of the candidate muon (depending on the decay channel)
208  hists_["muonCalIso_" ] = store_->book1D("MuonCalIso" , "Iso_{Cal}(#mu)" , 50, 0., 1.);
209  // track isolation of the candidate muon (depending on the decay channel)
210  hists_["muonTrkIso_" ] = store_->book1D("MuonTrkIso" , "Iso_{Trk}(#mu)" , 50, 0., 1.);
211  // calo isolation of the candidate electron (depending on the decay channel)
212  hists_["elecCalIso_" ] = store_->book1D("ElecCalIso" , "Iso_{Cal}(e)" , 50, 0., 1.);
213  // track isolation of the candidate electron (depending on the decay channel)
214  hists_["elecTrkIso_" ] = store_->book1D("ElecTrkIso" , "Iso_{Trk}(e)" , 50, 0., 1.);
215  // eta of the leading jet
216  hists_["jet1Eta_" ] = store_->book1D("Jet1Eta" , "#eta(jet1)" , 30, -5., 5.);
217  // eta of the 2. leading jet
218  hists_["jet2Eta_" ] = store_->book1D("Jet2Eta" , "#eta(jet2)" , 30, -5., 5.);
219  // pt of the 1. leading jet (not corrected)
220  hists_["jet1PtRaw_" ] = store_->book1D("Jet1PtRaw" , "pt_{Raw}(jet1)" , 60, 0., 300.);
221  // pt of the 2. leading jet (not corrected)
222  hists_["jet2PtRaw_" ] = store_->book1D("Jet2PtRaw" , "pt_{Raw}(jet2)" , 60, 0., 300.);
223  // deltaEta between the 2 leading jets
224  hists_["dEtaJet1Jet2_"] = store_->book1D("DEtaJet1Jet2", "#Delta#eta(jet1,jet2)" , 80, -4., 4.);
225  // deltaEta between the lepton and the leading jet
226  hists_["dEtaJet1Lep1_"] = store_->book1D("DEtaJet1Lep1", "#Delta#eta(jet1,lep1)" , 80, -4., 4.);
227  // deltaEta between the lepton and MET
228  hists_["dEtaLep1MET_" ] = store_->book1D("DEtaLep1MET" , "#Delta#eta(lep1,MET)" , 80, -4., 4.);
229  // deltaEta between leading jet and MET
230  hists_["dEtaJet1MET_" ] = store_->book1D("DEtaJet1MET" , "#Delta#eta(jet1,MET)" , 80, -4., 4.);
231  // deltaPhi of 2 leading jets
232  hists_["dPhiJet1Jet2_"] = store_->book1D("DPhiJet1Jet2", "#Delta#phi(jet1,jet2)" , 64, -3.2, 3.2);
233  // deltaPhi of 1. lepton and 1. jet
234  hists_["dPhiJet1Lep1_"] = store_->book1D("DPhiJet1Lep1", "#Delta#phi(jet1,lep1)" , 64, -3.2, 3.2);
235  // deltaPhi of 1. lepton and MET
236  hists_["dPhiLep1MET_" ] = store_->book1D("DPhiLep1MET" , "#Delta#phi(lep1,MET)" , 64, -3.2, 3.2);
237  // deltaPhi of 1. jet and MET
238  hists_["dPhiJet1MET_" ] = store_->book1D("DPhiJet1MET" , "#Delta#phi(jet1,MET)" , 64, -3.2, 3.2);
239  // selected dimuon events
240  hists_["diMuonLogger_"] = store_->book2D("DiMuonLogger", "Logged DiMuon Events" , 8, 0., 8., 10, 0., 10.);
241  // selected dielec events
242  hists_["diElecLogger_"] = store_->book2D("DiElecLogger", "Logged DiElec Events" , 8, 0., 8., 10, 0., 10.);
243  // selected elemu events
244  hists_["elecMuLogger_"] = store_->book2D("ElecMuLogger", "Logged ElecMu Events" , 8, 0., 8., 10, 0., 10.);
245 
246  // set bin labels for trigger monitoring
247  loggerBinLabels(std::string("diMuonLogger_"));
248  loggerBinLabels(std::string("diElecLogger_"));
249  loggerBinLabels(std::string("elecMuLogger_"));
250  return;
251  }
252 
253  void
255  {
256  // fetch trigger event if configured such
258  if(!triggerTable_.label().empty()) {
259  if( !event.getByLabel(triggerTable_, triggerTable) ) return;
260  }
261 
262  /*
263  ------------------------------------------------------------
264 
265  Run and Inst. Luminosity information (Inst. Lumi. filled now with a dummy value=5.0)
266 
267  ------------------------------------------------------------
268  */
269 
270  if (!event.eventAuxiliary().run()) return;
271  fill("RunNumb_", event.eventAuxiliary().run());
272 
273  double dummy=5.; fill("InstLumi_", dummy);
274 
275 
276  /*
277  ------------------------------------------------------------
278 
279  Muon Selection
280 
281  ------------------------------------------------------------
282  */
283 
284  // buffer isolated muons
285  std::vector<const reco::Muon*> isoMuons;
286 
288  if( !event.getByLabel(muons_, muons) ) return;
289 
290  for(edm::View<reco::Muon>::const_iterator muon=muons->begin(); muon!=muons->end(); ++muon){
291  // restrict to globalMuons
292  if( muon->isGlobalMuon() ){
293  fill("muonDelZ_" , muon->globalTrack()->vz());
294  fill("muonDelXY_", muon->globalTrack()->vx(), muon->globalTrack()->vy());
295  // apply preselection
296  if(!muonSelect_ || (*muonSelect_)(*muon)){
297  double isolationTrk = muon->pt()/(muon->pt()+muon->isolationR03().sumPt);
298  double isolationCal = muon->pt()/(muon->pt()+muon->isolationR03().emEt+muon->isolationR03().hadEt);
299  double isolationRel = (muon->isolationR03().sumPt+muon->isolationR03().emEt+muon->isolationR03().hadEt)/muon->pt();
300  fill("muonTrkIso_" , isolationTrk); fill("muonCalIso_" , isolationCal); fill("muonRelIso_" , isolationRel);
301  if(!muonIso_ || (*muonIso_)(*muon)) isoMuons.push_back(&(*muon));
302  }
303  }
304  }
305  fill("muonMultIso_", isoMuons.size());
306 
307  /*
308  ------------------------------------------------------------
309 
310  Electron Selection
311 
312  ------------------------------------------------------------
313  */
314 
315  // buffer isolated electronss
316  std::vector<const reco::GsfElectron*> isoElecs;
317  edm::Handle<edm::ValueMap<float> > electronId;
318  if(!electronId_.label().empty()) {
319  if( !event.getByLabel(electronId_, electronId) ) return;
320  }
321 
323  if( !event.getByLabel(elecs_, elecs) ) return;
324 
325  for(edm::View<reco::GsfElectron>::const_iterator elec=elecs->begin(); elec!=elecs->end(); ++elec){
326  // restrict to electrons with good electronId
327  int idx = elec-elecs->begin();
328  if( electronId_.label().empty() ? true : ((int)(*electronId)[elecs->refAt(idx)] & eidPattern_) ){
329  // apply preselection
330  if(!elecSelect_ || (*elecSelect_)(*elec)){
331  double isolationTrk = elec->pt()/(elec->pt()+elec->dr03TkSumPt());
332  double isolationCal = elec->pt()/(elec->pt()+elec->dr03EcalRecHitSumEt()+elec->dr03HcalTowerSumEt());
333  double isolationRel = (elec->dr03TkSumPt()+elec->dr03EcalRecHitSumEt()+elec->dr03HcalTowerSumEt())/elec->pt();
334  fill("elecTrkIso_" , isolationTrk); fill("elecCalIso_" , isolationCal); fill("elecRelIso_" , isolationRel);
335  if(!elecIso_ || (*elecIso_)(*elec)) isoElecs.push_back(&(*elec));
336  }
337  }
338  }
339  fill("elecMultIso_", isoElecs.size());
340 
341  /*
342  ------------------------------------------------------------
343 
344  Jet Selection
345 
346  ------------------------------------------------------------
347  */
348 
349  const JetCorrector* corrector=0;
350  if(!jetCorrector_.empty()){
351  // check whether a jet correcto is in the event setup or not
352  if(setup.find( edm::eventsetup::EventSetupRecordKey::makeKey<JetCorrectionsRecord>() )){
353  corrector = JetCorrector::getJetCorrector(jetCorrector_, setup);
354  }
355  else{
356  edm::LogVerbatim( "TopHLTDiLeptonOfflineDQM" )
357  << "\n"
358  << "------------------------------------------------------------------------------------- \n"
359  << " No JetCorrectionsRecord available from EventSetup: \n"
360  << " - Jets will not be corrected. \n"
361  << " - If you want to change this add the following lines to your cfg file: \n"
362  << " \n"
363  << " ## load jet corrections \n"
364  << " process.load(\"JetMETCorrections.Configuration.JetCorrectionServicesAllAlgos_cff\") \n"
365  << " process.prefer(\"ak5CaloL2L3\") \n"
366  << " \n"
367  << "------------------------------------------------------------------------------------- \n";
368  }
369  }
370 
371  unsigned int mult=0;
372  // buffer leadingJets
373  std::vector<reco::Jet> leadingJets;
375  if( !event.getByLabel(jets_, jets) ) return;
376 
378  if(jetIDSelect_){
379  if( !event.getByLabel(jetIDLabel_, jetID) ) return;
380  }
381 
382  for(edm::View<reco::Jet>::const_iterator jet=jets->begin(); jet!=jets->end(); ++jet){
383  unsigned int idx=jet-jets->begin();
384  if( jetIDSelect_ && dynamic_cast<const reco::CaloJet*>(jets->refAt(idx).get())){
385  if(!(*jetIDSelect_)((*jetID)[jets->refAt(idx)])) continue;
386  }
387  // chekc additional jet selection for calo, pf and bare reco jets
388  if(dynamic_cast<const reco::CaloJet*>(&*jet)){
389  reco::CaloJet sel = dynamic_cast<const reco::CaloJet&>(*jet); sel.scaleEnergy(corrector ? corrector->correction(*jet) : 1.);
390  StringCutObjectSelector<reco::CaloJet> jetSelect(jetSelect_); if(!jetSelect(sel)){ continue;}
391  }
392  else if(dynamic_cast<const reco::PFJet*>(&*jet)){
393  reco::PFJet sel= dynamic_cast<const reco::PFJet&>(*jet); sel.scaleEnergy(corrector ? corrector->correction(*jet) : 1.);
394  StringCutObjectSelector<reco::PFJet> jetSelect(jetSelect_); if(!jetSelect(sel)) continue;
395  }
396  else{
397  reco::Jet sel = *jet; sel.scaleEnergy(corrector ? corrector->correction(*jet) : 1.);
398  StringCutObjectSelector<reco::Jet> jetSelect(jetSelect_); if(!jetSelect(sel)) continue;
399  }
400  // check for overlaps
401  bool overlap=false;
402  for(std::vector<const reco::GsfElectron*>::const_iterator elec=isoElecs.begin(); elec!=isoElecs.end(); ++elec){
403  if(reco::deltaR((*elec)->eta(), (*elec)->phi(), jet->eta(), jet->phi())<0.4){overlap=true; break;}
404  } if(overlap){continue;}
405  // prepare jet to fill monitor histograms
406  reco::Jet monitorJet=*jet; monitorJet.scaleEnergy(corrector ? corrector->correction(*jet) : 1.);
407  ++mult; // determine jet multiplicity
408  if(idx==0) {
409  leadingJets.push_back(monitorJet);
410  fill("jet1Pt_" , monitorJet.pt());
411  fill("jet1PtRaw_" , jet->pt() );
412  fill("jet1Eta_" , jet->eta());
413  }
414  if(idx==1) {
415  leadingJets.push_back(monitorJet);
416  fill("jet2Pt_" , monitorJet.pt());
417  fill("jet2PtRaw_" , jet->pt() );
418  fill("jet2Eta_" , jet->eta());
419  }
420  }
421  if(leadingJets.size()>1){
422  fill("dEtaJet1Jet2_" , leadingJets[0].eta()-leadingJets[1].eta());
423  fill("dPhiJet1Jet2_" , reco::deltaPhi(leadingJets[0].phi(), leadingJets[1].phi()));
424  if( !isoMuons.empty() ){
425  if( isoElecs.empty() || isoMuons[0]->pt()>isoElecs[0]->pt() ){
426  fill("dEtaJet1Lep1_" , isoMuons[0]->eta()-leadingJets[0].eta());
427  fill("dPhiJet1Lep1_" , reco::deltaPhi(isoMuons[0]->phi() , leadingJets[0].phi()));
428  }
429  }
430  if( !isoElecs.empty() ){
431  if( isoMuons.empty() || isoElecs[0]->pt()>isoMuons[0]->pt() ){
432  fill("dEtaJet1Lep1_" , isoElecs[0]->eta()-leadingJets[0].eta());
433  fill("dPhiJet1Lep1_" , reco::deltaPhi(isoElecs[0]->phi() , leadingJets[0].phi()));
434  }
435  }
436  }
437  fill("jetMult_", mult);
438 
439  /*
440  ------------------------------------------------------------
441 
442  MET Selection
443 
444  ------------------------------------------------------------
445  */
446 
447  // buffer for event logging
448  reco::MET caloMET;
449  for(std::vector<edm::InputTag>::const_iterator met_=mets_.begin(); met_!=mets_.end(); ++met_){
450 
452  if( !event.getByLabel(*met_, met) ) continue;
453 
454  if(met->begin()!=met->end()){
455  unsigned int idx=met_-mets_.begin();
456  if(idx==0){
457  caloMET=*met->begin();
458  fill("metCalo_", met->begin()->et());
459  if(!leadingJets.empty()){
460  fill("dEtaJet1MET_" , leadingJets[0].eta()-met->begin()->eta());
461  fill("dPhiJet1MET_" , reco::deltaPhi(leadingJets[0].phi(), met->begin()->phi()));
462  }
463  if( !isoMuons.empty() ){
464  if( isoElecs.empty() || isoMuons[0]->pt()>isoElecs[0]->pt() ){
465  fill("dEtaLep1MET_" , isoMuons[0]->eta()-met->begin()->eta());
466  fill("dPhiLep1MET_" , reco::deltaPhi(isoMuons[0]->phi(), met->begin()->phi()));
467  }
468  }
469  if( !isoElecs.empty() ){
470  if( isoMuons.empty() || isoElecs[0]->pt()>isoMuons[0]->pt() ){
471  fill("dEtaLep1MET_" , isoElecs[0]->eta()-met->begin()->eta());
472  fill("dPhiLep1MET_" , reco::deltaPhi(isoElecs[0]->phi(), met->begin()->phi()));
473  }
474  }
475  }
476  if(idx==1){ fill("metTC_" , met->begin()->et());}
477  if(idx==2){ fill("metPflow_", met->begin()->et());}
478  }
479  }
480 
481 
482  /*
483  ------------------------------------------------------------
484 
485  Event Monitoring
486 
487  ------------------------------------------------------------
488  */
489 
490  // check number of isolated leptons
491  fill("lepMultIso_", isoMuons.size(), isoElecs.size());
492  // ELECMU channel
493  if( decayChannel(isoMuons, isoElecs) == ELECMU ){
494  fill("decayChannel_", 0.5);
495  double mass = (isoElecs[0]->p4()+isoMuons[0]->p4()).mass();
496  if( (lowerEdge_==-1. && upperEdge_==-1.) || (lowerEdge_<mass && mass<upperEdge_) ){
497 
498  fill("dEtaL1L2_" , isoElecs[0]->eta()-isoMuons[0]->eta());
499  fill("sumEtaL1L2_", (isoElecs[0]->eta()+isoMuons[0]->eta())/2);
500  fill("dPhiL1L2_" , reco::deltaPhi(isoElecs[0]->phi(), isoMuons[0]->eta()));
501  fill("elecPt_", isoElecs[0]->pt()); fill("muonPt_", isoMuons[0]->pt());
502  fill("lep1Pt_", isoElecs[0]->pt()>isoMuons[0]->pt() ? isoElecs[0]->pt() : isoMuons[0]->pt());
503  fill("lep2Pt_", isoElecs[0]->pt()>isoMuons[0]->pt() ? isoMuons[0]->pt() : isoElecs[0]->pt());
504  // fill plots for trigger monitoring
505  if(!triggerTable_.label().empty()) fill(event, *triggerTable, "elecMu", elecMuPaths_);
506  if(elecMuLogged_<=hists_.find("elecMuLogger_")->second->getNbinsY()){
507  // log runnumber, lumi block, event number & some
508  // more pysics infomation for interesting events
509  fill("elecMuLogger_", 0.5, elecMuLogged_+0.5, event.eventAuxiliary().run());
510  fill("elecMuLogger_", 1.5, elecMuLogged_+0.5, event.eventAuxiliary().luminosityBlock());
511  fill("elecMuLogger_", 2.5, elecMuLogged_+0.5, event.eventAuxiliary().event());
512  fill("elecMuLogger_", 3.5, elecMuLogged_+0.5, isoMuons[0]->pt());
513  fill("elecMuLogger_", 4.5, elecMuLogged_+0.5, isoElecs[0]->pt());
514  if(leadingJets.size()>0) fill("elecMuLogger_", 5.5, elecMuLogged_+0.5, leadingJets[0].pt());
515  if(leadingJets.size()>1) fill("elecMuLogger_", 6.5, elecMuLogged_+0.5, leadingJets[1].pt());
516  fill("elecMuLogger_", 7.5, elecMuLogged_+0.5, caloMET.et());
517  ++elecMuLogged_;
518  }
519  }
520  }
521 
522  // DIMUON channel
523  if( decayChannel(isoMuons, isoElecs) == DIMUON ){
524  fill("decayChannel_", 1.5);
525  int charge = isoMuons[0]->charge()*isoMuons[1]->charge();
526  double mass = (isoMuons[0]->p4()+isoMuons[1]->p4()).mass();
527 
528  fill(charge<0 ? "invMass_" : "invMassWC_" , mass );
529  fill(charge<0 ? "invMassLog_" : "invMassWCLog_" , log10(mass));
530  if((lowerEdge_==-1. && upperEdge_==-1.) || (lowerEdge_<mass && mass<upperEdge_) ){
531  fill("dEtaL1L2_" , isoMuons[0]->eta()-isoMuons[1]->eta() );
532  fill("sumEtaL1L2_", (isoMuons[0]->eta()+isoMuons[1]->eta())/2);
533  fill("dPhiL1L2_", reco::deltaPhi(isoMuons[0]->phi(),isoMuons[1]->phi()) );
534  fill("muonPt_", isoMuons[0]->pt()); fill("muonPt_", isoMuons[1]->pt());
535  fill("lep1Pt_", isoMuons[0]->pt()); fill("lep2Pt_", isoMuons[1]->pt());
536  // fill plots for trigger monitoring
537  if(!triggerTable_.label().empty()) fill(event, *triggerTable, "diMuon", diMuonPaths_);
538  if(diMuonLogged_<=hists_.find("diMuonLogger_")->second->getNbinsY()){
539  // log runnumber, lumi block, event number & some
540  // more pysics infomation for interesting events
541  fill("diMuonLogger_", 0.5, diMuonLogged_+0.5, event.eventAuxiliary().run());
542  fill("diMuonLogger_", 1.5, diMuonLogged_+0.5, event.eventAuxiliary().luminosityBlock());
543  fill("diMuonLogger_", 2.5, diMuonLogged_+0.5, event.eventAuxiliary().event());
544  fill("diMuonLogger_", 3.5, diMuonLogged_+0.5, isoMuons[0]->pt());
545  fill("diMuonLogger_", 4.5, diMuonLogged_+0.5, isoMuons[1]->pt());
546  if(leadingJets.size()>0) fill("diMuonLogger_", 5.5, diMuonLogged_+0.5, leadingJets[0].pt());
547  if(leadingJets.size()>1) fill("diMuonLogger_", 6.5, diMuonLogged_+0.5, leadingJets[1].pt());
548  fill("diMuonLogger_", 7.5, diMuonLogged_+0.5, caloMET.et());
549  ++diMuonLogged_;
550  }
551  }
552  }
553 
554  // DIELEC channel
555  if( decayChannel(isoMuons, isoElecs) == DIELEC ){
556  fill("decayChannel_", 2.5);
557  int charge = isoElecs[0]->charge()*isoElecs[1]->charge();
558  double mass = (isoElecs[0]->p4()+isoElecs[1]->p4()).mass();
559  fill(charge<0 ? "invMass_" : "invMassWC_" , mass );
560  fill(charge<0 ? "invMassLog_" : "invMassWCLog_" , log10(mass));
561  if((lowerEdge_==-1. && upperEdge_==-1.) || (lowerEdge_<mass && mass<upperEdge_) ){
562  fill("dEtaL1L2_" , isoElecs[0]->eta()-isoElecs[1]->eta() );
563  fill("sumEtaL1L2_", (isoElecs[0]->eta()+isoElecs[1]->eta())/2);
564  fill("dPhiL1L2_" , reco::deltaPhi(isoElecs[0]->phi(),isoElecs[1]->phi()) );
565  fill("elecPt_", isoElecs[0]->pt()); fill("elecPt_", isoElecs[1]->pt());
566  fill("lep1Pt_", isoElecs[0]->pt()); fill("lep2Pt_", isoElecs[1]->pt());
567  if(diElecLogged_<=hists_.find("diElecLogger_")->second->getNbinsY()){
568  // log runnumber, lumi block, event number & some
569  // more pysics infomation for interesting events
570  fill("diElecLogger_", 0.5, diElecLogged_+0.5, event.eventAuxiliary().run());
571  fill("diElecLogger_", 1.5, diElecLogged_+0.5, event.eventAuxiliary().luminosityBlock());
572  fill("diElecLogger_", 2.5, diElecLogged_+0.5, event.eventAuxiliary().event());
573  fill("diElecLogger_", 3.5, diElecLogged_+0.5, isoElecs[0]->pt());
574  fill("diElecLogger_", 4.5, diElecLogged_+0.5, isoElecs[1]->pt());
575  if(leadingJets.size()>0) fill("diElecLogger_", 5.5, diElecLogged_+0.5, leadingJets[0].pt());
576  if(leadingJets.size()>1) fill("diElecLogger_", 6.5, diElecLogged_+0.5, leadingJets[1].pt());
577  fill("diElecLogger_", 7.5, diElecLogged_+0.5, caloMET.et());
578  ++diElecLogged_;
579  }
580  }
581  }
582  }
583 
584 }
585 
586 TopHLTDiLeptonOfflineDQM::TopHLTDiLeptonOfflineDQM(const edm::ParameterSet& cfg): triggerTable_(""), vertex_(""), vertexSelect_(0), beamspotSelect_(0)
587 {
588  // configure the preselection
589  edm::ParameterSet presel=cfg.getParameter<edm::ParameterSet>("preselection");
590  if( presel.existsAs<edm::ParameterSet>("trigger") ){
591  edm::ParameterSet trigger=presel.getParameter<edm::ParameterSet>("trigger");
592  triggerTable_=trigger.getParameter<edm::InputTag>("src");
593  triggerPaths_=trigger.getParameter<std::vector<std::string> >("select");
594  }
595  if( presel.existsAs<edm::ParameterSet>("vertex" ) ){
596  edm::ParameterSet vertex=presel.getParameter<edm::ParameterSet>("vertex");
597  vertex_= vertex.getParameter<edm::InputTag>("src");
599  }
600  if( presel.existsAs<edm::ParameterSet>("beamspot" ) ){
601  edm::ParameterSet beamspot=presel.getParameter<edm::ParameterSet>("beamspot");
602  beamspot_= beamspot.getParameter<edm::InputTag>("src");
604  }
605 
606  // conifgure the selection
607  std::vector<edm::ParameterSet> sel=cfg.getParameter<std::vector<edm::ParameterSet> >("selection");
608  for(unsigned int i=0; i<sel.size(); ++i){
609  selectionOrder_.push_back(sel.at(i).getParameter<std::string>("label"));
610  selection_[selectionStep(selectionOrder_.back())] = std::make_pair(sel.at(i), new TopDiLeptonOffline::MonitorEnsemble(selectionStep(selectionOrder_.back()).c_str(), cfg.getParameter<edm::ParameterSet>("setup")));
611  }
612 }
613 
614 void
616 {
617  if(!triggerTable_.label().empty()){
619  if( !event.getByLabel(triggerTable_, triggerTable) ) return;
620  if(!acceptHLT(event, *triggerTable, triggerPaths_)) return;
621  }
622  if(!vertex_.label().empty()){
624  if( !event.getByLabel(vertex_, vertex) ) return;
625  if(vertex->empty() || !(*vertexSelect_)(vertex->front())) return;
626  }
627  if(!beamspot_.label().empty()){
629  if( !event.getByLabel(beamspot_, beamspot) ) return;
630  if(!(*beamspotSelect_)(*beamspot)) return;
631  }
632  // apply selection steps
633  for(std::vector<std::string>::const_iterator selIt=selectionOrder_.begin(); selIt!=selectionOrder_.end(); ++selIt){
634  std::string key = selectionStep(*selIt), type = objectType(*selIt);
635  if(selection_.find(key)!=selection_.end()){
636  if(type=="empty"){
637  selection_[key].second->fill(event, setup);
638  }
639  if(type=="Hlt" ){
640 // cout<<"HLT filled"<<endl;
641  selection_[key].second->fill(event, setup);
642  }
643  if(type=="muons"){
645  if(step.select(event)){
646  selection_[key].second->fill(event, setup);
647  } else break;
648  }
649  if(type=="elecs"){
651  if(step.select(event)){
652  selection_[key].second->fill(event, setup);
653  } else break;
654  }
655  if(type=="jets" ){
657  if(step.select(event, setup)){
658  selection_[key].second->fill(event, setup);
659  } else break;
660  }
661  if(type=="jets/pf" ){
663  if(step.select(event, setup)){
664  selection_[key].second->fill(event, setup);
665  } else break;
666  }
667  if(type=="jets/calo" ){
669  if(step.select(event, setup)){
670  selection_[key].second->fill(event, setup);
671  } else break;
672  }
673  if(type=="met" ){
675  if(step.select(event)){
676  selection_[key].second->fill(event, setup);
677  } else break;
678  }
679  }
680  }
681 }
682 
683 
type
Definition: HCALResponse.h:21
T getParameter(std::string const &) const
#define DEBUG
virtual double et() const GCC11_FINAL
transverse energy
int i
Definition: DBlmapReader.cc:9
StringCutObjectSelector< reco::BeamSpot > * beamspotSelect_
string cut selector
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
virtual void analyze(const edm::Event &event, const edm::EventSetup &setup)
do this during the event loop
string fill
Definition: lumiContext.py:319
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:187
Jets made from CaloTowers.
Definition: CaloJet.h:30
bool acceptHLT(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Base class for all types of Jets.
Definition: Jet.h:21
RunNumber_t run() const
virtual void scaleEnergy(double fScale)
scale energy of the jet
Definition: Jet.cc:445
std::string selectionStep(const std::string &label)
T eta() const
double charge(const std::vector< uint8_t > &Ampls)
Jets made from PFObjects.
Definition: PFJet.h:22
std::vector< std::string > selectionOrder_
edm::InputTag triggerTable_
trigger table
std::vector< std::string > triggerPaths_
trigger paths
LuminosityBlockNumber_t luminosityBlock() const
const eventsetup::EventSetupRecord * find(const eventsetup::EventSetupRecordKey &) const
Definition: EventSetup.cc:90
bool overlap(const reco::Muon &muon1, const reco::Muon &muon2, double pullX=1.0, double pullY=1.0, bool checkAdjacentChambers=false)
StringCutObjectSelector< reco::Vertex > * vertexSelect_
string cut selector
std::map< std::string, std::pair< edm::ParameterSet, TopDiLeptonOffline::MonitorEnsemble * > > selection_
Definition: MET.h:32
vector< PseudoJet > jets
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
bool first
Definition: L1TdeRCT.cc:94
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
bool select(const edm::Event &event)
apply selection
TopHLTDiLeptonOfflineDQM(const edm::ParameterSet &cfg)
default constructor
double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:12
EventAuxiliary const & eventAuxiliary() const
Definition: Event.h:65
edm::InputTag beamspot_
beamspot
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
static const JetCorrector * getJetCorrector(const std::string &fName, const edm::EventSetup &fSetup)
retrieve corrector from the event setup. troughs exception if something is missing ...
Definition: JetCorrector.cc:51
std::string const & label() const
Definition: InputTag.h:42
std::string objectType(const std::string &label)
list key
Definition: combine.py:13
tuple muons
Definition: patZpeak.py:38
edm::InputTag vertex_
primary vertex
MonitorEnsemble(const char *label, const edm::ParameterSet &cfg)
default contructor
virtual float pt() const GCC11_FINAL
transverse momentum
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
EventNumber_t event() const
Definition: DDAxes.h:10