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)
 
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 70 of file TrackDetectorAssociator.cc.

70  {
71  ivProp_ = nullptr;
72  useDefaultPropagator_ = false;
73 }

◆ ~TrackDetectorAssociator()

TrackDetectorAssociator::~TrackDetectorAssociator ( )
default

Member Function Documentation

◆ addTAMuonSegmentMatch()

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

Definition at line 803 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().

805  {
806  LogTrace("TrackAssociator") << "Segment local position: " << segment->localPosition() << "\n"
807  << std::hex << segment->geographicalId().rawId() << "\n";
808 
809  const GeomDet* chamber = muonDetIdAssociator_->getGeomDet(matchedChamber.id);
810  TrajectoryStateOnSurface trajectoryStateOnSurface = matchedChamber.tState;
811  GlobalPoint segmentGlobalPosition = chamber->toGlobal(segment->localPosition());
812 
813  LogTrace("TrackAssociator") << "Segment global position: " << segmentGlobalPosition
814  << " \t (R_xy,eta,phi): " << segmentGlobalPosition.perp() << ","
815  << segmentGlobalPosition.eta() << "," << segmentGlobalPosition.phi() << "\n";
816 
817  LogTrace("TrackAssociator") << "\teta hit: " << segmentGlobalPosition.eta()
818  << " \tpropagator: " << trajectoryStateOnSurface.freeState()->position().eta() << "\n"
819  << "\tphi hit: " << segmentGlobalPosition.phi()
820  << " \tpropagator: " << trajectoryStateOnSurface.freeState()->position().phi()
821  << std::endl;
822 
823  bool isGood = false;
824  bool isDTWithoutY = false;
825  const DTRecSegment4D* dtseg = dynamic_cast<const DTRecSegment4D*>(segment);
826  if (dtseg && (!dtseg->hasZed()))
827  isDTWithoutY = true;
828 
829  float deltaPhi(std::abs(segmentGlobalPosition.phi() - trajectoryStateOnSurface.freeState()->position().phi()));
830  if (deltaPhi > float(M_PI))
831  deltaPhi = std::abs(deltaPhi - float(M_PI) * 2.f);
832  float deltaEta = std::abs(segmentGlobalPosition.eta() - trajectoryStateOnSurface.freeState()->position().eta());
833 
834  if (isDTWithoutY) {
835  isGood = deltaPhi < parameters.dRMuon;
836  // Be in chamber
837  isGood &= deltaEta < .3f;
838  } else
839  isGood = deltaEta * deltaEta + deltaPhi * deltaPhi < parameters.dRMuon * parameters.dRMuon;
840 
841  if (isGood) {
842  TAMuonSegmentMatch muonSegment;
843  muonSegment.segmentGlobalPosition = getPoint(segmentGlobalPosition);
844  muonSegment.segmentLocalPosition = getPoint(segment->localPosition());
845  muonSegment.segmentLocalDirection = getVector(segment->localDirection());
846  muonSegment.segmentLocalErrorXX = segment->localPositionError().xx();
847  muonSegment.segmentLocalErrorYY = segment->localPositionError().yy();
848  muonSegment.segmentLocalErrorXY = segment->localPositionError().xy();
849  muonSegment.segmentLocalErrorDxDz = segment->localDirectionError().xx();
850  muonSegment.segmentLocalErrorDyDz = segment->localDirectionError().yy();
851 
852  // DANGEROUS - compiler cannot guaranty parameters ordering
853  // AlgebraicSymMatrix segmentCovMatrix = segment->parametersError();
854  // muonSegment.segmentLocalErrorXDxDz = segmentCovMatrix[2][0];
855  // muonSegment.segmentLocalErrorYDyDz = segmentCovMatrix[3][1];
856  muonSegment.segmentLocalErrorXDxDz = -999.f;
857  muonSegment.segmentLocalErrorYDyDz = -999.f;
858  muonSegment.hasZed = true;
859  muonSegment.hasPhi = true;
860 
861  // timing information
862  muonSegment.t0 = 0.f;
863  if (dtseg) {
864  if ((dtseg->hasPhi()) && (!isDTWithoutY)) {
865  int phiHits = dtseg->phiSegment()->specificRecHits().size();
866  // int zHits = dtseg->zSegment()->specificRecHits().size();
867  int hits = 0;
868  double t0 = 0.;
869  // TODO: cuts on hit numbers not optimized in any way yet...
870  if (phiHits > 5 && dtseg->phiSegment()->ist0Valid()) {
871  t0 += dtseg->phiSegment()->t0() * phiHits;
872  hits += phiHits;
873  LogTrace("TrackAssociator") << " Phi t0: " << dtseg->phiSegment()->t0() << " hits: " << phiHits;
874  }
875  // the z segments seem to contain little useful information...
876  // if (zHits>3) {
877  // t0+=s->zSegment()->t0()*zHits;
878  // hits+=zHits;
879  // LogTrace("TrackAssociator") << " Z t0: " << s->zSegment()->t0() << " hits: " << zHits << std::endl;
880  // }
881  if (hits)
882  muonSegment.t0 = t0 / hits;
883  // LogTrace("TrackAssociator") << " --- t0: " << muonSegment.t0 << std::endl;
884  } else {
885  // check and set dimensionality
886  if (isDTWithoutY)
887  muonSegment.hasZed = false;
888  if (!dtseg->hasPhi())
889  muonSegment.hasPhi = false;
890  }
891  }
892  matchedChamber.segments.push_back(muonSegment);
893  }
894 
895  return isGood;
896 }
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 111 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().

114  {
115  return associate(iEvent, iSetup, parameters, &fts);
116 }
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 118 of file TrackDetectorAssociator.cc.

