3 constexpr
float c_cm_per_ns = 29.9792458;
17 phi = phi < 0 ? phi + 2. *
TMath::Pi() : phi;
18 float phi_degrees = phi * (360.) / (2. *
TMath::Pi());
19 int iPhi = (
int)((phi_degrees / 5.) + 1.);
21 return iPhi < 73 ? iPhi : 73;
25 phi = phi < 0 ? phi + 2. *
TMath::Pi() : phi;
26 float phi_degrees = phi * (360.) / (2. *
TMath::Pi());
27 int iPhi = (
int)(phi_degrees + 1.);
29 return iPhi < 361 ? iPhi : 360;
52 float METOverSumEt = TheCaloMET.
sumEt() ? TheCaloMET.
pt() / TheCaloMET.
sumEt() : 0;
55 int EcalOverlapping_CSCRecHits[361] = {};
56 int EcalOverlapping_CSCSegments[361] = {};
57 int HcalOverlapping_CSCRecHits[73] = {};
58 int HcalOverlapping_CSCSegments[73] = {};
63 bool EcalOverlap[361];
65 for (
int i = 0;
i < 361;
i++) {
66 EcalOverlap[
i] =
false;
68 HcalOverlap[
i] =
false;
71 std::vector<CSCRecHit2D> Hits = iSegment->specificRecHits();
72 for (std::vector<CSCRecHit2D>::iterator iHit = Hits.begin(); iHit != Hits.end(); iHit++) {
73 DetId TheDetUnitId(iHit->geographicalId());
80 LocalPoint TheLocalPosition = iHit->localPosition();
82 const GlobalPoint TheGlobalPosition = TheSurface.toGlobal(TheLocalPosition);
86 float x = TheGlobalPosition.
x();
87 float y = TheGlobalPosition.
y();
89 float r = TMath::Sqrt(
x *
x + y * y);
91 if (r < Ecal_R_Max && r > Ecal_R_Min)
92 EcalOverlap[Ecal_iphi] =
true;
93 if (r < Hcal_R_Max && r > Hcal_R_Max)
94 HcalOverlap[Hcal_iphi] =
true;
96 for (
int i = 0;
i < 361;
i++) {
98 EcalOverlapping_CSCSegments[
i]++;
99 if (
i < 73 && HcalOverlap[
i])
100 HcalOverlapping_CSCSegments[
i]++;
107 DetId TheDetUnitId(iCSCRecHit->geographicalId());
114 LocalPoint TheLocalPosition = iCSCRecHit->localPosition();
116 const GlobalPoint TheGlobalPosition = TheSurface.toGlobal(TheLocalPosition);
120 float x = TheGlobalPosition.
x();
121 float y = TheGlobalPosition.
y();
123 float r = TMath::Sqrt(
x *
x + y * y);
125 if (r < Ecal_R_Max && r > Ecal_R_Min)
126 EcalOverlapping_CSCRecHits[Ecaliphi]++;
127 if (r < Hcal_R_Max && r > Hcal_R_Max)
128 HcalOverlapping_CSCRecHits[Hcaliphi]++;
134 std::vector<PhiWedge> EcalWedges = TheEcalHaloData.
GetPhiWedges();
137 std::vector<PhiWedge> HcalWedges = TheHcalHaloData.
GetPhiWedges();
148 std::vector<int> vEcaliPhi, vHcaliPhi;
150 for (std::vector<GlobalPoint>::iterator Pos = TheGlobalPositions.begin(); Pos != TheGlobalPositions.end(); Pos++) {
152 float global_phi = Pos->phi();
153 float global_r = TMath::Sqrt(Pos->x() * Pos->x() + Pos->y() * Pos->y());
160 for (std::vector<PhiWedge>::iterator iWedge = EcalWedges.begin(); iWedge != EcalWedges.end(); iWedge++) {
161 if ((TMath::Abs(global_EcaliPhi - iWedge->iPhi()) <= 5) && (global_r > Ecal_R_Min && global_r < Ecal_R_Max)) {
162 bool StoreWedge =
true;
163 for (
unsigned int i = 0;
i < vEcaliPhi.size();
i++)
164 if (vEcaliPhi[
i] == iWedge->iPhi())
171 vEcaliPhi.push_back(iWedge->iPhi());
177 for (std::vector<PhiWedge>::iterator iWedge = HcalWedges.begin(); iWedge != HcalWedges.end(); iWedge++) {
178 if ((TMath::Abs(global_HcaliPhi - iWedge->iPhi()) <= 2) && (global_r > Hcal_R_Min && global_r < Hcal_R_Max)) {
179 bool StoreWedge =
true;
180 for (
unsigned int i = 0;
i < vHcaliPhi.size();
i++)
181 if (vHcaliPhi[
i] == iWedge->iPhi())
185 vHcaliPhi.push_back(iWedge->iPhi());
205 if (iTower->
et() < TowerEtThreshold)
210 for (
unsigned int x = 0;
x < vEcaliPhi.size();
x++) {
211 if (
iphi == vEcaliPhi[
x]) {
212 dMEx += (TMath::Cos(iTower->
phi()) * iTower->
emEt());
213 dMEy += (TMath::Sin(iTower->
phi()) * iTower->
emEt());
216 for (
unsigned int x = 0;
x < vHcaliPhi.size();
x++) {
217 if (
iphi == vHcaliPhi[
x]) {
218 dMEx += (TMath::Cos(iTower->
phi()) * iTower->
hadEt());
219 dMEy += (TMath::Sin(iTower->
phi()) * iTower->
hadEt());
233 bool ECALBmatched(
false), ECALEmatched(
false), HCALBmatched(
false), HCALEmatched(
false);
235 if (TheCSCSegments.
isValid()) {
238 CSCDetId iCscDetID = iSegment->cscDetId();
239 bool Segment1IsGood =
true;
243 for (reco::MuonCollection::const_iterator
mu = TheMuons->begin();
mu != TheMuons->end() && (Segment1IsGood);
245 if (!
mu->isTrackerMuon() && !
mu->isGlobalMuon() &&
mu->isStandAloneMuon())
247 if (!
mu->isGlobalMuon() &&
mu->isTrackerMuon() &&
mu->pt() < 3)
249 const std::vector<MuonChamberMatch>
chambers =
mu->matches();
250 for (std::vector<MuonChamberMatch>::const_iterator kChamber =
chambers.begin(); kChamber !=
chambers.end();
254 for (std::vector<reco::MuonSegmentMatch>::const_iterator kSegment = kChamber->segmentMatches.begin();
255 kSegment != kChamber->segmentMatches.end();
258 CSCDetId kCscDetID = cscSegRef->cscDetId();
260 if (kCscDetID == iCscDetID) {
261 Segment1IsGood =
false;
272 LocalPoint iLocalPosition = iSegment->localPosition();
273 LocalVector iLocalDirection = iSegment->localDirection();
278 float iTheta = iGlobalDirection.
theta();
279 if (iTheta > max_segment_theta && iTheta <
TMath::Pi() - max_segment_theta)
282 float iPhi = iGlobalPosition.
phi();
283 float iR =
sqrt(iGlobalPosition.
perp2());
284 float iZ = iGlobalPosition.
z();
285 float iT = iSegment->time();
292 bool ebmatched = SegmentMatchingEB(TheGlobalHaloData, hccandEB, iZ, iR, iT, iPhi, ishlt);
293 bool eematched = SegmentMatchingEE(TheGlobalHaloData, hccandEE, iZ, iR, iT, iPhi, ishlt);
294 bool hbmatched = SegmentMatchingHB(TheGlobalHaloData, hccandHB, iZ, iR, iT, iPhi, ishlt);
295 bool hematched = SegmentMatchingHE(TheGlobalHaloData, hccandHE, iZ, iR, iT, iPhi, ishlt);
297 ECALBmatched |= ebmatched;
298 ECALEmatched |= eematched;
299 HCALBmatched |= hbmatched;
300 HCALEmatched |= hematched;
313 bool HaloPatternFoundInEB =
false;
314 for (
auto& hcand : hccandEB) {
315 if ((hcand.getIsHaloFromPattern() && !ishlt) || (hcand.getIsHaloFromPattern_HLT() && ishlt)) {
316 HaloPatternFoundInEB =
true;
318 AddtoBeamHaloEBEERechits(bhrhcandidates, TheGlobalHaloData,
true);
322 bool HaloPatternFoundInEE =
false;
323 for (
auto& hcand : hccandEE) {
324 if ((hcand.getIsHaloFromPattern() && !ishlt) || (hcand.getIsHaloFromPattern_HLT() && ishlt)) {
325 HaloPatternFoundInEE =
true;
327 AddtoBeamHaloEBEERechits(bhrhcandidates, TheGlobalHaloData,
false);
331 bool HaloPatternFoundInHB =
false;
332 for (
auto& hcand : hccandHB) {
333 if ((hcand.getIsHaloFromPattern() && !ishlt) || (hcand.getIsHaloFromPattern_HLT() && ishlt)) {
334 HaloPatternFoundInHB =
true;
336 AddtoBeamHaloHBHERechits(bhrhcandidates, TheGlobalHaloData);
340 bool HaloPatternFoundInHE =
false;
341 for (
auto& hcand : hccandHE) {
342 if ((hcand.getIsHaloFromPattern() && !ishlt) || (hcand.getIsHaloFromPattern_HLT() && ishlt)) {
343 HaloPatternFoundInHE =
true;
345 AddtoBeamHaloHBHERechits(bhrhcandidates, TheGlobalHaloData);
353 return TheGlobalHaloData;
357 const std::vector<HaloClusterCandidateECAL>& haloclustercands,
363 bool rhmatchingfound =
false;
365 for (
auto& hcand : haloclustercands) {
366 if (!ApplyMatchingCuts(
EB,
379 rhmatchingfound =
true;
383 AddtoBeamHaloEBEERechits(bhrhcandidates, thehalodata,
true);
386 return rhmatchingfound;
390 const std::vector<HaloClusterCandidateECAL>& haloclustercands,
396 bool rhmatchingfound =
false;
398 for (
auto& hcand : haloclustercands) {
399 if (!ApplyMatchingCuts(
EE,
412 rhmatchingfound =
true;
416 AddtoBeamHaloEBEERechits(bhrhcandidates, thehalodata,
false);
419 return rhmatchingfound;
423 const std::vector<HaloClusterCandidateHCAL>& haloclustercands,
429 bool rhmatchingfound =
false;
431 for (
auto& hcand : haloclustercands) {
432 if (!ApplyMatchingCuts(
HB,
445 rhmatchingfound =
true;
449 AddtoBeamHaloHBHERechits(bhrhcandidates, thehalodata);
452 return rhmatchingfound;
456 const std::vector<HaloClusterCandidateHCAL>& haloclustercands,
462 bool rhmatchingfound =
false;
464 for (
auto& hcand : haloclustercands) {
465 if (!ApplyMatchingCuts(
HE,
478 rhmatchingfound =
true;
482 AddtoBeamHaloHBHERechits(bhrhcandidates, thehalodata);
485 return rhmatchingfound;
500 double tBXrh = rhT +
sqrt(rhR * rhR + rhZ * rhZ) / c_cm_per_ns;
501 double tBXseg = segT +
sqrt(segR * segR + segZ * segZ) / c_cm_per_ns;
503 double tcorseg = tBXseg -
std::abs(segZ) / c_cm_per_ns;
504 double tcorsegincbh = tBXseg +
std::abs(segZ) / c_cm_per_ns;
505 double truedt[4] = {1000, 1000, 1000, 1000};
508 double twindow_seg = 15;
509 if (
std::abs(tcorsegincbh) < twindow_seg)
510 truedt[0] = tBXrh - tBXseg -
std::abs(rhZ - segZ) / c_cm_per_ns;
512 if (
std::abs(tcorseg) < twindow_seg)
513 truedt[1] = tBXseg - tBXrh -
std::abs(rhZ - segZ) / c_cm_per_ns;
515 if (tcorsegincbh > 25 - twindow_seg &&
std::abs(tcorsegincbh) < 25 + twindow_seg)
516 truedt[2] = tBXrh - tBXseg -
std::abs(rhZ - segZ) / c_cm_per_ns;
518 if (tcorseg > 25 - twindow_seg && tcorseg < 25 + twindow_seg)
519 truedt[3] = tBXseg - tBXrh -
std::abs(rhZ - segZ) / c_cm_per_ns;
522 if (rhet < et_thresh_rh_eb)
524 if (rhet < 20 && ishlt)
528 if (rhR - segR < dr_lowthresh_segvsrh_eb)
530 if (rhR - segR > dr_highthresh_segvsrh_eb)
532 if (
std::abs(truedt[0]) > dt_segvsrh_eb &&
std::abs(truedt[1]) > dt_segvsrh_eb &&
539 if (rhet < et_thresh_rh_ee)
541 if (rhet < 20 && ishlt)
545 if (rhR - segR < dr_lowthresh_segvsrh_ee)
547 if (rhR - segR > dr_highthresh_segvsrh_ee)
549 if (
std::abs(truedt[0]) > dt_segvsrh_ee &&
std::abs(truedt[1]) > dt_segvsrh_ee &&
556 if (rhet < et_thresh_rh_hb)
558 if (rhet < 20 && ishlt)
562 if (rhR - segR < dr_lowthresh_segvsrh_hb)
564 if (rhR - segR > dr_highthresh_segvsrh_hb)
566 if (
std::abs(truedt[0]) > dt_segvsrh_hb &&
std::abs(truedt[1]) > dt_segvsrh_hb &&
573 if (rhet < et_thresh_rh_he)
575 if (rhet < 20 && ishlt)
579 if (rhR - segR < dr_lowthresh_segvsrh_he)
581 if (rhR - segR > dr_highthresh_segvsrh_he)
583 if (
std::abs(truedt[0]) > dt_segvsrh_he &&
std::abs(truedt[1]) > dt_segvsrh_he &&
595 for (
size_t ihit = 0; ihit < bhtaggedrechits.
size(); ++ihit) {
596 bool alreadyincl =
false;
603 for (
size_t jhit = 0; jhit < refrhcoll.
size(); jhit++) {
605 if (rhitRef->detid() == rhRef->detid())
607 if (rhitRef->detid() == rhRef->detid())
610 if (!alreadyincl && isbarrel)
612 if (!alreadyincl && !isbarrel)
619 for (
size_t ihit = 0; ihit < bhtaggedrechits.
size(); ++ihit) {
620 bool alreadyincl =
false;
624 for (
size_t jhit = 0; jhit < refrhcoll.
size(); jhit++) {
626 if (rhitRef->detid() == rhRef->detid())
628 if (rhitRef->detid() == rhRef->detid())
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)
double pt() const final
transverse momentum
void SetSegmentIsEECaloMatched(bool b)
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
Geom::Phi< T > phi() const
void SetMETOverSumEt(float x)
const std::vector< HaloClusterCandidateHCAL > & getHaloClusterCandidatesHB() const
std::vector< PhiWedge > & GetMatchedEcalPhiWedges()
const std::vector< HaloClusterCandidateHCAL > & getHaloClusterCandidatesHE() const
void SetHaloPatternFoundHE(bool b)
double et(double vtxZ) const
C::const_iterator const_iterator
constant access iterator type
int Phi_To_HcaliPhi(float phi)
void SetHaloPatternFoundEE(bool b)
edm::RefVector< HBHERecHitCollection > & GetHBHERechits()
void SetSegmentIsEBCaloMatched(bool b)
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)
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
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)
const Plane & surface() const
The nominal surface of the GeomDet.
size_type size() const
Size of the RefVector.
void AddtoBeamHaloHBHERechits(edm::RefVector< HBHERecHitCollection > &bhtaggedrechits, reco::GlobalHaloData &thehalodata)
void SetMETCorrections(float x, float y)
const std::vector< HaloClusterCandidateECAL > & getHaloClusterCandidatesEB() const
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< HaloClusterCandidateECAL > & getHaloClusterCandidatesEE() const
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)
void SetSegmentIsHECaloMatched(bool b)
edm::RefVector< EcalRecHitCollection > & GetEBRechits()
const std::vector< GlobalPoint > & GetCSCTrackImpactPositions() const
void SetSegmentIsHBCaloMatched(bool b)
edm::RefVector< EcalRecHitCollection > & GetEERechits()
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)
double phi() const final
momentum azimuthal angle
const std::vector< PhiWedge > & GetPhiWedges() const
void SetHaloPatternFoundHB(bool b)
Geom::Theta< T > theta() const
const std::vector< PhiWedge > & GetPhiWedges() const
const GeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
void SetHaloPatternFoundEB(bool b)