CMS 3D CMS Logo

CSCHaloAlgo.cc
Go to the documentation of this file.
1 
4 /*
5  [class]: CSCHaloAlgo
6  [authors]: R. Remington, The University of Florida
7  [description]: See CSCHaloAlgo.h
8  [date]: October 15, 2009
9 */
10 using namespace reco;
11 using namespace std;
12 using namespace edm;
13 #include "TMath.h"
14 namespace {
15  constexpr float c_cm_per_ns = 29.9792458;
16 };
17 CSCHaloAlgo::CSCHaloAlgo(edm::ConsumesCollector iC) : geoToken_(iC.esConsumes()), geo_(nullptr), hgeo_(nullptr) {
18  deta_threshold = 0.;
19  min_inner_radius = 0.;
20  max_inner_radius = 9999.;
21  min_outer_radius = 0.;
22  max_outer_radius = 9999.;
23  dphi_threshold = 999.;
24  norm_chi2_threshold = 999.;
25  recHit_t0 = 0.;
26  recHit_twindow = 25.;
27  expected_BX = 3;
28  max_dt_muon_segment = -10.0;
30 
31  min_outer_theta = 0.;
33 
34  matching_dphi_threshold = 0.18; //radians
37 
38  et_thresh_rh_hbhe = 25; //GeV
39  et_thresh_rh_ee = 10;
40  et_thresh_rh_eb = 10;
41 
42  dphi_thresh_segvsrh_hbhe = 0.05; //radians
45 
46  dr_lowthresh_segvsrh_hbhe = -20; //cm
49 
53 
57 
61 }
62 
64  edm::Handle<reco::MuonCollection>& TheCosmicMuons,
65  const edm::Handle<reco::MuonTimeExtraMap> TheCSCTimeMap,
67  edm::Handle<CSCSegmentCollection>& TheCSCSegments,
73  edm::Handle<edm::TriggerResults>& TheHLTResults,
75  const edm::Handle<CSCALCTDigiCollection>& TheALCTs,
76  MuonSegmentMatcher* TheMatcher,
77  const edm::Event& TheEvent,
78  const edm::EventSetup& TheSetup) {
79  reco::CSCHaloData TheCSCHaloData;
80  int imucount = 0;
81 
82  bool calomatched = false;
83  bool ECALBmatched = false;
84  bool ECALEmatched = false;
85  bool HCALmatched = false;
86 
87  geo_ = &TheSetup.getData(geoToken_);
88  hgeo_ = dynamic_cast<const HcalGeometry*>(geo_->getSubdetectorGeometry(DetId::Hcal, 1));
89 
90  //}
91  bool trkmuunvetoisdefault = false; //Pb with low pt tracker muons that veto good csc segments/halo triggers.
92  //Test to "unveto" low pt trk muons.
93  //For now, we just recalculate everything without the veto and add an extra set of variables to the class CSCHaloData.
94  //If this is satisfactory, these variables can become the default ones by setting trkmuunvetoisdefault to true.
95  if (TheCosmicMuons.isValid()) {
96  short int n_tracks_small_beta = 0;
97  short int n_tracks_small_dT = 0;
98  short int n_tracks_small_dT_and_beta = 0;
99  for (reco::MuonCollection::const_iterator iMuon = TheCosmicMuons->begin(); iMuon != TheCosmicMuons->end();
100  iMuon++, imucount++) {
101  reco::TrackRef Track = iMuon->outerTrack();
102  if (!Track)
103  continue;
104 
105  bool StoreTrack = false;
106  // Calculate global phi coordinate for central most rechit in the track
107  float innermost_global_z = 1500.;
108  float outermost_global_z = 0.;
109  GlobalPoint InnerMostGlobalPosition(0., 0., 0.); // smallest abs(z)
110  GlobalPoint OuterMostGlobalPosition(0., 0., 0.); // largest abs(z)
111  int nCSCHits = 0;
112  for (unsigned int j = 0; j < Track->extra()->recHitsSize(); j++) {
113  auto hit = Track->extra()->recHitRef(j);
114  if (!hit->isValid())
115  continue;
116  DetId TheDetUnitId(hit->geographicalId());
117  if (TheDetUnitId.det() != DetId::Muon)
118  continue;
119  if (TheDetUnitId.subdetId() != MuonSubdetId::CSC)
120  continue;
121 
122  const GeomDetUnit* TheUnit = TheCSCGeometry.idToDetUnit(TheDetUnitId);
123  LocalPoint TheLocalPosition = hit->localPosition();
124  const BoundPlane& TheSurface = TheUnit->surface();
125  const GlobalPoint TheGlobalPosition = TheSurface.toGlobal(TheLocalPosition);
126 
127  float z = TheGlobalPosition.z();
128  if (abs(z) < innermost_global_z) {
129  innermost_global_z = abs(z);
130  InnerMostGlobalPosition = GlobalPoint(TheGlobalPosition);
131  }
132  if (abs(z) > outermost_global_z) {
133  outermost_global_z = abs(z);
134  OuterMostGlobalPosition = GlobalPoint(TheGlobalPosition);
135  }
136  nCSCHits++;
137  }
138 
139  std::vector<const CSCSegment*> MatchedSegments = TheMatcher->matchCSC(*Track, TheEvent);
140  // Find the inner and outer segments separately in case they don't agree completely with recHits
141  // Plan for the possibility segments in both endcaps
142  float InnerSegmentTime[2] = {0, 0};
143  float OuterSegmentTime[2] = {0, 0};
144  float innermost_seg_z[2] = {1500, 1500};
145  float outermost_seg_z[2] = {0, 0};
146  for (std::vector<const CSCSegment*>::const_iterator segment = MatchedSegments.begin();
147  segment != MatchedSegments.end();
148  ++segment) {
149  CSCDetId TheCSCDetId((*segment)->cscDetId());
150  const CSCChamber* TheCSCChamber = TheCSCGeometry.chamber(TheCSCDetId);
151  LocalPoint TheLocalPosition = (*segment)->localPosition();
152  const GlobalPoint TheGlobalPosition = TheCSCChamber->toGlobal(TheLocalPosition);
153  float z = TheGlobalPosition.z();
154  int TheEndcap = TheCSCDetId.endcap();
155  if (abs(z) < innermost_seg_z[TheEndcap - 1]) {
156  innermost_seg_z[TheEndcap - 1] = abs(z);
157  InnerSegmentTime[TheEndcap - 1] = (*segment)->time();
158  }
159  if (abs(z) > outermost_seg_z[TheEndcap - 1]) {
160  outermost_seg_z[TheEndcap - 1] = abs(z);
161  OuterSegmentTime[TheEndcap - 1] = (*segment)->time();
162  }
163  }
164 
165  if (nCSCHits < 3)
166  continue; // This needs to be optimized, but is the minimum
167 
168  float dT_Segment = 0; // default safe value, looks like collision muon
169 
170  if (innermost_seg_z[0] < outermost_seg_z[0]) // two segments in ME+
171  dT_Segment = OuterSegmentTime[0] - InnerSegmentTime[0];
172  if (innermost_seg_z[1] < outermost_seg_z[1]) // two segments in ME-
173  {
174  // replace the measurement if there weren't segments in ME+ or
175  // if the track in ME- has timing more consistent with an incoming particle
176  if (dT_Segment == 0.0 || OuterSegmentTime[1] - InnerSegmentTime[1] < dT_Segment)
177  dT_Segment = OuterSegmentTime[1] - InnerSegmentTime[1];
178  }
179 
180  if (OuterMostGlobalPosition.x() == 0. || OuterMostGlobalPosition.y() == 0. || OuterMostGlobalPosition.z() == 0.)
181  continue;
182  if (InnerMostGlobalPosition.x() == 0. || InnerMostGlobalPosition.y() == 0. || InnerMostGlobalPosition.z() == 0.)
183  continue;
184 
185  //Its a CSC Track,store it if it passes halo selection
186  StoreTrack = true;
187 
188  float deta = abs(OuterMostGlobalPosition.eta() - InnerMostGlobalPosition.eta());
189  float dphi = abs(deltaPhi(OuterMostGlobalPosition.barePhi(), InnerMostGlobalPosition.barePhi()));
190  float theta = Track->outerMomentum().theta();
191  float innermost_x = InnerMostGlobalPosition.x();
192  float innermost_y = InnerMostGlobalPosition.y();
193  float outermost_x = OuterMostGlobalPosition.x();
194  float outermost_y = OuterMostGlobalPosition.y();
195  float innermost_r = TMath::Sqrt(innermost_x * innermost_x + innermost_y * innermost_y);
196  float outermost_r = TMath::Sqrt(outermost_x * outermost_x + outermost_y * outermost_y);
197 
198  if (deta < deta_threshold)
199  StoreTrack = false;
201  StoreTrack = false;
202  if (dphi > dphi_threshold)
203  StoreTrack = false;
204  if (innermost_r < min_inner_radius)
205  StoreTrack = false;
206  if (innermost_r > max_inner_radius)
207  StoreTrack = false;
208  if (outermost_r < min_outer_radius)
209  StoreTrack = false;
210  if (outermost_r > max_outer_radius)
211  StoreTrack = false;
213  StoreTrack = false;
214 
215  if (StoreTrack) {
216  TheCSCHaloData.GetCSCTrackImpactPositions().push_back(InnerMostGlobalPosition);
217  TheCSCHaloData.GetTracks().push_back(Track);
218  }
219 
220  // Analyze the MuonTimeExtra information
221  if (TheCSCTimeMap.isValid()) {
222  reco::MuonRef muonR(TheCosmicMuons, imucount);
223  const reco::MuonTimeExtraMap& timeMapCSC = *TheCSCTimeMap;
224  reco::MuonTimeExtra timecsc = timeMapCSC[muonR];
225  float freeInverseBeta = timecsc.freeInverseBeta();
226 
227  if (dT_Segment < max_dt_muon_segment)
228  n_tracks_small_dT++;
229  if (freeInverseBeta < max_free_inverse_beta)
230  n_tracks_small_beta++;
231  if ((dT_Segment < max_dt_muon_segment) && (freeInverseBeta < max_free_inverse_beta))
232  n_tracks_small_dT_and_beta++;
233  } else {
234  static std::atomic<bool> MuonTimeFail{false};
235  bool expected = false;
236  if (MuonTimeFail.compare_exchange_strong(expected, true, std::memory_order_acq_rel)) {
237  edm::LogWarning("InvalidInputTag")
238  << "The MuonTimeExtraMap does not appear to be in the event. Some beam halo "
239  << " identification variables will be empty";
240  }
241  }
242  }
243  TheCSCHaloData.SetNIncomingTracks(n_tracks_small_dT, n_tracks_small_beta, n_tracks_small_dT_and_beta);
244  } else // collection is invalid
245  {
246  static std::atomic<bool> CosmicFail{false};
247  bool expected = false;
248  if (CosmicFail.compare_exchange_strong(expected, true, std::memory_order_acq_rel)) {
249  edm::LogWarning("InvalidInputTag")
250  << " The Cosmic Muon collection does not appear to be in the event. These beam halo "
251  << " identification variables will be empty";
252  }
253  }
254 
255  // Loop over the CSCRecHit2D collection to look for out-of-time recHits
256  // Out-of-time is defined as tpeak outside [t_0 + TOF - t_window, t_0 + TOF + t_window]
257  // where t_0 and t_window are configurable parameters
258  short int n_recHitsP = 0;
259  short int n_recHitsM = 0;
260  if (TheCSCRecHits.isValid()) {
262  for (dRHIter = TheCSCRecHits->begin(); dRHIter != TheCSCRecHits->end(); dRHIter++) {
263  if (!((*dRHIter).isValid()))
264  continue; // only interested in valid hits
265  CSCDetId idrec = (CSCDetId)(*dRHIter).cscDetId();
266  float RHTime = (*dRHIter).tpeak();
267  LocalPoint rhitlocal = (*dRHIter).localPosition();
268  const CSCChamber* chamber = TheCSCGeometry.chamber(idrec);
269  GlobalPoint globalPosition = chamber->toGlobal(rhitlocal);
270  float globZ = globalPosition.z();
271  if (RHTime < (recHit_t0 - recHit_twindow)) {
272  if (globZ > 0)
273  n_recHitsP++;
274  else
275  n_recHitsM++;
276  }
277 
278  /*
279 
280  float globX = globalPosition.x();
281  float globY = globalPosition.y();
282  float globZ = globalPosition.z();
283  float TOF = (sqrt(globX*globX+ globY*globY + globZ*globZ))/29.9792458 ; //cm -> ns
284  if ( (RHTime < (recHit_t0 + TOF - recHit_twindow)) || (RHTime > (recHit_t0 + TOF + recHit_twindow)) )
285  {
286  if( globZ > 0 )
287  n_recHitsP++;
288  else
289  n_recHitsM++;
290  }
291  */
292  }
293  } else {
294  static std::atomic<bool> RecHitFail{false};
295  bool expected = false;
296  if (RecHitFail.compare_exchange_strong(expected, true, std::memory_order_acq_rel)) {
297  edm::LogWarning("InvalidInputTag")
298  << "The requested CSCRecHit2DCollection does not appear to be in the event. The CSC RecHit "
299  << " variables used for halo identification will not be calculated or stored";
300  }
301  }
302  TheCSCHaloData.SetNOutOfTimeHits(n_recHitsP + n_recHitsM);
303  // MLR
304  // Loop through CSCSegments and count the number of "flat" segments with the same (r,phi),
305  // saving the value in TheCSCHaloData.
306  short int maxNSegments = 0;
307  bool plus_endcap = false;
308  bool minus_endcap = false;
309  bool both_endcaps = false;
310  bool both_endcaps_loose = false;
311  // bool both_endcaps_dtcut = false;
312 
313  short int maxNSegments_alt = 0;
314  bool both_endcaps_alt = false;
315  bool both_endcaps_loose_alt = false;
316  bool both_endcaps_loose_dtcut_alt = false;
317 
318  //float r = 0., phi = 0.;
319  if (TheCSCSegments.isValid()) {
320  for (CSCSegmentCollection::const_iterator iSegment = TheCSCSegments->begin(); iSegment != TheCSCSegments->end();
321  iSegment++) {
322  CSCDetId iCscDetID = iSegment->cscDetId();
323  bool Segment1IsGood = true;
324  bool Segment1IsGood_alt = true;
325 
326  //avoid segments from collision muons
327  if (TheMuons.isValid()) {
328  for (reco::MuonCollection::const_iterator mu = TheMuons->begin();
329  mu != TheMuons->end() && (Segment1IsGood || !trkmuunvetoisdefault);
330  mu++) {
331  bool lowpttrackmu = false;
332  if (!mu->isTrackerMuon() && !mu->isGlobalMuon() && mu->isStandAloneMuon())
333  continue;
334  if (!mu->isTrackerMuon() && !mu->isGlobalMuon() && mu->isStandAloneMuon() && trkmuunvetoisdefault)
335  continue;
336  if (!mu->isGlobalMuon() && mu->isTrackerMuon() && mu->pt() < 3)
337  lowpttrackmu = true;
338  const std::vector<MuonChamberMatch> chambers = mu->matches();
339  for (std::vector<MuonChamberMatch>::const_iterator kChamber = chambers.begin(); kChamber != chambers.end();
340  kChamber++) {
341  if (kChamber->detector() != MuonSubdetId::CSC)
342  continue;
343  for (std::vector<reco::MuonSegmentMatch>::const_iterator kSegment = kChamber->segmentMatches.begin();
344  kSegment != kChamber->segmentMatches.end();
345  kSegment++) {
346  edm::Ref<CSCSegmentCollection> cscSegRef = kSegment->cscSegmentRef;
347  CSCDetId kCscDetID = cscSegRef->cscDetId();
348 
349  if (kCscDetID == iCscDetID) {
350  Segment1IsGood = false;
351  if (!lowpttrackmu)
352  Segment1IsGood_alt = false;
353  }
354  }
355  }
356  }
357  }
358  if (!Segment1IsGood && !Segment1IsGood_alt)
359  continue;
360 
361  // Get local direction vector; if direction runs parallel to beamline,
362  // count this segment as beam halo candidate.
363  LocalPoint iLocalPosition = iSegment->localPosition();
364  LocalVector iLocalDirection = iSegment->localDirection();
365 
366  GlobalPoint iGlobalPosition = TheCSCGeometry.chamber(iCscDetID)->toGlobal(iLocalPosition);
367  GlobalVector iGlobalDirection = TheCSCGeometry.chamber(iCscDetID)->toGlobal(iLocalDirection);
368 
369  float iTheta = iGlobalDirection.theta();
370  if (iTheta > max_segment_theta && iTheta < TMath::Pi() - max_segment_theta)
371  continue;
372 
373  float iPhi = iGlobalPosition.phi();
374  float iR = TMath::Sqrt(iGlobalPosition.x() * iGlobalPosition.x() + iGlobalPosition.y() * iGlobalPosition.y());
375  float iZ = iGlobalPosition.z();
376  float iT = iSegment->time();
377 
378  // if(abs(iZ)<650&& TheEvent.id().run()< 251737) iT-= 25;
379  //Calo matching:
380 
381  bool hbhematched = HCALSegmentMatching(hbhehits,
388  iZ,
389  iR,
390  iT,
391  iPhi);
392  bool ebmatched = ECALSegmentMatching(ecalebhits,
399  iZ,
400  iR,
401  iT,
402  iPhi);
403  bool eematched = ECALSegmentMatching(ecaleehits,
410  iZ,
411  iR,
412  iT,
413  iPhi);
414  calomatched |= (hbhematched || ebmatched || eematched);
415  HCALmatched |= hbhematched;
416  ECALBmatched |= ebmatched;
417  ECALEmatched |= eematched;
418 
419  short int nSegs = 0;
420  short int nSegs_alt = 0;
421  // Changed to loop over all Segments (so N^2) to catch as many segments as possible.
422  for (CSCSegmentCollection::const_iterator jSegment = TheCSCSegments->begin(); jSegment != TheCSCSegments->end();
423  jSegment++) {
424  if (jSegment == iSegment)
425  continue;
426  bool Segment2IsGood = true;
427  bool Segment2IsGood_alt = true;
428  LocalPoint jLocalPosition = jSegment->localPosition();
429  LocalVector jLocalDirection = jSegment->localDirection();
430  CSCDetId jCscDetID = jSegment->cscDetId();
431  GlobalPoint jGlobalPosition = TheCSCGeometry.chamber(jCscDetID)->toGlobal(jLocalPosition);
432  GlobalVector jGlobalDirection = TheCSCGeometry.chamber(jCscDetID)->toGlobal(jLocalDirection);
433  float jTheta = jGlobalDirection.theta();
434  float jPhi = jGlobalPosition.phi();
435  float jR = TMath::Sqrt(jGlobalPosition.x() * jGlobalPosition.x() + jGlobalPosition.y() * jGlobalPosition.y());
436  float jZ = jGlobalPosition.z();
437  float jT = jSegment->time();
438  // if(abs(jZ)<650&& TheEvent.id().run() < 251737)jT-= 25;
439  if (std::abs(deltaPhi(jPhi, iPhi)) <= max_segment_phi_diff &&
440  (std::abs(jR - iR) < 0.05 * std::abs(jZ - iZ) || jZ * iZ > 0) &&
441  ((jR - iR) > -0.02 * std::abs(jZ - iZ) || iT > jT || jZ * iZ > 0) &&
442  ((iR - jR) > -0.02 * std::abs(jZ - iZ) || iT < jT || jZ * iZ > 0) &&
443  (std::abs(jR - iR) <= max_segment_r_diff || jZ * iZ < 0) &&
444  (jTheta < max_segment_theta || jTheta > TMath::Pi() - max_segment_theta)) {
446  if (TheMuons.isValid()) {
447  for (reco::MuonCollection::const_iterator mu = TheMuons->begin();
448  mu != TheMuons->end() && (Segment2IsGood || !trkmuunvetoisdefault);
449  mu++) {
450  bool lowpttrackmu = false;
451  if (!mu->isTrackerMuon() && !mu->isGlobalMuon() && mu->isStandAloneMuon())
452  continue;
453  if (!mu->isGlobalMuon() && mu->isTrackerMuon() && mu->pt() < 3)
454  lowpttrackmu = true;
455  const std::vector<MuonChamberMatch> chambers = mu->matches();
456  for (std::vector<MuonChamberMatch>::const_iterator kChamber = chambers.begin();
457  kChamber != chambers.end();
458  kChamber++) {
459  if (kChamber->detector() != MuonSubdetId::CSC)
460  continue;
461  for (std::vector<reco::MuonSegmentMatch>::const_iterator kSegment = kChamber->segmentMatches.begin();
462  kSegment != kChamber->segmentMatches.end();
463  kSegment++) {
464  edm::Ref<CSCSegmentCollection> cscSegRef = kSegment->cscSegmentRef;
465  CSCDetId kCscDetID = cscSegRef->cscDetId();
466 
467  if (kCscDetID == jCscDetID) {
468  Segment2IsGood = false;
469  if (!lowpttrackmu)
470  Segment2IsGood_alt = false;
471  }
472  }
473  }
474  }
475  }
476  if (Segment1IsGood && Segment2IsGood) {
477  nSegs++;
478  minus_endcap = iGlobalPosition.z() < 0 || jGlobalPosition.z() < 0;
479  plus_endcap = iGlobalPosition.z() > 0 || jGlobalPosition.z() > 0;
480  // if( abs(jT-iT)/sqrt( (jR-iR)*(jR-iR)+(jZ-iZ)*(jZ-iZ) )<0.05 && abs(jT-iT)/sqrt( (jR-iR)*(jR-iR)+(jZ-iZ)*(jZ-iZ) )>0.02 && minus_endcap&&plus_endcap ) both_endcaps_dtcut =true;
481  }
482  if (Segment1IsGood_alt && Segment2IsGood_alt) {
483  nSegs_alt++;
484  minus_endcap = iGlobalPosition.z() < 0 || jGlobalPosition.z() < 0;
485  plus_endcap = iGlobalPosition.z() > 0 || jGlobalPosition.z() > 0;
486  double iTBX = iT + sqrt(iGlobalPosition.mag2()) / c_cm_per_ns;
487  double jTBX = jT + sqrt(jGlobalPosition.mag2()) / c_cm_per_ns;
488  double truedt = (iTBX > jTBX) ? iTBX - jTBX - std::abs(iZ - jZ) / c_cm_per_ns
489  : jTBX - iTBX - std::abs(iZ - jZ) / c_cm_per_ns;
490  if (std::abs(truedt) < 15 && (iT > -15 || jT > -15) && minus_endcap && plus_endcap)
491  both_endcaps_loose_dtcut_alt = true;
492  }
493  }
494  }
495  // Correct the fact that the way nSegs counts will always be short by 1
496  if (nSegs > 0)
497  nSegs++;
498 
499  // The opposite endcaps segments do not need to belong to the longest chain.
500  if (nSegs > 0)
501  both_endcaps_loose = both_endcaps_loose ? both_endcaps_loose : minus_endcap && plus_endcap;
502  if (nSegs_alt > 0)
503  nSegs_alt++;
504  if (nSegs_alt > 0)
505  both_endcaps_loose_alt = both_endcaps_loose_alt ? both_endcaps_loose_alt : minus_endcap && plus_endcap;
506 
507  // if (nSegs > 0) both_endcaps_dt20ns = both_endcaps_dt20ns ? both_endcaps_dt20ns : minus_endcap && plus_endcap &&dt20ns;
508  if (nSegs > maxNSegments) {
509  // Use value of r, phi to collect halo CSCSegments for examining timing (not coded yet...)
510  //r = iR;
511  //phi = iPhi;
512  maxNSegments = nSegs;
513  both_endcaps = both_endcaps ? both_endcaps : minus_endcap && plus_endcap;
514  }
515 
516  if (nSegs_alt > maxNSegments_alt) {
517  maxNSegments_alt = nSegs_alt;
518  both_endcaps_alt = both_endcaps_alt ? both_endcaps_alt : minus_endcap && plus_endcap;
519  }
520  }
521  }
522 
523  //Deprecated methods, kept for backward compatibility
524  TheCSCHaloData.SetHLTBit(false);
525  TheCSCHaloData.SetNumberOfHaloTriggers(0, 0);
526  TheCSCHaloData.SetNumberOfHaloTriggers_TrkMuUnVeto(0, 0);
527  TheCSCHaloData.SetNOutOfTimeTriggers(0, 0);
528 
529  //Current methods used
530  TheCSCHaloData.SetNFlatHaloSegments(maxNSegments);
531  TheCSCHaloData.SetSegmentsBothEndcaps(both_endcaps);
532  TheCSCHaloData.SetNFlatHaloSegments_TrkMuUnVeto(maxNSegments_alt);
533  TheCSCHaloData.SetSegmentsBothEndcaps_Loose_TrkMuUnVeto(both_endcaps_loose_alt);
534  TheCSCHaloData.SetSegmentsBothEndcaps_Loose_dTcut_TrkMuUnVeto(both_endcaps_loose_dtcut_alt);
535  TheCSCHaloData.SetSegmentIsCaloMatched(calomatched);
536  TheCSCHaloData.SetSegmentIsHCaloMatched(HCALmatched);
537  TheCSCHaloData.SetSegmentIsEBCaloMatched(ECALBmatched);
538  TheCSCHaloData.SetSegmentIsEECaloMatched(ECALEmatched);
539 
540  return TheCSCHaloData;
541 }
542 
544  const GlobalPoint pos = ((id.det() == DetId::Hcal) ? hgeo_->getPosition(id) : GlobalPoint(geo_->getPosition(id)));
545  math::XYZPoint posV(pos.x() - vtx.x(), pos.y() - vtx.y(), pos.z() - vtx.z());
546  return posV;
547 }
548 
550  float et_thresh_rh,
551  float dphi_thresh_segvsrh,
552  float dr_lowthresh_segvsrh,
553  float dr_highthresh_segvsrh,
554  float dt_lowthresh_segvsrh,
555  float dt_highthresh_segvsrh,
556  float iZ,
557  float iR,
558  float iT,
559  float iPhi) {
560  reco::Vertex::Point vtx(0, 0, 0);
561  for (size_t ihit = 0; ihit < rechitcoll->size(); ++ihit) {
562  const HBHERecHit& rechit = (*rechitcoll)[ihit];
563  math::XYZPoint rhpos = getPosition(rechit.id(), vtx);
564  double rhet = rechit.energy() / cosh(rhpos.eta());
565  double dphi_rhseg = abs(deltaPhi(rhpos.phi(), iPhi));
566  double dr_rhseg = sqrt(rhpos.x() * rhpos.x() + rhpos.y() * rhpos.y()) - iR;
567  double dtcorr_rhseg = rechit.time() - abs(rhpos.z() - iZ) / 30 - iT;
568  if ((rechit.time() < -3) && (rhpos.z() * iZ < 0 || abs(rhpos.z()) < 200) && rhet > et_thresh_rh &&
569  dphi_rhseg < dphi_thresh_segvsrh && dr_rhseg < dr_highthresh_segvsrh &&
570  dr_rhseg > dr_lowthresh_segvsrh && //careful: asymmetric cut might not be the most appropriate thing
571  dtcorr_rhseg > dt_lowthresh_segvsrh && dtcorr_rhseg < dt_highthresh_segvsrh)
572  return true;
573  }
574  return false;
575 }
576 
578  float et_thresh_rh,
579  float dphi_thresh_segvsrh,
580  float dr_lowthresh_segvsrh,
581  float dr_highthresh_segvsrh,
582  float dt_lowthresh_segvsrh,
583  float dt_highthresh_segvsrh,
584  float iZ,
585  float iR,
586  float iT,
587  float iPhi) {
588  reco::Vertex::Point vtx(0, 0, 0);
589  for (size_t ihit = 0; ihit < rechitcoll->size(); ++ihit) {
590  const EcalRecHit& rechit = (*rechitcoll)[ihit];
591  math::XYZPoint rhpos = getPosition(rechit.id(), vtx);
592  double rhet = rechit.energy() / cosh(rhpos.eta());
593  double dphi_rhseg = abs(deltaPhi(rhpos.phi(), iPhi));
594  double dr_rhseg = sqrt(rhpos.x() * rhpos.x() + rhpos.y() * rhpos.y()) - iR;
595  double dtcorr_rhseg = rechit.time() - abs(rhpos.z() - iZ) / 30 - iT;
596  if ((rechit.time() < -1) && (rhpos.z() * iZ < 0 || abs(rhpos.z()) < 200) && rhet > et_thresh_rh &&
597  dphi_rhseg < dphi_thresh_segvsrh && dr_rhseg < dr_highthresh_segvsrh &&
598  dr_rhseg > dr_lowthresh_segvsrh && //careful: asymmetric cut might not be the most appropriate thing
599  dtcorr_rhseg > dt_lowthresh_segvsrh && dtcorr_rhseg < dr_highthresh_segvsrh)
600  return true;
601  }
602  return false;
603 }
float recHit_t0
Definition: CSCHaloAlgo.h:153
const double Pi
float dt_lowthresh_segvsrh_hbhe
Definition: CSCHaloAlgo.h:166
float time() const
Definition: EcalRecHit.h:71
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
float et_thresh_rh_ee
Definition: CSCHaloAlgo.h:170
float max_segment_r_diff
Definition: CSCHaloAlgo.h:162
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geoToken_
Definition: CSCHaloAlgo.h:173
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
float min_outer_radius
Definition: CSCHaloAlgo.h:149
float recHit_twindow
Definition: CSCHaloAlgo.h:154
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
Definition: CSCGeometry.cc:100
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
Definition: Track.h:65
float max_outer_radius
Definition: CSCHaloAlgo.h:150
float et_thresh_rh_hbhe
Definition: CSCHaloAlgo.h:166
void SetNFlatHaloSegments_TrkMuUnVeto(short int nSegments)
Definition: CSCHaloData.h:110
T z() const
Definition: PV3DBase.h:61
float dr_lowthresh_segvsrh_hbhe
Definition: CSCHaloAlgo.h:166
float dr_highthresh_segvsrh_ee
Definition: CSCHaloAlgo.h:170
size_type size() const
float dt_highthresh_segvsrh_eb
Definition: CSCHaloAlgo.h:168
float dphi_threshold
Definition: CSCHaloAlgo.h:151
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
reco::CSCHaloData Calculate(const CSCGeometry &TheCSCGeometry, edm::Handle< reco::MuonCollection > &TheCosmicMuons, const edm::Handle< reco::MuonTimeExtraMap > TheCSCTimeMap, edm::Handle< reco::MuonCollection > &TheMuons, edm::Handle< CSCSegmentCollection > &TheCSCSegments, edm::Handle< CSCRecHit2DCollection > &TheCSCRecHits, edm::Handle< L1MuGMTReadoutCollection > &TheL1GMTReadout, edm::Handle< HBHERecHitCollection > &hbhehits, edm::Handle< EcalRecHitCollection > &ecalebhits, edm::Handle< EcalRecHitCollection > &ecaleehits, edm::Handle< edm::TriggerResults > &TheHLTResults, const edm::TriggerNames *triggerNames, const edm::Handle< CSCALCTDigiCollection > &TheALCTs, MuonSegmentMatcher *TheMatcher, const edm::Event &TheEvent, const edm::EventSetup &TheEventSetup)
Definition: CSCHaloAlgo.cc:63
float dt_highthresh_segvsrh_hbhe
Definition: CSCHaloAlgo.h:166
void SetSegmentIsEECaloMatched(bool b)
Definition: CSCHaloData.h:118
T eta() const
Definition: PV3DBase.h:73
void SetSegmentsBothEndcaps_Loose_TrkMuUnVeto(bool b)
Definition: CSCHaloData.h:111
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
float freeInverseBeta() const
Definition: MuonTimeExtra.h:36
std::vector< const CSCSegment * > matchCSC(const reco::Track &muon, const edm::Event &event)
float deta_threshold
Definition: CSCHaloAlgo.h:144
float max_inner_radius
Definition: CSCHaloAlgo.h:148
float min_outer_theta
Definition: CSCHaloAlgo.h:146
T mag2() const
Definition: PV3DBase.h:63
float max_segment_phi_diff
Definition: CSCHaloAlgo.h:163
constexpr float energy() const
Definition: CaloRecHit.h:29
T barePhi() const
Definition: PV3DBase.h:65
float matching_dphi_threshold
Definition: CSCHaloAlgo.h:156
float matching_deta_threshold
Definition: CSCHaloAlgo.h:157
const CaloGeometry * geo_
Definition: CSCHaloAlgo.h:174
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
float dr_lowthresh_segvsrh_ee
Definition: CSCHaloAlgo.h:170
float dt_lowthresh_segvsrh_ee
Definition: CSCHaloAlgo.h:170
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:50
CSCHaloAlgo(edm::ConsumesCollector iC)
Definition: CSCHaloAlgo.cc:17
float max_outer_theta
Definition: CSCHaloAlgo.h:145
float max_dt_muon_segment
Definition: CSCHaloAlgo.h:159
float dphi_thresh_segvsrh_ee
Definition: CSCHaloAlgo.h:170
T sqrt(T t)
Definition: SSEVec.h:23
float dt_highthresh_segvsrh_ee
Definition: CSCHaloAlgo.h:170
void SetSegmentIsCaloMatched(bool b)
Definition: CSCHaloData.h:115
float et_thresh_rh_eb
Definition: CSCHaloAlgo.h:168
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void SetSegmentsBothEndcaps(bool b)
Definition: CSCHaloData.h:108
float dphi_thresh_segvsrh_hbhe
Definition: CSCHaloAlgo.h:166
math::XYZPoint Point
point in the space
Definition: Vertex.h:40
const HcalGeometry * hgeo_
Definition: CSCHaloAlgo.h:175
float min_inner_radius
Definition: CSCHaloAlgo.h:147
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
void SetHLTBit(bool status)
Definition: CSCHaloData.h:96
Definition: DetId.h:17
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
void SetNFlatHaloSegments(short int nSegments)
Definition: CSCHaloData.h:107
float dr_highthresh_segvsrh_hbhe
Definition: CSCHaloAlgo.h:166
constexpr HcalDetId id() const
get the id
Definition: HBHERecHit.h:41
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
void SetNIncomingTracks(short int n_small_dT, short int n_small_beta, short int n_small_both)
Definition: CSCHaloData.h:89
double normalizedChi2() const
chi-squared divided by n.d.o.f. (or chi-squared * 1e6 if n.d.o.f. is zero)
Definition: TrackBase.h:593
void SetNumberOfHaloTriggers(int PlusZ, int MinusZ)
Definition: CSCHaloData.h:73
float max_segment_theta
Definition: CSCHaloAlgo.h:164
float max_free_inverse_beta
Definition: CSCHaloAlgo.h:160
DetId id() const
get the id
Definition: EcalRecHit.h:78
bool isValid() const
Definition: HandleBase.h:70
constexpr float time() const
Definition: CaloRecHit.h:31
void SetSegmentIsHCaloMatched(bool b)
Definition: CSCHaloData.h:116
int matching_dwire_threshold
Definition: CSCHaloAlgo.h:158
float norm_chi2_threshold
Definition: CSCHaloAlgo.h:152
fixed size matrix
float dt_lowthresh_segvsrh_eb
Definition: CSCHaloAlgo.h:168
HLT enums.
math::XYZPoint getPosition(const DetId &id, reco::Vertex::Point vtx)
Definition: CSCHaloAlgo.cc:543
GlobalPoint getPosition(const DetId &id) const
void SetSegmentsBothEndcaps_Loose_dTcut_TrkMuUnVeto(bool b)
Definition: CSCHaloData.h:112
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Definition: RefVector.h:67
bool ECALSegmentMatching(edm::Handle< EcalRecHitCollection > &rechitcoll, float et_thresh_rh, float dphi_thresh_segvsrh, float dr_lowthresh_segvsrh, float dr_highthresh_segvsrh, float dt_lowthresh_segvsrh, float dt_highthresh_segvsrh, float iZ, float iR, float iT, float iPhi)
Definition: CSCHaloAlgo.cc:577
void SetNOutOfTimeHits(short int num)
Definition: CSCHaloData.h:87
void SetNumberOfHaloTriggers_TrkMuUnVeto(int PlusZ, int MinusZ)
Definition: CSCHaloData.h:77
const std::vector< GlobalPoint > & GetCSCTrackImpactPositions() const
Definition: CSCHaloData.h:100
Log< level::Warning, false > LogWarning
float energy() const
Definition: EcalRecHit.h:69
void SetNOutOfTimeTriggers(short int PlusZ, short int MinusZ)
Definition: CSCHaloData.h:82
static char chambers[264][20]
Definition: ReadPGInfo.cc:243
bool HCALSegmentMatching(edm::Handle< HBHERecHitCollection > &rechitcoll, float et_thresh_rh, float dphi_thresh_segvsrh, float dr_lowthresh_segvsrh, float dr_highthresh_segvsrh, float dt_lowthresh_segvsrh, float dt_highthresh_segvsrh, float iZ, float iR, float iT, float iPhi)
Definition: CSCHaloAlgo.cc:549
void SetSegmentIsEBCaloMatched(bool b)
Definition: CSCHaloData.h:117
static constexpr int CSC
Definition: MuonSubdetId.h:12
Geom::Theta< T > theta() const
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
float dr_highthresh_segvsrh_eb
Definition: CSCHaloAlgo.h:168
float dr_lowthresh_segvsrh_eb
Definition: CSCHaloAlgo.h:168
Geom::Theta< T > theta() const
Definition: PV3DBase.h:72
const GeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
Definition: CSCGeometry.cc:89
const TrackExtraRef & extra() const
reference to "extra" object
Definition: Track.h:139
edm::RefVector< reco::TrackCollection > & GetTracks()
Definition: CSCHaloData.h:69
float dphi_thresh_segvsrh_eb
Definition: CSCHaloAlgo.h:168