test
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 &)
 
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
< 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 846 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().

849 {
850  LogTrace("TrackAssociator")
851  << "Segment local position: " << segment->localPosition() << "\n"
852  << std::hex << segment->geographicalId().rawId() << "\n";
853 
854  const GeomDet* chamber = muonDetIdAssociator_->getGeomDet(matchedChamber.id);
855  TrajectoryStateOnSurface trajectoryStateOnSurface = matchedChamber.tState;
856  GlobalPoint segmentGlobalPosition = chamber->toGlobal(segment->localPosition());
857 
858  LogTrace("TrackAssociator")
859  << "Segment global position: " << segmentGlobalPosition << " \t (R_xy,eta,phi): "
860  << segmentGlobalPosition.perp() << "," << segmentGlobalPosition.eta() << "," << segmentGlobalPosition.phi() << "\n";
861 
862  LogTrace("TrackAssociator")
863  << "\teta hit: " << segmentGlobalPosition.eta() << " \tpropagator: " << trajectoryStateOnSurface.freeState()->position().eta() << "\n"
864  << "\tphi hit: " << segmentGlobalPosition.phi() << " \tpropagator: " << trajectoryStateOnSurface.freeState()->position().phi() << std::endl;
865 
866  bool isGood = false;
867  bool isDTWithoutY = false;
868  const DTRecSegment4D* dtseg = dynamic_cast<const DTRecSegment4D*>(segment);
869  if ( dtseg && (! dtseg->hasZed()) )
870  isDTWithoutY = true;
871 
872  double deltaPhi(fabs(segmentGlobalPosition.phi()-trajectoryStateOnSurface.freeState()->position().phi()));
873  if(deltaPhi>M_PI) deltaPhi = fabs(deltaPhi-M_PI*2.);
874 
875  if( isDTWithoutY )
876  {
877  isGood = deltaPhi < parameters.dRMuon;
878  // Be in chamber
879  isGood &= fabs(segmentGlobalPosition.eta()-trajectoryStateOnSurface.freeState()->position().eta()) < .3;
880  } else isGood = sqrt( pow(segmentGlobalPosition.eta()-trajectoryStateOnSurface.freeState()->position().eta(),2) +
881  deltaPhi*deltaPhi) < parameters.dRMuon;
882 
883  if(isGood) {
884  TAMuonSegmentMatch muonSegment;
885  muonSegment.segmentGlobalPosition = getPoint(segmentGlobalPosition);
886  muonSegment.segmentLocalPosition = getPoint( segment->localPosition() );
887  muonSegment.segmentLocalDirection = getVector( segment->localDirection() );
888  muonSegment.segmentLocalErrorXX = segment->localPositionError().xx();
889  muonSegment.segmentLocalErrorYY = segment->localPositionError().yy();
890  muonSegment.segmentLocalErrorXY = segment->localPositionError().xy();
891  muonSegment.segmentLocalErrorDxDz = segment->localDirectionError().xx();
892  muonSegment.segmentLocalErrorDyDz = segment->localDirectionError().yy();
893 
894  // DANGEROUS - compiler cannot guaranty parameters ordering
895  // AlgebraicSymMatrix segmentCovMatrix = segment->parametersError();
896  // muonSegment.segmentLocalErrorXDxDz = segmentCovMatrix[2][0];
897  // muonSegment.segmentLocalErrorYDyDz = segmentCovMatrix[3][1];
898  muonSegment.segmentLocalErrorXDxDz = -999;
899  muonSegment.segmentLocalErrorYDyDz = -999;
900  muonSegment.hasZed = true;
901  muonSegment.hasPhi = true;
902 
903  // timing information
904  muonSegment.t0 = 0;
905  if ( dtseg ) {
906  if ( (dtseg->hasPhi()) && (! isDTWithoutY) ) {
907  int phiHits = dtseg->phiSegment()->specificRecHits().size();
908  // int zHits = dtseg->zSegment()->specificRecHits().size();
909  int hits=0;
910  double t0=0.;
911  // TODO: cuts on hit numbers not optimized in any way yet...
912  if (phiHits>5 && dtseg->phiSegment()->ist0Valid()) {
913  t0+=dtseg->phiSegment()->t0()*phiHits;
914  hits+=phiHits;
915  LogTrace("TrackAssociator") << " Phi t0: " << dtseg->phiSegment()->t0() << " hits: " << phiHits;
916  }
917  // the z segments seem to contain little useful information...
918 // if (zHits>3) {
919 // t0+=s->zSegment()->t0()*zHits;
920 // hits+=zHits;
921 // std::cout << " Z t0: " << s->zSegment()->t0() << " hits: " << zHits << std::endl;
922 // }
923  if (hits) muonSegment.t0 = t0/hits;
924 // std::cout << " --- t0: " << muonSegment.t0 << std::endl;
925  } else {
926  // check and set dimensionality
927  if (isDTWithoutY) muonSegment.hasZed = false;
928  if (! dtseg->hasPhi()) muonSegment.hasPhi = false;
929  }
930  }
931  matchedChamber.segments.push_back(muonSegment);
932  }
933 
934  return isGood;
935 }
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 getVector(const GlobalVector &vec)
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
bool hasPhi() const
Does it have the Phi projection?
#define LogTrace(id)
#define M_PI
std::vector< DTRecHit1D > specificRecHits() const
Access to specific components.
bool ist0Valid() const
bool hasZed() const
Does it have the Z projection?
GlobalPoint position() const
math::XYZPoint getPoint(const GlobalPoint &point)
virtual LocalError localPositionError() const =0
T eta() const
Definition: PV3DBase.h:76
edm::ESHandle< DetIdAssociator > muonDetIdAssociator_
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 }
SteppingHelixStateInfo getStateAtHO()
math::XYZPoint trkGlobPosAtHO
dictionary parameters
Definition: Parameters.py:2
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)
void setMaxHOLength(float l=2200.)
void fillHcal(const edm::Event &, TrackDetMatchInfo &, const AssociatorParameters &)
void findHcalTrajectory(const FiducialVolume &)
GlobalVector momentum() const
edm::ESHandle< DetIdAssociator > hcalDetIdAssociator_
math::XYZPoint trkGlobPosAtHcal
FreeTrajectoryState stateAtIP
track info
void fillCaloTowers(const edm::Event &, TrackDetMatchInfo &, const AssociatorParameters &)
void fillCaloTruth(const edm::Event &, TrackDetMatchInfo &, const AssociatorParameters &)
GlobalVector trkMomAtHO
bool propagateAll(const SteppingHelixStateInfo &initialState)
propagate through the whole detector, returns true if successful
GlobalPoint position() const
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)
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.
void setStateAtIP(const SteppingHelixStateInfo &state)
void fillHO(const edm::Event &, TrackDetMatchInfo &, const AssociatorParameters &)
void setMaxDetectorLength(float l=2200.)
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 999 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().

