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

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

Definition at line 106 of file TrackDetectorAssociator.cc.

107 {
108  if (defProp_) delete defProp_;
109 }

Member Function Documentation

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

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

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

160 {
161  return associate(iEvent,iSetup,parameters,&fts);
162 }
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 164 of file TrackDetectorAssociator.cc.

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

169 {
171  if (! parameters.useEcal && ! parameters.useCalo && ! parameters.useHcal &&
172  ! parameters.useHO && ! parameters.useMuon && !parameters.usePreshower)
173  throw cms::Exception("ConfigurationError") <<
174  "Configuration error! No subdetector was selected for the track association.";
175 
176  SteppingHelixStateInfo trackOrigin(*innerState);
177  info.stateAtIP = *innerState;
178  cachedTrajectory_.setStateAtIP(trackOrigin);
179 
180  init( iSetup );
181  // get track trajectory
182  // ECAL points (EB+EE)
183  // If the phi angle between a track entrance and exit points is more
184  // than 2 crystals, it is possible that the track will cross 3 crystals
185  // and therefore one has to check at least 3 points along the track
186  // trajectory inside ECAL. In order to have a chance to cross 4 crystalls
187  // in the barrel, a track should have P_t as low as 3 GeV or smaller
188  // If it's necessary, number of points along trajectory can be increased
189 
191 
193  // estimate propagation outer boundaries based on
194  // requested sub-detector information. For now limit
195  // propagation region only if muon matching is not
196  // requested.
197  double HOmaxR = hoDetIdAssociator_->volume().maxR();
198  double HOmaxZ = hoDetIdAssociator_->volume().maxZ();
199  double minR = ecalDetIdAssociator_->volume().minR();
200  double minZ = preshowerDetIdAssociator_->volume().minZ();
205 
206  if (parameters.useMuon) {
207  double maxR = muonDetIdAssociator_->volume().maxR();
208  double maxZ = muonDetIdAssociator_->volume().maxZ();
211  }
212  else {
215  }
216 
217  // If track extras exist and outerState is before HO maximum, then use outerState
218  if (outerState) {
219  if (outerState->position().perp()<HOmaxR && fabs(outerState->position().z())<HOmaxZ) {
220  LogTrace("TrackAssociator") << "Using outerState as trackOrigin at Rho=" << outerState->position().perp()
221  << " Z=" << outerState->position().z() << "\n";
222  trackOrigin = SteppingHelixStateInfo(*outerState);
223  }
224  else if(innerState) {
225  LogTrace("TrackAssociator") << "Using innerState as trackOrigin at Rho=" << innerState->position().perp()
226  << " Z=" << innerState->position().z() << "\n";
227  trackOrigin = SteppingHelixStateInfo(*innerState);
228  }
229  }
230 
231  if ( trackOrigin.momentum().mag() == 0 ) return info;
232  if ( std::isnan(trackOrigin.momentum().x()) or std::isnan(trackOrigin.momentum().y()) or std::isnan(trackOrigin.momentum().z()) ) return info;
233  if ( ! cachedTrajectory_.propagateAll(trackOrigin) ) return info;
234 
235  // get trajectory in calorimeters
240 
244 
248 
249  if (parameters.useEcal) fillEcal( iEvent, info, parameters);
250  if (parameters.useCalo) fillCaloTowers( iEvent, info, parameters);
251  if (parameters.useHcal) fillHcal( iEvent, info, parameters);
252  if (parameters.useHO) fillHO( iEvent, info, parameters);
253  if (parameters.usePreshower) fillPreshower( iEvent, info, parameters);
254  if (parameters.useMuon) fillMuon( iEvent, info, parameters);
255  if (parameters.truthMatch) fillCaloTruth( iEvent, info, parameters);
256 
257  return info;
258 }
SteppingHelixStateInfo getStateAtHO()
math::XYZPoint trkGlobPosAtHO
static const TGPicture * info(bool iBackgroundIsBlack)
T perp() const
Definition: PV3DBase.h:72
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
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
bool isnan(float x)
Definition: math.h:13
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 958 of file TrackDetectorAssociator.cc.

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

