CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 &) dso_internal
 
void fillCaloTowers (const edm::Event &, TrackDetMatchInfo &, const AssociatorParameters &) dso_internal
 
void fillCaloTruth (const edm::Event &, TrackDetMatchInfo &, const AssociatorParameters &) dso_internal
 
void fillEcal (const edm::Event &, TrackDetMatchInfo &, const AssociatorParameters &) dso_internal
 
void fillHcal (const edm::Event &, TrackDetMatchInfo &, const AssociatorParameters &) dso_internal
 
void fillHO (const edm::Event &, TrackDetMatchInfo &, const AssociatorParameters &) dso_internal
 
void fillMuon (const edm::Event &, TrackDetMatchInfo &, const AssociatorParameters &) dso_internal
 
void fillPreshower (const edm::Event &iEvent, TrackDetMatchInfo &info, const AssociatorParameters &) dso_internal
 
DetIdAssociator::MapRange getMapRange (const std::pair< float, float > &delta, const float dR) dso_internal
 
math::XYZPoint getPoint (const GlobalPoint &point) dso_internal
 
math::XYZPoint getPoint (const LocalPoint &point) dso_internal
 
void getTAMuonChamberMatches (std::vector< TAMuonChamberMatch > &matches, const AssociatorParameters &parameters) dso_internal
 
math::XYZVector getVector (const GlobalVector &vec) dso_internal
 
math::XYZVector getVector (const LocalVector &vec) dso_internal
 
void init (const edm::EventSetup &) dso_internal
 

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
< IdealMagneticFieldRecord
theMagneticFeildWatcher_
 
edm::ESHandle
< GlobalTrackingGeometry
theTrackingGeometry_
 
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 101 of file TrackDetectorAssociator.cc.

102 {
103  ivProp_ = 0;
104  defProp_ = 0;
105  useDefaultPropagator_ = false;
106 }
TrackDetectorAssociator::~TrackDetectorAssociator ( )

Definition at line 108 of file TrackDetectorAssociator.cc.

109 {
110  if (defProp_) delete defProp_;
111 }

Member Function Documentation

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

Definition at line 849 of file TrackDetectorAssociator.cc.

References reco::deltaPhi(), TrackAssociatorParameters::dRMuon, PV3DBase< T, PVType, FrameType >::eta(), TrajectoryStateOnSurface::freeState(), TrackingRecHit::geographicalId(), TAMuonSegmentMatch::hasPhi, DTRecSegment4D::hasPhi(), TAMuonSegmentMatch::hasZed, DTRecSegment4D::hasZed(), 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(), GeomDet::toGlobal(), TAMuonChamberMatch::tState, LocalError::xx(), LocalError::xy(), and LocalError::yy().

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

Referenced by BetaCalculatorECAL::addInfoToCandidate(), EopTreeWriter::analyze(), EcalCosmicsHists::analyze(), IsolatedTracksCone::analyze(), spr::chargeIsolation(), spr::chargeIsolationEcal(), spr::chargeIsolationHcal(), spr::coneChargeIsolation(), muonisolation::JetExtractor::deposit(), muonisolation::CaloExtractorByAssociator::deposits(), cms::MuonMETValueMapProducer::determine_deltax_deltay(), MuonDetCleaner::fillHitMap(), MuonIdProducer::fillMuonId(), SelectReplacementCandidates::getRawIDsAdvanced(), getTrackDetMatchInfo(), InterestingTrackEcalDetIdProducer::produce(), AlCaIsoTracksProducer::produce(), HighPtTrackEcalDetIdProducer::produce(), and ReduceHcalRecHitCollectionProducer::produce().

162 {
163  return associate(iEvent,iSetup,parameters,&fts);
164 }
dictionary parameters
Definition: Parameters.py:2
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 166 of file TrackDetectorAssociator.cc.

References edm::hlt::Exception, info(), init, LogTrace, CosmicsPD_Skims::maxZ, 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, and PV3DBase< T, PVType, FrameType >::z().

171 {
173  if (! parameters.useEcal && ! parameters.useCalo && ! parameters.useHcal &&
174  ! parameters.useHO && ! parameters.useMuon && !parameters.usePreshower)
175  throw cms::Exception("ConfigurationError") <<
176  "Configuration error! No subdetector was selected for the track association.";
177  // TimerStack timers;
178  // timers.push("TrackDetectorAssociator::associate",TimerStack::DetailedMonitoring);
179 
180  SteppingHelixStateInfo trackOrigin(*innerState);
181  info.stateAtIP = *innerState;
182  cachedTrajectory_.setStateAtIP(trackOrigin);
183 
184  init( iSetup );
185  // get track trajectory
186  // timers.push("TrackDetectorAssociator::fillEcal::propagation");
187  // ECAL points (EB+EE)
188  // If the phi angle between a track entrance and exit points is more
189  // than 2 crystals, it is possible that the track will cross 3 crystals
190  // and therefore one has to check at least 3 points along the track
191  // trajectory inside ECAL. In order to have a chance to cross 4 crystalls
192  // in the barrel, a track should have P_t as low as 3 GeV or smaller
193  // If it's necessary, number of points along trajectory can be increased
194 
196 
197  // timers.push("TrackDetectorAssociator::associate::getTrajectories");
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();
206  double minZ = preshowerDetIdAssociator_->volume().minZ();
211 
212  double maxR(0);
213  double maxZ(0);
214 
215  if (parameters.useMuon) {
216  maxR = muonDetIdAssociator_->volume().maxR();
217  maxZ = muonDetIdAssociator_->volume().maxZ();
220  }
221  else {
222  maxR = HOmaxR;
223  maxZ = HOmaxZ;
226  }
227 
228  // If track extras exist and outerState is before HO maximum, then use outerState
229  if (outerState) {
230  if (outerState->position().perp()<HOmaxR && fabs(outerState->position().z())<HOmaxZ) {
231  LogTrace("TrackAssociator") << "Using outerState as trackOrigin at Rho=" << outerState->position().perp()
232  << " Z=" << outerState->position().z() << "\n";
233  trackOrigin = SteppingHelixStateInfo(*outerState);
234  }
235  else if(innerState) {
236  LogTrace("TrackAssociator") << "Using innerState as trackOrigin at Rho=" << innerState->position().perp()
237  << " Z=" << innerState->position().z() << "\n";
238  trackOrigin = SteppingHelixStateInfo(*innerState);
239  }
240  }
241 
242  if ( ! cachedTrajectory_.propagateAll(trackOrigin) ) return info;
243 
244  // get trajectory in calorimeters
249 
253 
257 
258  // timers.pop_and_push("TrackDetectorAssociator::associate::fillInfo");
259 
260  if (parameters.useEcal) fillEcal( iEvent, info, parameters);
261  if (parameters.useCalo) fillCaloTowers( iEvent, info, parameters);
262  if (parameters.useHcal) fillHcal( iEvent, info, parameters);
263  if (parameters.useHO) fillHO( iEvent, info, parameters);
264  if (parameters.usePreshower) fillPreshower( iEvent, info, parameters);
265  if (parameters.useMuon) fillMuon( iEvent, info, parameters);
266  if (parameters.truthMatch) fillCaloTruth( iEvent, info, parameters);
267 
268  return info;
269 }
void setMaxDetectorLength(float l=2200.) dso_internal
math::XYZPoint trkGlobPosAtHO
dictionary parameters
Definition: Parameters.py:2
static const TGPicture * info(bool iBackgroundIsBlack)
void fillHO(const edm::Event &, TrackDetMatchInfo &, const AssociatorParameters &) dso_internal
void findEcalTrajectory(const FiducialVolume &) dso_internal
void setMaxHOLength(float l=2200.) dso_internal
T perp() const
Definition: PV3DBase.h:72
void fillCaloTowers(const edm::Event &, TrackDetMatchInfo &, const AssociatorParameters &) dso_internal
void setMinDetectorRadius(float r=0.) dso_internal
void reset_trajectory() dso_internal
SteppingHelixStateInfo getStateAtHO() dso_internal
void fillPreshower(const edm::Event &iEvent, TrackDetMatchInfo &info, const AssociatorParameters &) dso_internal
void setCaloGeometry(edm::ESHandle< CaloGeometry > geometry)
void fillMuon(const edm::Event &, TrackDetMatchInfo &, const AssociatorParameters &) dso_internal
void findHcalTrajectory(const FiducialVolume &) dso_internal
GlobalVector momentum() const
edm::ESHandle< DetIdAssociator > hcalDetIdAssociator_
void setMaxHORadius(float r=800.) dso_internal
math::XYZPoint trkGlobPosAtHcal
FreeTrajectoryState stateAtIP
track info
void fillHcal(const edm::Event &, TrackDetMatchInfo &, const AssociatorParameters &) dso_internal
GlobalVector trkMomAtHO
GlobalPoint position() const
T z() const
Definition: PV3DBase.h:64
void fillCaloTruth(const edm::Event &, TrackDetMatchInfo &, const AssociatorParameters &) dso_internal
math::XYZPoint getPoint(const GlobalPoint &point) dso_internal
edm::ESHandle< CaloGeometry > theCaloGeometry_
edm::ESHandle< DetIdAssociator > ecalDetIdAssociator_
#define LogTrace(id)
void findPreshowerTrajectory(const FiducialVolume &) dso_internal
GlobalPoint position() const
GlobalVector trkMomAtEcal
edm::ESHandle< DetIdAssociator > hoDetIdAssociator_
bool propagateAll(const SteppingHelixStateInfo &initialState) dso_internal
propagate through the whole detector, returns true if successful
void fillEcal(const edm::Event &, TrackDetMatchInfo &, const AssociatorParameters &) dso_internal
void setStateAtIP(const SteppingHelixStateInfo &state) dso_internal
GlobalVector trkMomAtHcal
edm::ESHandle< DetIdAssociator > muonDetIdAssociator_
edm::ESHandle< DetIdAssociator > preshowerDetIdAssociator_
void init(const edm::EventSetup &) dso_internal
SteppingHelixStateInfo getStateAtHcal() dso_internal
void findHOTrajectory(const FiducialVolume &) dso_internal
math::XYZPoint trkGlobPosAtEcal
Track position at different parts of the calorimeter.
SteppingHelixStateInfo getStateAtEcal() dso_internal
void setMinDetectorLength(float l=0.) dso_internal
void setMaxDetectorRadius(float r=800.) dso_internal
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 1002 of file TrackDetectorAssociator.cc.

