CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
TrackDetectorAssociator Class Reference

#include <TrackDetectorAssociator.h>

Public Types

typedef TrackAssociatorParameters AssociatorParameters
 
enum  Direction { Any, InsideOut, OutsideIn }
 

Public Member Functions

TrackDetMatchInfo associate (const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const AssociatorParameters &)
 
TrackDetMatchInfo associate (const edm::Event &iEvent, const edm::EventSetup &iSetup, const AssociatorParameters &parameters, const FreeTrajectoryState *innerState, const FreeTrajectoryState *outerState=nullptr)
 
TrackDetMatchInfo associate (const edm::Event &, const edm::EventSetup &, const reco::Track &, const AssociatorParameters &, Direction direction=Any)
 associate using reco::Track More...
 
TrackDetMatchInfo associate (const edm::Event &, const edm::EventSetup &, const SimTrack &, const SimVertex &, const AssociatorParameters &)
 associate using a simulated track More...
 
TrackDetMatchInfo associate (const edm::Event &, const edm::EventSetup &, const GlobalVector &, const GlobalPoint &, const int, const AssociatorParameters &)
 associate using 3-momentum, vertex and charge More...
 
const CachedTrajectorygetCachedTrajector () const
 trajector information More...
 
void setPropagator (const Propagator *)
 use a user configured propagator More...
 
 TrackDetectorAssociator ()
 
void useDefaultPropagator ()
 use the default propagator More...
 
 ~TrackDetectorAssociator ()
 

Static Public Member Functions

static bool crossedIP (const reco::Track &track)
 
static FreeTrajectoryState getFreeTrajectoryState (const MagneticField *, const reco::Track &)
 get FreeTrajectoryState from different track representations More...
 
static FreeTrajectoryState getFreeTrajectoryState (const MagneticField *, const SimTrack &, const SimVertex &)
 
static FreeTrajectoryState getFreeTrajectoryState (const MagneticField *, const GlobalVector &, const GlobalPoint &, const int)
 

Private Member Functions

bool addTAMuonSegmentMatch (TAMuonChamberMatch &, const RecSegment *, const AssociatorParameters &)
 
void fillCaloTowers (const edm::Event &, TrackDetMatchInfo &, const AssociatorParameters &)
 
void fillCaloTruth (const edm::Event &, TrackDetMatchInfo &, const AssociatorParameters &)
 
void fillEcal (const edm::Event &, TrackDetMatchInfo &, const AssociatorParameters &)
 
void fillHcal (const edm::Event &, TrackDetMatchInfo &, const AssociatorParameters &)
 
void fillHO (const edm::Event &, TrackDetMatchInfo &, const AssociatorParameters &)
 
void fillMuon (const edm::Event &, TrackDetMatchInfo &, const AssociatorParameters &)
 
void fillPreshower (const edm::Event &iEvent, TrackDetMatchInfo &info, const AssociatorParameters &)
 
DetIdAssociator::MapRange getMapRange (const std::pair< float, float > &delta, const float dR)
 
math::XYZPoint getPoint (const GlobalPoint &point)
 
math::XYZPoint getPoint (const LocalPoint &point)
 
void getTAMuonChamberMatches (std::vector< TAMuonChamberMatch > &matches, const AssociatorParameters &parameters, std::set< DetId > occupancy)
 
math::XYZVector getVector (const GlobalVector &vec)
 
math::XYZVector getVector (const LocalVector &vec)
 
void init (const edm::EventSetup &, const AssociatorParameters &)
 

Private Attributes

CachedTrajectory cachedTrajectory_
 
const DetIdAssociatorcaloDetIdAssociator_
 
std::unique_ptr< PropagatordefProp_
 
const DetIdAssociatorecalDetIdAssociator_
 
const DetIdAssociatorhcalDetIdAssociator_
 
const DetIdAssociatorhoDetIdAssociator_
 
const PropagatorivProp_
 
const DetIdAssociatormuonDetIdAssociator_
 
const DetIdAssociatorpreshowerDetIdAssociator_
 
const CaloGeometrytheCaloGeometry_
 
edm::ESWatcher< IdealMagneticFieldRecordtheMagneticFieldWatcher_
 
const GlobalTrackingGeometrytheTrackingGeometry_
 
bool useDefaultPropagator_
 

Detailed Description

Definition at line 44 of file TrackDetectorAssociator.h.

Member Typedef Documentation

◆ AssociatorParameters

Definition at line 49 of file TrackDetectorAssociator.h.

Member Enumeration Documentation

◆ Direction

Constructor & Destructor Documentation

◆ TrackDetectorAssociator()

TrackDetectorAssociator::TrackDetectorAssociator ( )
explicit

Definition at line 73 of file TrackDetectorAssociator.cc.

73  {
74  ivProp_ = nullptr;
75  useDefaultPropagator_ = false;
76 }

◆ ~TrackDetectorAssociator()

TrackDetectorAssociator::~TrackDetectorAssociator ( )
default

Member Function Documentation

◆ addTAMuonSegmentMatch()

bool TrackDetectorAssociator::addTAMuonSegmentMatch ( TAMuonChamberMatch matchedChamber,
const RecSegment segment,
const AssociatorParameters parameters 
)
private

Definition at line 868 of file TrackDetectorAssociator.cc.

References funct::abs(), relativeConstraints::chamber, spr::deltaEta, reco::deltaPhi(), PV3DBase< T, PVType, FrameType >::eta(), f, TrajectoryStateOnSurface::freeState(), TrackingRecHit::geographicalId(), TAMuonSegmentMatch::hasPhi, DTRecSegment4D::hasPhi(), TAMuonSegmentMatch::hasZed, DTRecSegment4D::hasZed(), hfClusterShapes_cfi::hits, TAMuonChamberMatch::id, DTRecSegment2D::ist0Valid(), RecSegment::localDirection(), RecSegment::localDirectionError(), TrackingRecHit::localPosition(), TrackingRecHit::localPositionError(), LogTrace, M_PI, PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), DTRecSegment4D::phiSegment(), FreeTrajectoryState::position(), DetId::rawId(), TAMuonSegmentMatch::segmentGlobalPosition, TAMuonSegmentMatch::segmentLocalDirection, TAMuonSegmentMatch::segmentLocalErrorDxDz, TAMuonSegmentMatch::segmentLocalErrorDyDz, TAMuonSegmentMatch::segmentLocalErrorXDxDz, TAMuonSegmentMatch::segmentLocalErrorXX, TAMuonSegmentMatch::segmentLocalErrorXY, TAMuonSegmentMatch::segmentLocalErrorYDyDz, TAMuonSegmentMatch::segmentLocalErrorYY, TAMuonSegmentMatch::segmentLocalPosition, TAMuonChamberMatch::segments, DTRecSegment2D::specificRecHits(), TAMuonSegmentMatch::t0, DTRecSegment2D::t0(), FrontierCondition_GT_autoExpress_cfi::t0, TAMuonChamberMatch::tState, LocalError::xx(), LocalError::xy(), and LocalError::yy().

870  {
871  LogTrace("TrackAssociator") << "Segment local position: " << segment->localPosition() << "\n"
872  << std::hex << segment->geographicalId().rawId() << "\n";
873 
874  const GeomDet* chamber = muonDetIdAssociator_->getGeomDet(matchedChamber.id);
875  TrajectoryStateOnSurface trajectoryStateOnSurface = matchedChamber.tState;
876  GlobalPoint segmentGlobalPosition = chamber->toGlobal(segment->localPosition());
877 
878  LogTrace("TrackAssociator") << "Segment global position: " << segmentGlobalPosition
879  << " \t (R_xy,eta,phi): " << segmentGlobalPosition.perp() << ","
880  << segmentGlobalPosition.eta() << "," << segmentGlobalPosition.phi() << "\n";
881 
882  LogTrace("TrackAssociator") << "\teta hit: " << segmentGlobalPosition.eta()
883  << " \tpropagator: " << trajectoryStateOnSurface.freeState()->position().eta() << "\n"
884  << "\tphi hit: " << segmentGlobalPosition.phi()
885  << " \tpropagator: " << trajectoryStateOnSurface.freeState()->position().phi()
886  << std::endl;
887 
888  bool isGood = false;
889  bool isDTWithoutY = false;
890  const DTRecSegment4D* dtseg = dynamic_cast<const DTRecSegment4D*>(segment);
891  if (dtseg && (!dtseg->hasZed()))
892  isDTWithoutY = true;
893 
894  float deltaPhi(std::abs(segmentGlobalPosition.phi() - trajectoryStateOnSurface.freeState()->position().phi()));
895  if (deltaPhi > float(M_PI))
896  deltaPhi = std::abs(deltaPhi - float(M_PI) * 2.f);
897  float deltaEta = std::abs(segmentGlobalPosition.eta() - trajectoryStateOnSurface.freeState()->position().eta());
898 
899  if (isDTWithoutY) {
900  isGood = deltaPhi < parameters.dRMuon;
901  // Be in chamber
902  isGood &= deltaEta < .3f;
903  } else
904  isGood = deltaEta * deltaEta + deltaPhi * deltaPhi < parameters.dRMuon * parameters.dRMuon;
905 
906  if (isGood) {
907  TAMuonSegmentMatch muonSegment;
908  muonSegment.segmentGlobalPosition = getPoint(segmentGlobalPosition);
909  muonSegment.segmentLocalPosition = getPoint(segment->localPosition());
910  muonSegment.segmentLocalDirection = getVector(segment->localDirection());
911  muonSegment.segmentLocalErrorXX = segment->localPositionError().xx();
912  muonSegment.segmentLocalErrorYY = segment->localPositionError().yy();
913  muonSegment.segmentLocalErrorXY = segment->localPositionError().xy();
914  muonSegment.segmentLocalErrorDxDz = segment->localDirectionError().xx();
915  muonSegment.segmentLocalErrorDyDz = segment->localDirectionError().yy();
916 
917  // DANGEROUS - compiler cannot guaranty parameters ordering
918  // AlgebraicSymMatrix segmentCovMatrix = segment->parametersError();
919  // muonSegment.segmentLocalErrorXDxDz = segmentCovMatrix[2][0];
920  // muonSegment.segmentLocalErrorYDyDz = segmentCovMatrix[3][1];
921  muonSegment.segmentLocalErrorXDxDz = -999.f;
922  muonSegment.segmentLocalErrorYDyDz = -999.f;
923  muonSegment.hasZed = true;
924  muonSegment.hasPhi = true;
925 
926  // timing information
927  muonSegment.t0 = 0.f;
928  if (dtseg) {
929  if ((dtseg->hasPhi()) && (!isDTWithoutY)) {
930  int phiHits = dtseg->phiSegment()->specificRecHits().size();
931  // int zHits = dtseg->zSegment()->specificRecHits().size();
932  int hits = 0;
933  double t0 = 0.;
934  // TODO: cuts on hit numbers not optimized in any way yet...
935  if (phiHits > 5 && dtseg->phiSegment()->ist0Valid()) {
936  t0 += dtseg->phiSegment()->t0() * phiHits;
937  hits += phiHits;
938  LogTrace("TrackAssociator") << " Phi t0: " << dtseg->phiSegment()->t0() << " hits: " << phiHits;
939  }
940  // the z segments seem to contain little useful information...
941  // if (zHits>3) {
942  // t0+=s->zSegment()->t0()*zHits;
943  // hits+=zHits;
944  // LogTrace("TrackAssociator") << " Z t0: " << s->zSegment()->t0() << " hits: " << zHits << std::endl;
945  // }
946  if (hits)
947  muonSegment.t0 = t0 / hits;
948  // LogTrace("TrackAssociator") << " --- t0: " << muonSegment.t0 << std::endl;
949  } else {
950  // check and set dimensionality
951  if (isDTWithoutY)
952  muonSegment.hasZed = false;
953  if (!dtseg->hasPhi())
954  muonSegment.hasPhi = false;
955  }
956  }
957  matchedChamber.segments.push_back(muonSegment);
958  }
959 
960  return isGood;
961 }
bool ist0Valid() const
T perp() const
Definition: PV3DBase.h:69
virtual LocalError localDirectionError() const =0
Error on the local direction.
TrajectoryStateOnSurface tState
bool hasPhi() const
Does it have the Phi projection?
double t0() const
Get the segment t0 (if recomputed, 0 is returned otherwise)
math::XYZPoint segmentGlobalPosition
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
math::XYZPoint segmentLocalPosition
virtual LocalVector localDirection() const =0
Local direction.
T eta() const
Definition: PV3DBase.h:73
math::XYZVector getVector(const GlobalVector &vec)
math::XYZVector segmentLocalDirection
static const double deltaEta
Definition: CaloConstants.h:8
#define LogTrace(id)
GlobalPoint position() const
float yy() const
Definition: LocalError.h:24
const DetIdAssociator * muonDetIdAssociator_
std::vector< TAMuonSegmentMatch > segments
distance sign convention: negative - crossed chamber, positive - missed chamber
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
virtual const GeomDet * getGeomDet(const DetId &) const =0
#define M_PI
float xy() const
Definition: LocalError.h:23
DetId geographicalId() const
math::XYZPoint getPoint(const GlobalPoint &point)
const DTChamberRecSegment2D * phiSegment() const
The superPhi segment: 0 if no phi projection available.
std::vector< DTRecHit1D > specificRecHits() const
Access to specific components.
virtual LocalError localPositionError() const =0
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
FreeTrajectoryState const * freeState(bool withErrors=true) const
bool hasZed() const
Does it have the Z projection?
virtual LocalPoint localPosition() const =0
float xx() const
Definition: LocalError.h:22