963 {
964  double currentStepSize = cachedTrajectory_.getPropagationStep();
965 
967  iSetup.get<IdealMagneticFieldRecord>().get(bField);
968 
969  if(track.extra().isNull()) {
970  if ( direction != InsideOut )
971  throw cms::Exception("FatalError") <<
972  "No TrackExtra information is available and association is done with something else than InsideOut track.\n" <<
973  "Either change the parameter or provide needed data!\n";
974  LogTrace("TrackAssociator") << "Track Extras not found\n";
976  return associate(iEvent, iSetup, parameters, &initialState); // 5th argument is null pointer
977  }
978 
979  LogTrace("TrackAssociator") << "Track Extras found\n";
982  FreeTrajectoryState referenceState = trajectoryStateTransform::initialFreeState(track,&*bField);
983 
984  LogTrace("TrackAssociator") << "inner track state (rho, z, phi):" <<
985  track.innerPosition().Rho() << ", " << track.innerPosition().z() <<
986  ", " << track.innerPosition().phi() << "\n";
987  LogTrace("TrackAssociator") << "innerFreeState (rho, z, phi):" <<
988  innerState.position().perp() << ", " << innerState.position().z() <<
989  ", " << innerState.position().phi() << "\n";
990 
991  LogTrace("TrackAssociator") << "outer track state (rho, z, phi):" <<
992  track.outerPosition().Rho() << ", " << track.outerPosition().z() <<
993  ", " << track.outerPosition().phi() << "\n";
994  LogTrace("TrackAssociator") << "outerFreeState (rho, z, phi):" <<
995  outerState.position().perp() << ", " << outerState.position().z() <<
996  ", " << outerState.position().phi() << "\n";
997 
998  // InsideOut first
999  if ( crossedIP( track ) ) {
1000  switch ( direction ) {
1001  case InsideOut:
1002  case Any:
1003  return associate(iEvent, iSetup, parameters, &referenceState, &outerState);
1004  break;
1005  case OutsideIn:
1006  {
1007  cachedTrajectory_.setPropagationStep( -fabs(currentStepSize) );
1008  TrackDetMatchInfo result = associate(iEvent, iSetup, parameters, &innerState, &referenceState);
1009  cachedTrajectory_.setPropagationStep( currentStepSize );
1010  return result;
1011  break;
1012  }
1013  }
1014  } else {
1015  switch ( direction ) {
1016  case InsideOut:
1017  return associate(iEvent, iSetup, parameters, &innerState, &outerState);
1018  break;
1019  case OutsideIn:
1020  {
1021  cachedTrajectory_.setPropagationStep( -fabs(currentStepSize) );
1022  TrackDetMatchInfo result = associate(iEvent, iSetup, parameters, &outerState, &innerState);
1023  cachedTrajectory_.setPropagationStep( currentStepSize );
1024  return result;
1025  break;
1026  }
1027  case Any:
1028  {
1029  // check if we deal with clear outside-in case
1030  if ( track.innerPosition().Dot( track.innerMomentum() ) < 0 &&
1031  track.outerPosition().Dot( track.outerMomentum() ) < 0 )
1032  {
1033  cachedTrajectory_.setPropagationStep( -fabs(currentStepSize) );
1035  if ( track.innerPosition().R() < track.outerPosition().R() )
1036  result = associate(iEvent, iSetup, parameters, &innerState, &outerState);
1037  else
1038  result = associate(iEvent, iSetup, parameters, &outerState, &innerState);
1039  cachedTrajectory_.setPropagationStep( currentStepSize );
1040  return result;
1041  }
1042  }
1043  }
1044  }
1045 
1046  // all other cases
1047  return associate(iEvent, iSetup, parameters, &innerState, &outerState);
1048 }
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:189
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
void setPropagationStep(float s=20.)
const math::XYZPoint & outerPosition() const
position of the outermost hit
Definition: Track.h:65
tuple result
Definition: mps_fire.py:83
const math::XYZPoint & innerPosition() const
position of the innermost hit
Definition: Track.h:55
T z() const
Definition: PV3DBase.h:64
bool isNull() const
Checks for null.
Definition: Ref.h:249
#define LogTrace(id)
GlobalPoint position() const
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
Definition: Track.h:70
const T & get() const
Definition: EventSetup.h:56
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
Definition: Track.h:60
TrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const AssociatorParameters &)
FreeTrajectoryState innerFreeState(const reco::Track &tk, const MagneticField *field, bool withErr=true)
FreeTrajectoryState outerFreeState(const reco::Track &tk, const MagneticField *field, bool withErr=true)
FreeTrajectoryState initialFreeState(const reco::Track &tk, const MagneticField *field, bool withErr=true)
TrackDetMatchInfo TrackDetectorAssociator::associate ( const edm::Event iEvent,
const edm::EventSetup iSetup,
const SimTrack track,
const SimVertex vertex,
const AssociatorParameters parameters 
)

