#include <MuonTrajectoryUpdator.h>
Classes | |
struct | RadiusComparatorInOut |
Ordering along increasing radius (for DT rechits) More... | |
struct | RadiusComparatorOutIn |
Ordering along decreasing radius (for DT rechits) More... | |
struct | ZedComparatorInOut |
Ordering along increasing zed (for CSC rechits) More... | |
struct | ZedComparatorOutIn |
Ordering along decreasing zed (for CSC rechits) More... | |
Public Member Functions | |
const MeasurementEstimator * | estimator () const |
accasso at the propagator | |
NavigationDirection | fitDirection () |
get the fit direction | |
void | makeFirstTime () |
reset the theFirstTSOSFlag | |
double | maxChi2 () const |
get the max chi2 allowed | |
const TrajectoryStateUpdator * | measurementUpdator () const |
MuonTrajectoryUpdator (const edm::ParameterSet &par, NavigationDirection fitDirection) | |
Constructor from Propagator and Parameter set. | |
MuonTrajectoryUpdator (NavigationDirection fitDirection, double chi2, int granularity) | |
Constructor from Propagator, chi2 and the granularity flag. | |
void | setFitDirection (NavigationDirection fitDirection) |
set fit direction | |
void | setMaxChi2 (double chi2) |
set max chi2 | |
virtual std::pair< bool, TrajectoryStateOnSurface > | update (const TrajectoryMeasurement *measurement, Trajectory &trajectory, const Propagator *propagator) |
update the Trajectory with the TrajectoryMeasurement | |
virtual | ~MuonTrajectoryUpdator () |
Destructor. | |
Private Member Functions | |
TrajectoryStateOnSurface | propagateState (const TrajectoryStateOnSurface &state, const TrajectoryMeasurement *measurement, const TransientTrackingRecHit::ConstRecHitPointer ¤t, const Propagator *propagator) const |
void | sort (TransientTrackingRecHit::ConstRecHitContainer &, const DetLayer *) |
TrajectoryMeasurement | updateMeasurement (const TrajectoryStateOnSurface &propagatedTSOS, const TrajectoryStateOnSurface &lastUpdatedTSOS, const TransientTrackingRecHit::ConstRecHitPointer &recHit, const double &chi2, const DetLayer *detLayer, const TrajectoryMeasurement *initialMeasurement) |
Return the trajectory measurement. It handles both the fw and the bw propagation. | |
Private Attributes | |
MeasurementEstimator * | theEstimator |
bool | theFirstTSOSFlag |
NavigationDirection | theFitDirection |
int | theGranularity |
double | theMaxChi2 |
the max chi2 allowed | |
bool | theRescaleErrorFlag |
double | theRescaleFactor |
bool | theRPCExFlag |
TrajectoryStateUpdator * | theUpdator |
bool | useInvalidHits |
An updator for the Muon system This class update a trajectory with a muon chamber measurement. In spite of the name, it is NOT an updator, but has one. A muon RecHit is a segment (for DT and CSC) or a "hit" (RPC). This updator is suitable both for FW and BW filtering. The difference between the two fitter are two: the granularity of the updating (i.e.: segment position or 1D rechit position), which can be set via parameter set, and the propagation direction which is embeded in the propagator set in the c'tor.
An updator for the Muon system This class update a trajectory with a muon chamber measurement. In spite of the name, it is NOT an updator, but has one. A muon RecHit is a segment (for DT and CSC) or a "hit" (RPC). This updator is suitable both for FW and BW filtering. The difference between the two fitter are two: the granularity of the updating (i.e.: segment position or 1D rechit position), which can be set via parameter set, and the propagation direction which is embeded in the propagator set in the c'tor.
Definition at line 34 of file MuonTrajectoryUpdator.h.
MuonTrajectoryUpdator::MuonTrajectoryUpdator | ( | const edm::ParameterSet & | par, |
NavigationDirection | fitDirection | ||
) |
Constructor from Propagator and Parameter set.
Definition at line 42 of file MuonTrajectoryUpdator.cc.
References Chi2MeasurementEstimatorESProducer_cfi::Chi2MeasurementEstimator, edm::ParameterSet::getParameter(), theEstimator, theFirstTSOSFlag, theGranularity, theMaxChi2, theRescaleErrorFlag, theRescaleFactor, theRPCExFlag, theUpdator, and useInvalidHits.
: theFitDirection(fitDirection){ // The max allowed chi2 to accept a rechit in the fit theMaxChi2 = par.getParameter<double>("MaxChi2"); theEstimator = new Chi2MeasurementEstimator(theMaxChi2); // The KF updator theUpdator= new KFUpdator(); // The granularity theGranularity = par.getParameter<int>("Granularity"); // Rescale the error of the first state? theRescaleErrorFlag = par.getParameter<bool>("RescaleError"); if(theRescaleErrorFlag) // The rescale factor theRescaleFactor = par.getParameter<double>("RescaleErrorFactor"); // Use the invalid hits? useInvalidHits = par.getParameter<bool>("UseInvalidHits"); // Flag needed for the rescaling theFirstTSOSFlag = true; // Exlude RPC from the fit? theRPCExFlag = par.getParameter<bool>("ExcludeRPCFromFit"); }
MuonTrajectoryUpdator::MuonTrajectoryUpdator | ( | NavigationDirection | fitDirection, |
double | chi2, | ||
int | granularity | ||
) |
Constructor from Propagator, chi2 and the granularity flag.
Definition at line 72 of file MuonTrajectoryUpdator.cc.
References Chi2MeasurementEstimatorESProducer_cfi::Chi2MeasurementEstimator, theEstimator, theMaxChi2, and theUpdator.
: theMaxChi2(chi2), theGranularity(granularity), theFitDirection(fitDirection){ theEstimator = new Chi2MeasurementEstimator(theMaxChi2); // The KF updator theUpdator= new KFUpdator(); }
MuonTrajectoryUpdator::~MuonTrajectoryUpdator | ( | ) | [virtual] |
Destructor.
Definition at line 83 of file MuonTrajectoryUpdator.cc.
References theEstimator, and theUpdator.
{ delete theEstimator; delete theUpdator; }
const MeasurementEstimator* MuonTrajectoryUpdator::estimator | ( | void | ) | const [inline] |
accasso at the propagator
Definition at line 57 of file MuonTrajectoryUpdator.h.
References theEstimator.
Referenced by CosmicMuonTrajectoryBuilder::trajectories(), and update().
{return theEstimator;}
NavigationDirection MuonTrajectoryUpdator::fitDirection | ( | ) | [inline] |
get the fit direction
Definition at line 64 of file MuonTrajectoryUpdator.h.
References theFitDirection.
Referenced by setFitDirection(), and sort().
{return theFitDirection;}
void MuonTrajectoryUpdator::makeFirstTime | ( | ) |
reset the theFirstTSOSFlag
Definition at line 88 of file MuonTrajectoryUpdator.cc.
References theFirstTSOSFlag.
Referenced by CosmicMuonTrajectoryBuilder::build(), and StandAloneMuonFilter::reset().
{ theFirstTSOSFlag = true; }
double MuonTrajectoryUpdator::maxChi2 | ( | ) | const [inline] |
get the max chi2 allowed
Definition at line 61 of file MuonTrajectoryUpdator.h.
References theMaxChi2.
{return theMaxChi2 ;}
const TrajectoryStateUpdator* MuonTrajectoryUpdator::measurementUpdator | ( | ) | const [inline] |
Definition at line 58 of file MuonTrajectoryUpdator.h.
References theUpdator.
Referenced by update().
{return theUpdator;}
TrajectoryStateOnSurface MuonTrajectoryUpdator::propagateState | ( | const TrajectoryStateOnSurface & | state, |
const TrajectoryMeasurement * | measurement, | ||
const TransientTrackingRecHit::ConstRecHitPointer & | current, | ||
const Propagator * | propagator | ||
) | const [private] |
Propagate the state to the hit surface if it's a multi hit RecHit. i.e.: if "current" is a sub-rechit of the mesurement (i.e. a 1/2D RecHit) the state will be propagated to the surface where lies the "current" rechit
Definition at line 213 of file MuonTrajectoryUpdator.cc.
References TrajectoryMeasurement::predictedState(), Propagator::propagate(), and TrajectoryMeasurement::recHit().
Referenced by update().
{ const TransientTrackingRecHit::ConstRecHitPointer mother = measurement->recHit(); if( current->geographicalId() == mother->geographicalId() ) return measurement->predictedState(); const TrajectoryStateOnSurface tsos = propagator->propagate(state, current->det()->surface()); return tsos; }
void MuonTrajectoryUpdator::setFitDirection | ( | NavigationDirection | fitDirection | ) | [inline] |
set fit direction
Definition at line 70 of file MuonTrajectoryUpdator.h.
References fitDirection(), and theFitDirection.
Referenced by CosmicMuonTrajectoryBuilder::build(), and CosmicMuonTrajectoryBuilder::trajectories().
void MuonTrajectoryUpdator::setMaxChi2 | ( | double | chi2 | ) | [inline] |
set max chi2
Definition at line 67 of file MuonTrajectoryUpdator.h.
References theMaxChi2.
{theMaxChi2 = chi2;}
void MuonTrajectoryUpdator::sort | ( | TransientTrackingRecHit::ConstRecHitContainer & | recHitsForFit, |
const DetLayer * | detLayer | ||
) | [private] |
Definition at line 254 of file MuonTrajectoryUpdator.cc.
References CSC(), GeomDetEnumerators::DT, fitDirection(), insideOut, outsideIn, and DetLayer::subDetector().
Referenced by update().
{ if(detLayer->subDetector()==GeomDetEnumerators::DT){ if(fitDirection() == insideOut) stable_sort(recHitsForFit.begin(),recHitsForFit.end(), RadiusComparatorInOut() ); else if(fitDirection() == outsideIn) stable_sort(recHitsForFit.begin(),recHitsForFit.end(),RadiusComparatorOutIn() ); else LogError("Muon|RecoMuon|MuonTrajectoryUpdator") <<"MuonTrajectoryUpdator::sort: Wrong propagation direction!!"; } else if(detLayer->subDetector()==GeomDetEnumerators::CSC){ if(fitDirection() == insideOut) stable_sort(recHitsForFit.begin(),recHitsForFit.end(), ZedComparatorInOut() ); else if(fitDirection() == outsideIn) stable_sort(recHitsForFit.begin(),recHitsForFit.end(), ZedComparatorOutIn() ); else LogError("Muon|RecoMuon|MuonTrajectoryUpdator") <<"MuonTrajectoryUpdator::sort: Wrong propagation direction!!"; } }
pair< bool, TrajectoryStateOnSurface > MuonTrajectoryUpdator::update | ( | const TrajectoryMeasurement * | measurement, |
Trajectory & | trajectory, | ||
const Propagator * | propagator | ||
) | [virtual] |
update the Trajectory with the TrajectoryMeasurement
Definition at line 94 of file MuonTrajectoryUpdator.cc.
References MuonTransientTrackingRecHitBreaker::breakInSubRecHits(), MuonPatternRecoDumper::dumpTSOS(), MeasurementEstimator::estimate(), estimator(), TrajectoryStateOnSurface::globalDirection(), TrajectoryStateOnSurface::globalPosition(), TrajectoryStateOnSurface::isValid(), TrajectoryMeasurement::layer(), LogTrace, measurementUpdator(), metname, DetId::Muon, PV3DBase< T, PVType, FrameType >::perp(), TrajectoryMeasurement::predictedState(), propagateState(), Trajectory::push(), TrajectoryMeasurement::recHit(), TrajectoryStateOnSurface::rescaleError(), dedefs::RPC, sort(), MuonTransientTrackingRecHit::specificBuild(), AlCaHLTBitMon_QueryRunRegistry::string, theFirstTSOSFlag, theGranularity, theRescaleErrorFlag, theRescaleFactor, theRPCExFlag, TrajectoryStateUpdator::update(), updateMeasurement(), and useInvalidHits.
Referenced by CosmicMuonTrajectoryBuilder::build(), CosmicMuonTrajectoryBuilder::trajectories(), and StandAloneMuonFilter::update().
{ const std::string metname = "Muon|RecoMuon|MuonTrajectoryUpdator"; MuonPatternRecoDumper muonDumper; // Status of the updating bool updated=false; if(!measurement) return pair<bool,TrajectoryStateOnSurface>(updated,TrajectoryStateOnSurface() ); // measurement layer const DetLayer* detLayer=measurement->layer(); // these are the 4D segment for the CSC/DT and a point for the RPC TransientTrackingRecHit::ConstRecHitPointer muonRecHit = measurement->recHit(); // The KFUpdator takes TransientTrackingRecHits as arg. TransientTrackingRecHit::ConstRecHitContainer recHitsForFit = MuonTransientTrackingRecHitBreaker::breakInSubRecHits(muonRecHit,theGranularity); // sort the container in agreement with the porpagation direction sort(recHitsForFit,detLayer); TrajectoryStateOnSurface lastUpdatedTSOS = measurement->predictedState(); LogTrace(metname)<<"Number of rechits for the fit: "<<recHitsForFit.size()<<endl; TransientTrackingRecHit::ConstRecHitContainer::iterator recHit; for(recHit = recHitsForFit.begin(); recHit != recHitsForFit.end(); ++recHit ) { if ((*recHit)->isValid() ) { // propagate the TSOS onto the rechit plane TrajectoryStateOnSurface propagatedTSOS = propagateState(lastUpdatedTSOS, measurement, *recHit, propagator); if ( propagatedTSOS.isValid() ) { pair<bool,double> thisChi2 = estimator()->estimate(propagatedTSOS, *((*recHit).get())); LogTrace(metname) << "Estimation for Kalman Fit. Chi2: " << thisChi2.second; // Is an RPC hit? Prepare the variable to possibly exluding it from the fit bool wantIncludeThisHit = true; if (theRPCExFlag && (*recHit)->geographicalId().det() == DetId::Muon && (*recHit)->geographicalId().subdetId() == MuonSubdetId::RPC){ wantIncludeThisHit = false; LogTrace(metname) << "This is an RPC hit and the present configuration is such that it will be excluded from the fit"; } // The Chi2 cut was already applied in the estimator, which // returns 0 if the chi2 is bigger than the cut defined in its // constructor if (thisChi2.first) { updated=true; if (wantIncludeThisHit) { // This split is a trick to have the RPC hits counted as updatable (in used chamber counting), while are not actually included in the fit when the proper obtion is activated. LogTrace(metname) << endl << " Kalman Start" << "\n" << "\n"; LogTrace(metname) << " Meas. Position : " << (**recHit).globalPosition() << "\n" << " Pred. Position : " << propagatedTSOS.globalPosition() << " Pred Direction : " << propagatedTSOS.globalDirection()<< endl; if(theRescaleErrorFlag && theFirstTSOSFlag){ propagatedTSOS.rescaleError(theRescaleFactor); theFirstTSOSFlag = false; } lastUpdatedTSOS = measurementUpdator()->update(propagatedTSOS,*((*recHit).get())); LogTrace(metname) << " Fit Position : " << lastUpdatedTSOS.globalPosition() << " Fit Direction : " << lastUpdatedTSOS.globalDirection() << "\n" << " Fit position radius : " << lastUpdatedTSOS.globalPosition().perp() << "filter updated" << endl; LogTrace(metname) << muonDumper.dumpTSOS(lastUpdatedTSOS); LogTrace(metname) << "\n\n Kalman End" << "\n" << "\n"; TrajectoryMeasurement updatedMeasurement = updateMeasurement( propagatedTSOS, lastUpdatedTSOS, *recHit, thisChi2.second, detLayer, measurement); // FIXME: check! trajectory.push(updatedMeasurement, thisChi2.second); } else { LogTrace(metname) << " Compatible RecHit with good chi2 but made with RPC when it was decided to not include it in the fit" << " --> trajectory NOT updated, invalid RecHit added." << endl; MuonTransientTrackingRecHit::MuonRecHitPointer invalidRhPtr = MuonTransientTrackingRecHit::specificBuild( (*recHit)->det(), (*recHit)->hit() ); invalidRhPtr->invalidateHit(); TrajectoryMeasurement invalidRhMeasurement(propagatedTSOS, propagatedTSOS, invalidRhPtr.get(), thisChi2.second, detLayer); trajectory.push(invalidRhMeasurement, thisChi2.second); } } else { if(useInvalidHits) { LogTrace(metname) << " Compatible RecHit with too large chi2" << " --> trajectory NOT updated, invalid RecHit added." << endl; MuonTransientTrackingRecHit::MuonRecHitPointer invalidRhPtr = MuonTransientTrackingRecHit::specificBuild( (*recHit)->det(), (*recHit)->hit() ); invalidRhPtr->invalidateHit(); TrajectoryMeasurement invalidRhMeasurement(propagatedTSOS, propagatedTSOS, invalidRhPtr.get(), thisChi2.second, detLayer); trajectory.push(invalidRhMeasurement, thisChi2.second); } } } } } recHitsForFit.clear(); return pair<bool,TrajectoryStateOnSurface>(updated,lastUpdatedTSOS); }
TrajectoryMeasurement MuonTrajectoryUpdator::updateMeasurement | ( | const TrajectoryStateOnSurface & | propagatedTSOS, |
const TrajectoryStateOnSurface & | lastUpdatedTSOS, | ||
const TransientTrackingRecHit::ConstRecHitPointer & | recHit, | ||
const double & | chi2, | ||
const DetLayer * | detLayer, | ||
const TrajectoryMeasurement * | initialMeasurement | ||
) | [private] |
Return the trajectory measurement. It handles both the fw and the bw propagation.
Definition at line 230 of file MuonTrajectoryUpdator.cc.
Referenced by update().
{ return TrajectoryMeasurement(propagatedTSOS, lastUpdatedTSOS, recHit,chi2,detLayer); // // FIXME: put a better check! One could fit in first out-in and then in - out // if(propagator()->propagationDirection() == alongMomentum) // return TrajectoryMeasurement(propagatedTSOS, lastUpdatedTSOS, // recHit,thisChi2.second,detLayer); // // FIXME: Check this carefully!! // else if(propagator()->propagationDirection() == oppositeToMomentum) // return TrajectoryMeasurement(initialMeasurement->forwardPredictedState(), // propagatedTSOS, lastUpdatedTSOS, // recHit,thisChi2.second,detLayer); // else{ // LogError("MuonTrajectoryUpdator::updateMeasurement") <<"Wrong propagation direction!!"; // } }
Definition at line 142 of file MuonTrajectoryUpdator.h.
Referenced by estimator(), MuonTrajectoryUpdator(), and ~MuonTrajectoryUpdator().
bool MuonTrajectoryUpdator::theFirstTSOSFlag [private] |
Definition at line 151 of file MuonTrajectoryUpdator.h.
Referenced by makeFirstTime(), MuonTrajectoryUpdator(), and update().
Definition at line 148 of file MuonTrajectoryUpdator.h.
Referenced by fitDirection(), and setFitDirection().
int MuonTrajectoryUpdator::theGranularity [private] |
the granularity if 0 4D-segments are used both for the DT and CSC, if 1 2D-segments are used for the DT and the 2D-points for the CSC if 2 the 1D rec hit for the DT are used, while the 2D rechit for the CSC are used Maybe in a second step there will be more than 3 option i.e. max granularity for DT but not for the CSC and the viceversa
Definition at line 96 of file MuonTrajectoryUpdator.h.
Referenced by MuonTrajectoryUpdator(), and update().
double MuonTrajectoryUpdator::theMaxChi2 [private] |
the max chi2 allowed
Definition at line 88 of file MuonTrajectoryUpdator.h.
Referenced by maxChi2(), MuonTrajectoryUpdator(), and setMaxChi2().
bool MuonTrajectoryUpdator::theRescaleErrorFlag [private] |
Definition at line 152 of file MuonTrajectoryUpdator.h.
Referenced by MuonTrajectoryUpdator(), and update().
double MuonTrajectoryUpdator::theRescaleFactor [private] |
Definition at line 153 of file MuonTrajectoryUpdator.h.
Referenced by MuonTrajectoryUpdator(), and update().
bool MuonTrajectoryUpdator::theRPCExFlag [private] |
Definition at line 158 of file MuonTrajectoryUpdator.h.
Referenced by MuonTrajectoryUpdator(), and update().
Definition at line 143 of file MuonTrajectoryUpdator.h.
Referenced by measurementUpdator(), MuonTrajectoryUpdator(), and ~MuonTrajectoryUpdator().
bool MuonTrajectoryUpdator::useInvalidHits [private] |
Definition at line 156 of file MuonTrajectoryUpdator.h.
Referenced by MuonTrajectoryUpdator(), and update().