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