associate using a simulated track

Definition at line 1050 of file TrackDetectorAssociator.cc.

1055 {
1056  return associate(iEvent, iSetup, getFreeTrajectoryState(iSetup, track, vertex), parameters);
1057 }
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 1059 of file TrackDetectorAssociator.cc.

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

Definition at line 1069 of file TrackDetectorAssociator.cc.

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

Referenced by MuonIdProducer::produce().

1070 {
1071  bool crossed = true;
1072  crossed &= (track.innerPosition().rho() > 3 ); // something close to active volume
1073  crossed &= (track.outerPosition().rho() > 3 ); // something close to active volume
1074  crossed &= ( ( track.innerPosition().x()*track.innerMomentum().x() +
1075  track.innerPosition().y()*track.innerMomentum().y() < 0 ) !=
1076  ( track.outerPosition().x()*track.outerMomentum().x() +
1077  track.outerPosition().y()*track.outerMomentum().y() < 0 ) );
1078  return crossed;
1079 }
const math::XYZPoint & outerPosition() const
position of the outermost hit
Definition: Track.h:65
const math::XYZPoint & innerPosition() const
position of the innermost hit
Definition: Track.h:55
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
Definition: Track.h:70
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
Definition: Track.h:60
void TrackDetectorAssociator::fillCaloTowers ( const edm::Event iEvent,
TrackDetMatchInfo info,
const AssociatorParameters parameters 
)
private

Definition at line 332 of file TrackDetectorAssociator.cc.

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

335 {
336  // use ECAL and HCAL trajectories to match a tower. (HO isn't used for matching).
337  std::vector<GlobalPoint> trajectory;
338  const std::vector<SteppingHelixStateInfo>& ecalTrajectoryStates = cachedTrajectory_.getEcalTrajectory();
339  const std::vector<SteppingHelixStateInfo>& hcalTrajectoryStates = cachedTrajectory_.getHcalTrajectory();
340  for(std::vector<SteppingHelixStateInfo>::const_iterator itr = ecalTrajectoryStates.begin();
341  itr != ecalTrajectoryStates.end(); itr++) trajectory.push_back(itr->position());
342  for(std::vector<SteppingHelixStateInfo>::const_iterator itr = hcalTrajectoryStates.begin();
343  itr != hcalTrajectoryStates.end(); itr++) trajectory.push_back(itr->position());
344 
345  if(trajectory.empty()) {
346  LogTrace("TrackAssociator") << "HCAL trajectory is empty; moving on\n";
347  info.isGoodCalo = 0;
348  return;
349  }
350  info.isGoodCalo = 1;
351 
352  // find crossed CaloTowers
354  iEvent.getByToken(parameters.caloTowersToken, caloTowers);
355  if (!caloTowers.isValid()) throw cms::Exception("FatalError") << "Unable to find CaloTowers in event!\n";
356 
357  std::set<DetId> caloTowerIdsInRegion;
358  if (parameters.accountForTrajectoryChangeCalo){
359  // get trajectory change with respect to initial state
361  parameters.dRHcalPreselection);
362  caloTowerIdsInRegion = caloDetIdAssociator_->getDetIdsCloseToAPoint(trajectory[0],mapRange);
363  } else caloTowerIdsInRegion = caloDetIdAssociator_->getDetIdsCloseToAPoint(trajectory[0], parameters.dRHcalPreselection);
364 
365  LogTrace("TrackAssociator") << "Towers in the region: " << caloTowerIdsInRegion.size();
366 
367  auto caloTowerIdsInAConeBegin = caloTowerIdsInRegion.begin();
368  auto caloTowerIdsInAConeEnd = caloTowerIdsInRegion.end();
369  std::set<DetId> caloTowerIdsInAConeTmp;
370  if (!caloDetIdAssociator_->selectAllInACone(parameters.dRHcal)){
371  caloTowerIdsInAConeTmp = caloDetIdAssociator_->getDetIdsInACone(caloTowerIdsInRegion, trajectory, parameters.dRHcal);
372  caloTowerIdsInAConeBegin = caloTowerIdsInAConeTmp.begin();
373  caloTowerIdsInAConeEnd = caloTowerIdsInAConeTmp.end();
374  }
375  LogTrace("TrackAssociator") << "Towers in the cone: " << std::distance(caloTowerIdsInAConeBegin, caloTowerIdsInAConeEnd);
376 
377  info.crossedTowerIds = caloDetIdAssociator_->getCrossedDetIds(caloTowerIdsInRegion, trajectory);
378  const std::vector<DetId>& crossedCaloTowerIds = info.crossedTowerIds;
379  LogTrace("TrackAssociator") << "Towers crossed: " << crossedCaloTowerIds.size();
380 
381  // add CaloTowers
382  for(std::vector<DetId>::const_iterator itr=crossedCaloTowerIds.begin(); itr!=crossedCaloTowerIds.end();itr++)
383  {
384  CaloTowerCollection::const_iterator tower = (*caloTowers).find(*itr);
385  if(tower != (*caloTowers).end())
386  info.crossedTowers.push_back(&*tower);
387  else
388  LogTrace("TrackAssociator") << "Crossed CaloTower is not found for DetId: " << (*itr).rawId();
389  }
390 
391  for(std::set<DetId>::const_iterator itr=caloTowerIdsInAConeBegin; itr!=caloTowerIdsInAConeEnd;itr++)
392  {
393  CaloTowerCollection::const_iterator tower = (*caloTowers).find(*itr);
394  if(tower != (*caloTowers).end())
395  info.towers.push_back(&*tower);
396  else
397  LogTrace("TrackAssociator") << "CaloTower from the cone is not found for DetId: " << (*itr).rawId();
398  }
399 
400 }
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:462
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:75
#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 898 of file TrackDetectorAssociator.cc.

