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 //
17 //
18 
19 
20 // user include files
21 
25 
28 
31 
34 
36 
37 double HLTMonHcalIsoTrack::getDist(double eta1, double phi1, double eta2, double phi2)
38 {
39  double dphi = fabs(phi1 - phi2);
40  if(dphi>acos(-1)) dphi = 2*acos(-1)-dphi;
41  double dr = sqrt(dphi*dphi + pow(eta1-eta2,2));
42  return dr;
43 }
44 
45 std::pair<int,int> HLTMonHcalIsoTrack::towerIndex(double eta, double phi)
46 {
47  int ieta = 0;
48  int iphi = 0;
49  if (eta!=0)
50  {
51  for (int i=1; i<21; i++)
52  {
53  if (fabs(eta)<(i*0.087)&&fabs(eta)>(i-1)*0.087) ieta=int(fabs(eta)/eta)*i;
54  }
55  if (fabs(eta)>1.740&&fabs(eta)<=1.830) ieta=int(fabs(eta)/eta)*21;
56  if (fabs(eta)>1.830&&fabs(eta)<=1.930) ieta=int(fabs(eta)/eta)*22;
57  if (fabs(eta)>1.930&&fabs(eta)<=2.043) ieta=int(fabs(eta)/eta)*23;
58  if (fabs(eta)>2.043&&fabs(eta)<=2.172) ieta=int(fabs(eta)/eta)*24;
59  }
60 
61  double delta=phi+0.174532925;
62  if (delta<0) delta=delta+2*acos(-1);
63  if (fabs(eta)<1.740)
64  {
65  for (int i=0; i<72; i++)
66  {
67  if (delta<(i+1)*0.087266462&&delta>i*0.087266462) iphi=i;
68  }
69  }
70  else
71  {
72  for (int i=0; i<36; i++)
73  {
74  if (delta<2*(i+1)*0.087266462&&delta>2*i*0.087266462) iphi=2*i;
75  }
76  }
77 
78  return std::pair<int,int>(ieta,iphi);
79 }
80 
81 
83 {
84  folderName_ = iConfig.getParameter<std::string>("folderName");
85  outRootFileName_=iConfig.getParameter<std::string>("outputRootFileName");
86 
87  useProducerCollections_=iConfig.getParameter<bool>("useProducerCollections");
88  hltRAWEventTag_=iConfig.getParameter<std::string>("hltRAWTriggerEventLabel");
89  hltAODEventTag_=iConfig.getParameter<std::string>("hltAODTriggerEventLabel");
90 
91  hltProcess_=iConfig.getParameter<std::string>("hltProcessName");
92 
93  saveToRootFile_=iConfig.getParameter<bool>("SaveToRootFile");
94 
95  triggers = iConfig.getParameter<std::vector<edm::ParameterSet> >("triggers");
96  for (std::vector<edm::ParameterSet>::iterator inTrig = triggers.begin(); inTrig != triggers.end(); inTrig++)
97  {
98  trigNames_.push_back(inTrig->getParameter<std::string>("triggerName"));
99  l1filterLabels_.push_back(inTrig->getParameter<std::string>("hltL1filterLabel"));
100  l2filterLabels_.push_back(inTrig->getParameter<std::string>("hltL2filterLabel"));
101  l3filterLabels_.push_back(inTrig->getParameter<std::string>("hltL3filterLabel"));
102  l2collectionLabels_.push_back(inTrig->getParameter<std::string>("l2collectionLabel"));
103  l3collectionLabels_.push_back(inTrig->getParameter<std::string>("l3collectionLabel"));
104  l2collectionToken_.push_back(consumes<reco::IsolatedPixelTrackCandidateCollection>(inTrig->getParameter<std::string>("l2collectionLabel")));
105  l3collectionToken_.push_back(consumes<reco::IsolatedPixelTrackCandidateCollection>(inTrig->getParameter<std::string>("l3collectionLabel")));
106  }
107 
108  //set Token(-s)
109  toLabToken_ = consumes<trigger::TriggerEventWithRefs>(edm::InputTag(hltRAWEventTag_,"",hltProcess_));
110 }
111 
112 
114 {}
115 
117 {
120  iEvent.getByToken(toLabToken_, triggerObj);
121  if(!triggerObj.isValid()) return;
122 
123  for (unsigned int trInd=0; trInd<triggers.size(); trInd++)
124  {
125  bool l1pass=false;
126  std::vector<l1extra::L1JetParticleRef> l1CenJets;
127  std::vector<l1extra::L1JetParticleRef> l1ForJets;
128  std::vector<l1extra::L1JetParticleRef> l1TauJets;
130  trigger::size_type l1filterIndex=triggerObj->filterIndex(l1Tag);
131 
132  if (l1filterIndex<triggerObj->size())
133  {
134  triggerObj->getObjects(l1filterIndex, trigger::TriggerL1CenJet, l1CenJets);
135  triggerObj->getObjects(l1filterIndex, trigger::TriggerL1ForJet, l1ForJets);
136  triggerObj->getObjects(l1filterIndex, trigger::TriggerL1TauJet, l1TauJets);
137  }
138 
139  if (l1CenJets.size()>0||l1ForJets.size()>0||l1TauJets.size()>0)
140  {
141  hL2L3acc[trInd]->Fill(1+0.001,1);
142  l1pass=true;
143  }
144 
145  if (!l1pass) continue;
146  std::vector<reco::IsolatedPixelTrackCandidateRef> l2tracks;
148  trigger::size_type l2filterIndex=triggerObj->filterIndex(l2Tag);
149  if (l2filterIndex<triggerObj->size()) triggerObj->getObjects(l2filterIndex, trigger::TriggerTrack, l2tracks);
150 
151  std::vector<reco::IsolatedPixelTrackCandidateRef> l3tracks;
153  trigger::size_type l3filterIndex=triggerObj->filterIndex(l3Tag);
154  if (l3filterIndex<triggerObj->size()) triggerObj->getObjects(l3filterIndex, trigger::TriggerTrack, l3tracks);
155 
158 
159  if (l2tracks.size()>0)
160  {
161  hL2L3acc[trInd]->Fill(2+0.0001,1);
163  {
164  iEvent.getByToken(l3collectionToken_[trInd], l3col);
165  if(!l3col.isValid()) continue;
166 
167  for (reco::IsolatedPixelTrackCandidateCollection::const_iterator l3it=l3col->begin(); l3it!=l3col->end(); ++l3it)
168  {
169  double drmin=100;
170  int selL2tr=-1;
171  for (unsigned int il2=0; il2<l2tracks.size(); il2++)
172  {
173  double drl2l3=reco::deltaR(l3it->eta(),l3it->phi(),l2tracks[il2]->eta(),l2tracks[il2]->phi());
174  if (drl2l3<drmin)
175  {
176  drmin=drl2l3;
177  selL2tr=il2;
178  }
179  }
180  if (selL2tr!=-1&&drmin<0.03&&l2tracks[selL2tr]->p()!=0) hL3candL2rat[trInd]->Fill(l3it->p()/l2tracks[selL2tr]->p(),1);
181  if (selL2tr!=-1) hL3L2trackMatch[trInd]->Fill(drmin,1);
182  }
183  }
184  }
185 
186  if (l3tracks.size()>0) hL2L3acc[trInd]->Fill(3+0.0001,1);
187 
188  l1extra::L1JetParticleRef maxPtJet;
189 
190  double l1maxPt=-1;
191  for (unsigned int i=0; i<l1CenJets.size(); i++)
192  {
193  if (l1CenJets[i]->pt()>l1maxPt)
194  {
195  l1maxPt=l1CenJets[i]->pt();
196  maxPtJet=l1CenJets[i];
197  }
198  }
199  for (unsigned int i=0; i<l1ForJets.size(); i++)
200  {
201  if (l1ForJets[i]->pt()>l1maxPt)
202  {
203  l1maxPt=l1ForJets[i]->pt();
204  maxPtJet=l1ForJets[i];
205  }
206  }
207  for (unsigned int i=0; i<l1TauJets.size(); i++)
208  {
209  if (l1TauJets[i]->pt()>l1maxPt)
210  {
211  l1maxPt=l1TauJets[i]->pt();
212  maxPtJet=l1TauJets[i];
213  }
214  }
215 
216  if (maxPtJet.isNonnull()) hL1eta[trInd]->Fill(maxPtJet->eta(),1);
217  if (maxPtJet.isNonnull()) hL1phi[trInd]->Fill(maxPtJet->phi(),1);
218 
222  {
223  iEvent.getByToken(l2collectionToken_[trInd], l2col);
224  if(!l2col.isValid()) continue;
225  for (reco::IsolatedPixelTrackCandidateCollection::const_iterator l2it=l2col->begin(); l2it!=l2col->end(); l2it++)
226  {
227  hL2isolationP[trInd]->Fill(l2it->maxPtPxl(),1);
228  }
229  }
230 
231  for (unsigned int i=0; i<l2tracks.size(); i++)
232  {
233  std::pair<int, int> tower=towerIndex(l2tracks[i]->eta(), l2tracks[i]->phi());
234  hL2TowerOccupancy[trInd]->Fill(tower.first,tower.second,1);
235  }
236  for (unsigned int i=0; i<l3tracks.size(); i++)
237  {
238  std::pair<int, int> tower=towerIndex(l3tracks[i]->eta(), l3tracks[i]->phi());
239  hL3TowerOccupancy[trInd]->Fill(tower.first,tower.second,1);
240  }
241  }
242 }
243 
245 {
248 
249  char tmp1[100];
250  char tmp2[100];
251  for (unsigned int i=0; i<triggers.size(); i++)
252  {
253  std::sprintf(tmp1,"hL2L3acc_%s",trigNames_[i].c_str());
254  std::sprintf(tmp2,"number of L1, L2 and L3 accepts; [%s]",trigNames_[i].c_str());
255  MonitorElement* hL2L3accBuf=dbe_->book1D(tmp1,tmp2,3,1,4);
256  hL2L3acc.push_back(hL2L3accBuf);
257  hL2L3acc[i]->setTitle(tmp1);
258  hL2L3acc[i]->setAxisTitle("trigger level",1);
259 
260  std::sprintf(tmp1,"hL2L3trackMatch_%s",trigNames_[i].c_str());
261  std::sprintf(tmp2,"R from L3 object to L2 object; [%s]",trigNames_[i].c_str());
262  MonitorElement* hL3L2trackMatchBuf=dbe_->book1D(tmp1,tmp2,1000,0,1);
263  hL3L2trackMatch.push_back(hL3L2trackMatchBuf);
264  hL3L2trackMatch[i]->setAxisTitle("R(eta,phi)",1);
265 
266  std::sprintf(tmp1,"hL2L3rat_%s",trigNames_[i].c_str());
267  std::sprintf(tmp2,"ratio of L3 to L2 momentum measurement; [%s]",trigNames_[i].c_str());
268  MonitorElement* hL3L2ratBuf=dbe_->book1D(tmp1,tmp2,1000,0,10);
269  hL3candL2rat.push_back(hL3L2ratBuf);
270  hL3candL2rat[i]->setAxisTitle("P_L3/P_L2",1);
271 
272  std::sprintf(tmp1,"hL1eta_%s",trigNames_[i].c_str());
273  std::sprintf(tmp2,"eta distribution of L1 triggers; [%s]",trigNames_[i].c_str());
274  MonitorElement* hL1etaBuf=dbe_->book1D(tmp1,tmp2,1000,-7,7);
275  hL1eta.push_back(hL1etaBuf);
276  hL1eta[i]->setAxisTitle("eta",1);
277 
278  std::sprintf(tmp1,"hL1phi_%s",trigNames_[i].c_str());
279  std::sprintf(tmp2,"phi distribution of L1 triggers; [%s]",trigNames_[i].c_str());
280  MonitorElement* hL1phiBuf=dbe_->book1D(tmp1,tmp2,1000,-4,4);
281  hL1phi.push_back(hL1phiBuf);
282  hL1phi[i]->setAxisTitle("phi",1);
283 
284  std::sprintf(tmp1,"hL2isolation_%s",trigNames_[i].c_str());
285  std::sprintf(tmp2,"isolation momentum at L2; [%s]",trigNames_[i].c_str());
286  MonitorElement* hL2isolationBuf=dbe_->book1D(tmp1,tmp2,1000,0,10);
287  hL2isolationP.push_back(hL2isolationBuf);
288  hL2isolationP[i]->setAxisTitle("max P (GeV)",1);
289 
290  std::sprintf(tmp1,"hL2occupancy_%s",trigNames_[i].c_str());
291  std::sprintf(tmp2,"tower occupancy at L2; [%s]",trigNames_[i].c_str());
292  MonitorElement* hL2TowerOccupancyBuf=dbe_->book2D(tmp1,tmp2,48,-25,25,73,0,73);
293  hL2TowerOccupancy.push_back(hL2TowerOccupancyBuf);
294  hL2TowerOccupancy[i]->setAxisTitle("ieta",1);
295  hL2TowerOccupancy[i]->setAxisTitle("iphi",2);
296  hL2TowerOccupancy[i]->getTH2F()->SetOption("colz");
297  hL2TowerOccupancy[i]->getTH2F()->SetStats(kFALSE);
298 
299 
300  std::sprintf(tmp1,"hL3occupancy_%s",trigNames_[i].c_str());
301  std::sprintf(tmp2,"tower occupancy at L3; [%s]",trigNames_[i].c_str());
302  MonitorElement* hL3TowerOccupancyBuf=dbe_->book2D(tmp1,tmp2,48,-25,25,73,0,73);
303  hL3TowerOccupancy.push_back(hL3TowerOccupancyBuf);
304  hL3TowerOccupancy[i]->setAxisTitle("ieta",1);
305  hL3TowerOccupancy[i]->setAxisTitle("iphi",2);
306  hL3TowerOccupancy[i]->getTH2F()->SetOption("colz");
307  hL3TowerOccupancy[i]->getTH2F()->SetStats(kFALSE);
308  }
309 }
310 
312 
313 if(dbe_&&saveToRootFile_)
314  {
316  }
317 }
318 
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:872
std::string hltRAWEventTag_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
std::string outRootFileName_
std::vector< std::string > l2collectionLabels_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
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
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:48
std::vector< std::string > l2filterLabels_
std::vector< edm::EDGetTokenT< reco::IsolatedPixelTrackCandidateCollection > > l2collectionToken_
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", const uint32_t run=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:2296
std::vector< std::string > l3filterLabels_
bool isValid() const
Definition: HandleBase.h:76
std::vector< edm::ParameterSet > triggers
std::vector< std::string > l1filterLabels_
edm::EDGetTokenT< trigger::TriggerEventWithRefs > toLabToken_
std::vector< MonitorElement * > hL3TowerOccupancy
std::vector< edm::EDGetTokenT< reco::IsolatedPixelTrackCandidateCollection > > l3collectionToken_
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:1000
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:584
std::string hltAODEventTag_
std::vector< std::string > trigNames_
Definition: DDAxes.h:10