References ecalTB2006H4_GenSimDigiReco_cfg::bField, edm::hlt::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(), query::result, and PV3DBase< T, PVType, FrameType >::z().

1007 {
1008  double currentStepSize = cachedTrajectory_.getPropagationStep();
1009 
1011  iSetup.get<IdealMagneticFieldRecord>().get(bField);
1012 
1013  if(track.extra().isNull()) {
1014  if ( direction != InsideOut )
1015  throw cms::Exception("FatalError") <<
1016  "No TrackExtra information is available and association is done with something else than InsideOut track.\n" <<
1017  "Either change the parameter or provide needed data!\n";
1018  LogTrace("TrackAssociator") << "Track Extras not found\n";
1019  FreeTrajectoryState initialState = trajectoryStateTransform::initialFreeState(track,&*bField);
1020  return associate(iEvent, iSetup, parameters, &initialState); // 5th argument is null pointer
1021  }
1022 
1023  LogTrace("TrackAssociator") << "Track Extras found\n";
1026  FreeTrajectoryState referenceState = trajectoryStateTransform::initialFreeState(track,&*bField);
1027 
1028  LogTrace("TrackAssociator") << "inner track state (rho, z, phi):" <<
1029  track.innerPosition().Rho() << ", " << track.innerPosition().z() <<
1030  ", " << track.innerPosition().phi() << "\n";
1031  LogTrace("TrackAssociator") << "innerFreeState (rho, z, phi):" <<
1032  innerState.position().perp() << ", " << innerState.position().z() <<
1033  ", " << innerState.position().phi() << "\n";
1034 
1035  LogTrace("TrackAssociator") << "outer track state (rho, z, phi):" <<
1036  track.outerPosition().Rho() << ", " << track.outerPosition().z() <<
1037  ", " << track.outerPosition().phi() << "\n";
1038  LogTrace("TrackAssociator") << "outerFreeState (rho, z, phi):" <<
1039  outerState.position().perp() << ", " << outerState.position().z() <<
1040  ", " << 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  {
1051  cachedTrajectory_.setPropagationStep( -fabs(currentStepSize) );
1052  TrackDetMatchInfo result = associate(iEvent, iSetup, parameters, &innerState, &referenceState);
1053  cachedTrajectory_.setPropagationStep( currentStepSize );
1054  return result;
1055  break;
1056  }
1057  }
1058  } else {
1059  switch ( direction ) {
1060  case InsideOut:
1061  return associate(iEvent, iSetup, parameters, &innerState, &outerState);
1062  break;
1063  case OutsideIn:
1064  {
1065  cachedTrajectory_.setPropagationStep( -fabs(currentStepSize) );
1066  TrackDetMatchInfo result = associate(iEvent, iSetup, parameters, &outerState, &innerState);
1067  cachedTrajectory_.setPropagationStep( currentStepSize );
1068  return result;
1069  break;
1070  }
1071  case Any:
1072  {
1073  // check if we deal with clear outside-in case
1074  if ( track.innerPosition().Dot( track.innerMomentum() ) < 0 &&
1075  track.outerPosition().Dot( track.outerMomentum() ) < 0 )
1076  {
1077  cachedTrajectory_.setPropagationStep( -fabs(currentStepSize) );
1079  if ( track.innerPosition().R() < track.outerPosition().R() )
1080  result = associate(iEvent, iSetup, parameters, &innerState, &outerState);
1081  else
1082  result = associate(iEvent, iSetup, parameters, &outerState, &innerState);
1083  cachedTrajectory_.setPropagationStep( currentStepSize );
1084  return result;
1085  }
1086  }
1087  }
1088  }
1089 
1090  // all other cases
1091  return associate(iEvent, iSetup, parameters, &innerState, &outerState);
1092 }
dictionary parameters
Definition: Parameters.py:2
T perp() const
Definition: PV3DBase.h:72
static bool crossedIP(const reco::Track &track)
const TrackExtraRef & extra() const
reference to &quot;extra&quot; object
Definition: Track.h:96
FreeTrajectoryState innerFreeState(const reco::Track &tk, const MagneticField *field)
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:46
const math::XYZPoint & innerPosition() const
position of the innermost hit
Definition: Track.h:41
bool isNull() const
Checks for null.
Definition: Ref.h:247
T z() const
Definition: PV3DBase.h:64
tuple result
Definition: query.py:137
#define LogTrace(id)
GlobalPoint position() const
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
Definition: Track.h:48
FreeTrajectoryState initialFreeState(const reco::Track &tk, const MagneticField *field)
const T & get() const
Definition: EventSetup.h:55
float getPropagationStep() const dso_internal
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
Definition: Track.h:44
TrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const AssociatorParameters &)
FreeTrajectoryState outerFreeState(const reco::Track &tk, const MagneticField *field)
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 1094 of file TrackDetectorAssociator.cc.

1099 {
1100  return associate(iEvent, iSetup, getFreeTrajectoryState(iSetup, track, vertex), parameters);
1101 }
dictionary parameters
Definition: Parameters.py:2
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 1103 of file TrackDetectorAssociator.cc.

1109 {
1110  return associate(iEvent, iSetup, getFreeTrajectoryState(iSetup, momentum, vertex, charge), parameters);
1111 }
dictionary parameters
Definition: Parameters.py:2
static FreeTrajectoryState getFreeTrajectoryState(const edm::EventSetup &, const reco::Track &)
get FreeTrajectoryState from different track representations
double charge(const std::vector< uint8_t > &Ampls)
TrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const AssociatorParameters &)
bool TrackDetectorAssociator::crossedIP ( const reco::Track track)
static

Definition at line 1113 of file TrackDetectorAssociator.cc.

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

Referenced by MuonIdProducer::produce().

