CMS 3D CMS Logo

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