1004 {
1005  double currentStepSize = cachedTrajectory_.getPropagationStep();
1006 
1008  iSetup.get<IdealMagneticFieldRecord>().get(bField);
1009 
1010  if(track.extra().isNull()) {
1011  if ( direction != InsideOut )
1012  throw cms::Exception("FatalError") <<
1013  "No TrackExtra information is available and association is done with something else than InsideOut track.\n" <<
1014  "Either change the parameter or provide needed data!\n";
1015  LogTrace("TrackAssociator") << "Track Extras not found\n";
1016  FreeTrajectoryState initialState = trajectoryStateTransform::initialFreeState(track,&*bField);
1017  return associate(iEvent, iSetup, parameters, &initialState); // 5th argument is null pointer
1018  }
1019 
1020  LogTrace("TrackAssociator") << "Track Extras found\n";
1023  FreeTrajectoryState referenceState = trajectoryStateTransform::initialFreeState(track,&*bField);
1024 
1025  LogTrace("TrackAssociator") << "inner track state (rho, z, phi):" <<
1026  track.innerPosition().Rho() << ", " << track.innerPosition().z() <<
1027  ", " << track.innerPosition().phi() << "\n";
1028  LogTrace("TrackAssociator") << "innerFreeState (rho, z, phi):" <<
1029  innerState.position().perp() << ", " << innerState.position().z() <<
1030  ", " << innerState.position().phi() << "\n";
1031 
1032  LogTrace("TrackAssociator") << "outer track state (rho, z, phi):" <<
1033  track.outerPosition().Rho() << ", " << track.outerPosition().z() <<
1034  ", " << track.outerPosition().phi() << "\n";
1035  LogTrace("TrackAssociator") << "outerFreeState (rho, z, phi):" <<
1036  outerState.position().perp() << ", " << outerState.position().z() <<
1037  ", " << outerState.position().phi() << "\n";
1038 
1039  // InsideOut first
1040  if ( crossedIP( track ) ) {
1041  switch ( direction ) {
1042  case InsideOut:
1043  case Any:
1044  return associate(iEvent, iSetup, parameters, &referenceState, &outerState);
1045  break;
1046  case OutsideIn:
1047  {
1048  cachedTrajectory_.setPropagationStep( -fabs(currentStepSize) );
1049  TrackDetMatchInfo result = associate(iEvent, iSetup, parameters, &innerState, &referenceState);
1050  cachedTrajectory_.setPropagationStep( currentStepSize );
1051  return result;
1052  break;
1053  }
1054  }
1055  } else {
1056  switch ( direction ) {
1057  case InsideOut:
1058  return associate(iEvent, iSetup, parameters, &innerState, &outerState);
1059  break;
1060  case OutsideIn:
1061  {
1062  cachedTrajectory_.setPropagationStep( -fabs(currentStepSize) );
1063  TrackDetMatchInfo result = associate(iEvent, iSetup, parameters, &outerState, &innerState);
1064  cachedTrajectory_.setPropagationStep( currentStepSize );
1065  return result;
1066  break;
1067  }
1068  case Any:
1069  {
1070  // check if we deal with clear outside-in case
1071  if ( track.innerPosition().Dot( track.innerMomentum() ) < 0 &&
1072  track.outerPosition().Dot( track.outerMomentum() ) < 0 )
1073  {
1074  cachedTrajectory_.setPropagationStep( -fabs(currentStepSize) );
1076  if ( track.innerPosition().R() < track.outerPosition().R() )
1077  result = associate(iEvent, iSetup, parameters, &innerState, &outerState);
1078  else
1079  result = associate(iEvent, iSetup, parameters, &outerState, &innerState);
1080  cachedTrajectory_.setPropagationStep( currentStepSize );
1081  return result;
1082  }
1083  }
1084  }
1085  }
1086 
1087  // all other cases
1088  return associate(iEvent, iSetup, parameters, &innerState, &outerState);
1089 }
dictionary parameters
Definition: Parameters.py:2
float getPropagationStep() const
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:97
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:47
const math::XYZPoint & innerPosition() const
position of the innermost hit
Definition: Track.h:42
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:49
FreeTrajectoryState initialFreeState(const reco::Track &tk, const MagneticField *field)
const T & get() const
Definition: EventSetup.h:55
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
Definition: Track.h:45
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 1091 of file TrackDetectorAssociator.cc.