1114 {
1115  bool crossed = true;
1116  crossed &= (track.innerPosition().rho() > 3 ); // something close to active volume
1117  crossed &= (track.outerPosition().rho() > 3 ); // something close to active volume
1118  crossed &= ( ( track.innerPosition().x()*track.innerMomentum().x() +
1119  track.innerPosition().y()*track.innerMomentum().y() < 0 ) !=
1120  ( track.outerPosition().x()*track.outerMomentum().x() +
1121  track.outerPosition().y()*track.outerMomentum().y() < 0 ) );
1122  return crossed;
1123 }
const math::XYZPoint & outerPosition() const
position of the outermost hit
Definition: Track.h:46
const math::XYZPoint & innerPosition() const
position of the innermost hit
Definition: Track.h:41
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
Definition: Track.h:48
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
Definition: Track.h:44
void TrackDetectorAssociator::fillCaloTowers ( const edm::Event iEvent,
TrackDetMatchInfo info,
const AssociatorParameters parameters 
)
private

Definition at line 354 of file TrackDetectorAssociator.cc.

References TrackAssociatorParameters::accountForTrajectoryChangeCalo, HiRecoJets_cff::caloTowers, TrackDetMatchInfo::crossedTowerIds, TrackDetMatchInfo::crossedTowers, TrackAssociatorParameters::dRHcal, TrackAssociatorParameters::dRHcalPreselection, edm::Event::getByLabel(), CachedTrajectory::IpToHcal, TrackDetMatchInfo::isGoodCalo, edm::HandleBase::isValid(), LogTrace, TrackAssociatorParameters::theCaloTowerCollectionLabel, and TrackDetMatchInfo::towers.

357 {
358  // TimerStack timers;
359  // timers.push("TrackDetectorAssociator::fillCaloTowers");
360 
361  // use ECAL and HCAL trajectories to match a tower. (HO isn't used for matching).
362  std::vector<GlobalPoint> trajectory;
363  const std::vector<SteppingHelixStateInfo>& ecalTrajectoryStates = cachedTrajectory_.getEcalTrajectory();
364  const std::vector<SteppingHelixStateInfo>& hcalTrajectoryStates = cachedTrajectory_.getHcalTrajectory();
365  for(std::vector<SteppingHelixStateInfo>::const_iterator itr = ecalTrajectoryStates.begin();
366  itr != ecalTrajectoryStates.end(); itr++) trajectory.push_back(itr->position());
367  for(std::vector<SteppingHelixStateInfo>::const_iterator itr = hcalTrajectoryStates.begin();
368  itr != hcalTrajectoryStates.end(); itr++) trajectory.push_back(itr->position());
369 
370  if(trajectory.empty()) {
371  LogTrace("TrackAssociator") << "HCAL trajectory is empty; moving on\n";
372  info.isGoodCalo = 0;
373  return;
374  }
375  info.isGoodCalo = 1;
376 
377  // find crossed CaloTowers
378  // timers.push("TrackDetectorAssociator::fillCaloTowers::access::CaloTowers");
380 
381  iEvent.getByLabel( parameters.theCaloTowerCollectionLabel, caloTowers );
382  if (!caloTowers.isValid()) throw cms::Exception("FatalError") << "Unable to find CaloTowers in event!\n";
383 
384  // timers.pop_and_push("TrackDetectorAssociator::fillCaloTowers::matching");
385  std::set<DetId> caloTowerIdsInRegion;
386  if (parameters.accountForTrajectoryChangeCalo){
387  // get trajectory change with respect to initial state
389  parameters.dRHcalPreselection);
390  caloTowerIdsInRegion = caloDetIdAssociator_->getDetIdsCloseToAPoint(trajectory[0],mapRange);
391  } else caloTowerIdsInRegion = caloDetIdAssociator_->getDetIdsCloseToAPoint(trajectory[0], parameters.dRHcalPreselection);
392 
393  LogTrace("TrackAssociator") << "Towers in the region: " << caloTowerIdsInRegion.size();
394  std::set<DetId> caloTowerIdsInACone = caloDetIdAssociator_->getDetIdsInACone(caloTowerIdsInRegion, trajectory, parameters.dRHcal);
395  LogTrace("TrackAssociator") << "Towers in the cone: " << caloTowerIdsInACone.size();
396  std::vector<DetId> crossedCaloTowerIds = caloDetIdAssociator_->getCrossedDetIds(caloTowerIdsInRegion, trajectory);
397  LogTrace("TrackAssociator") << "Towers crossed: " << crossedCaloTowerIds.size();
398 
399  info.crossedTowerIds = crossedCaloTowerIds;
400 
401  // add CaloTowers
402  // timers.pop_and_push("TrackDetectorAssociator::fillCaloTowers::addCrossedTowers");
403  for(std::vector<DetId>::const_iterator itr=crossedCaloTowerIds.begin(); itr!=crossedCaloTowerIds.end();itr++)
404  {
405  CaloTowerCollection::const_iterator tower = (*caloTowers).find(*itr);
406  if(tower != (*caloTowers).end())
407  info.crossedTowers.push_back(&*tower);
408  else
409  LogTrace("TrackAssociator") << "Crossed CaloTower is not found for DetId: " << (*itr).rawId();
410  }
411 
412  // timers.pop_and_push("TrackDetectorAssociator::fillCaloTowers::addTowersInTheRegion");
413  for(std::set<DetId>::const_iterator itr=caloTowerIdsInACone.begin(); itr!=caloTowerIdsInACone.end();itr++)
414  {
415  CaloTowerCollection::const_iterator tower = (*caloTowers).find(*itr);
416  if(tower != (*caloTowers).end())
417  info.towers.push_back(&*tower);
418  else
419  LogTrace("TrackAssociator") << "CaloTower from the cone is not found for DetId: " << (*itr).rawId();
420  }
421 
422 }
dictionary parameters
Definition: Parameters.py:2
std::pair< float, float > trajectoryDelta(TrajectorType) dso_internal
std::vector< const CaloTower * > crossedTowers
std::vector< const CaloTower * > towers
std::vector< DetId > crossedTowerIds
const std::vector< SteppingHelixStateInfo > & getHcalTrajectory() const
std::vector< CaloTower >::const_iterator const_iterator
const std::vector< SteppingHelixStateInfo > & getEcalTrajectory() const
DetIdAssociator::MapRange getMapRange(const std::pair< float, float > &delta, const float dR) dso_internal
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
#define LogTrace(id)
edm::ESHandle< DetIdAssociator > caloDetIdAssociator_
void TrackDetectorAssociator::fillCaloTruth ( const edm::Event iEvent,
TrackDetMatchInfo info,
const AssociatorParameters parameters 
)
private

Definition at line 942 of file TrackDetectorAssociator.cc.

References TrackDetMatchInfo::ecalTrueEnergy, SimTrack::genpartIndex(), edm::Event::getByLabel(), TrackDetMatchInfo::hcalTrueEnergy, TrackDetMatchInfo::hcalTrueEnergyCorrected, FreeTrajectoryState::momentum(), TrackDetMatchInfo::simTrack, TrackDetMatchInfo::stateAtIP, TrackDetMatchInfo::trkGlobPosAtHcal, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

