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 50 of file TrackDetectorAssociator.h.

Member Typedef Documentation

Definition at line 55 of file TrackDetectorAssociator.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

TrackDetectorAssociator::TrackDetectorAssociator ( )

Definition at line 105 of file TrackDetectorAssociator.cc.

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

Definition at line 112 of file TrackDetectorAssociator.cc.

113 {
114  if (defProp_) delete defProp_;
115 }

Member Function Documentation

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

Definition at line 841 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(), cscNeutronWriter_cfi::t0, TAMuonSegmentMatch::t0, DTRecSegment2D::t0(), GeomDet::toGlobal(), TAMuonChamberMatch::tState, LocalError::xx(), LocalError::xy(), and LocalError::yy().

Referenced by getCachedTrajector().

844 {
845  LogTrace("TrackAssociator")
846  << "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")
854  << "Segment global position: " << segmentGlobalPosition << " \t (R_xy,eta,phi): "
855  << segmentGlobalPosition.perp() << "," << segmentGlobalPosition.eta() << "," << segmentGlobalPosition.phi() << "\n";
856 
857  LogTrace("TrackAssociator")
858  << "\teta hit: " << segmentGlobalPosition.eta() << " \tpropagator: " << trajectoryStateOnSurface.freeState()->position().eta() << "\n"
859  << "\tphi hit: " << segmentGlobalPosition.phi() << " \tpropagator: " << trajectoryStateOnSurface.freeState()->position().phi() << std::endl;
860 
861  bool isGood = false;
862  bool isDTWithoutY = false;
863  const DTRecSegment4D* dtseg = dynamic_cast<const DTRecSegment4D*>(segment);
864  if ( dtseg && (! dtseg->hasZed()) )
865  isDTWithoutY = true;
866 
867  double deltaPhi(fabs(segmentGlobalPosition.phi()-trajectoryStateOnSurface.freeState()->position().phi()));
868  if(deltaPhi>M_PI) deltaPhi = fabs(deltaPhi-M_PI*2.);
869 
870  if( isDTWithoutY )
871  {
872  isGood = deltaPhi < parameters.dRMuon;
873  // Be in chamber
874  isGood &= fabs(segmentGlobalPosition.eta()-trajectoryStateOnSurface.freeState()->position().eta()) < .3;
875  } else isGood = sqrt( pow(segmentGlobalPosition.eta()-trajectoryStateOnSurface.freeState()->position().eta(),2) +
876  deltaPhi*deltaPhi) < parameters.dRMuon;
877 
878  if(isGood) {
879  TAMuonSegmentMatch muonSegment;
880  muonSegment.segmentGlobalPosition = getPoint(segmentGlobalPosition);
881  muonSegment.segmentLocalPosition = getPoint( segment->localPosition() );
882  muonSegment.segmentLocalDirection = getVector( segment->localDirection() );
883  muonSegment.segmentLocalErrorXX = segment->localPositionError().xx();
884  muonSegment.segmentLocalErrorYY = segment->localPositionError().yy();
885  muonSegment.segmentLocalErrorXY = segment->localPositionError().xy();
886  muonSegment.segmentLocalErrorDxDz = segment->localDirectionError().xx();
887  muonSegment.segmentLocalErrorDyDz = segment->localDirectionError().yy();
888 
889  // DANGEROUS - compiler cannot guaranty parameters ordering
890  // AlgebraicSymMatrix segmentCovMatrix = segment->parametersError();
891  // muonSegment.segmentLocalErrorXDxDz = segmentCovMatrix[2][0];
892  // muonSegment.segmentLocalErrorYDyDz = segmentCovMatrix[3][1];
893  muonSegment.segmentLocalErrorXDxDz = -999;
894  muonSegment.segmentLocalErrorYDyDz = -999;
895  muonSegment.hasZed = true;
896  muonSegment.hasPhi = true;
897 
898  // timing information
899  muonSegment.t0 = 0;
900  if ( dtseg ) {
901  if ( (dtseg->hasPhi()) && (! isDTWithoutY) ) {
902  int phiHits = dtseg->phiSegment()->specificRecHits().size();
903  // int zHits = dtseg->zSegment()->specificRecHits().size();
904  int hits=0;
905  double t0=0.;
906  // TODO: cuts on hit numbers not optimized in any way yet...
907  if (phiHits>5 && dtseg->phiSegment()->ist0Valid()) {
908  t0+=dtseg->phiSegment()->t0()*phiHits;
909  hits+=phiHits;
910  LogTrace("TrackAssociator") << " Phi t0: " << dtseg->phiSegment()->t0() << " hits: " << phiHits;
911  }
912  // the z segments seem to contain little useful information...
913 // if (zHits>3) {
914 // t0+=s->zSegment()->t0()*zHits;
915 // hits+=zHits;
916 // LogTrace("TrackAssociator") << " Z t0: " << s->zSegment()->t0() << " hits: " << zHits << std::endl;
917 // }
918  if (hits) muonSegment.t0 = t0/hits;
919 // LogTrace("TrackAssociator") << " --- t0: " << muonSegment.t0 << std::endl;
920  } else {
921  // check and set dimensionality
922  if (isDTWithoutY) muonSegment.hasZed = false;
923  if (! dtseg->hasPhi()) muonSegment.hasPhi = false;
924  }
925  }
926  matchedChamber.segments.push_back(muonSegment);
927  }
928 
929  return isGood;
930 }
float xx() const
Definition: LocalError.h:24
virtual LocalError localDirectionError() const =0
Error on the local direction.
T perp() const
Definition: PV3DBase.h:72
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:54
math::XYZPoint segmentLocalPosition
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
math::XYZVector getVector(const GlobalVector &vec)
math::XYZVector segmentLocalDirection
uint32_t rawId() const
get the raw id
Definition: DetId.h:44
virtual LocalVector localDirection() const =0
Local direction.
float xy() const
Definition: LocalError.h:25
float yy() const
Definition: LocalError.h:26
T sqrt(T t)
Definition: SSEVec.h:18
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:76
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:40
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 162 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().

