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