References funct::abs(), Exception, iEvent, info(), 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().

122  {
124  if (!parameters.useEcal && !parameters.useCalo && !parameters.useHcal && !parameters.useHO && !parameters.useMuon &&
125  !parameters.usePreshower)
126  throw cms::Exception("ConfigurationError")
127  << "Configuration error! No subdetector was selected for the track association.";
128 
129  SteppingHelixStateInfo trackOrigin(*innerState);
130  info.stateAtIP = *innerState;
131  cachedTrajectory_.setStateAtIP(trackOrigin);
132 
133  init(iSetup, parameters);
134  // get track trajectory
135  // ECAL points (EB+EE)
136  // If the phi angle between a track entrance and exit points is more
137  // than 2 crystals, it is possible that the track will cross 3 crystals
138  // and therefore one has to check at least 3 points along the track
139  // trajectory inside ECAL. In order to have a chance to cross 4 crystalls
140  // in the barrel, a track should have P_t as low as 3 GeV or smaller
141  // If it's necessary, number of points along trajectory can be increased
142 
143  info.setCaloGeometry(theCaloGeometry_);
144 
146  // estimate propagation outer boundaries based on
147  // requested sub-detector information. For now limit
148  // propagation region only if muon matching is not
149  // requested.
150  double HOmaxR = hoDetIdAssociator_->volume().maxR();
151  double HOmaxZ = hoDetIdAssociator_->volume().maxZ();
152  double minR = ecalDetIdAssociator_->volume().minR();
155  cachedTrajectory_.setMaxHOLength(HOmaxZ * 2.);
158 
159  if (parameters.useMuon) {
160  double maxR = muonDetIdAssociator_->volume().maxR();
161  double maxZ = muonDetIdAssociator_->volume().maxZ();
164  } else {
167  }
168 
169  // If track extras exist and outerState is before HO maximum, then use outerState
170  if (outerState) {
171  if (outerState->position().perp() < HOmaxR && std::abs(outerState->position().z()) < HOmaxZ) {
172  LogTrace("TrackAssociator") << "Using outerState as trackOrigin at Rho=" << outerState->position().perp()
173  << " Z=" << outerState->position().z() << "\n";
174  trackOrigin = SteppingHelixStateInfo(*outerState);
175  } else if (innerState) {
176  LogTrace("TrackAssociator") << "Using innerState as trackOrigin at Rho=" << innerState->position().perp()
177  << " Z=" << innerState->position().z() << "\n";
178  trackOrigin = SteppingHelixStateInfo(*innerState);
179  }
180  }
181 
182  if (trackOrigin.momentum().mag() == 0)
183  return info;
184  if (edm::isNotFinite(trackOrigin.momentum().x()) or edm::isNotFinite(trackOrigin.momentum().y()) or
185  edm::isNotFinite(trackOrigin.momentum().z()))
186  return info;
187  if (!cachedTrajectory_.propagateAll(trackOrigin))
188  return info;
189 
190  // get trajectory in calorimeters
195 
196  info.trkGlobPosAtEcal = getPoint(cachedTrajectory_.getStateAtEcal().position());
197  info.trkGlobPosAtHcal = getPoint(cachedTrajectory_.getStateAtHcal().position());
198  info.trkGlobPosAtHO = getPoint(cachedTrajectory_.getStateAtHO().position());
199 
200  info.trkMomAtEcal = cachedTrajectory_.getStateAtEcal().momentum();
201  info.trkMomAtHcal = cachedTrajectory_.getStateAtHcal().momentum();
202  info.trkMomAtHO = cachedTrajectory_.getStateAtHO().momentum();
203 
204  if (parameters.useEcal)
206  if (parameters.useCalo)
208  if (parameters.useHcal)
210  if (parameters.useHO)
212  if (parameters.usePreshower)
214  if (parameters.useMuon)
216  if (parameters.truthMatch)
218 
219  return info;
220 }
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 967 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_2023v12_cff::track, and PV3DBase< T, PVType, FrameType >::z().