◆ associate() [1/5]

TrackDetMatchInfo TrackDetectorAssociator::associate ( const edm::Event iEvent,
const edm::EventSetup iSetup,
const FreeTrajectoryState fts,
const AssociatorParameters parameters 
)

propagate a track across the whole detector and find associated objects. Association is done in two modes 1) an object is associated to a track only if crossed by track 2) an object is associated to a track if it is withing an eta-phi cone of some radius with respect to a track. (the cone origin is at (0,0,0)) Trajectory bending in eta-phi is taking into account when matching is performed

associate using FreeTrajectoryState

Definition at line 114 of file TrackDetectorAssociator.cc.

References iEvent.

Referenced by EopTreeWriter::analyze(), ValidIsoTrkCalib::analyze(), EcalCosmicsHists::analyze(), muonisolation::CaloExtractorByAssociator::deposits(), cms::MuonMETValueMapProducer::determine_deltax_deltay(), MuonIdProducer::fillMuonId(), and InterestingTrackEcalDetIdProducer::produce().

117  {
118  return associate(iEvent, iSetup, parameters, &fts);
119 }
int iEvent
Definition: GenABIO.cc:224
TrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const AssociatorParameters &)

◆ associate() [2/5]

TrackDetMatchInfo TrackDetectorAssociator::associate ( const edm::Event iEvent,
const edm::EventSetup iSetup,
const AssociatorParameters parameters,
const FreeTrajectoryState innerState,
const FreeTrajectoryState outerState = nullptr 
)

associate using inner and outer most states of a track in the silicon tracker.

Definition at line 121 of file TrackDetectorAssociator.cc.

References funct::abs(), Exception, iEvent, info(), reco::init(), edm::isNotFinite(), LogTrace, PV3DBase< T, PVType, FrameType >::mag(), CosmicsPD_Skims::maxZ, CosmicGenFilterHelix_cff::minZ, SteppingHelixStateInfo::momentum(), or, PV3DBase< T, PVType, FrameType >::perp(), FreeTrajectoryState::position(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

125  {
127  if (!parameters.useEcal && !parameters.useCalo && !parameters.useHcal && !parameters.useHO && !parameters.useMuon &&
128  !parameters.usePreshower)
129  throw cms::Exception("ConfigurationError")
130  << "Configuration error! No subdetector was selected for the track association.";
131 
132  SteppingHelixStateInfo trackOrigin(*innerState);
133  info.stateAtIP = *innerState;
134  cachedTrajectory_.setStateAtIP(trackOrigin);
135 
136  init(iSetup, parameters);
137  // get track trajectory
138  // ECAL points (EB+EE)
139  // If the phi angle between a track entrance and exit points is more
140  // than 2 crystals, it is possible that the track will cross 3 crystals
141  // and therefore one has to check at least 3 points along the track
142  // trajectory inside ECAL. In order to have a chance to cross 4 crystalls
143  // in the barrel, a track should have P_t as low as 3 GeV or smaller
144  // If it's necessary, number of points along trajectory can be increased
145 
146  info.setCaloGeometry(theCaloGeometry_);
147 
149  // estimate propagation outer boundaries based on
150  // requested sub-detector information. For now limit
151  // propagation region only if muon matching is not
152  // requested.
153  double HOmaxR = hoDetIdAssociator_->volume().maxR();
154  double HOmaxZ = hoDetIdAssociator_->volume().maxZ();
155  double minR = ecalDetIdAssociator_->volume().minR();
158  cachedTrajectory_.setMaxHOLength(HOmaxZ * 2.);
161 
162  if (parameters.useMuon) {
163  double maxR = muonDetIdAssociator_->volume().maxR();
164  double maxZ = muonDetIdAssociator_->volume().maxZ();
167  } else {
170  }
171 
172  // If track extras exist and outerState is before HO maximum, then use outerState
173  if (outerState) {
174  if (outerState->position().perp() < HOmaxR && std::abs(outerState->position().z()) < HOmaxZ) {
175  LogTrace("TrackAssociator") << "Using outerState as trackOrigin at Rho=" << outerState->position().perp()
176  << " Z=" << outerState->position().z() << "\n";
177  trackOrigin = SteppingHelixStateInfo(*outerState);
178  } else if (innerState) {
179  LogTrace("TrackAssociator") << "Using innerState as trackOrigin at Rho=" << innerState->position().perp()
180  << " Z=" << innerState->position().z() << "\n";
181  trackOrigin = SteppingHelixStateInfo(*innerState);
182  }
183  }
184 
185  if (trackOrigin.momentum().mag() == 0)
186  return info;
187  if (edm::isNotFinite(trackOrigin.momentum().x()) or edm::isNotFinite(trackOrigin.momentum().y()) or
188  edm::isNotFinite(trackOrigin.momentum().z()))
189  return info;
190  if (!cachedTrajectory_.propagateAll(trackOrigin))
191  return info;
192 
193  // get trajectory in calorimeters
198 
199  info.trkGlobPosAtEcal = getPoint(cachedTrajectory_.getStateAtEcal().position());
200  info.trkGlobPosAtHcal = getPoint(cachedTrajectory_.getStateAtHcal().position());
201  info.trkGlobPosAtHO = getPoint(cachedTrajectory_.getStateAtHO().position());
202 
203  info.trkMomAtEcal = cachedTrajectory_.getStateAtEcal().momentum();
204  info.trkMomAtHcal = cachedTrajectory_.getStateAtHcal().momentum();
205  info.trkMomAtHO = cachedTrajectory_.getStateAtHO().momentum();
206 
207  if (parameters.useEcal)
209  if (parameters.useCalo)
211  if (parameters.useHcal)
213  if (parameters.useHO)
215  if (parameters.usePreshower)
217  if (parameters.useMuon)
219  if (parameters.truthMatch)
221 
222  return info;
223 }
SteppingHelixStateInfo getStateAtHO()
static const TGPicture * info(bool iBackgroundIsBlack)
T perp() const
Definition: PV3DBase.h:69
const DetIdAssociator * ecalDetIdAssociator_
void findPreshowerTrajectory(const FiducialVolume &)
T z() const
Definition: PV3DBase.h:61
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
void setMinDetectorLength(float l=0.)
void setMinDetectorRadius(float r=0.)
void setMaxHOLength(float l=2200.)
void fillHcal(const edm::Event &, TrackDetMatchInfo &, const AssociatorParameters &)
double maxZ(bool withTolerance=true) const
void findHcalTrajectory(const FiducialVolume &)
#define LogTrace(id)
GlobalPoint position() const
void fillCaloTowers(const edm::Event &, TrackDetMatchInfo &, const AssociatorParameters &)
GlobalPoint position() const
void fillCaloTruth(const edm::Event &, TrackDetMatchInfo &, const AssociatorParameters &)
const DetIdAssociator * hcalDetIdAssociator_
void init(const edm::EventSetup &, const AssociatorParameters &)
int iEvent
Definition: GenABIO.cc:224
const FiducialVolume & volume() const
get active detector volume
bool propagateAll(const SteppingHelixStateInfo &initialState)
propagate through the whole detector, returns true if successful
const DetIdAssociator * hoDetIdAssociator_
const DetIdAssociator * muonDetIdAssociator_
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
void setMaxHORadius(float r=800.)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void fillPreshower(const edm::Event &iEvent, TrackDetMatchInfo &info, const AssociatorParameters &)
math::XYZPoint getPoint(const GlobalPoint &point)
void fillMuon(const edm::Event &, TrackDetMatchInfo &, const AssociatorParameters &)
void findEcalTrajectory(const FiducialVolume &)
GlobalVector momentum() const
void fillEcal(const edm::Event &, TrackDetMatchInfo &, const AssociatorParameters &)
SteppingHelixStateInfo getStateAtEcal()
const DetIdAssociator * preshowerDetIdAssociator_
void findHOTrajectory(const FiducialVolume &)
double minR(bool withTolerance=true) const
void setStateAtIP(const SteppingHelixStateInfo &state)
void fillHO(const edm::Event &, TrackDetMatchInfo &, const AssociatorParameters &)
double maxR(bool withTolerance=true) const
void setMaxDetectorLength(float l=2200.)
const CaloGeometry * theCaloGeometry_
SteppingHelixStateInfo getStateAtHcal()
double minZ(bool withTolerance=true) const
void setMaxDetectorRadius(float r=800.)

◆ associate() [3/5]

TrackDetMatchInfo TrackDetectorAssociator::associate ( const edm::Event iEvent,
const edm::EventSetup iSetup,
const reco::Track track,
const AssociatorParameters parameters,
Direction  direction = Any 
)

associate using reco::Track

Definition at line 1032 of file TrackDetectorAssociator.cc.

References funct::abs(), Calorimetry_cff::bField, Exception, edm::EventSetup::getData(), iEvent, trajectoryStateTransform::initialFreeState(), trajectoryStateTransform::innerFreeState(), LogTrace, trajectoryStateTransform::outerFreeState(), PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), FreeTrajectoryState::position(), mps_fire::result, HLT_2024v11_cff::track, and PV3DBase< T, PVType, FrameType >::z().

