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  * $Date: 2010/02/24 19:08:54 $
5  * $Revision: 1.6 $
6  * \author K. Hatakeyama - Rockefeller University
7  */
8 
12 
15 
17 
22 
24 
25 #include "TVector2.h"
26 
27 #include <string>
28 using namespace edm;
29 
30 // ***********************************************************
32 
33  parameters = pSet;
34  _ptThreshold = 30.;
35 
36 }
37 
38 // ***********************************************************
40 
42 
43  evtCounter = 0;
44  metname = "HTMHTAnalyzer";
45 
46  // PFMET information
47  theJetCollectionForHTMHTLabel = parameters.getParameter<edm::InputTag>("JetCollectionForHTMHTLabel");
48  _source = parameters.getParameter<std::string>("Source");
49 
50  LogTrace(metname)<<"[HTMHTAnalyzer] Parameters initialization";
51  dbe->setCurrentFolder("JetMET/MET/"+_source);
52 
53  HLTPathsJetMBByName_ = parameters.getParameter<std::vector<std::string > >("HLTPathsJetMB");
54 
55  // misc
56  _verbose = parameters.getParameter<int>("verbose");
57  _ptThreshold = parameters.getParameter<double>("ptThreshold");
58 
59  jetME = dbe->book1D("metReco", "metReco", 4, 1, 5);
60  jetME->setBinLabel(4,"HTMHT",1);
61 
62  hNevents = dbe->book1D("METTask_Nevents", "METTask_Nevents", 1,0,1);
63  hNJets = dbe->book1D("METTask_NJets", "METTask_NJets", 100, 0, 100);
64  hMHx = dbe->book1D("METTask_MHx", "METTask_MHx", 500,-500,500);
65  hMHy = dbe->book1D("METTask_MHy", "METTask_MHy", 500,-500,500);
66  hMHT = dbe->book1D("METTask_MHT", "METTask_MHT", 500,0,1000);
67  hMHTPhi = dbe->book1D("METTask_MhTPhi", "METTask_MhTPhi", 80,-4,4);
68  hHT = dbe->book1D("METTask_HT", "METTask_HT", 500,0,2000);
69 
70 }
71 
72 
73 // ***********************************************************
75  const edm::TriggerResults& triggerResults) {
76 
77  LogTrace(metname)<<"[HTMHTAnalyzer] Analyze HT & MHT";
78 
79  jetME->Fill(4);
80 
81  // ==========================================================
82  // Trigger information
83  //
84  if(&triggerResults) {
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  } else {
116 
117  edm::LogInfo("CaloMetAnalyzer") << "TriggerResults::HLT not found, "
118  "automatically select events";
119  //return;
120 
121  }
122 
123  // ==========================================================
124 
125  // **** Get the Calo Jet container
127 
128  // **** Get the SISCone Jet container
129  iEvent.getByLabel(theJetCollectionForHTMHTLabel, jetcoll);
130 
131  if(!jetcoll.isValid()) return;
132 
133  // ==========================================================
134  // Reconstructed HT & MHT Information
135 
136  int njet=0;
137  double MHx=0.;
138  double MHy=0.;
139  double MHT=0.;
140  double MHTPhi=0.;
141  double HT=0.;
142 
143  for (reco::CaloJetCollection::const_iterator calojet = jetcoll->begin(); calojet!=jetcoll->end(); ++calojet){
144  if (calojet->pt()>_ptThreshold){
145  njet++;
146  MHx += -1.*calojet->px();
147  MHy += -1.*calojet->py();
148  HT += calojet->pt();
149  }
150  }
151 
152  TVector2 *tv2 = new TVector2(MHx,MHy);
153  MHT =tv2->Mod();
154  MHTPhi=tv2->Phi();
155 
156  //std::cout << "HTMHT " << MHT << std::endl;
157 
158  hNevents->Fill(1.);
159  hNJets->Fill(njet);
160  if (njet>0){
161  hMHx->Fill(MHx);
162  hMHy->Fill(MHy);
163  hMHT->Fill(MHT);
164  hMHTPhi->Fill(MHTPhi);
165  hHT->Fill(HT);
166  }
167 
168 }
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
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:514
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:91
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:355
#define LogTrace(id)
void beginJob(DQMStore *dbe)
Inizialize parameters for histo binning.
tuple cout
Definition: gather_cfg.py:41
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:232