945 {
946  // get list of simulated tracks and their vertices
947  using namespace edm;
948  Handle<SimTrackContainer> simTracks;
949  iEvent.getByLabel<SimTrackContainer>("g4SimHits", simTracks);
950  if (! simTracks.isValid() ) throw cms::Exception("FatalError") << "No simulated tracks found\n";
951 
952  Handle<SimVertexContainer> simVertices;
953  iEvent.getByLabel<SimVertexContainer>("g4SimHits", simVertices);
954  if (! simVertices.isValid() ) throw cms::Exception("FatalError") << "No simulated vertices found\n";
955 
956  // get sim calo hits
957  Handle<PCaloHitContainer> simEcalHitsEB;
958  iEvent.getByLabel("g4SimHits","EcalHitsEB",simEcalHitsEB);
959  if (! simEcalHitsEB.isValid() ) throw cms::Exception("FatalError") << "No simulated ECAL EB hits found\n";
960 
961  Handle<PCaloHitContainer> simEcalHitsEE;
962  iEvent.getByLabel("g4SimHits","EcalHitsEE",simEcalHitsEE);
963  if (! simEcalHitsEE.isValid() ) throw cms::Exception("FatalError") << "No simulated ECAL EE hits found\n";
964 
965  Handle<PCaloHitContainer> simHcalHits;
966  iEvent.getByLabel("g4SimHits","HcalHits",simHcalHits);
967  if (! simHcalHits.isValid() ) throw cms::Exception("FatalError") << "No simulated HCAL hits found\n";
968 
969  // find truth partner
970  SimTrackContainer::const_iterator simTrack = simTracks->begin();
971  for( ; simTrack != simTracks->end(); ++simTrack){
972  math::XYZVector simP3( simTrack->momentum().x(), simTrack->momentum().y(), simTrack->momentum().z() );
973  math::XYZVector recoP3( info.stateAtIP.momentum().x(), info.stateAtIP.momentum().y(), info.stateAtIP.momentum().z() );
974  if ( ROOT::Math::VectorUtil::DeltaR(recoP3, simP3) < 0.1 ) break;
975  }
976  if ( simTrack != simTracks->end() ) {
977  info.simTrack = &(*simTrack);
978  double ecalTrueEnergy(0);
979  double hcalTrueEnergy(0);
980 
981  // loop over calo hits
982  for( PCaloHitContainer::const_iterator hit = simEcalHitsEB->begin(); hit != simEcalHitsEB->end(); ++hit )
983  if ( hit->geantTrackId() == info.simTrack->genpartIndex() ) ecalTrueEnergy += hit->energy();
984 
985  for( PCaloHitContainer::const_iterator hit = simEcalHitsEE->begin(); hit != simEcalHitsEE->end(); ++hit )
986  if ( hit->geantTrackId() == info.simTrack->genpartIndex() ) ecalTrueEnergy += hit->energy();
987 
988  for( PCaloHitContainer::const_iterator hit = simHcalHits->begin(); hit != simHcalHits->end(); ++hit )
989  if ( hit->geantTrackId() == info.simTrack->genpartIndex() ) hcalTrueEnergy += hit->energy();
990 
991  info.ecalTrueEnergy = ecalTrueEnergy;
992  info.hcalTrueEnergy = hcalTrueEnergy;
993  info.hcalTrueEnergyCorrected = hcalTrueEnergy;
994  if ( fabs(info.trkGlobPosAtHcal.eta()) < 1.3 )
995  info.hcalTrueEnergyCorrected = hcalTrueEnergy*113.2;
996  else
997  if ( fabs(info.trkGlobPosAtHcal.eta()) < 3.0 )
998  info.hcalTrueEnergyCorrected = hcalTrueEnergy*167.2;
999  }
1000 }
T y() const
Definition: PV3DBase.h:63
math::XYZPoint trkGlobPosAtHcal
FreeTrajectoryState stateAtIP
track info
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 getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
GlobalVector momentum() const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
std::vector< SimVertex > SimVertexContainer
T x() const
Definition: PV3DBase.h:62
const SimTrack * simTrack
MC truth info.
std::vector< SimTrack > SimTrackContainer
void TrackDetectorAssociator::fillEcal ( const edm::Event iEvent,
TrackDetMatchInfo info,
const AssociatorParameters parameters 
)
private

Definition at line 271 of file TrackDetectorAssociator.cc.

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

274 {
275  // TimerStack timers;
276  // timers.push("TrackDetectorAssociator::fillEcal");
277 
278  const std::vector<SteppingHelixStateInfo>& trajectoryStates = cachedTrajectory_.getEcalTrajectory();
279 
280  for(std::vector<SteppingHelixStateInfo>::const_iterator itr = trajectoryStates.begin();
281  itr != trajectoryStates.end(); itr++)
282  LogTrace("TrackAssociator") << "ECAL trajectory point (rho, z, phi): " << itr->position().perp() <<
283  ", " << itr->position().z() << ", " << itr->position().phi();
284 
285  std::vector<GlobalPoint> coreTrajectory;
286  for(std::vector<SteppingHelixStateInfo>::const_iterator itr = trajectoryStates.begin();
287  itr != trajectoryStates.end(); itr++) coreTrajectory.push_back(itr->position());
288 
289  if(coreTrajectory.empty()) {
290  LogTrace("TrackAssociator") << "ECAL track trajectory is empty; moving on\n";
291  info.isGoodEcal = 0;
292  return;
293  }
294  info.isGoodEcal = 1;
295 
296  // Find ECAL crystals
297  // timers.push("TrackDetectorAssociator::fillEcal::access::EcalBarrel");
299  iEvent.getByLabel( parameters.theEBRecHitCollectionLabel, EBRecHits );
300  if (!EBRecHits.isValid()) throw cms::Exception("FatalError") << "Unable to find EBRecHitCollection in the event!\n";
301 
302  // timers.pop_and_push("TrackDetectorAssociator::fillEcal::access::EcalEndcaps");
304  iEvent.getByLabel( parameters.theEERecHitCollectionLabel, EERecHits );
305  if (!EERecHits.isValid()) throw cms::Exception("FatalError") << "Unable to find EERecHitCollection in event!\n";
306 
307  // timers.pop_and_push("TrackDetectorAssociator::fillEcal::matching");
308  // timers.push("TrackDetectorAssociator::fillEcal::matching::region");
309  std::set<DetId> ecalIdsInRegion;
310  if (parameters.accountForTrajectoryChangeCalo){
311  // get trajectory change with respect to initial state
313  parameters.dREcalPreselection);
314  ecalIdsInRegion = ecalDetIdAssociator_->getDetIdsCloseToAPoint(coreTrajectory[0],mapRange);
315  } else ecalIdsInRegion = ecalDetIdAssociator_->getDetIdsCloseToAPoint(coreTrajectory[0], parameters.dREcalPreselection);
316  // timers.pop_and_push("TrackDetectorAssociator::fillEcal::matching::cone");
317  LogTrace("TrackAssociator") << "ECAL hits in the region: " << ecalIdsInRegion.size();
318  if (parameters.dREcalPreselection > parameters.dREcal)
319  ecalIdsInRegion = ecalDetIdAssociator_->getDetIdsInACone(ecalIdsInRegion, coreTrajectory, parameters.dREcal);
320  LogTrace("TrackAssociator") << "ECAL hits in the cone: " << ecalIdsInRegion.size();
321  std::vector<DetId> crossedEcalIds =
322  ecalDetIdAssociator_->getCrossedDetIds(ecalIdsInRegion, coreTrajectory);
323  LogTrace("TrackAssociator") << "ECAL crossed hits " << crossedEcalIds.size();
324 
325  info.crossedEcalIds = crossedEcalIds;
326 
327  // add EcalRecHits
328  // timers.pop_and_push("TrackDetectorAssociator::fillEcal::addCrossedHits");
329  for(std::vector<DetId>::const_iterator itr=crossedEcalIds.begin(); itr!=crossedEcalIds.end();itr++)
330  {
331  std::vector<EcalRecHit>::const_iterator ebHit = (*EBRecHits).find(*itr);
332  std::vector<EcalRecHit>::const_iterator eeHit = (*EERecHits).find(*itr);
333  if(ebHit != (*EBRecHits).end())
334  info.crossedEcalRecHits.push_back(&*ebHit);
335  else if(eeHit != (*EERecHits).end())
336  info.crossedEcalRecHits.push_back(&*eeHit);
337  else
338  LogTrace("TrackAssociator") << "Crossed EcalRecHit is not found for DetId: " << itr->rawId();
339  }
340  // timers.pop_and_push("TrackDetectorAssociator::fillEcal::addHitsInTheRegion");
341  for(std::set<DetId>::const_iterator itr=ecalIdsInRegion.begin(); itr!=ecalIdsInRegion.end();itr++)
342  {
343  std::vector<EcalRecHit>::const_iterator ebHit = (*EBRecHits).find(*itr);
344  std::vector<EcalRecHit>::const_iterator eeHit = (*EERecHits).find(*itr);
345  if(ebHit != (*EBRecHits).end())
346  info.ecalRecHits.push_back(&*ebHit);
347  else if(eeHit != (*EERecHits).end())
348  info.ecalRecHits.push_back(&*eeHit);
349  else
350  LogTrace("TrackAssociator") << "EcalRecHit from the cone is not found for DetId: " << itr->rawId();
351  }
352 }
dictionary parameters
Definition: Parameters.py:2
std::pair< float, float > trajectoryDelta(TrajectorType) dso_internal
std::vector< const EcalRecHit * > ecalRecHits
hits in the cone
std::vector< DetId > crossedEcalIds
std::vector< const EcalRecHit * > crossedEcalRecHits
hits in detector elements crossed by a track
const std::vector< SteppingHelixStateInfo > & getEcalTrajectory() const
DetIdAssociator::MapRange getMapRange(const std::pair< float, float > &delta, const float dR) dso_internal
edm::ESHandle< DetIdAssociator > ecalDetIdAssociator_
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
#define LogTrace(id)
void TrackDetectorAssociator::fillHcal ( const edm::Event iEvent,
TrackDetMatchInfo info,
const AssociatorParameters parameters 
)
private