1036  {
1037  double currentStepSize = cachedTrajectory_.getPropagationStep();
1038 
1039  const MagneticField* bField = &iSetup.getData(parameters.bFieldToken);
1040 
1041  if (track.extra().isNull()) {
1042  if (direction != InsideOut)
1043  throw cms::Exception("FatalError") << "No TrackExtra information is available and association is done with "
1044  "something else than InsideOut track.\n"
1045  << "Either change the parameter or provide needed data!\n";
1046  LogTrace("TrackAssociator") << "Track Extras not found\n";
1048  return associate(iEvent, iSetup, parameters, &initialState); // 5th argument is null pointer
1049  }
1050 
1051  LogTrace("TrackAssociator") << "Track Extras found\n";
1055 
1056  LogTrace("TrackAssociator") << "inner track state (rho, z, phi):" << track.innerPosition().Rho() << ", "
1057  << track.innerPosition().z() << ", " << track.innerPosition().phi() << "\n";
1058  LogTrace("TrackAssociator") << "innerFreeState (rho, z, phi):" << innerState.position().perp() << ", "
1059  << innerState.position().z() << ", " << innerState.position().phi() << "\n";
1060 
1061  LogTrace("TrackAssociator") << "outer track state (rho, z, phi):" << track.outerPosition().Rho() << ", "
1062  << track.outerPosition().z() << ", " << track.outerPosition().phi() << "\n";
1063  LogTrace("TrackAssociator") << "outerFreeState (rho, z, phi):" << outerState.position().perp() << ", "
1064  << outerState.position().z() << ", " << outerState.position().phi() << "\n";
1065 
1066  // InsideOut first
1067  if (crossedIP(track)) {
1068  switch (direction) {
1069  case InsideOut:
1070  case Any:
1071  return associate(iEvent, iSetup, parameters, &referenceState, &outerState);
1072  break;
1073  case OutsideIn: {
1074  cachedTrajectory_.setPropagationStep(-std::abs(currentStepSize));
1075  TrackDetMatchInfo result = associate(iEvent, iSetup, parameters, &innerState, &referenceState);
1076  cachedTrajectory_.setPropagationStep(currentStepSize);
1077  return result;
1078  break;
1079  }
1080  }
1081  } else {
1082  switch (direction) {
1083  case InsideOut:
1084  return associate(iEvent, iSetup, parameters, &innerState, &outerState);
1085  break;
1086  case OutsideIn: {
1087  cachedTrajectory_.setPropagationStep(-std::abs(currentStepSize));
1088  TrackDetMatchInfo result = associate(iEvent, iSetup, parameters, &outerState, &innerState);
1089  cachedTrajectory_.setPropagationStep(currentStepSize);
1090  return result;
1091  break;
1092  }
1093  case Any: {
1094  // check if we deal with clear outside-in case
1095  if (track.innerPosition().Dot(track.innerMomentum()) < 0 &&
1096  track.outerPosition().Dot(track.outerMomentum()) < 0) {
1097  cachedTrajectory_.setPropagationStep(-std::abs(currentStepSize));
1099  if (track.innerPosition().Mag2() < track.outerPosition().Mag2())
1100  result = associate(iEvent, iSetup, parameters, &innerState, &outerState);
1101  else
1102  result = associate(iEvent, iSetup, parameters, &outerState, &innerState);
1103  cachedTrajectory_.setPropagationStep(currentStepSize);
1104  return result;
1105  }
1106  }
1107  }
1108  }
1109 
1110  // all other cases
1111  return associate(iEvent, iSetup, parameters, &innerState, &outerState);
1112 }
T perp() const
Definition: PV3DBase.h:69
static bool crossedIP(const reco::Track &track)
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
T z() const
Definition: PV3DBase.h:61
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
float getPropagationStep() const
void setPropagationStep(float s=20.)
#define LogTrace(id)
GlobalPoint position() const
int iEvent
Definition: GenABIO.cc:224
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
TrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const AssociatorParameters &)
FreeTrajectoryState innerFreeState(const reco::Track &tk, const MagneticField *field, bool withErr=true)
FreeTrajectoryState outerFreeState(const reco::Track &tk, const MagneticField *field, bool withErr=true)
FreeTrajectoryState initialFreeState(const reco::Track &tk, const MagneticField *field, bool withErr=true)

◆ associate() [4/5]

TrackDetMatchInfo TrackDetectorAssociator::associate ( const edm::Event iEvent,
const edm::EventSetup iSetup,
const SimTrack track,
const SimVertex vertex,
const AssociatorParameters parameters 
)

associate using a simulated track

Definition at line 1114 of file TrackDetectorAssociator.cc.

References Calorimetry_cff::bField, edm::EventSetup::getData(), iEvent, HLT_2024v11_cff::track, and bphysicsOniaDQM_cfi::vertex.

1118  {
1119  auto const* bField = &iSetup.getData(parameters.bFieldToken);
1121 }
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
int iEvent
Definition: GenABIO.cc:224
static FreeTrajectoryState getFreeTrajectoryState(const MagneticField *, const reco::Track &)
get FreeTrajectoryState from different track representations
TrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const AssociatorParameters &)

◆ associate() [5/5]

TrackDetMatchInfo TrackDetectorAssociator::associate ( const edm::Event iEvent,
const edm::EventSetup iSetup,
const GlobalVector momentum,
const GlobalPoint vertex,
const int  charge,
const AssociatorParameters parameters 
)

associate using 3-momentum, vertex and charge

Definition at line 1123 of file TrackDetectorAssociator.cc.

References Calorimetry_cff::bField, reco::charge(), edm::EventSetup::getData(), iEvent, and bphysicsOniaDQM_cfi::vertex.

1128  {
1129  auto const* bField = &iSetup.getData(parameters.bFieldToken);
1130  return associate(iEvent, iSetup, getFreeTrajectoryState(bField, momentum, vertex, charge), parameters);
1131 }
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
int iEvent
Definition: GenABIO.cc:224
static FreeTrajectoryState getFreeTrajectoryState(const MagneticField *, const reco::Track &)
get FreeTrajectoryState from different track representations
TrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const AssociatorParameters &)

◆ crossedIP()

bool TrackDetectorAssociator::crossedIP ( const reco::Track track)
static

Definition at line 1133 of file TrackDetectorAssociator.cc.

References HLT_2024v11_cff::track.

Referenced by MuonIdProducer::produce().

1133  {
1134  bool crossed = true;
1135  crossed &= (track.innerPosition().rho() > 3); // something close to active volume
1136  crossed &= (track.outerPosition().rho() > 3); // something close to active volume
1137  crossed &=
1138  ((track.innerPosition().x() * track.innerMomentum().x() + track.innerPosition().y() * track.innerMomentum().y() <
1139  0) !=
1140  (track.outerPosition().x() * track.outerMomentum().x() + track.outerPosition().y() * track.outerMomentum().y() <
1141  0));
1142  return crossed;
1143 }

◆ fillCaloTowers()

void TrackDetectorAssociator::fillCaloTowers ( const edm::Event iEvent,
TrackDetMatchInfo info,
const AssociatorParameters parameters 
)
private

Definition at line 299 of file TrackDetectorAssociator.cc.

References eleHcalExtractorBlocks_cff::caloTowers, HLT_2024v11_cff::distance, iEvent, info(), CachedTrajectory::IpToHcal, LogTrace, and l1tHGCalTowerProducer_cfi::tower.

