CMS 3D CMS Logo

DQMHcalIsoTrackAlCaReco.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: DQMOffline/CalibCalo
4 // Class: DQMHcalIsoTrackAlCaReco
5 //
14 //
15 // Original Author: Grigory SAFRONOV
16 // Created: Tue Oct 14 16:10:31 CEST 2008
17 // Modified: Tue Mar 3 16:10:31 CEST 2015
18 //
19 //
20 
21 // system include files
22 #include <cmath>
23 #include <fstream>
24 #include <vector>
25 
26 // user include files
31 
38 
41 
43 public:
45  ~DQMHcalIsoTrackAlCaReco() override;
46 
47  void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
48  void analyze(const edm::Event &, const edm::EventSetup &) override;
49 
50 private:
52  std::vector<std::string> l1FilterTag_, hltFilterTag_;
53  std::vector<int> type_;
57 
58  double pThr_;
59 
60  std::vector<MonitorElement *> hL1Pt_, hL1Eta_, hL1phi_;
61  std::vector<MonitorElement *> hHltP_, hHltEta_, hHltPhi_;
63  std::vector<MonitorElement *> hOffP_;
65 
67  std::vector<double> etaRange_;
68  std::vector<unsigned int> indexH_;
69  std::vector<bool> ifL3_;
70 };
71 
73  folderName_ = iConfig.getParameter<std::string>("FolderName");
74  l1FilterTag_ = iConfig.getParameter<std::vector<std::string>>("L1FilterLabel");
75  hltFilterTag_ = iConfig.getParameter<std::vector<std::string>>("HltFilterLabels");
76  type_ = iConfig.getParameter<std::vector<int>>("TypeFilter");
77  labelTrigger_ = iConfig.getParameter<edm::InputTag>("TriggerLabel");
78  labelTrack_ = iConfig.getParameter<edm::InputTag>("TracksLabel");
79  pThr_ = iConfig.getUntrackedParameter<double>("pThrL3", 0);
80 
81  nTotal_ = nHLTaccepts_ = 0;
82  tokTrigger_ = consumes<trigger::TriggerEvent>(labelTrigger_);
83  tokTrack_ = consumes<reco::HcalIsolatedTrackCandidateCollection>(labelTrack_);
84  LogDebug("HcalIsoTrack") << "Folder " << folderName_ << " Input Tag for Trigger " << labelTrigger_ << " track "
85  << labelTrack_ << " threshold " << pThr_ << " with " << l1FilterTag_.size()
86  << " level 1 and " << hltFilterTag_.size() << " hlt filter tags"
87  << "\n";
88  for (unsigned int k = 0; k < l1FilterTag_.size(); ++k)
89  LogDebug("HcalIsoTrack") << "L1FilterTag[" << k << "] " << l1FilterTag_[k] << "\n";
90  for (unsigned int k = 0; k < hltFilterTag_.size(); ++k)
91  LogDebug("HcalIsoTrack") << "HLTFilterTag[" << k << "] " << hltFilterTag_[k] << "\n";
92 }
93 
95 
97  nTotal_++;
98  bool accept(false);
100  iEvent.getByToken(tokTrigger_, trEv);
101 
103  iEvent.getByToken(tokTrack_, recoIsoTracks);
104  LogDebug("HcalIsoTrack") << "Gets Trigger information with " << trEv.isValid() << " and offline tracks with "
105  << recoIsoTracks.isValid() << "\n";
106 
107  if (trEv.isValid()) {
108  const trigger::TriggerObjectCollection &TOCol(trEv->getObjects());
109  const trigger::size_type nFilt(trEv->sizeFilters());
110  // plots for L1 trigger
111  for (unsigned int k = 0; k < l1FilterTag_.size(); ++k) {
112  trigger::Keys KEYSl1;
113  double etaTrigl1(-10000), phiTrigl1(-10000), ptMaxl1(0);
114  for (trigger::size_type iFilt = 0; iFilt != nFilt; iFilt++) {
115  LogDebug("HcalIsoTrack") << trEv->filterTag(iFilt).label() << " find for " << l1FilterTag_[k] << " gives "
116  << (trEv->filterTag(iFilt).label()).find(l1FilterTag_[k]) << "\n";
117  if ((trEv->filterTag(iFilt).label()).find(l1FilterTag_[k]) != std::string::npos) {
118  KEYSl1 = trEv->filterKeys(iFilt);
119  trigger::size_type nRegl1 = KEYSl1.size();
120  LogDebug("HcalIsoTrack") << "# of objects " << nRegl1 << "\n";
121  for (trigger::size_type iReg = 0; iReg < nRegl1; iReg++) {
122  const trigger::TriggerObject &TObj(TOCol[KEYSl1[iReg]]);
123  LogDebug("HcalIsoTrack") << "Object[" << iReg << "] with pt " << TObj.pt() << " " << TObj.eta() << " "
124  << TObj.phi() << "\n";
125  if (TObj.pt() > ptMaxl1) {
126  etaTrigl1 = TObj.eta();
127  phiTrigl1 = TObj.phi();
128  ptMaxl1 = TObj.pt();
129  }
130  }
131  }
132  }
133  LogDebug("HcalIsoTrack") << "For L1 trigger type " << k << " pt " << ptMaxl1 << " eta " << etaTrigl1 << " phi "
134  << phiTrigl1 << "\n";
135  if (ptMaxl1 > 0) {
136  hL1Pt_[k]->Fill(ptMaxl1);
137  hL1Eta_[k]->Fill(etaTrigl1);
138  hL1phi_[k]->Fill(phiTrigl1);
139  }
140  }
141  // Now make plots for hlt objects
142  trigger::Keys KEYS;
143  for (unsigned l = 0; l < hltFilterTag_.size(); l++) {
144  for (trigger::size_type iFilt = 0; iFilt != nFilt; iFilt++) {
145  LogDebug("HcalIsoTrack") << trEv->filterTag(iFilt).label() << " find for " << hltFilterTag_[l] << " gives "
146  << (trEv->filterTag(iFilt).label()).find(hltFilterTag_[l]) << "\n";
147  if ((trEv->filterTag(iFilt).label()).find(hltFilterTag_[l]) != std::string::npos) {
148  KEYS = trEv->filterKeys(iFilt);
149  trigger::size_type nReg = KEYS.size();
150  LogDebug("HcalIsoTrack") << "# of objects for HLT " << nReg << "\n";
151  // checks with IsoTrack trigger results
152  for (trigger::size_type iReg = 0; iReg < nReg; iReg++) {
153  const trigger::TriggerObject &TObj(TOCol[KEYS[iReg]]);
154  LogDebug("HcalIsoTrack") << "HLT Filter Tag " << l << " trigger " << iFilt << " object " << iReg << " p "
155  << TObj.p() << " pointer " << indexH_[l] << ":" << hHltP_[indexH_[l]] << ":"
156  << hHltEta_[indexH_[l]] << ":" << hHltPhi_[indexH_[l]] << "\n";
157  if (TObj.p() > pThr_) {
158  hHltP_[indexH_[l]]->Fill(TObj.p());
159  hHltEta_[indexH_[l]]->Fill(TObj.eta());
160  hHltPhi_[indexH_[l]]->Fill(TObj.phi());
161  if (ifL3_[l])
162  accept = true;
163  if (recoIsoTracks.isValid() && ifL3_[l]) {
164  double minRecoL3dist(1000), pt(1000);
165  reco::HcalIsolatedTrackCandidateCollection::const_iterator mrtr;
166  for (mrtr = recoIsoTracks->begin(); mrtr != recoIsoTracks->end(); mrtr++) {
167  double R = deltaR(mrtr->eta(), mrtr->phi(), TObj.eta(), TObj.phi());
168  if (R < minRecoL3dist) {
169  minRecoL3dist = R;
170  pt = mrtr->pt();
171  }
172  }
173  LogDebug("HcalIsoTrack") << "Minimum R " << minRecoL3dist << " pt " << pt << ":" << TObj.pt() << "\n";
174  hL3Dr_->Fill(minRecoL3dist);
175  if (minRecoL3dist < 0.02)
176  hL3Rat_->Fill(TObj.pt() / pt);
177  }
178  }
179  }
180  }
181  }
182  }
183  }
184 
185  // general distributions
186  if (recoIsoTracks.isValid()) {
187  for (reco::HcalIsolatedTrackCandidateCollection::const_iterator itr = recoIsoTracks->begin();
188  itr != recoIsoTracks->end();
189  itr++) {
190  hMaxP_->Fill(itr->maxP());
191  hEnEcal_->Fill(itr->energyEcal());
192  std::pair<int, int> etaphi = itr->towerIndex();
193  hIeta_->Fill(etaphi.first);
194  hIphi_->Fill(etaphi.second);
195  LogDebug("HcalIsoTrack") << "Reco track p " << itr->p() << " eta|phi " << etaphi.first << "|" << etaphi.second
196  << " maxP " << itr->maxP() << " EcalE " << itr->energyEcal() << " pointers " << hHltP_[3]
197  << ":" << hHltEta_[3] << ":" << hHltPhi_[3] << "\n";
198  if (itr->p() >= pThr_) {
199  hHltP_[3]->Fill(itr->p());
200  hHltEta_[3]->Fill(itr->eta());
201  hHltPhi_[3]->Fill(itr->phi());
202  }
203  double etaAbs = std::abs(itr->eta());
204  hOffP_[0]->Fill(itr->p());
205  for (unsigned int l = 1; l < etaRange_.size(); l++) {
206  if (etaAbs >= etaRange_[l - 1] && etaAbs < etaRange_[l]) {
207  LogDebug("HcalIsoTrack") << "Range " << l << " p " << itr->p() << " pointer " << hOffP_[l];
208  hOffP_[l]->Fill(itr->p());
209  break;
210  }
211  }
212  }
213  }
214 
215  if (accept)
216  nHLTaccepts_++;
217  LogDebug("HcalIsoTrack") << "Accept " << accept << "\n";
218 }
219 
221  iBooker.setCurrentFolder(folderName_);
222  LogDebug("HcalIsoTrack") << "Set the folder to " << folderName_ << "\n";
223  char name[100], title[200];
224  for (unsigned int k = 0; k < l1FilterTag_.size(); ++k) {
225  sprintf(name, "hp%s", l1FilterTag_[k].c_str());
226  sprintf(title, "p_T of L1 object for %s", l1FilterTag_[k].c_str());
227  hL1Pt_.push_back(iBooker.book1D(name, title, 1000, 0, 1000));
228  hL1Pt_[k]->setAxisTitle("p_T (GeV)", 1);
229  sprintf(name, "heta%s", l1FilterTag_[k].c_str());
230  sprintf(title, "#eta of L1 object for %s", l1FilterTag_[k].c_str());
231  hL1Eta_.push_back(iBooker.book1D(name, title, 100, -2.5, 2.5));
232  hL1Eta_[k]->setAxisTitle("#eta", 1);
233  sprintf(name, "hphi%s", l1FilterTag_[k].c_str());
234  sprintf(title, "#phi of L1 object for %s", l1FilterTag_[k].c_str());
235  hL1phi_.push_back(iBooker.book1D(name, title, 100, -3.2, 3.2));
236  hL1phi_[k]->setAxisTitle("#phi", 1);
237  }
238 
239  std::string types[4] = {"L2", "L2x", "L3", "Off"};
240  for (unsigned int l = 0; l < 4; l++) {
241  sprintf(name, "hp%s", types[l].c_str());
242  sprintf(title, "Momentum of %s object", types[l].c_str());
243  hHltP_.push_back(iBooker.book1D(name, title, 200, 0, 1000));
244  hHltP_[l]->setAxisTitle("p (GeV)", 1);
245  sprintf(name, "heta%s", types[l].c_str());
246  sprintf(title, "#eta of %s object", types[l].c_str());
247  hHltEta_.push_back(iBooker.book1D(name, title, 16, -2, 2));
248  hHltEta_[l]->setAxisTitle("#eta", 1);
249  sprintf(name, "hphi%s", types[l].c_str());
250  sprintf(title, "#phi of %s object", types[l].c_str());
251  hHltPhi_.push_back(iBooker.book1D(name, title, 16, -3.2, 3.2));
252  hHltPhi_[l]->setAxisTitle("#phi", 1);
253  }
254  sprintf(title, "Distance of offline track from L3 object");
255  hL3Dr_ = (iBooker.book1D("hDRL3", title, 40, 0, 0.2));
256  hL3Dr_->setAxisTitle("R(#eta,#phi)", 1);
257  sprintf(title, "Ratio of p L3/Offline");
258  hL3Rat_ = (iBooker.book1D("hRatL3", title, 500, 0, 3));
259  indexH_.clear();
260  ifL3_.clear();
261  for (unsigned int l = 0; l < hltFilterTag_.size(); l++) {
262  unsigned int indx = (type_[l] >= 0 && type_[l] < 3) ? type_[l] : 0;
263  indexH_.push_back(indx);
264  ifL3_.push_back(indx == 2);
265  LogDebug("HcalIsoTrack") << "Filter[" << l << "] " << hltFilterTag_[l] << " type " << type_[l] << " index "
266  << indexH_[l] << " L3? " << ifL3_[l] << "\n";
267  }
268 
269  double etaV[6] = {0.0, 0.5, 1.0, 1.5, 2.0, 2.5};
270  for (unsigned int k = 0; k < 6; ++k) {
271  sprintf(name, "hOffP%d", k);
272  if (k == 0) {
273  sprintf(title, "p of AlCaReco object (All)");
274  } else {
275  sprintf(title, "p of AlCaReco object (%3.1f < |#eta| < %3.1f)", etaV[k - 1], etaV[k]);
276  }
277  etaRange_.push_back(etaV[k]);
278  hOffP_.push_back(iBooker.book1D(name, title, 1000, 0, 1000));
279  hOffP_[k]->setAxisTitle("E (GeV)", 1);
280  }
281  hMaxP_ = iBooker.book1D("hChgIsol", "Energy for charge isolation", 110, -10, 100);
282  hMaxP_->setAxisTitle("p (GeV)", 1);
283  hEnEcal_ = iBooker.book1D("hEnEcal", "Energy in ECAL", 100, 0, 20);
284  hEnEcal_->setAxisTitle("E (GeV)", 1);
285  hIeta_ = iBooker.book1D("hIEta", "i#eta for HCAL tower", 90, -45, 45);
286  hIeta_->setAxisTitle("i#eta", 1);
287  hIphi_ = iBooker.book1D("hIPhi", "i#phi for HCAL tower", 72, 0, 72);
288  hIphi_->setAxisTitle("i#phi", 1);
289 }
290 
std::pair< T, T > etaphi(T x, T y, T z)
Definition: FastMath.h:162
const Keys & filterKeys(trigger::size_type index) const
Definition: TriggerEvent.h:118
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::vector< MonitorElement * > hL1phi_
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
edm::EDGetTokenT< reco::HcalIsolatedTrackCandidateCollection > tokTrack_
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
void analyze(const edm::Event &, const edm::EventSetup &) override
DQMHcalIsoTrackAlCaReco(const edm::ParameterSet &)
trigger::size_type sizeFilters() const
Definition: TriggerEvent.h:146
std::vector< unsigned int > indexH_
std::vector< MonitorElement * > hHltP_
std::string const & label() const
Definition: InputTag.h:36
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:31
uint16_t size_type
const edm::InputTag filterTag(trigger::size_type index) const
Definition: TriggerEvent.h:108
T getUntrackedParameter(std::string const &, T const &) const
std::vector< double > etaRange_
void Fill(long long x)
Single trigger physics object (e.g., an isolated muon)
Definition: TriggerObject.h:21
edm::EDGetTokenT< trigger::TriggerEvent > tokTrigger_
int iEvent
Definition: GenABIO.cc:224
std::vector< MonitorElement * > hHltPhi_
std::vector< MonitorElement * > hHltEta_
std::vector< MonitorElement * > hL1Pt_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const TriggerObjectCollection & getObjects() const
Definition: TriggerEvent.h:101
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::vector< std::string > hltFilterTag_
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:75
std::vector< size_type > Keys
bool isValid() const
Definition: HandleBase.h:70
std::vector< MonitorElement * > hL1Eta_
std::vector< MonitorElement * > hOffP_
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
std::vector< std::string > l1FilterTag_
Definition: Run.h:45
#define LogDebug(id)
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)