Definition at line 449 of file TrackDetectorAssociator.cc.

References TrackAssociatorParameters::accountForTrajectoryChangeCalo, runEdmFileComparison::collection, TrackDetMatchInfo::crossedHcalIds, TrackDetMatchInfo::crossedHcalRecHits, TrackAssociatorParameters::dRHcal, TrackAssociatorParameters::dRHcalPreselection, edm::Event::getByLabel(), TrackDetMatchInfo::hcalRecHits, DetIdInfo::info(), CachedTrajectory::IpToHcal, TrackDetMatchInfo::isGoodHcal, edm::HandleBase::isValid(), LogTrace, and TrackAssociatorParameters::theHBHERecHitCollectionLabel.

452 {
453  // TimerStack timers;
454  // timers.push("TrackDetectorAssociator::fillHcal");
455 
456  const std::vector<SteppingHelixStateInfo>& trajectoryStates = cachedTrajectory_.getHcalTrajectory();
457 
458  std::vector<GlobalPoint> coreTrajectory;
459  for(std::vector<SteppingHelixStateInfo>::const_iterator itr = trajectoryStates.begin();
460  itr != trajectoryStates.end(); itr++) coreTrajectory.push_back(itr->position());
461 
462  if(coreTrajectory.empty()) {
463  LogTrace("TrackAssociator") << "HCAL trajectory is empty; moving on\n";
464  info.isGoodHcal = 0;
465  return;
466  }
467  info.isGoodHcal = 1;
468 
469  // find crossed Hcals
470  // timers.push("TrackDetectorAssociator::fillHcal::access::Hcal");
472 
473  iEvent.getByLabel( parameters.theHBHERecHitCollectionLabel, collection );
474  if ( ! collection.isValid() ) throw cms::Exception("FatalError") << "Unable to find HBHERecHits in event!\n";
475 
476  // timers.pop_and_push("TrackDetectorAssociator::fillHcal::matching");
477  std::set<DetId> idsInRegion;
478  if (parameters.accountForTrajectoryChangeCalo){
479  // get trajectory change with respect to initial state
481  parameters.dRHcalPreselection);
482  idsInRegion = hcalDetIdAssociator_->getDetIdsCloseToAPoint(coreTrajectory[0], mapRange);
483  } else idsInRegion = hcalDetIdAssociator_->getDetIdsCloseToAPoint(coreTrajectory[0], parameters.dRHcalPreselection);
484 
485  LogTrace("TrackAssociator") << "HCAL hits in the region: " << idsInRegion.size() << "\n" << DetIdInfo::info(idsInRegion);
486  std::set<DetId> idsInACone = hcalDetIdAssociator_->getDetIdsInACone(idsInRegion, coreTrajectory, parameters.dRHcal);
487  LogTrace("TrackAssociator") << "HCAL hits in the cone: " << idsInACone.size() << "\n" << DetIdInfo::info(idsInACone);
488  std::vector<DetId> crossedIds =
489  hcalDetIdAssociator_->getCrossedDetIds(idsInRegion, coreTrajectory);
490  LogTrace("TrackAssociator") << "HCAL hits crossed: " << crossedIds.size() << "\n" << DetIdInfo::info(crossedIds);
491 
492  info.crossedHcalIds = crossedIds;
493  // timers.pop_and_push("TrackDetectorAssociator::fillHcal::addCrossedHits");
494  // add Hcal
495  // timers.push("TrackDetectorAssociator::fillHcal::addHcal");
496  for(std::vector<DetId>::const_iterator itr=crossedIds.begin(); itr!=crossedIds.end();itr++)
497  {
498  HBHERecHitCollection::const_iterator hit = (*collection).find(*itr);
499  if( hit != (*collection).end() )
500  info.crossedHcalRecHits.push_back(&*hit);
501  else
502  LogTrace("TrackAssociator") << "Crossed HBHERecHit is not found for DetId: " << itr->rawId();
503  }
504  // timers.pop_and_push("TrackDetectorAssociator::fillHcal::addHitsInTheRegion");
505  for(std::set<DetId>::const_iterator itr=idsInACone.begin(); itr!=idsInACone.end();itr++)
506  {
507  HBHERecHitCollection::const_iterator hit = (*collection).find(*itr);
508  if( hit != (*collection).end() )
509  info.hcalRecHits.push_back(&*hit);
510  else
511  LogTrace("TrackAssociator") << "HBHERecHit from the cone is not found for DetId: " << itr->rawId();
512  }
513 }
dictionary parameters
Definition: Parameters.py:2
std::pair< float, float > trajectoryDelta(TrajectorType) dso_internal
std::vector< const HBHERecHit * > crossedHcalRecHits
const std::vector< SteppingHelixStateInfo > & getHcalTrajectory() const
std::vector< HBHERecHit >::const_iterator const_iterator
std::vector< DetId > crossedHcalIds
edm::ESHandle< DetIdAssociator > hcalDetIdAssociator_
DetIdAssociator::MapRange getMapRange(const std::pair< float, float > &delta, const float dR) dso_internal
std::vector< const HBHERecHit * > hcalRecHits
static std::string info(const DetId &)
Definition: DetIdInfo.cc:28
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
#define LogTrace(id)
void TrackDetectorAssociator::fillHO ( const edm::Event iEvent,
TrackDetMatchInfo info,
const AssociatorParameters parameters 
)
private

Definition at line 515 of file TrackDetectorAssociator.cc.

References TrackAssociatorParameters::accountForTrajectoryChangeCalo, runEdmFileComparison::collection, TrackDetMatchInfo::crossedHOIds, TrackDetMatchInfo::crossedHORecHits, TrackAssociatorParameters::dRHcal, TrackAssociatorParameters::dRHcalPreselection, edm::Event::getByLabel(), TrackDetMatchInfo::hoRecHits, CachedTrajectory::IpToHO, TrackDetMatchInfo::isGoodHO, edm::HandleBase::isValid(), LogTrace, and TrackAssociatorParameters::theHORecHitCollectionLabel.

518 {
519  // TimerStack timers;
520  // timers.push("TrackDetectorAssociator::fillHO");
521 
522  const std::vector<SteppingHelixStateInfo>& trajectoryStates = cachedTrajectory_.getHOTrajectory();
523 
524  std::vector<GlobalPoint> coreTrajectory;
525  for(std::vector<SteppingHelixStateInfo>::const_iterator itr = trajectoryStates.begin();
526  itr != trajectoryStates.end(); itr++) coreTrajectory.push_back(itr->position());
527 
528  if(coreTrajectory.empty()) {
529  LogTrace("TrackAssociator") << "HO trajectory is empty; moving on\n";
530  info.isGoodHO = 0;
531  return;
532  }
533  info.isGoodHO = 1;
534 
535  // find crossed HOs
536  // timers.pop_and_push("TrackDetectorAssociator::fillHO::access::HO");
538 
539  iEvent.getByLabel( parameters.theHORecHitCollectionLabel, collection );
540  if ( ! collection.isValid() ) throw cms::Exception("FatalError") << "Unable to find HORecHits in event!\n";
541 
542  // timers.pop_and_push("TrackDetectorAssociator::fillHO::matching");
543  std::set<DetId> idsInRegion;
544  if (parameters.accountForTrajectoryChangeCalo){
545  // get trajectory change with respect to initial state
547  parameters.dRHcalPreselection);
548  idsInRegion = hoDetIdAssociator_->getDetIdsCloseToAPoint(coreTrajectory[0], mapRange);
549  } else idsInRegion = hoDetIdAssociator_->getDetIdsCloseToAPoint(coreTrajectory[0], parameters.dRHcalPreselection);
550 
551  LogTrace("TrackAssociator") << "idsInRegion.size(): " << idsInRegion.size();
552  std::set<DetId> idsInACone = hoDetIdAssociator_->getDetIdsInACone(idsInRegion, coreTrajectory, parameters.dRHcal);
553  LogTrace("TrackAssociator") << "idsInACone.size(): " << idsInACone.size();
554  std::vector<DetId> crossedIds =
555  hoDetIdAssociator_->getCrossedDetIds(idsInRegion, coreTrajectory);
556 
557  info.crossedHOIds = crossedIds;
558 
559  // add HO
560  // timers.pop_and_push("TrackDetectorAssociator::fillHO::addCrossedHits");
561  for(std::vector<DetId>::const_iterator itr=crossedIds.begin(); itr!=crossedIds.end();itr++)
562  {
563  HORecHitCollection::const_iterator hit = (*collection).find(*itr);
564  if( hit != (*collection).end() )
565  info.crossedHORecHits.push_back(&*hit);
566  else
567  LogTrace("TrackAssociator") << "Crossed HORecHit is not found for DetId: " << itr->rawId();
568  }
569 
570  // timers.pop_and_push("TrackDetectorAssociator::fillHO::addHitsInTheRegion");
571  for(std::set<DetId>::const_iterator itr=idsInACone.begin(); itr!=idsInACone.end();itr++)
572  {
573  HORecHitCollection::const_iterator hit = (*collection).find(*itr);
574  if( hit != (*collection).end() )
575  info.hoRecHits.push_back(&*hit);
576  else
577  LogTrace("TrackAssociator") << "HORecHit from the cone is not found for DetId: " << itr->rawId();
578  }
579 }
dictionary parameters
Definition: Parameters.py:2
std::pair< float, float > trajectoryDelta(TrajectorType) dso_internal
const std::vector< SteppingHelixStateInfo > & getHOTrajectory() const
std::vector< HORecHit >::const_iterator const_iterator
DetIdAssociator::MapRange getMapRange(const std::pair< float, float > &delta, const float dR) dso_internal
std::vector< DetId > crossedHOIds
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
#define LogTrace(id)
edm::ESHandle< DetIdAssociator > hoDetIdAssociator_
std::vector< const HORecHit * > crossedHORecHits
std::vector< const HORecHit * > hoRecHits
void TrackDetectorAssociator::fillMuon ( const edm::Event iEvent,
TrackDetMatchInfo info,
const AssociatorParameters parameters 
)
private