301  {
302  // use ECAL and HCAL trajectories to match a tower. (HO isn't used for matching).
303  std::vector<GlobalPoint> trajectory;
304  const std::vector<SteppingHelixStateInfo>& ecalTrajectoryStates = cachedTrajectory_.getEcalTrajectory();
305  const std::vector<SteppingHelixStateInfo>& hcalTrajectoryStates = cachedTrajectory_.getHcalTrajectory();
306  for (std::vector<SteppingHelixStateInfo>::const_iterator itr = ecalTrajectoryStates.begin();
307  itr != ecalTrajectoryStates.end();
308  itr++)
309  trajectory.push_back(itr->position());
310  for (std::vector<SteppingHelixStateInfo>::const_iterator itr = hcalTrajectoryStates.begin();
311  itr != hcalTrajectoryStates.end();
312  itr++)
313  trajectory.push_back(itr->position());
314 
315  if (trajectory.empty()) {
316  LogTrace("TrackAssociator") << "HCAL trajectory is empty; moving on\n";
317  info.isGoodCalo = false;
318  return;
319  }
320  info.isGoodCalo = true;
321 
322  // find crossed CaloTowers
324  iEvent.getByToken(parameters.caloTowersToken, caloTowers);
325  if (!caloTowers.isValid())
326  throw cms::Exception("FatalError") << "Unable to find CaloTowers in event!\n";
327 
328  std::set<DetId> caloTowerIdsInRegion;
329  if (parameters.accountForTrajectoryChangeCalo) {
330  // get trajectory change with respect to initial state
331  DetIdAssociator::MapRange mapRange =
333  caloTowerIdsInRegion = caloDetIdAssociator_->getDetIdsCloseToAPoint(trajectory[0], mapRange);
334  } else
335  caloTowerIdsInRegion = caloDetIdAssociator_->getDetIdsCloseToAPoint(trajectory[0], parameters.dRHcalPreselection);
336 
337  LogTrace("TrackAssociator") << "Towers in the region: " << caloTowerIdsInRegion.size();
338 
339  auto caloTowerIdsInAConeBegin = caloTowerIdsInRegion.begin();
340  auto caloTowerIdsInAConeEnd = caloTowerIdsInRegion.end();
341  std::set<DetId> caloTowerIdsInAConeTmp;
343  caloTowerIdsInAConeTmp =
344  caloDetIdAssociator_->getDetIdsInACone(caloTowerIdsInRegion, trajectory, parameters.dRHcal);
345  caloTowerIdsInAConeBegin = caloTowerIdsInAConeTmp.begin();
346  caloTowerIdsInAConeEnd = caloTowerIdsInAConeTmp.end();
347  }
348  LogTrace("TrackAssociator") << "Towers in the cone: "
349  << std::distance(caloTowerIdsInAConeBegin, caloTowerIdsInAConeEnd);
350 
351  info.crossedTowerIds = caloDetIdAssociator_->getCrossedDetIds(caloTowerIdsInRegion, trajectory);
352  const std::vector<DetId>& crossedCaloTowerIds = info.crossedTowerIds;
353  LogTrace("TrackAssociator") << "Towers crossed: " << crossedCaloTowerIds.size();
354 
355  // add CaloTowers
356  for (std::vector<DetId>::const_iterator itr = crossedCaloTowerIds.begin(); itr != crossedCaloTowerIds.end(); itr++) {
357  CaloTowerCollection::const_iterator tower = (*caloTowers).find(*itr);
358  if (tower != (*caloTowers).end())
359  info.crossedTowers.push_back(&*tower);
360  else
361  LogTrace("TrackAssociator") << "Crossed CaloTower is not found for DetId: " << (*itr).rawId();
362  }
363 
364  for (std::set<DetId>::const_iterator itr = caloTowerIdsInAConeBegin; itr != caloTowerIdsInAConeEnd; itr++) {
365  CaloTowerCollection::const_iterator tower = (*caloTowers).find(*itr);
366  if (tower != (*caloTowers).end())
367  info.towers.push_back(&*tower);
368  else
369  LogTrace("TrackAssociator") << "CaloTower from the cone is not found for DetId: " << (*itr).rawId();
370  }
371 }
virtual bool selectAllInACone(const double dR) const
helper to see if getDetIdsInACone is useful
static const TGPicture * info(bool iBackgroundIsBlack)
virtual std::vector< DetId > getCrossedDetIds(const std::set< DetId > &, const std::vector< GlobalPoint > &trajectory) const
std::vector< CaloTower >::const_iterator const_iterator
#define LogTrace(id)
int iEvent
Definition: GenABIO.cc:224
virtual std::set< DetId > getDetIdsCloseToAPoint(const GlobalPoint &, const int iN=0) const
const std::vector< SteppingHelixStateInfo > & getEcalTrajectory() const
std::pair< float, float > trajectoryDelta(TrajectorType)
const std::vector< SteppingHelixStateInfo > & getHcalTrajectory() const
virtual std::set< DetId > getDetIdsInACone(const std::set< DetId > &, const std::vector< GlobalPoint > &trajectory, const double dR) const
DetIdAssociator::MapRange getMapRange(const std::pair< float, float > &delta, const float dR)
const DetIdAssociator * caloDetIdAssociator_

◆ fillCaloTruth()

void TrackDetectorAssociator::fillCaloTruth ( const edm::Event iEvent,
TrackDetMatchInfo info,
const AssociatorParameters parameters 
)
private

Definition at line 965 of file TrackDetectorAssociator.cc.

References funct::abs(), electronAnalyzer_cfi::DeltaR, f, iEvent, info(), edm::HandleBase::isValid(), cscDigiValidation_cfi::simTrack, TrackCandidateProducer_cfi::simTracks, and HGCalValidator_cfi::simVertices.

967  {
968  // get list of simulated tracks and their vertices
969  using namespace edm;
971  iEvent.getByToken(parameters.simTracksToken, simTracks);
972  if (!simTracks.isValid())
973  throw cms::Exception("FatalError") << "No simulated tracks found\n";
974 
976  iEvent.getByToken(parameters.simVerticesToken, simVertices);
977  if (!simVertices.isValid())
978  throw cms::Exception("FatalError") << "No simulated vertices found\n";
979 
980  // get sim calo hits
981  Handle<PCaloHitContainer> simEcalHitsEB;
982  iEvent.getByToken(parameters.simEcalHitsEBToken, simEcalHitsEB);
983  if (!simEcalHitsEB.isValid())
984  throw cms::Exception("FatalError") << "No simulated ECAL EB hits found\n";
985 
986  Handle<PCaloHitContainer> simEcalHitsEE;
987  iEvent.getByToken(parameters.simEcalHitsEEToken, simEcalHitsEE);
988  if (!simEcalHitsEE.isValid())
989  throw cms::Exception("FatalError") << "No simulated ECAL EE hits found\n";
990 
991  Handle<PCaloHitContainer> simHcalHits;
992  iEvent.getByToken(parameters.simHcalHitsToken, simHcalHits);
993  if (!simHcalHits.isValid())
994  throw cms::Exception("FatalError") << "No simulated HCAL hits found\n";
995 
996  // find truth partner
997  SimTrackContainer::const_iterator simTrack = simTracks->begin();
998  for (; simTrack != simTracks->end(); ++simTrack) {
999  math::XYZVector simP3(simTrack->momentum().x(), simTrack->momentum().y(), simTrack->momentum().z());
1000  math::XYZVector recoP3(info.stateAtIP.momentum().x(), info.stateAtIP.momentum().y(), info.stateAtIP.momentum().z());
1001  if (ROOT::Math::VectorUtil::DeltaR(recoP3, simP3) < 0.1)
1002  break;
1003  }
1004  if (simTrack != simTracks->end()) {
1005  info.simTrack = &(*simTrack);
1006  float ecalTrueEnergy(0);
1007  float hcalTrueEnergy(0);
1008 
1009  // loop over calo hits
1010  for (PCaloHitContainer::const_iterator hit = simEcalHitsEB->begin(); hit != simEcalHitsEB->end(); ++hit)
1011  if (hit->geantTrackId() == info.simTrack->genpartIndex())
1012  ecalTrueEnergy += hit->energy();
1013 
1014  for (PCaloHitContainer::const_iterator hit = simEcalHitsEE->begin(); hit != simEcalHitsEE->end(); ++hit)
1015  if (hit->geantTrackId() == info.simTrack->genpartIndex())
1016  ecalTrueEnergy += hit->energy();
1017 
1018  for (PCaloHitContainer::const_iterator hit = simHcalHits->begin(); hit != simHcalHits->end(); ++hit)
1019  if (hit->geantTrackId() == info.simTrack->genpartIndex())
1020  hcalTrueEnergy += hit->energy();
1021 
1022  info.ecalTrueEnergy = ecalTrueEnergy;
1023  info.hcalTrueEnergy = hcalTrueEnergy;
1024  info.hcalTrueEnergyCorrected = hcalTrueEnergy;
1025  if (std::abs(info.trkGlobPosAtHcal.eta()) < 1.3f)
1026  info.hcalTrueEnergyCorrected = hcalTrueEnergy * 113.2f;
1027  else if (std::abs(info.trkGlobPosAtHcal.eta()) < 3.0f)
1028  info.hcalTrueEnergyCorrected = hcalTrueEnergy * 167.2f;
1029  }
1030 }
static const TGPicture * info(bool iBackgroundIsBlack)
int iEvent
Definition: GenABIO.cc:224
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
bool isValid() const
Definition: HandleBase.h:70
HLT enums.

◆ fillEcal()

void TrackDetectorAssociator::fillEcal ( const edm::Event iEvent,
TrackDetMatchInfo info,
const AssociatorParameters parameters 
)
private

Definition at line 225 of file TrackDetectorAssociator.cc.

References filterRecHits_cfi::EBRecHits, filterRecHits_cfi::EERecHits, iEvent, info(), CachedTrajectory::IpToEcal, and LogTrace.

227  {
228  const std::vector<SteppingHelixStateInfo>& trajectoryStates = cachedTrajectory_.getEcalTrajectory();
229 
230  for (std::vector<SteppingHelixStateInfo>::const_iterator itr = trajectoryStates.begin();
231  itr != trajectoryStates.end();
232  itr++)
233  LogTrace("TrackAssociator") << "ECAL trajectory point (rho, z, phi): " << itr->position().perp() << ", "
234  << itr->position().z() << ", " << itr->position().phi();
235 
236  std::vector<GlobalPoint> coreTrajectory;
237  for (std::vector<SteppingHelixStateInfo>::const_iterator itr = trajectoryStates.begin();
238  itr != trajectoryStates.end();
239  itr++)
240  coreTrajectory.push_back(itr->position());
241 
242  if (coreTrajectory.empty()) {
243  LogTrace("TrackAssociator") << "ECAL track trajectory is empty; moving on\n";
244  info.isGoodEcal = false;
245  return;
246  }
247  info.isGoodEcal = true;
248 
249  // Find ECAL crystals
251  iEvent.getByToken(parameters.EBRecHitsToken, EBRecHits);
252  if (!EBRecHits.isValid())
253  throw cms::Exception("FatalError") << "Unable to find EBRecHitCollection in the event!\n";
254 
256  iEvent.getByToken(parameters.EERecHitsToken, EERecHits);
257  if (!EERecHits.isValid())
258  throw cms::Exception("FatalError") << "Unable to find EERecHitCollection in event!\n";
259 
260  std::set<DetId> ecalIdsInRegion;
261  if (parameters.accountForTrajectoryChangeCalo) {
262  // get trajectory change with respect to initial state
263  DetIdAssociator::MapRange mapRange =
265  ecalIdsInRegion = ecalDetIdAssociator_->getDetIdsCloseToAPoint(coreTrajectory[0], mapRange);
266  } else
267  ecalIdsInRegion = ecalDetIdAssociator_->getDetIdsCloseToAPoint(coreTrajectory[0], parameters.dREcalPreselection);
268  LogTrace("TrackAssociator") << "ECAL hits in the region: " << ecalIdsInRegion.size();
269  if (parameters.dREcalPreselection > parameters.dREcal)
270  ecalIdsInRegion = ecalDetIdAssociator_->getDetIdsInACone(ecalIdsInRegion, coreTrajectory, parameters.dREcal);
271  LogTrace("TrackAssociator") << "ECAL hits in the cone: " << ecalIdsInRegion.size();
272  info.crossedEcalIds = ecalDetIdAssociator_->getCrossedDetIds(ecalIdsInRegion, coreTrajectory);
273  const std::vector<DetId>& crossedEcalIds = info.crossedEcalIds;
274  LogTrace("TrackAssociator") << "ECAL crossed hits " << crossedEcalIds.size();
275 
276  // add EcalRecHits
277  for (std::vector<DetId>::const_iterator itr = crossedEcalIds.begin(); itr != crossedEcalIds.end(); itr++) {
278  std::vector<EcalRecHit>::const_iterator ebHit = (*EBRecHits).find(*itr);
279  std::vector<EcalRecHit>::const_iterator eeHit = (*EERecHits).find(*itr);
280  if (ebHit != (*EBRecHits).end())
281  info.crossedEcalRecHits.push_back(&*ebHit);
282  else if (eeHit != (*EERecHits).end())
283  info.crossedEcalRecHits.push_back(&*eeHit);
284  else
285  LogTrace("TrackAssociator") << "Crossed EcalRecHit is not found for DetId: " << itr->rawId();
286  }
287  for (std::set<DetId>::const_iterator itr = ecalIdsInRegion.begin(); itr != ecalIdsInRegion.end(); itr++) {
288  std::vector<EcalRecHit>::const_iterator ebHit = (*EBRecHits).find(*itr);
289  std::vector<EcalRecHit>::const_iterator eeHit = (*EERecHits).find(*itr);
290  if (ebHit != (*EBRecHits).end())
291  info.ecalRecHits.push_back(&*ebHit);
292  else if (eeHit != (*EERecHits).end())
293  info.ecalRecHits.push_back(&*eeHit);
294  else
295  LogTrace("TrackAssociator") << "EcalRecHit from the cone is not found for DetId: " << itr->rawId();
296  }
297 }
static const TGPicture * info(bool iBackgroundIsBlack)
const DetIdAssociator * ecalDetIdAssociator_
virtual std::vector< DetId > getCrossedDetIds(const std::set< DetId > &, const std::vector< GlobalPoint > &trajectory) const
#define LogTrace(id)
int iEvent
Definition: GenABIO.cc:224
virtual std::set< DetId > getDetIdsCloseToAPoint(const GlobalPoint &, const int iN=0) const
const std::vector< SteppingHelixStateInfo > & getEcalTrajectory() const
std::pair< float, float > trajectoryDelta(TrajectorType)
virtual std::set< DetId > getDetIdsInACone(const std::set< DetId > &, const std::vector< GlobalPoint > &trajectory, const double dR) const
DetIdAssociator::MapRange getMapRange(const std::pair< float, float > &delta, const float dR)