971  {
972  double currentStepSize = cachedTrajectory_.getPropagationStep();
973 
974  const MagneticField* bField = &iSetup.getData(parameters.bFieldToken);
975 
976  if (track.extra().isNull()) {
977  if (direction != InsideOut)
978  throw cms::Exception("FatalError") << "No TrackExtra information is available and association is done with "
979  "something else than InsideOut track.\n"
980  << "Either change the parameter or provide needed data!\n";
981  LogTrace("TrackAssociator") << "Track Extras not found\n";
983  return associate(iEvent, iSetup, parameters, &initialState); // 5th argument is null pointer
984  }
985 
986  LogTrace("TrackAssociator") << "Track Extras found\n";
990 
991  LogTrace("TrackAssociator") << "inner track state (rho, z, phi):" << track.innerPosition().Rho() << ", "
992  << track.innerPosition().z() << ", " << track.innerPosition().phi() << "\n";
993  LogTrace("TrackAssociator") << "innerFreeState (rho, z, phi):" << innerState.position().perp() << ", "
994  << innerState.position().z() << ", " << innerState.position().phi() << "\n";
995 
996  LogTrace("TrackAssociator") << "outer track state (rho, z, phi):" << track.outerPosition().Rho() << ", "
997  << track.outerPosition().z() << ", " << track.outerPosition().phi() << "\n";
998  LogTrace("TrackAssociator") << "outerFreeState (rho, z, phi):" << outerState.position().perp() << ", "
999  << outerState.position().z() << ", " << outerState.position().phi() << "\n";
1000 
1001  // InsideOut first
1002  if (crossedIP(track)) {
1003  switch (direction) {
1004  case InsideOut:
1005  case Any:
1006  return associate(iEvent, iSetup, parameters, &referenceState, &outerState);
1007  break;
1008  case OutsideIn: {
1009  cachedTrajectory_.setPropagationStep(-std::abs(currentStepSize));
1010  TrackDetMatchInfo result = associate(iEvent, iSetup, parameters, &innerState, &referenceState);
1011  cachedTrajectory_.setPropagationStep(currentStepSize);
1012  return result;
1013  break;
1014  }
1015  }
1016  } else {
1017  switch (direction) {
1018  case InsideOut:
1019  return associate(iEvent, iSetup, parameters, &innerState, &outerState);
1020  break;
1021  case OutsideIn: {
1022  cachedTrajectory_.setPropagationStep(-std::abs(currentStepSize));
1023  TrackDetMatchInfo result = associate(iEvent, iSetup, parameters, &outerState, &innerState);
1024  cachedTrajectory_.setPropagationStep(currentStepSize);
1025  return result;
1026  break;
1027  }
1028  case Any: {
1029  // check if we deal with clear outside-in case
1030  if (track.innerPosition().Dot(track.innerMomentum()) < 0 &&
1031  track.outerPosition().Dot(track.outerMomentum()) < 0) {
1032  cachedTrajectory_.setPropagationStep(-std::abs(currentStepSize));
1034  if (track.innerPosition().Mag2() < track.outerPosition().Mag2())
1035  result = associate(iEvent, iSetup, parameters, &innerState, &outerState);
1036  else
1037  result = associate(iEvent, iSetup, parameters, &outerState, &innerState);
1038  cachedTrajectory_.setPropagationStep(currentStepSize);
1039  return result;
1040  }
1041  }
1042  }
1043  }
1044 
1045  // all other cases
1046  return associate(iEvent, iSetup, parameters, &innerState, &outerState);
1047 }
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 1049 of file TrackDetectorAssociator.cc.

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

1053  {
1054  auto const* bField = &iSetup.getData(parameters.bFieldToken);
1056 }
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 1058 of file TrackDetectorAssociator.cc.

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

1063  {
1064  auto const* bField = &iSetup.getData(parameters.bFieldToken);
1065  return associate(iEvent, iSetup, getFreeTrajectoryState(bField, momentum, vertex, charge), parameters);
1066 }
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 1068 of file TrackDetectorAssociator.cc.

References HLT_2023v12_cff::track.

Referenced by MuonIdProducer::produce().

1068  {
1069  bool crossed = true;
1070  crossed &= (track.innerPosition().rho() > 3); // something close to active volume
1071  crossed &= (track.outerPosition().rho() > 3); // something close to active volume
1072  crossed &=
1073  ((track.innerPosition().x() * track.innerMomentum().x() + track.innerPosition().y() * track.innerMomentum().y() <
1074  0) !=
1075  (track.outerPosition().x() * track.outerMomentum().x() + track.outerPosition().y() * track.outerMomentum().y() <
1076  0));
1077  return crossed;
1078 }

◆ fillCaloTowers()

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

Definition at line 296 of file TrackDetectorAssociator.cc.

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

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

902  {
903  // get list of simulated tracks and their vertices
904  using namespace edm;
906  iEvent.getByToken(parameters.simTracksToken, simTracks);
907  if (!simTracks.isValid())
908  throw cms::Exception("FatalError") << "No simulated tracks found\n";
909 
911  iEvent.getByToken(parameters.simVerticesToken, simVertices);
912  if (!simVertices.isValid())
913  throw cms::Exception("FatalError") << "No simulated vertices found\n";
914 
915  // get sim calo hits
916  Handle<PCaloHitContainer> simEcalHitsEB;
917  iEvent.getByToken(parameters.simEcalHitsEBToken, simEcalHitsEB);
918  if (!simEcalHitsEB.isValid())
919  throw cms::Exception("FatalError") << "No simulated ECAL EB hits found\n";
920 
921  Handle<PCaloHitContainer> simEcalHitsEE;
922  iEvent.getByToken(parameters.simEcalHitsEEToken, simEcalHitsEE);
923  if (!simEcalHitsEE.isValid())
924  throw cms::Exception("FatalError") << "No simulated ECAL EE hits found\n";
925 
926  Handle<PCaloHitContainer> simHcalHits;
927  iEvent.getByToken(parameters.simHcalHitsToken, simHcalHits);
928  if (!simHcalHits.isValid())
929  throw cms::Exception("FatalError") << "No simulated HCAL hits found\n";
930 
931  // find truth partner
932  SimTrackContainer::const_iterator simTrack = simTracks->begin();
933  for (; simTrack != simTracks->end(); ++simTrack) {
934  math::XYZVector simP3(simTrack->momentum().x(), simTrack->momentum().y(), simTrack->momentum().z());
935  math::XYZVector recoP3(info.stateAtIP.momentum().x(), info.stateAtIP.momentum().y(), info.stateAtIP.momentum().z());
936  if (ROOT::Math::VectorUtil::DeltaR(recoP3, simP3) < 0.1)
937  break;
938  }
939  if (simTrack != simTracks->end()) {
940  info.simTrack = &(*simTrack);
941  float ecalTrueEnergy(0);
942  float hcalTrueEnergy(0);
943 
944  // loop over calo hits
945  for (PCaloHitContainer::const_iterator hit = simEcalHitsEB->begin(); hit != simEcalHitsEB->end(); ++hit)
946  if (hit->geantTrackId() == info.simTrack->genpartIndex())
947  ecalTrueEnergy += hit->energy();
948 
949  for (PCaloHitContainer::const_iterator hit = simEcalHitsEE->begin(); hit != simEcalHitsEE->end(); ++hit)
950  if (hit->geantTrackId() == info.simTrack->genpartIndex())
951  ecalTrueEnergy += hit->energy();
952 
953  for (PCaloHitContainer::const_iterator hit = simHcalHits->begin(); hit != simHcalHits->end(); ++hit)
954  if (hit->geantTrackId() == info.simTrack->genpartIndex())
955  hcalTrueEnergy += hit->energy();
956 
957  info.ecalTrueEnergy = ecalTrueEnergy;
958  info.hcalTrueEnergy = hcalTrueEnergy;
959  info.hcalTrueEnergyCorrected = hcalTrueEnergy;
960  if (std::abs(info.trkGlobPosAtHcal.eta()) < 1.3f)
961  info.hcalTrueEnergyCorrected = hcalTrueEnergy * 113.2f;
962  else if (std::abs(info.trkGlobPosAtHcal.eta()) < 3.0f)
963  info.hcalTrueEnergyCorrected = hcalTrueEnergy * 167.2f;
964  }
965 }
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 222 of file TrackDetectorAssociator.cc.

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

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

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