1096 {
1097  return associate(iEvent, iSetup, getFreeTrajectoryState(iSetup, track, vertex), parameters);
1098 }
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 1100 of file TrackDetectorAssociator.cc.

1106 {
1107  return associate(iEvent, iSetup, getFreeTrajectoryState(iSetup, momentum, vertex, charge), parameters);
1108 }
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 1110 of file TrackDetectorAssociator.cc.

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

Referenced by MuonIdProducer::produce().

1111 {
1112  bool crossed = true;
1113  crossed &= (track.innerPosition().rho() > 3 ); // something close to active volume
1114  crossed &= (track.outerPosition().rho() > 3 ); // something close to active volume
1115  crossed &= ( ( track.innerPosition().x()*track.innerMomentum().x() +
1116  track.innerPosition().y()*track.innerMomentum().y() < 0 ) !=
1117  ( track.outerPosition().x()*track.outerMomentum().x() +
1118  track.outerPosition().y()*track.outerMomentum().y() < 0 ) );
1119  return crossed;
1120 }
const math::XYZPoint & outerPosition() const
position of the outermost hit
Definition: Track.h:47
const math::XYZPoint & innerPosition() const
position of the innermost hit
Definition: Track.h:42
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
Definition: Track.h:49
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
Definition: Track.h:45
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, TrackAssociatorParameters::caloTowersToken, TrackDetMatchInfo::crossedTowerIds, TrackDetMatchInfo::crossedTowers, TrackAssociatorParameters::dRHcal, TrackAssociatorParameters::dRHcalPreselection, edm::Event::getByToken(), CachedTrajectory::IpToHcal, TrackDetMatchInfo::isGoodCalo, edm::HandleBase::isValid(), LogTrace, 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  iEvent.getByToken(parameters.caloTowersToken, caloTowers);
381  if (!caloTowers.isValid()) throw cms::Exception("FatalError") << "Unable to find CaloTowers in event!\n";
382 
383  // timers.pop_and_push("TrackDetectorAssociator::fillCaloTowers::matching");
384  std::set<DetId> caloTowerIdsInRegion;
385  if (parameters.accountForTrajectoryChangeCalo){
386  // get trajectory change with respect to initial state
388  parameters.dRHcalPreselection);
389  caloTowerIdsInRegion = caloDetIdAssociator_->getDetIdsCloseToAPoint(trajectory[0],mapRange);
390  } else caloTowerIdsInRegion = caloDetIdAssociator_->getDetIdsCloseToAPoint(trajectory[0], parameters.dRHcalPreselection);
391 
392  LogTrace("TrackAssociator") << "Towers in the region: " << caloTowerIdsInRegion.size();
393  std::set<DetId> caloTowerIdsInACone = caloDetIdAssociator_->getDetIdsInACone(caloTowerIdsInRegion, trajectory, parameters.dRHcal);
394  LogTrace("TrackAssociator") << "Towers in the cone: " << caloTowerIdsInACone.size();
395  std::vector<DetId> crossedCaloTowerIds = caloDetIdAssociator_->getCrossedDetIds(caloTowerIdsInRegion, trajectory);
396  LogTrace("TrackAssociator") << "Towers crossed: " << crossedCaloTowerIds.size();
397 
398  info.crossedTowerIds = crossedCaloTowerIds;
399 
400  // add CaloTowers
401  // timers.pop_and_push("TrackDetectorAssociator::fillCaloTowers::addCrossedTowers");
402  for(std::vector<DetId>::const_iterator itr=crossedCaloTowerIds.begin(); itr!=crossedCaloTowerIds.end();itr++)
403  {
404  CaloTowerCollection::const_iterator tower = (*caloTowers).find(*itr);
405  if(tower != (*caloTowers).end())
406  info.crossedTowers.push_back(&*tower);
407  else
408  LogTrace("TrackAssociator") << "Crossed CaloTower is not found for DetId: " << (*itr).rawId();
409  }
410 
411  // timers.pop_and_push("TrackDetectorAssociator::fillCaloTowers::addTowersInTheRegion");
412  for(std::set<DetId>::const_iterator itr=caloTowerIdsInACone.begin(); itr!=caloTowerIdsInACone.end();itr++)
413  {
414  CaloTowerCollection::const_iterator tower = (*caloTowers).find(*itr);
415  if(tower != (*caloTowers).end())
416  info.towers.push_back(&*tower);
417  else
418  LogTrace("TrackAssociator") << "CaloTower from the cone is not found for DetId: " << (*itr).rawId();
419  }
420 
421 }
dictionary parameters
Definition: Parameters.py:2
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:434
std::vector< CaloTower >::const_iterator const_iterator
const std::vector< SteppingHelixStateInfo > & getEcalTrajectory() const
std::pair< float, float > trajectoryDelta(TrajectorType)
bool isValid() const
Definition: HandleBase.h:76
#define LogTrace(id)
DetIdAssociator::MapRange getMapRange(const std::pair< float, float > &delta, const float dR)
edm::ESHandle< DetIdAssociator > caloDetIdAssociator_
void TrackDetectorAssociator::fillCaloTruth ( const edm::Event iEvent,
TrackDetMatchInfo info,
const AssociatorParameters parameters 
)
private