References HLT_25ns10e33_v2_cff::DeltaR, 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().

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

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

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

429 {
430  const std::vector<SteppingHelixStateInfo>& trajectoryStates = cachedTrajectory_.getHcalTrajectory();
431 
432  std::vector<GlobalPoint> coreTrajectory;
433  for(std::vector<SteppingHelixStateInfo>::const_iterator itr = trajectoryStates.begin();
434  itr != trajectoryStates.end(); itr++) coreTrajectory.push_back(itr->position());
435 
436  if(coreTrajectory.empty()) {
437  LogTrace("TrackAssociator") << "HCAL trajectory is empty; moving on\n";
438  info.isGoodHcal = 0;
439  return;
440  }
441  info.isGoodHcal = 1;
442 
443  // find crossed Hcals
445  iEvent.getByToken(parameters.HBHEcollToken, collection);
446  if ( ! collection.isValid() ) throw cms::Exception("FatalError") << "Unable to find HBHERecHits in event!\n";
447 
448  std::set<DetId> idsInRegion;
449  if (parameters.accountForTrajectoryChangeCalo){
450  // get trajectory change with respect to initial state
452  parameters.dRHcalPreselection);
453  idsInRegion = hcalDetIdAssociator_->getDetIdsCloseToAPoint(coreTrajectory[0], mapRange);
454  } else idsInRegion = hcalDetIdAssociator_->getDetIdsCloseToAPoint(coreTrajectory[0], parameters.dRHcalPreselection);
455 
456  LogTrace("TrackAssociator") << "HCAL hits in the region: " << idsInRegion.size() << "\n" << DetIdInfo::info(idsInRegion,0);
457 
458  auto idsInAConeBegin = idsInRegion.begin();
459  auto idsInAConeEnd = idsInRegion.end();
460  std::set<DetId> idsInAConeTmp;
461  if (! hcalDetIdAssociator_->selectAllInACone(parameters.dRHcal)){
462  idsInAConeTmp = hcalDetIdAssociator_->getDetIdsInACone(idsInRegion, coreTrajectory, parameters.dRHcal);
463  idsInAConeBegin = idsInAConeTmp.begin();
464  idsInAConeEnd = idsInAConeTmp.end();
465  }
466  LogTrace("TrackAssociator") << "HCAL hits in the cone: " << std::distance(idsInAConeBegin, idsInAConeEnd) << "\n"
467  << DetIdInfo::info(std::set<DetId>(idsInAConeBegin, idsInAConeEnd), 0);
468  info.crossedHcalIds = hcalDetIdAssociator_->getCrossedDetIds(idsInRegion, coreTrajectory);
469  const std::vector<DetId>& crossedIds = info.crossedHcalIds;
470  LogTrace("TrackAssociator") << "HCAL hits crossed: " << crossedIds.size() << "\n" << DetIdInfo::info(crossedIds,0);
471 
472  // add Hcal
473  for(std::vector<DetId>::const_iterator itr=crossedIds.begin(); itr!=crossedIds.end();itr++)
474  {
475  HBHERecHitCollection::const_iterator hit = (*collection).find(*itr);
476  if( hit != (*collection).end() )
477  info.crossedHcalRecHits.push_back(&*hit);
478  else
479  LogTrace("TrackAssociator") << "Crossed HBHERecHit is not found for DetId: " << itr->rawId();
480  }
481  for(std::set<DetId>::const_iterator itr=idsInAConeBegin; itr!=idsInAConeEnd;itr++)
482  {
483  HBHERecHitCollection::const_iterator hit = (*collection).find(*itr);
484  if( hit != (*collection).end() )
485  info.hcalRecHits.push_back(&*hit);
486  else
487  LogTrace("TrackAssociator") << "HBHERecHit from the cone is not found for DetId: " << itr->rawId();
488  }
489 }
std::vector< const HBHERecHit * > crossedHcalRecHits
const std::vector< SteppingHelixStateInfo > & getHcalTrajectory() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
std::vector< HBHERecHit >::const_iterator const_iterator
std::vector< DetId > crossedHcalIds
edm::ESHandle< DetIdAssociator > hcalDetIdAssociator_
std::vector< const HBHERecHit * > hcalRecHits
std::pair< float, float > trajectoryDelta(TrajectorType)
bool isValid() const
Definition: HandleBase.h:75
#define LogTrace(id)
static std::string info(const DetId &, const TrackerTopology *tTopo)
Definition: DetIdInfo.cc:29
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 491 of file TrackDetectorAssociator.cc.

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