395  {
396  const std::vector<SteppingHelixStateInfo>& trajectoryStates = cachedTrajectory_.getHcalTrajectory();
397 
398  std::vector<GlobalPoint> coreTrajectory;
399  for (std::vector<SteppingHelixStateInfo>::const_iterator itr = trajectoryStates.begin();
400  itr != trajectoryStates.end();
401  itr++)
402  coreTrajectory.push_back(itr->position());
403 
404  if (coreTrajectory.empty()) {
405  LogTrace("TrackAssociator") << "HCAL trajectory is empty; moving on\n";
406  info.isGoodHcal = false;
407  return;
408  }
409  info.isGoodHcal = true;
410 
411  // find crossed Hcals
413  iEvent.getByToken(parameters.HBHEcollToken, collection);
414  if (!collection.isValid())
415  throw cms::Exception("FatalError") << "Unable to find HBHERecHits in event!\n";
416 
417  std::set<DetId> idsInRegion;
418  if (parameters.accountForTrajectoryChangeCalo) {
419  // get trajectory change with respect to initial state
420  DetIdAssociator::MapRange mapRange =
422  idsInRegion = hcalDetIdAssociator_->getDetIdsCloseToAPoint(coreTrajectory[0], mapRange);
423  } else
424  idsInRegion = hcalDetIdAssociator_->getDetIdsCloseToAPoint(coreTrajectory[0], parameters.dRHcalPreselection);
425 
426  LogTrace("TrackAssociator") << "HCAL hits in the region: " << idsInRegion.size() << "\n"
427  << DetIdInfo::info(idsInRegion, nullptr);
428 
429  auto idsInAConeBegin = idsInRegion.begin();
430  auto idsInAConeEnd = idsInRegion.end();
431  std::set<DetId> idsInAConeTmp;
433  idsInAConeTmp = hcalDetIdAssociator_->getDetIdsInACone(idsInRegion, coreTrajectory, parameters.dRHcal);
434  idsInAConeBegin = idsInAConeTmp.begin();
435  idsInAConeEnd = idsInAConeTmp.end();
436  }
437  LogTrace("TrackAssociator") << "HCAL hits in the cone: " << std::distance(idsInAConeBegin, idsInAConeEnd) << "\n"
438  << DetIdInfo::info(std::set<DetId>(idsInAConeBegin, idsInAConeEnd), nullptr);
439  info.crossedHcalIds = hcalDetIdAssociator_->getCrossedDetIds(idsInRegion, coreTrajectory);
440  const std::vector<DetId>& crossedIds = info.crossedHcalIds;
441  LogTrace("TrackAssociator") << "HCAL hits crossed: " << crossedIds.size() << "\n"
442  << DetIdInfo::info(crossedIds, nullptr);
443 
444  // add Hcal
445  for (std::vector<DetId>::const_iterator itr = crossedIds.begin(); itr != crossedIds.end(); itr++) {
446  HBHERecHitCollection::const_iterator hit = (*collection).find(*itr);
447  if (hit != (*collection).end())
448  info.crossedHcalRecHits.push_back(&*hit);
449  else
450  LogTrace("TrackAssociator") << "Crossed HBHERecHit is not found for DetId: " << itr->rawId();
451  }
452  for (std::set<DetId>::const_iterator itr = idsInAConeBegin; itr != idsInAConeEnd; itr++) {
453  HBHERecHitCollection::const_iterator hit = (*collection).find(*itr);
454  if (hit != (*collection).end())
455  info.hcalRecHits.push_back(&*hit);
456  else
457  LogTrace("TrackAssociator") << "HBHERecHit from the cone is not found for DetId: " << itr->rawId();
458  }
459 }
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 461 of file TrackDetectorAssociator.cc.

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