◆ fillHcal()

void TrackDetectorAssociator::fillHcal ( const edm::Event iEvent,
TrackDetMatchInfo info,
const AssociatorParameters parameters 
)
private

Definition at line 396 of file TrackDetectorAssociator.cc.

References universalConfigTemplate::collection, HLT_2024v11_cff::distance, iEvent, DetIdInfo::info(), info(), CachedTrajectory::IpToHcal, and LogTrace.

398  {
399  const std::vector<SteppingHelixStateInfo>& trajectoryStates = cachedTrajectory_.getHcalTrajectory();
400 
401  std::vector<GlobalPoint> coreTrajectory;
402  for (std::vector<SteppingHelixStateInfo>::const_iterator itr = trajectoryStates.begin();
403  itr != trajectoryStates.end();
404  itr++)
405  coreTrajectory.push_back(itr->position());
406 
407  if (coreTrajectory.empty()) {
408  LogTrace("TrackAssociator") << "HCAL trajectory is empty; moving on\n";
409  info.isGoodHcal = false;
410  return;
411  }
412  info.isGoodHcal = true;
413 
414  // find crossed Hcals
416  iEvent.getByToken(parameters.HBHEcollToken, collection);
417  if (!collection.isValid())
418  throw cms::Exception("FatalError") << "Unable to find HBHERecHits in event!\n";
419 
420  std::set<DetId> idsInRegion;
421  if (parameters.accountForTrajectoryChangeCalo) {
422  // get trajectory change with respect to initial state
423  DetIdAssociator::MapRange mapRange =
425  idsInRegion = hcalDetIdAssociator_->getDetIdsCloseToAPoint(coreTrajectory[0], mapRange);
426  } else
427  idsInRegion = hcalDetIdAssociator_->getDetIdsCloseToAPoint(coreTrajectory[0], parameters.dRHcalPreselection);
428 
429  LogTrace("TrackAssociator") << "HCAL hits in the region: " << idsInRegion.size() << "\n"
430  << DetIdInfo::info(idsInRegion, nullptr);
431 
432  auto idsInAConeBegin = idsInRegion.begin();
433  auto idsInAConeEnd = idsInRegion.end();
434  std::set<DetId> idsInAConeTmp;
436  idsInAConeTmp = hcalDetIdAssociator_->getDetIdsInACone(idsInRegion, coreTrajectory, parameters.dRHcal);
437  idsInAConeBegin = idsInAConeTmp.begin();
438  idsInAConeEnd = idsInAConeTmp.end();
439  }
440  LogTrace("TrackAssociator") << "HCAL hits in the cone: " << std::distance(idsInAConeBegin, idsInAConeEnd) << "\n"
441  << DetIdInfo::info(std::set<DetId>(idsInAConeBegin, idsInAConeEnd), nullptr);
442  info.crossedHcalIds = hcalDetIdAssociator_->getCrossedDetIds(idsInRegion, coreTrajectory);
443  const std::vector<DetId>& crossedIds = info.crossedHcalIds;
444  LogTrace("TrackAssociator") << "HCAL hits crossed: " << crossedIds.size() << "\n"
445  << DetIdInfo::info(crossedIds, nullptr);
446 
447  // add Hcal
448  for (std::vector<DetId>::const_iterator itr = crossedIds.begin(); itr != crossedIds.end(); itr++) {
449  HBHERecHitCollection::const_iterator hit = (*collection).find(*itr);
450  if (hit != (*collection).end())
451  info.crossedHcalRecHits.push_back(&*hit);
452  else
453  LogTrace("TrackAssociator") << "Crossed HBHERecHit is not found for DetId: " << itr->rawId();
454  }
455  for (std::set<DetId>::const_iterator itr = idsInAConeBegin; itr != idsInAConeEnd; itr++) {
456  HBHERecHitCollection::const_iterator hit = (*collection).find(*itr);
457  if (hit != (*collection).end())
458  info.hcalRecHits.push_back(&*hit);
459  else
460  LogTrace("TrackAssociator") << "HBHERecHit from the cone is not found for DetId: " << itr->rawId();
461  }
462 }
virtual bool selectAllInACone(const double dR) const
helper to see if getDetIdsInACone is useful
static const TGPicture * info(bool iBackgroundIsBlack)
virtual std::vector< DetId > getCrossedDetIds(const std::set< DetId > &, const std::vector< GlobalPoint > &trajectory) const
std::vector< T >::const_iterator const_iterator
#define LogTrace(id)
const DetIdAssociator * hcalDetIdAssociator_
int iEvent
Definition: GenABIO.cc:224
virtual std::set< DetId > getDetIdsCloseToAPoint(const GlobalPoint &, const int iN=0) const
std::pair< float, float > trajectoryDelta(TrajectorType)
const std::vector< SteppingHelixStateInfo > & getHcalTrajectory() const
static std::string info(const DetId &, const TrackerTopology *tTopo)
Definition: DetIdInfo.cc:25
virtual std::set< DetId > getDetIdsInACone(const std::set< DetId > &, const std::vector< GlobalPoint > &trajectory, const double dR) const
DetIdAssociator::MapRange getMapRange(const std::pair< float, float > &delta, const float dR)

◆ fillHO()

void TrackDetectorAssociator::fillHO ( const edm::Event iEvent,
TrackDetMatchInfo info,
const AssociatorParameters parameters 
)
private

Definition at line 464 of file TrackDetectorAssociator.cc.

References universalConfigTemplate::collection, HLT_2024v11_cff::distance, iEvent, info(), CachedTrajectory::IpToHO, and LogTrace.

466  {
467  const std::vector<SteppingHelixStateInfo>& trajectoryStates = cachedTrajectory_.getHOTrajectory();
468 
469  std::vector<GlobalPoint> coreTrajectory;
470  for (std::vector<SteppingHelixStateInfo>::const_iterator itr = trajectoryStates.begin();
471  itr != trajectoryStates.end();
472  itr++)
473  coreTrajectory.push_back(itr->position());
474 
475  if (coreTrajectory.empty()) {
476  LogTrace("TrackAssociator") << "HO trajectory is empty; moving on\n";
477  info.isGoodHO = false;
478  return;
479  }
480  info.isGoodHO = true;
481 
482  // find crossed HOs
484  iEvent.getByToken(parameters.HOcollToken, collection);
485  if (!collection.isValid())
486  throw cms::Exception("FatalError") << "Unable to find HORecHits in event!\n";
487 
488  std::set<DetId> idsInRegion;
489  if (parameters.accountForTrajectoryChangeCalo) {
490  // get trajectory change with respect to initial state
491  DetIdAssociator::MapRange mapRange =
493  idsInRegion = hoDetIdAssociator_->getDetIdsCloseToAPoint(coreTrajectory[0], mapRange);
494  } else
495  idsInRegion = hoDetIdAssociator_->getDetIdsCloseToAPoint(coreTrajectory[0], parameters.dRHcalPreselection);
496 
497  LogTrace("TrackAssociator") << "idsInRegion.size(): " << idsInRegion.size();
498 
499  auto idsInAConeBegin = idsInRegion.begin();
500  auto idsInAConeEnd = idsInRegion.end();
501  std::set<DetId> idsInAConeTmp;
503  idsInAConeTmp = hoDetIdAssociator_->getDetIdsInACone(idsInRegion, coreTrajectory, parameters.dRHcal);
504  idsInAConeBegin = idsInAConeTmp.begin();
505  idsInAConeEnd = idsInAConeTmp.end();
506  }
507  LogTrace("TrackAssociator") << "idsInACone.size(): " << std::distance(idsInAConeBegin, idsInAConeEnd);
508  info.crossedHOIds = hoDetIdAssociator_->getCrossedDetIds(idsInRegion, coreTrajectory);
509  const std::vector<DetId>& crossedIds = info.crossedHOIds;
510 
511  // add HO
512  for (std::vector<DetId>::const_iterator itr = crossedIds.begin(); itr != crossedIds.end(); itr++) {
513  HORecHitCollection::const_iterator hit = (*collection).find(*itr);
514  if (hit != (*collection).end())
515  info.crossedHORecHits.push_back(&*hit);
516  else
517  LogTrace("TrackAssociator") << "Crossed HORecHit is not found for DetId: " << itr->rawId();
518  }
519 
520  for (std::set<DetId>::const_iterator itr = idsInAConeBegin; itr != idsInAConeEnd; itr++) {
521  HORecHitCollection::const_iterator hit = (*collection).find(*itr);
522  if (hit != (*collection).end())
523  info.hoRecHits.push_back(&*hit);
524  else
525  LogTrace("TrackAssociator") << "HORecHit from the cone is not found for DetId: " << itr->rawId();
526  }
527 }
virtual bool selectAllInACone(const double dR) const
helper to see if getDetIdsInACone is useful
static const TGPicture * info(bool iBackgroundIsBlack)
virtual std::vector< DetId > getCrossedDetIds(const std::set< DetId > &, const std::vector< GlobalPoint > &trajectory) const
std::vector< T >::const_iterator const_iterator
#define LogTrace(id)
int iEvent
Definition: GenABIO.cc:224
const DetIdAssociator * hoDetIdAssociator_
virtual std::set< DetId > getDetIdsCloseToAPoint(const GlobalPoint &, const int iN=0) const
std::pair< float, float > trajectoryDelta(TrajectorType)
virtual std::set< DetId > getDetIdsInACone(const std::set< DetId > &, const std::vector< GlobalPoint > &trajectory, const double dR) const
DetIdAssociator::MapRange getMapRange(const std::pair< float, float > &delta, const float dR)
const std::vector< SteppingHelixStateInfo > & getHOTrajectory() const

