CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FourVectorHLT.cc
Go to the documentation of this file.
1 // $Id: FourVectorHLT.cc,v 1.13 2010/02/17 22:53:25 wdd Exp $
2 // See header file for information.
7 
10 
13 
15 
16 using namespace edm;
17 
19  resetMe_(true), currentRun_(-99)
20 {
21  LogDebug("FourVectorHLT") << "constructor...." ;
22 
24  if ( ! dbe_ ) {
25  LogWarning("Status") << "unable to get DQMStore service?";
26  }
27  if (iConfig.getUntrackedParameter < bool > ("DQMStore", false)) {
28  dbe_->setVerbose(0);
29  }
30 
31 
32  dirname_="HLT/FourVectorHLT" ;
33 
34  if (dbe_ != 0 ) {
35  LogDebug("Status") << "Setting current directory to " << dirname_;
37  }
38 
39 
40  // plotting paramters
41  ptMin_ = iConfig.getUntrackedParameter<double>("ptMin",0.);
42  ptMax_ = iConfig.getUntrackedParameter<double>("ptMax",200.);
43  nBins_ = iConfig.getUntrackedParameter<unsigned int>("Nbins",50);
44 
45  plotAll_ = iConfig.getUntrackedParameter<bool>("plotAll", false);
46 
47  // this is the list of paths to look at.
48  std::vector<edm::ParameterSet> filters =
49  iConfig.getParameter<std::vector<edm::ParameterSet> >("filters");
50  for(std::vector<edm::ParameterSet>::iterator
51  filterconf = filters.begin() ; filterconf != filters.end();
52  filterconf++) {
53  std::string me = filterconf->getParameter<std::string>("name");
54  int objectType = filterconf->getParameter<unsigned int>("type");
55  float ptMin = filterconf->getUntrackedParameter<double>("ptMin");
56  float ptMax = filterconf->getUntrackedParameter<double>("ptMax");
57  hltPaths_.push_back(PathInfo(me, objectType, ptMin, ptMax));
58  }
59  if ( hltPaths_.size() && plotAll_) {
60  // these two ought to be mutually exclusive....
61  LogWarning("Configuration") << "Using both plotAll and a list. "
62  "list will be ignored." ;
63  hltPaths_.clear();
64  }
66  iConfig.getParameter<edm::InputTag>("triggerSummaryLabel");
67 }
68 
69 
71 {
72 
73  // do anything here that needs to be done at desctruction time
74  // (e.g. close files, deallocate resources etc.)
75 
76 }
77 
78 
79 //
80 // member functions
81 //
82 
83 // ------------ method called to for each event ------------
84 void
86 {
87  using namespace edm;
88  using namespace trigger;
89  ++nev_;
90  LogDebug("Status")<< "analyze" ;
91 
92  edm::Handle<TriggerEvent> triggerObj;
93  iEvent.getByLabel(triggerSummaryLabel_,triggerObj);
94  if(!triggerObj.isValid()) {
95  edm::LogInfo("Status") << "Summary HLT object (TriggerEvent) not found, "
96  "skipping event";
97  return;
98  }
99 
100  const trigger::TriggerObjectCollection & toc(triggerObj->getObjects());
101 
102  if ( plotAll_ ) {
103  for ( size_t ia = 0; ia < triggerObj->sizeFilters(); ++ ia) {
104  std::string fullname = triggerObj->filterTag(ia).encode();
105  // the name can have in it the module label as well as the process and
106  // other labels - strip 'em
107  std::string name;
108  size_t p = fullname.find_first_of(':');
109  if ( p != std::string::npos) {
110  name = fullname.substr(0, p);
111  }
112  else {
113  name = fullname;
114  }
115 
116  LogDebug("Parameter") << "filter " << ia << ", full name = " << fullname
117  << ", p = " << p
118  << ", abbreviated = " << name ;
119 
120  PathInfoCollection::iterator pic = hltPaths_.find(name);
121  if ( pic == hltPaths_.end() ) {
122  // doesn't exist - add it
123  MonitorElement *et(0), *eta(0), *phi(0), *etavsphi(0);
124 
125  std::string histoname(name+"_et");
126  LogDebug("Status") << "new histo with name "<< histoname ;
128  std::string title(name+" E_{T}");
129  et = dbe_->book1D(histoname.c_str(),
130  title.c_str(),nBins_, 0, 100);
131 
132  histoname = name+"_eta";
133  title = name+" #eta";
134  eta = dbe_->book1D(histoname.c_str(),
135  title.c_str(),nBins_,-2.7,2.7);
136 
137  histoname = name+"_phi";
138  title = name+" #phi";
139  phi = dbe_->book1D(histoname.c_str(),
140  title.c_str(),nBins_,-3.14,3.14);
141 
142 
143  histoname = name+"_etaphi";
144  title = name+" #eta vs #phi";
145  etavsphi = dbe_->book2D(histoname.c_str(),
146  title.c_str(),
147  nBins_,-2.7,2.7,
148  nBins_,-3.14, 3.14);
149 
150  // no idea how to get the bin boundries in this mode
151  PathInfo e(name,0, et, eta, phi, etavsphi, ptMin_,ptMax_);
152  hltPaths_.push_back(e);
153  pic = hltPaths_.begin() + hltPaths_.size()-1;
154  }
155  const trigger::Keys & k = triggerObj->filterKeys(ia);
156  for (trigger::Keys::const_iterator ki = k.begin(); ki !=k.end(); ++ki ) {
157  LogDebug("Parameters") << "pt, eta, phi = "
158  << toc[*ki].pt() << ", "
159  << toc[*ki].eta() << ", "
160  << toc[*ki].phi() ;
161  pic->getEtHisto()->Fill(toc[*ki].pt());
162  pic->getEtaHisto()->Fill(toc[*ki].eta());
163  pic->getPhiHisto()->Fill(toc[*ki].phi());
164  pic->getEtaVsPhiHisto()->Fill(toc[*ki].eta(), toc[*ki].phi());
165  }
166 
167  }
168 
169  }
170  else { // not plotAll_
171  for(PathInfoCollection::iterator v = hltPaths_.begin();
172  v!= hltPaths_.end(); ++v ) {
173  const int index = triggerObj->filterIndex(v->getName());
174  if ( index >= triggerObj->sizeFilters() ) {
175  continue; // not in this event
176  }
177  LogDebug("Status") << "filling ... " ;
178  const trigger::Keys & k = triggerObj->filterKeys(index);
179  for (trigger::Keys::const_iterator ki = k.begin(); ki !=k.end(); ++ki ) {
180  v->getEtHisto()->Fill(toc[*ki].pt());
181  v->getEtaHisto()->Fill(toc[*ki].eta());
182  v->getPhiHisto()->Fill(toc[*ki].phi());
183  v->getEtaVsPhiHisto()->Fill(toc[*ki].eta(), toc[*ki].phi());
184  }
185  }
186  }
187 }
188 
189 
190 // -- method called once each job just before starting event loop --------
191 void
193 {
194  nev_ = 0;
195  DQMStore *dbe = 0;
196  dbe = Service<DQMStore>().operator->();
197 
198  if (dbe) {
200  dbe->rmdir(dirname_);
201  }
202 
203 
204  if (dbe) {
206 
207  if ( ! plotAll_ ) {
208  for(PathInfoCollection::iterator v = hltPaths_.begin();
209  v!= hltPaths_.end(); ++v ) {
210  MonitorElement *et, *eta, *phi, *etavsphi=0;
211  std::string histoname(v->getName()+"_et");
212  std::string title(v->getName()+" E_t");
213  et = dbe->book1D(histoname.c_str(),
214  title.c_str(),nBins_,
215  v->getPtMin(),
216  v->getPtMax());
217 
218  histoname = v->getName()+"_eta";
219  title = v->getName()+" #eta";
220  eta = dbe->book1D(histoname.c_str(),
221  title.c_str(),nBins_,-2.7,2.7);
222 
223  histoname = v->getName()+"_phi";
224  title = v->getName()+" #phi";
225  phi = dbe->book1D(histoname.c_str(),
226  histoname.c_str(),nBins_,-3.14,3.14);
227 
228 
229  histoname = v->getName()+"_etaphi";
230  title = v->getName()+" #eta vs #phi";
231  etavsphi = dbe->book2D(histoname.c_str(),
232  title.c_str(),
233  nBins_,-2.7,2.7,
234  nBins_,-3.14, 3.14);
235 
236  v->setHistos( et, eta, phi, etavsphi);
237  }
238  } // ! plotAll_ - for plotAll we discover it during the event
239  }
240 }
241 
242 // - method called once each job just after ending the event loop ------------
243 void
245 {
246  LogInfo("Status") << "endJob: analyzed " << nev_ << " events";
247  return;
248 }
249 
250 
251 // BeginRun
253 {
254  LogDebug("Status") << "beginRun, run " << run.id();
255 }
256 
259 {
260  LogDebug("Status") << "endRun, run " << run.id();
261 }
#define LogDebug(id)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
RunID const & id() const
Definition: RunBase.h:41
std::string dirname_
Definition: FourVectorHLT.h:82
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:717
void rmdir(const std::string &fullpath)
Definition: DQMStore.cc:2530
virtual void endJob()
T eta() const
FourVectorHLT(const edm::ParameterSet &)
std::vector< TPRegexp > filters
Definition: eve_filter.cc:25
int iEvent
Definition: GenABIO.cc:243
void setVerbose(unsigned level)
Definition: DQMStore.cc:393
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
int k[5][pyjets_maxn]
virtual void analyze(const edm::Event &, const edm::EventSetup &)
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:83
void endRun(const edm::Run &run, const edm::EventSetup &c)
EndRun.
std::vector< size_type > Keys
PathInfoCollection hltPaths_
unsigned int nBins_
Definition: FourVectorHLT.h:78
std::vector< PathInfo >::iterator find(std::string pathName)
DQMStore * dbe_
Definition: FourVectorHLT.h:70
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:845
virtual void beginJob()
mathSSE::Vec4< T > v
void beginRun(const edm::Run &run, const edm::EventSetup &c)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
Definition: Run.h:33
edm::InputTag triggerSummaryLabel_
Definition: FourVectorHLT.h:85
Definition: DDAxes.h:10