463  {
464  const std::vector<SteppingHelixStateInfo>& trajectoryStates = cachedTrajectory_.getHOTrajectory();
465 
466  std::vector<GlobalPoint> coreTrajectory;
467  for (std::vector<SteppingHelixStateInfo>::const_iterator itr = trajectoryStates.begin();
468  itr != trajectoryStates.end();
469  itr++)
470  coreTrajectory.push_back(itr->position());
471 
472  if (coreTrajectory.empty()) {
473  LogTrace("TrackAssociator") << "HO trajectory is empty; moving on\n";
474  info.isGoodHO = false;
475  return;
476  }
477  info.isGoodHO = true;
478 
479  // find crossed HOs
481  iEvent.getByToken(parameters.HOcollToken, collection);
482  if (!collection.isValid())
483  throw cms::Exception("FatalError") << "Unable to find HORecHits in event!\n";
484 
485  std::set<DetId> idsInRegion;
486  if (parameters.accountForTrajectoryChangeCalo) {
487  // get trajectory change with respect to initial state
488  DetIdAssociator::MapRange mapRange =
490  idsInRegion = hoDetIdAssociator_->getDetIdsCloseToAPoint(coreTrajectory[0], mapRange);
491  } else
492  idsInRegion = hoDetIdAssociator_->getDetIdsCloseToAPoint(coreTrajectory[0], parameters.dRHcalPreselection);
493 
494  LogTrace("TrackAssociator") << "idsInRegion.size(): " << idsInRegion.size();
495 
496  auto idsInAConeBegin = idsInRegion.begin();
497  auto idsInAConeEnd = idsInRegion.end();
498  std::set<DetId> idsInAConeTmp;
500  idsInAConeTmp = hoDetIdAssociator_->getDetIdsInACone(idsInRegion, coreTrajectory, parameters.dRHcal);
501  idsInAConeBegin = idsInAConeTmp.begin();
502  idsInAConeEnd = idsInAConeTmp.end();
503  }
504  LogTrace("TrackAssociator") << "idsInACone.size(): " << std::distance(idsInAConeBegin, idsInAConeEnd);
505  info.crossedHOIds = hoDetIdAssociator_->getCrossedDetIds(idsInRegion, coreTrajectory);
506  const std::vector<DetId>& crossedIds = info.crossedHOIds;
507 
508  // add HO
509  for (std::vector<DetId>::const_iterator itr = crossedIds.begin(); itr != crossedIds.end(); itr++) {
510  HORecHitCollection::const_iterator hit = (*collection).find(*itr);
511  if (hit != (*collection).end())
512  info.crossedHORecHits.push_back(&*hit);
513  else
514  LogTrace("TrackAssociator") << "Crossed HORecHit is not found for DetId: " << itr->rawId();
515  }
516 
517  for (std::set<DetId>::const_iterator itr = idsInAConeBegin; itr != idsInAConeEnd; itr++) {
518  HORecHitCollection::const_iterator hit = (*collection).find(*itr);
519  if (hit != (*collection).end())
520  info.hoRecHits.push_back(&*hit);
521  else
522  LogTrace("TrackAssociator") << "HORecHit from the cone is not found for DetId: " << itr->rawId();
523  }
524 }
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 705 of file TrackDetectorAssociator.cc.

References relativeConstraints::chamber, dtChamberEfficiency_cfi::cscSegments, gemSegments_cfi::gemSegments, iEvent, info(), edm::HandleBase::isValid(), LogTrace, me0Segments_cfi::me0Segments, and FastTimerService_cff::range.

707  {
708  // Get the segments from the event
710  iEvent.getByToken(parameters.dtSegmentsToken, dtSegments);
711  if (!dtSegments.isValid())
712  throw cms::Exception("FatalError") << "Unable to find DTRecSegment4DCollection in event!\n";
713 
715  iEvent.getByToken(parameters.cscSegmentsToken, cscSegments);
716  if (!cscSegments.isValid())
717  throw cms::Exception("FatalError") << "Unable to find CSCSegmentCollection in event!\n";
718 
720  if (parameters.useGEM)
721  iEvent.getByToken(parameters.gemSegmentsToken, gemSegments);
723  if (parameters.useME0)
724  iEvent.getByToken(parameters.me0SegmentsToken, me0Segments);
725 
727 
728  // check the map of available segments
729  // if there is no segments in a given direction at all,
730  // then there is no point to fly there.
731  //
732  // MISSING
733  // Possible solution: quick search for presence of segments
734  // for the set of DetIds
735 
736  // get a set of matches corresponding to muon chambers
737  std::vector<TAMuonChamberMatch> matchedChambers;
738  LogTrace("TrackAssociator") << "Trying to Get ChamberMatches" << std::endl;
739  getTAMuonChamberMatches(matchedChambers, parameters);
740  LogTrace("TrackAssociator") << "Chambers matched: " << matchedChambers.size() << "\n";
741 
742  // Iterate over all chamber matches and fill segment matching
743  // info if it's available
744  for (std::vector<TAMuonChamberMatch>::iterator matchedChamber = matchedChambers.begin();
745  matchedChamber != matchedChambers.end();
746  matchedChamber++) {
747  const GeomDet* geomDet = muonDetIdAssociator_->getGeomDet((*matchedChamber).id);
748  // DT chamber
749  if (const DTChamber* chamber = dynamic_cast<const DTChamber*>(geomDet)) {
750  // Get the range for the corresponding segments
751  DTRecSegment4DCollection::range range = dtSegments->get(chamber->id());
752  // Loop over the segments of this chamber
753  for (DTRecSegment4DCollection::const_iterator segment = range.first; segment != range.second; segment++) {
754  if (addTAMuonSegmentMatch(*matchedChamber, &(*segment), parameters)) {
755  matchedChamber->segments.back().dtSegmentRef = DTRecSegment4DRef(dtSegments, segment - dtSegments->begin());
756  }
757  }
758  }
759  // CSC Chamber
760  else if (const CSCChamber* chamber = dynamic_cast<const CSCChamber*>(geomDet)) {
761  // Get the range for the corresponding segments
763  // Loop over the segments
764  for (CSCSegmentCollection::const_iterator segment = range.first; segment != range.second; segment++) {
765  if (addTAMuonSegmentMatch(*matchedChamber, &(*segment), parameters)) {
766  matchedChamber->segments.back().cscSegmentRef = CSCSegmentRef(cscSegments, segment - cscSegments->begin());
767  }
768  }
769  } else {
770  // GEM Chamber
771  if (parameters.useGEM) {
772  if (const GEMSuperChamber* chamber = dynamic_cast<const GEMSuperChamber*>(geomDet)) {
773  // Get the range for the corresponding segments
775  // Loop over the segments
776  for (GEMSegmentCollection::const_iterator segment = range.first; segment != range.second; segment++) {
777  if (addTAMuonSegmentMatch(*matchedChamber, &(*segment), parameters)) {
778  matchedChamber->segments.back().gemSegmentRef =
779  GEMSegmentRef(gemSegments, segment - gemSegments->begin());
780  }
781  }
782  }
783  }
784  // ME0 Chamber
785  if (parameters.useME0) {
786  if (const ME0Chamber* chamber = dynamic_cast<const ME0Chamber*>(geomDet)) {
787  // Get the range for the corresponding segments
789  // Loop over the segments
790  for (ME0SegmentCollection::const_iterator segment = range.first; segment != range.second; segment++) {
791  if (addTAMuonSegmentMatch(*matchedChamber, &(*segment), parameters)) {
792  matchedChamber->segments.back().me0SegmentRef =
793  ME0SegmentRef(me0Segments, segment - me0Segments->begin());
794  }
795  }
796  }
797  }
798  }
799  info.chambers.push_back(*matchedChamber);
800  }
801 }
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
void getTAMuonChamberMatches(std::vector< TAMuonChamberMatch > &matches, const AssociatorParameters &parameters)
const DetIdAssociator * muonDetIdAssociator_
edm::Ref< GEMSegmentCollection > GEMSegmentRef
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 370 of file TrackDetectorAssociator.cc.

