CMS 3D CMS Logo

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