CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
FixTrackHitPattern Class Reference

#include <FixTrackHitPattern.h>

Classes

struct  Result
 

Public Member Functions

Result analyze (const edm::EventSetup &iSetup, const reco::Track &track)
 
 FixTrackHitPattern ()
 
 ~FixTrackHitPattern ()
 

Private Member Functions

void init (const edm::EventSetup &iSetup)
 

Private Attributes

edm::ESHandle
< TransientTrackBuilder
trkTool_
 

Detailed Description

Definition at line 52 of file FixTrackHitPattern.h.

Constructor & Destructor Documentation

FixTrackHitPattern::FixTrackHitPattern ( )
inline

Definition at line 61 of file FixTrackHitPattern.h.

61 {}
FixTrackHitPattern::~FixTrackHitPattern ( )
inline

Definition at line 63 of file FixTrackHitPattern.h.

63 {}

Member Function Documentation

FixTrackHitPattern::Result FixTrackHitPattern::analyze ( const edm::EventSetup iSetup,
const reco::Track track 
)

Definition at line 30 of file FixTrackHitPattern.cc.

References alongMomentum, AnalyticalPropagator_cfi::AnalyticalPropagator, GetTrackTrajInfo::analyze(), DetLayer::compatibleLayers(), counter, TrajectoryStateOnSurface::freeTrajectoryState(), edm::EventSetup::get(), reco::HitPattern::getHitPattern(), reco::HitPattern::getHitType(), reco::HitPattern::getLayer(), reco::HitPattern::getSubStructure(), AnalysisDataFormats_SUSYBSMObjects::hp, FixTrackHitPattern::Result::innerHitPattern, MeasurementDet::isActive(), j, LogDebug, max(), TrackingRecHit::missing, reco::HitPattern::numberOfHits(), oppositeToMomentum, FixTrackHitPattern::Result::outerHitPattern, LargeD0_PixelPairStep_cff::propagator, query::result, reco::HitPattern::set(), ntuplemaker::status, patCandidatesForDimuonsSequences_cff::tracker, and TrackValidation_HighPurity_cff::valid.

Referenced by CheckHitPattern::analyze().

