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