Definition at line 775 of file TrackDetectorAssociator.cc.

References TrackDetMatchInfo::chambers, cscSegments_cfi::cscSegments, edm::Event::getByLabel(), edm::HandleBase::isValid(), LogTrace, TrackAssociatorParameters::theCSCSegmentCollectionLabel, and TrackAssociatorParameters::theDTRecSegment4DCollectionLabel.

778 {
779  // TimerStack timers;
780  // timers.push("TrackDetectorAssociator::fillMuon");
781 
782  // Get the segments from the event
783  // timers.push("TrackDetectorAssociator::fillMuon::access");
785  iEvent.getByLabel( parameters.theDTRecSegment4DCollectionLabel, dtSegments );
786  if (! dtSegments.isValid())
787  throw cms::Exception("FatalError") << "Unable to find DTRecSegment4DCollection in event!\n";
788 
790  iEvent.getByLabel( parameters.theCSCSegmentCollectionLabel, cscSegments );
791  if (! cscSegments.isValid())
792  throw cms::Exception("FatalError") << "Unable to find CSCSegmentCollection in event!\n";
793 
795 
796  // check the map of available segments
797  // if there is no segments in a given direction at all,
798  // then there is no point to fly there.
799  //
800  // MISSING
801  // Possible solution: quick search for presence of segments
802  // for the set of DetIds
803 
804  // timers.pop_and_push("TrackDetectorAssociator::fillMuon::matchChembers");
805 
806  // get a set of matches corresponding to muon chambers
807  std::vector<TAMuonChamberMatch> matchedChambers;
808  LogTrace("TrackAssociator") << "Trying to Get ChamberMatches" << std::endl;
809  getTAMuonChamberMatches(matchedChambers, parameters);
810  LogTrace("TrackAssociator") << "Chambers matched: " << matchedChambers.size() << "\n";
811 
812  // Iterate over all chamber matches and fill segment matching
813  // info if it's available
814  // timers.pop_and_push("TrackDetectorAssociator::fillMuon::findSemgents");
815  for(std::vector<TAMuonChamberMatch>::iterator matchedChamber = matchedChambers.begin();
816  matchedChamber != matchedChambers.end(); matchedChamber++)
817  {
818  const GeomDet* geomDet = muonDetIdAssociator_->getGeomDet((*matchedChamber).id);
819  // DT chamber
820  if(const DTChamber* chamber = dynamic_cast<const DTChamber*>(geomDet) ) {
821  // Get the range for the corresponding segments
822  DTRecSegment4DCollection::range range = dtSegments->get(chamber->id());
823  // Loop over the segments of this chamber
824  for (DTRecSegment4DCollection::const_iterator segment = range.first; segment!=range.second; segment++) {
825  if (addTAMuonSegmentMatch(*matchedChamber, &(*segment), parameters)) {
826  matchedChamber->segments.back().dtSegmentRef = DTRecSegment4DRef(dtSegments, segment - dtSegments->begin());
827  }
828  }
829  }else{
830  // CSC Chamber
831  if(const CSCChamber* chamber = dynamic_cast<const CSCChamber*>(geomDet) ) {
832  // Get the range for the corresponding segments
833  CSCSegmentCollection::range range = cscSegments->get(chamber->id());
834  // Loop over the segments
835  for (CSCSegmentCollection::const_iterator segment = range.first; segment!=range.second; segment++) {
836  if (addTAMuonSegmentMatch(*matchedChamber, &(*segment), parameters)) {
837  matchedChamber->segments.back().cscSegmentRef = CSCSegmentRef(cscSegments, segment - cscSegments->begin());
838  }
839  }
840  }else{
841  // throw cms::Exception("FatalError") << "Failed to cast GeomDet object to either DTChamber or CSCChamber. Who is this guy anyway?\n";
842  }
843  }
844  info.chambers.push_back(*matchedChamber);
845  }
846 }
dictionary parameters
Definition: Parameters.py:2
std::pair< const_iterator, const_iterator > range
iterator range
Definition: RangeMap.h:50
edm::Ref< CSCSegmentCollection > CSCSegmentRef
std::vector< TAMuonChamberMatch > chambers
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
#define LogTrace(id)
edm::Ref< DTRecSegment4DCollection > DTRecSegment4DRef
bool addTAMuonSegmentMatch(TAMuonChamberMatch &, const RecSegment *, const AssociatorParameters &) dso_internal
void getTAMuonChamberMatches(std::vector< TAMuonChamberMatch > &matches, const AssociatorParameters &parameters) dso_internal
edm::ESHandle< DetIdAssociator > muonDetIdAssociator_
void TrackDetectorAssociator::fillPreshower ( const edm::Event iEvent,
TrackDetMatchInfo info,
const AssociatorParameters parameters 
)
private

Definition at line 424 of file TrackDetectorAssociator.cc.

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

427 {
428  std::vector<GlobalPoint> trajectory;
429  const std::vector<SteppingHelixStateInfo>& trajectoryStates = cachedTrajectory_.getPreshowerTrajectory();
430  for(std::vector<SteppingHelixStateInfo>::const_iterator itr = trajectoryStates.begin();
431  itr != trajectoryStates.end(); itr++) trajectory.push_back(itr->position());
432 
433  if(trajectory.empty()) {
434  LogTrace("TrackAssociator") << "Preshower trajectory is empty; moving on\n";
435  return;
436  }
437 
438  std::set<DetId> idsInRegion =
439  preshowerDetIdAssociator_->getDetIdsCloseToAPoint(trajectory[0],
440  parameters.dRPreshowerPreselection);
441 
442  LogTrace("TrackAssociator") << "Number of Preshower Ids in the region: " << idsInRegion.size();
443  std::vector<DetId> crossedIds = preshowerDetIdAssociator_->getCrossedDetIds(idsInRegion, trajectory);
444  LogTrace("TrackAssociator") << "Number of Preshower Ids in crossed: " << crossedIds.size();
445  info.crossedPreshowerIds = crossedIds;
446 }
std::vector< DetId > crossedPreshowerIds
dictionary parameters
Definition: Parameters.py:2
const std::vector< SteppingHelixStateInfo > & getPreshowerTrajectory() const
#define LogTrace(id)
edm::ESHandle< DetIdAssociator > preshowerDetIdAssociator_
const CachedTrajectory& TrackDetectorAssociator::getCachedTrajector ( ) const
inline

