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=0)
 
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 edm::EventSetup &, const reco::Track &)
 get FreeTrajectoryState from different track representations More...
 
static FreeTrajectoryState getFreeTrajectoryState (const edm::EventSetup &, const SimTrack &, const SimVertex &)
 
static FreeTrajectoryState getFreeTrajectoryState (const edm::EventSetup &, 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 &)
 

Private Attributes

CachedTrajectory cachedTrajectory_
 
edm::ESHandle< DetIdAssociatorcaloDetIdAssociator_
 
PropagatordefProp_
 
edm::ESHandle< DetIdAssociatorecalDetIdAssociator_
 
edm::ESHandle< DetIdAssociatorhcalDetIdAssociator_
 
edm::ESHandle< DetIdAssociatorhoDetIdAssociator_
 
const PropagatorivProp_
 
edm::ESHandle< DetIdAssociatormuonDetIdAssociator_
 
edm::ESHandle< DetIdAssociatorpreshowerDetIdAssociator_
 
edm::ESHandle< CaloGeometrytheCaloGeometry_
 
edm::ESWatcher< IdealMagneticFieldRecordtheMagneticFeildWatcher_
 
edm::ESHandle< GlobalTrackingGeometrytheTrackingGeometry_
 
bool useDefaultPropagator_
 

Detailed Description

Definition at line 49 of file TrackDetectorAssociator.h.

Member Typedef Documentation

Definition at line 54 of file TrackDetectorAssociator.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

TrackDetectorAssociator::TrackDetectorAssociator ( )

Definition at line 104 of file TrackDetectorAssociator.cc.

104  {
105  ivProp_ = nullptr;
106  defProp_ = nullptr;
107  useDefaultPropagator_ = false;
108 }
TrackDetectorAssociator::~TrackDetectorAssociator ( )

Definition at line 110 of file TrackDetectorAssociator.cc.

110  {
111  if (defProp_)
112  delete defProp_;
113 }

Member Function Documentation

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

Definition at line 843 of file TrackDetectorAssociator.cc.

References relativeConstraints::chamber, reco::deltaPhi(), TrackAssociatorParameters::dRMuon, PV3DBase< T, PVType, FrameType >::eta(), 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(), funct::pow(), 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(), mathSSE::sqrt(), TAMuonSegmentMatch::t0, DTRecSegment2D::t0(), FrontierCondition_GT_autoExpress_cfi::t0, GeomDet::toGlobal(), TAMuonChamberMatch::tState, LocalError::xx(), LocalError::xy(), and LocalError::yy().

Referenced by getCachedTrajector().

845  {
846  LogTrace("TrackAssociator") << "Segment local position: " << segment->localPosition() << "\n"
847  << std::hex << segment->geographicalId().rawId() << "\n";
848 
849  const GeomDet* chamber = muonDetIdAssociator_->getGeomDet(matchedChamber.id);
850  TrajectoryStateOnSurface trajectoryStateOnSurface = matchedChamber.tState;
851  GlobalPoint segmentGlobalPosition = chamber->toGlobal(segment->localPosition());
852 
853  LogTrace("TrackAssociator") << "Segment global position: " << segmentGlobalPosition
854  << " \t (R_xy,eta,phi): " << segmentGlobalPosition.perp() << ","
855  << segmentGlobalPosition.eta() << "," << segmentGlobalPosition.phi() << "\n";
856 
857  LogTrace("TrackAssociator") << "\teta hit: " << segmentGlobalPosition.eta()
858  << " \tpropagator: " << trajectoryStateOnSurface.freeState()->position().eta() << "\n"
859  << "\tphi hit: " << segmentGlobalPosition.phi()
860  << " \tpropagator: " << trajectoryStateOnSurface.freeState()->position().phi()
861  << std::endl;
862 
863  bool isGood = false;
864  bool isDTWithoutY = false;
865  const DTRecSegment4D* dtseg = dynamic_cast<const DTRecSegment4D*>(segment);
866  if (dtseg && (!dtseg->hasZed()))
867  isDTWithoutY = true;
868 
869  double deltaPhi(fabs(segmentGlobalPosition.phi() - trajectoryStateOnSurface.freeState()->position().phi()));
870  if (deltaPhi > M_PI)
871  deltaPhi = fabs(deltaPhi - M_PI * 2.);
872 
873  if (isDTWithoutY) {
874  isGood = deltaPhi < parameters.dRMuon;
875  // Be in chamber
876  isGood &= fabs(segmentGlobalPosition.eta() - trajectoryStateOnSurface.freeState()->position().eta()) < .3;
877  } else
878  isGood = sqrt(pow(segmentGlobalPosition.eta() - trajectoryStateOnSurface.freeState()->position().eta(), 2) +
879  deltaPhi * deltaPhi) < parameters.dRMuon;
880 
881  if (isGood) {
882  TAMuonSegmentMatch muonSegment;
883  muonSegment.segmentGlobalPosition = getPoint(segmentGlobalPosition);
884  muonSegment.segmentLocalPosition = getPoint(segment->localPosition());
885  muonSegment.segmentLocalDirection = getVector(segment->localDirection());
886  muonSegment.segmentLocalErrorXX = segment->localPositionError().xx();
887  muonSegment.segmentLocalErrorYY = segment->localPositionError().yy();
888  muonSegment.segmentLocalErrorXY = segment->localPositionError().xy();
889  muonSegment.segmentLocalErrorDxDz = segment->localDirectionError().xx();
890  muonSegment.segmentLocalErrorDyDz = segment->localDirectionError().yy();
891 
892  // DANGEROUS - compiler cannot guaranty parameters ordering
893  // AlgebraicSymMatrix segmentCovMatrix = segment->parametersError();
894  // muonSegment.segmentLocalErrorXDxDz = segmentCovMatrix[2][0];
895  // muonSegment.segmentLocalErrorYDyDz = segmentCovMatrix[3][1];
896  muonSegment.segmentLocalErrorXDxDz = -999;
897  muonSegment.segmentLocalErrorYDyDz = -999;
898  muonSegment.hasZed = true;
899  muonSegment.hasPhi = true;
900 
901  // timing information
902  muonSegment.t0 = 0;
903  if (dtseg) {
904  if ((dtseg->hasPhi()) && (!isDTWithoutY)) {
905  int phiHits = dtseg->phiSegment()->specificRecHits().size();
906  // int zHits = dtseg->zSegment()->specificRecHits().size();
907  int hits = 0;
908  double t0 = 0.;
909  // TODO: cuts on hit numbers not optimized in any way yet...
910  if (phiHits > 5 && dtseg->phiSegment()->ist0Valid()) {
911  t0 += dtseg->phiSegment()->t0() * phiHits;
912  hits += phiHits;
913  LogTrace("TrackAssociator") << " Phi t0: " << dtseg->phiSegment()->t0() << " hits: " << phiHits;
914  }
915  // the z segments seem to contain little useful information...
916  // if (zHits>3) {
917  // t0+=s->zSegment()->t0()*zHits;
918  // hits+=zHits;
919  // LogTrace("TrackAssociator") << " Z t0: " << s->zSegment()->t0() << " hits: " << zHits << std::endl;
920  // }
921  if (hits)
922  muonSegment.t0 = t0 / hits;
923  // LogTrace("TrackAssociator") << " --- t0: " << muonSegment.t0 << std::endl;
924  } else {
925  // check and set dimensionality
926  if (isDTWithoutY)
927  muonSegment.hasZed = false;
928  if (!dtseg->hasPhi())
929  muonSegment.hasPhi = false;
930  }
931  }
932  matchedChamber.segments.push_back(muonSegment);
933  }
934 
935  return isGood;
936 }
float xx() const
Definition: LocalError.h:22
virtual LocalError localDirectionError() const =0
Error on the local direction.
T perp() const
Definition: PV3DBase.h:69
TrajectoryStateOnSurface tState
math::XYZPoint segmentGlobalPosition
const DTChamberRecSegment2D * phiSegment() const
The superPhi segment: 0 if no phi projection available.
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
math::XYZPoint segmentLocalPosition
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
math::XYZVector getVector(const GlobalVector &vec)
math::XYZVector segmentLocalDirection
virtual LocalVector localDirection() const =0
Local direction.
float xy() const
Definition: LocalError.h:23
float yy() const
Definition: LocalError.h:24
T sqrt(T t)
Definition: SSEVec.h:19
FreeTrajectoryState const * freeState(bool withErrors=true) const
std::vector< TAMuonSegmentMatch > segments
distance sign convention: negative - crossed chamber, positive - missed chamber
bool hasPhi() const
Does it have the Phi projection?
virtual LocalPoint localPosition() const =0
#define LogTrace(id)
std::vector< DTRecHit1D > specificRecHits() const
Access to specific components.
bool ist0Valid() const
#define M_PI
virtual const GeomDet * getGeomDet(const DetId &) const =0
bool hasZed() const
Does it have the Z projection?
GlobalPoint position() const
math::XYZPoint getPoint(const GlobalPoint &point)
T eta() const
Definition: PV3DBase.h:73
edm::ESHandle< DetIdAssociator > muonDetIdAssociator_
DetId geographicalId() const
virtual LocalError localPositionError() const =0
double t0() const
Get the segment t0 (if recomputed, 0 is returned otherwise)
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
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 154 of file TrackDetectorAssociator.cc.

Referenced by BetaCalculatorECAL::addInfoToCandidate(), EopTreeWriter::analyze(), EcalCosmicsHists::analyze(), spr::chargeIsolation(), spr::chargeIsolationEcal(), spr::chargeIsolationHcal(), spr::coneChargeIsolation(), muonisolation::JetExtractor::deposit(), muonisolation::CaloExtractorByAssociator::deposits(), cms::MuonMETValueMapProducer::determine_deltax_deltay(), MuonIdProducer::fillMuonId(), pat::PATIsolatedTrackProducer::getTrackDetMatchInfo(), CaloCleaner< T >::produce(), InterestingTrackEcalDetIdProducer::produce(), HighPtTrackEcalDetIdProducer::produce(), and ReduceHcalRecHitCollectionProducer::produce().

157  {
158  return associate(iEvent, iSetup, parameters, &fts);
159 }
TrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const AssociatorParameters &)
TrackDetMatchInfo TrackDetectorAssociator::associate ( const edm::Event iEvent,
const edm::EventSetup iSetup,
const AssociatorParameters parameters,
const FreeTrajectoryState innerState,
const FreeTrajectoryState outerState = 0 
)

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

Definition at line 161 of file TrackDetectorAssociator.cc.

