15 constexpr
float c_cm_per_ns = 29.9792458;
82 bool calomatched =
false;
83 bool ECALBmatched =
false;
84 bool ECALEmatched =
false;
85 bool HCALmatched =
false;
91 bool trkmuunvetoisdefault =
false;
96 short int n_tracks_small_beta = 0;
97 short int n_tracks_small_dT = 0;
98 short int n_tracks_small_dT_and_beta = 0;
99 for (reco::MuonCollection::const_iterator iMuon = TheCosmicMuons->begin(); iMuon != TheCosmicMuons->end();
100 iMuon++, imucount++) {
105 bool StoreTrack =
false;
107 float innermost_global_z = 1500.;
108 float outermost_global_z = 0.;
112 for (
unsigned int j = 0;
j <
Track->
extra()->recHitsSize();
j++) {
116 DetId TheDetUnitId(
hit->geographicalId());
125 const GlobalPoint TheGlobalPosition = TheSurface.toGlobal(TheLocalPosition);
127 float z = TheGlobalPosition.
z();
128 if (
abs(
z) < innermost_global_z) {
129 innermost_global_z =
abs(
z);
130 InnerMostGlobalPosition =
GlobalPoint(TheGlobalPosition);
132 if (
abs(
z) > outermost_global_z) {
133 outermost_global_z =
abs(
z);
134 OuterMostGlobalPosition =
GlobalPoint(TheGlobalPosition);
139 std::vector<const CSCSegment*> MatchedSegments = TheMatcher->
matchCSC(*
Track, TheEvent);
142 float InnerSegmentTime[2] = {0, 0};
143 float OuterSegmentTime[2] = {0, 0};
144 float innermost_seg_z[2] = {1500, 1500};
145 float outermost_seg_z[2] = {0, 0};
146 for (std::vector<const CSCSegment*>::const_iterator segment = MatchedSegments.begin();
147 segment != MatchedSegments.end();
149 CSCDetId TheCSCDetId((*segment)->cscDetId());
151 LocalPoint TheLocalPosition = (*segment)->localPosition();
152 const GlobalPoint TheGlobalPosition = TheCSCChamber->toGlobal(TheLocalPosition);
153 float z = TheGlobalPosition.
z();
154 int TheEndcap = TheCSCDetId.endcap();
155 if (
abs(
z) < innermost_seg_z[TheEndcap - 1]) {
156 innermost_seg_z[TheEndcap - 1] =
abs(
z);
157 InnerSegmentTime[TheEndcap - 1] = (*segment)->time();
159 if (
abs(
z) > outermost_seg_z[TheEndcap - 1]) {
160 outermost_seg_z[TheEndcap - 1] =
abs(
z);
161 OuterSegmentTime[TheEndcap - 1] = (*segment)->time();
168 float dT_Segment = 0;
170 if (innermost_seg_z[0] < outermost_seg_z[0])
171 dT_Segment = OuterSegmentTime[0] - InnerSegmentTime[0];
172 if (innermost_seg_z[1] < outermost_seg_z[1])
176 if (dT_Segment == 0.0 || OuterSegmentTime[1] - InnerSegmentTime[1] < dT_Segment)
177 dT_Segment = OuterSegmentTime[1] - InnerSegmentTime[1];
180 if (OuterMostGlobalPosition.
x() == 0. || OuterMostGlobalPosition.
y() == 0. || OuterMostGlobalPosition.
z() == 0.)
182 if (InnerMostGlobalPosition.
x() == 0. || InnerMostGlobalPosition.
y() == 0. || InnerMostGlobalPosition.
z() == 0.)
188 float deta =
abs(OuterMostGlobalPosition.
eta() - InnerMostGlobalPosition.
eta());
191 float innermost_x = InnerMostGlobalPosition.
x();
192 float innermost_y = InnerMostGlobalPosition.
y();
193 float outermost_x = OuterMostGlobalPosition.
x();
194 float outermost_y = OuterMostGlobalPosition.
y();
195 float innermost_r = TMath::Sqrt(innermost_x * innermost_x + innermost_y * innermost_y);
196 float outermost_r = TMath::Sqrt(outermost_x * outermost_x + outermost_y * outermost_y);
230 n_tracks_small_beta++;
232 n_tracks_small_dT_and_beta++;
234 static std::atomic<bool> MuonTimeFail{
false};
235 bool expected =
false;
236 if (MuonTimeFail.compare_exchange_strong(expected,
true, std::memory_order_acq_rel)) {
238 <<
"The MuonTimeExtraMap does not appear to be in the event. Some beam halo " 239 <<
" identification variables will be empty";
243 TheCSCHaloData.
SetNIncomingTracks(n_tracks_small_dT, n_tracks_small_beta, n_tracks_small_dT_and_beta);
246 static std::atomic<bool> CosmicFail{
false};
247 bool expected =
false;
248 if (CosmicFail.compare_exchange_strong(expected,
true, std::memory_order_acq_rel)) {
250 <<
" The Cosmic Muon collection does not appear to be in the event. These beam halo " 251 <<
" identification variables will be empty";
258 short int n_recHitsP = 0;
259 short int n_recHitsM = 0;
262 for (dRHIter = TheCSCRecHits->begin(); dRHIter != TheCSCRecHits->end(); dRHIter++) {
263 if (!((*dRHIter).isValid()))
266 float RHTime = (*dRHIter).tpeak();
267 LocalPoint rhitlocal = (*dRHIter).localPosition();
270 float globZ = globalPosition.
z();
294 static std::atomic<bool> RecHitFail{
false};
295 bool expected =
false;
296 if (RecHitFail.compare_exchange_strong(expected,
true, std::memory_order_acq_rel)) {
298 <<
"The requested CSCRecHit2DCollection does not appear to be in the event. The CSC RecHit " 299 <<
" variables used for halo identification will not be calculated or stored";
306 short int maxNSegments = 0;
307 bool plus_endcap =
false;
308 bool minus_endcap =
false;
309 bool both_endcaps =
false;
310 bool both_endcaps_loose =
false;
313 short int maxNSegments_alt = 0;
314 bool both_endcaps_alt =
false;
315 bool both_endcaps_loose_alt =
false;
316 bool both_endcaps_loose_dtcut_alt =
false;
319 if (TheCSCSegments.
isValid()) {
322 CSCDetId iCscDetID = iSegment->cscDetId();
323 bool Segment1IsGood =
true;
324 bool Segment1IsGood_alt =
true;
328 for (reco::MuonCollection::const_iterator
mu = TheMuons->begin();
329 mu != TheMuons->end() && (Segment1IsGood || !trkmuunvetoisdefault);
331 bool lowpttrackmu =
false;
332 if (!
mu->isTrackerMuon() && !
mu->isGlobalMuon() &&
mu->isStandAloneMuon())
334 if (!
mu->isTrackerMuon() && !
mu->isGlobalMuon() &&
mu->isStandAloneMuon() && trkmuunvetoisdefault)
336 if (!
mu->isGlobalMuon() &&
mu->isTrackerMuon() &&
mu->pt() < 3)
338 const std::vector<MuonChamberMatch>
chambers =
mu->matches();
339 for (std::vector<MuonChamberMatch>::const_iterator kChamber =
chambers.begin(); kChamber !=
chambers.end();
343 for (std::vector<reco::MuonSegmentMatch>::const_iterator kSegment = kChamber->segmentMatches.begin();
344 kSegment != kChamber->segmentMatches.end();
347 CSCDetId kCscDetID = cscSegRef->cscDetId();
349 if (kCscDetID == iCscDetID) {
350 Segment1IsGood =
false;
352 Segment1IsGood_alt =
false;
358 if (!Segment1IsGood && !Segment1IsGood_alt)
363 LocalPoint iLocalPosition = iSegment->localPosition();
364 LocalVector iLocalDirection = iSegment->localDirection();
369 float iTheta = iGlobalDirection.
theta();
373 float iPhi = iGlobalPosition.
phi();
374 float iR = TMath::Sqrt(iGlobalPosition.
x() * iGlobalPosition.
x() + iGlobalPosition.
y() * iGlobalPosition.
y());
375 float iZ = iGlobalPosition.
z();
376 float iT = iSegment->time();
414 calomatched |= (hbhematched || ebmatched || eematched);
415 HCALmatched |= hbhematched;
416 ECALBmatched |= ebmatched;
417 ECALEmatched |= eematched;
420 short int nSegs_alt = 0;
424 if (jSegment == iSegment)
426 bool Segment2IsGood =
true;
427 bool Segment2IsGood_alt =
true;
428 LocalPoint jLocalPosition = jSegment->localPosition();
429 LocalVector jLocalDirection = jSegment->localDirection();
430 CSCDetId jCscDetID = jSegment->cscDetId();
433 float jTheta = jGlobalDirection.
theta();
434 float jPhi = jGlobalPosition.
phi();
435 float jR = TMath::Sqrt(jGlobalPosition.
x() * jGlobalPosition.
x() + jGlobalPosition.
y() * jGlobalPosition.
y());
436 float jZ = jGlobalPosition.
z();
437 float jT = jSegment->time();
441 ((jR - iR) > -0.02 *
std::abs(jZ - iZ) || iT > jT || jZ * iZ > 0) &&
442 ((iR - jR) > -0.02 *
std::abs(jZ - iZ) || iT < jT || jZ * iZ > 0) &&
447 for (reco::MuonCollection::const_iterator
mu = TheMuons->begin();
448 mu != TheMuons->end() && (Segment2IsGood || !trkmuunvetoisdefault);
450 bool lowpttrackmu =
false;
451 if (!
mu->isTrackerMuon() && !
mu->isGlobalMuon() &&
mu->isStandAloneMuon())
453 if (!
mu->isGlobalMuon() &&
mu->isTrackerMuon() &&
mu->pt() < 3)
455 const std::vector<MuonChamberMatch>
chambers =
mu->matches();
456 for (std::vector<MuonChamberMatch>::const_iterator kChamber =
chambers.begin();
461 for (std::vector<reco::MuonSegmentMatch>::const_iterator kSegment = kChamber->segmentMatches.begin();
462 kSegment != kChamber->segmentMatches.end();
465 CSCDetId kCscDetID = cscSegRef->cscDetId();
467 if (kCscDetID == jCscDetID) {
468 Segment2IsGood =
false;
470 Segment2IsGood_alt =
false;
476 if (Segment1IsGood && Segment2IsGood) {
478 minus_endcap = iGlobalPosition.
z() < 0 || jGlobalPosition.
z() < 0;
479 plus_endcap = iGlobalPosition.
z() > 0 || jGlobalPosition.
z() > 0;
482 if (Segment1IsGood_alt && Segment2IsGood_alt) {
484 minus_endcap = iGlobalPosition.
z() < 0 || jGlobalPosition.
z() < 0;
485 plus_endcap = iGlobalPosition.
z() > 0 || jGlobalPosition.
z() > 0;
486 double iTBX = iT +
sqrt(iGlobalPosition.
mag2()) / c_cm_per_ns;
487 double jTBX = jT +
sqrt(jGlobalPosition.
mag2()) / c_cm_per_ns;
488 double truedt = (iTBX > jTBX) ? iTBX - jTBX -
std::abs(iZ - jZ) / c_cm_per_ns
489 : jTBX - iTBX -
std::abs(iZ - jZ) / c_cm_per_ns;
490 if (
std::abs(truedt) < 15 && (iT > -15 || jT > -15) && minus_endcap && plus_endcap)
491 both_endcaps_loose_dtcut_alt =
true;
501 both_endcaps_loose = both_endcaps_loose ? both_endcaps_loose : minus_endcap && plus_endcap;
505 both_endcaps_loose_alt = both_endcaps_loose_alt ? both_endcaps_loose_alt : minus_endcap && plus_endcap;
508 if (nSegs > maxNSegments) {
512 maxNSegments = nSegs;
513 both_endcaps = both_endcaps ? both_endcaps : minus_endcap && plus_endcap;
516 if (nSegs_alt > maxNSegments_alt) {
517 maxNSegments_alt = nSegs_alt;
518 both_endcaps_alt = both_endcaps_alt ? both_endcaps_alt : minus_endcap && plus_endcap;
540 return TheCSCHaloData;
551 float dphi_thresh_segvsrh,
552 float dr_lowthresh_segvsrh,
553 float dr_highthresh_segvsrh,
554 float dt_lowthresh_segvsrh,
555 float dt_highthresh_segvsrh,
561 for (
size_t ihit = 0; ihit < rechitcoll->
size(); ++ihit) {
562 const HBHERecHit& rechit = (*rechitcoll)[ihit];
564 double rhet = rechit.
energy() / cosh(rhpos.eta());
565 double dphi_rhseg =
abs(
deltaPhi(rhpos.phi(), iPhi));
566 double dr_rhseg =
sqrt(rhpos.x() * rhpos.x() + rhpos.y() * rhpos.y()) - iR;
567 double dtcorr_rhseg = rechit.
time() -
abs(rhpos.z() - iZ) / 30 - iT;
568 if ((rechit.
time() < -3) && (rhpos.z() * iZ < 0 ||
abs(rhpos.z()) < 200) && rhet > et_thresh_rh &&
569 dphi_rhseg < dphi_thresh_segvsrh && dr_rhseg < dr_highthresh_segvsrh &&
570 dr_rhseg > dr_lowthresh_segvsrh &&
571 dtcorr_rhseg > dt_lowthresh_segvsrh && dtcorr_rhseg < dt_highthresh_segvsrh)
579 float dphi_thresh_segvsrh,
580 float dr_lowthresh_segvsrh,
581 float dr_highthresh_segvsrh,
582 float dt_lowthresh_segvsrh,
583 float dt_highthresh_segvsrh,
589 for (
size_t ihit = 0; ihit < rechitcoll->
size(); ++ihit) {
590 const EcalRecHit& rechit = (*rechitcoll)[ihit];
592 double rhet = rechit.
energy() / cosh(rhpos.eta());
593 double dphi_rhseg =
abs(
deltaPhi(rhpos.phi(), iPhi));
594 double dr_rhseg =
sqrt(rhpos.x() * rhpos.x() + rhpos.y() * rhpos.y()) - iR;
595 double dtcorr_rhseg = rechit.
time() -
abs(rhpos.z() - iZ) / 30 - iT;
596 if ((rechit.
time() < -1) && (rhpos.z() * iZ < 0 ||
abs(rhpos.z()) < 200) && rhet > et_thresh_rh &&
597 dphi_rhseg < dphi_thresh_segvsrh && dr_rhseg < dr_highthresh_segvsrh &&
598 dr_rhseg > dr_lowthresh_segvsrh &&
599 dtcorr_rhseg > dt_lowthresh_segvsrh && dtcorr_rhseg < dr_highthresh_segvsrh)
float dt_lowthresh_segvsrh_hbhe
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geoToken_
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
void SetNFlatHaloSegments_TrkMuUnVeto(short int nSegments)
float dr_lowthresh_segvsrh_hbhe
float dr_highthresh_segvsrh_ee
float dt_highthresh_segvsrh_eb
Geom::Phi< T > phi() const
reco::CSCHaloData Calculate(const CSCGeometry &TheCSCGeometry, edm::Handle< reco::MuonCollection > &TheCosmicMuons, const edm::Handle< reco::MuonTimeExtraMap > TheCSCTimeMap, edm::Handle< reco::MuonCollection > &TheMuons, edm::Handle< CSCSegmentCollection > &TheCSCSegments, edm::Handle< CSCRecHit2DCollection > &TheCSCRecHits, edm::Handle< L1MuGMTReadoutCollection > &TheL1GMTReadout, edm::Handle< HBHERecHitCollection > &hbhehits, edm::Handle< EcalRecHitCollection > &ecalebhits, edm::Handle< EcalRecHitCollection > &ecaleehits, edm::Handle< edm::TriggerResults > &TheHLTResults, const edm::TriggerNames *triggerNames, const edm::Handle< CSCALCTDigiCollection > &TheALCTs, MuonSegmentMatcher *TheMatcher, const edm::Event &TheEvent, const edm::EventSetup &TheEventSetup)
float dt_highthresh_segvsrh_hbhe
void SetSegmentIsEECaloMatched(bool b)
void SetSegmentsBothEndcaps_Loose_TrkMuUnVeto(bool b)
Global3DPoint GlobalPoint
std::vector< const CSCSegment * > matchCSC(const reco::Track &muon, const edm::Event &event)
float max_segment_phi_diff
constexpr float energy() const
float matching_dphi_threshold
float matching_deta_threshold
const CaloGeometry * geo_
C::const_iterator const_iterator
constant access iterator type
float dr_lowthresh_segvsrh_ee
float dt_lowthresh_segvsrh_ee
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
CSCHaloAlgo(edm::ConsumesCollector iC)
float max_dt_muon_segment
float dphi_thresh_segvsrh_ee
float dt_highthresh_segvsrh_ee
void SetSegmentIsCaloMatched(bool b)
Abs< T >::type abs(const T &t)
void SetSegmentsBothEndcaps(bool b)
float dphi_thresh_segvsrh_hbhe
math::XYZPoint Point
point in the space
const HcalGeometry * hgeo_
bool getData(T &iHolder) const
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
void SetHLTBit(bool status)
const Plane & surface() const
The nominal surface of the GeomDet.
void SetNFlatHaloSegments(short int nSegments)
float dr_highthresh_segvsrh_hbhe
constexpr HcalDetId id() const
get the id
XYZPointD XYZPoint
point in space with cartesian internal representation
void SetNIncomingTracks(short int n_small_dT, short int n_small_beta, short int n_small_both)
double normalizedChi2() const
chi-squared divided by n.d.o.f. (or chi-squared * 1e6 if n.d.o.f. is zero)
void SetNumberOfHaloTriggers(int PlusZ, int MinusZ)
float max_free_inverse_beta
DetId id() const
get the id
constexpr float time() const
void SetSegmentIsHCaloMatched(bool b)
int matching_dwire_threshold
float norm_chi2_threshold
float dt_lowthresh_segvsrh_eb
math::XYZPoint getPosition(const DetId &id, reco::Vertex::Point vtx)
GlobalPoint getPosition(const DetId &id) const
void SetSegmentsBothEndcaps_Loose_dTcut_TrkMuUnVeto(bool b)
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
bool ECALSegmentMatching(edm::Handle< EcalRecHitCollection > &rechitcoll, float et_thresh_rh, float dphi_thresh_segvsrh, float dr_lowthresh_segvsrh, float dr_highthresh_segvsrh, float dt_lowthresh_segvsrh, float dt_highthresh_segvsrh, float iZ, float iR, float iT, float iPhi)
void SetNOutOfTimeHits(short int num)
void SetNumberOfHaloTriggers_TrkMuUnVeto(int PlusZ, int MinusZ)
const std::vector< GlobalPoint > & GetCSCTrackImpactPositions() const
Log< level::Warning, false > LogWarning
void SetNOutOfTimeTriggers(short int PlusZ, short int MinusZ)
static char chambers[264][20]
bool HCALSegmentMatching(edm::Handle< HBHERecHitCollection > &rechitcoll, float et_thresh_rh, float dphi_thresh_segvsrh, float dr_lowthresh_segvsrh, float dr_highthresh_segvsrh, float dt_lowthresh_segvsrh, float dt_highthresh_segvsrh, float iZ, float iR, float iT, float iPhi)
void SetSegmentIsEBCaloMatched(bool b)
Geom::Theta< T > theta() const
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
float dr_highthresh_segvsrh_eb
float dr_lowthresh_segvsrh_eb
Geom::Theta< T > theta() const
const GeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
const TrackExtraRef & extra() const
reference to "extra" object
edm::RefVector< reco::TrackCollection > & GetTracks()
float dphi_thresh_segvsrh_eb