trajector information

Definition at line 102 of file TrackDetectorAssociator.h.

References cachedTrajectory_.

Referenced by MuonCaloDistanceProducer::fillDistanceMap().

103  {return cachedTrajectory_;}
FreeTrajectoryState TrackDetectorAssociator::getFreeTrajectoryState ( const edm::EventSetup iSetup,
const reco::Track track 
)
static

get FreeTrajectoryState from different track representations

Definition at line 614 of file TrackDetectorAssociator.cc.

References ecalTB2006H4_GenSimDigiReco_cfg::bField, reco::TrackBase::charge(), alignCSCRings::e, edm::EventSetup::get(), reco::TrackBase::momentum(), point, and reco::TrackBase::vertex().

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

616 {
618  iSetup.get<IdealMagneticFieldRecord>().get(bField);
619 
620  GlobalVector vector( track.momentum().x(), track.momentum().y(), track.momentum().z() );
621 
622  GlobalPoint point( track.vertex().x(), track.vertex().y(), track.vertex().z() );
623 
624  GlobalTrajectoryParameters tPars(point, vector, track.charge(), &*bField);
625 
626  // FIX THIS !!!
627  // need to convert from perigee to global or helix (curvilinear) frame
628  // for now just an arbitrary matrix.
629  ROOT::Math::SMatrixIdentity id;
630  AlgebraicSymMatrix66 covT(id); covT *= 1e-6; // initialize to sigma=1e-3
631  CartesianTrajectoryError tCov(covT);
632 
633  return FreeTrajectoryState(tPars, tCov);
634 }
const Vector & momentum() const
track momentum vector
Definition: TrackBase.h:148
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepSym< double, 6 > > AlgebraicSymMatrix66
const Point & vertex() const
reference point on the track. This method is DEPRECATED, please use referencePoint() instead ...
Definition: TrackBase.h:154
const T & get() const
Definition: EventSetup.h:55
int charge() const
track electric charge
Definition: TrackBase.h:111
*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 581 of file TrackDetectorAssociator.cc.

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

584 {
585  GlobalVector vector( track.momentum().x(), track.momentum().y(), track.momentum().z() );
586  GlobalPoint point( vertex.position().x(), vertex.position().y(), vertex.position().z() );
587 
588  int charge = track.type( )> 0 ? -1 : 1; // lepton convention
589  if ( abs(track.type( )) == 211 || // pion
590  abs(track.type( )) == 321 || // kaon
591  abs(track.type( )) == 2212 )
592  charge = track.type( )< 0 ? -1 : 1;
593  return getFreeTrajectoryState(iSetup, vector, point, charge);
594 }
static FreeTrajectoryState getFreeTrajectoryState(const edm::EventSetup &, const reco::Track &)
get FreeTrajectoryState from different track representations
double charge(const std::vector< uint8_t > &Ampls)
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:40
const math::XYZTLorentzVectorD & momentum() const
particle info...
Definition: CoreSimTrack.h:36
*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 596 of file TrackDetectorAssociator.cc.

References ecalTB2006H4_GenSimDigiReco_cfg::bField, alignCSCRings::e, and edm::EventSetup::get().

600 {
602  iSetup.get<IdealMagneticFieldRecord>().get(bField);
603 
604  GlobalTrajectoryParameters tPars(vertex, momentum, charge, &*bField);
605 
606  ROOT::Math::SMatrixIdentity id;
607  AlgebraicSymMatrix66 covT(id); covT *= 1e-6; // initialize to sigma=1e-3
608  CartesianTrajectoryError tCov(covT);
609 
610  return FreeTrajectoryState(tPars, tCov);
611 }
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepSym< double, 6 > > AlgebraicSymMatrix66
double charge(const std::vector< uint8_t > &Ampls)
const T & get() const
Definition: EventSetup.h:55
DetIdAssociator::MapRange TrackDetectorAssociator::getMapRange ( const std::pair< float, float > &  delta,
const float  dR 
)
private

Definition at line 636 of file TrackDetectorAssociator.cc.

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

638 {
639  DetIdAssociator::MapRange mapRange;
640  mapRange.dThetaPlus = dR;
641  mapRange.dThetaMinus = dR;
642  mapRange.dPhiPlus = dR;
643  mapRange.dPhiMinus = dR;
644  if ( delta.first > 0 )
645  mapRange.dThetaPlus += delta.first;
646  else
647  mapRange.dThetaMinus += fabs(delta.first);
648  if ( delta.second > 0 )
649  mapRange.dPhiPlus += delta.second;
650  else
651  mapRange.dPhiMinus += fabs(delta.second);
652  LogTrace("TrackAssociator") << "Selection range: (dThetaPlus, dThetaMinus, dPhiPlus, dPhiMinus, dRPreselection): " <<
653  mapRange.dThetaPlus << ", " << mapRange.dThetaMinus << ", " <<
654  mapRange.dPhiPlus << ", " << mapRange.dPhiMinus << ", " << dR;
655  return mapRange;
656 }
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 658 of file TrackDetectorAssociator.cc.

References Surface::bounds(), TrackAssociatorParameters::dRMuonPreselection, TrajectoryStateOnSurface::freeState(), CachedTrajectory::FullTrajectory, TAMuonChamberMatch::id, DetIdInfo::info(), SteppingHelixStateInfo::isValid(), TrajectoryStateOnSurface::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(), 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().