494 {
495  const std::vector<SteppingHelixStateInfo>& trajectoryStates = cachedTrajectory_.getHOTrajectory();
496 
497  std::vector<GlobalPoint> coreTrajectory;
498  for(std::vector<SteppingHelixStateInfo>::const_iterator itr = trajectoryStates.begin();
499  itr != trajectoryStates.end(); itr++) coreTrajectory.push_back(itr->position());
500 
501  if(coreTrajectory.empty()) {
502  LogTrace("TrackAssociator") << "HO trajectory is empty; moving on\n";
503  info.isGoodHO = 0;
504  return;
505  }
506  info.isGoodHO = 1;
507 
508  // find crossed HOs
510  iEvent.getByToken(parameters.HOcollToken, collection);
511  if ( ! collection.isValid() ) throw cms::Exception("FatalError") << "Unable to find HORecHits in event!\n";
512 
513  std::set<DetId> idsInRegion;
514  if (parameters.accountForTrajectoryChangeCalo){
515  // get trajectory change with respect to initial state
517  parameters.dRHcalPreselection);
518  idsInRegion = hoDetIdAssociator_->getDetIdsCloseToAPoint(coreTrajectory[0], mapRange);
519  } else idsInRegion = hoDetIdAssociator_->getDetIdsCloseToAPoint(coreTrajectory[0], parameters.dRHcalPreselection);
520 
521  LogTrace("TrackAssociator") << "idsInRegion.size(): " << idsInRegion.size();
522 
523  auto idsInAConeBegin = idsInRegion.begin();
524  auto idsInAConeEnd = idsInRegion.end();
525  std::set<DetId> idsInAConeTmp;
526  if (! hoDetIdAssociator_->selectAllInACone(parameters.dRHcal)){
527  idsInAConeTmp = hoDetIdAssociator_->getDetIdsInACone(idsInRegion, coreTrajectory, parameters.dRHcal);
528  idsInAConeBegin = idsInAConeTmp.begin();
529  idsInAConeEnd = idsInAConeTmp.end();
530  }
531  LogTrace("TrackAssociator") << "idsInACone.size(): " << std::distance(idsInAConeBegin, idsInAConeEnd);
532  info.crossedHOIds = hoDetIdAssociator_->getCrossedDetIds(idsInRegion, coreTrajectory);
533  const std::vector<DetId>& crossedIds = info.crossedHOIds;
534 
535  // add HO
536  for(std::vector<DetId>::const_iterator itr=crossedIds.begin(); itr!=crossedIds.end();itr++)
537  {
538  HORecHitCollection::const_iterator hit = (*collection).find(*itr);
539  if( hit != (*collection).end() )
540  info.crossedHORecHits.push_back(&*hit);
541  else
542  LogTrace("TrackAssociator") << "Crossed HORecHit is not found for DetId: " << itr->rawId();
543  }
544 
545  for(std::set<DetId>::const_iterator itr=idsInAConeBegin; itr!=idsInAConeEnd;itr++)
546  {
547  HORecHitCollection::const_iterator hit = (*collection).find(*itr);
548  if( hit != (*collection).end() )
549  info.hoRecHits.push_back(&*hit);
550  else
551  LogTrace("TrackAssociator") << "HORecHit from the cone is not found for DetId: " << itr->rawId();
552  }
553 }
const std::vector< SteppingHelixStateInfo > & getHOTrajectory() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
std::vector< HORecHit >::const_iterator const_iterator
std::vector< DetId > crossedHOIds
std::pair< float, float > trajectoryDelta(TrajectorType)
bool isValid() const
Definition: HandleBase.h:75
#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 738 of file TrackDetectorAssociator.cc.

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