166 {
167  return associate(iEvent,iSetup,parameters,&fts);
168 }
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 170 of file TrackDetectorAssociator.cc.

References Exception, info(), init, edm::isNotFinite(), LogTrace, PV3DBase< T, PVType, FrameType >::mag(), pvSelector_cfi::maxZ, HiClusterCompatibility_cfi::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().

175 {
177  if (! parameters.useEcal && ! parameters.useCalo && ! parameters.useHcal &&
178  ! parameters.useHO && ! parameters.useMuon && !parameters.usePreshower)
179  throw cms::Exception("ConfigurationError") <<
180  "Configuration error! No subdetector was selected for the track association.";
181 
182  SteppingHelixStateInfo trackOrigin(*innerState);
183  info.stateAtIP = *innerState;
184  cachedTrajectory_.setStateAtIP(trackOrigin);
185 
186  init( iSetup );
187  // get track trajectory
188  // ECAL points (EB+EE)
189  // If the phi angle between a track entrance and exit points is more
190  // than 2 crystals, it is possible that the track will cross 3 crystals
191  // and therefore one has to check at least 3 points along the track
192  // trajectory inside ECAL. In order to have a chance to cross 4 crystalls
193  // in the barrel, a track should have P_t as low as 3 GeV or smaller
194  // If it's necessary, number of points along trajectory can be increased
195 
197 
199  // estimate propagation outer boundaries based on
200  // requested sub-detector information. For now limit
201  // propagation region only if muon matching is not
202  // requested.
203  double HOmaxR = hoDetIdAssociator_->volume().maxR();
204  double HOmaxZ = hoDetIdAssociator_->volume().maxZ();
205  double minR = ecalDetIdAssociator_->volume().minR();
211 
212  if (parameters.useMuon) {
213  double maxR = muonDetIdAssociator_->volume().maxR();
214  double maxZ = muonDetIdAssociator_->volume().maxZ();
217  }
218  else {
221  }
222 
223  // If track extras exist and outerState is before HO maximum, then use outerState
224  if (outerState) {
225  if (outerState->position().perp()<HOmaxR && fabs(outerState->position().z())<HOmaxZ) {
226  LogTrace("TrackAssociator") << "Using outerState as trackOrigin at Rho=" << outerState->position().perp()
227  << " Z=" << outerState->position().z() << "\n";
228  trackOrigin = SteppingHelixStateInfo(*outerState);
229  }
230  else if(innerState) {
231  LogTrace("TrackAssociator") << "Using innerState as trackOrigin at Rho=" << innerState->position().perp()
232  << " Z=" << innerState->position().z() << "\n";
233  trackOrigin = SteppingHelixStateInfo(*innerState);
234  }
235  }
236 
237  if ( trackOrigin.momentum().mag() == 0 ) return info;
238  if ( edm::isNotFinite(trackOrigin.momentum().x()) or edm::isNotFinite(trackOrigin.momentum().y()) or edm::isNotFinite(trackOrigin.momentum().z()) ) return info;
239  if ( ! cachedTrajectory_.propagateAll(trackOrigin) ) return info;
240 
241  // get trajectory in calorimeters
246 
250 
254 
255  if (parameters.useEcal) fillEcal( iEvent, info, parameters);
256  if (parameters.useCalo) fillCaloTowers( iEvent, info, parameters);
257  if (parameters.useHcal) fillHcal( iEvent, info, parameters);
258  if (parameters.useHO) fillHO( iEvent, info, parameters);
259  if (parameters.usePreshower) fillPreshower( iEvent, info, parameters);
260  if (parameters.useMuon) fillMuon( iEvent, info, parameters);
261  if (parameters.truthMatch) fillCaloTruth( iEvent, info, parameters);
262 
263  return info;
264 }
SteppingHelixStateInfo getStateAtHO()
math::XYZPoint trkGlobPosAtHO
static const TGPicture * info(bool iBackgroundIsBlack)
T perp() const
Definition: PV3DBase.h:72
void findPreshowerTrajectory(const FiducialVolume &)
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 &)
bool isNotFinite(T x)
Definition: isFinite.h:10
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:64
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 994 of file TrackDetectorAssociator.cc.