◆ fillMuon()

void TrackDetectorAssociator::fillMuon ( const edm::Event iEvent,
TrackDetMatchInfo info,
const AssociatorParameters parameters 
)
private

Definition at line 721 of file TrackDetectorAssociator.cc.

References relativeConstraints::chamber, cscRecHitPSet::cscSegment, dtChamberEfficiency_cfi::cscSegments, muonGEMRecHitPSet::gemRecHit, me0TriggerPseudoDigis_cff::gemRecHits, iEvent, info(), edm::HandleBase::isValid(), LogTrace, simTrackMatching_cfi::me0RecHit, me0RecHits_cfi::me0RecHits, me0Segments_cfi::me0Segments, FastTimerService_cff::range, and dtTriggerPhase2PrimitiveDigis_cfi::rpcRecHits.

723  {
724  // Get the segments from the event
726  iEvent.getByToken(parameters.dtSegmentsToken, dtSegments);
727  if (!dtSegments.isValid())
728  throw cms::Exception("FatalError") << "Unable to find DTRecSegment4DCollection in event!\n";
729 
731  iEvent.getByToken(parameters.cscSegmentsToken, cscSegments);
732  if (!cscSegments.isValid())
733  throw cms::Exception("FatalError") << "Unable to find CSCSegmentCollection in event!\n";
734 
736  if (parameters.useGEM)
737  iEvent.getByToken(parameters.gemSegmentsToken, gemSegments);
739  if (parameters.useME0)
740  iEvent.getByToken(parameters.me0SegmentsToken, me0Segments);
741 
742  // Get the hits from the event only if track preselection is activated
743  // Get the chambers segments/hits in the events
744  std::set<DetId> occupancy_set;
745  if (parameters.preselectMuonTracks) {
747  iEvent.getByToken(parameters.rpcHitsToken, rpcRecHits);
748  if (!rpcRecHits.isValid())
749  throw cms::Exception("FatalError") << "Unable to find RPCRecHitCollection in event!\n";
750 
752  if (parameters.useGEM)
753  iEvent.getByToken(parameters.gemHitsToken, gemRecHits);
754 
756  if (parameters.useME0)
757  iEvent.getByToken(parameters.me0HitsToken, me0RecHits);
758 
759  for (const auto& dtSegment : *dtSegments) {
760  occupancy_set.insert(dtSegment.geographicalId());
761  }
762  for (const auto& cscSegment : *cscSegments) {
763  occupancy_set.insert(cscSegment.geographicalId());
764  }
765  for (const auto& rpcRecHit : *rpcRecHits) {
766  occupancy_set.insert(rpcRecHit.geographicalId());
767  }
768  if (parameters.useGEM) {
769  for (const auto& gemSegment : *gemSegments) {
770  occupancy_set.insert(gemSegment.geographicalId());
771  }
772  for (const auto& gemRecHit : *gemRecHits) {
773  occupancy_set.insert(gemRecHit.geographicalId());
774  }
775  }
776  if (parameters.useME0) {
777  for (const auto& me0Segment : *me0Segments) {
778  occupancy_set.insert(me0Segment.geographicalId());
779  }
780  for (const auto& me0RecHit : *me0RecHits) {
781  occupancy_set.insert(me0RecHit.geographicalId());
782  }
783  }
784  if (occupancy_set.empty()) {
785  LogTrace("TrackAssociator") << "No segments or hits were found in the event: aborting track extrapolation"
786  << std::endl;
787  return;
788  }
789  }
790 
792 
793  // check the map of available segments
794  // if there is no segments in a given direction at all,
795  // then there is no point to fly there.
796  //
797  // MISSING
798  // Possible solution: quick search for presence of segments
799  // for the set of DetIds
800 
801  // get a set of matches corresponding to muon chambers
802  std::vector<TAMuonChamberMatch> matchedChambers;
803  LogTrace("TrackAssociator") << "Trying to Get ChamberMatches" << std::endl;
804  getTAMuonChamberMatches(matchedChambers, parameters, occupancy_set);
805  LogTrace("TrackAssociator") << "Chambers matched: " << matchedChambers.size() << "\n";
806 
807  // Iterate over all chamber matches and fill segment matching
808  // info if it's available
809  for (std::vector<TAMuonChamberMatch>::iterator matchedChamber = matchedChambers.begin();
810  matchedChamber != matchedChambers.end();
811  matchedChamber++) {
812  const GeomDet* geomDet = muonDetIdAssociator_->getGeomDet((*matchedChamber).id);
813  // DT chamber
814  if (const DTChamber* chamber = dynamic_cast<const DTChamber*>(geomDet)) {
815  // Get the range for the corresponding segments
816  DTRecSegment4DCollection::range range = dtSegments->get(chamber->id());
817  // Loop over the segments of this chamber
818  for (DTRecSegment4DCollection::const_iterator segment = range.first; segment != range.second; segment++) {
819  if (addTAMuonSegmentMatch(*matchedChamber, &(*segment), parameters)) {
820  matchedChamber->segments.back().dtSegmentRef = DTRecSegment4DRef(dtSegments, segment - dtSegments->begin());
821  }
822  }
823  }
824  // CSC Chamber
825  else if (const CSCChamber* chamber = dynamic_cast<const CSCChamber*>(geomDet)) {
826  // Get the range for the corresponding segments
828  // Loop over the segments
829  for (CSCSegmentCollection::const_iterator segment = range.first; segment != range.second; segment++) {
830  if (addTAMuonSegmentMatch(*matchedChamber, &(*segment), parameters)) {
831  matchedChamber->segments.back().cscSegmentRef = CSCSegmentRef(cscSegments, segment - cscSegments->begin());
832  }
833  }
834  } else {
835  // GEM Chamber
836  if (parameters.useGEM) {
837  if (const GEMSuperChamber* chamber = dynamic_cast<const GEMSuperChamber*>(geomDet)) {
838  // Get the range for the corresponding segments
839  GEMSegmentCollection::range range = gemSegments->get(chamber->id());
840  // Loop over the segments
841  for (GEMSegmentCollection::const_iterator segment = range.first; segment != range.second; segment++) {
842  if (addTAMuonSegmentMatch(*matchedChamber, &(*segment), parameters)) {
843  matchedChamber->segments.back().gemSegmentRef =
844  GEMSegmentRef(gemSegments, segment - gemSegments->begin());
845  }
846  }
847  }
848  }
849  // ME0 Chamber
850  if (parameters.useME0) {
851  if (const ME0Chamber* chamber = dynamic_cast<const ME0Chamber*>(geomDet)) {
852  // Get the range for the corresponding segments
854  // Loop over the segments
855  for (ME0SegmentCollection::const_iterator segment = range.first; segment != range.second; segment++) {
856  if (addTAMuonSegmentMatch(*matchedChamber, &(*segment), parameters)) {
857  matchedChamber->segments.back().me0SegmentRef =
858  ME0SegmentRef(me0Segments, segment - me0Segments->begin());
859  }
860  }
861  }
862  }
863  }
864  info.chambers.push_back(*matchedChamber);
865  }
866 }
static const TGPicture * info(bool iBackgroundIsBlack)
std::pair< const_iterator, const_iterator > range
iterator range
Definition: RangeMap.h:50
edm::Ref< CSCSegmentCollection > CSCSegmentRef
edm::Ref< ME0SegmentCollection > ME0SegmentRef
bool addTAMuonSegmentMatch(TAMuonChamberMatch &, const RecSegment *, const AssociatorParameters &)
#define LogTrace(id)
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
int iEvent
Definition: GenABIO.cc:224
const DetIdAssociator * muonDetIdAssociator_
edm::Ref< GEMSegmentCollection > GEMSegmentRef
void getTAMuonChamberMatches(std::vector< TAMuonChamberMatch > &matches, const AssociatorParameters &parameters, std::set< DetId > occupancy)
virtual const GeomDet * getGeomDet(const DetId &) const =0
edm::Ref< DTRecSegment4DCollection > DTRecSegment4DRef
bool isValid() const
Definition: HandleBase.h:70

◆ fillPreshower()

void TrackDetectorAssociator::fillPreshower ( const edm::Event iEvent,
TrackDetMatchInfo info,
const AssociatorParameters parameters 
)
private

Definition at line 373 of file TrackDetectorAssociator.cc.

References info(), and LogTrace.

375  {
376  std::vector<GlobalPoint> trajectory;
377  const std::vector<SteppingHelixStateInfo>& trajectoryStates = cachedTrajectory_.getPreshowerTrajectory();
378  for (std::vector<SteppingHelixStateInfo>::const_iterator itr = trajectoryStates.begin();
379  itr != trajectoryStates.end();
380  itr++)
381  trajectory.push_back(itr->position());
382 
383  if (trajectory.empty()) {
384  LogTrace("TrackAssociator") << "Preshower trajectory is empty; moving on\n";
385  return;
386  }
387 
388  std::set<DetId> idsInRegion =
389  preshowerDetIdAssociator_->getDetIdsCloseToAPoint(trajectory[0], parameters.dRPreshowerPreselection);
390 
391  LogTrace("TrackAssociator") << "Number of Preshower Ids in the region: " << idsInRegion.size();
392  info.crossedPreshowerIds = preshowerDetIdAssociator_->getCrossedDetIds(idsInRegion, trajectory);
393  LogTrace("TrackAssociator") << "Number of Preshower Ids in crossed: " << info.crossedPreshowerIds.size();
394 }
static const TGPicture * info(bool iBackgroundIsBlack)
virtual std::vector< DetId > getCrossedDetIds(const std::set< DetId > &, const std::vector< GlobalPoint > &trajectory) const
#define LogTrace(id)
virtual std::set< DetId > getDetIdsCloseToAPoint(const GlobalPoint &, const int iN=0) const
const std::vector< SteppingHelixStateInfo > & getPreshowerTrajectory() const
const DetIdAssociator * preshowerDetIdAssociator_

◆ getCachedTrajector()

const CachedTrajectory& TrackDetectorAssociator::getCachedTrajector ( ) const
inline

trajector information

Definition at line 93 of file TrackDetectorAssociator.h.

References cachedTrajectory_.

93 { return cachedTrajectory_; }

◆ getFreeTrajectoryState() [1/3]

FreeTrajectoryState TrackDetectorAssociator::getFreeTrajectoryState ( const MagneticField bField,
const reco::Track track 
)
static

get FreeTrajectoryState from different track representations

Definition at line 557 of file TrackDetectorAssociator.cc.

