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