References Exception, HLT_2018_cff::fillCaloTowers, info(), init, edm::isNotFinite(), LogTrace, PV3DBase< T, PVType, FrameType >::mag(), CosmicsPD_Skims::maxZ, HLT_2018_cff::minR, CosmicGenFilterHelix_cff::minZ, SteppingHelixStateInfo::momentum(), or, PV3DBase< T, PVType, FrameType >::perp(), FreeTrajectoryState::position(), TrackDetMatchInfo::setCaloGeometry(), TrackDetMatchInfo::stateAtIP, TrackDetMatchInfo::trkGlobPosAtEcal, TrackDetMatchInfo::trkGlobPosAtHcal, TrackDetMatchInfo::trkGlobPosAtHO, TrackDetMatchInfo::trkMomAtEcal, TrackDetMatchInfo::trkMomAtHcal, TrackDetMatchInfo::trkMomAtHO, TrackAssociatorParameters::truthMatch, TrackAssociatorParameters::useCalo, TrackAssociatorParameters::useEcal, TrackAssociatorParameters::useHcal, TrackAssociatorParameters::useHO, TrackAssociatorParameters::useMuon, TrackAssociatorParameters::usePreshower, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

165  {
167  if (!parameters.useEcal && !parameters.useCalo && !parameters.useHcal && !parameters.useHO && !parameters.useMuon &&
168  !parameters.usePreshower)
169  throw cms::Exception("ConfigurationError")
170  << "Configuration error! No subdetector was selected for the track association.";
171 
172  SteppingHelixStateInfo trackOrigin(*innerState);
173  info.stateAtIP = *innerState;
174  cachedTrajectory_.setStateAtIP(trackOrigin);
175 
176  init(iSetup);
177  // get track trajectory
178  // ECAL points (EB+EE)
179  // If the phi angle between a track entrance and exit points is more
180  // than 2 crystals, it is possible that the track will cross 3 crystals
181  // and therefore one has to check at least 3 points along the track
182  // trajectory inside ECAL. In order to have a chance to cross 4 crystalls
183  // in the barrel, a track should have P_t as low as 3 GeV or smaller
184  // If it's necessary, number of points along trajectory can be increased
185 
187 
189  // estimate propagation outer boundaries based on
190  // requested sub-detector information. For now limit
191  // propagation region only if muon matching is not
192  // requested.
193  double HOmaxR = hoDetIdAssociator_->volume().maxR();
194  double HOmaxZ = hoDetIdAssociator_->volume().maxZ();
195  double minR = ecalDetIdAssociator_->volume().minR();
198  cachedTrajectory_.setMaxHOLength(HOmaxZ * 2.);
201 
202  if (parameters.useMuon) {
203  double maxR = muonDetIdAssociator_->volume().maxR();
204  double maxZ = muonDetIdAssociator_->volume().maxZ();
207  } else {
210  }
211 
212  // If track extras exist and outerState is before HO maximum, then use outerState
213  if (outerState) {
214  if (outerState->position().perp() < HOmaxR && fabs(outerState->position().z()) < HOmaxZ) {
215  LogTrace("TrackAssociator") << "Using outerState as trackOrigin at Rho=" << outerState->position().perp()
216  << " Z=" << outerState->position().z() << "\n";
217  trackOrigin = SteppingHelixStateInfo(*outerState);
218  } else if (innerState) {
219  LogTrace("TrackAssociator") << "Using innerState as trackOrigin at Rho=" << innerState->position().perp()
220  << " Z=" << innerState->position().z() << "\n";
221  trackOrigin = SteppingHelixStateInfo(*innerState);
222  }
223  }
224 
225  if (trackOrigin.momentum().mag() == 0)
226  return info;
227  if (edm::isNotFinite(trackOrigin.momentum().x()) or edm::isNotFinite(trackOrigin.momentum().y()) or
228  edm::isNotFinite(trackOrigin.momentum().z()))
229  return info;
230  if (!cachedTrajectory_.propagateAll(trackOrigin))
231  return info;
232 
233  // get trajectory in calorimeters
238 
242 
246 
247  if (parameters.useEcal)
248  fillEcal(iEvent, info, parameters);
249  if (parameters.useCalo)
250  fillCaloTowers(iEvent, info, parameters);
251  if (parameters.useHcal)
252  fillHcal(iEvent, info, parameters);
253  if (parameters.useHO)
254  fillHO(iEvent, info, parameters);
255  if (parameters.usePreshower)
256  fillPreshower(iEvent, info, parameters);
257  if (parameters.useMuon)
258  fillMuon(iEvent, info, parameters);
259  if (parameters.truthMatch)
260  fillCaloTruth(iEvent, info, parameters);
261 
262  return info;
263 }
SteppingHelixStateInfo getStateAtHO()
math::XYZPoint trkGlobPosAtHO
static const TGPicture * info(bool iBackgroundIsBlack)
T perp() const
Definition: PV3DBase.h:69
void findPreshowerTrajectory(const FiducialVolume &)
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
void setMinDetectorLength(float l=0.)
void setMinDetectorRadius(float r=0.)
void setCaloGeometry(edm::ESHandle< CaloGeometry > geometry)
double maxZ(bool withTolerance=true) const
void setMaxHOLength(float l=2200.)
void fillHcal(const edm::Event &, TrackDetMatchInfo &, const AssociatorParameters &)
void findHcalTrajectory(const FiducialVolume &)
double minZ(bool withTolerance=true) const
GlobalVector momentum() const
edm::ESHandle< DetIdAssociator > hcalDetIdAssociator_
math::XYZPoint trkGlobPosAtHcal
FreeTrajectoryState stateAtIP
track info
void fillCaloTowers(const edm::Event &, TrackDetMatchInfo &, const AssociatorParameters &)
void fillCaloTruth(const edm::Event &, TrackDetMatchInfo &, const AssociatorParameters &)
GlobalVector trkMomAtHO
bool propagateAll(const SteppingHelixStateInfo &initialState)
propagate through the whole detector, returns true if successful
GlobalPoint position() const
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
T z() const
Definition: PV3DBase.h:61
void setMaxHORadius(float r=800.)
edm::ESHandle< CaloGeometry > theCaloGeometry_
edm::ESHandle< DetIdAssociator > ecalDetIdAssociator_
void fillPreshower(const edm::Event &iEvent, TrackDetMatchInfo &info, const AssociatorParameters &)
#define LogTrace(id)
double minR(bool withTolerance=true) const
GlobalPoint position() const
math::XYZPoint getPoint(const GlobalPoint &point)
GlobalVector trkMomAtEcal
edm::ESHandle< DetIdAssociator > hoDetIdAssociator_
void fillMuon(const edm::Event &, TrackDetMatchInfo &, const AssociatorParameters &)
void findEcalTrajectory(const FiducialVolume &)
void init(const edm::EventSetup &)
GlobalVector trkMomAtHcal
edm::ESHandle< DetIdAssociator > muonDetIdAssociator_
edm::ESHandle< DetIdAssociator > preshowerDetIdAssociator_
void fillEcal(const edm::Event &, TrackDetMatchInfo &, const AssociatorParameters &)
SteppingHelixStateInfo getStateAtEcal()
void findHOTrajectory(const FiducialVolume &)
math::XYZPoint trkGlobPosAtEcal
Track position at different parts of the calorimeter.
const FiducialVolume & volume() const
get active detector volume
void setStateAtIP(const SteppingHelixStateInfo &state)
void fillHO(const edm::Event &, TrackDetMatchInfo &, const AssociatorParameters &)
void setMaxDetectorLength(float l=2200.)
double maxR(bool withTolerance=true) const
SteppingHelixStateInfo getStateAtHcal()
void setMaxDetectorRadius(float r=800.)
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 1007 of file TrackDetectorAssociator.cc.

References Calorimetry_cff::bField, Exception, reco::Track::extra(), edm::EventSetup::get(), trajectoryStateTransform::initialFreeState(), trajectoryStateTransform::innerFreeState(), reco::Track::innerMomentum(), reco::Track::innerPosition(), edm::Ref< C, T, F >::isNull(), LogTrace, trajectoryStateTransform::outerFreeState(), reco::Track::outerMomentum(), reco::Track::outerPosition(), PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), FreeTrajectoryState::position(), mps_fire::result, and PV3DBase< T, PVType, FrameType >::z().