References info(), and LogTrace.

372  {
373  std::vector<GlobalPoint> trajectory;
374  const std::vector<SteppingHelixStateInfo>& trajectoryStates = cachedTrajectory_.getPreshowerTrajectory();
375  for (std::vector<SteppingHelixStateInfo>::const_iterator itr = trajectoryStates.begin();
376  itr != trajectoryStates.end();
377  itr++)
378  trajectory.push_back(itr->position());
379 
380  if (trajectory.empty()) {
381  LogTrace("TrackAssociator") << "Preshower trajectory is empty; moving on\n";
382  return;
383  }
384 
385  std::set<DetId> idsInRegion =
386  preshowerDetIdAssociator_->getDetIdsCloseToAPoint(trajectory[0], parameters.dRPreshowerPreselection);
387 
388  LogTrace("TrackAssociator") << "Number of Preshower Ids in the region: " << idsInRegion.size();
389  info.crossedPreshowerIds = preshowerDetIdAssociator_->getCrossedDetIds(idsInRegion, trajectory);
390  LogTrace("TrackAssociator") << "Number of Preshower Ids in crossed: " << info.crossedPreshowerIds.size();
391 }
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 554 of file TrackDetectorAssociator.cc.

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

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

555  {
556  GlobalVector vector(track.momentum().x(), track.momentum().y(), track.momentum().z());
557 
558  GlobalPoint point(track.vertex().x(), track.vertex().y(), track.vertex().z());
559 
561 
562  // FIX THIS !!!
563  // need to convert from perigee to global or helix (curvilinear) frame
564  // for now just an arbitrary matrix.
565  ROOT::Math::SMatrixIdentity id;
566  AlgebraicSymMatrix66 covT(id);
567  covT *= 1e-6; // initialize to sigma=1e-3
568  CartesianTrajectoryError tCov(covT);
569 
570  return FreeTrajectoryState(tPars, tCov);
571 }
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 526 of file TrackDetectorAssociator.cc.

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

528  {
529  GlobalVector vector(track.momentum().x(), track.momentum().y(), track.momentum().z());
530  GlobalPoint point(vertex.position().x(), vertex.position().y(), vertex.position().z());
531 
532  int charge = track.type() > 0 ? -1 : 1; // lepton convention
533  if (abs(track.type()) == 211 || // pion
534  abs(track.type()) == 321 || // kaon
535  abs(track.type()) == 2212)
536  charge = track.type() < 0 ? -1 : 1;
538 }
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 540 of file TrackDetectorAssociator.cc.

References Calorimetry_cff::bField, ALCARECOTkAlJpsiMuMu_cff::charge, MillePedeFileConverter_cfg::e, l1ctLayer2EG_cff::id, and bphysicsOniaDQM_cfi::vertex.

543  {
544  GlobalTrajectoryParameters tPars(vertex, momentum, charge, bField);
545 
546  ROOT::Math::SMatrixIdentity id;
547  AlgebraicSymMatrix66 covT(id);
548  covT *= 1e-6; // initialize to sigma=1e-3
549  CartesianTrajectoryError tCov(covT);
550 
551  return FreeTrajectoryState(tPars, tCov);
552 }
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 573 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.

573  {
574  DetIdAssociator::MapRange mapRange;
575  mapRange.dThetaPlus = dR;
576  mapRange.dThetaMinus = dR;
577  mapRange.dPhiPlus = dR;
578  mapRange.dPhiMinus = dR;
579  if (delta.first > 0)
580  mapRange.dThetaPlus += delta.first;
581  else
582  mapRange.dThetaMinus += std::abs(delta.first);
583  if (delta.second > 0)
584  mapRange.dPhiPlus += delta.second;
585  else
586  mapRange.dPhiMinus += std::abs(delta.second);
587  LogTrace("TrackAssociator") << "Selection range: (dThetaPlus, dThetaMinus, dPhiPlus, dPhiMinus, dRPreselection): "
588  << mapRange.dThetaPlus << ", " << mapRange.dThetaMinus << ", " << mapRange.dPhiPlus
589  << ", " << mapRange.dPhiMinus << ", " << dR;
590  return mapRange;
591 }
#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 135 of file TrackDetectorAssociator.h.