References ecalTB2006H4_GenSimDigiReco_cfg::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().

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

1091 {
1092  return associate(iEvent, iSetup, getFreeTrajectoryState(iSetup, track, vertex), parameters);
1093 }
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 1095 of file TrackDetectorAssociator.cc.

1101 {
1102  return associate(iEvent, iSetup, getFreeTrajectoryState(iSetup, momentum, vertex, charge), parameters);
1103 }
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 1105 of file TrackDetectorAssociator.cc.

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

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

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

Definition at line 338 of file TrackDetectorAssociator.cc.

References TrackAssociatorParameters::accountForTrajectoryChangeCalo, eleHcalExtractorBlocks_cff::caloTowers, TrackAssociatorParameters::caloTowersToken, TrackDetMatchInfo::crossedTowerIds, TrackDetMatchInfo::crossedTowers, SoftLeptonByDistance_cfi::distance, TrackAssociatorParameters::dRHcal, TrackAssociatorParameters::dRHcalPreselection, edm::Event::getByToken(), CachedTrajectory::IpToHcal, TrackDetMatchInfo::isGoodCalo, edm::HandleBase::isValid(), LogTrace, 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(); itr++) trajectory.push_back(itr->position());
348  for(std::vector<SteppingHelixStateInfo>::const_iterator itr = hcalTrajectoryStates.begin();
349  itr != hcalTrajectoryStates.end(); itr++) trajectory.push_back(itr->position());
350 
351  if(trajectory.empty()) {
352  LogTrace("TrackAssociator") << "HCAL trajectory is empty; moving on\n";
353  info.isGoodCalo = false;
354  return;
355  }
356  info.isGoodCalo = true;
357 
358  // find crossed CaloTowers
360  iEvent.getByToken(parameters.caloTowersToken, caloTowers);
361  if (!caloTowers.isValid()) throw cms::Exception("FatalError") << "Unable to find CaloTowers in event!\n";
362 
363  std::set<DetId> caloTowerIdsInRegion;
364  if (parameters.accountForTrajectoryChangeCalo){
365  // get trajectory change with respect to initial state
367  parameters.dRHcalPreselection);
368  caloTowerIdsInRegion = caloDetIdAssociator_->getDetIdsCloseToAPoint(trajectory[0],mapRange);
369  } else caloTowerIdsInRegion = caloDetIdAssociator_->getDetIdsCloseToAPoint(trajectory[0], parameters.dRHcalPreselection);
370 
371  LogTrace("TrackAssociator") << "Towers in the region: " << caloTowerIdsInRegion.size();
372 
373  auto caloTowerIdsInAConeBegin = caloTowerIdsInRegion.begin();
374  auto caloTowerIdsInAConeEnd = caloTowerIdsInRegion.end();
375  std::set<DetId> caloTowerIdsInAConeTmp;
377  caloTowerIdsInAConeTmp = caloDetIdAssociator_->getDetIdsInACone(caloTowerIdsInRegion, trajectory, parameters.dRHcal);
378  caloTowerIdsInAConeBegin = caloTowerIdsInAConeTmp.begin();
379  caloTowerIdsInAConeEnd = caloTowerIdsInAConeTmp.end();
380  }
381  LogTrace("TrackAssociator") << "Towers in the cone: " << std::distance(caloTowerIdsInAConeBegin, caloTowerIdsInAConeEnd);
382 
383  info.crossedTowerIds = caloDetIdAssociator_->getCrossedDetIds(caloTowerIdsInRegion, trajectory);
384  const std::vector<DetId>& crossedCaloTowerIds = info.crossedTowerIds;
385  LogTrace("TrackAssociator") << "Towers crossed: " << crossedCaloTowerIds.size();
386 
387  // add CaloTowers
388  for(std::vector<DetId>::const_iterator itr=crossedCaloTowerIds.begin(); itr!=crossedCaloTowerIds.end();itr++)
389  {
390  CaloTowerCollection::const_iterator tower = (*caloTowers).find(*itr);
391  if(tower != (*caloTowers).end())
392  info.crossedTowers.push_back(&*tower);
393  else
394  LogTrace("TrackAssociator") << "Crossed CaloTower is not found for DetId: " << (*itr).rawId();
395  }
396 
397  for(std::set<DetId>::const_iterator itr=caloTowerIdsInAConeBegin; itr!=caloTowerIdsInAConeEnd;itr++)
398  {
399  CaloTowerCollection::const_iterator tower = (*caloTowers).find(*itr);
400  if(tower != (*caloTowers).end())
401  info.towers.push_back(&*tower);
402  else
403  LogTrace("TrackAssociator") << "CaloTower from the cone is not found for DetId: " << (*itr).rawId();
404  }
405 
406 }
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:519
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:74
#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 934 of file TrackDetectorAssociator.cc.