1011  {
1012  double currentStepSize = cachedTrajectory_.getPropagationStep();
1013 
1015  iSetup.get<IdealMagneticFieldRecord>().get(bField);
1016 
1017  if (track.extra().isNull()) {
1018  if (direction != InsideOut)
1019  throw cms::Exception("FatalError") << "No TrackExtra information is available and association is done with "
1020  "something else than InsideOut track.\n"
1021  << "Either change the parameter or provide needed data!\n";
1022  LogTrace("TrackAssociator") << "Track Extras not found\n";
1023  FreeTrajectoryState initialState = trajectoryStateTransform::initialFreeState(track, &*bField);
1024  return associate(iEvent, iSetup, parameters, &initialState); // 5th argument is null pointer
1025  }
1026 
1027  LogTrace("TrackAssociator") << "Track Extras found\n";
1028  FreeTrajectoryState innerState = trajectoryStateTransform::innerFreeState(track, &*bField);
1029  FreeTrajectoryState outerState = trajectoryStateTransform::outerFreeState(track, &*bField);
1030  FreeTrajectoryState referenceState = trajectoryStateTransform::initialFreeState(track, &*bField);
1031 
1032  LogTrace("TrackAssociator") << "inner track state (rho, z, phi):" << track.innerPosition().Rho() << ", "
1033  << track.innerPosition().z() << ", " << track.innerPosition().phi() << "\n";
1034  LogTrace("TrackAssociator") << "innerFreeState (rho, z, phi):" << innerState.position().perp() << ", "
1035  << innerState.position().z() << ", " << innerState.position().phi() << "\n";
1036 
1037  LogTrace("TrackAssociator") << "outer track state (rho, z, phi):" << track.outerPosition().Rho() << ", "
1038  << track.outerPosition().z() << ", " << track.outerPosition().phi() << "\n";
1039  LogTrace("TrackAssociator") << "outerFreeState (rho, z, phi):" << outerState.position().perp() << ", "
1040  << outerState.position().z() << ", " << outerState.position().phi() << "\n";
1041 
1042  // InsideOut first
1043  if (crossedIP(track)) {
1044  switch (direction) {
1045  case InsideOut:
1046  case Any:
1047  return associate(iEvent, iSetup, parameters, &referenceState, &outerState);
1048  break;
1049  case OutsideIn: {
1050  cachedTrajectory_.setPropagationStep(-fabs(currentStepSize));
1051  TrackDetMatchInfo result = associate(iEvent, iSetup, parameters, &innerState, &referenceState);
1052  cachedTrajectory_.setPropagationStep(currentStepSize);
1053  return result;
1054  break;
1055  }
1056  }
1057  } else {
1058  switch (direction) {
1059  case InsideOut:
1060  return associate(iEvent, iSetup, parameters, &innerState, &outerState);
1061  break;
1062  case OutsideIn: {
1063  cachedTrajectory_.setPropagationStep(-fabs(currentStepSize));
1064  TrackDetMatchInfo result = associate(iEvent, iSetup, parameters, &outerState, &innerState);
1065  cachedTrajectory_.setPropagationStep(currentStepSize);
1066  return result;
1067  break;
1068  }
1069  case Any: {
1070  // check if we deal with clear outside-in case
1071  if (track.innerPosition().Dot(track.innerMomentum()) < 0 &&
1072  track.outerPosition().Dot(track.outerMomentum()) < 0) {
1073  cachedTrajectory_.setPropagationStep(-fabs(currentStepSize));
1075  if (track.innerPosition().R() < track.outerPosition().R())
1076  result = associate(iEvent, iSetup, parameters, &innerState, &outerState);
1077  else
1078  result = associate(iEvent, iSetup, parameters, &outerState, &innerState);
1079  cachedTrajectory_.setPropagationStep(currentStepSize);
1080  return result;
1081  }
1082  }
1083  }
1084  }
1085 
1086  // all other cases
1087  return associate(iEvent, iSetup, parameters, &innerState, &outerState);
1088 }
float getPropagationStep() const
T perp() const
Definition: PV3DBase.h:69
static bool crossedIP(const reco::Track &track)
const TrackExtraRef & extra() const
reference to "extra" object
Definition: Track.h:139
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
void setPropagationStep(float s=20.)
const math::XYZPoint & outerPosition() const
position of the outermost hit
Definition: Track.h:62
const math::XYZPoint & innerPosition() const
position of the innermost hit
Definition: Track.h:56
T z() const
Definition: PV3DBase.h:61
bool isNull() const
Checks for null.
Definition: Ref.h:235
#define LogTrace(id)
GlobalPoint position() const
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
Definition: Track.h:65
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
Definition: Track.h:59
T get() const
Definition: EventSetup.h:73
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)
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 1090 of file TrackDetectorAssociator.cc.

1094  {
1095  return associate(iEvent, iSetup, getFreeTrajectoryState(iSetup, track, vertex), parameters);
1096 }
static FreeTrajectoryState getFreeTrajectoryState(const edm::EventSetup &, const reco::Track &)
get FreeTrajectoryState from different track representations
TrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const AssociatorParameters &)
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 1098 of file TrackDetectorAssociator.cc.

1103  {
1104  return associate(iEvent, iSetup, getFreeTrajectoryState(iSetup, momentum, vertex, charge), parameters);
1105 }
static FreeTrajectoryState getFreeTrajectoryState(const edm::EventSetup &, const reco::Track &)
get FreeTrajectoryState from different track representations
TrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const AssociatorParameters &)
bool TrackDetectorAssociator::crossedIP ( const reco::Track track)
static

Definition at line 1107 of file TrackDetectorAssociator.cc.

References reco::Track::innerMomentum(), reco::Track::innerPosition(), reco::Track::outerMomentum(), and reco::Track::outerPosition().

Referenced by getCachedTrajector(), and MuonIdProducer::produce().

1107  {
1108  bool crossed = true;
1109  crossed &= (track.innerPosition().rho() > 3); // something close to active volume
1110  crossed &= (track.outerPosition().rho() > 3); // something close to active volume
1111  crossed &=
1112  ((track.innerPosition().x() * track.innerMomentum().x() + track.innerPosition().y() * track.innerMomentum().y() <
1113  0) !=
1114  (track.outerPosition().x() * track.outerMomentum().x() + track.outerPosition().y() * track.outerMomentum().y() <
1115  0));
1116  return crossed;
1117 }
const math::XYZPoint & outerPosition() const
position of the outermost hit
Definition: Track.h:62
const math::XYZPoint & innerPosition() const
position of the innermost hit
Definition: Track.h:56
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
Definition: Track.h:65
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
Definition: Track.h:59
void TrackDetectorAssociator::fillCaloTowers ( const edm::Event iEvent,
TrackDetMatchInfo info,
const AssociatorParameters parameters 
)
private

Definition at line 339 of file TrackDetectorAssociator.cc.

References TrackAssociatorParameters::accountForTrajectoryChangeCalo, eleHcalExtractorBlocks_cff::caloTowers, TrackAssociatorParameters::caloTowersToken, TrackDetMatchInfo::crossedTowerIds, TrackDetMatchInfo::crossedTowers, HLT_2018_cff::distance, TrackAssociatorParameters::dRHcal, TrackAssociatorParameters::dRHcalPreselection, edm::Event::getByToken(), CachedTrajectory::IpToHcal, TrackDetMatchInfo::isGoodCalo, edm::HandleBase::isValid(), LogTrace, hgcalTowerProducer_cfi::tower, and TrackDetMatchInfo::towers.

Referenced by getCachedTrajector().

341  {
342  // use ECAL and HCAL trajectories to match a tower. (HO isn't used for matching).
343  std::vector<GlobalPoint> trajectory;
344  const std::vector<SteppingHelixStateInfo>& ecalTrajectoryStates = cachedTrajectory_.getEcalTrajectory();
345  const std::vector<SteppingHelixStateInfo>& hcalTrajectoryStates = cachedTrajectory_.getHcalTrajectory();
346  for (std::vector<SteppingHelixStateInfo>::const_iterator itr = ecalTrajectoryStates.begin();
347  itr != ecalTrajectoryStates.end();
348  itr++)
349  trajectory.push_back(itr->position());
350  for (std::vector<SteppingHelixStateInfo>::const_iterator itr = hcalTrajectoryStates.begin();
351  itr != hcalTrajectoryStates.end();
352  itr++)
353  trajectory.push_back(itr->position());
354 
355  if (trajectory.empty()) {
356  LogTrace("TrackAssociator") << "HCAL trajectory is empty; moving on\n";
357  info.isGoodCalo = false;
358  return;
359  }
360  info.isGoodCalo = true;
361 
362  // find crossed CaloTowers
364  iEvent.getByToken(parameters.caloTowersToken, caloTowers);
365  if (!caloTowers.isValid())
366  throw cms::Exception("FatalError") << "Unable to find CaloTowers in event!\n";
367 
368  std::set<DetId> caloTowerIdsInRegion;
369  if (parameters.accountForTrajectoryChangeCalo) {
370  // get trajectory change with respect to initial state
371  DetIdAssociator::MapRange mapRange =
373  caloTowerIdsInRegion = caloDetIdAssociator_->getDetIdsCloseToAPoint(trajectory[0], mapRange);
374  } else
375  caloTowerIdsInRegion = caloDetIdAssociator_->getDetIdsCloseToAPoint(trajectory[0], parameters.dRHcalPreselection);
376 
377  LogTrace("TrackAssociator") << "Towers in the region: " << caloTowerIdsInRegion.size();
378 
379  auto caloTowerIdsInAConeBegin = caloTowerIdsInRegion.begin();
380  auto caloTowerIdsInAConeEnd = caloTowerIdsInRegion.end();
381  std::set<DetId> caloTowerIdsInAConeTmp;
383  caloTowerIdsInAConeTmp =
384  caloDetIdAssociator_->getDetIdsInACone(caloTowerIdsInRegion, trajectory, parameters.dRHcal);
385  caloTowerIdsInAConeBegin = caloTowerIdsInAConeTmp.begin();
386  caloTowerIdsInAConeEnd = caloTowerIdsInAConeTmp.end();
387  }
388  LogTrace("TrackAssociator") << "Towers in the cone: "
389  << std::distance(caloTowerIdsInAConeBegin, caloTowerIdsInAConeEnd);
390 
391  info.crossedTowerIds = caloDetIdAssociator_->getCrossedDetIds(caloTowerIdsInRegion, trajectory);
392  const std::vector<DetId>& crossedCaloTowerIds = info.crossedTowerIds;
393  LogTrace("TrackAssociator") << "Towers crossed: " << crossedCaloTowerIds.size();
394 
395  // add CaloTowers
396  for (std::vector<DetId>::const_iterator itr = crossedCaloTowerIds.begin(); itr != crossedCaloTowerIds.end(); itr++) {
397  CaloTowerCollection::const_iterator tower = (*caloTowers).find(*itr);
398  if (tower != (*caloTowers).end())
399  info.crossedTowers.push_back(&*tower);
400  else
401  LogTrace("TrackAssociator") << "Crossed CaloTower is not found for DetId: " << (*itr).rawId();
402  }
403 
404  for (std::set<DetId>::const_iterator itr = caloTowerIdsInAConeBegin; itr != caloTowerIdsInAConeEnd; itr++) {
405  CaloTowerCollection::const_iterator tower = (*caloTowers).find(*itr);
406  if (tower != (*caloTowers).end())
407  info.towers.push_back(&*tower);
408  else
409  LogTrace("TrackAssociator") << "CaloTower from the cone is not found for DetId: " << (*itr).rawId();
410  }
411 }
virtual std::set< DetId > getDetIdsInACone(const std::set< DetId > &, const std::vector< GlobalPoint > &trajectory, const double dR) const
std::vector< const CaloTower * > crossedTowers
std::vector< const CaloTower * > towers
std::vector< DetId > crossedTowerIds
const std::vector< SteppingHelixStateInfo > & getHcalTrajectory() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
virtual bool selectAllInACone(const double dR) const
helper to see if getDetIdsInACone is useful
std::vector< CaloTower >::const_iterator const_iterator
virtual std::vector< DetId > getCrossedDetIds(const std::set< DetId > &, const std::vector< GlobalPoint > &trajectory) const
const std::vector< SteppingHelixStateInfo > & getEcalTrajectory() const
std::pair< float, float > trajectoryDelta(TrajectorType)
bool isValid() const
Definition: HandleBase.h:70
#define LogTrace(id)
DetIdAssociator::MapRange getMapRange(const std::pair< float, float > &delta, const float dR)
virtual std::set< DetId > getDetIdsCloseToAPoint(const GlobalPoint &, const int iN=0) const
edm::ESHandle< DetIdAssociator > caloDetIdAssociator_
void TrackDetectorAssociator::fillCaloTruth ( const edm::Event iEvent,
TrackDetMatchInfo info,
const AssociatorParameters parameters 
)
private

