CMS 3D CMS Logo

DiJetMonitor.cc
Go to the documentation of this file.
2 
4 
6 
8 
9 
10 // -----------------------------
11 // constructors and destructor
12 // -----------------------------
13 
15 num_genTriggerEventFlag_ ( new GenericTriggerEventFlag(iConfig.getParameter<edm::ParameterSet>("numGenericTriggerEventPSet"),consumesCollector(), *this))
16 ,den_genTriggerEventFlag_ ( new GenericTriggerEventFlag(iConfig.getParameter<edm::ParameterSet>("denGenericTriggerEventPSet"),consumesCollector(), *this))
17 {
18  folderName_ = iConfig.getParameter<std::string>("FolderName");
19  dijetSrc_ = mayConsume<reco::PFJetCollection>(iConfig.getParameter<edm::InputTag>("dijetSrc"));//jet
20 
23 
24  ptcut_ = iConfig.getParameter<double>("ptcut" );
25 
26 }
27 
29  edm::Run const & iRun,
30  edm::EventSetup const & iSetup)
31 {
32 
33  std::string histname, histtitle;
34  std::string currentFolder = folderName_ ;
35  ibooker.setCurrentFolder(currentFolder);
36 
37  histname = "jetpt1"; histtitle = "leading Jet Pt";
39  setMETitle(jetpt1ME_,"Pt_1 [GeV]","events");
40 
41  histname = "jetpt2"; histtitle = "second leading Jet Pt";
43  setMETitle(jetpt2ME_,"Pt_2 [GeV]","events");
44 
45  histname = "jetptAvgB"; histtitle = "Pt average before offline selection";
47  setMETitle(jetptAvgbME_,"(pt_1 + pt_2)*0.5 [GeV]","events");
48 
49  histname = "jetptAvgA"; histtitle = "Pt average after offline selection";
51  setMETitle(jetptAvgaME_,"(pt_1 + pt_2)*0.5 [GeV]","events");
52 
53  histname = "jetptAvgAThr"; histtitle = "Pt average after offline selection";
55  setMETitle(jetptAvgaThrME_,"(pt_1 + pt_2)*0.5 [GeV]","events");
56 
57  histname = "jetptTag"; histtitle = "Tag Jet Pt";
59  setMETitle(jetptTagME_,"Pt_tag [GeV]","events ");
60 
61  histname = "jetptPrb"; histtitle = "Probe Jet Pt";
63  setMETitle(jetptPrbME_,"Pt_prb [GeV]","events");
64 
65  histname = "jetptAsym"; histtitle = "Jet Pt Asymetry";
66  bookME(ibooker,jetptAsyME_,histname,histtitle,asy_binning.nbins,asy_binning.xmin, asy_binning.xmax);
67  setMETitle(jetptAsyME_,"(pt_prb - pt_tag)/(pt_prb + pt_tag)","events");
68 
69  histname = "jetetaPrb"; histtitle = "Probe Jet eta";
71  setMETitle(jetetaPrbME_,"Eta_probe #eta","events");
72 
73  histname = "jetetaTag"; histtitle = "Tag Jet eta";
75  setMETitle(jetetaTagME_,"Eta_tag #eta","events");
76 
77  histname = "ptAsymVSetaPrb"; histtitle = "Pt_Asym vs eta_prb";
79  setMETitle(jetAsyEtaME_,"(pt_prb - pt_tag)/(pt_prb + pt_tag)","Eta_probe #eta");
80 
81  histname = "etaPrbVSphiPrb"; histtitle = "eta_prb vs phi_prb";
83  setMETitle(jetEtaPhiME_,"Eta_probe #eta","Phi_probe #phi");
84 
85  histname = "jetphiPrb"; histtitle = "Probe Jet phi";
87  setMETitle(jetphiPrbME_,"Phi_probe #phi","events");
88 
89  // Initialize the GenericTriggerEventFlag
90  // Initialize the GenericTriggerEventFlag
91  if ( num_genTriggerEventFlag_ && num_genTriggerEventFlag_->on() ) num_genTriggerEventFlag_->initRun( iRun, iSetup );
92  if ( den_genTriggerEventFlag_ && den_genTriggerEventFlag_->on() ) den_genTriggerEventFlag_->initRun( iRun, iSetup );
93 
94 }
95 
100 #include "DataFormats/Math/interface/deltaR.h" // For Delta R
102  int Event = -999;
103  Event = iEvent.id().event();
104  // Filter out events if Trigger Filtering is requested
105  if (den_genTriggerEventFlag_->on() && ! den_genTriggerEventFlag_->accept( iEvent, iSetup) ) return;
106 
107  std::vector<double> v_jetpt;
108  std::vector<double> v_jeteta;
109  std::vector<double> v_jetphi;
110 
111  v_jetpt.clear();
112  v_jeteta.clear();
113  v_jetphi.clear();
114 
116  iEvent.getByToken( dijetSrc_, offjets );
117  if (!offjets.isValid()){
118  edm::LogWarning("DiJetMonitor") << "DiJet handle not valid \n";
119  return;
120  }
121  for ( reco::PFJetCollection::const_iterator ibegin = offjets->begin(), iend = offjets->end(), ijet = ibegin; ijet != iend; ++ijet ) {
122  if (ijet->pt()< ptcut_) {continue;}
123  v_jetpt.push_back(ijet->pt());
124  v_jeteta.push_back(ijet->eta());
125  v_jetphi.push_back(ijet->phi());
126  }
127  if (v_jetpt.size() < 2) {return;}
128  double pt_1 = v_jetpt[0];
129  double eta_1 = v_jeteta[0];
130  double phi_1 = v_jetphi[0];
131  double pt_2 = v_jetpt[1];
132  double eta_2 = v_jeteta[1];
133  double phi_2 = v_jetphi[1];
134  double pt_avg_b = (pt_1 + pt_2)*0.5;
135  int tag_id = -999, probe_id = -999;
136 
137  jetpt1ME_.denominator -> Fill(pt_1);
138  jetpt2ME_.denominator -> Fill(pt_2);
139  jetptAvgbME_.denominator -> Fill(pt_avg_b);
140 
141  if( dijet_selection(eta_1, phi_1, eta_2, phi_2, pt_1, pt_2,tag_id, probe_id,Event) ){
142 
143  if(tag_id == 0 && probe_id == 1) {
144  double pt_asy = (pt_2 - pt_1)/(pt_1 + pt_2);
145  double pt_avg = (pt_1 + pt_2)*0.5;
146  jetptAvgaME_.denominator -> Fill(pt_avg);
147  jetptAvgaThrME_.denominator -> Fill(pt_avg);
148  jetptTagME_.denominator -> Fill(pt_1);
149  jetptPrbME_.denominator -> Fill(pt_2);
150  jetetaPrbME_.denominator -> Fill(eta_2);
151  jetetaTagME_.denominator -> Fill(eta_1);
152  jetptAsyME_.denominator ->Fill(pt_asy);
153  jetphiPrbME_.denominator -> Fill(phi_2);
154  jetAsyEtaME_.denominator -> Fill(pt_asy,eta_2);
155  jetEtaPhiME_.denominator -> Fill(eta_2,phi_2);
156  }
157  if(tag_id == 1 && probe_id == 0) {
158  double pt_asy = (pt_1 - pt_2)/(pt_2 + pt_1);
159  double pt_avg = (pt_2 + pt_1)*0.5;
160  jetptAvgaME_.denominator -> Fill(pt_avg);
161  jetptAvgaThrME_.denominator -> Fill(pt_avg);
162  jetptTagME_.denominator -> Fill(pt_2);
163  jetptPrbME_.denominator -> Fill(pt_1);
164  jetetaPrbME_.denominator -> Fill(eta_1);
165  jetetaTagME_.denominator -> Fill(eta_2);
166  jetptAsyME_.denominator ->Fill(pt_asy);
167  jetphiPrbME_.denominator -> Fill(phi_1);
168  jetAsyEtaME_.denominator -> Fill(pt_asy,eta_1);
169  jetEtaPhiME_.denominator -> Fill(eta_1,phi_1);
170  }
171 
172  if (num_genTriggerEventFlag_->on() && ! num_genTriggerEventFlag_->accept( iEvent, iSetup) ) return;
173 
174  jetpt1ME_.numerator -> Fill(pt_1);
175  jetpt2ME_.numerator -> Fill(pt_2);
176  jetptAvgbME_.numerator -> Fill(pt_avg_b);
177 
178  if(tag_id == 0 && probe_id == 1) {
179  double pt_asy = (pt_2 - pt_1)/(pt_1 + pt_2);
180  double pt_avg = (pt_1 + pt_2)*0.5;
181  jetptAvgaME_.numerator -> Fill(pt_avg);
182  jetptAvgaThrME_.numerator -> Fill(pt_avg);
183  jetptTagME_.numerator -> Fill(pt_1);
184  jetptPrbME_.numerator -> Fill(pt_2);
185  jetetaPrbME_.numerator -> Fill(eta_2);
186  jetetaTagME_.numerator -> Fill(eta_1);
187  jetptAsyME_.numerator ->Fill(pt_asy);
188  jetphiPrbME_.numerator -> Fill(phi_2);
189  jetAsyEtaME_.numerator -> Fill(pt_asy,eta_2);
190  jetEtaPhiME_.numerator -> Fill(eta_2,phi_2);
191  }
192  if(tag_id == 1 && probe_id == 0) {
193  double pt_asy = (pt_1 - pt_2)/(pt_2 + pt_1);
194  double pt_avg = (pt_2 + pt_1)*0.5;
195  jetptAvgaME_.numerator -> Fill(pt_avg);
196  jetptAvgaThrME_.numerator -> Fill(pt_avg);
197  jetptTagME_.numerator -> Fill(pt_2);
198  jetptPrbME_.numerator -> Fill(pt_1);
199  jetetaPrbME_.numerator -> Fill(eta_1);
200  jetetaTagME_.numerator -> Fill(eta_2);
201  jetptAsyME_.numerator ->Fill(pt_asy);
202  jetphiPrbME_.numerator -> Fill(phi_1);
203  jetAsyEtaME_.numerator -> Fill(pt_asy,eta_1);
204  jetEtaPhiME_.numerator -> Fill(eta_1,phi_1);
205  }
206  }
207 }
208 
210 {
212  desc.add<std::string> ( "FolderName", "HLT/JME/Jets/AK4/PF" );
213 
214  desc.add<edm::InputTag>( "met", edm::InputTag("pfMet") );
215  desc.add<edm::InputTag>( "dijetSrc", edm::InputTag("ak4PFJets") );
216  desc.add<edm::InputTag>( "electrons",edm::InputTag("gedGsfElectrons") );
217  desc.add<edm::InputTag>( "muons", edm::InputTag("muons") );
218  desc.add<int>("njets", 0);
219  desc.add<int>("nelectrons", 0);
220  desc.add<double>("ptcut", 20);
221 
222  edm::ParameterSetDescription genericTriggerEventPSet;
223  genericTriggerEventPSet.add<bool>("andOr");
224  genericTriggerEventPSet.add<edm::InputTag>("dcsInputTag", edm::InputTag("scalersRawToDigi") );
225  genericTriggerEventPSet.add<std::vector<int> >("dcsPartitions",{});
226  genericTriggerEventPSet.add<bool>("andOrDcs", false);
227  genericTriggerEventPSet.add<bool>("errorReplyDcs", true);
228  genericTriggerEventPSet.add<std::string>("dbLabel","");
229  genericTriggerEventPSet.add<bool>("andOrHlt", true);
230  genericTriggerEventPSet.add<edm::InputTag>("hltInputTag", edm::InputTag("TriggerResults::HLT") );
231  genericTriggerEventPSet.add<std::vector<std::string> >("hltPaths",{});
232  genericTriggerEventPSet.add<bool>("errorReplyHlt",false);
233  genericTriggerEventPSet.add<unsigned int>("verbosityLevel",1);
234 
235  desc.add<edm::ParameterSetDescription>("numGenericTriggerEventPSet", genericTriggerEventPSet);
236  desc.add<edm::ParameterSetDescription>("denGenericTriggerEventPSet", genericTriggerEventPSet);
237 
240  edm::ParameterSetDescription dijetPtThrPSet;
241  fillHistoPSetDescription(dijetPSet);
242  fillHistoPSetDescription(dijetPtThrPSet);
243  histoPSet.add<edm::ParameterSetDescription>("dijetPSet", dijetPSet);
244  histoPSet.add<edm::ParameterSetDescription>("dijetPtThrPSet", dijetPtThrPSet);
245  std::vector<double> bins = {0.,20.,40.,60.,80.,90.,100.,110.,120.,130.,140.,150.,160.,170.,180.,190.,200.,220.,240.,260.,280.,300.,350.,400.,450.,1000.}; // DiJet pT Binning
246  histoPSet.add<std::vector<double> >("jetptBinning", bins);
247 
250  histoPSet.add<edm::ParameterSetDescription>("lsPSet", lsPSet);
251  desc.add<edm::ParameterSetDescription>("histoPSet",histoPSet);
252 
253  descriptions.add("dijetMonitoring", desc);
254 }
255 
256 //---- Additional DiJet offline selection------
257 bool DiJetMonitor::dijet_selection(double eta_1, double phi_1, double eta_2, double phi_2, double pt_1, double pt_2, int &tag_id, int &probe_id, int Event){
258  double etacut = 1.7;
259  double phicut = 2.7;
260 
261  bool passeta = (std::abs(eta_1)< etacut || std::abs(eta_2) < etacut );//check that one of the jets in the barrel
262 
263  float delta_phi_1_2= (phi_1 - phi_2);
264  bool other_cuts = (std::abs(delta_phi_1_2) >= phicut); //check that jets are back to back
265 
266  if(std::abs(eta_1)<etacut && std::abs(eta_2)>etacut) {
267  tag_id = 0;
268  probe_id = 1;
269  }
270  else
271  if(std::abs(eta_2)<etacut && std::abs(eta_1)>etacut) {
272  tag_id = 1;
273  probe_id = 0;
274  }
275  else
276  if(std::abs(eta_2)<etacut && std::abs(eta_1)<etacut){
277  int numb = Event % 2;
278  if(numb==0){
279  tag_id = 0;
280  probe_id = 1;
281  }
282  if(numb==1){
283  tag_id = 1;
284  probe_id = 0;
285  }
286  }
287  if (passeta && other_cuts)
288  return true;
289  else
290  return false;
291 }
292 
293 //------------------------------------------------------------------------//
294 // Define this as a plug-in
ObjME jetetaPrbME_
Definition: DiJetMonitor.h:85
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:41
MonitorElement * numerator
std::unique_ptr< GenericTriggerEventFlag > den_genTriggerEventFlag_
Definition: DiJetMonitor.h:92
ObjME jetphiPrbME_
Definition: DiJetMonitor.h:87
static void fillHistoLSPSetDescription(edm::ParameterSetDescription &pset)
std::unique_ptr< GenericTriggerEventFlag > num_genTriggerEventFlag_
Definition: DiJetMonitor.h:91
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void analyze(edm::Event const &iEvent, edm::EventSetup const &iSetup) override
ObjME jetptPrbME_
Definition: DiJetMonitor.h:83
MEbinning dijetpt_binning_
Definition: DiJetMonitor.h:73
ObjME jetAsyEtaME_
Definition: DiJetMonitor.h:88
MEbinning asy_binning
Definition: DiJetMonitor.h:116
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: DiJetMonitor.cc:28
MEbinning dijetptThr_binning_
Definition: DiJetMonitor.h:74
Provides a code based selection for trigger and DCS information in order to have no failing filters i...
static void fillHistoPSetDescription(edm::ParameterSetDescription &pset)
ObjME jetptAvgbME_
Definition: DiJetMonitor.h:81
void setMETitle(ObjME &me, const std::string &titleX, const std::string &titleY)
DiJetMonitor(const edm::ParameterSet &)
Definition: DiJetMonitor.cc:14
ObjME jetptAsyME_
Definition: DiJetMonitor.h:84
void Fill(long long x)
edm::EDGetTokenT< reco::PFJetCollection > dijetSrc_
Definition: DiJetMonitor.h:70
static MEbinning getHistoPSet(const edm::ParameterSet &pset)
int iEvent
Definition: GenABIO.cc:230
ObjME jetetaTagME_
Definition: DiJetMonitor.h:86
MEbinning dijet_phi_binning
Definition: DiJetMonitor.h:101
MonitorElement * denominator
bool dijet_selection(double eta_1, double phi_1, double eta_2, double phi_2, double pt_1, double pt_2, int &tag_id, int &probe_id, int Event)
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
std::string folderName_
Definition: DiJetMonitor.h:64
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double ptcut_
Definition: DiJetMonitor.h:95
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:74
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:279
ObjME jetptAvgaME_
Definition: DiJetMonitor.h:79
void add(std::string const &label, ParameterSetDescription const &psetDescription)
ObjME jetptTagME_
Definition: DiJetMonitor.h:82
edm::EventID id() const
Definition: EventBase.h:60
HLT enums.
MEbinning dijet_eta_binning
Definition: DiJetMonitor.h:108
ObjME jetpt2ME_
Definition: DiJetMonitor.h:78
ObjME jetptAvgaThrME_
Definition: DiJetMonitor.h:80
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void bookME(DQMStore::IBooker &, ObjME &me, const std::string &histname, const std::string &histtitle, unsigned nbins, double xmin, double xmax)
Definition: Run.h:43
ObjME jetpt1ME_
Definition: DiJetMonitor.h:77
ObjME jetEtaPhiME_
Definition: DiJetMonitor.h:89