References HiRegitMuonDetachedTripletStep_cff::DeltaR, TrackDetMatchInfo::ecalTrueEnergy, SimTrack::genpartIndex(), edm::Event::getByToken(), TrackDetMatchInfo::hcalTrueEnergy, TrackDetMatchInfo::hcalTrueEnergyCorrected, edm::HandleBase::isValid(), FreeTrajectoryState::momentum(), TrackAssociatorParameters::simEcalHitsEBToken, TrackAssociatorParameters::simEcalHitsEEToken, TrackAssociatorParameters::simHcalHitsToken, simTrackMatching_cfi::simTrack, TrackDetMatchInfo::simTrack, tkConvValidator_cfi::simTracks, TrackAssociatorParameters::simTracksToken, 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().

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

Definition at line 266 of file TrackDetectorAssociator.cc.

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

Referenced by getCachedTrajector().

269 {
270  const std::vector<SteppingHelixStateInfo>& trajectoryStates = cachedTrajectory_.getEcalTrajectory();
271 
272  for(std::vector<SteppingHelixStateInfo>::const_iterator itr = trajectoryStates.begin();
273  itr != trajectoryStates.end(); itr++)
274  LogTrace("TrackAssociator") << "ECAL trajectory point (rho, z, phi): " << itr->position().perp() <<
275  ", " << itr->position().z() << ", " << itr->position().phi();
276 
277  std::vector<GlobalPoint> coreTrajectory;
278  for(std::vector<SteppingHelixStateInfo>::const_iterator itr = trajectoryStates.begin();
279  itr != trajectoryStates.end(); itr++) coreTrajectory.push_back(itr->position());
280 
281  if(coreTrajectory.empty()) {
282  LogTrace("TrackAssociator") << "ECAL track trajectory is empty; moving on\n";
283  info.isGoodEcal = false;
284  return;
285  }
286  info.isGoodEcal = true;
287 
288  // Find ECAL crystals
290  iEvent.getByToken(parameters.EBRecHitsToken, EBRecHits);
291  if (!EBRecHits.isValid()) throw cms::Exception("FatalError") << "Unable to find EBRecHitCollection in the event!\n";
292 
294  iEvent.getByToken(parameters.EERecHitsToken, EERecHits);
295  if (!EERecHits.isValid()) throw cms::Exception("FatalError") << "Unable to find EERecHitCollection in event!\n";
296 
297  std::set<DetId> ecalIdsInRegion;
298  if (parameters.accountForTrajectoryChangeCalo){
299  // get trajectory change with respect to initial state
301  parameters.dREcalPreselection);
302  ecalIdsInRegion = ecalDetIdAssociator_->getDetIdsCloseToAPoint(coreTrajectory[0],mapRange);
303  } else ecalIdsInRegion = ecalDetIdAssociator_->getDetIdsCloseToAPoint(coreTrajectory[0], parameters.dREcalPreselection);
304  LogTrace("TrackAssociator") << "ECAL hits in the region: " << ecalIdsInRegion.size();
305  if (parameters.dREcalPreselection > parameters.dREcal)
306  ecalIdsInRegion = ecalDetIdAssociator_->getDetIdsInACone(ecalIdsInRegion, coreTrajectory, parameters.dREcal);
307  LogTrace("TrackAssociator") << "ECAL hits in the cone: " << ecalIdsInRegion.size();
308  info.crossedEcalIds = ecalDetIdAssociator_->getCrossedDetIds(ecalIdsInRegion, coreTrajectory);
309  const std::vector<DetId>& crossedEcalIds = info.crossedEcalIds;
310  LogTrace("TrackAssociator") << "ECAL crossed hits " << crossedEcalIds.size();
311 
312 
313  // add EcalRecHits
314  for(std::vector<DetId>::const_iterator itr=crossedEcalIds.begin(); itr!=crossedEcalIds.end();itr++)
315  {
316  std::vector<EcalRecHit>::const_iterator ebHit = (*EBRecHits).find(*itr);
317  std::vector<EcalRecHit>::const_iterator eeHit = (*EERecHits).find(*itr);
318  if(ebHit != (*EBRecHits).end())
319  info.crossedEcalRecHits.push_back(&*ebHit);
320  else if(eeHit != (*EERecHits).end())
321  info.crossedEcalRecHits.push_back(&*eeHit);
322  else
323  LogTrace("TrackAssociator") << "Crossed EcalRecHit is not found for DetId: " << itr->rawId();
324  }
325  for(std::set<DetId>::const_iterator itr=ecalIdsInRegion.begin(); itr!=ecalIdsInRegion.end();itr++)
326  {
327  std::vector<EcalRecHit>::const_iterator ebHit = (*EBRecHits).find(*itr);
328  std::vector<EcalRecHit>::const_iterator eeHit = (*EERecHits).find(*itr);
329  if(ebHit != (*EBRecHits).end())
330  info.ecalRecHits.push_back(&*ebHit);
331  else if(eeHit != (*EERecHits).end())
332  info.ecalRecHits.push_back(&*eeHit);
333  else
334  LogTrace("TrackAssociator") << "EcalRecHit from the cone is not found for DetId: " << itr->rawId();
335  }
336 }
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:519
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:74
#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 432 of file TrackDetectorAssociator.cc.