Definition at line 940 of file TrackDetectorAssociator.cc.

References electronAnalyzer_cfi::DeltaR, TrackDetMatchInfo::ecalTrueEnergy, SimTrack::genpartIndex(), edm::Event::getByToken(), TrackDetMatchInfo::hcalTrueEnergy, TrackDetMatchInfo::hcalTrueEnergyCorrected, edm::HandleBase::isValid(), FreeTrajectoryState::momentum(), TrackAssociatorParameters::simEcalHitsEBToken, TrackAssociatorParameters::simEcalHitsEEToken, TrackAssociatorParameters::simHcalHitsToken, muonSimHitMatcherPSet::simTrack, TrackDetMatchInfo::simTrack, TrackCandidateProducer_cfi::simTracks, TrackAssociatorParameters::simTracksToken, HGCalValidator_cfi::simVertices, TrackAssociatorParameters::simVerticesToken, TrackDetMatchInfo::stateAtIP, TrackDetMatchInfo::trkGlobPosAtHcal, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by getCachedTrajector().

942  {
943  // get list of simulated tracks and their vertices
944  using namespace edm;
946  iEvent.getByToken(parameters.simTracksToken, simTracks);
947  if (!simTracks.isValid())
948  throw cms::Exception("FatalError") << "No simulated tracks found\n";
949 
951  iEvent.getByToken(parameters.simVerticesToken, simVertices);
952  if (!simVertices.isValid())
953  throw cms::Exception("FatalError") << "No simulated vertices found\n";
954 
955  // get sim calo hits
956  Handle<PCaloHitContainer> simEcalHitsEB;
957  iEvent.getByToken(parameters.simEcalHitsEBToken, simEcalHitsEB);
958  if (!simEcalHitsEB.isValid())
959  throw cms::Exception("FatalError") << "No simulated ECAL EB hits found\n";
960 
961  Handle<PCaloHitContainer> simEcalHitsEE;
962  iEvent.getByToken(parameters.simEcalHitsEEToken, simEcalHitsEE);
963  if (!simEcalHitsEE.isValid())
964  throw cms::Exception("FatalError") << "No simulated ECAL EE hits found\n";
965 
966  Handle<PCaloHitContainer> simHcalHits;
967  iEvent.getByToken(parameters.simHcalHitsToken, simHcalHits);
968  if (!simHcalHits.isValid())
969  throw cms::Exception("FatalError") << "No simulated HCAL hits found\n";
970 
971  // find truth partner
972  SimTrackContainer::const_iterator simTrack = simTracks->begin();
973  for (; simTrack != simTracks->end(); ++simTrack) {
974  math::XYZVector simP3(simTrack->momentum().x(), simTrack->momentum().y(), simTrack->momentum().z());
975  math::XYZVector recoP3(info.stateAtIP.momentum().x(), info.stateAtIP.momentum().y(), info.stateAtIP.momentum().z());
976  if (ROOT::Math::VectorUtil::DeltaR(recoP3, simP3) < 0.1)
977  break;
978  }
979  if (simTrack != simTracks->end()) {
980  info.simTrack = &(*simTrack);
981  double ecalTrueEnergy(0);
982  double hcalTrueEnergy(0);
983 
984  // loop over calo hits
985  for (PCaloHitContainer::const_iterator hit = simEcalHitsEB->begin(); hit != simEcalHitsEB->end(); ++hit)
986  if (hit->geantTrackId() == info.simTrack->genpartIndex())
987  ecalTrueEnergy += hit->energy();
988 
989  for (PCaloHitContainer::const_iterator hit = simEcalHitsEE->begin(); hit != simEcalHitsEE->end(); ++hit)
990  if (hit->geantTrackId() == info.simTrack->genpartIndex())
991  ecalTrueEnergy += hit->energy();
992 
993  for (PCaloHitContainer::const_iterator hit = simHcalHits->begin(); hit != simHcalHits->end(); ++hit)
994  if (hit->geantTrackId() == info.simTrack->genpartIndex())
995  hcalTrueEnergy += hit->energy();
996 
997  info.ecalTrueEnergy = ecalTrueEnergy;
998  info.hcalTrueEnergy = hcalTrueEnergy;
999  info.hcalTrueEnergyCorrected = hcalTrueEnergy;
1000  if (fabs(info.trkGlobPosAtHcal.eta()) < 1.3)
1001  info.hcalTrueEnergyCorrected = hcalTrueEnergy * 113.2;
1002  else if (fabs(info.trkGlobPosAtHcal.eta()) < 3.0)
1003  info.hcalTrueEnergyCorrected = hcalTrueEnergy * 167.2;
1004  }
1005 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
T y() const
Definition: PV3DBase.h:60
math::XYZPoint trkGlobPosAtHcal
FreeTrajectoryState stateAtIP
track info
T z() const
Definition: PV3DBase.h:61
int genpartIndex() const
index of the corresponding Generator particle in the Event container (-1 if no Genpart) ...
Definition: SimTrack.h:34
bool isValid() const
Definition: HandleBase.h:70
GlobalVector momentum() const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
HLT enums.
T x() const
Definition: PV3DBase.h:59
const SimTrack * simTrack
MC truth info.
void TrackDetectorAssociator::fillEcal ( const edm::Event iEvent,
TrackDetMatchInfo info,
const AssociatorParameters parameters 
)
private

Definition at line 265 of file TrackDetectorAssociator.cc.

References TrackAssociatorParameters::accountForTrajectoryChangeCalo, TrackDetMatchInfo::crossedEcalIds, TrackDetMatchInfo::crossedEcalRecHits, TrackAssociatorParameters::dREcal, TrackAssociatorParameters::dREcalPreselection, filterRecHits_cfi::EBRecHits, TrackAssociatorParameters::EBRecHitsToken, TrackDetMatchInfo::ecalRecHits, filterRecHits_cfi::EERecHits, TrackAssociatorParameters::EERecHitsToken, edm::Event::getByToken(), CachedTrajectory::IpToEcal, TrackDetMatchInfo::isGoodEcal, edm::HandleBase::isValid(), and LogTrace.

Referenced by getCachedTrajector().

267  {
268  const std::vector<SteppingHelixStateInfo>& trajectoryStates = cachedTrajectory_.getEcalTrajectory();
269 
270  for (std::vector<SteppingHelixStateInfo>::const_iterator itr = trajectoryStates.begin();
271  itr != trajectoryStates.end();
272  itr++)
273  LogTrace("TrackAssociator") << "ECAL trajectory point (rho, z, phi): " << itr->position().perp() << ", "
274  << itr->position().z() << ", " << itr->position().phi();
275 
276  std::vector<GlobalPoint> coreTrajectory;
277  for (std::vector<SteppingHelixStateInfo>::const_iterator itr = trajectoryStates.begin();
278  itr != trajectoryStates.end();
279  itr++)
280  coreTrajectory.push_back(itr->position());
281 
282  if (coreTrajectory.empty()) {
283  LogTrace("TrackAssociator") << "ECAL track trajectory is empty; moving on\n";
284  info.isGoodEcal = false;
285  return;
286  }
287  info.isGoodEcal = true;
288 
289  // Find ECAL crystals
291  iEvent.getByToken(parameters.EBRecHitsToken, EBRecHits);
292  if (!EBRecHits.isValid())
293  throw cms::Exception("FatalError") << "Unable to find EBRecHitCollection in the event!\n";
294 
296  iEvent.getByToken(parameters.EERecHitsToken, EERecHits);
297  if (!EERecHits.isValid())
298  throw cms::Exception("FatalError") << "Unable to find EERecHitCollection in event!\n";
299 
300  std::set<DetId> ecalIdsInRegion;
301  if (parameters.accountForTrajectoryChangeCalo) {
302  // get trajectory change with respect to initial state
303  DetIdAssociator::MapRange mapRange =
305  ecalIdsInRegion = ecalDetIdAssociator_->getDetIdsCloseToAPoint(coreTrajectory[0], mapRange);
306  } else
307  ecalIdsInRegion = ecalDetIdAssociator_->getDetIdsCloseToAPoint(coreTrajectory[0], parameters.dREcalPreselection);
308  LogTrace("TrackAssociator") << "ECAL hits in the region: " << ecalIdsInRegion.size();
309  if (parameters.dREcalPreselection > parameters.dREcal)
310  ecalIdsInRegion = ecalDetIdAssociator_->getDetIdsInACone(ecalIdsInRegion, coreTrajectory, parameters.dREcal);
311  LogTrace("TrackAssociator") << "ECAL hits in the cone: " << ecalIdsInRegion.size();
312  info.crossedEcalIds = ecalDetIdAssociator_->getCrossedDetIds(ecalIdsInRegion, coreTrajectory);
313  const std::vector<DetId>& crossedEcalIds = info.crossedEcalIds;
314  LogTrace("TrackAssociator") << "ECAL crossed hits " << crossedEcalIds.size();
315 
316  // add EcalRecHits
317  for (std::vector<DetId>::const_iterator itr = crossedEcalIds.begin(); itr != crossedEcalIds.end(); itr++) {
318  std::vector<EcalRecHit>::const_iterator ebHit = (*EBRecHits).find(*itr);
319  std::vector<EcalRecHit>::const_iterator eeHit = (*EERecHits).find(*itr);
320  if (ebHit != (*EBRecHits).end())
321  info.crossedEcalRecHits.push_back(&*ebHit);
322  else if (eeHit != (*EERecHits).end())
323  info.crossedEcalRecHits.push_back(&*eeHit);
324  else
325  LogTrace("TrackAssociator") << "Crossed EcalRecHit is not found for DetId: " << itr->rawId();
326  }
327  for (std::set<DetId>::const_iterator itr = ecalIdsInRegion.begin(); itr != ecalIdsInRegion.end(); itr++) {
328  std::vector<EcalRecHit>::const_iterator ebHit = (*EBRecHits).find(*itr);
329  std::vector<EcalRecHit>::const_iterator eeHit = (*EERecHits).find(*itr);
330  if (ebHit != (*EBRecHits).end())
331  info.ecalRecHits.push_back(&*ebHit);
332  else if (eeHit != (*EERecHits).end())
333  info.ecalRecHits.push_back(&*eeHit);
334  else
335  LogTrace("TrackAssociator") << "EcalRecHit from the cone is not found for DetId: " << itr->rawId();
336  }
337 }
virtual std::set< DetId > getDetIdsInACone(const std::set< DetId > &, const std::vector< GlobalPoint > &trajectory, const double dR) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
std::vector< const EcalRecHit * > ecalRecHits
hits in the cone
std::vector< DetId > crossedEcalIds
virtual std::vector< DetId > getCrossedDetIds(const std::set< DetId > &, const std::vector< GlobalPoint > &trajectory) const
std::vector< const EcalRecHit * > crossedEcalRecHits
hits in detector elements crossed by a track
const std::vector< SteppingHelixStateInfo > & getEcalTrajectory() const
edm::ESHandle< DetIdAssociator > ecalDetIdAssociator_
std::pair< float, float > trajectoryDelta(TrajectorType)
bool isValid() const
Definition: HandleBase.h:70
#define LogTrace(id)
DetIdAssociator::MapRange getMapRange(const std::pair< float, float > &delta, const float dR)
virtual std::set< DetId > getDetIdsCloseToAPoint(const GlobalPoint &, const int iN=0) const
void TrackDetectorAssociator::fillHcal ( const edm::Event iEvent,
TrackDetMatchInfo info,
const AssociatorParameters parameters 
)
private

Definition at line 436 of file TrackDetectorAssociator.cc.

References TrackAssociatorParameters::accountForTrajectoryChangeCalo, universalConfigTemplate::collection, TrackDetMatchInfo::crossedHcalIds, TrackDetMatchInfo::crossedHcalRecHits, HLT_2018_cff::distance, TrackAssociatorParameters::dRHcal, TrackAssociatorParameters::dRHcalPreselection, edm::Event::getByToken(), TrackAssociatorParameters::HBHEcollToken, TrackDetMatchInfo::hcalRecHits, DetIdInfo::info(), CachedTrajectory::IpToHcal, TrackDetMatchInfo::isGoodHcal, edm::HandleBase::isValid(), and LogTrace.

Referenced by getCachedTrajector().

438  {
439  const std::vector<SteppingHelixStateInfo>& trajectoryStates = cachedTrajectory_.getHcalTrajectory();
440 
441  std::vector<GlobalPoint> coreTrajectory;
442  for (std::vector<SteppingHelixStateInfo>::const_iterator itr = trajectoryStates.begin();
443  itr != trajectoryStates.end();
444  itr++)
445  coreTrajectory.push_back(itr->position());
446 
447  if (coreTrajectory.empty()) {
448  LogTrace("TrackAssociator") << "HCAL trajectory is empty; moving on\n";
449  info.isGoodHcal = false;
450  return;
451  }
452  info.isGoodHcal = true;
453 
454  // find crossed Hcals
456  iEvent.getByToken(parameters.HBHEcollToken, collection);
457  if (!collection.isValid())
458  throw cms::Exception("FatalError") << "Unable to find HBHERecHits in event!\n";
459 
460  std::set<DetId> idsInRegion;
461  if (parameters.accountForTrajectoryChangeCalo) {
462  // get trajectory change with respect to initial state
463  DetIdAssociator::MapRange mapRange =
465  idsInRegion = hcalDetIdAssociator_->getDetIdsCloseToAPoint(coreTrajectory[0], mapRange);
466  } else
467  idsInRegion = hcalDetIdAssociator_->getDetIdsCloseToAPoint(coreTrajectory[0], parameters.dRHcalPreselection);
468 
469  LogTrace("TrackAssociator") << "HCAL hits in the region: " << idsInRegion.size() << "\n"
470  << DetIdInfo::info(idsInRegion, nullptr);
471 
472  auto idsInAConeBegin = idsInRegion.begin();
473  auto idsInAConeEnd = idsInRegion.end();
474  std::set<DetId> idsInAConeTmp;
476  idsInAConeTmp = hcalDetIdAssociator_->getDetIdsInACone(idsInRegion, coreTrajectory, parameters.dRHcal);
477  idsInAConeBegin = idsInAConeTmp.begin();
478  idsInAConeEnd = idsInAConeTmp.end();
479  }
480  LogTrace("TrackAssociator") << "HCAL hits in the cone: " << std::distance(idsInAConeBegin, idsInAConeEnd) << "\n"
481  << DetIdInfo::info(std::set<DetId>(idsInAConeBegin, idsInAConeEnd), nullptr);
482  info.crossedHcalIds = hcalDetIdAssociator_->getCrossedDetIds(idsInRegion, coreTrajectory);
483  const std::vector<DetId>& crossedIds = info.crossedHcalIds;
484  LogTrace("TrackAssociator") << "HCAL hits crossed: " << crossedIds.size() << "\n"
485  << DetIdInfo::info(crossedIds, nullptr);
486 
487  // add Hcal
488  for (std::vector<DetId>::const_iterator itr = crossedIds.begin(); itr != crossedIds.end(); itr++) {
489  HBHERecHitCollection::const_iterator hit = (*collection).find(*itr);
490  if (hit != (*collection).end())
491  info.crossedHcalRecHits.push_back(&*hit);
492  else
493  LogTrace("TrackAssociator") << "Crossed HBHERecHit is not found for DetId: " << itr->rawId();
494  }
495  for (std::set<DetId>::const_iterator itr = idsInAConeBegin; itr != idsInAConeEnd; itr++) {
496  HBHERecHitCollection::const_iterator hit = (*collection).find(*itr);
497  if (hit != (*collection).end())
498  info.hcalRecHits.push_back(&*hit);
499  else
500  LogTrace("TrackAssociator") << "HBHERecHit from the cone is not found for DetId: " << itr->rawId();
501  }
502 }
virtual std::set< DetId > getDetIdsInACone(const std::set< DetId > &, const std::vector< GlobalPoint > &trajectory, const double dR) const
std::vector< const HBHERecHit * > crossedHcalRecHits
const std::vector< SteppingHelixStateInfo > & getHcalTrajectory() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
virtual bool selectAllInACone(const double dR) const
helper to see if getDetIdsInACone is useful
std::vector< T >::const_iterator const_iterator
virtual std::vector< DetId > getCrossedDetIds(const std::set< DetId > &, const std::vector< GlobalPoint > &trajectory) const
std::vector< DetId > crossedHcalIds
edm::ESHandle< DetIdAssociator > hcalDetIdAssociator_
std::vector< const HBHERecHit * > hcalRecHits
std::pair< float, float > trajectoryDelta(TrajectorType)
bool isValid() const
Definition: HandleBase.h:70
#define LogTrace(id)
static std::string info(const DetId &, const TrackerTopology *tTopo)
Definition: DetIdInfo.cc:25
DetIdAssociator::MapRange getMapRange(const std::pair< float, float > &delta, const float dR)
virtual std::set< DetId > getDetIdsCloseToAPoint(const GlobalPoint &, const int iN=0) const
void TrackDetectorAssociator::fillHO ( const edm::Event iEvent,
TrackDetMatchInfo info,
const AssociatorParameters parameters 
)
private

