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.);
22 return iPhi < 73 ? iPhi : 73 ;
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.);
31 return iPhi < 361 ? iPhi : 360 ;
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)
48 float METOverSumEt = TheCaloMET.
sumEt() ? TheCaloMET.
pt() / TheCaloMET.
sumEt() : 0 ;
54 int EcalOverlapping_CSCRecHits[361];
55 int EcalOverlapping_CSCSegments[361];
56 int HcalOverlapping_CSCRecHits[73];
57 int HcalOverlapping_CSCSegments[73];
63 bool EcalOverlap[361];
65 for(
int i = 0 ;
i < 361 ;
i++ )
67 EcalOverlap[
i] =
false;
68 if(
i < 73 ) HcalOverlap[
i] =
false;
71 std::vector<CSCRecHit2D> Hits = iSegment->specificRecHits() ;
72 for(std::vector<CSCRecHit2D>::iterator iHit = Hits.begin() ; iHit != Hits.end(); iHit++ )
74 DetId TheDetUnitId(iHit->geographicalId());
79 LocalPoint TheLocalPosition = iHit->localPosition();
81 const GlobalPoint TheGlobalPosition = TheSurface.toGlobal(TheLocalPosition);
85 float x = TheGlobalPosition.
x();
86 float y = TheGlobalPosition.
y();
88 float r = TMath::Sqrt( x*x + y*y);
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;
95 for(
int i = 0 ;
i < 361 ;
i++ )
97 if( EcalOverlap[
i] ) EcalOverlapping_CSCSegments[
i]++;
98 if( i < 73 && HcalOverlap[i] )
99 HcalOverlapping_CSCSegments[
i]++;
108 DetId TheDetUnitId(iCSCRecHit->geographicalId());
113 LocalPoint TheLocalPosition = iCSCRecHit->localPosition();
115 const GlobalPoint TheGlobalPosition = TheSurface.toGlobal(TheLocalPosition);
119 float x = TheGlobalPosition.
x();
120 float y = TheGlobalPosition.
y();
122 float r = TMath::Sqrt(x*x + y*y);
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] ++ ;
133 std::vector<PhiWedge> EcalWedges = TheEcalHaloData.
GetPhiWedges();
136 std::vector<PhiWedge> HcalWedges = TheHcalHaloData.
GetPhiWedges();
147 std::vector<int> vEcaliPhi, vHcaliPhi;
150 int N_Unmatched_Tracks = 0;
152 for( std::vector<GlobalPoint>::iterator Pos = TheGlobalPositions.begin() ; Pos != TheGlobalPositions.end() ; Pos ++ )
155 float global_phi = Pos->phi();
156 float global_r = TMath::Sqrt(Pos->x()*Pos->x() + Pos->y()*Pos->y());
161 bool MATCHED =
false;
164 for( std::vector<PhiWedge>::iterator iWedge = EcalWedges.begin() ; iWedge != EcalWedges.end() ; iWedge++ )
166 if( (
TMath::Abs( global_EcaliPhi - iWedge->iPhi() ) <= 5 ) && (global_r > Ecal_R_Min && global_r < Ecal_R_Max ) )
168 bool StoreWedge =
true;
169 for(
unsigned int i = 0 ;
i< vEcaliPhi.size() ;
i++ )
if ( vEcaliPhi[
i] == iWedge->iPhi() ) StoreWedge =
false;
176 vEcaliPhi.push_back( iWedge->iPhi() );
183 for( std::vector<PhiWedge>::iterator iWedge = HcalWedges.begin() ; iWedge != HcalWedges.end() ; iWedge++ )
185 if( (
TMath::Abs( global_HcaliPhi - iWedge->iPhi() ) <= 2 ) && (global_r > Hcal_R_Min && global_r < Hcal_R_Max ) )
187 bool StoreWedge =
true;
188 for(
unsigned int i = 0 ;
i < vHcaliPhi.size() ;
i++ )
if( vHcaliPhi[
i] == iWedge->iPhi() ) StoreWedge =
false;
192 vHcaliPhi.push_back( iWedge->iPhi() ) ;
202 if( !MATCHED ) N_Unmatched_Tracks ++;
215 if( iTower->
et() < TowerEtThreshold )
continue;
216 if(
abs(iTower->
ieta()) > 24 )
continue;
217 int iphi = iTower->
iphi();
218 for(
unsigned int x = 0 ;
x < vEcaliPhi.size() ;
x++ )
220 if( iphi == vEcaliPhi[
x] )
222 dMEx += ( TMath::Cos(iTower->
phi())*iTower->
emEt() );
223 dMEy += ( TMath::Sin(iTower->
phi())*iTower->
emEt() );
226 for(
unsigned int x = 0 ;
x < vHcaliPhi.size() ;
x++ )
228 if( iphi == vHcaliPhi[
x] )
230 dMEx += ( TMath::Cos(iTower->
phi() )*iTower->
hadEt() ) ;
231 dMEy += ( TMath::Sin(iTower->
phi() )*iTower->
hadEt() ) ;
247 bool ECALBmatched(
false), ECALEmatched(
false),HCALBmatched(
false),HCALEmatched(
false);
249 if (TheCSCSegments.
isValid()) {
251 iSegment != TheCSCSegments->end();
254 CSCDetId iCscDetID = iSegment->cscDetId();
255 bool Segment1IsGood=
true;
261 for(reco::MuonCollection::const_iterator
mu = TheMuons->begin();
mu!= TheMuons->end() && (Segment1IsGood) ;
mu++ )
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 ++ )
271 for( std::vector<reco::MuonSegmentMatch>::const_iterator kSegment = kChamber->segmentMatches.begin();
272 kSegment != kChamber->segmentMatches.end(); kSegment++ )
275 CSCDetId kCscDetID = cscSegRef->cscDetId();
277 if( kCscDetID == iCscDetID )
279 Segment1IsGood =
false;
286 if(!Segment1IsGood)
continue;
290 LocalPoint iLocalPosition = iSegment->localPosition();
291 LocalVector iLocalDirection = iSegment->localDirection();
296 float iTheta = iGlobalDirection.
theta();
297 if (iTheta > max_segment_theta && iTheta <
TMath::Pi() - max_segment_theta)
continue;
299 float iPhi = iGlobalPosition.
phi();
300 float iR =
sqrt(iGlobalPosition.
perp2()) ;
301 float iZ = iGlobalPosition.
z();
302 float iT = iSegment->time();
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);
314 ECALBmatched |= ebmatched;
315 ECALEmatched |= eematched;
316 HCALBmatched |= hbmatched;
317 HCALEmatched |= hematched;
333 bool HaloPatternFoundInEB =
false;
334 for(
auto & hcand : hccandEB){
335 if((hcand.getIsHaloFromPattern() &&!ishlt)||(hcand.getIsHaloFromPattern_HLT() &&ishlt)){
336 HaloPatternFoundInEB =
true;
338 AddtoBeamHaloEBEERechits(bhrhcandidates, TheGlobalHaloData,
true);
343 bool HaloPatternFoundInEE =
false;
344 for(
auto & hcand : hccandEE){
345 if((hcand.getIsHaloFromPattern() &&!ishlt)||(hcand.getIsHaloFromPattern_HLT() &&ishlt)){
346 HaloPatternFoundInEE =
true;
348 AddtoBeamHaloEBEERechits( bhrhcandidates, TheGlobalHaloData,
false);
353 bool HaloPatternFoundInHB =
false;
354 for(
auto & hcand : hccandHB){
355 if((hcand.getIsHaloFromPattern() &&!ishlt)||(hcand.getIsHaloFromPattern_HLT() &&ishlt)){
356 HaloPatternFoundInHB =
true;
358 AddtoBeamHaloHBHERechits(bhrhcandidates, TheGlobalHaloData);
363 bool HaloPatternFoundInHE =
false;
364 for(
auto & hcand : hccandHE){
365 if((hcand.getIsHaloFromPattern() &&!ishlt)||(hcand.getIsHaloFromPattern_HLT() &&ishlt)){
366 HaloPatternFoundInHE =
true;
368 AddtoBeamHaloHBHERechits(bhrhcandidates, TheGlobalHaloData);
376 return TheGlobalHaloData;
385 bool rhmatchingfound =
false;
387 for(
auto & hcand : haloclustercands){
389 if(!ApplyMatchingCuts(
EB,ishlt, hcand.getSeedEt(), iZ, hcand.getSeedZ(),iR, hcand.getSeedR(), iT,hcand.getSeedTime(), iPhi, hcand.getSeedPhi()))
continue;
391 rhmatchingfound=
true;
395 AddtoBeamHaloEBEERechits(bhrhcandidates, thehalodata,
true);
399 return rhmatchingfound;
404 bool rhmatchingfound =
false;
406 for(
auto & hcand : haloclustercands){
408 if(!ApplyMatchingCuts(
EE,ishlt, hcand.getSeedEt(), iZ, hcand.getSeedZ(),iR, hcand.getSeedR(), iT,hcand.getSeedTime(), iPhi, hcand.getSeedPhi()))
continue;
410 rhmatchingfound=
true;
414 AddtoBeamHaloEBEERechits(bhrhcandidates, thehalodata,
false);
418 return rhmatchingfound;
423 bool rhmatchingfound =
false;
425 for(
auto & hcand : haloclustercands){
427 if(!ApplyMatchingCuts(
HB,ishlt, hcand.getSeedEt(), iZ, hcand.getSeedZ(),iR, hcand.getSeedR(), iT,hcand.getSeedTime(), iPhi, hcand.getSeedPhi()))
continue;
429 rhmatchingfound=
true;
433 AddtoBeamHaloHBHERechits(bhrhcandidates, thehalodata);
437 return rhmatchingfound;
442 bool rhmatchingfound =
false;
444 for(
auto & hcand : haloclustercands){
446 if(!ApplyMatchingCuts(
HE,ishlt, hcand.getSeedEt(), iZ, hcand.getSeedZ(),iR, hcand.getSeedR(), iT,hcand.getSeedTime(), iPhi, hcand.getSeedPhi()))
continue;
448 rhmatchingfound=
true;
452 AddtoBeamHaloHBHERechits(bhrhcandidates, thehalodata);
456 return rhmatchingfound;
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){
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;
466 double tcorseg = tBXseg -
std::abs(segZ)/c_cm_per_ns;
467 double tcorsegincbh = tBXseg +
std::abs(segZ)/c_cm_per_ns;
468 double truedt[4]={1000,1000,1000,1000};
471 double twindow_seg = 15;
472 if(
std::abs(tcorsegincbh) <twindow_seg) truedt[0] = tBXrh -tBXseg -
std::abs(rhZ-segZ)/c_cm_per_ns;
474 if(
std::abs(tcorseg) < twindow_seg) truedt[1] = tBXseg -tBXrh -
std::abs(rhZ-segZ)/c_cm_per_ns;
476 if(tcorsegincbh> 25-twindow_seg&&
std::abs(tcorsegincbh) <25+twindow_seg) truedt[2] = tBXrh -tBXseg -
std::abs(rhZ-segZ)/c_cm_per_ns;
478 if(tcorseg >25-twindow_seg && tcorseg<25+twindow_seg) truedt[3] = tBXseg -tBXrh -
std::abs(rhZ-segZ)/c_cm_per_ns;
482 if(rhet< et_thresh_rh_eb)
return false;
483 if(rhet< 20&&ishlt)
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;
494 if(rhet< et_thresh_rh_ee)
return false;
495 if(rhet< 20&&ishlt)
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;
505 if(rhet< et_thresh_rh_hb)
return false;
506 if(rhet< 20&&ishlt)
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;
516 if(rhet< et_thresh_rh_he)
return false;
517 if(rhet< 20&&ishlt)
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;
532 for(
size_t ihit = 0; ihit<bhtaggedrechits.
size(); ++ ihit){
533 bool alreadyincl =
false;
538 for(
size_t jhit =0; jhit < refrhcoll.
size();jhit++){
540 if(rhitRef->detid() == rhRef->detid()) alreadyincl=
true;
541 if(rhitRef->detid() == rhRef->detid())
break;
550 for(
size_t ihit = 0; ihit<bhtaggedrechits.
size(); ++ ihit){
551 bool alreadyincl =
false;
555 for(
size_t jhit =0; jhit < refrhcoll.
size();jhit++){
557 if(rhitRef->detid() == rhRef->detid()) alreadyincl=
true;
558 if(rhitRef->detid() == rhRef->detid())
break;
virtual double pt() const final
transverse momentum
const std::vector< HaloClusterCandidateHCAL > & getHaloClusterCandidatesHB() const
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
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Geom::Phi< T > phi() const
void SetMETOverSumEt(float x)
std::vector< PhiWedge > & GetMatchedEcalPhiWedges()
const Plane & surface() const
The nominal surface of the GeomDet.
void SetHaloPatternFoundHE(bool b)
Geom::Theta< T > theta() const
virtual double phi() const final
momentum azimuthal angle
T x() const
Cartesian x coordinate.
const std::vector< HaloClusterCandidateECAL > & getHaloClusterCandidatesEB() const
int Phi_To_HcaliPhi(float phi)
void SetHaloPatternFoundEE(bool b)
edm::RefVector< HBHERecHitCollection > & GetHBHERechits()
void SetSegmentIsEBCaloMatched(bool b)
const std::vector< GlobalPoint > & GetCSCTrackImpactPositions() const
Abs< T >::type abs(const T &t)
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 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)
virtual const GeomDetUnit * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
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.
void SetOverlappingCSCRecHits(int x)
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
std::vector< PhiWedge > & GetMatchedHcalPhiWedges()
void SetOverlappingCSCSegments(int x)
const std::vector< HaloClusterCandidateHCAL > & getHaloClusterCandidatesHE() const
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
size_type size() const
Size of the RefVector.
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
void SetSegmentIsHECaloMatched(bool b)
double et(double vtxZ) const
edm::RefVector< EcalRecHitCollection > & GetEBRechits()
void SetSegmentIsHBCaloMatched(bool b)
edm::RefVector< EcalRecHitCollection > & GetEERechits()
const std::vector< HaloClusterCandidateECAL > & getHaloClusterCandidatesEE() const
static char chambers[264][20]
bool ApplyMatchingCuts(int subdet, bool ishlt, double rhet, double segZ, double rhZ, double segR, double rhR, double segT, double rhT, double segPhi, double rhPhi)
void SetHaloPatternFoundHB(bool b)
void SetHaloPatternFoundEB(bool b)