Go to the documentation of this file.00001 #include "RecoTracker/DebugTools/interface/FixTrackHitPattern.h"
00002 #include "RecoTracker/DebugTools/interface/GetTrackTrajInfo.h"
00003
00004 #include "RecoTracker/Record/interface/TrackerRecoGeometryRecord.h"
00005 #include "RecoTracker/TkDetLayers/interface/GeometricSearchTracker.h"
00006 #include "RecoTracker/MeasurementDet/interface/MeasurementTracker.h"
00007 #include "TrackingTools/MeasurementDet/interface/MeasurementDet.h"
00008 #include "RecoTracker/Record/interface/CkfComponentsRecord.h"
00009 #include "DataFormats/TrackingRecHit/interface/InvalidTrackingRecHit.h"
00010
00011
00012 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
00013 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
00014
00015 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
00016 #include "Geometry/Records/interface/IdealGeometryRecord.h"
00017
00018 #include "TrackingTools/KalmanUpdators/interface/Chi2MeasurementEstimator.h"
00019 #include "TrackingTools/GeomPropagators/interface/AnalyticalPropagator.h"
00020
00021 #include "TrackingTools/DetLayers/interface/NavigationSchool.h"
00022 #include "RecoTracker/Record/interface/NavigationSchoolRecord.h"
00023 #include "TrackingTools/DetLayers/interface/NavigationSetter.h"
00024
00025 #include "TrackingTools/Records/interface/TransientTrackRecord.h"
00026 #include "DataFormats/Math/interface/deltaPhi.h"
00027
00028 #include "FWCore/Utilities/interface/Exception.h"
00029
00030 FixTrackHitPattern::Result FixTrackHitPattern::analyze(const edm::EventSetup& iSetup, const reco::Track& track)
00031 {
00032
00033
00034 Result result;
00035
00036 using namespace std;
00037
00038
00039 edm::ESHandle<GeometricSearchTracker> tracker;
00040 iSetup.get<TrackerRecoGeometryRecord>().get( tracker );
00041
00042
00043 edm::ESHandle<NavigationSchool> theSchool;
00044 iSetup.get<NavigationSchoolRecord>().get("SimpleNavigationSchool",theSchool);
00045 NavigationSetter junk(*theSchool);
00046
00047
00048 edm::ESHandle<MeasurementTracker> measTk;
00049 iSetup.get<CkfComponentsRecord>().get(measTk);
00050
00051
00052
00053
00054
00055 edm::ESHandle<MagneticField> magField;
00056 iSetup.get<IdealMagneticFieldRecord>().get(magField);
00057 AnalyticalPropagator propagator(&(*magField), alongMomentum);
00058
00059
00060
00061
00062 Chi2MeasurementEstimator estimator(30.,3.0);
00063
00064
00065 static GetTrackTrajInfo getTrackTrajInfo;
00066 vector<GetTrackTrajInfo::Result> trkTrajInfo = getTrackTrajInfo.analyze(iSetup, track);
00067 unsigned int nValidHits = trkTrajInfo.size();
00068
00069
00070
00071
00072
00073 enum InnerOuter {INNER = 1, OUTER=2};
00074 for (unsigned int inOut = INNER; inOut <= OUTER; inOut++) {
00075
00076
00077 unsigned int ihit = (inOut == INNER) ? 0 : nValidHits - 1;
00078
00079
00080 if (trkTrajInfo[ihit].valid) {
00081 const DetLayer* detLayer = trkTrajInfo[ihit].detLayer;
00082 const TrajectoryStateOnSurface& detTSOS = trkTrajInfo[ihit].detTSOS;
00083 const FreeTrajectoryState* detFTS = detTSOS.freeTrajectoryState();
00084
00085
00086
00087 const PropagationDirection direc = (inOut == INNER) ? oppositeToMomentum : alongMomentum;
00088
00089
00090
00091
00092
00093
00094
00095 vector<const DetLayer*> compLayers = detLayer->compatibleLayers(*detFTS, direc);
00096 LogDebug("FTHP")<<"Number of inner/outer "<<inOut<<" layers intercepted by track = "<<compLayers.size()<<endl;
00097
00098 int counter = 0;
00099 reco::HitPattern newHitPattern;
00100
00101 for(vector<const DetLayer *>::const_iterator it=compLayers.begin(); it!=compLayers.end();
00102 ++it){
00103 if ((*it)->basicComponents().empty()) {
00104
00105 edm::LogWarning("FixTrackHitPattern")<<"a detlayer with no components: I can not figure out a DetId from this layer. please investigate.";
00106 continue;
00107 }
00108
00109
00110
00111 propagator.setPropagationDirection(direc);
00112 vector< GeometricSearchDet::DetWithState > detWithState = (*it)->compatibleDets(detTSOS, propagator, estimator);
00113
00114 if(detWithState.size() > 0) {
00115
00116 DetId id = detWithState.front().first->geographicalId();
00117 const MeasurementDet* measDet = measTk->idToDet(id);
00118 if(measDet->isActive()){
00119
00120
00121 InvalidTrackingRecHit tmpHit(id, TrackingRecHit::missing);
00122 newHitPattern.set(tmpHit, counter);
00123 counter++;
00124 } else {
00125
00126 }
00127 }
00128 }
00129
00130
00131 if (inOut == INNER) {
00132 result.innerHitPattern = newHitPattern;
00133 } else {
00134 result.outerHitPattern = newHitPattern;
00135 }
00136
00137
00138 LogDebug("FTHP")<<"Number of missing hits "<<newHitPattern.numberOfHits()<<"/"<<counter<<endl;
00139 for (int j = 0; j < std::max(newHitPattern.numberOfHits(), counter); j++) {
00140 uint32_t hp = newHitPattern.getHitPattern(j);
00141 uint32_t subDet = newHitPattern.getSubStructure(hp);
00142 uint32_t layer = newHitPattern.getLayer(hp);
00143 uint32_t status = newHitPattern.getHitType(hp);
00144 LogDebug("FTHP")<<" layer with no matched hit at counter="<<j<<" subdet="<<subDet<<" layer="<<layer<<" status="<<status<<endl;
00145 }
00146
00147 } else {
00148 LogDebug("FTHP")<<"WARNING: could not calculate inner/outer hit pattern as trajectory info for inner/out hit missing"<<endl;
00149 }
00150
00151 }
00152
00153 return result;
00154 }