References Calorimetry_cff::bField, MillePedeFileConverter_cfg::e, l1ctLayer2EG_cff::id, point, HLT_2024v11_cff::track, and trackerHitRTTI::vector.

Referenced by EopTreeWriter::analyze(), ValidIsoTrkCalib::analyze(), cms::MuonMETValueMapProducer::determine_deltax_deltay(), and InterestingTrackEcalDetIdProducer::produce().

558  {
559  GlobalVector vector(track.momentum().x(), track.momentum().y(), track.momentum().z());
560 
561  GlobalPoint point(track.vertex().x(), track.vertex().y(), track.vertex().z());
562 
564 
565  // FIX THIS !!!
566  // need to convert from perigee to global or helix (curvilinear) frame
567  // for now just an arbitrary matrix.
568  ROOT::Math::SMatrixIdentity id;
569  AlgebraicSymMatrix66 covT(id);
570  covT *= 1e-6; // initialize to sigma=1e-3
571  CartesianTrajectoryError tCov(covT);
572 
573  return FreeTrajectoryState(tPars, tCov);
574 }
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepSym< double, 6 > > AlgebraicSymMatrix66
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5

◆ getFreeTrajectoryState() [2/3]

FreeTrajectoryState TrackDetectorAssociator::getFreeTrajectoryState ( const MagneticField bField,
const SimTrack track,
const SimVertex vertex 
)
static

Definition at line 529 of file TrackDetectorAssociator.cc.

References funct::abs(), Calorimetry_cff::bField, reco::charge(), point, HLT_2024v11_cff::track, trackerHitRTTI::vector, and bphysicsOniaDQM_cfi::vertex.

531  {
532  GlobalVector vector(track.momentum().x(), track.momentum().y(), track.momentum().z());
533  GlobalPoint point(vertex.position().x(), vertex.position().y(), vertex.position().z());
534 
535  int charge = track.type() > 0 ? -1 : 1; // lepton convention
536  if (abs(track.type()) == 211 || // pion
537  abs(track.type()) == 321 || // kaon
538  abs(track.type()) == 2212)
539  charge = track.type() < 0 ? -1 : 1;
541 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static FreeTrajectoryState getFreeTrajectoryState(const MagneticField *, const reco::Track &)
get FreeTrajectoryState from different track representations
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5

◆ getFreeTrajectoryState() [3/3]

FreeTrajectoryState TrackDetectorAssociator::getFreeTrajectoryState ( const MagneticField bField,
const GlobalVector momentum,
const GlobalPoint vertex,
const int  charge 
)
static

Definition at line 543 of file TrackDetectorAssociator.cc.

References Calorimetry_cff::bField, reco::charge(), MillePedeFileConverter_cfg::e, l1ctLayer2EG_cff::id, and bphysicsOniaDQM_cfi::vertex.

546  {
547  GlobalTrajectoryParameters tPars(vertex, momentum, charge, bField);
548 
549  ROOT::Math::SMatrixIdentity id;
550  AlgebraicSymMatrix66 covT(id);
551  covT *= 1e-6; // initialize to sigma=1e-3
552  CartesianTrajectoryError tCov(covT);
553 
554  return FreeTrajectoryState(tPars, tCov);
555 }
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepSym< double, 6 > > AlgebraicSymMatrix66

◆ getMapRange()

DetIdAssociator::MapRange TrackDetectorAssociator::getMapRange ( const std::pair< float, float > &  delta,
const float  dR 
)
private

Definition at line 576 of file TrackDetectorAssociator.cc.

References funct::abs(), dumpMFGeometry_cfg::delta, DetIdAssociator::MapRange::dPhiMinus, DetIdAssociator::MapRange::dPhiPlus, HGC3DClusterGenMatchSelector_cfi::dR, DetIdAssociator::MapRange::dThetaMinus, DetIdAssociator::MapRange::dThetaPlus, and LogTrace.

576  {
577  DetIdAssociator::MapRange mapRange;
578  mapRange.dThetaPlus = dR;
579  mapRange.dThetaMinus = dR;
580  mapRange.dPhiPlus = dR;
581  mapRange.dPhiMinus = dR;
582  if (delta.first > 0)
583  mapRange.dThetaPlus += delta.first;
584  else
585  mapRange.dThetaMinus += std::abs(delta.first);
586  if (delta.second > 0)
587  mapRange.dPhiPlus += delta.second;
588  else
589  mapRange.dPhiMinus += std::abs(delta.second);
590  LogTrace("TrackAssociator") << "Selection range: (dThetaPlus, dThetaMinus, dPhiPlus, dPhiMinus, dRPreselection): "
591  << mapRange.dThetaPlus << ", " << mapRange.dThetaMinus << ", " << mapRange.dPhiPlus
592  << ", " << mapRange.dPhiMinus << ", " << dR;
593  return mapRange;
594 }
#define LogTrace(id)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

◆ getPoint() [1/2]

math::XYZPoint TrackDetectorAssociator::getPoint ( const GlobalPoint point)
inlineprivate

Definition at line 136 of file TrackDetectorAssociator.h.

References point.

136  {
137  return math::XYZPoint(point.x(), point.y(), point.z());
138  }
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5

◆ getPoint() [2/2]

math::XYZPoint TrackDetectorAssociator::getPoint ( const LocalPoint point)
inlineprivate

Definition at line 140 of file TrackDetectorAssociator.h.

References point.

140  {
141  return math::XYZPoint(point.x(), point.y(), point.z());
142  }
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5

◆ getTAMuonChamberMatches()

void TrackDetectorAssociator::getTAMuonChamberMatches ( std::vector< TAMuonChamberMatch > &  matches,
const AssociatorParameters parameters,
std::set< DetId occupancy 
)
private

Definition at line 596 of file TrackDetectorAssociator.cc.

References funct::abs(), Surface::bounds(), hcalRecHitTable_cff::detId, f, TrajectoryStateOnSurface::freeState(), CachedTrajectory::FullTrajectory, DetIdInfo::info(), TrajectoryStateOnSurface::isValid(), SteppingHelixStateInfo::isValid(), Bounds::length(), CSCWireTopology::lengthOfPlane(), TrajectoryStateOnSurface::localError(), LogTrace, oniaPATMuonsWithTrigger_cff::matches, SteppingHelixStateInfo::momentum(), CSCWireTopology::narrowWidthOfPlane(), CSCChamberSpecs::oddLayerGeometry(), SteppingHelixStateInfo::position(), FreeTrajectoryState::position(), LocalTrajectoryError::positionError(), DBoxMetadataHelper::set_intersection(), mathSSE::sqrt(), GeomDet::surface(), GloballyPositioned< T >::toLocal(), Vector3DBase< T, FrameTag >::unit(), CSCWireTopology::wideWidthOfPlane(), Bounds::width(), TrapezoidalPlaneBounds::width(), CSCWireTopology::wireAngle(), CSCLayerGeometry::wireTopology(), PV3DBase< T, PVType, FrameType >::x(), LocalError::xx(), PV3DBase< T, PVType, FrameType >::y(), CSCWireTopology::yOfWire(), and LocalError::yy().

598  {
599  // Strategy:
600  // Propagate through the whole detector, estimate change in eta and phi
601  // along the trajectory, add this to dRMuon and find DetIds around this
602  // direction using the map. Then propagate fast to each surface and apply
603  // final matching criteria.
604 
605  // get the direction first
607  // If trajectory point at HCAL is not valid, try to use the outer most state of the
608  // trajectory instead.
609  if (!trajectoryPoint.isValid())
610  trajectoryPoint = cachedTrajectory_.getOuterState();
611  if (!trajectoryPoint.isValid()) {
612  LogTrace("TrackAssociator")
613  << "trajectory position at HCAL is not valid. Assume the track cannot reach muon detectors and skip it";
614  return;
615  }
616 
617  GlobalVector direction = trajectoryPoint.momentum().unit();
618  LogTrace("TrackAssociator") << "muon direction: " << direction
619  << "\n\t and corresponding point: " << trajectoryPoint.position() << "\n";
620 
621  DetIdAssociator::MapRange mapRange =
623 
624  // and find chamber DetIds
625 
626  std::set<DetId> muonIdsInRegion = muonDetIdAssociator_->getDetIdsCloseToAPoint(trajectoryPoint.position(), mapRange);
627  LogTrace("TrackAssociator") << "Number of chambers to check: " << muonIdsInRegion.size();
628 
629  if (parameters.preselectMuonTracks) {
630  std::set<DetId> muonIdsInRegionOccupied;
631  std::set_intersection(muonIdsInRegion.begin(),
632  muonIdsInRegion.end(),
633  occupancy.begin(),
634  occupancy.end(),
635  std::inserter(muonIdsInRegionOccupied, muonIdsInRegionOccupied.begin()));
636  if (muonIdsInRegionOccupied.empty())
637  return;
638  }
639 
640  for (std::set<DetId>::const_iterator detId = muonIdsInRegion.begin(); detId != muonIdsInRegion.end(); detId++) {
641  const GeomDet* geomDet = muonDetIdAssociator_->getGeomDet(*detId);
642  TrajectoryStateOnSurface stateOnSurface = cachedTrajectory_.propagate(&geomDet->surface());
643  if (!stateOnSurface.isValid()) {
644  LogTrace("TrackAssociator") << "Failed to propagate the track; moving on\n\t"
645  << "Element is not crosssed: " << DetIdInfo::info(*detId, nullptr) << "\n";
646  continue;
647  }
648  LocalPoint localPoint = geomDet->surface().toLocal(stateOnSurface.freeState()->position());
649  LocalError localError = stateOnSurface.localError().positionError();
650  float distanceX = 0.f;
651  float distanceY = 0.f;
652  if (const CSCChamber* cscChamber = dynamic_cast<const CSCChamber*>(geomDet)) {
653  const CSCChamberSpecs* chamberSpecs = cscChamber->specs();
654  if (!chamberSpecs) {
655  LogTrace("TrackAssociator") << "Failed to get CSCChamberSpecs from CSCChamber; moving on\n";
656  continue;
657  }
658  const CSCLayerGeometry* layerGeometry = chamberSpecs->oddLayerGeometry(1);
659  if (!layerGeometry) {
660  LogTrace("TrackAssociator") << "Failed to get CSCLayerGeometry from CSCChamberSpecs; moving on\n";
661  continue;
662  }
663  const CSCWireTopology* wireTopology = layerGeometry->wireTopology();
664  if (!wireTopology) {
665  LogTrace("TrackAssociator") << "Failed to get CSCWireTopology from CSCLayerGeometry; moving on\n";
666  continue;
667  }
668 
669  float wideWidth = wireTopology->wideWidthOfPlane();
670  float narrowWidth = wireTopology->narrowWidthOfPlane();
671  float length = wireTopology->lengthOfPlane();
672  // If slanted, there is no y offset between local origin and symmetry center of wire plane
673  float yOfFirstWire = std::abs(wireTopology->wireAngle()) > 1.E-06f ? -0.5 * length : wireTopology->yOfWire(1);
674  // y offset between local origin and symmetry center of wire plane
675  float yCOWPOffset = yOfFirstWire + 0.5f * length;
676 
677  // tangent of the incline angle from inside the trapezoid
678  float tangent = (wideWidth - narrowWidth) / (2.f * length);
679  // y position wrt bottom of trapezoid
680  float yPrime = localPoint.y() + std::abs(yOfFirstWire);
681  // half trapezoid width at y' is 0.5 * narrowWidth + x side of triangle with the above tangent and side y'
682  float halfWidthAtYPrime = 0.5f * narrowWidth + yPrime * tangent;
683  distanceX = std::abs(localPoint.x()) - halfWidthAtYPrime;
684  distanceY = std::abs(localPoint.y() - yCOWPOffset) - 0.5f * length;
685  } else if (dynamic_cast<const GEMChamber*>(geomDet) || dynamic_cast<const GEMSuperChamber*>(geomDet)) {
686  const TrapezoidalPlaneBounds* bounds = dynamic_cast<const TrapezoidalPlaneBounds*>(&geomDet->surface().bounds());
687 
688  float wideWidth = bounds->width();
689  float narrowWidth = 2.f * bounds->widthAtHalfLength() - wideWidth;
690  float length = bounds->length();
691  float tangent = (wideWidth - narrowWidth) / (2.f * length);
692  float halfWidthAtY = tangent * localPoint.y() + 0.25f * (narrowWidth + wideWidth);
693 
694  distanceX = std::abs(localPoint.x()) - halfWidthAtY;
695  distanceY = std::abs(localPoint.y()) - 0.5f * length;
696  } else {
697  distanceX = std::abs(localPoint.x()) - 0.5f * geomDet->surface().bounds().width();
698  distanceY = std::abs(localPoint.y()) - 0.5f * geomDet->surface().bounds().length();
699  }
700  if ((distanceX < parameters.muonMaxDistanceX && distanceY < parameters.muonMaxDistanceY) ||
701  (distanceX * distanceX <
702  localError.xx() * parameters.muonMaxDistanceSigmaX * parameters.muonMaxDistanceSigmaX &&
703  distanceY * distanceY <
704  localError.yy() * parameters.muonMaxDistanceSigmaY * parameters.muonMaxDistanceSigmaY)) {
705  LogTrace("TrackAssociator") << "found a match: " << DetIdInfo::info(*detId, nullptr) << "\n";
707  match.tState = stateOnSurface;
708  match.localDistanceX = distanceX;
709  match.localDistanceY = distanceY;
710  match.id = *detId;
711  matches.push_back(match);
712  } else {
713  LogTrace("TrackAssociator") << "chamber is too far: " << DetIdInfo::info(*detId, nullptr)
714  << "\n\tdistanceX: " << distanceX << "\t distanceY: " << distanceY
715  << "\t sigmaX: " << distanceX / sqrt(localError.xx())
716  << "\t sigmaY: " << distanceY / sqrt(localError.yy()) << "\n";
717  }
718  }
719 }
virtual float length() const =0
double wideWidthOfPlane() const
const LocalTrajectoryError & localError() const
float width() const override
const CSCWireTopology * wireTopology() const
LocalError positionError() const
LocalPoint toLocal(const GlobalPoint &gp) const
#define LogTrace(id)
GlobalPoint position() const
GlobalPoint position() const
float yy() const
Definition: LocalError.h:24
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
float wireAngle() const override
const DetIdAssociator * muonDetIdAssociator_
T sqrt(T t)
Definition: SSEVec.h:19
virtual std::set< DetId > getDetIdsCloseToAPoint(const GlobalPoint &, const int iN=0) const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
std::pair< float, float > trajectoryDelta(TrajectorType)
virtual const GeomDet * getGeomDet(const DetId &) const =0
SteppingHelixStateInfo getOuterState()
float yOfWire(float wire, float x=0.) const
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
void propagate(SteppingHelixStateInfo &state, const Plane &plane)
const CSCLayerGeometry * oddLayerGeometry(int iendcap) const
Accessors for LayerGeometry&#39;s.
static std::string info(const DetId &, const TrackerTopology *tTopo)
Definition: DetIdInfo.cc:25
double lengthOfPlane() const
DetIdAssociator::MapRange getMapRange(const std::pair< float, float > &delta, const float dR)
double narrowWidthOfPlane() const
GlobalVector momentum() const
FreeTrajectoryState const * freeState(bool withErrors=true) const
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
Vector3DBase unit() const
Definition: Vector3DBase.h:54
virtual float width() const =0
SteppingHelixStateInfo getStateAtHcal()
float xx() const
Definition: LocalError.h:22
std::vector< std::string > set_intersection(std::vector< std::string > const &v1, std::vector< std::string > const &v2)
const Bounds & bounds() const
Definition: Surface.h:87

◆ getVector() [1/2]

math::XYZVector TrackDetectorAssociator::getVector ( const GlobalVector vec)
inlineprivate

Definition at line 144 of file TrackDetectorAssociator.h.

144 { return math::XYZVector(vec.x(), vec.y(), vec.z()); }
T z() const
Definition: PV3DBase.h:61
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31

◆ getVector() [2/2]

math::XYZVector TrackDetectorAssociator::getVector ( const LocalVector vec)
inlineprivate

Definition at line 146 of file TrackDetectorAssociator.h.

146 { return math::XYZVector(vec.x(), vec.y(), vec.z()); }
T z() const
Definition: PV3DBase.h:61
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31

◆ init()

void TrackDetectorAssociator::init ( const edm::EventSetup iSetup,
const AssociatorParameters parameters 
)
private

Definition at line 87 of file TrackDetectorAssociator.cc.

References anyDirection, Calorimetry_cff::bField, edm::EventSetup::getData(), and eostools::move().

87  {
88  // access the calorimeter geometry
89  theCaloGeometry_ = &iSetup.getData(parameters.theCaloGeometryToken);
90 
91  // get the tracking Geometry
92  theTrackingGeometry_ = &iSetup.getData(parameters.theTrackingGeometryToken);
93 
95  // setup propagator
96  const MagneticField* bField = &iSetup.getData(parameters.bFieldToken);
97 
98  auto prop = std::make_unique<SteppingHelixPropagator>(bField, anyDirection);
99  prop->setMaterialMode(false);
100  prop->applyRadX0Correction(true);
101  // prop->setDebug(true); // tmp
102  defProp_ = std::move(prop);
103  setPropagator(defProp_.get());
104  }
105 
106  ecalDetIdAssociator_ = &iSetup.getData(parameters.ecalDetIdAssociatorToken);
107  hcalDetIdAssociator_ = &iSetup.getData(parameters.hcalDetIdAssociatorToken);
108  hoDetIdAssociator_ = &iSetup.getData(parameters.hoDetIdAssociatorToken);
109  caloDetIdAssociator_ = &iSetup.getData(parameters.caloDetIdAssociatorToken);
110  muonDetIdAssociator_ = &iSetup.getData(parameters.muonDetIdAssociatorToken);
111  preshowerDetIdAssociator_ = &iSetup.getData(parameters.preshowerDetIdAssociatorToken);
112 }
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
const DetIdAssociator * ecalDetIdAssociator_
std::unique_ptr< Propagator > defProp_
const DetIdAssociator * hcalDetIdAssociator_
const DetIdAssociator * hoDetIdAssociator_
void setPropagator(const Propagator *)
use a user configured propagator
const DetIdAssociator * muonDetIdAssociator_
edm::ESWatcher< IdealMagneticFieldRecord > theMagneticFieldWatcher_
const GlobalTrackingGeometry * theTrackingGeometry_
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
const DetIdAssociator * preshowerDetIdAssociator_
const DetIdAssociator * caloDetIdAssociator_
const CaloGeometry * theCaloGeometry_
def move(src, dest)
Definition: eostools.py:511

