CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTMonHcalIsoTrack.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HLTriggerOffline/special
4 // Class: DQMHcalIsoTrackAlCaRaw
5 //
13 //
14 // Original Author: Grigory SAFRONOV
15 // Created: Mon Oct 6 10:10:22 CEST 2008
16 // $Id: HLTMonHcalIsoTrack.cc,v 1.5 2010/08/07 14:55:56 wmtan Exp $
17 //
18 //
19 
20 
21 // user include files
22 
26 
29 
32 
35 
37 
38 double HLTMonHcalIsoTrack::getDist(double eta1, double phi1, double eta2, double phi2)
39 {
40  double dphi = fabs(phi1 - phi2);
41  if(dphi>acos(-1)) dphi = 2*acos(-1)-dphi;
42  double dr = sqrt(dphi*dphi + pow(eta1-eta2,2));
43  return dr;
44 }
45 
46 std::pair<int,int> HLTMonHcalIsoTrack::towerIndex(double eta, double phi)
47 {
48  int ieta = 0;
49  int iphi = 0;
50  if (eta!=0)
51  {
52  for (int i=1; i<21; i++)
53  {
54  if (fabs(eta)<(i*0.087)&&fabs(eta)>(i-1)*0.087) ieta=int(fabs(eta)/eta)*i;
55  }
56  if (fabs(eta)>1.740&&fabs(eta)<=1.830) ieta=int(fabs(eta)/eta)*21;
57  if (fabs(eta)>1.830&&fabs(eta)<=1.930) ieta=int(fabs(eta)/eta)*22;
58  if (fabs(eta)>1.930&&fabs(eta)<=2.043) ieta=int(fabs(eta)/eta)*23;
59  if (fabs(eta)>2.043&&fabs(eta)<=2.172) ieta=int(fabs(eta)/eta)*24;
60  }
61 
62  double delta=phi+0.174532925;
63  if (delta<0) delta=delta+2*acos(-1);
64  if (fabs(eta)<1.740)
65  {
66  for (int i=0; i<72; i++)
67  {
68  if (delta<(i+1)*0.087266462&&delta>i*0.087266462) iphi=i;
69  }
70  }
71  else
72  {
73  for (int i=0; i<36; i++)
74  {
75  if (delta<2*(i+1)*0.087266462&&delta>2*i*0.087266462) iphi=2*i;
76  }
77  }
78 
79  return std::pair<int,int>(ieta,iphi);
80 }
81 
82 
84 {
85  folderName_ = iConfig.getParameter<std::string>("folderName");
86  outRootFileName_=iConfig.getParameter<std::string>("outputRootFileName");
87 
88  useProducerCollections_=iConfig.getParameter<bool>("useProducerCollections");
89  hltRAWEventTag_=iConfig.getParameter<std::string>("hltRAWTriggerEventLabel");
90  hltAODEventTag_=iConfig.getParameter<std::string>("hltAODTriggerEventLabel");
91 
92  hltProcess_=iConfig.getParameter<std::string>("hltProcessName");
93 
94  saveToRootFile_=iConfig.getParameter<bool>("SaveToRootFile");
95 
96  triggers = iConfig.getParameter<std::vector<edm::ParameterSet> >("triggers");
97  for (std::vector<edm::ParameterSet>::iterator inTrig = triggers.begin(); inTrig != triggers.end(); inTrig++)
98  {
99  trigNames_.push_back(inTrig->getParameter<std::string>("triggerName"));
100  l1filterLabels_.push_back(inTrig->getParameter<std::string>("hltL1filterLabel"));
101  l2filterLabels_.push_back(inTrig->getParameter<std::string>("hltL2filterLabel"));
102  l3filterLabels_.push_back(inTrig->getParameter<std::string>("hltL3filterLabel"));
103  l2collectionLabels_.push_back(inTrig->getParameter<std::string>("l2collectionLabel"));
104  l3collectionLabels_.push_back(inTrig->getParameter<std::string>("l3collectionLabel"));
105  }
106 }
107 
108 
110 {}
111 
113 {
116  iEvent.getByLabel(toLab,triggerObj);
117  if(!triggerObj.isValid()) return;
118 
119  for (unsigned int trInd=0; trInd<triggers.size(); trInd++)
120  {
121  bool l1pass=false;
122  std::vector<l1extra::L1JetParticleRef> l1CenJets;
123  std::vector<l1extra::L1JetParticleRef> l1ForJets;
124  std::vector<l1extra::L1JetParticleRef> l1TauJets;
126  trigger::size_type l1filterIndex=triggerObj->filterIndex(l1Tag);
127 
128  if (l1filterIndex<triggerObj->size())
129  {
130  triggerObj->getObjects(l1filterIndex, trigger::TriggerL1CenJet, l1CenJets);
131  triggerObj->getObjects(l1filterIndex, trigger::TriggerL1ForJet, l1ForJets);
132  triggerObj->getObjects(l1filterIndex, trigger::TriggerL1TauJet, l1TauJets);
133  }
134 
135  if (l1CenJets.size()>0||l1ForJets.size()>0||l1TauJets.size()>0)
136  {
137  hL2L3acc[trInd]->Fill(1+0.001,1);
138  l1pass=true;
139  }
140 
141  if (!l1pass) continue;
142  std::vector<reco::IsolatedPixelTrackCandidateRef> l2tracks;
144  trigger::size_type l2filterIndex=triggerObj->filterIndex(l2Tag);
145  if (l2filterIndex<triggerObj->size()) triggerObj->getObjects(l2filterIndex, trigger::TriggerTrack, l2tracks);
146 
147  std::vector<reco::IsolatedPixelTrackCandidateRef> l3tracks;
149  trigger::size_type l3filterIndex=triggerObj->filterIndex(l3Tag);
150  if (l3filterIndex<triggerObj->size()) triggerObj->getObjects(l3filterIndex, trigger::TriggerTrack, l3tracks);
151 
154 
155  if (l2tracks.size()>0)
156  {
157  hL2L3acc[trInd]->Fill(2+0.0001,1);
159  {
160  iEvent.getByLabel(l3collectionLabels_[trInd],l3col);
161  if(!l3col.isValid()) continue;
162 
163  for (reco::IsolatedPixelTrackCandidateCollection::const_iterator l3it=l3col->begin(); l3it!=l3col->end(); ++l3it)
164  {
165  double drmin=100;
166  int selL2tr=-1;
167  for (unsigned int il2=0; il2<l2tracks.size(); il2++)
168  {
169  double drl2l3=reco::deltaR(l3it->eta(),l3it->phi(),l2tracks[il2]->eta(),l2tracks[il2]->phi());
170  if (drl2l3<drmin)
171  {
172  drmin=drl2l3;
173  selL2tr=il2;
174  }
175  }
176  if (selL2tr!=-1&&drmin<0.03&&l2tracks[selL2tr]->p()!=0) hL3candL2rat[trInd]->Fill(l3it->p()/l2tracks[selL2tr]->p(),1);
177  if (selL2tr!=-1) hL3L2trackMatch[trInd]->Fill(drmin,1);
178  }
179  }
180  }
181 
182  if (l3tracks.size()>0) hL2L3acc[trInd]->Fill(3+0.0001,1);
183 
184  l1extra::L1JetParticleRef maxPtJet;
185 
186  double l1maxPt=-1;
187  for (unsigned int i=0; i<l1CenJets.size(); i++)
188  {
189  if (l1CenJets[i]->pt()>l1maxPt)
190  {
191  l1maxPt=l1CenJets[i]->pt();
192  maxPtJet=l1CenJets[i];
193  }
194  }
195  for (unsigned int i=0; i<l1ForJets.size(); i++)
196  {
197  if (l1ForJets[i]->pt()>l1maxPt)
198  {
199  l1maxPt=l1ForJets[i]->pt();
200  maxPtJet=l1ForJets[i];
201  }
202  }
203  for (unsigned int i=0; i<l1TauJets.size(); i++)
204  {
205  if (l1TauJets[i]->pt()>l1maxPt)
206  {
207  l1maxPt=l1TauJets[i]->pt();
208  maxPtJet=l1TauJets[i];
209  }
210  }
211 
212  if (maxPtJet.isNonnull()) hL1eta[trInd]->Fill(maxPtJet->eta(),1);
213  if (maxPtJet.isNonnull()) hL1phi[trInd]->Fill(maxPtJet->phi(),1);
214 
218  {
219  iEvent.getByLabel(l2collectionLabels_[trInd],l2col);
220  if(!l2col.isValid()) continue;
221  for (reco::IsolatedPixelTrackCandidateCollection::const_iterator l2it=l2col->begin(); l2it!=l2col->end(); l2it++)
222  {
223  hL2isolationP[trInd]->Fill(l2it->maxPtPxl(),1);
224  }
225  }
226 
227  for (unsigned int i=0; i<l2tracks.size(); i++)
228  {
229  std::pair<int, int> tower=towerIndex(l2tracks[i]->eta(), l2tracks[i]->phi());
230  hL2TowerOccupancy[trInd]->Fill(tower.first,tower.second,1);
231  }
232  for (unsigned int i=0; i<l3tracks.size(); i++)
233  {
234  std::pair<int, int> tower=towerIndex(l3tracks[i]->eta(), l3tracks[i]->phi());
235  hL3TowerOccupancy[trInd]->Fill(tower.first,tower.second,1);
236  }
237  }
238 }
239 
241 {
244 
245  char tmp1[100];
246  char tmp2[100];
247  for (unsigned int i=0; i<triggers.size(); i++)
248  {
249  std::sprintf(tmp1,"hL2L3acc_%s",trigNames_[i].c_str());
250  std::sprintf(tmp2,"number of L1, L2 and L3 accepts; [%s]",trigNames_[i].c_str());
251  MonitorElement* hL2L3accBuf=dbe_->book1D(tmp1,tmp2,3,1,4);
252  hL2L3acc.push_back(hL2L3accBuf);
253  hL2L3acc[i]->setTitle(tmp1);
254  hL2L3acc[i]->setAxisTitle("trigger level",1);
255 
256  std::sprintf(tmp1,"hL2L3trackMatch_%s",trigNames_[i].c_str());
257  std::sprintf(tmp2,"R from L3 object to L2 object; [%s]",trigNames_[i].c_str());
258  MonitorElement* hL3L2trackMatchBuf=dbe_->book1D(tmp1,tmp2,1000,0,1);
259  hL3L2trackMatch.push_back(hL3L2trackMatchBuf);
260  hL3L2trackMatch[i]->setAxisTitle("R(eta,phi)",1);
261 
262  std::sprintf(tmp1,"hL2L3rat_%s",trigNames_[i].c_str());
263  std::sprintf(tmp2,"ratio of L3 to L2 momentum measurement; [%s]",trigNames_[i].c_str());
264  MonitorElement* hL3L2ratBuf=dbe_->book1D(tmp1,tmp2,1000,0,10);
265  hL3candL2rat.push_back(hL3L2ratBuf);
266  hL3candL2rat[i]->setAxisTitle("P_L3/P_L2",1);
267 
268  std::sprintf(tmp1,"hL1eta_%s",trigNames_[i].c_str());
269  std::sprintf(tmp2,"eta distribution of L1 triggers; [%s]",trigNames_[i].c_str());
270  MonitorElement* hL1etaBuf=dbe_->book1D(tmp1,tmp2,1000,-7,7);
271  hL1eta.push_back(hL1etaBuf);
272  hL1eta[i]->setAxisTitle("eta",1);
273 
274  std::sprintf(tmp1,"hL1phi_%s",trigNames_[i].c_str());
275  std::sprintf(tmp2,"phi distribution of L1 triggers; [%s]",trigNames_[i].c_str());
276  MonitorElement* hL1phiBuf=dbe_->book1D(tmp1,tmp2,1000,-4,4);
277  hL1phi.push_back(hL1phiBuf);
278  hL1phi[i]->setAxisTitle("phi",1);
279 
280  std::sprintf(tmp1,"hL2isolation_%s",trigNames_[i].c_str());
281  std::sprintf(tmp2,"isolation momentum at L2; [%s]",trigNames_[i].c_str());
282  MonitorElement* hL2isolationBuf=dbe_->book1D(tmp1,tmp2,1000,0,10);
283  hL2isolationP.push_back(hL2isolationBuf);
284  hL2isolationP[i]->setAxisTitle("max P (GeV)",1);
285 
286  std::sprintf(tmp1,"hL2occupancy_%s",trigNames_[i].c_str());
287  std::sprintf(tmp2,"tower occupancy at L2; [%s]",trigNames_[i].c_str());
288  MonitorElement* hL2TowerOccupancyBuf=dbe_->book2D(tmp1,tmp2,48,-25,25,73,0,73);
289  hL2TowerOccupancy.push_back(hL2TowerOccupancyBuf);
290  hL2TowerOccupancy[i]->setAxisTitle("ieta",1);
291  hL2TowerOccupancy[i]->setAxisTitle("iphi",2);
292  hL2TowerOccupancy[i]->getTH2F()->SetOption("colz");
293  hL2TowerOccupancy[i]->getTH2F()->SetStats(kFALSE);
294 
295 
296  std::sprintf(tmp1,"hL3occupancy_%s",trigNames_[i].c_str());
297  std::sprintf(tmp2,"tower occupancy at L3; [%s]",trigNames_[i].c_str());
298  MonitorElement* hL3TowerOccupancyBuf=dbe_->book2D(tmp1,tmp2,48,-25,25,73,0,73);
299  hL3TowerOccupancy.push_back(hL3TowerOccupancyBuf);
300  hL3TowerOccupancy[i]->setAxisTitle("ieta",1);
301  hL3TowerOccupancy[i]->setAxisTitle("iphi",2);
302  hL3TowerOccupancy[i]->getTH2F()->SetOption("colz");
303  hL3TowerOccupancy[i]->getTH2F()->SetStats(kFALSE);
304  }
305 }
306 
308 
309 if(dbe_&&saveToRootFile_)
310  {
312  }
313 }
314 
dbl * delta
Definition: mlp_gen.cc:36
HLTMonHcalIsoTrack(const edm::ParameterSet &)
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
std::vector< MonitorElement * > hL2L3acc
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:717
std::string hltRAWEventTag_
std::string outRootFileName_
std::vector< std::string > l2collectionLabels_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:2113
virtual void analyze(const edm::Event &, const edm::EventSetup &)
double getDist(double, double, double, double)
T eta() const
uint16_t size_type
std::vector< MonitorElement * > hL2isolationP
double deltaR(double eta1, double phi1, double eta2, double phi2)
Definition: deltaR.h:19
std::vector< MonitorElement * > hL2TowerOccupancy
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
std::vector< std::string > l3collectionLabels_
std::vector< MonitorElement * > hL3L2trackMatch
int iEvent
Definition: GenABIO.cc:243
std::pair< int, int > towerIndex(double, double)
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
std::vector< MonitorElement * > hL1eta
T sqrt(T t)
Definition: SSEVec.h:46
std::vector< std::string > l2filterLabels_
std::vector< std::string > l3filterLabels_
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
std::vector< edm::ParameterSet > triggers
std::vector< std::string > l1filterLabels_
std::vector< MonitorElement * > hL3TowerOccupancy
std::vector< MonitorElement * > hL3candL2rat
std::vector< MonitorElement * > hL1phi
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
tuple size
Write out results.
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
std::string hltAODEventTag_
std::vector< std::string > trigNames_
Definition: DDAxes.h:10