82 bool calomatched =
false;
83 bool ECALBmatched =
false;
84 bool ECALEmatched =
false;
85 bool HCALmatched =
false;
93 bool trkmuunvetoisdefault =
false;
98 short int n_tracks_small_beta = 0;
99 short int n_tracks_small_dT = 0;
100 short int n_tracks_small_dT_and_beta = 0;
101 for (reco::MuonCollection::const_iterator iMuon = TheCosmicMuons->begin(); iMuon != TheCosmicMuons->end();
102 iMuon++, imucount++) {
107 bool StoreTrack =
false;
109 float innermost_global_z = 1500.;
110 float outermost_global_z = 0.;
114 for (
unsigned int j = 0;
j < Track->extra()->recHitsSize();
j++) {
115 auto hit = Track->extra()->recHitRef(
j);
118 DetId TheDetUnitId(
hit->geographicalId());
127 const GlobalPoint TheGlobalPosition = TheSurface.toGlobal(TheLocalPosition);
129 float z = TheGlobalPosition.
z();
130 if (
abs(z) < innermost_global_z) {
131 innermost_global_z =
abs(z);
132 InnerMostGlobalPosition =
GlobalPoint(TheGlobalPosition);
134 if (
abs(z) > outermost_global_z) {
135 outermost_global_z =
abs(z);
136 OuterMostGlobalPosition =
GlobalPoint(TheGlobalPosition);
141 std::vector<const CSCSegment*> MatchedSegments = TheMatcher->
matchCSC(*Track, TheEvent);
144 float InnerSegmentTime[2] = {0, 0};
145 float OuterSegmentTime[2] = {0, 0};
146 float innermost_seg_z[2] = {1500, 1500};
147 float outermost_seg_z[2] = {0, 0};
148 for (std::vector<const CSCSegment*>::const_iterator segment = MatchedSegments.begin();
149 segment != MatchedSegments.end();
151 CSCDetId TheCSCDetId((*segment)->cscDetId());
153 LocalPoint TheLocalPosition = (*segment)->localPosition();
154 const GlobalPoint TheGlobalPosition = TheCSCChamber->toGlobal(TheLocalPosition);
155 float z = TheGlobalPosition.
z();
156 int TheEndcap = TheCSCDetId.endcap();
157 if (
abs(z) < innermost_seg_z[TheEndcap - 1]) {
158 innermost_seg_z[TheEndcap - 1] =
abs(z);
159 InnerSegmentTime[TheEndcap - 1] = (*segment)->time();
161 if (
abs(z) > outermost_seg_z[TheEndcap - 1]) {
162 outermost_seg_z[TheEndcap - 1] =
abs(z);
163 OuterSegmentTime[TheEndcap - 1] = (*segment)->time();
170 float dT_Segment = 0;
172 if (innermost_seg_z[0] < outermost_seg_z[0])
173 dT_Segment = OuterSegmentTime[0] - InnerSegmentTime[0];
174 if (innermost_seg_z[1] < outermost_seg_z[1])
178 if (dT_Segment == 0.0 || OuterSegmentTime[1] - InnerSegmentTime[1] < dT_Segment)
179 dT_Segment = OuterSegmentTime[1] - InnerSegmentTime[1];
182 if (OuterMostGlobalPosition.
x() == 0. || OuterMostGlobalPosition.
y() == 0. || OuterMostGlobalPosition.
z() == 0.)
184 if (InnerMostGlobalPosition.
x() == 0. || InnerMostGlobalPosition.
y() == 0. || InnerMostGlobalPosition.
z() == 0.)
190 float deta =
abs(OuterMostGlobalPosition.
eta() - InnerMostGlobalPosition.
eta());
192 float theta = Track->outerMomentum().theta();
193 float innermost_x = InnerMostGlobalPosition.
x();
194 float innermost_y = InnerMostGlobalPosition.
y();
195 float outermost_x = OuterMostGlobalPosition.
x();
196 float outermost_y = OuterMostGlobalPosition.
y();
197 float innermost_r = TMath::Sqrt(innermost_x * innermost_x + innermost_y * innermost_y);
198 float outermost_r = TMath::Sqrt(outermost_x * outermost_x + outermost_y * outermost_y);
232 n_tracks_small_beta++;
234 n_tracks_small_dT_and_beta++;
236 static std::atomic<bool> MuonTimeFail{
false};
237 bool expected =
false;
238 if (MuonTimeFail.compare_exchange_strong(expected,
true, std::memory_order_acq_rel)) {
240 <<
"The MuonTimeExtraMap does not appear to be in the event. Some beam halo " 241 <<
" identification variables will be empty";
245 TheCSCHaloData.
SetNIncomingTracks(n_tracks_small_dT, n_tracks_small_beta, n_tracks_small_dT_and_beta);
248 static std::atomic<bool> CosmicFail{
false};
249 bool expected =
false;
250 if (CosmicFail.compare_exchange_strong(expected,
true, std::memory_order_acq_rel)) {
252 <<
" The Cosmic Muon collection does not appear to be in the event. These beam halo " 253 <<
" identification variables will be empty";
260 short int n_recHitsP = 0;
261 short int n_recHitsM = 0;
264 for (dRHIter = TheCSCRecHits->begin(); dRHIter != TheCSCRecHits->end(); dRHIter++) {
265 if (!((*dRHIter).isValid()))
268 float RHTime = (*dRHIter).tpeak();
269 LocalPoint rhitlocal = (*dRHIter).localPosition();
272 float globZ = globalPosition.
z();
296 static std::atomic<bool> RecHitFail{
false};
297 bool expected =
false;
298 if (RecHitFail.compare_exchange_strong(expected,
true, std::memory_order_acq_rel)) {
300 <<
"The requested CSCRecHit2DCollection does not appear to be in the event. The CSC RecHit " 301 <<
" variables used for halo identification will not be calculated or stored";
308 short int maxNSegments = 0;
309 bool plus_endcap =
false;
310 bool minus_endcap =
false;
311 bool both_endcaps =
false;
312 bool both_endcaps_loose =
false;
315 short int maxNSegments_alt = 0;
316 bool both_endcaps_alt =
false;
317 bool both_endcaps_loose_alt =
false;
318 bool both_endcaps_loose_dtcut_alt =
false;
321 if (TheCSCSegments.
isValid()) {
324 CSCDetId iCscDetID = iSegment->cscDetId();
325 bool Segment1IsGood =
true;
326 bool Segment1IsGood_alt =
true;
330 for (reco::MuonCollection::const_iterator
mu = TheMuons->begin();
331 mu != TheMuons->end() && (Segment1IsGood || !trkmuunvetoisdefault);
333 bool lowpttrackmu =
false;
334 if (!
mu->isTrackerMuon() && !
mu->isGlobalMuon() &&
mu->isStandAloneMuon())
336 if (!
mu->isTrackerMuon() && !
mu->isGlobalMuon() &&
mu->isStandAloneMuon() && trkmuunvetoisdefault)
338 if (!
mu->isGlobalMuon() &&
mu->isTrackerMuon() &&
mu->pt() < 3)
340 const std::vector<MuonChamberMatch>
chambers =
mu->matches();
341 for (std::vector<MuonChamberMatch>::const_iterator kChamber = chambers.begin(); kChamber != chambers.end();
345 for (std::vector<reco::MuonSegmentMatch>::const_iterator kSegment = kChamber->segmentMatches.begin();
346 kSegment != kChamber->segmentMatches.end();
349 CSCDetId kCscDetID = cscSegRef->cscDetId();
351 if (kCscDetID == iCscDetID) {
352 Segment1IsGood =
false;
354 Segment1IsGood_alt =
false;
360 if (!Segment1IsGood && !Segment1IsGood_alt)
365 LocalPoint iLocalPosition = iSegment->localPosition();
366 LocalVector iLocalDirection = iSegment->localDirection();
371 float iTheta = iGlobalDirection.
theta();
375 float iPhi = iGlobalPosition.
phi();
376 float iR = TMath::Sqrt(iGlobalPosition.
x() * iGlobalPosition.
x() + iGlobalPosition.
y() * iGlobalPosition.
y());
377 float iZ = iGlobalPosition.
z();
378 float iT = iSegment->time();
416 calomatched |= (hbhematched || ebmatched || eematched);
417 HCALmatched |= hbhematched;
418 ECALBmatched |= ebmatched;
419 ECALEmatched |= eematched;
422 short int nSegs_alt = 0;
426 if (jSegment == iSegment)
428 bool Segment2IsGood =
true;
429 bool Segment2IsGood_alt =
true;
430 LocalPoint jLocalPosition = jSegment->localPosition();
431 LocalVector jLocalDirection = jSegment->localDirection();
432 CSCDetId jCscDetID = jSegment->cscDetId();
435 float jTheta = jGlobalDirection.
theta();
436 float jPhi = jGlobalPosition.
phi();
437 float jR = TMath::Sqrt(jGlobalPosition.
x() * jGlobalPosition.
x() + jGlobalPosition.
y() * jGlobalPosition.
y());
438 float jZ = jGlobalPosition.
z();
439 float jT = jSegment->time();
443 ((jR - iR) > -0.02 *
std::abs(jZ - iZ) || iT > jT || jZ * iZ > 0) &&
444 ((iR - jR) > -0.02 *
std::abs(jZ - iZ) || iT < jT || jZ * iZ > 0) &&
449 for (reco::MuonCollection::const_iterator
mu = TheMuons->begin();
450 mu != TheMuons->end() && (Segment2IsGood || !trkmuunvetoisdefault);
452 bool lowpttrackmu =
false;
453 if (!
mu->isTrackerMuon() && !
mu->isGlobalMuon() &&
mu->isStandAloneMuon())
455 if (!
mu->isGlobalMuon() &&
mu->isTrackerMuon() &&
mu->pt() < 3)
457 const std::vector<MuonChamberMatch>
chambers =
mu->matches();
458 for (std::vector<MuonChamberMatch>::const_iterator kChamber = chambers.begin();
459 kChamber != chambers.end();
463 for (std::vector<reco::MuonSegmentMatch>::const_iterator kSegment = kChamber->segmentMatches.begin();
464 kSegment != kChamber->segmentMatches.end();
467 CSCDetId kCscDetID = cscSegRef->cscDetId();
469 if (kCscDetID == jCscDetID) {
470 Segment2IsGood =
false;
472 Segment2IsGood_alt =
false;
478 if (Segment1IsGood && Segment2IsGood) {
480 minus_endcap = iGlobalPosition.
z() < 0 || jGlobalPosition.
z() < 0;
481 plus_endcap = iGlobalPosition.
z() > 0 || jGlobalPosition.
z() > 0;
484 if (Segment1IsGood_alt && Segment2IsGood_alt) {
486 minus_endcap = iGlobalPosition.
z() < 0 || jGlobalPosition.
z() < 0;
487 plus_endcap = iGlobalPosition.
z() > 0 || jGlobalPosition.
z() > 0;
488 double iTBX = iT +
sqrt(iGlobalPosition.
mag2()) / c_cm_per_ns;
489 double jTBX = jT +
sqrt(jGlobalPosition.
mag2()) / c_cm_per_ns;
490 double truedt = (iTBX > jTBX) ? iTBX - jTBX -
std::abs(iZ - jZ) / c_cm_per_ns
491 : jTBX - iTBX -
std::abs(iZ - jZ) / c_cm_per_ns;
492 if (
std::abs(truedt) < 15 && (iT > -15 || jT > -15) && minus_endcap && plus_endcap)
493 both_endcaps_loose_dtcut_alt =
true;
503 both_endcaps_loose = both_endcaps_loose ? both_endcaps_loose : minus_endcap && plus_endcap;
507 both_endcaps_loose_alt = both_endcaps_loose_alt ? both_endcaps_loose_alt : minus_endcap && plus_endcap;
510 if (nSegs > maxNSegments) {
514 maxNSegments = nSegs;
515 both_endcaps = both_endcaps ? both_endcaps : minus_endcap && plus_endcap;
518 if (nSegs_alt > maxNSegments_alt) {
519 maxNSegments_alt = nSegs_alt;
520 both_endcaps_alt = both_endcaps_alt ? both_endcaps_alt : minus_endcap && plus_endcap;
542 return TheCSCHaloData;
553 float dphi_thresh_segvsrh,
554 float dr_lowthresh_segvsrh,
555 float dr_highthresh_segvsrh,
556 float dt_lowthresh_segvsrh,
557 float dt_highthresh_segvsrh,
563 for (
size_t ihit = 0; ihit < rechitcoll->
size(); ++ihit) {
564 const HBHERecHit& rechit = (*rechitcoll)[ihit];
566 double rhet = rechit.
energy() / cosh(rhpos.eta());
567 double dphi_rhseg =
abs(
deltaPhi(rhpos.phi(), iPhi));
568 double dr_rhseg =
sqrt(rhpos.x() * rhpos.x() + rhpos.y() * rhpos.y()) - iR;
569 double dtcorr_rhseg = rechit.
time() -
abs(rhpos.z() - iZ) / 30 - iT;
570 if ((rechit.
time() < -3) && (rhpos.z() * iZ < 0 ||
abs(rhpos.z()) < 200) && rhet > et_thresh_rh &&
571 dphi_rhseg < dphi_thresh_segvsrh && dr_rhseg < dr_highthresh_segvsrh &&
572 dr_rhseg > dr_lowthresh_segvsrh &&
573 dtcorr_rhseg > dt_lowthresh_segvsrh && dtcorr_rhseg < dt_highthresh_segvsrh)
581 float dphi_thresh_segvsrh,
582 float dr_lowthresh_segvsrh,
583 float dr_highthresh_segvsrh,
584 float dt_lowthresh_segvsrh,
585 float dt_highthresh_segvsrh,
591 for (
size_t ihit = 0; ihit < rechitcoll->
size(); ++ihit) {
592 const EcalRecHit& rechit = (*rechitcoll)[ihit];
594 double rhet = rechit.
energy() / cosh(rhpos.eta());
595 double dphi_rhseg =
abs(
deltaPhi(rhpos.phi(), iPhi));
596 double dr_rhseg =
sqrt(rhpos.x() * rhpos.x() + rhpos.y() * rhpos.y()) - iR;
597 double dtcorr_rhseg = rechit.
time() -
abs(rhpos.z() - iZ) / 30 - iT;
598 if ((rechit.
time() < -1) && (rhpos.z() * iZ < 0 ||
abs(rhpos.z()) < 200) && rhet > et_thresh_rh &&
599 dphi_rhseg < dphi_thresh_segvsrh && dr_rhseg < dr_highthresh_segvsrh &&
600 dr_rhseg > dr_lowthresh_segvsrh &&
601 dtcorr_rhseg > dt_lowthresh_segvsrh && dtcorr_rhseg < dr_highthresh_segvsrh)
constexpr float energy() const
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
float dt_lowthresh_segvsrh_hbhe
void SetNFlatHaloSegments_TrkMuUnVeto(short int nSegments)
float dr_lowthresh_segvsrh_hbhe
float dr_highthresh_segvsrh_ee
float dt_highthresh_segvsrh_eb
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)
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
float dt_highthresh_segvsrh_hbhe
void SetSegmentIsEECaloMatched(bool b)
HcalDetId id() const
get the id
void SetSegmentsBothEndcaps_Loose_TrkMuUnVeto(bool b)
Geom::Phi< T > phi() const
Global3DPoint GlobalPoint
Geom::Theta< T > theta() const
std::vector< const CSCSegment * > matchCSC(const reco::Track &muon, const edm::Event &event)
const Plane & surface() const
The nominal surface of the GeomDet.
float max_segment_phi_diff
float matching_dphi_threshold
Geom::Theta< T > theta() const
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
float max_dt_muon_segment
float dphi_thresh_segvsrh_ee
float dt_highthresh_segvsrh_ee
void SetSegmentIsCaloMatched(bool b)
constexpr float time() const
const std::vector< GlobalPoint > & GetCSCTrackImpactPositions() const
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
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_
GlobalPoint getPosition(const DetId &id) const
void SetHLTBit(bool status)
void SetNFlatHaloSegments(short int nSegments)
float dr_highthresh_segvsrh_hbhe
DetId 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)
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
void SetNumberOfHaloTriggers(int PlusZ, int MinusZ)
float max_free_inverse_beta
void SetSegmentIsHCaloMatched(bool b)
const GeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
int matching_dwire_threshold
float norm_chi2_threshold
float dt_lowthresh_segvsrh_eb
math::XYZPoint getPosition(const DetId &id, reco::Vertex::Point vtx)
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)
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)
T const * product() const
float dr_highthresh_segvsrh_eb
float dr_lowthresh_segvsrh_eb
edm::RefVector< reco::TrackCollection > & GetTracks()
float dphi_thresh_segvsrh_eb