CMS 3D CMS Logo

HTMHTAnalyzer.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * \author K. Hatakeyama - Rockefeller University
5  */
6 
10 
13 
15 
20 
22 
23 #include "TVector2.h"
24 
25 #include <string>
26 using namespace edm;
27 
28 // ***********************************************************
30 
31  parameters = pSet;
32  _ptThreshold = 30.;
33 
34 }
35 
36 // ***********************************************************
38 
39 
40 
42  edm::Run const & iRun,
43  edm::EventSetup const & ) {
44  evtCounter = 0;
45  metname = "HTMHTAnalyzer";
46 
47  // PFMET information
48  theJetCollectionForHTMHTLabel = parameters.getParameter<edm::InputTag>("JetCollectionForHTMHTLabel");
49  _source = parameters.getParameter<std::string>("Source");
50 
51  LogTrace(metname)<<"[HTMHTAnalyzer] Parameters initialization";
52  ibooker.setCurrentFolder("JetMET/MET/"+_source);
53 
54  HLTPathsJetMBByName_ = parameters.getParameter<std::vector<std::string > >("HLTPathsJetMB");
55 
56  // misc
57  _verbose = parameters.getParameter<int>("verbose");
58  _ptThreshold = parameters.getParameter<double>("ptThreshold");
59 
60  jetME = ibooker.book1D("metReco", "metReco", 4, 1, 5);
61  jetME->setBinLabel(4,"HTMHT",1);
62 
63  hNevents = ibooker.book1D("METTask_Nevents", "METTask_Nevents", 1,0,1);
64  hNJets = ibooker.book1D("METTask_NJets", "METTask_NJets", 100, 0, 100);
65  hMHx = ibooker.book1D("METTask_MHx", "METTask_MHx", 500,-500,500);
66  hMHy = ibooker.book1D("METTask_MHy", "METTask_MHy", 500,-500,500);
67  hMHT = ibooker.book1D("METTask_MHT", "METTask_MHT", 500,0,1000);
68  hMHTPhi = ibooker.book1D("METTask_MhTPhi", "METTask_MhTPhi", 80,-4,4);
69  hHT = ibooker.book1D("METTask_HT", "METTask_HT", 500,0,2000);
70 
71 }
72 
73 
74 // ***********************************************************
77 
78  LogTrace(metname)<<"[HTMHTAnalyzer] Analyze HT & MHT";
79 
80  jetME->Fill(4);
81 
82  // ==========================================================
83  // Trigger information
84  //
85 
87 
88  //
89  //
90  // Check how many HLT triggers are in triggerResults
91  int ntrigs = triggerResults.size();
92  if (_verbose) std::cout << "ntrigs=" << ntrigs << std::endl;
93 
94  //
95  //
96  // If index=ntrigs, this HLT trigger doesn't exist in the HLT table for this data.
97  const edm::TriggerNames & triggerNames = iEvent.triggerNames(triggerResults);
98 
99  //
100  //
101  // count number of requested Jet or MB HLT paths which have fired
102  for (unsigned int i=0; i!=HLTPathsJetMBByName_.size(); i++) {
103  unsigned int triggerIndex = triggerNames.triggerIndex(HLTPathsJetMBByName_[i]);
104  if (triggerIndex<triggerResults.size()) {
105  if (triggerResults.accept(triggerIndex)) {
106  _trig_JetMB++;
107  }
108  }
109  }
110  // for empty input vectors (n==0), take all HLT triggers!
111  if (HLTPathsJetMBByName_.size()==0) _trig_JetMB=triggerResults.size()-1;
112 
113  if (_trig_JetMB==0) return;
114 
115  // ==========================================================
116 
117  // **** Get the Calo Jet container
119 
120  // **** Get the SISCone Jet container
121  iEvent.getByLabel(theJetCollectionForHTMHTLabel, jetcoll);
122 
123  if(!jetcoll.isValid()) return;
124 
125  // ==========================================================
126  // Reconstructed HT & MHT Information
127 
128  int njet=0;
129  double MHx=0.;
130  double MHy=0.;
131  double MHT=0.;
132  double MHTPhi=0.;
133  double HT=0.;
134 
135  for (reco::CaloJetCollection::const_iterator calojet = jetcoll->begin(); calojet!=jetcoll->end(); ++calojet){
136  if (calojet->pt()>_ptThreshold){
137  njet++;
138  MHx += -1.*calojet->px();
139  MHy += -1.*calojet->py();
140  HT += calojet->pt();
141  }
142  }
143 
144  TVector2 *tv2 = new TVector2(MHx,MHy);
145  MHT =tv2->Mod();
146  MHTPhi=tv2->Phi();
147 
148  //std::cout << "HTMHT " << MHT << std::endl;
149 
150  hNevents->Fill(1.);
151  hNJets->Fill(njet);
152  if (njet>0){
153  hMHx->Fill(MHx);
154  hMHy->Fill(MHy);
155  hMHT->Fill(MHT);
156  hMHTPhi->Fill(MHTPhi);
157  hHT->Fill(HT);
158  }
159 
160 }
const std::string metname
HTMHTAnalyzer(const edm::ParameterSet &)
Constructor.
bool accept() const
Has at least one path accepted the event?
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
void analyze(const edm::Event &, const edm::EventSetup &, const edm::TriggerResults &)
Get the analysis.
virtual ~HTMHTAnalyzer()
Destructor.
int iEvent
Definition: GenABIO.cc:230
unsigned int triggerIndex(std::string const &name) const
Definition: TriggerNames.cc:32
unsigned int size() const
Get number of paths stored.
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
bool isValid() const
Definition: HandleBase.h:74
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:416
#define LogTrace(id)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
static std::string const triggerResults("TriggerResults")
HLT enums.
Definition: HT.h:21
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const override
Definition: Event.cc:239
Definition: Run.h:42
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override