Definition at line 504 of file TrackDetectorAssociator.cc.

References TrackAssociatorParameters::accountForTrajectoryChangeCalo, universalConfigTemplate::collection, TrackDetMatchInfo::crossedHOIds, TrackDetMatchInfo::crossedHORecHits, HLT_2018_cff::distance, TrackAssociatorParameters::dRHcal, TrackAssociatorParameters::dRHcalPreselection, edm::Event::getByToken(), TrackAssociatorParameters::HOcollToken, TrackDetMatchInfo::hoRecHits, CachedTrajectory::IpToHO, TrackDetMatchInfo::isGoodHO, edm::HandleBase::isValid(), and LogTrace.

Referenced by getCachedTrajector().

506  {
507  const std::vector<SteppingHelixStateInfo>& trajectoryStates = cachedTrajectory_.getHOTrajectory();
508 
509  std::vector<GlobalPoint> coreTrajectory;
510  for (std::vector<SteppingHelixStateInfo>::const_iterator itr = trajectoryStates.begin();
511  itr != trajectoryStates.end();
512  itr++)
513  coreTrajectory.push_back(itr->position());
514 
515  if (coreTrajectory.empty()) {
516  LogTrace("TrackAssociator") << "HO trajectory is empty; moving on\n";
517  info.isGoodHO = false;
518  return;
519  }
520  info.isGoodHO = true;
521 
522  // find crossed HOs
524  iEvent.getByToken(parameters.HOcollToken, collection);
525  if (!collection.isValid())
526  throw cms::Exception("FatalError") << "Unable to find HORecHits in event!\n";
527 
528  std::set<DetId> idsInRegion;
529  if (parameters.accountForTrajectoryChangeCalo) {
530  // get trajectory change with respect to initial state
531  DetIdAssociator::MapRange mapRange =
533  idsInRegion = hoDetIdAssociator_->getDetIdsCloseToAPoint(coreTrajectory[0], mapRange);
534  } else
535  idsInRegion = hoDetIdAssociator_->getDetIdsCloseToAPoint(coreTrajectory[0], parameters.dRHcalPreselection);
536 
537  LogTrace("TrackAssociator") << "idsInRegion.size(): " << idsInRegion.size();
538 
539  auto idsInAConeBegin = idsInRegion.begin();
540  auto idsInAConeEnd = idsInRegion.end();
541  std::set<DetId> idsInAConeTmp;
543  idsInAConeTmp = hoDetIdAssociator_->getDetIdsInACone(idsInRegion, coreTrajectory, parameters.dRHcal);
544  idsInAConeBegin = idsInAConeTmp.begin();
545  idsInAConeEnd = idsInAConeTmp.end();
546  }
547  LogTrace("TrackAssociator") << "idsInACone.size(): " << std::distance(idsInAConeBegin, idsInAConeEnd);
548  info.crossedHOIds = hoDetIdAssociator_->getCrossedDetIds(idsInRegion, coreTrajectory);
549  const std::vector<DetId>& crossedIds = info.crossedHOIds;
550 
551  // add HO
552  for (std::vector<DetId>::const_iterator itr = crossedIds.begin(); itr != crossedIds.end(); itr++) {
553  HORecHitCollection::const_iterator hit = (*collection).find(*itr);
554  if (hit != (*collection).end())
555  info.crossedHORecHits.push_back(&*hit);
556  else
557  LogTrace("TrackAssociator") << "Crossed HORecHit is not found for DetId: " << itr->rawId();
558  }
559 
560  for (std::set<DetId>::const_iterator itr = idsInAConeBegin; itr != idsInAConeEnd; itr++) {
561  HORecHitCollection::const_iterator hit = (*collection).find(*itr);
562  if (hit != (*collection).end())
563  info.hoRecHits.push_back(&*hit);
564  else
565  LogTrace("TrackAssociator") << "HORecHit from the cone is not found for DetId: " << itr->rawId();
566  }
567 }
virtual std::set< DetId > getDetIdsInACone(const std::set< DetId > &, const std::vector< GlobalPoint > &trajectory, const double dR) const
const std::vector< SteppingHelixStateInfo > & getHOTrajectory() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
virtual bool selectAllInACone(const double dR) const
helper to see if getDetIdsInACone is useful
std::vector< T >::const_iterator const_iterator
virtual std::vector< DetId > getCrossedDetIds(const std::set< DetId > &, const std::vector< GlobalPoint > &trajectory) const
std::vector< DetId > crossedHOIds
std::pair< float, float > trajectoryDelta(TrajectorType)
bool isValid() const
Definition: HandleBase.h:70
#define LogTrace(id)
edm::ESHandle< DetIdAssociator > hoDetIdAssociator_
DetIdAssociator::MapRange getMapRange(const std::pair< float, float > &delta, const float dR)
std::vector< const HORecHit * > crossedHORecHits
virtual std::set< DetId > getDetIdsCloseToAPoint(const GlobalPoint &, const int iN=0) const
std::vector< const HORecHit * > hoRecHits
void TrackDetectorAssociator::fillMuon ( const edm::Event iEvent,
TrackDetMatchInfo info,
const AssociatorParameters parameters 
)
private

