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