31 {
32  // Recalculate the inner and outer missing hit patterns. See header file for detailed comments.
33 
34  Result result;
35 #if 0
36  using namespace std;
37 
38  // Initialise Tracker geometry info (not sufficient to do this only on first call).
40  iSetup.get<TrackerRecoGeometryRecord>().get( tracker );
41 
42  // This is also needed to extrapolate amongst the tracker layers.
44  iSetup.get<NavigationSchoolRecord>().get("SimpleNavigationSchool",theSchool);
45  NavigationSetter junk(*theSchool);
46 
47  // This is needed to determine which sensors are functioning.
49  iSetup.get<CkfComponentsRecord>().get(measTk);
50  // Don't do this. It tries getting the tracker clusters, which do not exist in AOD.
51  // Hopefully not needed if one simply wants to know which sensors are active.
52  // measTk->update(iEvent);
53 
54  // Get the magnetic field and use it to define a propagator for extrapolating the track trajectory.
56  iSetup.get<IdealMagneticFieldRecord>().get(magField);
58 
59  // This is used to check if a track is compatible with crossing a sensor.
60  // Use +3.0 rather than default -3.0 here, so hit defined as inside acceptance if
61  // no more than 3*sigma outside detector edge, as opposed to more than 3*sigma inside detector edge.
62  Chi2MeasurementEstimator estimator(30.,3.0);
63 
64  // Get the track trajectory and detLayer at each valid hit on the track.
65  static GetTrackTrajInfo getTrackTrajInfo;
66  vector<GetTrackTrajInfo::Result> trkTrajInfo = getTrackTrajInfo.analyze(iSetup, track);
67  unsigned int nValidHits = trkTrajInfo.size();
68 
69  // Calculate the inner and outer hitPatterns on the track.
70  // i.e. The list of where the track should have had hits inside its innermost valid hit
71  // and outside its outmost valid hit.
72 
73  enum InnerOuter {INNER = 1, OUTER=2};
74  for (unsigned int inOut = INNER; inOut <= OUTER; inOut++) {
75 
76  // Get the track trajectory and detLayer at the inner/outermost valid hit.
77  unsigned int ihit = (inOut == INNER) ? 0 : nValidHits - 1;
78 
79  // Check that information about the track trajectory was available for this hit.
80  if (trkTrajInfo[ihit].valid) {
81  const DetLayer* detLayer = trkTrajInfo[ihit].detLayer;
82  const TrajectoryStateOnSurface& detTSOS = trkTrajInfo[ihit].detTSOS;
83  const FreeTrajectoryState* detFTS = detTSOS.freeTrajectoryState();
84 
85  // When getting inner hit pattern, must propagate track inwards from innermost layer with valid hit.
86  // When getting outer hit pattern, must propagate track outwards from outermost layer with valid hit.
87  const PropagationDirection direc = (inOut == INNER) ? oppositeToMomentum : alongMomentum;
88 
89  // Find all layers this track is compatible with in the desired direction, starting from this layer.
90  // Based on code in RecoTracker/TrackProducer/interface/TrackProducerBase.icc
91  // N.B. The following call uses code in RecoTracker/TkNavigation/src/SimpleBarrelNavigableLayer::compatibleLayers()
92  // and RecoTracker/TkNavigation/src/SimpleNavigableLayer::wellInside().
93  // These make some curious checks on the direction of the trajectory relative to its starting point,
94  // so care was required above when calculating detFTS.
95  vector<const DetLayer*> compLayers = detLayer->compatibleLayers(*detFTS, direc);
96  LogDebug("FTHP")<<"Number of inner/outer "<<inOut<<" layers intercepted by track = "<<compLayers.size()<<endl;
97 
98  int counter = 0;
99  reco::HitPattern newHitPattern;
100 
101  for(vector<const DetLayer *>::const_iterator it=compLayers.begin(); it!=compLayers.end();
102  ++it){
103  if ((*it)->basicComponents().empty()) {
104  //this should never happen. but better protect for it
105  edm::LogWarning("FixTrackHitPattern")<<"a detlayer with no components: I can not figure out a DetId from this layer. please investigate.";
106  continue;
107  }
108 
109  // Find the sensor in this layer which is closest to the track trajectory.
110  // And get the track trajectory at that sensor.
111  propagator.setPropagationDirection(direc);
112  vector< GeometricSearchDet::DetWithState > detWithState = (*it)->compatibleDets(detTSOS, propagator, estimator);
113  // Check that at least one sensor was compatible with the track trajectory.
114  if(detWithState.size() > 0) {
115  // Check that this sensor is functional
116  DetId id = detWithState.front().first->geographicalId();
117  const MeasurementDet* measDet = measTk->idToDet(id);
118  if(measDet->isActive()){
119  // Hence record that the track should have produced a hit here, but did not.
120  // Store the information in a HitPattern.
121  InvalidTrackingRecHit tmpHit(id, TrackingRecHit::missing);
122  newHitPattern.set(tmpHit, counter);
123  counter++;
124  } else {
125  // Missing hit expected here, since sensor was not functioning.
126  }
127  }
128  }//end loop over compatible layers
129 
130  // Store this result.
131  if (inOut == INNER) {
132  result.innerHitPattern = newHitPattern;
133  } else {
134  result.outerHitPattern = newHitPattern;
135  }
136 
137  // Print result for debugging.
138  LogDebug("FTHP")<<"Number of missing hits "<<newHitPattern.numberOfHits()<<"/"<<counter<<endl;
139  for (int j = 0; j < std::max(newHitPattern.numberOfHits(), counter); j++) {
140  uint32_t hp = newHitPattern.getHitPattern(j);
141  uint32_t subDet = newHitPattern.getSubStructure(hp);
142  uint32_t layer = newHitPattern.getLayer(hp);
143  uint32_t status = newHitPattern.getHitType(hp);
144  LogDebug("FTHP")<<" layer with no matched hit at counter="<<j<<" subdet="<<subDet<<" layer="<<layer<<" status="<<status<<endl;
145  }
146 
147  } else {
148  LogDebug("FTHP")<<"WARNING: could not calculate inner/outer hit pattern as trajectory info for inner/out hit missing"<<endl;
149  }
150 
151  }
152 #endif
153  return result;
154 }
#define LogDebug(id)
std::vector< const DetLayer * > compatibleLayers(Args &&...args) const
Returns all layers compatible.
Definition: DetLayer.h:69
static uint32_t getLayer(uint32_t pattern)
Definition: HitPattern.h:520
static uint32_t getHitType(uint32_t pattern)
Definition: HitPattern.h:536
void set(const I &begin, const I &end)
Definition: HitPattern.h:152
PropagationDirection
const T & max(const T &a, const T &b)
FreeTrajectoryState const * freeTrajectoryState(bool withErrors=true) const
susybsm::HSCParticleRefProd hp
Definition: classes.h:27
tuple result
Definition: query.py:137
int numberOfHits() const
Definition: HitPattern.cc:211
static uint32_t getSubStructure(uint32_t pattern)
Definition: HitPattern.h:514
int j
Definition: DBlmapReader.cc:9
std::vector< Result > analyze(const edm::EventSetup &iSetup, const reco::Track &track)
Definition: DetId.h:18
const T & get() const
Definition: EventSetup.h:55
virtual bool isActive(const MeasurementTrackerEvent &data) const =0
static std::atomic< unsigned int > counter
tuple status
Definition: ntuplemaker.py:245
uint32_t getHitPattern(int position) const
Definition: HitPattern.cc:142
void FixTrackHitPattern::init ( const edm::EventSetup iSetup)
private

Member Data Documentation

edm::ESHandle<TransientTrackBuilder> FixTrackHitPattern::trkTool_
private

Definition at line 74 of file FixTrackHitPattern.h.