References TrackAssociatorParameters::accountForTrajectoryChangeCalo, universalConfigTemplate::collection, TrackDetMatchInfo::crossedHcalIds, TrackDetMatchInfo::crossedHcalRecHits, SoftLeptonByDistance_cfi::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().

435 {
436  const std::vector<SteppingHelixStateInfo>& trajectoryStates = cachedTrajectory_.getHcalTrajectory();
437 
438  std::vector<GlobalPoint> coreTrajectory;
439  for(std::vector<SteppingHelixStateInfo>::const_iterator itr = trajectoryStates.begin();
440  itr != trajectoryStates.end(); itr++) coreTrajectory.push_back(itr->position());
441 
442  if(coreTrajectory.empty()) {
443  LogTrace("TrackAssociator") << "HCAL trajectory is empty; moving on\n";
444  info.isGoodHcal = false;
445  return;
446  }
447  info.isGoodHcal = true;
448 
449  // find crossed Hcals
451  iEvent.getByToken(parameters.HBHEcollToken, collection);
452  if ( ! collection.isValid() ) throw cms::Exception("FatalError") << "Unable to find HBHERecHits in event!\n";
453 
454  std::set<DetId> idsInRegion;
455  if (parameters.accountForTrajectoryChangeCalo){
456  // get trajectory change with respect to initial state
458  parameters.dRHcalPreselection);
459  idsInRegion = hcalDetIdAssociator_->getDetIdsCloseToAPoint(coreTrajectory[0], mapRange);
460  } else idsInRegion = hcalDetIdAssociator_->getDetIdsCloseToAPoint(coreTrajectory[0], parameters.dRHcalPreselection);
461 
462  LogTrace("TrackAssociator") << "HCAL hits in the region: " << idsInRegion.size() << "\n" << DetIdInfo::info(idsInRegion,nullptr);
463 
464  auto idsInAConeBegin = idsInRegion.begin();
465  auto idsInAConeEnd = idsInRegion.end();
466  std::set<DetId> idsInAConeTmp;
468  idsInAConeTmp = hcalDetIdAssociator_->getDetIdsInACone(idsInRegion, coreTrajectory, parameters.dRHcal);
469  idsInAConeBegin = idsInAConeTmp.begin();
470  idsInAConeEnd = idsInAConeTmp.end();
471  }
472  LogTrace("TrackAssociator") << "HCAL hits in the cone: " << std::distance(idsInAConeBegin, idsInAConeEnd) << "\n"
473  << DetIdInfo::info(std::set<DetId>(idsInAConeBegin, idsInAConeEnd), nullptr);
474  info.crossedHcalIds = hcalDetIdAssociator_->getCrossedDetIds(idsInRegion, coreTrajectory);
475  const std::vector<DetId>& crossedIds = info.crossedHcalIds;
476  LogTrace("TrackAssociator") << "HCAL hits crossed: " << crossedIds.size() << "\n" << DetIdInfo::info(crossedIds,nullptr);
477 
478  // add Hcal
479  for(std::vector<DetId>::const_iterator itr=crossedIds.begin(); itr!=crossedIds.end();itr++)
480  {
481  HBHERecHitCollection::const_iterator hit = (*collection).find(*itr);
482  if( hit != (*collection).end() )
483  info.crossedHcalRecHits.push_back(&*hit);
484  else
485  LogTrace("TrackAssociator") << "Crossed HBHERecHit is not found for DetId: " << itr->rawId();
486  }
487  for(std::set<DetId>::const_iterator itr=idsInAConeBegin; itr!=idsInAConeEnd;itr++)
488  {
489  HBHERecHitCollection::const_iterator hit = (*collection).find(*itr);
490  if( hit != (*collection).end() )
491  info.hcalRecHits.push_back(&*hit);
492  else
493  LogTrace("TrackAssociator") << "HBHERecHit from the cone is not found for DetId: " << itr->rawId();
494  }
495 }
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:519
virtual bool selectAllInACone(const double dR) const
helper to see if getDetIdsInACone is useful
std::vector< HBHERecHit >::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:74
#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 497 of file TrackDetectorAssociator.cc.

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