741 {
742  // Get the segments from the event
744  iEvent.getByToken(parameters.dtSegmentsToken, dtSegments);
745  if (! dtSegments.isValid())
746  throw cms::Exception("FatalError") << "Unable to find DTRecSegment4DCollection in event!\n";
747 
749  iEvent.getByToken(parameters.cscSegmentsToken, cscSegments);
750  if (! cscSegments.isValid())
751  throw cms::Exception("FatalError") << "Unable to find CSCSegmentCollection in event!\n";
752 
754 
755  // check the map of available segments
756  // if there is no segments in a given direction at all,
757  // then there is no point to fly there.
758  //
759  // MISSING
760  // Possible solution: quick search for presence of segments
761  // for the set of DetIds
762 
763  // get a set of matches corresponding to muon chambers
764  std::vector<TAMuonChamberMatch> matchedChambers;
765  LogTrace("TrackAssociator") << "Trying to Get ChamberMatches" << std::endl;
766  getTAMuonChamberMatches(matchedChambers, parameters);
767  LogTrace("TrackAssociator") << "Chambers matched: " << matchedChambers.size() << "\n";
768 
769  // Iterate over all chamber matches and fill segment matching
770  // info if it's available
771  for(std::vector<TAMuonChamberMatch>::iterator matchedChamber = matchedChambers.begin();
772  matchedChamber != matchedChambers.end(); matchedChamber++)
773  {
774  const GeomDet* geomDet = muonDetIdAssociator_->getGeomDet((*matchedChamber).id);
775  // DT chamber
776  if(const DTChamber* chamber = dynamic_cast<const DTChamber*>(geomDet) ) {
777  // Get the range for the corresponding segments
778  DTRecSegment4DCollection::range range = dtSegments->get(chamber->id());
779  // Loop over the segments of this chamber
780  for (DTRecSegment4DCollection::const_iterator segment = range.first; segment!=range.second; segment++) {
781  if (addTAMuonSegmentMatch(*matchedChamber, &(*segment), parameters)) {
782  matchedChamber->segments.back().dtSegmentRef = DTRecSegment4DRef(dtSegments, segment - dtSegments->begin());
783  }
784  }
785  }else{
786  // CSC Chamber
787  if(const CSCChamber* chamber = dynamic_cast<const CSCChamber*>(geomDet) ) {
788  // Get the range for the corresponding segments
789  CSCSegmentCollection::range range = cscSegments->get(chamber->id());
790  // Loop over the segments
791  for (CSCSegmentCollection::const_iterator segment = range.first; segment!=range.second; segment++) {
792  if (addTAMuonSegmentMatch(*matchedChamber, &(*segment), parameters)) {
793  matchedChamber->segments.back().cscSegmentRef = CSCSegmentRef(cscSegments, segment - cscSegments->begin());
794  }
795  }
796  }else{
797  // throw cms::Exception("FatalError") << "Failed to cast GeomDet object to either DTChamber or CSCChamber. Who is this guy anyway?\n";
798  }
799  }
800  info.chambers.push_back(*matchedChamber);
801  }
802 }
std::pair< const_iterator, const_iterator > range
iterator range
Definition: RangeMap.h:50
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
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:75
#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 402 of file TrackDetectorAssociator.cc.

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