References point.

135  {
136  return math::XYZPoint(point.x(), point.y(), point.z());
137  }
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 139 of file TrackDetectorAssociator.h.

References point.

139  {
140  return math::XYZPoint(point.x(), point.y(), point.z());
141  }
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 
)
private

Definition at line 593 of file TrackDetectorAssociator.cc.

References funct::abs(), Surface::bounds(), 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(), 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().

594  {
595  // Strategy:
596  // Propagate through the whole detector, estimate change in eta and phi
597  // along the trajectory, add this to dRMuon and find DetIds around this
598  // direction using the map. Then propagate fast to each surface and apply
599  // final matching criteria.
600 
601  // get the direction first
603  // If trajectory point at HCAL is not valid, try to use the outer most state of the
604  // trajectory instead.
605  if (!trajectoryPoint.isValid())
606  trajectoryPoint = cachedTrajectory_.getOuterState();
607  if (!trajectoryPoint.isValid()) {
608  LogTrace("TrackAssociator")
609  << "trajectory position at HCAL is not valid. Assume the track cannot reach muon detectors and skip it";
610  return;
611  }
612 
613  GlobalVector direction = trajectoryPoint.momentum().unit();
614  LogTrace("TrackAssociator") << "muon direction: " << direction
615  << "\n\t and corresponding point: " << trajectoryPoint.position() << "\n";
616 
617  DetIdAssociator::MapRange mapRange =
619 
620  // and find chamber DetIds
621 
622  std::set<DetId> muonIdsInRegion = muonDetIdAssociator_->getDetIdsCloseToAPoint(trajectoryPoint.position(), mapRange);
623  LogTrace("TrackAssociator") << "Number of chambers to check: " << muonIdsInRegion.size();
624  for (std::set<DetId>::const_iterator detId = muonIdsInRegion.begin(); detId != muonIdsInRegion.end(); detId++) {
625  const GeomDet* geomDet = muonDetIdAssociator_->getGeomDet(*detId);
626  TrajectoryStateOnSurface stateOnSurface = cachedTrajectory_.propagate(&geomDet->surface());
627  if (!stateOnSurface.isValid()) {
628  LogTrace("TrackAssociator") << "Failed to propagate the track; moving on\n\t"
629  << "Element is not crosssed: " << DetIdInfo::info(*detId, nullptr) << "\n";
630  continue;
631  }
632  LocalPoint localPoint = geomDet->surface().toLocal(stateOnSurface.freeState()->position());
633  LocalError localError = stateOnSurface.localError().positionError();
634  float distanceX = 0.f;
635  float distanceY = 0.f;
636  if (const CSCChamber* cscChamber = dynamic_cast<const CSCChamber*>(geomDet)) {
637  const CSCChamberSpecs* chamberSpecs = cscChamber->specs();
638  if (!chamberSpecs) {
639  LogTrace("TrackAssociator") << "Failed to get CSCChamberSpecs from CSCChamber; moving on\n";
640  continue;
641  }
642  const CSCLayerGeometry* layerGeometry = chamberSpecs->oddLayerGeometry(1);
643  if (!layerGeometry) {
644  LogTrace("TrackAssociator") << "Failed to get CSCLayerGeometry from CSCChamberSpecs; moving on\n";
645  continue;
646  }
647  const CSCWireTopology* wireTopology = layerGeometry->wireTopology();
648  if (!wireTopology) {
649  LogTrace("TrackAssociator") << "Failed to get CSCWireTopology from CSCLayerGeometry; moving on\n";
650  continue;
651  }
652 
653  float wideWidth = wireTopology->wideWidthOfPlane();
654  float narrowWidth = wireTopology->narrowWidthOfPlane();
655  float length = wireTopology->lengthOfPlane();
656  // If slanted, there is no y offset between local origin and symmetry center of wire plane
657  float yOfFirstWire = std::abs(wireTopology->wireAngle()) > 1.E-06f ? -0.5 * length : wireTopology->yOfWire(1);
658  // y offset between local origin and symmetry center of wire plane
659  float yCOWPOffset = yOfFirstWire + 0.5f * length;
660 
661  // tangent of the incline angle from inside the trapezoid
662  float tangent = (wideWidth - narrowWidth) / (2.f * length);
663  // y position wrt bottom of trapezoid
664  float yPrime = localPoint.y() + std::abs(yOfFirstWire);
665  // half trapezoid width at y' is 0.5 * narrowWidth + x side of triangle with the above tangent and side y'
666  float halfWidthAtYPrime = 0.5f * narrowWidth + yPrime * tangent;
667  distanceX = std::abs(localPoint.x()) - halfWidthAtYPrime;
668  distanceY = std::abs(localPoint.y() - yCOWPOffset) - 0.5f * length;
669  } else if (dynamic_cast<const GEMChamber*>(geomDet) || dynamic_cast<const GEMSuperChamber*>(geomDet)) {
670  const TrapezoidalPlaneBounds* bounds = dynamic_cast<const TrapezoidalPlaneBounds*>(&geomDet->surface().bounds());
671 
672  float wideWidth = bounds->width();
673  float narrowWidth = 2.f * bounds->widthAtHalfLength() - wideWidth;
674  float length = bounds->length();
675  float tangent = (wideWidth - narrowWidth) / (2.f * length);
676  float halfWidthAtY = tangent * localPoint.y() + 0.25f * (narrowWidth + wideWidth);
677 
678  distanceX = std::abs(localPoint.x()) - halfWidthAtY;
679  distanceY = std::abs(localPoint.y()) - 0.5f * length;
680  } else {
681  distanceX = std::abs(localPoint.x()) - 0.5f * geomDet->surface().bounds().width();
682  distanceY = std::abs(localPoint.y()) - 0.5f * geomDet->surface().bounds().length();
683  }
684  if ((distanceX < parameters.muonMaxDistanceX && distanceY < parameters.muonMaxDistanceY) ||
685  (distanceX * distanceX <
686  localError.xx() * parameters.muonMaxDistanceSigmaX * parameters.muonMaxDistanceSigmaX &&
687  distanceY * distanceY <
688  localError.yy() * parameters.muonMaxDistanceSigmaY * parameters.muonMaxDistanceSigmaY)) {
689  LogTrace("TrackAssociator") << "found a match: " << DetIdInfo::info(*detId, nullptr) << "\n";
691  match.tState = stateOnSurface;
692  match.localDistanceX = distanceX;
693  match.localDistanceY = distanceY;
694  match.id = *detId;
695  matches.push_back(match);
696  } else {
697  LogTrace("TrackAssociator") << "chamber is too far: " << DetIdInfo::info(*detId, nullptr)
698  << "\n\tdistanceX: " << distanceX << "\t distanceY: " << distanceY
699  << "\t sigmaX: " << distanceX / sqrt(localError.xx())
700  << "\t sigmaY: " << distanceY / sqrt(localError.yy()) << "\n";
701  }
702  }
703 }
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
const Bounds & bounds() const
Definition: Surface.h:87

