CMS 3D CMS Logo

ObjMonitor.cc
Go to the documentation of this file.
2 
4 
6 
8 
14 
15 // -----------------------------
16 // constructors and destructor
17 // -----------------------------
18 
20  folderName_ ( iConfig.getParameter<std::string>("FolderName") )
21  , metToken_ ( consumes<reco::PFMETCollection> (iConfig.getParameter<edm::InputTag>("met") ) )
22  , jetToken_ ( mayConsume<reco::PFJetCollection> (iConfig.getParameter<edm::InputTag>("jets") ) )
23  , eleToken_ ( mayConsume<reco::GsfElectronCollection>(iConfig.getParameter<edm::InputTag>("electrons") ) )
24  , muoToken_ ( mayConsume<reco::MuonCollection> (iConfig.getParameter<edm::InputTag>("muons") ) )
25  , phoToken_ ( mayConsume<reco::PhotonCollection> (iConfig.getParameter<edm::InputTag>("photons") ) )
26  , trkToken_ ( mayConsume<reco::TrackCollection> (iConfig.getParameter<edm::InputTag>("tracks") ) )
27  , do_met_ (iConfig.getParameter<bool>("doMETHistos") )
28  , do_jet_ (iConfig.getParameter<bool>("doJetHistos") )
29  , do_ht_ (iConfig.getParameter<bool>("doHTHistos") )
30  , do_hmg_ (iConfig.getParameter<bool>("doHMesonGammaHistos") )
31  , num_genTriggerEventFlag_(std::make_unique<GenericTriggerEventFlag>(iConfig.getParameter<edm::ParameterSet>("numGenericTriggerEventPSet"),consumesCollector(), *this))
32  , den_genTriggerEventFlag_(std::make_unique<GenericTriggerEventFlag>(iConfig.getParameter<edm::ParameterSet>("denGenericTriggerEventPSet"),consumesCollector(), *this))
33  , metSelection_ ( iConfig.getParameter<std::string>("metSelection") )
34  , jetSelection_ ( iConfig.getParameter<std::string>("jetSelection") )
35  , jetId_ ( iConfig.getParameter<std::string>("jetId") )
36  , htjetSelection_ ( iConfig.getParameter<std::string>("htjetSelection"))
37  , eleSelection_ ( iConfig.getParameter<std::string>("eleSelection") )
38  , muoSelection_ ( iConfig.getParameter<std::string>("muoSelection") )
39  , phoSelection_ ( iConfig.getParameter<std::string>("phoSelection") )
40  , trkSelection_ ( iConfig.getParameter<std::string>("trkSelection") )
41  , njets_ ( iConfig.getParameter<int>("njets" ) )
42  , nelectrons_ ( iConfig.getParameter<int>("nelectrons" ) )
43  , nmuons_ ( iConfig.getParameter<int>("nmuons" ) )
44  , nphotons_ ( iConfig.getParameter<int>("nphotons") )
45  , nmesons_ ( iConfig.getParameter<int>("nmesons") )
46 {
47  if (do_met_){
48  metDQM_.initialise(iConfig);
49  }
50  if (do_jet_){
51  jetDQM_.initialise(iConfig);
52  }
53  if (do_ht_ ){
54  htDQM_.initialise(iConfig);
55  }
56  if (do_hmg_ ){
57  hmgDQM_.initialise(iConfig);
58  }
59 }
60 
61 ObjMonitor::~ObjMonitor() = default;
62 
64  edm::Run const & iRun,
65  edm::EventSetup const & iSetup)
66 {
67 
68  std::string currentFolder = folderName_ ;
69  ibooker.setCurrentFolder(currentFolder);
70 
71  if (do_met_) metDQM_.bookHistograms(ibooker);
72  if (do_jet_) jetDQM_.bookHistograms(ibooker);
73  if (do_ht_ ) htDQM_.bookHistograms(ibooker);
74  if (do_hmg_ ) hmgDQM_.bookHistograms(ibooker);
75 
76  // Initialize the GenericTriggerEventFlag
77  if ( num_genTriggerEventFlag_ && num_genTriggerEventFlag_->on() ) num_genTriggerEventFlag_->initRun( iRun, iSetup );
78  if ( den_genTriggerEventFlag_ && den_genTriggerEventFlag_->on() ) den_genTriggerEventFlag_->initRun( iRun, iSetup );
79 
80 }
81 
83 
84  // Filter out events if Trigger Filtering is requested
85  if (den_genTriggerEventFlag_->on() && ! den_genTriggerEventFlag_->accept( iEvent, iSetup) ) return;
86 
88  iEvent.getByToken( metToken_, metHandle );
89  reco::PFMET pfmet = metHandle->front();
90  if ( ! metSelection_( pfmet ) ) return;
91 
92  float met = pfmet.pt();
93  float phi = pfmet.phi();
94 
96  iEvent.getByToken( jetToken_, jetHandle );
97  std::vector<reco::PFJet> jets;
98  std::vector<reco::PFJet> htjets;
99  if ( jetHandle->size() < njets_ ) return;
100  for ( auto const & j : *jetHandle ) {
101  if ( jetSelection_( j ) ) {
102  if (jetId_=="loose" || jetId_ =="tight"){
103  double abseta = abs(j.eta());
104  double NHF = j.neutralHadronEnergyFraction();
105  double NEMF = j.neutralEmEnergyFraction();
106  double CHF = j.chargedHadronEnergyFraction();
107  double CEMF = j.chargedEmEnergyFraction();
108  unsigned NumNeutralParticles =j.neutralMultiplicity();
109  unsigned CHM = j.chargedMultiplicity();
110  bool passId = (jetId_=="loose" && looseJetId(abseta,NHF,NEMF,CHF,CEMF,NumNeutralParticles,CHM)) || (jetId_=="tight" && tightJetId(abseta,NHF,NEMF,CHF,CEMF,NumNeutralParticles,CHM));
111  if (passId) jets.push_back(j);
112  }
113  else jets.push_back(j);
114  }
115  if ( htjetSelection_( j ) ) htjets.push_back(j);
116  }
117  if ( jets.size() < njets_ ) return;
118 
120  iEvent.getByToken( eleToken_, eleHandle );
121  std::vector<reco::GsfElectron> electrons;
122  if ( eleHandle->size() < nelectrons_ ) return;
123  for ( auto const & e : *eleHandle ) {
124  if ( eleSelection_( e ) ) electrons.push_back(e);
125  }
126  if ( electrons.size() < nelectrons_ ) return;
127 
129  iEvent.getByToken( muoToken_, muoHandle );
130  if ( muoHandle->size() < nmuons_ ) return;
131  std::vector<reco::Muon> muons;
132  for ( auto const & m : *muoHandle ) {
133  if ( muoSelection_( m ) ) muons.push_back(m);
134  }
135  if ( muons.size() < nmuons_ ) return;
136 
138  iEvent.getByToken( phoToken_, phoHandle );
139  if ( phoHandle->size() < nphotons_ ) return;
140  std::vector<reco::Photon> photons;
141  for ( auto const & m : *phoHandle ) {
142  if ( phoSelection_( m ) ) photons.push_back(m);
143  }
144  if ( photons.size() < nphotons_ ) return;
145 
146  std::vector<TLorentzVector> passedMesons;
147  if (do_hmg_ ) {
149  iEvent.getByToken( trkToken_, trkHandle );
150  // find isolated mesons (phi or rho)
151  TLorentzVector t1,t2;
152  float hadronMassHyp[2] = {0.1396,0.4937}; // pi or K mass
153  float loMassLim[2] = {0.5,0.9}; // rho or phi mass
154  float hiMassLim[2] = {1.0,1.11}; // rho or phi mass
155 
156  for (size_t i = 0; i < trkHandle->size(); ++i){
157  const reco::Track trk1 = trkHandle->at(i);
158  if (!trkSelection_(trk1)) continue;
159  for (size_t j = i+1; j < trkHandle->size(); ++j){
160  const reco::Track trk2 = trkHandle->at(j);
161  if (!trkSelection_(trk2)) continue;
162  if (trk1.charge() * trk2.charge() != -1) continue;
163 
164  for (unsigned hyp = 0; hyp < 2; ++hyp){
165 
166  t1.SetPtEtaPhiM(trk1.pt(),trk1.eta(),trk1.phi(),hadronMassHyp[hyp]);
167  t2.SetPtEtaPhiM(trk2.pt(),trk2.eta(),trk2.phi(),hadronMassHyp[hyp]);
168  TLorentzVector mesCand = t1 + t2;
169 
170  // cuts
171  if (mesCand.M() < loMassLim[hyp] || mesCand.M() > hiMassLim[hyp]) continue; //mass
172  if (mesCand.Pt() < 35. || fabs(mesCand.Rapidity()) > 2.1 ) continue; //pT eta
173 
174  // isolation
175  float absIso = 0.;
176  for (size_t k = 0; k < trkHandle->size(); ++k){
177  if (k == i || k == j) continue;
178  const reco::Track trkN = trkHandle->at(k);
179  if (trkN.charge() == 0 || trkN.pt() < 0.5 ||
180  ( trkN.dz() > 0.1 ) ||
181  deltaR(trkN.eta(),trkN.phi(),mesCand.Eta(),mesCand.Phi()) > 0.5) continue;
182  absIso += trkN.pt();
183  }
184  if (absIso/mesCand.Pt() > 0.2) continue;
185  passedMesons.push_back(mesCand);
186  }
187  }
188  }
189  if ( passedMesons.size() < nmesons_ ) return;
190  }
191 
192  bool passNumCond = num_genTriggerEventFlag_->off() || num_genTriggerEventFlag_->accept( iEvent, iSetup);
193  int ls = iEvent.id().luminosityBlock();
194 
195  if (do_met_) metDQM_.fillHistograms(met,phi,ls,passNumCond);
196  if (do_jet_) jetDQM_.fillHistograms(jets,pfmet,ls,passNumCond);
197  if (do_ht_ ) htDQM_.fillHistograms(htjets,met,ls,passNumCond);
198  if (do_hmg_ ) hmgDQM_.fillHistograms(photons,passedMesons,ls,passNumCond);
199 
200 }
201 
202 bool ObjMonitor::looseJetId(const double & abseta,
203  const double & NHF,
204  const double & NEMF,
205  const double & CHF,
206  const double & CEMF,
207  const unsigned & NumNeutralParticles,
208  const unsigned & CHM)
209 {
210  if (abseta<=2.7){
211  unsigned NumConst = CHM+NumNeutralParticles;
212 
213  return ((NumConst>1 && NHF<0.99 && NEMF<0.99) && ((abseta<=2.4 && CHF>0 && CHM>0 && CEMF<0.99) || abseta>2.4));
214  }
215  else if (abseta<=3){
216  return (NumNeutralParticles>2 && NEMF>0.01 && NHF<0.98);
217  }
218  else {
219  return NumNeutralParticles>10 && NEMF<0.90;
220  }
221 }
222 bool ObjMonitor::tightJetId(const double & abseta,
223  const double & NHF,
224  const double & NEMF,
225  const double & CHF,
226  const double & CEMF,
227  const unsigned & NumNeutralParticles,
228  const unsigned & CHM)
229 {
230  if (abseta<=2.7){
231  unsigned NumConst = CHM+NumNeutralParticles;
232  return (NumConst>1 && NHF<0.90 && NEMF<0.90 ) && ((abseta<=2.4 && CHF>0 && CHM>0 && CEMF<0.99) || abseta>2.4);
233  }
234  else if (abseta<=3){
235  return (NHF<0.98 && NEMF>0.01 && NumNeutralParticles>2);
236  }
237  else {
238  return (NEMF<0.90 && NumNeutralParticles>10);
239  }
240 }
241 
243 {
245  desc.add<std::string> ( "FolderName", "HLT/OBJ" );
246 
247  desc.add<edm::InputTag>( "met", edm::InputTag("pfMet") );
248  desc.add<edm::InputTag>( "jets", edm::InputTag("ak4PFJetsCHS") );
249  desc.add<edm::InputTag>( "electrons",edm::InputTag("gedGsfElectrons") );
250  desc.add<edm::InputTag>( "muons", edm::InputTag("muons") );
251  desc.add<edm::InputTag>( "photons", edm::InputTag("gedPhotons") );
252  desc.add<edm::InputTag>( "tracks", edm::InputTag("generalTracks") );
253  desc.add<std::string>("metSelection", "pt > 0");
254  desc.add<std::string>("jetSelection", "pt > 0");
255  desc.add<std::string>("jetId", "");
256  desc.add<std::string>("htjetSelection", "pt > 30");
257  desc.add<std::string>("eleSelection", "pt > 0");
258  desc.add<std::string>("muoSelection", "pt > 0");
259  desc.add<std::string>("phoSelection", "pt > 0");
260  desc.add<std::string>("trkSelection", "pt > 0");
261  desc.add<int>("njets", 0);
262  desc.add<int>("nelectrons", 0);
263  desc.add<int>("nmuons", 0);
264  desc.add<int>("nphotons", 0);
265  desc.add<int>("nmesons", 0);
266 
267  edm::ParameterSetDescription genericTriggerEventPSet;
268  genericTriggerEventPSet.add<bool>("andOr");
269  genericTriggerEventPSet.add<edm::InputTag>("dcsInputTag", edm::InputTag("scalersRawToDigi") );
270  genericTriggerEventPSet.add<std::vector<int> >("dcsPartitions",{});
271  genericTriggerEventPSet.add<bool>("andOrDcs", false);
272  genericTriggerEventPSet.add<bool>("errorReplyDcs", true);
273  genericTriggerEventPSet.add<std::string>("dbLabel","");
274  genericTriggerEventPSet.add<bool>("andOrHlt", true);
275  genericTriggerEventPSet.add<edm::InputTag>("hltInputTag", edm::InputTag("TriggerResults::HLT") );
276  genericTriggerEventPSet.add<std::vector<std::string> >("hltPaths",{});
277  genericTriggerEventPSet.add<std::string>("hltDBKey","");
278  genericTriggerEventPSet.add<bool>("errorReplyHlt",false);
279  genericTriggerEventPSet.add<unsigned int>("verbosityLevel",1);
280 
281  desc.add<edm::ParameterSetDescription>("numGenericTriggerEventPSet", genericTriggerEventPSet);
282  desc.add<edm::ParameterSetDescription>("denGenericTriggerEventPSet", genericTriggerEventPSet);
283 
284  desc.add<bool>("doMETHistos", true);
286  METDQM::fillMetDescription(histoPSet);
287  desc.add<bool>("doJetHistos", true);
288  JetDQM::fillJetDescription(histoPSet);
289  desc.add<bool>("doHTHistos", true);
290  HTDQM::fillHtDescription(histoPSet);
291  desc.add<bool>("doHMesonGammaHistos", true);
293 
294  desc.add<edm::ParameterSetDescription>("histoPSet",histoPSet);
295 
296  descriptions.add("objMonitoring", desc);
297 }
298 
299 // Define this as a plug-in
void fillHistograms(const double &met, const double &phi, const int &ls, const bool passCond)
Definition: METDQM.cc:39
edm::EDGetTokenT< reco::TrackCollection > trkToken_
Definition: ObjMonitor.h:92
unsigned nelectrons_
Definition: ObjMonitor.h:119
void initialise(const edm::ParameterSet &iConfig)
Definition: JetDQM.cc:8
void fillHistograms(const std::vector< reco::PFJet > &jets, const reco::PFMET &pfmet, const int &ls, const bool passCond)
Definition: JetDQM.cc:90
void bookHistograms(DQMStore::IBooker &)
Definition: METDQM.cc:16
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: ObjMonitor.cc:242
bool looseJetId(const double &abseta, const double &NHF, const double &NEMF, const double &CHF, const double &CEMF, const unsigned &NumNeutralParticles, const unsigned &CHM)
Definition: ObjMonitor.cc:202
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
static void fillJetDescription(edm::ParameterSetDescription &histoPSet)
Definition: JetDQM.cc:180
void bookHistograms(DQMStore::IBooker &)
Definition: HTDQM.cc:16
static void fillMetDescription(edm::ParameterSetDescription &histoPSet)
Definition: METDQM.cc:62
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
edm::EDGetTokenT< reco::GsfElectronCollection > eleToken_
Definition: ObjMonitor.h:89
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:645
double pt() const final
transverse momentum
Provides a code based selection for trigger and DCS information in order to have no failing filters i...
void initialise(const edm::ParameterSet &iConfig)
Definition: HTDQM.cc:7
bool tightJetId(const double &abseta, const double &NHF, const double &NEMF, const double &CHF, const double &CEMF, const unsigned &NumNeutralParticles, const unsigned &CHM)
Definition: ObjMonitor.cc:222
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:40
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
StringCutObjectSelector< reco::MET, true > metSelection_
Definition: ObjMonitor.h:109
static void fillHmgDescription(edm::ParameterSetDescription &histoPSet)
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
unsigned nmuons_
Definition: ObjMonitor.h:120
unsigned nphotons_
Definition: ObjMonitor.h:121
void initialise(const edm::ParameterSet &iConfig)
StringCutObjectSelector< reco::Photon, true > phoSelection_
Definition: ObjMonitor.h:115
int iEvent
Definition: GenABIO.cc:230
std::string jetId_
Definition: ObjMonitor.h:111
std::unique_ptr< GenericTriggerEventFlag > num_genTriggerEventFlag_
Definition: ObjMonitor.h:106
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:651
edm::EDGetTokenT< reco::PFMETCollection > metToken_
Definition: ObjMonitor.h:87
void initialise(const edm::ParameterSet &iConfig)
Definition: METDQM.cc:7
void bookHistograms(DQMStore::IBooker &)
Definition: JetDQM.cc:23
vector< PseudoJet > jets
double pt() const
track transverse momentum
Definition: TrackBase.h:621
~ObjMonitor() override
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
StringCutObjectSelector< reco::PFJet, true > jetSelection_
Definition: ObjMonitor.h:110
std::unique_ptr< GenericTriggerEventFlag > den_genTriggerEventFlag_
Definition: ObjMonitor.h:107
std::string folderName_
Definition: ObjMonitor.h:84
bool do_met_
Definition: ObjMonitor.h:96
static void fillHtDescription(edm::ParameterSetDescription &histoPSet)
Definition: HTDQM.cc:61
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool do_jet_
Definition: ObjMonitor.h:98
edm::EDGetTokenT< reco::PhotonCollection > phoToken_
Definition: ObjMonitor.h:91
void bookHistograms(DQMStore::IBooker &)
int k[5][pyjets_maxn]
StringCutObjectSelector< reco::Track, true > trkSelection_
Definition: ObjMonitor.h:116
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
Definition: TrackBase.h:609
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
def ls(path, rec=False)
Definition: eostools.py:348
bool do_ht_
Definition: ObjMonitor.h:100
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
void analyze(edm::Event const &iEvent, edm::EventSetup const &iSetup) override
Definition: ObjMonitor.cc:82
met
===> hadronic RAZOR
JetDQM jetDQM_
Definition: ObjMonitor.h:99
std::vector< Photon > PhotonCollection
collectin of Photon objects
Definition: PhotonFwd.h:9
unsigned nmesons_
Definition: ObjMonitor.h:122
HMesonGammaDQM hmgDQM_
Definition: ObjMonitor.h:103
void add(std::string const &label, ParameterSetDescription const &psetDescription)
bool do_hmg_
Definition: ObjMonitor.h:102
edm::EventID id() const
Definition: EventBase.h:60
std::vector< PFJet > PFJetCollection
collection of PFJet objects
edm::EDGetTokenT< reco::PFJetCollection > jetToken_
Definition: ObjMonitor.h:88
fixed size matrix
HLT enums.
StringCutObjectSelector< reco::Muon, true > muoSelection_
Definition: ObjMonitor.h:114
void fillHistograms(const reco::PhotonCollection &photons, std::vector< TLorentzVector > mesons, const int &ls, const bool passCond)
StringCutObjectSelector< reco::PFJet, true > htjetSelection_
Definition: ObjMonitor.h:112
void fillHistograms(const std::vector< reco::PFJet > &htjets, const double &met, const int &ls, const bool passCond)
Definition: HTDQM.cc:35
int charge() const
track electric charge
Definition: TrackBase.h:567
edm::EDGetTokenT< reco::MuonCollection > muoToken_
Definition: ObjMonitor.h:90
unsigned njets_
Definition: ObjMonitor.h:118
double phi() const final
momentum azimuthal angle
METDQM metDQM_
Definition: ObjMonitor.h:97
ObjMonitor(const edm::ParameterSet &)
Definition: ObjMonitor.cc:19
StringCutObjectSelector< reco::GsfElectron, true > eleSelection_
Definition: ObjMonitor.h:113
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: ObjMonitor.cc:63
Definition: Run.h:44
HTDQM htDQM_
Definition: ObjMonitor.h:101
Collection of PF MET.