Definition at line 745 of file TrackDetectorAssociator.cc.

References relativeConstraints::chamber, TrackDetMatchInfo::chambers, dtChamberEfficiency_cfi::cscSegments, TrackAssociatorParameters::cscSegmentsToken, TrackAssociatorParameters::dtSegmentsToken, gemSegments_cfi::gemSegments, TrackAssociatorParameters::gemSegmentsToken, edm::Event::getByToken(), edm::HandleBase::isValid(), LogTrace, me0Segments_cfi::me0Segments, TrackAssociatorParameters::me0SegmentsToken, FastTimerService_cff::range, TrackAssociatorParameters::useGEM, and TrackAssociatorParameters::useME0.

Referenced by getCachedTrajector().

747  {
748  // Get the segments from the event
750  iEvent.getByToken(parameters.dtSegmentsToken, dtSegments);
751  if (!dtSegments.isValid())
752  throw cms::Exception("FatalError") << "Unable to find DTRecSegment4DCollection in event!\n";
753 
755  iEvent.getByToken(parameters.cscSegmentsToken, cscSegments);
756  if (!cscSegments.isValid())
757  throw cms::Exception("FatalError") << "Unable to find CSCSegmentCollection in event!\n";
758 
760  if (parameters.useGEM)
761  iEvent.getByToken(parameters.gemSegmentsToken, gemSegments);
763  if (parameters.useME0)
764  iEvent.getByToken(parameters.me0SegmentsToken, me0Segments);
765 
767 
768  // check the map of available segments
769  // if there is no segments in a given direction at all,
770  // then there is no point to fly there.
771  //
772  // MISSING
773  // Possible solution: quick search for presence of segments
774  // for the set of DetIds
775 
776  // get a set of matches corresponding to muon chambers
777  std::vector<TAMuonChamberMatch> matchedChambers;
778  LogTrace("TrackAssociator") << "Trying to Get ChamberMatches" << std::endl;
779  getTAMuonChamberMatches(matchedChambers, parameters);
780  LogTrace("TrackAssociator") << "Chambers matched: " << matchedChambers.size() << "\n";
781 
782  // Iterate over all chamber matches and fill segment matching
783  // info if it's available
784  for (std::vector<TAMuonChamberMatch>::iterator matchedChamber = matchedChambers.begin();
785  matchedChamber != matchedChambers.end();
786  matchedChamber++) {
787  const GeomDet* geomDet = muonDetIdAssociator_->getGeomDet((*matchedChamber).id);
788  // DT chamber
789  if (const DTChamber* chamber = dynamic_cast<const DTChamber*>(geomDet)) {
790  // Get the range for the corresponding segments
791  DTRecSegment4DCollection::range range = dtSegments->get(chamber->id());
792  // Loop over the segments of this chamber
793  for (DTRecSegment4DCollection::const_iterator segment = range.first; segment != range.second; segment++) {
794  if (addTAMuonSegmentMatch(*matchedChamber, &(*segment), parameters)) {
795  matchedChamber->segments.back().dtSegmentRef = DTRecSegment4DRef(dtSegments, segment - dtSegments->begin());
796  }
797  }
798  }
799  // CSC Chamber
800  else if (const CSCChamber* chamber = dynamic_cast<const CSCChamber*>(geomDet)) {
801  // Get the range for the corresponding segments
802  CSCSegmentCollection::range range = cscSegments->get(chamber->id());
803  // Loop over the segments
804  for (CSCSegmentCollection::const_iterator segment = range.first; segment != range.second; segment++) {
805  if (addTAMuonSegmentMatch(*matchedChamber, &(*segment), parameters)) {
806  matchedChamber->segments.back().cscSegmentRef = CSCSegmentRef(cscSegments, segment - cscSegments->begin());
807  }
808  }
809  } else {
810  // GEM Chamber
811  if (parameters.useGEM) {
812  if (const GEMSuperChamber* chamber = dynamic_cast<const GEMSuperChamber*>(geomDet)) {
813  // Get the range for the corresponding segments
814  GEMSegmentCollection::range range = gemSegments->get(chamber->id());
815  // Loop over the segments
816  for (GEMSegmentCollection::const_iterator segment = range.first; segment != range.second; segment++) {
817  if (addTAMuonSegmentMatch(*matchedChamber, &(*segment), parameters)) {
818  matchedChamber->segments.back().gemSegmentRef =
819  GEMSegmentRef(gemSegments, segment - gemSegments->begin());
820  }
821  }
822  }
823  }
824  // ME0 Chamber
825  if (parameters.useME0) {
826  if (const ME0Chamber* chamber = dynamic_cast<const ME0Chamber*>(geomDet)) {
827  // Get the range for the corresponding segments
828  ME0SegmentCollection::range range = me0Segments->get(chamber->id());
829  // Loop over the segments
830  for (ME0SegmentCollection::const_iterator segment = range.first; segment != range.second; segment++) {
831  if (addTAMuonSegmentMatch(*matchedChamber, &(*segment), parameters)) {
832  matchedChamber->segments.back().me0SegmentRef =
833  ME0SegmentRef(me0Segments, segment - me0Segments->begin());
834  }
835  }
836  }
837  }
838  }
839  info.chambers.push_back(*matchedChamber);
840  }
841 }
std::pair< const_iterator, const_iterator > range
iterator range
Definition: RangeMap.h:50
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
edm::Ref< CSCSegmentCollection > CSCSegmentRef
edm::Ref< ME0SegmentCollection > ME0SegmentRef
bool addTAMuonSegmentMatch(TAMuonChamberMatch &, const RecSegment *, const AssociatorParameters &)
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
void getTAMuonChamberMatches(std::vector< TAMuonChamberMatch > &matches, const AssociatorParameters &parameters)
edm::Ref< GEMSegmentCollection > GEMSegmentRef
std::vector< TAMuonChamberMatch > chambers
bool isValid() const
Definition: HandleBase.h:70
#define LogTrace(id)
edm::Ref< DTRecSegment4DCollection > DTRecSegment4DRef
virtual const GeomDet * getGeomDet(const DetId &) const =0
edm::ESHandle< DetIdAssociator > muonDetIdAssociator_
void TrackDetectorAssociator::fillPreshower ( const edm::Event iEvent,
TrackDetMatchInfo info,
const AssociatorParameters parameters 
)
private

Definition at line 413 of file TrackDetectorAssociator.cc.

References TrackDetMatchInfo::crossedPreshowerIds, TrackAssociatorParameters::dRPreshowerPreselection, and LogTrace.

Referenced by getCachedTrajector().

415  {
416  std::vector<GlobalPoint> trajectory;
417  const std::vector<SteppingHelixStateInfo>& trajectoryStates = cachedTrajectory_.getPreshowerTrajectory();
418  for (std::vector<SteppingHelixStateInfo>::const_iterator itr = trajectoryStates.begin();
419  itr != trajectoryStates.end();
420  itr++)
421  trajectory.push_back(itr->position());
422 
423  if (trajectory.empty()) {
424  LogTrace("TrackAssociator") << "Preshower trajectory is empty; moving on\n";
425  return;
426  }
427 
428  std::set<DetId> idsInRegion =
429  preshowerDetIdAssociator_->getDetIdsCloseToAPoint(trajectory[0], parameters.dRPreshowerPreselection);
430 
431  LogTrace("TrackAssociator") << "Number of Preshower Ids in the region: " << idsInRegion.size();
432  info.crossedPreshowerIds = preshowerDetIdAssociator_->getCrossedDetIds(idsInRegion, trajectory);
433  LogTrace("TrackAssociator") << "Number of Preshower Ids in crossed: " << info.crossedPreshowerIds.size();
434 }
std::vector< DetId > crossedPreshowerIds
virtual std::vector< DetId > getCrossedDetIds(const std::set< DetId > &, const std::vector< GlobalPoint > &trajectory) const
const std::vector< SteppingHelixStateInfo > & getPreshowerTrajectory() const
#define LogTrace(id)
edm::ESHandle< DetIdAssociator > preshowerDetIdAssociator_
virtual std::set< DetId > getDetIdsCloseToAPoint(const GlobalPoint &, const int iN=0) const
const CachedTrajectory& TrackDetectorAssociator::getCachedTrajector ( ) const
inline
FreeTrajectoryState TrackDetectorAssociator::getFreeTrajectoryState ( const edm::EventSetup iSetup,
const reco::Track track 
)
static

get FreeTrajectoryState from different track representations

Definition at line 600 of file TrackDetectorAssociator.cc.

References Calorimetry_cff::bField, reco::TrackBase::charge(), MillePedeFileConverter_cfg::e, edm::EventSetup::get(), triggerObjects_cff::id, reco::TrackBase::momentum(), point, and reco::TrackBase::vertex().

Referenced by BetaCalculatorECAL::addInfoToCandidate(), EopTreeWriter::analyze(), spr::chargeIsolation(), spr::chargeIsolationEcal(), spr::chargeIsolationHcal(), spr::coneChargeIsolation(), cms::MuonMETValueMapProducer::determine_deltax_deltay(), getCachedTrajector(), and InterestingTrackEcalDetIdProducer::produce().

