CMS 3D CMS Logo

ObjMonitor.cc
Go to the documentation of this file.
2 
4 
6 
8 
13 
14 // -----------------------------
15 // constructors and destructor
16 // -----------------------------
17 
19  folderName_ ( iConfig.getParameter<std::string>("FolderName") )
20  , metToken_ ( consumes<reco::PFMETCollection> (iConfig.getParameter<edm::InputTag>("met") ) )
21  , jetToken_ ( mayConsume<reco::PFJetCollection> (iConfig.getParameter<edm::InputTag>("jets") ) )
22  , eleToken_ ( mayConsume<reco::GsfElectronCollection>(iConfig.getParameter<edm::InputTag>("electrons") ) )
23  , muoToken_ ( mayConsume<reco::MuonCollection> (iConfig.getParameter<edm::InputTag>("muons") ) )
24  , phoToken_ ( mayConsume<reco::PhotonCollection> (iConfig.getParameter<edm::InputTag>("photons") ) )
25  , do_met_ (iConfig.getParameter<bool>("doMETHistos") )
26  , do_jet_ (iConfig.getParameter<bool>("doJetHistos") )
27  , do_ht_ (iConfig.getParameter<bool>("doHTHistos") )
28  , num_genTriggerEventFlag_(std::make_unique<GenericTriggerEventFlag>(iConfig.getParameter<edm::ParameterSet>("numGenericTriggerEventPSet"),consumesCollector(), *this))
29  , den_genTriggerEventFlag_(std::make_unique<GenericTriggerEventFlag>(iConfig.getParameter<edm::ParameterSet>("denGenericTriggerEventPSet"),consumesCollector(), *this))
30  , metSelection_ ( iConfig.getParameter<std::string>("metSelection") )
31  , jetSelection_ ( iConfig.getParameter<std::string>("jetSelection") )
32  , jetId_ ( iConfig.getParameter<std::string>("jetId") )
33  , htjetSelection_ ( iConfig.getParameter<std::string>("htjetSelection"))
34  , eleSelection_ ( iConfig.getParameter<std::string>("eleSelection") )
35  , muoSelection_ ( iConfig.getParameter<std::string>("muoSelection") )
36  , phoSelection_ ( iConfig.getParameter<std::string>("phoSelection") )
37  , njets_ ( iConfig.getParameter<int>("njets" ) )
38  , nelectrons_ ( iConfig.getParameter<int>("nelectrons" ) )
39  , nmuons_ ( iConfig.getParameter<int>("nmuons" ) )
40  , nphotons_ ( iConfig.getParameter<int>("nphotons") )
41 {
42  if (do_met_){
43  metDQM_.initialise(iConfig);
44  }
45  if (do_jet_){
46  jetDQM_.initialise(iConfig);
47  }
48  if (do_ht_ ){
49  htDQM_.initialise(iConfig);
50  }
51 }
52 
53 ObjMonitor::~ObjMonitor() = default;
54 
56  edm::Run const & iRun,
57  edm::EventSetup const & iSetup)
58 {
59 
60  std::string currentFolder = folderName_ ;
61  ibooker.setCurrentFolder(currentFolder);
62 
63  if (do_met_) metDQM_.bookHistograms(ibooker);
64  if (do_jet_) jetDQM_.bookHistograms(ibooker);
65  if (do_ht_ ) htDQM_.bookHistograms(ibooker);
66 
67  // Initialize the GenericTriggerEventFlag
68  if ( num_genTriggerEventFlag_ && num_genTriggerEventFlag_->on() ) num_genTriggerEventFlag_->initRun( iRun, iSetup );
69  if ( den_genTriggerEventFlag_ && den_genTriggerEventFlag_->on() ) den_genTriggerEventFlag_->initRun( iRun, iSetup );
70 
71 }
72 
74 
75  // Filter out events if Trigger Filtering is requested
76  if (den_genTriggerEventFlag_->on() && ! den_genTriggerEventFlag_->accept( iEvent, iSetup) ) return;
77 
79  iEvent.getByToken( metToken_, metHandle );
80  reco::PFMET pfmet = metHandle->front();
81  if ( ! metSelection_( pfmet ) ) return;
82 
83  float met = pfmet.pt();
84  float phi = pfmet.phi();
85 
87  iEvent.getByToken( jetToken_, jetHandle );
88  std::vector<reco::PFJet> jets;
89  std::vector<reco::PFJet> htjets;
90  if ( jetHandle->size() < njets_ ) return;
91  for ( auto const & j : *jetHandle ) {
92  if ( jetSelection_( j ) ) {
93  if (jetId_=="loose" || jetId_ =="tight"){
94  double abseta = abs(j.eta());
95  double NHF = j.neutralHadronEnergyFraction();
96  double NEMF = j.neutralEmEnergyFraction();
97  double CHF = j.chargedHadronEnergyFraction();
98  double CEMF = j.chargedEmEnergyFraction();
99  unsigned NumNeutralParticles =j.neutralMultiplicity();
100  unsigned CHM = j.chargedMultiplicity();
101  bool passId = (jetId_=="loose" && looseJetId(abseta,NHF,NEMF,CHF,CEMF,NumNeutralParticles,CHM)) || (jetId_=="tight" && tightJetId(abseta,NHF,NEMF,CHF,CEMF,NumNeutralParticles,CHM));
102  if (passId) jets.push_back(j);
103  }
104  else jets.push_back(j);
105  }
106  if ( htjetSelection_( j ) ) htjets.push_back(j);
107  }
108  if ( jets.size() < njets_ ) return;
109 
111  iEvent.getByToken( eleToken_, eleHandle );
112  std::vector<reco::GsfElectron> electrons;
113  if ( eleHandle->size() < nelectrons_ ) return;
114  for ( auto const & e : *eleHandle ) {
115  if ( eleSelection_( e ) ) electrons.push_back(e);
116  }
117  if ( electrons.size() < nelectrons_ ) return;
118 
120  iEvent.getByToken( muoToken_, muoHandle );
121  if ( muoHandle->size() < nmuons_ ) return;
122  std::vector<reco::Muon> muons;
123  for ( auto const & m : *muoHandle ) {
124  if ( muoSelection_( m ) ) muons.push_back(m);
125  }
126  if ( muons.size() < nmuons_ ) return;
127 
129  iEvent.getByToken( phoToken_, phoHandle );
130  if ( phoHandle->size() < nphotons_ ) return;
131  std::vector<reco::Photon> photons;
132  for ( auto const & m : *phoHandle ) {
133  if ( phoSelection_( m ) ) photons.push_back(m);
134  }
135  if ( photons.size() < nphotons_ ) return;
136 
137 
138  bool passNumCond = num_genTriggerEventFlag_->off() || num_genTriggerEventFlag_->accept( iEvent, iSetup);
139  int ls = iEvent.id().luminosityBlock();
140 
141  if (do_met_) metDQM_.fillHistograms(met,phi,ls,passNumCond);
142  if (do_jet_) jetDQM_.fillHistograms(jets,pfmet,ls,passNumCond);
143  if (do_ht_ ) htDQM_.fillHistograms(htjets,met,ls,passNumCond);
144 
145 }
146 
147 bool ObjMonitor::looseJetId(const double & abseta,
148  const double & NHF,
149  const double & NEMF,
150  const double & CHF,
151  const double & CEMF,
152  const unsigned & NumNeutralParticles,
153  const unsigned & CHM)
154 {
155  if (abseta<=2.7){
156  unsigned NumConst = CHM+NumNeutralParticles;
157 
158  return ((NumConst>1 && NHF<0.99 && NEMF<0.99) && ((abseta<=2.4 && CHF>0 && CHM>0 && CEMF<0.99) || abseta>2.4));
159  }
160  else if (abseta<=3){
161  return (NumNeutralParticles>2 && NEMF>0.01 && NHF<0.98);
162  }
163  else {
164  return NumNeutralParticles>10 && NEMF<0.90;
165  }
166 }
167 bool ObjMonitor::tightJetId(const double & abseta,
168  const double & NHF,
169  const double & NEMF,
170  const double & CHF,
171  const double & CEMF,
172  const unsigned & NumNeutralParticles,
173  const unsigned & CHM)
174 {
175  if (abseta<=2.7){
176  unsigned NumConst = CHM+NumNeutralParticles;
177  return (NumConst>1 && NHF<0.90 && NEMF<0.90 ) && ((abseta<=2.4 && CHF>0 && CHM>0 && CEMF<0.99) || abseta>2.4);
178  }
179  else if (abseta<=3){
180  return (NHF<0.98 && NEMF>0.01 && NumNeutralParticles>2);
181  }
182  else {
183  return (NEMF<0.90 && NumNeutralParticles>10);
184  }
185 }
186 
188 {
190  desc.add<std::string> ( "FolderName", "HLT/OBJ" );
191 
192  desc.add<edm::InputTag>( "met", edm::InputTag("pfMet") );
193  desc.add<edm::InputTag>( "jets", edm::InputTag("ak4PFJetsCHS") );
194  desc.add<edm::InputTag>( "electrons",edm::InputTag("gedGsfElectrons") );
195  desc.add<edm::InputTag>( "muons", edm::InputTag("muons") );
196  desc.add<edm::InputTag>( "photons", edm::InputTag("gedPhotons") );
197  desc.add<std::string>("metSelection", "pt > 0");
198  desc.add<std::string>("jetSelection", "pt > 0");
199  desc.add<std::string>("jetId", "");
200  desc.add<std::string>("htjetSelection", "pt > 30");
201  desc.add<std::string>("eleSelection", "pt > 0");
202  desc.add<std::string>("muoSelection", "pt > 0");
203  desc.add<std::string>("phoSelection", "pt > 0");
204  desc.add<int>("njets", 0);
205  desc.add<int>("nelectrons", 0);
206  desc.add<int>("nmuons", 0);
207  desc.add<int>("nphotons", 0);
208 
209  edm::ParameterSetDescription genericTriggerEventPSet;
210  genericTriggerEventPSet.add<bool>("andOr");
211  genericTriggerEventPSet.add<edm::InputTag>("dcsInputTag", edm::InputTag("scalersRawToDigi") );
212  genericTriggerEventPSet.add<std::vector<int> >("dcsPartitions",{});
213  genericTriggerEventPSet.add<bool>("andOrDcs", false);
214  genericTriggerEventPSet.add<bool>("errorReplyDcs", true);
215  genericTriggerEventPSet.add<std::string>("dbLabel","");
216  genericTriggerEventPSet.add<bool>("andOrHlt", true);
217  genericTriggerEventPSet.add<edm::InputTag>("hltInputTag", edm::InputTag("TriggerResults::HLT") );
218  genericTriggerEventPSet.add<std::vector<std::string> >("hltPaths",{});
219  genericTriggerEventPSet.add<std::string>("hltDBKey","");
220  genericTriggerEventPSet.add<bool>("errorReplyHlt",false);
221  genericTriggerEventPSet.add<unsigned int>("verbosityLevel",1);
222 
223  desc.add<edm::ParameterSetDescription>("numGenericTriggerEventPSet", genericTriggerEventPSet);
224  desc.add<edm::ParameterSetDescription>("denGenericTriggerEventPSet", genericTriggerEventPSet);
225 
226  desc.add<bool>("doMETHistos", true);
228  METDQM::fillMetDescription(histoPSet);
229  desc.add<bool>("doJetHistos", true);
230  JetDQM::fillJetDescription(histoPSet);
231  desc.add<bool>("doHTHistos", true);
232  HTDQM::fillHtDescription(histoPSet);
233 
234  desc.add<edm::ParameterSetDescription>("histoPSet",histoPSet);
235 
236  descriptions.add("objMonitoring", desc);
237 }
238 
239 // Define this as a plug-in
void fillHistograms(const double &met, const double &phi, const int &ls, const bool passCond)
Definition: METDQM.cc:39
unsigned nelectrons_
Definition: ObjMonitor.h:113
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:187
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:147
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
#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
edm::EDGetTokenT< reco::GsfElectronCollection > eleToken_
Definition: ObjMonitor.h:88
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:167
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:40
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
StringCutObjectSelector< reco::MET, true > metSelection_
Definition: ObjMonitor.h:105
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
unsigned nmuons_
Definition: ObjMonitor.h:114
unsigned nphotons_
Definition: ObjMonitor.h:115
StringCutObjectSelector< reco::Photon, true > phoSelection_
Definition: ObjMonitor.h:111
int iEvent
Definition: GenABIO.cc:230
std::string jetId_
Definition: ObjMonitor.h:107
std::unique_ptr< GenericTriggerEventFlag > num_genTriggerEventFlag_
Definition: ObjMonitor.h:102
edm::EDGetTokenT< reco::PFMETCollection > metToken_
Definition: ObjMonitor.h:86
void initialise(const edm::ParameterSet &iConfig)
Definition: METDQM.cc:7
void bookHistograms(DQMStore::IBooker &)
Definition: JetDQM.cc:23
vector< PseudoJet > jets
~ObjMonitor() override
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
StringCutObjectSelector< reco::PFJet, true > jetSelection_
Definition: ObjMonitor.h:106
std::unique_ptr< GenericTriggerEventFlag > den_genTriggerEventFlag_
Definition: ObjMonitor.h:103
std::string folderName_
Definition: ObjMonitor.h:83
bool do_met_
Definition: ObjMonitor.h:94
static void fillHtDescription(edm::ParameterSetDescription &histoPSet)
Definition: HTDQM.cc:61
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool do_jet_
Definition: ObjMonitor.h:96
edm::EDGetTokenT< reco::PhotonCollection > phoToken_
Definition: ObjMonitor.h:90
def ls(path, rec=False)
Definition: eostools.py:348
bool do_ht_
Definition: ObjMonitor.h:98
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:279
void analyze(edm::Event const &iEvent, edm::EventSetup const &iSetup) override
Definition: ObjMonitor.cc:73
met
===> hadronic RAZOR
JetDQM jetDQM_
Definition: ObjMonitor.h:97
std::vector< Photon > PhotonCollection
collectin of Photon objects
Definition: PhotonFwd.h:9
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::EventID id() const
Definition: EventBase.h:60
std::vector< PFJet > PFJetCollection
collection of PFJet objects
edm::EDGetTokenT< reco::PFJetCollection > jetToken_
Definition: ObjMonitor.h:87
fixed size matrix
HLT enums.
StringCutObjectSelector< reco::Muon, true > muoSelection_
Definition: ObjMonitor.h:110
StringCutObjectSelector< reco::PFJet, true > htjetSelection_
Definition: ObjMonitor.h:108
void fillHistograms(const std::vector< reco::PFJet > &htjets, const double &met, const int &ls, const bool passCond)
Definition: HTDQM.cc:35
edm::EDGetTokenT< reco::MuonCollection > muoToken_
Definition: ObjMonitor.h:89
unsigned njets_
Definition: ObjMonitor.h:112
double phi() const final
momentum azimuthal angle
METDQM metDQM_
Definition: ObjMonitor.h:95
ObjMonitor(const edm::ParameterSet &)
Definition: ObjMonitor.cc:18
StringCutObjectSelector< reco::GsfElectron, true > eleSelection_
Definition: ObjMonitor.h:109
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: ObjMonitor.cc:55
Definition: Run.h:43
HTDQM htDQM_
Definition: ObjMonitor.h:99
Collection of PF MET.