Referenced by getCachedTrajector().

500 {
501  const std::vector<SteppingHelixStateInfo>& trajectoryStates = cachedTrajectory_.getHOTrajectory();
502 
503  std::vector<GlobalPoint> coreTrajectory;
504  for(std::vector<SteppingHelixStateInfo>::const_iterator itr = trajectoryStates.begin();
505  itr != trajectoryStates.end(); itr++) coreTrajectory.push_back(itr->position());
506 
507  if(coreTrajectory.empty()) {
508  LogTrace("TrackAssociator") << "HO trajectory is empty; moving on\n";
509  info.isGoodHO = false;
510  return;
511  }
512  info.isGoodHO = true;
513 
514  // find crossed HOs
516  iEvent.getByToken(parameters.HOcollToken, collection);
517  if ( ! collection.isValid() ) throw cms::Exception("FatalError") << "Unable to find HORecHits in event!\n";
518 
519  std::set<DetId> idsInRegion;
520  if (parameters.accountForTrajectoryChangeCalo){
521  // get trajectory change with respect to initial state
523  parameters.dRHcalPreselection);
524  idsInRegion = hoDetIdAssociator_->getDetIdsCloseToAPoint(coreTrajectory[0], mapRange);
525  } else idsInRegion = hoDetIdAssociator_->getDetIdsCloseToAPoint(coreTrajectory[0], parameters.dRHcalPreselection);
526 
527  LogTrace("TrackAssociator") << "idsInRegion.size(): " << idsInRegion.size();
528 
529  auto idsInAConeBegin = idsInRegion.begin();
530  auto idsInAConeEnd = idsInRegion.end();
531  std::set<DetId> idsInAConeTmp;
533  idsInAConeTmp = hoDetIdAssociator_->getDetIdsInACone(idsInRegion, coreTrajectory, parameters.dRHcal);
534  idsInAConeBegin = idsInAConeTmp.begin();
535  idsInAConeEnd = idsInAConeTmp.end();
536  }
537  LogTrace("TrackAssociator") << "idsInACone.size(): " << std::distance(idsInAConeBegin, idsInAConeEnd);
538  info.crossedHOIds = hoDetIdAssociator_->getCrossedDetIds(idsInRegion, coreTrajectory);
539  const std::vector<DetId>& crossedIds = info.crossedHOIds;
540 
541  // add HO
542  for(std::vector<DetId>::const_iterator itr=crossedIds.begin(); itr!=crossedIds.end();itr++)
543  {
544  HORecHitCollection::const_iterator hit = (*collection).find(*itr);
545  if( hit != (*collection).end() )
546  info.crossedHORecHits.push_back(&*hit);
547  else
548  LogTrace("TrackAssociator") << "Crossed HORecHit is not found for DetId: " << itr->rawId();
549  }
550 
551  for(std::set<DetId>::const_iterator itr=idsInAConeBegin; itr!=idsInAConeEnd;itr++)
552  {
553  HORecHitCollection::const_iterator hit = (*collection).find(*itr);
554  if( hit != (*collection).end() )
555  info.hoRecHits.push_back(&*hit);
556  else
557  LogTrace("TrackAssociator") << "HORecHit from the cone is not found for DetId: " << itr->rawId();
558  }
559 }
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:519
virtual bool selectAllInACone(const double dR) const
helper to see if getDetIdsInACone is useful
std::vector< HORecHit >::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:74
#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 744 of file TrackDetectorAssociator.cc.

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

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

