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 
40 
41  evtCounter = 0;
42  metname = "HTMHTAnalyzer";
43 
44  // PFMET information
45  theJetCollectionForHTMHTLabel = parameters.getParameter<edm::InputTag>("JetCollectionForHTMHTLabel");
46  _source = parameters.getParameter<std::string>("Source");
47 
48  LogTrace(metname)<<"[HTMHTAnalyzer] Parameters initialization";
49  dbe->setCurrentFolder("JetMET/MET/"+_source);
50 
51  HLTPathsJetMBByName_ = parameters.getParameter<std::vector<std::string > >("HLTPathsJetMB");
52 
53  // misc
54  _verbose = parameters.getParameter<int>("verbose");
55  _ptThreshold = parameters.getParameter<double>("ptThreshold");
56 
57  jetME = dbe->book1D("metReco", "metReco", 4, 1, 5);
58  jetME->setBinLabel(4,"HTMHT",1);
59 
60  hNevents = dbe->book1D("METTask_Nevents", "METTask_Nevents", 1,0,1);
61  hNJets = dbe->book1D("METTask_NJets", "METTask_NJets", 100, 0, 100);
62  hMHx = dbe->book1D("METTask_MHx", "METTask_MHx", 500,-500,500);
63  hMHy = dbe->book1D("METTask_MHy", "METTask_MHy", 500,-500,500);
64  hMHT = dbe->book1D("METTask_MHT", "METTask_MHT", 500,0,1000);
65  hMHTPhi = dbe->book1D("METTask_MhTPhi", "METTask_MhTPhi", 80,-4,4);
66  hHT = dbe->book1D("METTask_HT", "METTask_HT", 500,0,2000);
67 
68 }
69 
70 
71 // ***********************************************************
74 
75  LogTrace(metname)<<"[HTMHTAnalyzer] Analyze HT & MHT";
76 
77  jetME->Fill(4);
78 
79  // ==========================================================
80  // Trigger information
81  //
82  if(&triggerResults) {
83 
85 
86  //
87  //
88  // Check how many HLT triggers are in triggerResults
89  int ntrigs = triggerResults.size();
90  if (_verbose) std::cout << "ntrigs=" << ntrigs << std::endl;
91 
92  //
93  //
94  // If index=ntrigs, this HLT trigger doesn't exist in the HLT table for this data.
95  const edm::TriggerNames & triggerNames = iEvent.triggerNames(triggerResults);
96 
97  //
98  //
99  // count number of requested Jet or MB HLT paths which have fired
100  for (unsigned int i=0; i!=HLTPathsJetMBByName_.size(); i++) {
101  unsigned int triggerIndex = triggerNames.triggerIndex(HLTPathsJetMBByName_[i]);
102  if (triggerIndex<triggerResults.size()) {
103  if (triggerResults.accept(triggerIndex)) {
104  _trig_JetMB++;
105  }
106  }
107  }
108  // for empty input vectors (n==0), take all HLT triggers!
109  if (HLTPathsJetMBByName_.size()==0) _trig_JetMB=triggerResults.size()-1;
110 
111  if (_trig_JetMB==0) return;
112 
113  } else {
114 
115  edm::LogInfo("CaloMetAnalyzer") << "TriggerResults::HLT not found, "
116  "automatically select events";
117  //return;
118 
119  }
120 
121  // ==========================================================
122 
123  // **** Get the Calo Jet container
125 
126  // **** Get the SISCone Jet container
127  iEvent.getByLabel(theJetCollectionForHTMHTLabel, jetcoll);
128 
129  if(!jetcoll.isValid()) return;
130 
131  // ==========================================================
132  // Reconstructed HT & MHT Information
133 
134  int njet=0;
135  double MHx=0.;
136  double MHy=0.;
137  double MHT=0.;
138  double MHTPhi=0.;
139  double HT=0.;
140 
141  for (reco::CaloJetCollection::const_iterator calojet = jetcoll->begin(); calojet!=jetcoll->end(); ++calojet){
142  if (calojet->pt()>_ptThreshold){
143  njet++;
144  MHx += -1.*calojet->px();
145  MHy += -1.*calojet->py();
146  HT += calojet->pt();
147  }
148  }
149 
150  TVector2 *tv2 = new TVector2(MHx,MHy);
151  MHT =tv2->Mod();
152  MHTPhi=tv2->Phi();
153 
154  //std::cout << "HTMHT " << MHT << std::endl;
155 
156  hNevents->Fill(1.);
157  hNJets->Fill(njet);
158  if (njet>0){
159  hMHx->Fill(MHx);
160  hMHy->Fill(MHy);
161  hMHT->Fill(MHT);
162  hMHTPhi->Fill(MHTPhi);
163  hHT->Fill(HT);
164  }
165 
166 }
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:204
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:873
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:243
unsigned int triggerIndex(std::string const &name) const
Definition: TriggerNames.cc:32
unsigned int size() const
Get number of paths stored.
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
#define LogTrace(id)
static std::string const triggerResults("TriggerResults")
void beginJob(DQMStore *dbe)
Inizialize parameters for histo binning.
tuple cout
Definition: gather_cfg.py:121
Definition: HT.h:20
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:585