Definition at line 939 of file TrackDetectorAssociator.cc.

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

942 {
943  // get list of simulated tracks and their vertices
944  using namespace edm;
945  Handle<SimTrackContainer> simTracks;
946  iEvent.getByToken(parameters.simTracksToken, simTracks);
947  if (! simTracks.isValid() ) throw cms::Exception("FatalError") << "No simulated tracks found\n";
948 
949  Handle<SimVertexContainer> simVertices;
950  iEvent.getByToken(parameters.simVerticesToken, simVertices);
951  if (! simVertices.isValid() ) throw cms::Exception("FatalError") << "No simulated vertices found\n";
952 
953  // get sim calo hits
954  Handle<PCaloHitContainer> simEcalHitsEB;
955  iEvent.getByToken(parameters.simEcalHitsEBToken, simEcalHitsEB);
956  if (! simEcalHitsEB.isValid() ) throw cms::Exception("FatalError") << "No simulated ECAL EB hits found\n";
957 
958  Handle<PCaloHitContainer> simEcalHitsEE;
959  iEvent.getByToken(parameters.simEcalHitsEEToken, simEcalHitsEE);
960  if (! simEcalHitsEE.isValid() ) throw cms::Exception("FatalError") << "No simulated ECAL EE hits found\n";
961 
962  Handle<PCaloHitContainer> simHcalHits;
963  iEvent.getByToken(parameters.simHcalHitsToken, simHcalHits);
964  if (! simHcalHits.isValid() ) throw cms::Exception("FatalError") << "No simulated HCAL hits found\n";
965 
966  // find truth partner
967  SimTrackContainer::const_iterator simTrack = simTracks->begin();
968  for( ; simTrack != simTracks->end(); ++simTrack){
969  math::XYZVector simP3( simTrack->momentum().x(), simTrack->momentum().y(), simTrack->momentum().z() );
970  math::XYZVector recoP3( info.stateAtIP.momentum().x(), info.stateAtIP.momentum().y(), info.stateAtIP.momentum().z() );
971  if ( ROOT::Math::VectorUtil::DeltaR(recoP3, simP3) < 0.1 ) break;
972  }
973  if ( simTrack != simTracks->end() ) {
974  info.simTrack = &(*simTrack);
975  double ecalTrueEnergy(0);
976  double hcalTrueEnergy(0);
977 
978  // loop over calo hits
979  for( PCaloHitContainer::const_iterator hit = simEcalHitsEB->begin(); hit != simEcalHitsEB->end(); ++hit )
980  if ( hit->geantTrackId() == info.simTrack->genpartIndex() ) ecalTrueEnergy += hit->energy();
981 
982  for( PCaloHitContainer::const_iterator hit = simEcalHitsEE->begin(); hit != simEcalHitsEE->end(); ++hit )
983  if ( hit->geantTrackId() == info.simTrack->genpartIndex() ) ecalTrueEnergy += hit->energy();
984 
985  for( PCaloHitContainer::const_iterator hit = simHcalHits->begin(); hit != simHcalHits->end(); ++hit )
986  if ( hit->geantTrackId() == info.simTrack->genpartIndex() ) hcalTrueEnergy += hit->energy();
987 
988  info.ecalTrueEnergy = ecalTrueEnergy;
989  info.hcalTrueEnergy = hcalTrueEnergy;
990  info.hcalTrueEnergyCorrected = hcalTrueEnergy;
991  if ( fabs(info.trkGlobPosAtHcal.eta()) < 1.3 )
992  info.hcalTrueEnergyCorrected = hcalTrueEnergy*113.2;
993  else
994  if ( fabs(info.trkGlobPosAtHcal.eta()) < 3.0 )
995  info.hcalTrueEnergyCorrected = hcalTrueEnergy*167.2;
996  }
997 }
dictionary parameters
Definition: Parameters.py:2
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
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
GlobalVector momentum() const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
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 271 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.

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.getByToken(parameters.EBRecHitsToken, 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.getByToken(parameters.EERecHitsToken, 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
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
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
edm::ESHandle< DetIdAssociator > ecalDetIdAssociator_
std::pair< float, float > trajectoryDelta(TrajectorType)
bool isValid() const
Definition: HandleBase.h:76
#define LogTrace(id)
DetIdAssociator::MapRange getMapRange(const std::pair< float, float > &delta, const float dR)
void TrackDetectorAssociator::fillHcal ( const edm::Event iEvent,
TrackDetMatchInfo info,
const AssociatorParameters parameters 
)
private

Definition at line 448 of file TrackDetectorAssociator.cc.

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

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

Definition at line 513 of file TrackDetectorAssociator.cc.

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

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

References TrackDetMatchInfo::chambers, cscSegments_cfi::cscSegments, TrackAssociatorParameters::cscSegmentsToken, TrackAssociatorParameters::dtSegmentsToken, edm::Event::getByToken(), edm::HandleBase::isValid(), and LogTrace.

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

Definition at line 423 of file TrackDetectorAssociator.cc.

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

426 {
427  std::vector<GlobalPoint> trajectory;
428  const std::vector<SteppingHelixStateInfo>& trajectoryStates = cachedTrajectory_.getPreshowerTrajectory();
429  for(std::vector<SteppingHelixStateInfo>::const_iterator itr = trajectoryStates.begin();
430  itr != trajectoryStates.end(); itr++) trajectory.push_back(itr->position());
431 
432  if(trajectory.empty()) {
433  LogTrace("TrackAssociator") << "Preshower trajectory is empty; moving on\n";
434  return;
435  }
436 
437  std::set<DetId> idsInRegion =
438  preshowerDetIdAssociator_->getDetIdsCloseToAPoint(trajectory[0],
439  parameters.dRPreshowerPreselection);
440 
441  LogTrace("TrackAssociator") << "Number of Preshower Ids in the region: " << idsInRegion.size();
442  std::vector<DetId> crossedIds = preshowerDetIdAssociator_->getCrossedDetIds(idsInRegion, trajectory);
443  LogTrace("TrackAssociator") << "Number of Preshower Ids in crossed: " << crossedIds.size();
444  info.crossedPreshowerIds = crossedIds;
445 }
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 611 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().

613 {
615  iSetup.get<IdealMagneticFieldRecord>().get(bField);
616 
617  GlobalVector vector( track.momentum().x(), track.momentum().y(), track.momentum().z() );
618 
619  GlobalPoint point( track.vertex().x(), track.vertex().y(), track.vertex().z() );
620 
621  GlobalTrajectoryParameters tPars(point, vector, track.charge(), &*bField);
622 
623  // FIX THIS !!!
624  // need to convert from perigee to global or helix (curvilinear) frame
625  // for now just an arbitrary matrix.
626  ROOT::Math::SMatrixIdentity id;
627  AlgebraicSymMatrix66 covT(id); covT *= 1e-6; // initialize to sigma=1e-3
628  CartesianTrajectoryError tCov(covT);
629 
630  return FreeTrajectoryState(tPars, tCov);
631 }
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 578 of file TrackDetectorAssociator.cc.

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

581 {
582  GlobalVector vector( track.momentum().x(), track.momentum().y(), track.momentum().z() );
583  GlobalPoint point( vertex.position().x(), vertex.position().y(), vertex.position().z() );
584 
585  int charge = track.type( )> 0 ? -1 : 1; // lepton convention
586  if ( abs(track.type( )) == 211 || // pion
587  abs(track.type( )) == 321 || // kaon
588  abs(track.type( )) == 2212 )
589  charge = track.type( )< 0 ? -1 : 1;
590  return getFreeTrajectoryState(iSetup, vector, point, charge);
591 }
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: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

Definition at line 593 of file TrackDetectorAssociator.cc.

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

597 {
599  iSetup.get<IdealMagneticFieldRecord>().get(bField);
600 
601  GlobalTrajectoryParameters tPars(vertex, momentum, charge, &*bField);
602 
603  ROOT::Math::SMatrixIdentity id;
604  AlgebraicSymMatrix66 covT(id); covT *= 1e-6; // initialize to sigma=1e-3
605  CartesianTrajectoryError tCov(covT);
606 
607  return FreeTrajectoryState(tPars, tCov);
608 }
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 633 of file TrackDetectorAssociator.cc.

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

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

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

References anyDirection, SteppingHelixPropagator::applyRadX0Correction(), ecalTB2006H4_GenSimDigiReco_cfg::bField, edm::EventSetup::get(), SteppingHelixPropagator::setMaterialMode(), 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
void applyRadX0Correction(bool applyRadX0Correction)
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 setMaterialMode(bool noMaterial)
Switch for material effects mode: no material effects if true.
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)
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.