CMS 3D CMS Logo

GlobalHaloAlgo.cc
Go to the documentation of this file.
2 namespace {
3  constexpr float c_cm_per_ns = 29.9792458;
4 };
5 /*
6  [class]: GlobalHaloAlgo
7  [authors]: R. Remington, The University of Florida
8  [description]: See GlobalHaloAlgo.h
9  [date]: October 15, 2009
10 */
11 using namespace std;
12 using namespace edm;
13 using namespace reco;
14 
15 enum detectorregion { EB, EE, HB, HE };
16 int Phi_To_HcaliPhi(float phi) {
17  phi = phi < 0 ? phi + 2. * TMath::Pi() : phi;
18  float phi_degrees = phi * (360.) / (2. * TMath::Pi());
19  int iPhi = (int)((phi_degrees / 5.) + 1.);
20 
21  return iPhi < 73 ? iPhi : 73;
22 }
23 
24 int Phi_To_EcaliPhi(float phi) {
25  phi = phi < 0 ? phi + 2. * TMath::Pi() : phi;
26  float phi_degrees = phi * (360.) / (2. * TMath::Pi());
27  int iPhi = (int)(phi_degrees + 1.);
28 
29  return iPhi < 361 ? iPhi : 360;
30 }
31 
33  // Defaults are "loose"
34  Ecal_R_Min = 110.; // Tight: 200.
35  Ecal_R_Max = 330.; // Tight: 250.
36  Hcal_R_Min = 110.; // Tight: 220.
37  Hcal_R_Max = 490.; // Tight: 350.
38 }
39 
41  const CSCGeometry& TheCSCGeometry,
42  const reco::CaloMET& TheCaloMET,
43  edm::Handle<edm::View<Candidate> >& TheCaloTowers,
44  edm::Handle<CSCSegmentCollection>& TheCSCSegments,
47  const CSCHaloData& TheCSCHaloData,
48  const EcalHaloData& TheEcalHaloData,
49  const HcalHaloData& TheHcalHaloData,
50  bool ishlt) {
51  GlobalHaloData TheGlobalHaloData;
52  float METOverSumEt = TheCaloMET.sumEt() ? TheCaloMET.pt() / TheCaloMET.sumEt() : 0;
53  TheGlobalHaloData.SetMETOverSumEt(METOverSumEt);
54 
55  int EcalOverlapping_CSCRecHits[361] = {};
56  int EcalOverlapping_CSCSegments[361] = {};
57  int HcalOverlapping_CSCRecHits[73] = {};
58  int HcalOverlapping_CSCSegments[73] = {};
59 
60  if (TheCSCSegments.isValid()) {
61  for (CSCSegmentCollection::const_iterator iSegment = TheCSCSegments->begin(); iSegment != TheCSCSegments->end();
62  iSegment++) {
63  bool EcalOverlap[361];
64  bool HcalOverlap[73];
65  for (int i = 0; i < 361; i++) {
66  EcalOverlap[i] = false;
67  if (i < 73)
68  HcalOverlap[i] = false;
69  }
70 
71  std::vector<CSCRecHit2D> Hits = iSegment->specificRecHits();
72  for (std::vector<CSCRecHit2D>::iterator iHit = Hits.begin(); iHit != Hits.end(); iHit++) {
73  DetId TheDetUnitId(iHit->geographicalId());
74  if (TheDetUnitId.det() != DetId::Muon)
75  continue;
76  if (TheDetUnitId.subdetId() != MuonSubdetId::CSC)
77  continue;
78 
79  const GeomDetUnit* TheUnit = TheCSCGeometry.idToDetUnit(TheDetUnitId);
80  LocalPoint TheLocalPosition = iHit->localPosition();
81  const BoundPlane& TheSurface = TheUnit->surface();
82  const GlobalPoint TheGlobalPosition = TheSurface.toGlobal(TheLocalPosition);
83 
84  int Hcal_iphi = Phi_To_HcaliPhi(TheGlobalPosition.phi());
85  int Ecal_iphi = Phi_To_EcaliPhi(TheGlobalPosition.phi());
86  float x = TheGlobalPosition.x();
87  float y = TheGlobalPosition.y();
88 
89  float r = TMath::Sqrt(x * x + y * y);
90 
91  if (r < Ecal_R_Max && r > Ecal_R_Min)
92  EcalOverlap[Ecal_iphi] = true;
93  if (r < Hcal_R_Max && r > Hcal_R_Max)
94  HcalOverlap[Hcal_iphi] = true;
95  }
96  for (int i = 0; i < 361; i++) {
97  if (EcalOverlap[i])
98  EcalOverlapping_CSCSegments[i]++;
99  if (i < 73 && HcalOverlap[i])
100  HcalOverlapping_CSCSegments[i]++;
101  }
102  }
103  }
104  if (TheCSCRecHits.isValid()) {
105  for (CSCRecHit2DCollection::const_iterator iCSCRecHit = TheCSCRecHits->begin(); iCSCRecHit != TheCSCRecHits->end();
106  iCSCRecHit++) {
107  DetId TheDetUnitId(iCSCRecHit->geographicalId());
108  if (TheDetUnitId.det() != DetId::Muon)
109  continue;
110  if (TheDetUnitId.subdetId() != MuonSubdetId::CSC)
111  continue;
112 
113  const GeomDetUnit* TheUnit = TheCSCGeometry.idToDetUnit(TheDetUnitId);
114  LocalPoint TheLocalPosition = iCSCRecHit->localPosition();
115  const BoundPlane& TheSurface = TheUnit->surface();
116  const GlobalPoint TheGlobalPosition = TheSurface.toGlobal(TheLocalPosition);
117 
118  int Hcaliphi = Phi_To_HcaliPhi(TheGlobalPosition.phi());
119  int Ecaliphi = Phi_To_EcaliPhi(TheGlobalPosition.phi());
120  float x = TheGlobalPosition.x();
121  float y = TheGlobalPosition.y();
122 
123  float r = TMath::Sqrt(x * x + y * y);
124 
125  if (r < Ecal_R_Max && r > Ecal_R_Min)
126  EcalOverlapping_CSCRecHits[Ecaliphi]++;
127  if (r < Hcal_R_Max && r > Hcal_R_Max)
128  HcalOverlapping_CSCRecHits[Hcaliphi]++;
129  }
130  }
131 
132  // In development....
133  // Get Ecal Wedges
134  std::vector<PhiWedge> EcalWedges = TheEcalHaloData.GetPhiWedges();
135 
136  // Get Hcal Wedges
137  std::vector<PhiWedge> HcalWedges = TheHcalHaloData.GetPhiWedges();
138 
139  //Get Ref to CSC Tracks
140  //edm::RefVector<reco::TrackCollection> TheCSCTracks = TheCSCHaloData.GetTracks();
141  //for(unsigned int i = 0 ; i < TheCSCTracks.size() ; i++ )
142  //edm::Ref<reco::TrackCollection> iTrack( TheCSCTracks, i );
143 
144  // Get global positions of central most rechit of CSC Halo tracks
145  std::vector<GlobalPoint> TheGlobalPositions = TheCSCHaloData.GetCSCTrackImpactPositions();
146 
147  // Container to store Ecal/Hcal iPhi values matched to impact point of CSC tracks
148  std::vector<int> vEcaliPhi, vHcaliPhi;
149 
150  for (std::vector<GlobalPoint>::iterator Pos = TheGlobalPositions.begin(); Pos != TheGlobalPositions.end(); Pos++) {
151  // Calculate global phi coordinate for central most rechit in the track
152  float global_phi = Pos->phi();
153  float global_r = TMath::Sqrt(Pos->x() * Pos->x() + Pos->y() * Pos->y());
154 
155  // Convert global phi to iPhi
156  int global_EcaliPhi = Phi_To_EcaliPhi(global_phi);
157  int global_HcaliPhi = Phi_To_HcaliPhi(global_phi);
158 
159  //Loop over Ecal Phi Wedges
160  for (std::vector<PhiWedge>::iterator iWedge = EcalWedges.begin(); iWedge != EcalWedges.end(); iWedge++) {
161  if ((TMath::Abs(global_EcaliPhi - iWedge->iPhi()) <= 5) && (global_r > Ecal_R_Min && global_r < Ecal_R_Max)) {
162  bool StoreWedge = true;
163  for (unsigned int i = 0; i < vEcaliPhi.size(); i++)
164  if (vEcaliPhi[i] == iWedge->iPhi())
165  StoreWedge = false;
166 
167  if (StoreWedge) {
168  PhiWedge NewWedge(*iWedge);
169  NewWedge.SetOverlappingCSCSegments(EcalOverlapping_CSCSegments[iWedge->iPhi()]);
170  NewWedge.SetOverlappingCSCRecHits(EcalOverlapping_CSCRecHits[iWedge->iPhi()]);
171  vEcaliPhi.push_back(iWedge->iPhi());
172  TheGlobalHaloData.GetMatchedEcalPhiWedges().push_back(NewWedge);
173  }
174  }
175  }
176  //Loop over Hcal Phi Wedges
177  for (std::vector<PhiWedge>::iterator iWedge = HcalWedges.begin(); iWedge != HcalWedges.end(); iWedge++) {
178  if ((TMath::Abs(global_HcaliPhi - iWedge->iPhi()) <= 2) && (global_r > Hcal_R_Min && global_r < Hcal_R_Max)) {
179  bool StoreWedge = true;
180  for (unsigned int i = 0; i < vHcaliPhi.size(); i++)
181  if (vHcaliPhi[i] == iWedge->iPhi())
182  StoreWedge = false;
183 
184  if (StoreWedge) {
185  vHcaliPhi.push_back(iWedge->iPhi());
186  PhiWedge NewWedge(*iWedge);
187  NewWedge.SetOverlappingCSCSegments(HcalOverlapping_CSCSegments[iWedge->iPhi()]);
188  NewWedge.SetOverlappingCSCRecHits(HcalOverlapping_CSCRecHits[iWedge->iPhi()]);
189  PhiWedge wedge(*iWedge);
190  TheGlobalHaloData.GetMatchedHcalPhiWedges().push_back(NewWedge);
191  }
192  }
193  }
194  }
195 
196  // Corrections to MEx, MEy
197  float dMEx = 0.;
198  float dMEy = 0.;
199  // Loop over calotowers and correct the MET for the towers that lie in the trajectory of the CSC Halo Tracks
200  for (edm::View<Candidate>::const_iterator iCandidate = TheCaloTowers->begin(); iCandidate != TheCaloTowers->end();
201  iCandidate++) {
202  const Candidate* c = &(*iCandidate);
203  if (c) {
204  const CaloTower* iTower = dynamic_cast<const CaloTower*>(c);
205  if (iTower->et() < TowerEtThreshold)
206  continue;
207  if (abs(iTower->ieta()) > 24)
208  continue; // not in barrel/endcap
209  int iphi = iTower->iphi();
210  for (unsigned int x = 0; x < vEcaliPhi.size(); x++) {
211  if (iphi == vEcaliPhi[x]) {
212  dMEx += (TMath::Cos(iTower->phi()) * iTower->emEt());
213  dMEy += (TMath::Sin(iTower->phi()) * iTower->emEt());
214  }
215  }
216  for (unsigned int x = 0; x < vHcaliPhi.size(); x++) {
217  if (iphi == vHcaliPhi[x]) {
218  dMEx += (TMath::Cos(iTower->phi()) * iTower->hadEt());
219  dMEy += (TMath::Sin(iTower->phi()) * iTower->hadEt());
220  }
221  }
222  }
223  }
224 
225  TheGlobalHaloData.SetMETCorrections(dMEx, dMEy);
226 
227  std::vector<HaloClusterCandidateECAL> hccandEB = TheEcalHaloData.getHaloClusterCandidatesEB();
228  std::vector<HaloClusterCandidateECAL> hccandEE = TheEcalHaloData.getHaloClusterCandidatesEE();
229  std::vector<HaloClusterCandidateHCAL> hccandHB = TheHcalHaloData.getHaloClusterCandidatesHB();
230  std::vector<HaloClusterCandidateHCAL> hccandHE = TheHcalHaloData.getHaloClusterCandidatesHE();
231 
232  //CSC-calo matching
233  bool ECALBmatched(false), ECALEmatched(false), HCALBmatched(false), HCALEmatched(false);
234 
235  if (TheCSCSegments.isValid()) {
236  for (CSCSegmentCollection::const_iterator iSegment = TheCSCSegments->begin(); iSegment != TheCSCSegments->end();
237  iSegment++) {
238  CSCDetId iCscDetID = iSegment->cscDetId();
239  bool Segment1IsGood = true;
240 
241  //avoid segments from collision muons
242  if (TheMuons.isValid()) {
243  for (reco::MuonCollection::const_iterator mu = TheMuons->begin(); mu != TheMuons->end() && (Segment1IsGood);
244  mu++) {
245  if (!mu->isTrackerMuon() && !mu->isGlobalMuon() && mu->isStandAloneMuon())
246  continue;
247  if (!mu->isGlobalMuon() && mu->isTrackerMuon() && mu->pt() < 3)
248  continue;
249  const std::vector<MuonChamberMatch> chambers = mu->matches();
250  for (std::vector<MuonChamberMatch>::const_iterator kChamber = chambers.begin(); kChamber != chambers.end();
251  kChamber++) {
252  if (kChamber->detector() != MuonSubdetId::CSC)
253  continue;
254  for (std::vector<reco::MuonSegmentMatch>::const_iterator kSegment = kChamber->segmentMatches.begin();
255  kSegment != kChamber->segmentMatches.end();
256  kSegment++) {
257  edm::Ref<CSCSegmentCollection> cscSegRef = kSegment->cscSegmentRef;
258  CSCDetId kCscDetID = cscSegRef->cscDetId();
259 
260  if (kCscDetID == iCscDetID) {
261  Segment1IsGood = false;
262  }
263  }
264  }
265  }
266  }
267  if (!Segment1IsGood)
268  continue;
269 
270  // Get local direction vector; if direction runs parallel to beamline,
271  // count this segment as beam halo candidate.
272  LocalPoint iLocalPosition = iSegment->localPosition();
273  LocalVector iLocalDirection = iSegment->localDirection();
274 
275  GlobalPoint iGlobalPosition = TheCSCGeometry.chamber(iCscDetID)->toGlobal(iLocalPosition);
276  GlobalVector iGlobalDirection = TheCSCGeometry.chamber(iCscDetID)->toGlobal(iLocalDirection);
277 
278  float iTheta = iGlobalDirection.theta();
279  if (iTheta > max_segment_theta && iTheta < TMath::Pi() - max_segment_theta)
280  continue;
281 
282  float iPhi = iGlobalPosition.phi();
283  float iR = sqrt(iGlobalPosition.perp2());
284  float iZ = iGlobalPosition.z();
285  float iT = iSegment->time();
286 
287  //CSC-calo matching:
288  //Here, one checks if any halo cluster can be matched to a CSC segment.
289  //The matching uses both geometric (dphi, dR) and timing information (dt).
290  //The cut values depend on the subdetector considered (e.g. in HB, Rcalo-Rsegment is allowed to be very negative)
291 
292  bool ebmatched = SegmentMatchingEB(TheGlobalHaloData, hccandEB, iZ, iR, iT, iPhi, ishlt);
293  bool eematched = SegmentMatchingEE(TheGlobalHaloData, hccandEE, iZ, iR, iT, iPhi, ishlt);
294  bool hbmatched = SegmentMatchingHB(TheGlobalHaloData, hccandHB, iZ, iR, iT, iPhi, ishlt);
295  bool hematched = SegmentMatchingHE(TheGlobalHaloData, hccandHE, iZ, iR, iT, iPhi, ishlt);
296 
297  ECALBmatched |= ebmatched;
298  ECALEmatched |= eematched;
299  HCALBmatched |= hbmatched;
300  HCALEmatched |= hematched;
301  }
302  }
303 
304  TheGlobalHaloData.SetSegmentIsEBCaloMatched(ECALBmatched);
305  TheGlobalHaloData.SetSegmentIsEECaloMatched(ECALEmatched);
306  TheGlobalHaloData.SetSegmentIsHBCaloMatched(HCALBmatched);
307  TheGlobalHaloData.SetSegmentIsHECaloMatched(HCALEmatched);
308 
309  //Now checking patterns from EcalHaloData and HcalHaloData:
310  //Simply check whether any cluster has a halo pattern
311  //In that case store the rhits in GlobalHaloData
312 
313  bool HaloPatternFoundInEB = false;
314  for (auto& hcand : hccandEB) {
315  if ((hcand.getIsHaloFromPattern() && !ishlt) || (hcand.getIsHaloFromPattern_HLT() && ishlt)) {
316  HaloPatternFoundInEB = true;
317  edm::RefVector<EcalRecHitCollection> bhrhcandidates = hcand.getBeamHaloRecHitsCandidates();
318  AddtoBeamHaloEBEERechits(bhrhcandidates, TheGlobalHaloData, true);
319  }
320  }
321 
322  bool HaloPatternFoundInEE = false;
323  for (auto& hcand : hccandEE) {
324  if ((hcand.getIsHaloFromPattern() && !ishlt) || (hcand.getIsHaloFromPattern_HLT() && ishlt)) {
325  HaloPatternFoundInEE = true;
326  edm::RefVector<EcalRecHitCollection> bhrhcandidates = hcand.getBeamHaloRecHitsCandidates();
327  AddtoBeamHaloEBEERechits(bhrhcandidates, TheGlobalHaloData, false);
328  }
329  }
330 
331  bool HaloPatternFoundInHB = false;
332  for (auto& hcand : hccandHB) {
333  if ((hcand.getIsHaloFromPattern() && !ishlt) || (hcand.getIsHaloFromPattern_HLT() && ishlt)) {
334  HaloPatternFoundInHB = true;
335  edm::RefVector<HBHERecHitCollection> bhrhcandidates = hcand.getBeamHaloRecHitsCandidates();
336  AddtoBeamHaloHBHERechits(bhrhcandidates, TheGlobalHaloData);
337  }
338  }
339 
340  bool HaloPatternFoundInHE = false;
341  for (auto& hcand : hccandHE) {
342  if ((hcand.getIsHaloFromPattern() && !ishlt) || (hcand.getIsHaloFromPattern_HLT() && ishlt)) {
343  HaloPatternFoundInHE = true;
344  edm::RefVector<HBHERecHitCollection> bhrhcandidates = hcand.getBeamHaloRecHitsCandidates();
345  AddtoBeamHaloHBHERechits(bhrhcandidates, TheGlobalHaloData);
346  }
347  }
348  TheGlobalHaloData.SetHaloPatternFoundEB(HaloPatternFoundInEB);
349  TheGlobalHaloData.SetHaloPatternFoundEE(HaloPatternFoundInEE);
350  TheGlobalHaloData.SetHaloPatternFoundHB(HaloPatternFoundInHB);
351  TheGlobalHaloData.SetHaloPatternFoundHE(HaloPatternFoundInHE);
352 
353  return TheGlobalHaloData;
354 }
355 
357  const std::vector<HaloClusterCandidateECAL>& haloclustercands,
358  float iZ,
359  float iR,
360  float iT,
361  float iPhi,
362  bool ishlt) {
363  bool rhmatchingfound = false;
364 
365  for (auto& hcand : haloclustercands) {
366  if (!ApplyMatchingCuts(EB,
367  ishlt,
368  hcand.getSeedEt(),
369  iZ,
370  hcand.getSeedZ(),
371  iR,
372  hcand.getSeedR(),
373  iT,
374  hcand.getSeedTime(),
375  iPhi,
376  hcand.getSeedPhi()))
377  continue;
378 
379  rhmatchingfound = true;
380 
381  edm::RefVector<EcalRecHitCollection> bhrhcandidates = hcand.getBeamHaloRecHitsCandidates();
382 
383  AddtoBeamHaloEBEERechits(bhrhcandidates, thehalodata, true);
384  }
385 
386  return rhmatchingfound;
387 }
388 
390  const std::vector<HaloClusterCandidateECAL>& haloclustercands,
391  float iZ,
392  float iR,
393  float iT,
394  float iPhi,
395  bool ishlt) {
396  bool rhmatchingfound = false;
397 
398  for (auto& hcand : haloclustercands) {
399  if (!ApplyMatchingCuts(EE,
400  ishlt,
401  hcand.getSeedEt(),
402  iZ,
403  hcand.getSeedZ(),
404  iR,
405  hcand.getSeedR(),
406  iT,
407  hcand.getSeedTime(),
408  iPhi,
409  hcand.getSeedPhi()))
410  continue;
411 
412  rhmatchingfound = true;
413 
414  edm::RefVector<EcalRecHitCollection> bhrhcandidates = hcand.getBeamHaloRecHitsCandidates();
415 
416  AddtoBeamHaloEBEERechits(bhrhcandidates, thehalodata, false);
417  }
418 
419  return rhmatchingfound;
420 }
421 
423  const std::vector<HaloClusterCandidateHCAL>& haloclustercands,
424  float iZ,
425  float iR,
426  float iT,
427  float iPhi,
428  bool ishlt) {
429  bool rhmatchingfound = false;
430 
431  for (auto& hcand : haloclustercands) {
432  if (!ApplyMatchingCuts(HB,
433  ishlt,
434  hcand.getSeedEt(),
435  iZ,
436  hcand.getSeedZ(),
437  iR,
438  hcand.getSeedR(),
439  iT,
440  hcand.getSeedTime(),
441  iPhi,
442  hcand.getSeedPhi()))
443  continue;
444 
445  rhmatchingfound = true;
446 
447  edm::RefVector<HBHERecHitCollection> bhrhcandidates = hcand.getBeamHaloRecHitsCandidates();
448 
449  AddtoBeamHaloHBHERechits(bhrhcandidates, thehalodata);
450  }
451 
452  return rhmatchingfound;
453 }
454 
456  const std::vector<HaloClusterCandidateHCAL>& haloclustercands,
457  float iZ,
458  float iR,
459  float iT,
460  float iPhi,
461  bool ishlt) {
462  bool rhmatchingfound = false;
463 
464  for (auto& hcand : haloclustercands) {
465  if (!ApplyMatchingCuts(HE,
466  ishlt,
467  hcand.getSeedEt(),
468  iZ,
469  hcand.getSeedZ(),
470  iR,
471  hcand.getSeedR(),
472  iT,
473  hcand.getSeedTime(),
474  iPhi,
475  hcand.getSeedPhi()))
476  continue;
477 
478  rhmatchingfound = true;
479 
480  edm::RefVector<HBHERecHitCollection> bhrhcandidates = hcand.getBeamHaloRecHitsCandidates();
481 
482  AddtoBeamHaloHBHERechits(bhrhcandidates, thehalodata);
483  }
484 
485  return rhmatchingfound;
486 }
487 
489  bool ishlt,
490  double rhet,
491  double segZ,
492  double rhZ,
493  double segR,
494  double rhR,
495  double segT,
496  double rhT,
497  double segPhi,
498  double rhPhi) {
499  //Std::Absolute time wrt BX
500  double tBXrh = rhT + sqrt(rhR * rhR + rhZ * rhZ) / c_cm_per_ns;
501  double tBXseg = segT + sqrt(segR * segR + segZ * segZ) / c_cm_per_ns;
502  //Time at z=0, under beam halo hypothesis
503  double tcorseg = tBXseg - std::abs(segZ) / c_cm_per_ns; //Outgoing beam halo
504  double tcorsegincbh = tBXseg + std::abs(segZ) / c_cm_per_ns; //Ingoing beam halo
505  double truedt[4] = {1000, 1000, 1000, 1000};
506  //There are four types of segments associated to beam halo, test each hypothesis:
507  //IT beam halo, ingoing track
508  double twindow_seg = 15;
509  if (std::abs(tcorsegincbh) < twindow_seg)
510  truedt[0] = tBXrh - tBXseg - std::abs(rhZ - segZ) / c_cm_per_ns;
511  //IT beam halo, outgoing track
512  if (std::abs(tcorseg) < twindow_seg)
513  truedt[1] = tBXseg - tBXrh - std::abs(rhZ - segZ) / c_cm_per_ns;
514  //OT beam halo (from next BX), ingoing track
515  if (tcorsegincbh > 25 - twindow_seg && std::abs(tcorsegincbh) < 25 + twindow_seg)
516  truedt[2] = tBXrh - tBXseg - std::abs(rhZ - segZ) / c_cm_per_ns;
517  //OT beam halo (from next BX), outgoing track
518  if (tcorseg > 25 - twindow_seg && tcorseg < 25 + twindow_seg)
519  truedt[3] = tBXseg - tBXrh - std::abs(rhZ - segZ) / c_cm_per_ns;
520 
521  if (subdet == EB) {
522  if (rhet < et_thresh_rh_eb)
523  return false;
524  if (rhet < 20 && ishlt)
525  return false;
526  if (std::abs(deltaPhi(rhPhi, segPhi)) > dphi_thresh_segvsrh_eb)
527  return false;
528  if (rhR - segR < dr_lowthresh_segvsrh_eb)
529  return false;
530  if (rhR - segR > dr_highthresh_segvsrh_eb)
531  return false;
532  if (std::abs(truedt[0]) > dt_segvsrh_eb && std::abs(truedt[1]) > dt_segvsrh_eb &&
533  std::abs(truedt[2]) > dt_segvsrh_eb && std::abs(truedt[3]) > dt_segvsrh_eb)
534  return false;
535  return true;
536  }
537 
538  if (subdet == EE) {
539  if (rhet < et_thresh_rh_ee)
540  return false;
541  if (rhet < 20 && ishlt)
542  return false;
543  if (std::abs(deltaPhi(rhPhi, segPhi)) > dphi_thresh_segvsrh_ee)
544  return false;
545  if (rhR - segR < dr_lowthresh_segvsrh_ee)
546  return false;
547  if (rhR - segR > dr_highthresh_segvsrh_ee)
548  return false;
549  if (std::abs(truedt[0]) > dt_segvsrh_ee && std::abs(truedt[1]) > dt_segvsrh_ee &&
550  std::abs(truedt[2]) > dt_segvsrh_ee && std::abs(truedt[3]) > dt_segvsrh_ee)
551  return false;
552  return true;
553  }
554 
555  if (subdet == HB) {
556  if (rhet < et_thresh_rh_hb)
557  return false;
558  if (rhet < 20 && ishlt)
559  return false;
560  if (std::abs(deltaPhi(rhPhi, segPhi)) > dphi_thresh_segvsrh_hb)
561  return false;
562  if (rhR - segR < dr_lowthresh_segvsrh_hb)
563  return false;
564  if (rhR - segR > dr_highthresh_segvsrh_hb)
565  return false;
566  if (std::abs(truedt[0]) > dt_segvsrh_hb && std::abs(truedt[1]) > dt_segvsrh_hb &&
567  std::abs(truedt[2]) > dt_segvsrh_hb && std::abs(truedt[3]) > dt_segvsrh_hb)
568  return false;
569  return true;
570  }
571 
572  if (subdet == HE) {
573  if (rhet < et_thresh_rh_he)
574  return false;
575  if (rhet < 20 && ishlt)
576  return false;
577  if (std::abs(deltaPhi(rhPhi, segPhi)) > dphi_thresh_segvsrh_he)
578  return false;
579  if (rhR - segR < dr_lowthresh_segvsrh_he)
580  return false;
581  if (rhR - segR > dr_highthresh_segvsrh_he)
582  return false;
583  if (std::abs(truedt[0]) > dt_segvsrh_he && std::abs(truedt[1]) > dt_segvsrh_he &&
584  std::abs(truedt[2]) > dt_segvsrh_he && std::abs(truedt[3]) > dt_segvsrh_he)
585  return false;
586  return true;
587  }
588 
589  return false;
590 }
591 
593  reco::GlobalHaloData& thehalodata,
594  bool isbarrel) {
595  for (size_t ihit = 0; ihit < bhtaggedrechits.size(); ++ihit) {
596  bool alreadyincl = false;
597  edm::Ref<EcalRecHitCollection> rhRef(bhtaggedrechits[ihit]);
599  if (isbarrel)
600  refrhcoll = thehalodata.GetEBRechits();
601  else
602  refrhcoll = thehalodata.GetEERechits();
603  for (size_t jhit = 0; jhit < refrhcoll.size(); jhit++) {
604  edm::Ref<EcalRecHitCollection> rhitRef(refrhcoll[jhit]);
605  if (rhitRef->detid() == rhRef->detid())
606  alreadyincl = true;
607  if (rhitRef->detid() == rhRef->detid())
608  break;
609  }
610  if (!alreadyincl && isbarrel)
611  thehalodata.GetEBRechits().push_back(rhRef);
612  if (!alreadyincl && !isbarrel)
613  thehalodata.GetEERechits().push_back(rhRef);
614  }
615 }
616 
618  reco::GlobalHaloData& thehalodata) {
619  for (size_t ihit = 0; ihit < bhtaggedrechits.size(); ++ihit) {
620  bool alreadyincl = false;
621  edm::Ref<HBHERecHitCollection> rhRef(bhtaggedrechits[ihit]);
623  refrhcoll = thehalodata.GetHBHERechits();
624  for (size_t jhit = 0; jhit < refrhcoll.size(); jhit++) {
625  edm::Ref<HBHERecHitCollection> rhitRef(refrhcoll[jhit]);
626  if (rhitRef->detid() == rhRef->detid())
627  alreadyincl = true;
628  if (rhitRef->detid() == rhRef->detid())
629  break;
630  }
631  if (!alreadyincl)
632  thehalodata.GetHBHERechits().push_back(rhRef);
633  }
634 }
const double Pi
bool SegmentMatchingEE(reco::GlobalHaloData &thehalodata, const std::vector< reco::HaloClusterCandidateECAL > &haloclustercands, float iZ, float iR, float iT, float iPhi, bool ishlt)
void AddtoBeamHaloEBEERechits(edm::RefVector< EcalRecHitCollection > &bhtaggedrechits, reco::GlobalHaloData &thehalodata, bool isbarrel)
double pt() const final
transverse momentum
void SetSegmentIsEECaloMatched(bool b)
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
Definition: CSCGeometry.cc:100
T z() const
Definition: PV3DBase.h:61
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
void SetMETOverSumEt(float x)
double hadEt() const
Definition: CaloTower.h:136
const std::vector< HaloClusterCandidateHCAL > & getHaloClusterCandidatesHB() const
Definition: HcalHaloData.h:52
double sumEt() const
Definition: MET.h:56
std::vector< PhiWedge > & GetMatchedEcalPhiWedges()
const std::vector< HaloClusterCandidateHCAL > & getHaloClusterCandidatesHE() const
Definition: HcalHaloData.h:55
void SetHaloPatternFoundHE(bool b)
double et(double vtxZ) const
Definition: CaloTower.h:150
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
int Phi_To_HcaliPhi(float phi)
void SetHaloPatternFoundEE(bool b)
edm::RefVector< HBHERecHitCollection > & GetHBHERechits()
T sqrt(T t)
Definition: SSEVec.h:19
void SetSegmentIsEBCaloMatched(bool b)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
reco::GlobalHaloData Calculate(const CaloGeometry &TheCaloGeometry, const CSCGeometry &TheCSCGeometry, const reco::CaloMET &TheCaloMET, edm::Handle< edm::View< reco::Candidate > > &TheCaloTowers, edm::Handle< CSCSegmentCollection > &TheCSCSegments, edm::Handle< CSCRecHit2DCollection > &TheCSCRecHits, edm::Handle< reco::MuonCollection > &TheMuons, const reco::CSCHaloData &TheCSCHaloData, const reco::EcalHaloData &TheEcalHaloData, const reco::HcalHaloData &TheHcalHaloData, bool ishlt=false)
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
detectorregion
bool SegmentMatchingHB(reco::GlobalHaloData &thehalodata, const std::vector< reco::HaloClusterCandidateHCAL > &haloclustercands, float iZ, float iR, float iT, float iPhi, bool ishlt)
bool SegmentMatchingEB(reco::GlobalHaloData &thehalodata, const std::vector< reco::HaloClusterCandidateECAL > &haloclustercands, float iZ, float iR, float iT, float iPhi, bool ishlt)
Definition: DetId.h:17
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
size_type size() const
Size of the RefVector.
Definition: RefVector.h:102
void AddtoBeamHaloHBHERechits(edm::RefVector< HBHERecHitCollection > &bhtaggedrechits, reco::GlobalHaloData &thehalodata)
void SetMETCorrections(float x, float y)
int iphi() const
Definition: CaloTower.h:202
const std::vector< HaloClusterCandidateECAL > & getHaloClusterCandidatesEB() const
Definition: EcalHaloData.h:47
double emEt() const
Definition: CaloTower.h:135
int ieta() const
Definition: CaloTower.h:200
void SetOverlappingCSCRecHits(int x)
Definition: PhiWedge.h:63
T perp2() const
Definition: PV3DBase.h:68
bool isValid() const
Definition: HandleBase.h:70
fixed size matrix
HLT enums.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
std::vector< PhiWedge > & GetMatchedHcalPhiWedges()
void SetOverlappingCSCSegments(int x)
Definition: PhiWedge.h:62
const std::vector< HaloClusterCandidateECAL > & getHaloClusterCandidatesEE() const
Definition: EcalHaloData.h:49
float x
bool SegmentMatchingHE(reco::GlobalHaloData &thehalodata, const std::vector< reco::HaloClusterCandidateHCAL > &haloclustercands, float iZ, float iR, float iT, float iPhi, bool ishlt)
int Phi_To_EcaliPhi(float phi)
void SetSegmentIsHECaloMatched(bool b)
edm::RefVector< EcalRecHitCollection > & GetEBRechits()
const std::vector< GlobalPoint > & GetCSCTrackImpactPositions() const
Definition: CSCHaloData.h:100
void SetSegmentIsHBCaloMatched(bool b)
edm::RefVector< EcalRecHitCollection > & GetEERechits()
static char chambers[264][20]
Definition: ReadPGInfo.cc:243
bool ApplyMatchingCuts(int subdet, bool ishlt, double rhet, double segZ, double rhZ, double segR, double rhR, double segT, double rhT, double segPhi, double rhPhi)
double phi() const final
momentum azimuthal angle
static constexpr int CSC
Definition: MuonSubdetId.h:12
const std::vector< PhiWedge > & GetPhiWedges() const
Definition: HcalHaloData.h:45
void SetHaloPatternFoundHB(bool b)
Geom::Theta< T > theta() const
Definition: PV3DBase.h:72
const std::vector< PhiWedge > & GetPhiWedges() const
Definition: EcalHaloData.h:33
const GeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
Definition: CSCGeometry.cc:89
void SetHaloPatternFoundEB(bool b)