660 {
661  // Strategy:
662  // Propagate through the whole detector, estimate change in eta and phi
663  // along the trajectory, add this to dRMuon and find DetIds around this
664  // direction using the map. Then propagate fast to each surface and apply
665  // final matching criteria.
666 
667  // TimerStack timers(TimerStack::Disableable);
668  // timers.push("MuonDetIdAssociator::getTrajectoryInMuonDetector");
669  // timers.push("MuonDetIdAssociator::getTrajectoryInMuonDetector::propagation",TimerStack::FastMonitoring);
670  // timers.pop();
671  // get the direction first
673  // If trajectory point at HCAL is not valid, try to use the outer most state of the
674  // trajectory instead.
675  if(! trajectoryPoint.isValid() ) trajectoryPoint = cachedTrajectory_.getOuterState();
676  if(! trajectoryPoint.isValid() ) {
677  LogTrace("TrackAssociator") <<
678  "trajectory position at HCAL is not valid. Assume the track cannot reach muon detectors and skip it";
679  return;
680  }
681 
682  GlobalVector direction = trajectoryPoint.momentum().unit();
683  LogTrace("TrackAssociator") << "muon direction: " << direction << "\n\t and corresponding point: " <<
684  trajectoryPoint.position() <<"\n";
685 
687  parameters.dRMuonPreselection);
688 
689  // and find chamber DetIds
690 
691  // timers.push("MuonDetIdAssociator::getTrajectoryInMuonDetector::getDetIdsCloseToAPoint",TimerStack::FastMonitoring);
692  std::set<DetId> muonIdsInRegion =
693  muonDetIdAssociator_->getDetIdsCloseToAPoint(trajectoryPoint.position(), mapRange);
694  // timers.pop_and_push("MuonDetIdAssociator::getTrajectoryInMuonDetector::matching",TimerStack::FastMonitoring);
695  LogTrace("TrackAssociator") << "Number of chambers to check: " << muonIdsInRegion.size();
696  for(std::set<DetId>::const_iterator detId = muonIdsInRegion.begin(); detId != muonIdsInRegion.end(); detId++)
697  {
698  const GeomDet* geomDet = muonDetIdAssociator_->getGeomDet(*detId);
699  // timers.push("MuonDetIdAssociator::getTrajectoryInMuonDetector::matching::localPropagation",TimerStack::FastMonitoring);
700  TrajectoryStateOnSurface stateOnSurface = cachedTrajectory_.propagate( &geomDet->surface() );
701  if (! stateOnSurface.isValid()) {
702  LogTrace("TrackAssociator") << "Failed to propagate the track; moving on\n\t"<<
703  "Element is not crosssed: " << DetIdInfo::info(*detId) << "\n";
704  continue;
705  }
706  // timers.pop_and_push("MuonDetIdAssociator::getTrajectoryInMuonDetector::matching::geometryAccess",TimerStack::FastMonitoring);
707  LocalPoint localPoint = geomDet->surface().toLocal(stateOnSurface.freeState()->position());
708  LocalError localError = stateOnSurface.localError().positionError();
709  float distanceX = 0;
710  float distanceY = 0;
711  float sigmaX = 0.0;
712  float sigmaY = 0.0;
713  if(const CSCChamber* cscChamber = dynamic_cast<const CSCChamber*>(geomDet) ) {
714  const CSCChamberSpecs* chamberSpecs = cscChamber->specs();
715  if(! chamberSpecs) {
716  LogTrace("TrackAssociator") << "Failed to get CSCChamberSpecs from CSCChamber; moving on\n";
717  continue;
718  }
719  const CSCLayerGeometry* layerGeometry = chamberSpecs->oddLayerGeometry(1);
720  if(! layerGeometry) {
721  LogTrace("TrackAssociator") << "Failed to get CSCLayerGeometry from CSCChamberSpecs; moving on\n";
722  continue;
723  }
724  const CSCWireTopology* wireTopology = layerGeometry->wireTopology();
725  if(! wireTopology) {
726  LogTrace("TrackAssociator") << "Failed to get CSCWireTopology from CSCLayerGeometry; moving on\n";
727  continue;
728  }
729 
730  float wideWidth = wireTopology->wideWidthOfPlane();
731  float narrowWidth = wireTopology->narrowWidthOfPlane();
732  float length = wireTopology->lengthOfPlane();
733  // If slanted, there is no y offset between local origin and symmetry center of wire plane
734  float yOfFirstWire = fabs(wireTopology->wireAngle())>1.E-06 ? -0.5*length : wireTopology->yOfWire(1);
735  // y offset between local origin and symmetry center of wire plane
736  float yCOWPOffset = yOfFirstWire+0.5*length;
737 
738  // tangent of the incline angle from inside the trapezoid
739  float tangent = (wideWidth-narrowWidth)/(2.*length);
740  // y position wrt bottom of trapezoid
741  float yPrime = localPoint.y()+fabs(yOfFirstWire);
742  // half trapezoid width at y' is 0.5 * narrowWidth + x side of triangle with the above tangent and side y'
743  float halfWidthAtYPrime = 0.5*narrowWidth+yPrime*tangent;
744  distanceX = fabs(localPoint.x()) - halfWidthAtYPrime;
745  distanceY = fabs(localPoint.y()-yCOWPOffset) - 0.5*length;
746  sigmaX = distanceX/sqrt(localError.xx());
747  sigmaY = distanceY/sqrt(localError.yy());
748  } else {
749  distanceX = fabs(localPoint.x()) - geomDet->surface().bounds().width()/2.;
750  distanceY = fabs(localPoint.y()) - geomDet->surface().bounds().length()/2.;
751  sigmaX = distanceX/sqrt(localError.xx());
752  sigmaY = distanceY/sqrt(localError.yy());
753  }
754  // timers.pop_and_push("MuonDetIdAssociator::getTrajectoryInMuonDetector::matching::checking",TimerStack::FastMonitoring);
755  if ( (distanceX < parameters.muonMaxDistanceX && distanceY < parameters.muonMaxDistanceY) ||
756  (sigmaX < parameters.muonMaxDistanceSigmaX && sigmaY < parameters.muonMaxDistanceSigmaY) ) {
757  LogTrace("TrackAssociator") << "found a match: " << DetIdInfo::info(*detId) << "\n";
759  match.tState = stateOnSurface;
760  match.localDistanceX = distanceX;
761  match.localDistanceY = distanceY;
762  match.id = *detId;
763  matches.push_back(match);
764  } else {
765  LogTrace("TrackAssociator") << "chamber is too far: " <<
766  DetIdInfo::info(*detId) << "\n\tdistanceX: " << distanceX << "\t distanceY: " << distanceY <<
767  "\t sigmaX: " << sigmaX << "\t sigmaY: " << sigmaY << "\n";
768  }
769  //timers.pop();
770  }
771  //timers.pop();
772 
773 }
float xx() const
Definition: LocalError.h:24
dictionary parameters
Definition: Parameters.py:2
std::pair< float, float > trajectoryDelta(TrajectorType) dso_internal
const CSCWireTopology * wireTopology() const
virtual float length() const =0
TrajectoryStateOnSurface tState
SteppingHelixStateInfo getOuterState() dso_internal
T y() const
Definition: PV3DBase.h:63
const Bounds & bounds() const
Definition: Surface.h:128
GlobalVector momentum() const
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
LocalError positionError() const
float wireAngle() const
float yy() const
Definition: LocalError.h:26
GlobalPoint position() const
DetIdAssociator::MapRange getMapRange(const std::pair< float, float > &delta, const float dR) dso_internal
T sqrt(T t)
Definition: SSEVec.h:48
LocalPoint toLocal(const GlobalPoint &gp) const
FreeTrajectoryState const * freeState(bool withErrors=true) const
static std::string info(const DetId &)
Definition: DetIdInfo.cc:28
double lengthOfPlane() const
const LocalTrajectoryError & localError() const
float yOfWire(float wire, float x=0.) const
#define LogTrace(id)
double narrowWidthOfPlane() const
Vector3DBase unit() const
Definition: Vector3DBase.h:57
GlobalPoint position() const
double wideWidthOfPlane() const
const CSCLayerGeometry * oddLayerGeometry(int iendcap) const
Accessors for LayerGeometry&#39;s.
edm::ESHandle< DetIdAssociator > muonDetIdAssociator_
SteppingHelixStateInfo getStateAtHcal() dso_internal
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:6
void propagate(SteppingHelixStateInfo &state, const Plane &plane) dso_internal
T x() const
Definition: PV3DBase.h:62
virtual float width() const =0
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 125 of file TrackDetectorAssociator.cc.

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

126 {
127  // access the calorimeter geometry
128  iSetup.get<CaloGeometryRecord>().get(theCaloGeometry_);
129  if (!theCaloGeometry_.isValid())
130  throw cms::Exception("FatalError") << "Unable to find CaloGeometryRecord in event!\n";
131 
132  // get the tracking Geometry
135  throw cms::Exception("FatalError") << "Unable to find GlobalTrackingGeometryRecord in event!\n";
136 
138  // setup propagator
140  iSetup.get<IdealMagneticFieldRecord>().get(bField);
141 
143  prop->setMaterialMode(false);
144  prop->applyRadX0Correction(true);
145  // prop->setDebug(true); // tmp
146  defProp_ = prop;
148  }
149 
150  iSetup.get<DetIdAssociatorRecord>().get("EcalDetIdAssociator", ecalDetIdAssociator_);
151  iSetup.get<DetIdAssociatorRecord>().get("HcalDetIdAssociator", hcalDetIdAssociator_);
152  iSetup.get<DetIdAssociatorRecord>().get("HODetIdAssociator", hoDetIdAssociator_);
153  iSetup.get<DetIdAssociatorRecord>().get("CaloDetIdAssociator", caloDetIdAssociator_);
154  iSetup.get<DetIdAssociatorRecord>().get("MuonDetIdAssociator", muonDetIdAssociator_);
155  iSetup.get<DetIdAssociatorRecord>().get("PreshowerDetIdAssociator", preshowerDetIdAssociator_);
156 }
edm::ESWatcher< IdealMagneticFieldRecord > theMagneticFeildWatcher_
edm::ESHandle< DetIdAssociator > hcalDetIdAssociator_
void setPropagator(const Propagator *)
use a user configured propagator
edm::ESHandle< CaloGeometry > theCaloGeometry_
edm::ESHandle< DetIdAssociator > ecalDetIdAssociator_
edm::ESHandle< DetIdAssociator > hoDetIdAssociator_
const T & get() const
Definition: EventSetup.h:55
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:58
edm::ESHandle< DetIdAssociator > muonDetIdAssociator_
edm::ESHandle< DetIdAssociator > preshowerDetIdAssociator_
bool isValid() const
Definition: ESHandle.h:37
edm::ESHandle< DetIdAssociator > caloDetIdAssociator_
edm::ESHandle< GlobalTrackingGeometry > theTrackingGeometry_
void TrackDetectorAssociator::setPropagator ( const Propagator ptr)

use a user configured propagator

Definition at line 113 of file TrackDetectorAssociator.cc.

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

114 {
115  ivProp_ = ptr;
117 }
void setPropagator(const Propagator *ptr) dso_internal
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.