◆ setPropagator()

void TrackDetectorAssociator::setPropagator ( const Propagator ptr)

use a user configured propagator

Definition at line 80 of file TrackDetectorAssociator.cc.

Referenced by muonisolation::CaloExtractorByAssociator::deposits(), and MuonIdProducer::init().

80  {
81  ivProp_ = ptr;
83 }
void setPropagator(const Propagator *ptr)

◆ useDefaultPropagator()

void TrackDetectorAssociator::useDefaultPropagator ( )

Member Data Documentation

◆ cachedTrajectory_

CachedTrajectory TrackDetectorAssociator::cachedTrajectory_
private

Definition at line 150 of file TrackDetectorAssociator.h.

Referenced by getCachedTrajector().

◆ caloDetIdAssociator_

const DetIdAssociator* TrackDetectorAssociator::caloDetIdAssociator_
private

Definition at line 156 of file TrackDetectorAssociator.h.

◆ defProp_

std::unique_ptr<Propagator> TrackDetectorAssociator::defProp_
private

Definition at line 149 of file TrackDetectorAssociator.h.

◆ ecalDetIdAssociator_

const DetIdAssociator* TrackDetectorAssociator::ecalDetIdAssociator_
private

Definition at line 153 of file TrackDetectorAssociator.h.

◆ hcalDetIdAssociator_

const DetIdAssociator* TrackDetectorAssociator::hcalDetIdAssociator_
private

Definition at line 154 of file TrackDetectorAssociator.h.

◆ hoDetIdAssociator_

const DetIdAssociator* TrackDetectorAssociator::hoDetIdAssociator_
private

Definition at line 155 of file TrackDetectorAssociator.h.

◆ ivProp_

const Propagator* TrackDetectorAssociator::ivProp_
private

Definition at line 148 of file TrackDetectorAssociator.h.

◆ muonDetIdAssociator_

const DetIdAssociator* TrackDetectorAssociator::muonDetIdAssociator_
private

Definition at line 157 of file TrackDetectorAssociator.h.

◆ preshowerDetIdAssociator_

const DetIdAssociator* TrackDetectorAssociator::preshowerDetIdAssociator_
private

Definition at line 158 of file TrackDetectorAssociator.h.

◆ theCaloGeometry_

const CaloGeometry* TrackDetectorAssociator::theCaloGeometry_
private

Definition at line 160 of file TrackDetectorAssociator.h.

◆ theMagneticFieldWatcher_

edm::ESWatcher<IdealMagneticFieldRecord> TrackDetectorAssociator::theMagneticFieldWatcher_
private

Definition at line 163 of file TrackDetectorAssociator.h.

◆ theTrackingGeometry_

const GlobalTrackingGeometry* TrackDetectorAssociator::theTrackingGeometry_
private

Definition at line 161 of file TrackDetectorAssociator.h.

◆ useDefaultPropagator_

bool TrackDetectorAssociator::useDefaultPropagator_
private

Definition at line 151 of file TrackDetectorAssociator.h.