Referenced by getCachedTrajector().

411 {
412  std::vector<GlobalPoint> trajectory;
413  const std::vector<SteppingHelixStateInfo>& trajectoryStates = cachedTrajectory_.getPreshowerTrajectory();
414  for(std::vector<SteppingHelixStateInfo>::const_iterator itr = trajectoryStates.begin();
415  itr != trajectoryStates.end(); itr++) trajectory.push_back(itr->position());
416 
417  if(trajectory.empty()) {
418  LogTrace("TrackAssociator") << "Preshower trajectory is empty; moving on\n";
419  return;
420  }
421 
422  std::set<DetId> idsInRegion =
424  parameters.dRPreshowerPreselection);
425 
426  LogTrace("TrackAssociator") << "Number of Preshower Ids in the region: " << idsInRegion.size();
427  info.crossedPreshowerIds = preshowerDetIdAssociator_->getCrossedDetIds(idsInRegion, trajectory);
428  LogTrace("TrackAssociator") << "Number of Preshower Ids in crossed: " << info.crossedPreshowerIds.size();
429 }
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 594 of file TrackDetectorAssociator.cc.

References ecalTB2006H4_GenSimDigiReco_cfg::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().

596 {
598  iSetup.get<IdealMagneticFieldRecord>().get(bField);
599 
600  GlobalVector vector( track.momentum().x(), track.momentum().y(), track.momentum().z() );
601 
602  GlobalPoint point( track.vertex().x(), track.vertex().y(), track.vertex().z() );
603 
604  GlobalTrajectoryParameters tPars(point, vector, track.charge(), &*bField);
605 
606  // FIX THIS !!!
607  // need to convert from perigee to global or helix (curvilinear) frame
608  // for now just an arbitrary matrix.
609  ROOT::Math::SMatrixIdentity id;
610  AlgebraicSymMatrix66 covT(id); covT *= 1e-6; // initialize to sigma=1e-3
611  CartesianTrajectoryError tCov(covT);
612 
613  return FreeTrajectoryState(tPars, tCov);
614 }
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepSym< double, 6 > > AlgebraicSymMatrix66
const Vector & momentum() const
track momentum vector
Definition: TrackBase.h:675
const Point & vertex() const
reference point on the track. This method is DEPRECATED, please use referencePoint() instead ...
Definition: TrackBase.h:687
const T & get() const
Definition: EventSetup.h:59
int charge() const
track electric charge
Definition: TrackBase.h:567
*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 561 of file TrackDetectorAssociator.cc.

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

564 {
565  GlobalVector vector( track.momentum().x(), track.momentum().y(), track.momentum().z() );
566  GlobalPoint point( vertex.position().x(), vertex.position().y(), vertex.position().z() );
567 
568  int charge = track.type( )> 0 ? -1 : 1; // lepton convention
569  if ( abs(track.type( )) == 211 || // pion
570  abs(track.type( )) == 321 || // kaon
571  abs(track.type( )) == 2212 )
572  charge = track.type( )< 0 ? -1 : 1;
573  return getFreeTrajectoryState(iSetup, vector, point, charge);
574 }
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:26
int type() const
particle type (HEP PDT convension)
Definition: CoreSimTrack.h:25
const math::XYZTLorentzVectorD & momentum() const
Definition: CoreSimTrack.h:22
*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
DetIdAssociator::MapRange TrackDetectorAssociator::getMapRange ( const std::pair< float, float > &  delta,
const float  dR 
)
private

Definition at line 616 of file TrackDetectorAssociator.cc.

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

Referenced by getCachedTrajector().

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

Definition at line 165 of file TrackDetectorAssociator.h.

References point.

