#include <RecoMuon/TrackerSeedGenerator/plugins/TSGFromPropagation.h>
Tracker Seed Generator by propagating and updating a standAlone muon to the first 2 (or 1) rechits it meets in tracker system.
Definition at line 29 of file TSGFromPropagation.h.
TSGFromPropagation::TSGFromPropagation | ( | const edm::ParameterSet & | pset | ) |
constructor
Definition at line 32 of file TSGFromPropagation.cc.
References theCategory.
00032 :theTkLayerMeasurements (0), theTracker(0), theMeasTracker(0), theNavigation(0), theService(0), theEstimator(0), theTSTransformer(0), theConfig (iConfig) 00033 { 00034 theCategory = "Muon|RecoMuon|TSGFromPropagation"; 00035 }
TSGFromPropagation::TSGFromPropagation | ( | const edm::ParameterSet & | par, | |
const MuonServiceProxy * | service | |||
) |
Definition at line 37 of file TSGFromPropagation.cc.
References theCategory.
00037 : theTkLayerMeasurements (0), theTracker(0), theMeasTracker(0), theNavigation(0), theService(service),theUpdator(0), theEstimator(0), theTSTransformer(0), theConfig (iConfig) 00038 { 00039 theCategory = "Muon|RecoMuon|TSGFromPropagation"; 00040 }
TSGFromPropagation::~TSGFromPropagation | ( | ) | [virtual] |
destructor
Definition at line 42 of file TSGFromPropagation.cc.
References LogTrace, theCategory, theErrorMatrixAdjuster, theEstimator, theNavigation, theTkLayerMeasurements, theTSTransformer, and theUpdator.
00043 { 00044 00045 LogTrace(theCategory) << " TSGFromPropagation dtor called "; 00046 if ( theNavigation ) delete theNavigation; 00047 if ( theUpdator ) delete theUpdator; 00048 if ( theEstimator ) delete theEstimator; 00049 if ( theTkLayerMeasurements ) delete theTkLayerMeasurements; 00050 if ( theTSTransformer ) delete theTSTransformer; 00051 if ( theErrorMatrixAdjuster ) delete theErrorMatrixAdjuster; 00052 00053 }
void TSGFromPropagation::adjust | ( | TrajectoryStateOnSurface & | state | ) | const [private] |
adjust the error matrix of the TSOS
Definition at line 332 of file TSGFromPropagation.cc.
References TrajectoryStateOnSurface::curvilinearError(), MuonErrorMatrix::get(), TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalParameters(), MuonErrorMatrix::multiply(), TrajectoryStateOnSurface::surface(), TrajectoryStateOnSurface::surfaceSide(), theErrorMatrixAdjuster, and TrajectoryStateOnSurface::weight().
00332 { 00333 CurvilinearTrajectoryError oMat = state.curvilinearError(); 00334 CurvilinearTrajectoryError sfMat = theErrorMatrixAdjuster->get(state.globalMomentum());//FIXME with position 00335 MuonErrorMatrix::multiply(oMat, sfMat); 00336 00337 state = TrajectoryStateOnSurface(state.globalParameters(), 00338 oMat, 00339 state.surface(), 00340 state.surfaceSide(), 00341 state.weight()); 00342 }
void TSGFromPropagation::adjust | ( | FreeTrajectoryState & | state | ) | const [private] |
adjust the error matrix of the FTS
Definition at line 323 of file TSGFromPropagation.cc.
References FreeTrajectoryState::curvilinearError(), MuonErrorMatrix::get(), FreeTrajectoryState::momentum(), MuonErrorMatrix::multiply(), FreeTrajectoryState::parameters(), and theErrorMatrixAdjuster.
Referenced by innerState(), and outerTkState().
00323 { 00324 CurvilinearTrajectoryError oMat = state.curvilinearError(); 00325 CurvilinearTrajectoryError sfMat = theErrorMatrixAdjuster->get(state.momentum());//FIXME with position 00326 MuonErrorMatrix::multiply(oMat, sfMat); 00327 00328 state = FreeTrajectoryState(state.parameters(), 00329 oMat); 00330 }
TrajectorySeed TSGFromPropagation::createSeed | ( | const TrajectoryStateOnSurface & | tsos, | |
const edm::OwnVector< TrackingRecHit > & | container, | |||
const DetId & | id | |||
) | const [private] |
create a seed from a trajectory state
Definition at line 247 of file TSGFromPropagation.cc.
References oppositeToMomentum, TrajectoryStateTransform::persistentState(), and theTSTransformer.
00247 { 00248 00249 PTrajectoryStateOnDet* seedTSOS = theTSTransformer->persistentState(tsos,id.rawId()); 00250 return TrajectorySeed(*seedTSOS,container,oppositeToMomentum); 00251 00252 }
TrajectorySeed TSGFromPropagation::createSeed | ( | const TrajectoryStateOnSurface & | tsos, | |
const DetId & | id | |||
) | const [private] |
create a hitless seed from a trajectory state
Definition at line 240 of file TSGFromPropagation.cc.
Referenced by trackerSeeds().
00240 { 00241 00242 edm::OwnVector<TrackingRecHit> container; 00243 return createSeed(tsos, container, id); 00244 00245 }
double TSGFromPropagation::dxyDis | ( | const TrajectoryStateOnSurface & | tsos | ) | const [private] |
Definition at line 315 of file TSGFromPropagation.cc.
References TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().
00315 { 00316 return fabs(( - tsos.globalPosition().x() * tsos.globalMomentum().y() + tsos.globalPosition().y() * tsos.globalMomentum().x() )/tsos.globalMomentum().perp()); 00317 }
const Chi2MeasurementEstimator* TSGFromPropagation::estimator | ( | void | ) | const [inline, private] |
Definition at line 59 of file TSGFromPropagation.h.
References theEstimator.
Referenced by findMeasurements(), findMeasurements_new(), and trackerSeeds().
00059 { return theEstimator; }
std::vector< TrajectoryMeasurement > TSGFromPropagation::findMeasurements | ( | const DetLayer * | nl, | |
const TrajectoryStateOnSurface & | staState | |||
) | const [private] |
look for measurements on the first compatible layer
Definition at line 293 of file TSGFromPropagation.cc.
References estimator(), LayerMeasurements::measurements(), propagator(), HLT_VtxMuL3::result, tkLayerMeasurements(), and validMeasurements().
00293 { 00294 00295 std::vector<TrajectoryMeasurement> result = tkLayerMeasurements()->measurements((*nl), staState, *propagator(), *estimator()); 00296 validMeasurements(result); 00297 return result; 00298 }
std::vector< TrajectoryMeasurement > TSGFromPropagation::findMeasurements_new | ( | const DetLayer * | nl, | |
const TrajectoryStateOnSurface & | staState | |||
) | const [private] |
look for measurements on the first compatible layer (faster way)
Definition at line 268 of file TSGFromPropagation.cc.
References GeometricSearchDet::compatibleDets(), estimator(), propagator(), HLT_VtxMuL3::result, theMeasTracker, and validMeasurements().
Referenced by trackerSeeds().
00268 { 00269 00270 std::vector<TrajectoryMeasurement> result; 00271 00272 std::vector<DetLayer::DetWithState> compatDets = nl->compatibleDets(staState, *propagator(), *estimator()); 00273 if ( compatDets.empty() ) return result; 00274 00275 for (std::vector<DetLayer::DetWithState>::const_iterator idws = compatDets.begin(); idws != compatDets.end(); ++idws) { 00276 if ( idws->second.isValid() && (idws->first) ) { 00277 std::vector<TrajectoryMeasurement> tmptm = 00278 theMeasTracker->idToDet(idws->first->geographicalId())->fastMeasurements(idws->second, idws->second, *propagator(), *estimator()); 00279 validMeasurements(tmptm); 00280 // if ( tmptm.size() > 2 ) { 00281 // std::stable_sort(tmptm.begin(),tmptm.end(),increasingEstimate()); 00282 // result.insert(result.end(),tmptm.begin(), tmptm.begin()+2); 00283 // } else { 00284 result.insert(result.end(),tmptm.begin(), tmptm.end()); 00285 // } 00286 } 00287 } 00288 00289 return result; 00290 00291 }
void TSGFromPropagation::findSecondMeasurements | ( | std::vector< TrajectoryMeasurement > & | tms, | |
const std::vector< const DetLayer * > & | dls | |||
) | const [private] |
void TSGFromPropagation::init | ( | const MuonServiceProxy * | service | ) | [virtual] |
initialize
Reimplemented from TrackerSeedGenerator.
Definition at line 136 of file TSGFromPropagation.cc.
References Chi2MeasurementEstimatorESProducer_cfi::Chi2MeasurementEstimator, edm::ParameterSet::empty(), MuonErrorMatrix::get(), edm::ParameterSet::getParameter(), theAdjustAtIp, theCacheId_MT, theConfig, theErrorMatrixAdjuster, theErrorRescaling, theEstimator, theMaxChi2, theNavigation, thePropagatorName, theSelectStateFlag, theService, theTracker, theTSTransformer, theUpdateStateFlag, theUpdator, theUseSecondMeasurementsFlag, and theUseVertexStateFlag.
00136 { 00137 00138 theMaxChi2 = theConfig.getParameter<double>("MaxChi2"); 00139 00140 theErrorRescaling = theConfig.getParameter<double>("ErrorRescaling"); 00141 00142 theEstimator = new Chi2MeasurementEstimator(theMaxChi2); 00143 00144 theCacheId_MT = 0; 00145 00146 thePropagatorName = theConfig.getParameter<std::string>("Propagator"); 00147 00148 theService = service; 00149 00150 theUseVertexStateFlag = theConfig.getParameter<bool>("UseVertexState"); 00151 00152 theUpdateStateFlag = theConfig.getParameter<bool>("UpdateState"); 00153 00154 theUseSecondMeasurementsFlag = theConfig.getParameter<bool>("UseSecondMeasurements"); 00155 00156 theSelectStateFlag = theConfig.getParameter<bool>("SelectState"); 00157 00158 theUpdator = new KFUpdator(); 00159 00160 theTSTransformer = new TrajectoryStateTransform(); 00161 00162 edm::ParameterSet errorMatrixPset = theConfig.getParameter<edm::ParameterSet>("errorMatrixPset"); 00163 if (!errorMatrixPset.empty()){ 00164 theAdjustAtIp = errorMatrixPset.getParameter<bool>("atIP"); 00165 theErrorMatrixAdjuster = new MuonErrorMatrix(errorMatrixPset); 00166 } else { 00167 theAdjustAtIp =false; 00168 theErrorMatrixAdjuster=0; 00169 } 00170 00171 theService->eventSetup().get<TrackerRecoGeometryRecord>().get(theTracker); 00172 theNavigation = new DirectTrackerNavigation(theTracker); 00173 00174 }
TrajectoryStateOnSurface TSGFromPropagation::innerState | ( | const TrackCand & | staMuon | ) | const [private] |
Definition at line 198 of file TSGFromPropagation.cc.
References adjust(), alongMomentum, TrajectoryStateTransform::innerStateOnSurface(), oppositeToMomentum, TrajectoryStateOnSurface::rescaleError(), theAdjustAtIp, theErrorMatrixAdjuster, theErrorRescaling, theService, and theTSTransformer.
Referenced by outerTkState().
00198 { 00199 00200 TrajectoryStateOnSurface innerTS; 00201 00202 if ( staMuon.first && staMuon.first->isValid() ) { 00203 if (staMuon.first->direction() == alongMomentum) { 00204 innerTS = staMuon.first->firstMeasurement().updatedState(); 00205 } 00206 else if (staMuon.first->direction() == oppositeToMomentum) { 00207 innerTS = staMuon.first->lastMeasurement().updatedState(); 00208 } 00209 } else { 00210 innerTS = theTSTransformer->innerStateOnSurface(*(staMuon.second),*theService->trackingGeometry(), &*theService->magneticField()); 00211 } 00212 //rescale the error 00213 if (theErrorMatrixAdjuster && !theAdjustAtIp) adjust(innerTS); 00214 else innerTS.rescaleError(theErrorRescaling); 00215 00216 return innerTS; 00217 00218 // return theTSTransformer->innerStateOnSurface(*(staMuon.second),*theService->trackingGeometry(), &*theService->magneticField()); 00219 }
TrajectoryStateOnSurface TSGFromPropagation::outerTkState | ( | const TrackCand & | staMuon | ) | const [private] |
Definition at line 221 of file TSGFromPropagation.cc.
References adjust(), TrajectoryStateTransform::initialFreeState(), innerState(), propagator(), FreeTrajectoryState::rescaleError(), HLT_VtxMuL3::result, theAdjustAtIp, theErrorMatrixAdjuster, theErrorRescaling, theService, theTSTransformer, and theUseVertexStateFlag.
Referenced by trackerSeeds().
00221 { 00222 00223 TrajectoryStateOnSurface result; 00224 00225 if ( theUseVertexStateFlag && staMuon.second->pt() > 1.0 ) { 00226 FreeTrajectoryState iniState = theTSTransformer->initialFreeState(*(staMuon.second), &*theService->magneticField()); 00227 //rescale the error at IP 00228 if (theErrorMatrixAdjuster && theAdjustAtIp){ adjust(iniState); } 00229 else iniState.rescaleError(theErrorRescaling); 00230 00231 StateOnTrackerBound fromInside(&*(theService->propagator("PropagatorWithMaterial"))); 00232 result = fromInside(iniState); 00233 } else { 00234 StateOnTrackerBound fromOutside(&*propagator()); 00235 result = fromOutside(innerState(staMuon)); 00236 } 00237 return result; 00238 }
bool TSGFromPropagation::passSelection | ( | const TrajectoryStateOnSurface & | tsos | ) | const [private] |
check some quantity and beam-spot compatibility and decide to continue
Definition at line 304 of file TSGFromPropagation.cc.
References theSelectStateFlag, and zDis().
Referenced by trackerSeeds().
00304 { 00305 if ( !theSelectStateFlag ) return true; 00306 else { 00307 double theSigmaZ = 22; 00308 return ( (zDis(tsos) < theSigmaZ) ); 00309 } 00310 // double theDxyCut = 100; 00311 // return ( (zDis(tsos) < theSigmaZ) && (dxyDis(tsos) < theDxyCut) ); 00312 00313 }
edm::ESHandle<Propagator> TSGFromPropagation::propagator | ( | void | ) | const [inline, private] |
Definition at line 61 of file TSGFromPropagation.h.
References thePropagatorName, and theService.
Referenced by findMeasurements(), findMeasurements_new(), outerTkState(), and trackerSeeds().
00061 {return theService->propagator(thePropagatorName); }
void TSGFromPropagation::selectMeasurements | ( | std::vector< TrajectoryMeasurement > & | tms | ) | const [private] |
select by comparing likely measurements
further clean measurements
Definition at line 255 of file TSGFromPropagation.cc.
void TSGFromPropagation::setEvent | ( | const edm::Event & | iEvent | ) | [virtual] |
set an event
Reimplemented from TrackerSeedGenerator.
Definition at line 176 of file TSGFromPropagation.cc.
References LogTrace, theCacheId_MT, theCategory, theMeasTracker, theService, and theTkLayerMeasurements.
00176 { 00177 00178 bool measTrackerChanged = false; 00179 00180 unsigned long long newCacheId_MT = theService->eventSetup().get<CkfComponentsRecord>().cacheIdentifier(); 00181 00182 if ( newCacheId_MT != theCacheId_MT ) { 00183 LogTrace(theCategory) << "Measurment Tracker Geometry changed!"; 00184 theCacheId_MT = newCacheId_MT; 00185 theService->eventSetup().get<CkfComponentsRecord>().get(theMeasTracker); 00186 measTrackerChanged = true; 00187 } 00188 00189 theMeasTracker->update(iEvent); 00190 00191 if ( measTrackerChanged && (&*theMeasTracker) ) { 00192 if ( theTkLayerMeasurements ) delete theTkLayerMeasurements; 00193 theTkLayerMeasurements = new LayerMeasurements(&*theMeasTracker); 00194 } 00195 00196 }
const LayerMeasurements* TSGFromPropagation::tkLayerMeasurements | ( | ) | const [inline, private] |
Definition at line 55 of file TSGFromPropagation.h.
References theTkLayerMeasurements.
Referenced by findMeasurements().
00055 { return theTkLayerMeasurements; }
void TSGFromPropagation::trackerSeeds | ( | const TrackCand & | staMuon, | |
const TrackingRegion & | region, | |||
std::vector< TrajectorySeed > & | result | |||
) |
generate seed(s) for a track
Definition at line 55 of file TSGFromPropagation.cc.
References DirectTrackerNavigation::compatibleLayers(), createSeed(), estimator(), PV3DBase< T, PVType, FrameType >::eta(), findMeasurements_new(), TrajectoryStateOnSurface::freeState(), TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), i, TrajectoryStateOnSurface::isValid(), LogTrace, oppositeToMomentum, outerTkState(), passSelection(), PV3DBase< T, PVType, FrameType >::perp(), propagator(), edm::OwnVector< T, P >::push_back(), theCategory, theNavigation, theUpdateStateFlag, TrajectoryStateUpdator::update(), and updator().
00055 { 00056 00057 TrajectoryStateOnSurface staState = outerTkState(staMuon); 00058 00059 if ( !staState.isValid() ) { 00060 LogTrace(theCategory) << "Error: initial state from L2 muon is invalid."; 00061 return; 00062 } 00063 00064 LogTrace(theCategory) << "begin of trackerSeed:\n staState pos: "<<staState.globalPosition() 00065 << " mom: "<<staState.globalMomentum() 00066 <<"pos eta: "<<staState.globalPosition().eta() 00067 <<"mom eta: "<<staState.globalMomentum().eta(); 00068 00069 std::vector<const DetLayer*> nls = theNavigation->compatibleLayers(*(staState.freeState()), oppositeToMomentum); 00070 00071 LogTrace(theCategory) << " compatible layers: "<<nls.size(); 00072 00073 if ( nls.empty() ) return; 00074 00075 int ndesLayer = 0; 00076 00077 bool usePredictedState = false; 00078 00079 if ( theUpdateStateFlag ) { //use updated states 00080 std::vector<TrajectoryMeasurement> alltm; 00081 00082 for (std::vector<const DetLayer*>::const_iterator inl = nls.begin(); 00083 inl != nls.end(); inl++, ndesLayer++ ) { 00084 if ( (*inl == 0) ) break; 00085 alltm = findMeasurements_new(*inl, staState); 00086 if ( (!alltm.empty()) ) { 00087 LogTrace(theCategory) << "final compatible layer: "<<ndesLayer; 00088 break; 00089 } 00090 } 00091 00092 if ( alltm.empty() ) { 00093 LogTrace(theCategory) << " NO Measurements Found: eta: "<<staState.globalPosition().eta() <<"pt "<<staState.globalMomentum().perp(); 00094 usePredictedState = true; 00095 } else { 00096 LogTrace(theCategory) << " Measurements for seeds: "<<alltm.size(); 00097 std::stable_sort(alltm.begin(),alltm.end(),increasingEstimate()); 00098 if ( alltm.size() > 5 ) alltm.erase(alltm.begin() + 5, alltm.end()); 00099 00100 int i = 0; 00101 for (std::vector<TrajectoryMeasurement>::const_iterator itm = alltm.begin(); 00102 itm != alltm.end(); itm++, i++) { 00103 TrajectoryStateOnSurface updatedTSOS = updator()->update(itm->predictedState(), *(itm->recHit())); 00104 if ( updatedTSOS.isValid() && passSelection(updatedTSOS) ) { 00105 edm::OwnVector<TrackingRecHit> container; 00106 container.push_back(itm->recHit()->hit()->clone()); 00107 TrajectorySeed ts = createSeed(updatedTSOS, container, itm->recHit()->geographicalId()); 00108 result.push_back(ts); 00109 } 00110 } 00111 return; 00112 } 00113 } 00114 00115 if ( !theUpdateStateFlag || usePredictedState ) { //use predicted states 00116 LogTrace(theCategory) << "use predicted state: "; 00117 for (std::vector<const DetLayer*>::const_iterator inl = nls.begin(); 00118 inl != nls.end(); inl++ ) { 00119 00120 if ( !result.empty() || *inl == 0 ) { 00121 break; 00122 } 00123 std::vector<DetLayer::DetWithState> compatDets = (*inl)->compatibleDets(staState, *propagator(), *estimator()); 00124 LogTrace(theCategory) << " compatDets "<<compatDets.size(); 00125 if ( compatDets.empty() ) continue; 00126 TrajectorySeed ts = createSeed(compatDets.front().second, compatDets.front().first->geographicalId()); 00127 result.push_back(ts); 00128 00129 } 00130 LogTrace(theCategory) << "result: "<<result.size(); 00131 return; 00132 } 00133 return; 00134 }
const TrajectoryStateUpdator* TSGFromPropagation::updator | ( | ) | const [inline, private] |
Definition at line 57 of file TSGFromPropagation.h.
References theUpdator.
Referenced by trackerSeeds().
00057 {return theUpdator;}
void TSGFromPropagation::validMeasurements | ( | std::vector< TrajectoryMeasurement > & | tms | ) | const [private] |
select valid measurements
Definition at line 260 of file TSGFromPropagation.cc.
Referenced by findMeasurements(), and findMeasurements_new().
00260 { 00261 00262 std::vector<TrajectoryMeasurement>::iterator tmsend = std::remove_if(tms.begin(), tms.end(), isInvalid()); 00263 tms.erase(tmsend, tms.end()); 00264 return; 00265 00266 }
double TSGFromPropagation::zDis | ( | const TrajectoryStateOnSurface & | tsos | ) | const [private] |
Definition at line 319 of file TSGFromPropagation.cc.
References TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), PV3DBase< T, PVType, FrameType >::perp(), and PV3DBase< T, PVType, FrameType >::z().
Referenced by passSelection().
00319 { 00320 return fabs(tsos.globalPosition().z() - tsos.globalPosition().perp() * tsos.globalMomentum().z()/tsos.globalMomentum().perp()); 00321 }
bool TSGFromPropagation::theAdjustAtIp [private] |
Definition at line 148 of file TSGFromPropagation.h.
Referenced by init(), innerState(), and outerTkState().
unsigned long long TSGFromPropagation::theCacheId_MT [private] |
std::string TSGFromPropagation::theCategory [private] |
Definition at line 112 of file TSGFromPropagation.h.
Referenced by setEvent(), trackerSeeds(), TSGFromPropagation(), and ~TSGFromPropagation().
Definition at line 146 of file TSGFromPropagation.h.
Referenced by adjust(), init(), innerState(), outerTkState(), and ~TSGFromPropagation().
double TSGFromPropagation::theErrorRescaling [private] |
Definition at line 134 of file TSGFromPropagation.h.
Referenced by init(), innerState(), and outerTkState().
const Chi2MeasurementEstimator* TSGFromPropagation::theEstimator [private] |
Definition at line 126 of file TSGFromPropagation.h.
Referenced by estimator(), init(), and ~TSGFromPropagation().
double TSGFromPropagation::theMaxChi2 [private] |
Definition at line 118 of file TSGFromPropagation.h.
Referenced by findMeasurements_new(), and setEvent().
const DirectTrackerNavigation* TSGFromPropagation::theNavigation [private] |
Definition at line 120 of file TSGFromPropagation.h.
Referenced by init(), trackerSeeds(), and ~TSGFromPropagation().
std::string TSGFromPropagation::thePropagatorName [private] |
bool TSGFromPropagation::theSelectStateFlag [private] |
const MuonServiceProxy* TSGFromPropagation::theService [private] |
Definition at line 122 of file TSGFromPropagation.h.
Referenced by init(), innerState(), outerTkState(), propagator(), and setEvent().
const LayerMeasurements* TSGFromPropagation::theTkLayerMeasurements [private] |
Definition at line 114 of file TSGFromPropagation.h.
Referenced by setEvent(), tkLayerMeasurements(), and ~TSGFromPropagation().
Definition at line 128 of file TSGFromPropagation.h.
Referenced by createSeed(), init(), innerState(), outerTkState(), and ~TSGFromPropagation().
bool TSGFromPropagation::theUpdateStateFlag [private] |
const TrajectoryStateUpdator* TSGFromPropagation::theUpdator [private] |
Definition at line 124 of file TSGFromPropagation.h.
Referenced by init(), updator(), and ~TSGFromPropagation().