◆ getVector() [1/2]

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

Definition at line 143 of file TrackDetectorAssociator.h.

143 { 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 145 of file TrackDetectorAssociator.h.

145 { 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 84 of file TrackDetectorAssociator.cc.

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

84  {
85  // access the calorimeter geometry
86  theCaloGeometry_ = &iSetup.getData(parameters.theCaloGeometryToken);
87 
88  // get the tracking Geometry
89  theTrackingGeometry_ = &iSetup.getData(parameters.theTrackingGeometryToken);
90 
92  // setup propagator
93  const MagneticField* bField = &iSetup.getData(parameters.bFieldToken);
94 
95  auto prop = std::make_unique<SteppingHelixPropagator>(bField, anyDirection);
96  prop->setMaterialMode(false);
97  prop->applyRadX0Correction(true);
98  // prop->setDebug(true); // tmp
99  defProp_ = std::move(prop);
100  setPropagator(defProp_.get());
101  }
102 
103  ecalDetIdAssociator_ = &iSetup.getData(parameters.ecalDetIdAssociatorToken);
104  hcalDetIdAssociator_ = &iSetup.getData(parameters.hcalDetIdAssociatorToken);
105  hoDetIdAssociator_ = &iSetup.getData(parameters.hoDetIdAssociatorToken);
106  caloDetIdAssociator_ = &iSetup.getData(parameters.caloDetIdAssociatorToken);
107  muonDetIdAssociator_ = &iSetup.getData(parameters.muonDetIdAssociatorToken);
108  preshowerDetIdAssociator_ = &iSetup.getData(parameters.preshowerDetIdAssociatorToken);
109 }
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 77 of file TrackDetectorAssociator.cc.

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

77  {
78  ivProp_ = ptr;
80 }
void setPropagator(const Propagator *ptr)

◆ useDefaultPropagator()

void TrackDetectorAssociator::useDefaultPropagator ( )

Member Data Documentation

◆ cachedTrajectory_

CachedTrajectory TrackDetectorAssociator::cachedTrajectory_
private

Definition at line 149 of file TrackDetectorAssociator.h.

Referenced by getCachedTrajector().

◆ caloDetIdAssociator_

const DetIdAssociator* TrackDetectorAssociator::caloDetIdAssociator_
private

Definition at line 155 of file TrackDetectorAssociator.h.

◆ defProp_

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

Definition at line 148 of file TrackDetectorAssociator.h.

◆ ecalDetIdAssociator_

const DetIdAssociator* TrackDetectorAssociator::ecalDetIdAssociator_
private

Definition at line 152 of file TrackDetectorAssociator.h.

◆ hcalDetIdAssociator_

const DetIdAssociator* TrackDetectorAssociator::hcalDetIdAssociator_
private

Definition at line 153 of file TrackDetectorAssociator.h.

◆ hoDetIdAssociator_

const DetIdAssociator* TrackDetectorAssociator::hoDetIdAssociator_
private

Definition at line 154 of file TrackDetectorAssociator.h.

◆ ivProp_

const Propagator* TrackDetectorAssociator::ivProp_
private

Definition at line 147 of file TrackDetectorAssociator.h.

◆ muonDetIdAssociator_

const DetIdAssociator* TrackDetectorAssociator::muonDetIdAssociator_
private

Definition at line 156 of file TrackDetectorAssociator.h.

◆ preshowerDetIdAssociator_

const DetIdAssociator* TrackDetectorAssociator::preshowerDetIdAssociator_
private

Definition at line 157 of file TrackDetectorAssociator.h.

◆ theCaloGeometry_

const CaloGeometry* TrackDetectorAssociator::theCaloGeometry_
private

Definition at line 159 of file TrackDetectorAssociator.h.

◆ theMagneticFieldWatcher_

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

Definition at line 162 of file TrackDetectorAssociator.h.

◆ theTrackingGeometry_

const GlobalTrackingGeometry* TrackDetectorAssociator::theTrackingGeometry_
private

Definition at line 160 of file TrackDetectorAssociator.h.

◆ useDefaultPropagator_

bool TrackDetectorAssociator::useDefaultPropagator_
private

Definition at line 150 of file TrackDetectorAssociator.h.