166  {
167  return math::XYZPoint(point.x(),point.y(),point.z());
168  }
T y() const
Definition: PV3DBase.h:63
T z() const
Definition: PV3DBase.h:64
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
T x() const
Definition: PV3DBase.h:62
math::XYZPoint TrackDetectorAssociator::getPoint ( const LocalPoint point)
inlineprivate

Definition at line 170 of file TrackDetectorAssociator.h.

References point.

171  {
172  return math::XYZPoint(point.x(),point.y(),point.z());
173  }
T y() const
Definition: PV3DBase.h:63
T z() const
Definition: PV3DBase.h:64
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
T x() const
Definition: PV3DBase.h:62
void TrackDetectorAssociator::getTAMuonChamberMatches ( std::vector< TAMuonChamberMatch > &  matches,
const AssociatorParameters parameters 
)
private

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

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

Definition at line 175 of file TrackDetectorAssociator.h.

176  {
177  return math::XYZVector(vec.x(),vec.y(),vec.z());
178  }
T y() const
Definition: PV3DBase.h:63
T z() const
Definition: PV3DBase.h:64
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
T x() const
Definition: PV3DBase.h:62
math::XYZVector TrackDetectorAssociator::getVector ( const LocalVector vec)
inlineprivate

Definition at line 180 of file TrackDetectorAssociator.h.

181  {
182  return math::XYZVector(vec.x(),vec.y(),vec.z());
183  }
T y() const
Definition: PV3DBase.h:63
T z() const
Definition: PV3DBase.h:64
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
T x() const
Definition: PV3DBase.h:62
void TrackDetectorAssociator::init ( const edm::EventSetup iSetup)
private

Definition at line 129 of file TrackDetectorAssociator.cc.

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

Referenced by getCachedTrajector().

130 {
131  // access the calorimeter geometry
132  iSetup.get<CaloGeometryRecord>().get(theCaloGeometry_);
133  if (!theCaloGeometry_.isValid())
134  throw cms::Exception("FatalError") << "Unable to find CaloGeometryRecord in event!\n";
135 
136  // get the tracking Geometry
139  throw cms::Exception("FatalError") << "Unable to find GlobalTrackingGeometryRecord in event!\n";
140 
142  // setup propagator
144  iSetup.get<IdealMagneticFieldRecord>().get(bField);
145 
147  prop->setMaterialMode(false);
148  prop->applyRadX0Correction(true);
149  // prop->setDebug(true); // tmp
150  defProp_ = prop;
152  }
153 
154  iSetup.get<DetIdAssociatorRecord>().get("EcalDetIdAssociator", ecalDetIdAssociator_);
155  iSetup.get<DetIdAssociatorRecord>().get("HcalDetIdAssociator", hcalDetIdAssociator_);
156  iSetup.get<DetIdAssociatorRecord>().get("HODetIdAssociator", hoDetIdAssociator_);
157  iSetup.get<DetIdAssociatorRecord>().get("CaloDetIdAssociator", caloDetIdAssociator_);
158  iSetup.get<DetIdAssociatorRecord>().get("MuonDetIdAssociator", muonDetIdAssociator_);
159  iSetup.get<DetIdAssociatorRecord>().get("PreshowerDetIdAssociator", preshowerDetIdAssociator_);
160 }
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_
const T & get() const
Definition: EventSetup.h:59
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
edm::ESHandle< DetIdAssociator > muonDetIdAssociator_
edm::ESHandle< DetIdAssociator > preshowerDetIdAssociator_
bool isValid() const
Definition: ESHandle.h:47
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 187 of file TrackDetectorAssociator.h.

Referenced by getCachedTrajector().

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

Definition at line 193 of file TrackDetectorAssociator.h.

Propagator* TrackDetectorAssociator::defProp_
private

Definition at line 186 of file TrackDetectorAssociator.h.

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

Definition at line 190 of file TrackDetectorAssociator.h.

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

Definition at line 191 of file TrackDetectorAssociator.h.

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

Definition at line 192 of file TrackDetectorAssociator.h.

const Propagator* TrackDetectorAssociator::ivProp_
private

Definition at line 185 of file TrackDetectorAssociator.h.

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

Definition at line 194 of file TrackDetectorAssociator.h.

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

Definition at line 195 of file TrackDetectorAssociator.h.

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

Definition at line 197 of file TrackDetectorAssociator.h.

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

Definition at line 200 of file TrackDetectorAssociator.h.

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

Definition at line 198 of file TrackDetectorAssociator.h.

bool TrackDetectorAssociator::useDefaultPropagator_
private

Definition at line 188 of file TrackDetectorAssociator.h.