405 {
406  std::vector<GlobalPoint> trajectory;
407  const std::vector<SteppingHelixStateInfo>& trajectoryStates = cachedTrajectory_.getPreshowerTrajectory();
408  for(std::vector<SteppingHelixStateInfo>::const_iterator itr = trajectoryStates.begin();
409  itr != trajectoryStates.end(); itr++) trajectory.push_back(itr->position());
410 
411  if(trajectory.empty()) {
412  LogTrace("TrackAssociator") << "Preshower trajectory is empty; moving on\n";
413  return;
414  }
415 
416  std::set<DetId> idsInRegion =
417  preshowerDetIdAssociator_->getDetIdsCloseToAPoint(trajectory[0],
418  parameters.dRPreshowerPreselection);
419 
420  LogTrace("TrackAssociator") << "Number of Preshower Ids in the region: " << idsInRegion.size();
421  info.crossedPreshowerIds = preshowerDetIdAssociator_->getCrossedDetIds(idsInRegion, trajectory);
422  LogTrace("TrackAssociator") << "Number of Preshower Ids in crossed: " << info.crossedPreshowerIds.size();
423 }
std::vector< DetId > crossedPreshowerIds
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 588 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(), and InterestingTrackEcalDetIdProducer::produce().

590 {
592  iSetup.get<IdealMagneticFieldRecord>().get(bField);
593 
594  GlobalVector vector( track.momentum().x(), track.momentum().y(), track.momentum().z() );
595 
596  GlobalPoint point( track.vertex().x(), track.vertex().y(), track.vertex().z() );
597 
598  GlobalTrajectoryParameters tPars(point, vector, track.charge(), &*bField);
599 
600  // FIX THIS !!!
601  // need to convert from perigee to global or helix (curvilinear) frame
602  // for now just an arbitrary matrix.
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
const Vector & momentum() const
track momentum vector
Definition: TrackBase.h:670
const Point & vertex() const
reference point on the track. This method is DEPRECATED, please use referencePoint() instead ...
Definition: TrackBase.h:682
const T & get() const
Definition: EventSetup.h:56
int charge() const
track electric charge
Definition: TrackBase.h:562
*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 555 of file TrackDetectorAssociator.cc.

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

558 {
559  GlobalVector vector( track.momentum().x(), track.momentum().y(), track.momentum().z() );
560  GlobalPoint point( vertex.position().x(), vertex.position().y(), vertex.position().z() );
561 
562  int charge = track.type( )> 0 ? -1 : 1; // lepton convention
563  if ( abs(track.type( )) == 211 || // pion
564  abs(track.type( )) == 321 || // kaon
565  abs(track.type( )) == 2212 )
566  charge = track.type( )< 0 ? -1 : 1;
567  return getFreeTrajectoryState(iSetup, vector, point, charge);
568 }
static FreeTrajectoryState getFreeTrajectoryState(const edm::EventSetup &, const reco::Track &)
get FreeTrajectoryState from different track representations
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const math::XYZTLorentzVectorD & position() const
Definition: CoreSimVertex.h:26
int type() const
particle type (HEP PDT convension)
Definition: CoreSimTrack.h:25
const math::XYZTLorentzVectorD & momentum() const
Definition: CoreSimTrack.h:22
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
FreeTrajectoryState TrackDetectorAssociator::getFreeTrajectoryState ( const edm::EventSetup iSetup,
const GlobalVector momentum,
const GlobalPoint vertex,
const int  charge 
)
static

Definition at line 570 of file TrackDetectorAssociator.cc.

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

574 {
576  iSetup.get<IdealMagneticFieldRecord>().get(bField);
577 
578  GlobalTrajectoryParameters tPars(vertex, momentum, charge, &*bField);
579 
580  ROOT::Math::SMatrixIdentity id;
581  AlgebraicSymMatrix66 covT(id); covT *= 1e-6; // initialize to sigma=1e-3
582  CartesianTrajectoryError tCov(covT);
583 
584  return FreeTrajectoryState(tPars, tCov);
585 }
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepSym< double, 6 > > AlgebraicSymMatrix66
const T & get() const
Definition: EventSetup.h:56
DetIdAssociator::MapRange TrackDetectorAssociator::getMapRange ( const std::pair< float, float > &  delta,
const float  dR 
)
private

Definition at line 610 of file TrackDetectorAssociator.cc.

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

612 {
613  DetIdAssociator::MapRange mapRange;
614  mapRange.dThetaPlus = dR;
615  mapRange.dThetaMinus = dR;
616  mapRange.dPhiPlus = dR;
617  mapRange.dPhiMinus = dR;
618  if ( delta.first > 0 )
619  mapRange.dThetaPlus += delta.first;
620  else
621  mapRange.dThetaMinus += fabs(delta.first);
622  if ( delta.second > 0 )
623  mapRange.dPhiPlus += delta.second;
624  else
625  mapRange.dPhiMinus += fabs(delta.second);
626  LogTrace("TrackAssociator") << "Selection range: (dThetaPlus, dThetaMinus, dPhiPlus, dPhiMinus, dRPreselection): " <<
627  mapRange.dThetaPlus << ", " << mapRange.dThetaMinus << ", " <<
628  mapRange.dPhiPlus << ", " << mapRange.dPhiMinus << ", " << dR;
629  return mapRange;
630 }
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 632 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().

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

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

124 {
125  // access the calorimeter geometry
126  iSetup.get<CaloGeometryRecord>().get(theCaloGeometry_);
127  if (!theCaloGeometry_.isValid())
128  throw cms::Exception("FatalError") << "Unable to find CaloGeometryRecord in event!\n";
129 
130  // get the tracking Geometry
133  throw cms::Exception("FatalError") << "Unable to find GlobalTrackingGeometryRecord in event!\n";
134 
136  // setup propagator
138  iSetup.get<IdealMagneticFieldRecord>().get(bField);
139 
141  prop->setMaterialMode(false);
142  prop->applyRadX0Correction(true);
143  // prop->setDebug(true); // tmp
144  defProp_ = prop;
146  }
147 
148  iSetup.get<DetIdAssociatorRecord>().get("EcalDetIdAssociator", ecalDetIdAssociator_);
149  iSetup.get<DetIdAssociatorRecord>().get("HcalDetIdAssociator", hcalDetIdAssociator_);
150  iSetup.get<DetIdAssociatorRecord>().get("HODetIdAssociator", hoDetIdAssociator_);
151  iSetup.get<DetIdAssociatorRecord>().get("CaloDetIdAssociator", caloDetIdAssociator_);
152  iSetup.get<DetIdAssociatorRecord>().get("MuonDetIdAssociator", muonDetIdAssociator_);
153  iSetup.get<DetIdAssociatorRecord>().get("PreshowerDetIdAssociator", preshowerDetIdAssociator_);
154 }
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:56
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
edm::ESHandle< DetIdAssociator > muonDetIdAssociator_
edm::ESHandle< DetIdAssociator > preshowerDetIdAssociator_
bool isValid() const
Definition: ESHandle.h:47
edm::ESHandle< DetIdAssociator > caloDetIdAssociator_
edm::ESHandle< GlobalTrackingGeometry > theTrackingGeometry_
void setMaterialMode(bool noMaterial)
Switch for material effects mode: no material effects if true.
void TrackDetectorAssociator::setPropagator ( const Propagator ptr)

use a user configured propagator

Definition at line 111 of file TrackDetectorAssociator.cc.

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

112 {
113  ivProp_ = ptr;
115 }
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.