601  {
603  iSetup.get<IdealMagneticFieldRecord>().get(bField);
604 
605  GlobalVector vector(track.momentum().x(), track.momentum().y(), track.momentum().z());
606 
607  GlobalPoint point(track.vertex().x(), track.vertex().y(), track.vertex().z());
608 
609  GlobalTrajectoryParameters tPars(point, vector, track.charge(), &*bField);
610 
611  // FIX THIS !!!
612  // need to convert from perigee to global or helix (curvilinear) frame
613  // for now just an arbitrary matrix.
614  ROOT::Math::SMatrixIdentity id;
615  AlgebraicSymMatrix66 covT(id);
616  covT *= 1e-6; // initialize to sigma=1e-3
617  CartesianTrajectoryError tCov(covT);
618 
619  return FreeTrajectoryState(tPars, tCov);
620 }
const Vector & momentum() const
track momentum vector
Definition: TrackBase.h:629
const Point & vertex() const
reference point on the track. This method is DEPRECATED, please use referencePoint() instead ...
Definition: TrackBase.h:641
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepSym< double, 6 > > AlgebraicSymMatrix66
T get() const
Definition: EventSetup.h:73
int charge() const
track electric charge
Definition: TrackBase.h:575
*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
FreeTrajectoryState TrackDetectorAssociator::getFreeTrajectoryState ( const edm::EventSetup iSetup,
const SimTrack track,
const SimVertex vertex 
)
static

Definition at line 569 of file TrackDetectorAssociator.cc.

References funct::abs(), ALCARECOTkAlJpsiMuMu_cff::charge, CoreSimTrack::momentum(), point, CoreSimVertex::position(), and CoreSimTrack::type().

571  {
572  GlobalVector vector(track.momentum().x(), track.momentum().y(), track.momentum().z());
573  GlobalPoint point(vertex.position().x(), vertex.position().y(), vertex.position().z());
574 
575  int charge = track.type() > 0 ? -1 : 1; // lepton convention
576  if (abs(track.type()) == 211 || // pion
577  abs(track.type()) == 321 || // kaon
578  abs(track.type()) == 2212)
579  charge = track.type() < 0 ? -1 : 1;
580  return getFreeTrajectoryState(iSetup, vector, point, charge);
581 }
static FreeTrajectoryState getFreeTrajectoryState(const edm::EventSetup &, const reco::Track &)
get FreeTrajectoryState from different track representations
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const math::XYZTLorentzVectorD & position() const
Definition: CoreSimVertex.h:21
int type() const
particle type (HEP PDT convension)
Definition: CoreSimTrack.h:22
const math::XYZTLorentzVectorD & momentum() const
Definition: CoreSimTrack.h:19
*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
FreeTrajectoryState TrackDetectorAssociator::getFreeTrajectoryState ( const edm::EventSetup iSetup,
const GlobalVector momentum,
const GlobalPoint vertex,
const int  charge 
)
static

Definition at line 583 of file TrackDetectorAssociator.cc.

References Calorimetry_cff::bField, MillePedeFileConverter_cfg::e, edm::EventSetup::get(), and triggerObjects_cff::id.

586  {
588  iSetup.get<IdealMagneticFieldRecord>().get(bField);
589 
590  GlobalTrajectoryParameters tPars(vertex, momentum, charge, &*bField);
591 
592  ROOT::Math::SMatrixIdentity id;
593  AlgebraicSymMatrix66 covT(id);
594  covT *= 1e-6; // initialize to sigma=1e-3
595  CartesianTrajectoryError tCov(covT);
596 
597  return FreeTrajectoryState(tPars, tCov);
598 }
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepSym< double, 6 > > AlgebraicSymMatrix66
T get() const
Definition: EventSetup.h:73
DetIdAssociator::MapRange TrackDetectorAssociator::getMapRange ( const std::pair< float, float > &  delta,
const float  dR 
)
private

Definition at line 622 of file TrackDetectorAssociator.cc.

References DetIdAssociator::MapRange::dPhiMinus, DetIdAssociator::MapRange::dPhiPlus, HGC3DClusterGenMatchSelector_cfi::dR, DetIdAssociator::MapRange::dThetaMinus, DetIdAssociator::MapRange::dThetaPlus, and LogTrace.

Referenced by getCachedTrajector().

622  {
623  DetIdAssociator::MapRange mapRange;
624  mapRange.dThetaPlus = dR;
625  mapRange.dThetaMinus = dR;
626  mapRange.dPhiPlus = dR;
627  mapRange.dPhiMinus = dR;
628  if (delta.first > 0)
629  mapRange.dThetaPlus += delta.first;
630  else
631  mapRange.dThetaMinus += fabs(delta.first);
632  if (delta.second > 0)
633  mapRange.dPhiPlus += delta.second;
634  else
635  mapRange.dPhiMinus += fabs(delta.second);
636  LogTrace("TrackAssociator") << "Selection range: (dThetaPlus, dThetaMinus, dPhiPlus, dPhiMinus, dRPreselection): "
637  << mapRange.dThetaPlus << ", " << mapRange.dThetaMinus << ", " << mapRange.dPhiPlus
638  << ", " << mapRange.dPhiMinus << ", " << dR;
639  return mapRange;
640 }
#define LogTrace(id)
math::XYZPoint TrackDetectorAssociator::getPoint ( const GlobalPoint point)
inlineprivate

Definition at line 140 of file TrackDetectorAssociator.h.

References point.

140  {
141  return math::XYZPoint(point.x(), point.y(), point.z());
142  }
T y() const
Definition: PV3DBase.h:60
T z() const
Definition: PV3DBase.h:61
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
T x() const
Definition: PV3DBase.h:59
math::XYZPoint TrackDetectorAssociator::getPoint ( const LocalPoint point)
inlineprivate

Definition at line 144 of file TrackDetectorAssociator.h.

References point.

144  {
145  return math::XYZPoint(point.x(), point.y(), point.z());
146  }
T y() const
Definition: PV3DBase.h:60
T z() const
Definition: PV3DBase.h:61
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
T x() const
Definition: PV3DBase.h:59
void TrackDetectorAssociator::getTAMuonChamberMatches ( std::vector< TAMuonChamberMatch > &  matches,
const AssociatorParameters parameters 
)
private

Definition at line 642 of file TrackDetectorAssociator.cc.

References Surface::bounds(), TrackAssociatorParameters::dRMuonPreselection, TrajectoryStateOnSurface::freeState(), CachedTrajectory::FullTrajectory, TAMuonChamberMatch::id, DetIdInfo::info(), TrajectoryStateOnSurface::isValid(), SteppingHelixStateInfo::isValid(), Bounds::length(), CSCWireTopology::lengthOfPlane(), TAMuonChamberMatch::localDistanceX, TAMuonChamberMatch::localDistanceY, TrajectoryStateOnSurface::localError(), LogTrace, match(), SteppingHelixStateInfo::momentum(), TrackAssociatorParameters::muonMaxDistanceSigmaX, TrackAssociatorParameters::muonMaxDistanceSigmaY, TrackAssociatorParameters::muonMaxDistanceX, TrackAssociatorParameters::muonMaxDistanceY, CSCWireTopology::narrowWidthOfPlane(), CSCChamberSpecs::oddLayerGeometry(), SteppingHelixStateInfo::position(), FreeTrajectoryState::position(), LocalTrajectoryError::positionError(), fftjetvertexadder_cfi::sigmaX, fftjetvertexadder_cfi::sigmaY, mathSSE::sqrt(), GeomDet::surface(), GloballyPositioned< T >::toLocal(), TAMuonChamberMatch::tState, Vector3DBase< T, FrameTag >::unit(), CSCWireTopology::wideWidthOfPlane(), Bounds::width(), CSCWireTopology::wireAngle(), CSCLayerGeometry::wireTopology(), PV3DBase< T, PVType, FrameType >::x(), LocalError::xx(), PV3DBase< T, PVType, FrameType >::y(), CSCWireTopology::yOfWire(), and LocalError::yy().

Referenced by getCachedTrajector().

