CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  if(&triggerResults) {
86 
88 
89  //
90  //
91  // Check how many HLT triggers are in triggerResults
92  int ntrigs = triggerResults.size();
93  if (_verbose) std::cout << "ntrigs=" << ntrigs << std::endl;
94 
95  //
96  //
97  // If index=ntrigs, this HLT trigger doesn't exist in the HLT table for this data.
98  const edm::TriggerNames & triggerNames = iEvent.triggerNames(triggerResults);
99 
100  //
101  //
102  // count number of requested Jet or MB HLT paths which have fired
103  for (unsigned int i=0; i!=HLTPathsJetMBByName_.size(); i++) {
104  unsigned int triggerIndex = triggerNames.triggerIndex(HLTPathsJetMBByName_[i]);
105  if (triggerIndex<triggerResults.size()) {
106  if (triggerResults.accept(triggerIndex)) {
107  _trig_JetMB++;
108  }
109  }
110  }
111  // for empty input vectors (n==0), take all HLT triggers!
112  if (HLTPathsJetMBByName_.size()==0) _trig_JetMB=triggerResults.size()-1;
113 
114  if (_trig_JetMB==0) return;
115 
116  } else {
117 
118  edm::LogInfo("CaloMetAnalyzer") << "TriggerResults::HLT not found, "
119  "automatically select events";
120  //return;
121 
122  }
123 
124  // ==========================================================
125 
126  // **** Get the Calo Jet container
128 
129  // **** Get the SISCone Jet container
130  iEvent.getByLabel(theJetCollectionForHTMHTLabel, jetcoll);
131 
132  if(!jetcoll.isValid()) return;
133 
134  // ==========================================================
135  // Reconstructed HT & MHT Information
136 
137  int njet=0;
138  double MHx=0.;
139  double MHy=0.;
140  double MHT=0.;
141  double MHTPhi=0.;
142  double HT=0.;
143 
144  for (reco::CaloJetCollection::const_iterator calojet = jetcoll->begin(); calojet!=jetcoll->end(); ++calojet){
145  if (calojet->pt()>_ptThreshold){
146  njet++;
147  MHx += -1.*calojet->px();
148  MHy += -1.*calojet->py();
149  HT += calojet->pt();
150  }
151  }
152 
153  TVector2 *tv2 = new TVector2(MHx,MHy);
154  MHT =tv2->Mod();
155  MHTPhi=tv2->Phi();
156 
157  //std::cout << "HTMHT " << MHT << std::endl;
158 
159  hNevents->Fill(1.);
160  hNJets->Fill(njet);
161  if (njet>0){
162  hMHx->Fill(MHx);
163  hMHy->Fill(MHy);
164  hMHT->Fill(MHT);
165  hMHTPhi->Fill(MHTPhi);
166  hHT->Fill(HT);
167  }
168 
169 }
int i
Definition: DBlmapReader.cc:9
dictionary parameters
Definition: Parameters.py:2
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
Definition: Event.cc:208
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.
int njet
Definition: HydjetWrapper.h:90
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:75
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:405
#define LogTrace(id)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
static std::string const triggerResults("TriggerResults")
tuple cout
Definition: gather_cfg.py:121
Definition: HT.h:20
Definition: Run.h:41
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override