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