643  {
644  // Strategy:
645  // Propagate through the whole detector, estimate change in eta and phi
646  // along the trajectory, add this to dRMuon and find DetIds around this
647  // direction using the map. Then propagate fast to each surface and apply
648  // final matching criteria.
649 
650  // get the direction first
652  // If trajectory point at HCAL is not valid, try to use the outer most state of the
653  // trajectory instead.
654  if (!trajectoryPoint.isValid())
655  trajectoryPoint = cachedTrajectory_.getOuterState();
656  if (!trajectoryPoint.isValid()) {
657  LogTrace("TrackAssociator")
658  << "trajectory position at HCAL is not valid. Assume the track cannot reach muon detectors and skip it";
659  return;
660  }
661 
662  GlobalVector direction = trajectoryPoint.momentum().unit();
663  LogTrace("TrackAssociator") << "muon direction: " << direction
664  << "\n\t and corresponding point: " << trajectoryPoint.position() << "\n";
665 
666  DetIdAssociator::MapRange mapRange =
668 
669  // and find chamber DetIds
670 
671  std::set<DetId> muonIdsInRegion = muonDetIdAssociator_->getDetIdsCloseToAPoint(trajectoryPoint.position(), mapRange);
672  LogTrace("TrackAssociator") << "Number of chambers to check: " << muonIdsInRegion.size();
673  for (std::set<DetId>::const_iterator detId = muonIdsInRegion.begin(); detId != muonIdsInRegion.end(); detId++) {
674  const GeomDet* geomDet = muonDetIdAssociator_->getGeomDet(*detId);
675  TrajectoryStateOnSurface stateOnSurface = cachedTrajectory_.propagate(&geomDet->surface());
676  if (!stateOnSurface.isValid()) {
677  LogTrace("TrackAssociator") << "Failed to propagate the track; moving on\n\t"
678  << "Element is not crosssed: " << DetIdInfo::info(*detId, nullptr) << "\n";
679  continue;
680  }
681  LocalPoint localPoint = geomDet->surface().toLocal(stateOnSurface.freeState()->position());
682  LocalError localError = stateOnSurface.localError().positionError();
683  float distanceX = 0;
684  float distanceY = 0;
685  float sigmaX = 0.0;
686  float sigmaY = 0.0;
687  if (const CSCChamber* cscChamber = dynamic_cast<const CSCChamber*>(geomDet)) {
688  const CSCChamberSpecs* chamberSpecs = cscChamber->specs();
689  if (!chamberSpecs) {
690  LogTrace("TrackAssociator") << "Failed to get CSCChamberSpecs from CSCChamber; moving on\n";
691  continue;
692  }
693  const CSCLayerGeometry* layerGeometry = chamberSpecs->oddLayerGeometry(1);
694  if (!layerGeometry) {
695  LogTrace("TrackAssociator") << "Failed to get CSCLayerGeometry from CSCChamberSpecs; moving on\n";
696  continue;
697  }
698  const CSCWireTopology* wireTopology = layerGeometry->wireTopology();
699  if (!wireTopology) {
700  LogTrace("TrackAssociator") << "Failed to get CSCWireTopology from CSCLayerGeometry; moving on\n";
701  continue;
702  }
703 
704  float wideWidth = wireTopology->wideWidthOfPlane();
705  float narrowWidth = wireTopology->narrowWidthOfPlane();
706  float length = wireTopology->lengthOfPlane();
707  // If slanted, there is no y offset between local origin and symmetry center of wire plane
708  float yOfFirstWire = fabs(wireTopology->wireAngle()) > 1.E-06 ? -0.5 * length : wireTopology->yOfWire(1);
709  // y offset between local origin and symmetry center of wire plane
710  float yCOWPOffset = yOfFirstWire + 0.5 * length;
711 
712  // tangent of the incline angle from inside the trapezoid
713  float tangent = (wideWidth - narrowWidth) / (2. * length);
714  // y position wrt bottom of trapezoid
715  float yPrime = localPoint.y() + fabs(yOfFirstWire);
716  // half trapezoid width at y' is 0.5 * narrowWidth + x side of triangle with the above tangent and side y'
717  float halfWidthAtYPrime = 0.5 * narrowWidth + yPrime * tangent;
718  distanceX = fabs(localPoint.x()) - halfWidthAtYPrime;
719  distanceY = fabs(localPoint.y() - yCOWPOffset) - 0.5 * length;
720  sigmaX = distanceX / sqrt(localError.xx());
721  sigmaY = distanceY / sqrt(localError.yy());
722  } else {
723  distanceX = fabs(localPoint.x()) - geomDet->surface().bounds().width() / 2.;
724  distanceY = fabs(localPoint.y()) - geomDet->surface().bounds().length() / 2.;
725  sigmaX = distanceX / sqrt(localError.xx());
726  sigmaY = distanceY / sqrt(localError.yy());
727  }
728  if ((distanceX < parameters.muonMaxDistanceX && distanceY < parameters.muonMaxDistanceY) ||
729  (sigmaX < parameters.muonMaxDistanceSigmaX && sigmaY < parameters.muonMaxDistanceSigmaY)) {
730  LogTrace("TrackAssociator") << "found a match: " << DetIdInfo::info(*detId, nullptr) << "\n";
732  match.tState = stateOnSurface;
733  match.localDistanceX = distanceX;
734  match.localDistanceY = distanceY;
735  match.id = *detId;
736  matches.push_back(match);
737  } else {
738  LogTrace("TrackAssociator") << "chamber is too far: " << DetIdInfo::info(*detId, nullptr)
739  << "\n\tdistanceX: " << distanceX << "\t distanceY: " << distanceY
740  << "\t sigmaX: " << sigmaX << "\t sigmaY: " << sigmaY << "\n";
741  }
742  }
743 }
float xx() const
Definition: LocalError.h:22
virtual float length() const =0
const CSCWireTopology * wireTopology() const
TrajectoryStateOnSurface tState
T y() const
Definition: PV3DBase.h:60
const Bounds & bounds() const
Definition: Surface.h:89
GlobalVector momentum() const
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
LocalError positionError() const
virtual float width() const =0
float yy() const
Definition: LocalError.h:24
GlobalPoint position() const
T sqrt(T t)
Definition: SSEVec.h:19
LocalPoint toLocal(const GlobalPoint &gp) const
FreeTrajectoryState const * freeState(bool withErrors=true) const
double lengthOfPlane() const
std::pair< float, float > trajectoryDelta(TrajectorType)
const LocalTrajectoryError & localError() const
float yOfWire(float wire, float x=0.) const
#define LogTrace(id)
double narrowWidthOfPlane() const
SteppingHelixStateInfo getOuterState()
virtual const GeomDet * getGeomDet(const DetId &) const =0
Vector3DBase unit() const
Definition: Vector3DBase.h:54
GlobalPoint position() const
void propagate(SteppingHelixStateInfo &state, const Plane &plane)
double wideWidthOfPlane() const
static std::string info(const DetId &, const TrackerTopology *tTopo)
Definition: DetIdInfo.cc:25
const CSCLayerGeometry * oddLayerGeometry(int iendcap) const
Accessors for LayerGeometry&#39;s.
DetIdAssociator::MapRange getMapRange(const std::pair< float, float > &delta, const float dR)
edm::ESHandle< DetIdAssociator > muonDetIdAssociator_
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
float wireAngle() const override
virtual std::set< DetId > getDetIdsCloseToAPoint(const GlobalPoint &, const int iN=0) const
T x() const
Definition: PV3DBase.h:59
SteppingHelixStateInfo getStateAtHcal()
math::XYZVector TrackDetectorAssociator::getVector ( const GlobalVector vec)
inlineprivate

Definition at line 148 of file TrackDetectorAssociator.h.

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

Definition at line 150 of file TrackDetectorAssociator.h.

150 { return math::XYZVector(vec.x(), vec.y(), vec.z()); }
T y() const
Definition: PV3DBase.h:60
T z() const
Definition: PV3DBase.h:61
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
T x() const
Definition: PV3DBase.h:59
void TrackDetectorAssociator::init ( const edm::EventSetup iSetup)
private

Definition at line 122 of file TrackDetectorAssociator.cc.

References anyDirection, SteppingHelixPropagator::applyRadX0Correction(), Calorimetry_cff::bField, edm::EventSetup::get(), SteppingHelixPropagator::setMaterialMode(), and SteppingHelixPropagator_cfi::SteppingHelixPropagator.

Referenced by getCachedTrajector().

122  {
123  // access the calorimeter geometry
124  iSetup.get<CaloGeometryRecord>().get(theCaloGeometry_);
125  if (!theCaloGeometry_.isValid())
126  throw cms::Exception("FatalError") << "Unable to find CaloGeometryRecord in event!\n";
127 
128  // get the tracking Geometry
131  throw cms::Exception("FatalError") << "Unable to find GlobalTrackingGeometryRecord in event!\n";
132 
134  // setup propagator
136  iSetup.get<IdealMagneticFieldRecord>().get(bField);
137 
139  prop->setMaterialMode(false);
140  prop->applyRadX0Correction(true);
141  // prop->setDebug(true); // tmp
142  defProp_ = prop;
144  }
145 
146  iSetup.get<DetIdAssociatorRecord>().get("EcalDetIdAssociator", ecalDetIdAssociator_);
147  iSetup.get<DetIdAssociatorRecord>().get("HcalDetIdAssociator", hcalDetIdAssociator_);
148  iSetup.get<DetIdAssociatorRecord>().get("HODetIdAssociator", hoDetIdAssociator_);
149  iSetup.get<DetIdAssociatorRecord>().get("CaloDetIdAssociator", caloDetIdAssociator_);
150  iSetup.get<DetIdAssociatorRecord>().get("MuonDetIdAssociator", muonDetIdAssociator_);
151  iSetup.get<DetIdAssociatorRecord>().get("PreshowerDetIdAssociator", preshowerDetIdAssociator_);
152 }
edm::ESWatcher< IdealMagneticFieldRecord > theMagneticFeildWatcher_
edm::ESHandle< DetIdAssociator > hcalDetIdAssociator_
void setPropagator(const Propagator *)
use a user configured propagator
void applyRadX0Correction(bool applyRadX0Correction)
edm::ESHandle< CaloGeometry > theCaloGeometry_
edm::ESHandle< DetIdAssociator > ecalDetIdAssociator_
edm::ESHandle< DetIdAssociator > hoDetIdAssociator_
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
edm::ESHandle< DetIdAssociator > muonDetIdAssociator_
edm::ESHandle< DetIdAssociator > preshowerDetIdAssociator_
T get() const
Definition: EventSetup.h:73
bool isValid() const
Definition: ESHandle.h:44
edm::ESHandle< DetIdAssociator > caloDetIdAssociator_
edm::ESHandle< GlobalTrackingGeometry > theTrackingGeometry_
void setMaterialMode(bool noMaterial)
Switch for material effects mode: no material effects if true.
void TrackDetectorAssociator::setPropagator ( const Propagator ptr)
void TrackDetectorAssociator::useDefaultPropagator ( )

Member Data Documentation

CachedTrajectory TrackDetectorAssociator::cachedTrajectory_
private

Definition at line 154 of file TrackDetectorAssociator.h.

Referenced by getCachedTrajector().

edm::ESHandle<DetIdAssociator> TrackDetectorAssociator::caloDetIdAssociator_
private

Definition at line 160 of file TrackDetectorAssociator.h.

Propagator* TrackDetectorAssociator::defProp_
private

Definition at line 153 of file TrackDetectorAssociator.h.

edm::ESHandle<DetIdAssociator> TrackDetectorAssociator::ecalDetIdAssociator_
private

Definition at line 157 of file TrackDetectorAssociator.h.

edm::ESHandle<DetIdAssociator> TrackDetectorAssociator::hcalDetIdAssociator_
private

Definition at line 158 of file TrackDetectorAssociator.h.

edm::ESHandle<DetIdAssociator> TrackDetectorAssociator::hoDetIdAssociator_
private

Definition at line 159 of file TrackDetectorAssociator.h.

const Propagator* TrackDetectorAssociator::ivProp_
private

Definition at line 152 of file TrackDetectorAssociator.h.

edm::ESHandle<DetIdAssociator> TrackDetectorAssociator::muonDetIdAssociator_
private

Definition at line 161 of file TrackDetectorAssociator.h.

edm::ESHandle<DetIdAssociator> TrackDetectorAssociator::preshowerDetIdAssociator_
private

Definition at line 162 of file TrackDetectorAssociator.h.

edm::ESHandle<CaloGeometry> TrackDetectorAssociator::theCaloGeometry_
private

Definition at line 164 of file TrackDetectorAssociator.h.

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

Definition at line 167 of file TrackDetectorAssociator.h.

edm::ESHandle<GlobalTrackingGeometry> TrackDetectorAssociator::theTrackingGeometry_
private

Definition at line 165 of file TrackDetectorAssociator.h.

bool TrackDetectorAssociator::useDefaultPropagator_
private

Definition at line 155 of file TrackDetectorAssociator.h.