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;
151 int N_Unmatched_Tracks = 0;
153 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++) {
165 if ((TMath::Abs(global_EcaliPhi - iWedge->iPhi()) <= 5) && (global_r > Ecal_R_Min && global_r < Ecal_R_Max)) {
166 bool StoreWedge =
true;
167 for (
unsigned int i = 0;
i < vEcaliPhi.size();
i++)
168 if (vEcaliPhi[
i] == iWedge->iPhi())
175 vEcaliPhi.push_back(iWedge->iPhi());
182 for (std::vector<PhiWedge>::iterator iWedge = HcalWedges.begin(); iWedge != HcalWedges.end(); iWedge++) {
183 if ((TMath::Abs(global_HcaliPhi - iWedge->iPhi()) <= 2) && (global_r > Hcal_R_Min && global_r < Hcal_R_Max)) {
184 bool StoreWedge =
true;
185 for (
unsigned int i = 0;
i < vHcaliPhi.size();
i++)
186 if (vHcaliPhi[
i] == iWedge->iPhi())
190 vHcaliPhi.push_back(iWedge->iPhi());
201 N_Unmatched_Tracks++;
213 if (iTower->
et() < TowerEtThreshold)
218 for (
unsigned int x = 0;
x < vEcaliPhi.size();
x++) {
219 if (
iphi == vEcaliPhi[
x]) {
220 dMEx += (TMath::Cos(iTower->
phi()) * iTower->
emEt());
221 dMEy += (TMath::Sin(iTower->
phi()) * iTower->
emEt());
224 for (
unsigned int x = 0;
x < vHcaliPhi.size();
x++) {
225 if (
iphi == vHcaliPhi[
x]) {
226 dMEx += (TMath::Cos(iTower->
phi()) * iTower->
hadEt());
227 dMEy += (TMath::Sin(iTower->
phi()) * iTower->
hadEt());
241 bool ECALBmatched(
false), ECALEmatched(
false), HCALBmatched(
false), HCALEmatched(
false);
243 if (TheCSCSegments.
isValid()) {
246 CSCDetId iCscDetID = iSegment->cscDetId();
247 bool Segment1IsGood =
true;
251 for (reco::MuonCollection::const_iterator
mu = TheMuons->begin();
mu != TheMuons->end() && (Segment1IsGood);
253 if (!
mu->isTrackerMuon() && !
mu->isGlobalMuon() &&
mu->isStandAloneMuon())
255 if (!
mu->isGlobalMuon() &&
mu->isTrackerMuon() &&
mu->pt() < 3)
257 const std::vector<MuonChamberMatch>
chambers =
mu->matches();
258 for (std::vector<MuonChamberMatch>::const_iterator kChamber =
chambers.begin(); kChamber !=
chambers.end();
262 for (std::vector<reco::MuonSegmentMatch>::const_iterator kSegment = kChamber->segmentMatches.begin();
263 kSegment != kChamber->segmentMatches.end();
266 CSCDetId kCscDetID = cscSegRef->cscDetId();
268 if (kCscDetID == iCscDetID) {
269 Segment1IsGood =
false;
280 LocalPoint iLocalPosition = iSegment->localPosition();
281 LocalVector iLocalDirection = iSegment->localDirection();
286 float iTheta = iGlobalDirection.
theta();
287 if (iTheta > max_segment_theta && iTheta <
TMath::Pi() - max_segment_theta)
290 float iPhi = iGlobalPosition.
phi();
291 float iR =
sqrt(iGlobalPosition.
perp2());
292 float iZ = iGlobalPosition.
z();
293 float iT = iSegment->time();
300 bool ebmatched = SegmentMatchingEB(TheGlobalHaloData, hccandEB, iZ, iR, iT, iPhi, ishlt);
301 bool eematched = SegmentMatchingEE(TheGlobalHaloData, hccandEE, iZ, iR, iT, iPhi, ishlt);
302 bool hbmatched = SegmentMatchingHB(TheGlobalHaloData, hccandHB, iZ, iR, iT, iPhi, ishlt);
303 bool hematched = SegmentMatchingHE(TheGlobalHaloData, hccandHE, iZ, iR, iT, iPhi, ishlt);
305 ECALBmatched |= ebmatched;
306 ECALEmatched |= eematched;
307 HCALBmatched |= hbmatched;
308 HCALEmatched |= hematched;
321 bool HaloPatternFoundInEB =
false;
322 for (
auto& hcand : hccandEB) {
323 if ((hcand.getIsHaloFromPattern() && !ishlt) || (hcand.getIsHaloFromPattern_HLT() && ishlt)) {
324 HaloPatternFoundInEB =
true;
326 AddtoBeamHaloEBEERechits(bhrhcandidates, TheGlobalHaloData,
true);
330 bool HaloPatternFoundInEE =
false;
331 for (
auto& hcand : hccandEE) {
332 if ((hcand.getIsHaloFromPattern() && !ishlt) || (hcand.getIsHaloFromPattern_HLT() && ishlt)) {
333 HaloPatternFoundInEE =
true;
335 AddtoBeamHaloEBEERechits(bhrhcandidates, TheGlobalHaloData,
false);
339 bool HaloPatternFoundInHB =
false;
340 for (
auto& hcand : hccandHB) {
341 if ((hcand.getIsHaloFromPattern() && !ishlt) || (hcand.getIsHaloFromPattern_HLT() && ishlt)) {
342 HaloPatternFoundInHB =
true;
344 AddtoBeamHaloHBHERechits(bhrhcandidates, TheGlobalHaloData);
348 bool HaloPatternFoundInHE =
false;
349 for (
auto& hcand : hccandHE) {
350 if ((hcand.getIsHaloFromPattern() && !ishlt) || (hcand.getIsHaloFromPattern_HLT() && ishlt)) {
351 HaloPatternFoundInHE =
true;
353 AddtoBeamHaloHBHERechits(bhrhcandidates, TheGlobalHaloData);
361 return TheGlobalHaloData;
365 const std::vector<HaloClusterCandidateECAL>& haloclustercands,
371 bool rhmatchingfound =
false;
373 for (
auto& hcand : haloclustercands) {
374 if (!ApplyMatchingCuts(
EB,
387 rhmatchingfound =
true;
391 AddtoBeamHaloEBEERechits(bhrhcandidates, thehalodata,
true);
394 return rhmatchingfound;
398 const std::vector<HaloClusterCandidateECAL>& haloclustercands,
404 bool rhmatchingfound =
false;
406 for (
auto& hcand : haloclustercands) {
407 if (!ApplyMatchingCuts(
EE,
420 rhmatchingfound =
true;
424 AddtoBeamHaloEBEERechits(bhrhcandidates, thehalodata,
false);
427 return rhmatchingfound;
431 const std::vector<HaloClusterCandidateHCAL>& haloclustercands,
437 bool rhmatchingfound =
false;
439 for (
auto& hcand : haloclustercands) {
440 if (!ApplyMatchingCuts(
HB,
453 rhmatchingfound =
true;
457 AddtoBeamHaloHBHERechits(bhrhcandidates, thehalodata);
460 return rhmatchingfound;
464 const std::vector<HaloClusterCandidateHCAL>& haloclustercands,
470 bool rhmatchingfound =
false;
472 for (
auto& hcand : haloclustercands) {
473 if (!ApplyMatchingCuts(
HE,
486 rhmatchingfound =
true;
490 AddtoBeamHaloHBHERechits(bhrhcandidates, thehalodata);
493 return rhmatchingfound;
508 double tBXrh = rhT +
sqrt(rhR * rhR + rhZ * rhZ) / c_cm_per_ns;
509 double tBXseg = segT +
sqrt(segR * segR + segZ * segZ) / c_cm_per_ns;
511 double tcorseg = tBXseg -
std::abs(segZ) / c_cm_per_ns;
512 double tcorsegincbh = tBXseg +
std::abs(segZ) / c_cm_per_ns;
513 double truedt[4] = {1000, 1000, 1000, 1000};
516 double twindow_seg = 15;
517 if (
std::abs(tcorsegincbh) < twindow_seg)
518 truedt[0] = tBXrh - tBXseg -
std::abs(rhZ - segZ) / c_cm_per_ns;
520 if (
std::abs(tcorseg) < twindow_seg)
521 truedt[1] = tBXseg - tBXrh -
std::abs(rhZ - segZ) / c_cm_per_ns;
523 if (tcorsegincbh > 25 - twindow_seg &&
std::abs(tcorsegincbh) < 25 + twindow_seg)
524 truedt[2] = tBXrh - tBXseg -
std::abs(rhZ - segZ) / c_cm_per_ns;
526 if (tcorseg > 25 - twindow_seg && tcorseg < 25 + twindow_seg)
527 truedt[3] = tBXseg - tBXrh -
std::abs(rhZ - segZ) / c_cm_per_ns;
530 if (rhet < et_thresh_rh_eb)
532 if (rhet < 20 && ishlt)
536 if (rhR - segR < dr_lowthresh_segvsrh_eb)
538 if (rhR - segR > dr_highthresh_segvsrh_eb)
540 if (
std::abs(truedt[0]) > dt_segvsrh_eb &&
std::abs(truedt[1]) > dt_segvsrh_eb &&
547 if (rhet < et_thresh_rh_ee)
549 if (rhet < 20 && ishlt)
553 if (rhR - segR < dr_lowthresh_segvsrh_ee)
555 if (rhR - segR > dr_highthresh_segvsrh_ee)
557 if (
std::abs(truedt[0]) > dt_segvsrh_ee &&
std::abs(truedt[1]) > dt_segvsrh_ee &&
564 if (rhet < et_thresh_rh_hb)
566 if (rhet < 20 && ishlt)
570 if (rhR - segR < dr_lowthresh_segvsrh_hb)
572 if (rhR - segR > dr_highthresh_segvsrh_hb)
574 if (
std::abs(truedt[0]) > dt_segvsrh_hb &&
std::abs(truedt[1]) > dt_segvsrh_hb &&
581 if (rhet < et_thresh_rh_he)
583 if (rhet < 20 && ishlt)
587 if (rhR - segR < dr_lowthresh_segvsrh_he)
589 if (rhR - segR > dr_highthresh_segvsrh_he)
591 if (
std::abs(truedt[0]) > dt_segvsrh_he &&
std::abs(truedt[1]) > dt_segvsrh_he &&
603 for (
size_t ihit = 0; ihit < bhtaggedrechits.
size(); ++ihit) {
604 bool alreadyincl =
false;
611 for (
size_t jhit = 0; jhit < refrhcoll.
size(); jhit++) {
613 if (rhitRef->detid() == rhRef->detid())
615 if (rhitRef->detid() == rhRef->detid())
618 if (!alreadyincl && isbarrel)
620 if (!alreadyincl && !isbarrel)
627 for (
size_t ihit = 0; ihit < bhtaggedrechits.
size(); ++ihit) {
628 bool alreadyincl =
false;
632 for (
size_t jhit = 0; jhit < refrhcoll.
size(); jhit++) {
634 if (rhitRef->detid() == rhRef->detid())
636 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)