#include <RecoTracker/SiTrackerMRHTools/interface/SiTrackerMultiRecHitUpdator.h>
Definition at line 21 of file SiTrackerMultiRecHitUpdator.h.
SiTrackerMultiRecHitUpdator::SiTrackerMultiRecHitUpdator | ( | const TransientTrackingRecHitBuilder * | builder, | |
const TrackingRecHitPropagator * | hitpropagator, | |||
const std::vector< double > & | anAnnealingProgram | |||
) |
Definition at line 12 of file SiTrackerMultiRecHitUpdator.cc.
00014 : 00015 theBuilder(builder), 00016 theHitPropagator(hitpropagator), 00017 theChi2Cut(9.21), 00018 theAnnealingProgram(anAnnealingProgram){} //theAnnealingStep(0),
virtual SiTrackerMultiRecHitUpdator::~SiTrackerMultiRecHitUpdator | ( | ) | [inline, virtual] |
const std::vector<double>& SiTrackerMultiRecHitUpdator::annealingProgram | ( | ) | const [inline] |
Definition at line 28 of file SiTrackerMultiRecHitUpdator.h.
References theAnnealingProgram.
00028 {return theAnnealingProgram;}
TransientTrackingRecHit::RecHitPointer SiTrackerMultiRecHitUpdator::buildMultiRecHit | ( | const std::vector< const TrackingRecHit * > & | rhv, | |
TrajectoryStateOnSurface | tsos, | |||
double | annealing = 1. | |||
) | const [virtual] |
Definition at line 23 of file SiTrackerMultiRecHitUpdator.cc.
References TransientTrackingRecHitBuilder::build(), iter, theBuilder, and update().
00025 { 00026 TransientTrackingRecHit::ConstRecHitContainer tcomponents; 00027 for (std::vector<const TrackingRecHit*>::const_iterator iter = rhv.begin(); iter != rhv.end(); iter++){ 00028 TransientTrackingRecHit::RecHitPointer transient = theBuilder->build(*iter); 00029 if (transient->isValid()) tcomponents.push_back(transient); 00030 } 00031 00032 return update(tcomponents, tsos, annealing); 00033 00034 }
LocalPoint SiTrackerMultiRecHitUpdator::calcParameters | ( | TransientTrackingRecHit::ConstRecHitContainer & | map, | |
const LocalError & | er | |||
) | const [private] |
Definition at line 167 of file SiTrackerMultiRecHitUpdator.cc.
References lat::endl(), m, python::trackProbabilityAnalysis_cff::parameters, V, LocalError::xx(), LocalError::xy(), and LocalError::yy().
Referenced by update().
00167 { 00168 AlgebraicVector m_sum(2,0); 00169 int ierr; 00170 for( TransientTrackingRecHit::ConstRecHitContainer::const_iterator ihit = map.begin(); ihit != map.end(); ihit ++) { 00171 AlgebraicVector m((*ihit)->parameters()); 00172 AlgebraicSymMatrix V((*ihit)->parametersError()); 00173 AlgebraicSymMatrix W(V.inverse(ierr)); 00174 00175 if(ierr != 0) { 00176 edm::LogError("SiTrackerMultiRecHitUpdator")<<"MultiRecHit::checkParameters: W not valid!"<<std::endl; 00177 } 00178 00179 //m_sum += ihit->weight()*(W*m); 00180 m_sum += ((*ihit)->weight()*(W*m)); 00181 } 00182 AlgebraicSymMatrix V_sum(2); 00183 00184 V_sum[0][0] = er.xx(); 00185 V_sum[0][1] = er.xy(); 00186 V_sum[1][1] = er.yy(); 00187 //AlgebraicSymMatrix V_sum(parametersError()); 00188 AlgebraicVector parameters = V_sum*m_sum; 00189 return LocalPoint(parameters(1), parameters(2)); 00190 }
LocalError SiTrackerMultiRecHitUpdator::calcParametersError | ( | TransientTrackingRecHit::ConstRecHitContainer & | map | ) | const [private] |
Definition at line 150 of file SiTrackerMultiRecHitUpdator.cc.
References lat::endl(), and V.
Referenced by update().
00150 { 00151 AlgebraicSymMatrix W_sum(2,0); 00152 int ierr; 00153 for(TransientTrackingRecHit::ConstRecHitContainer::const_iterator ihit = map.begin(); ihit != map.end(); ihit ++) { 00154 AlgebraicSymMatrix V((*ihit)->parametersError()); 00155 AlgebraicSymMatrix W(V.inverse(ierr)); 00156 00157 if(ierr != 0) { 00158 edm::LogError("SiTrackerMultiRecHitUpdator")<<"MultiRecHit::checkParametersError: W not valid!"<<std::endl; 00159 } 00160 00161 W_sum += ((*ihit)->weight()*W); 00162 } 00163 AlgebraicSymMatrix parametersError = W_sum.inverse(ierr); 00164 return LocalError(parametersError(1,1), parametersError(1,2), parametersError(2,2)); 00165 }
const std::vector<double>& SiTrackerMultiRecHitUpdator::getAnnealingProgram | ( | ) | const [inline] |
Definition at line 46 of file SiTrackerMultiRecHitUpdator.h.
References theAnnealingProgram.
Referenced by DAFTrackProducerAlgorithm::runWithCandidate().
00046 {return theAnnealingProgram;}
TransientTrackingRecHit::RecHitPointer SiTrackerMultiRecHitUpdator::update | ( | TransientTrackingRecHit::ConstRecHitContainer & | tcomponents, | |
TrajectoryStateOnSurface | tsos, | |||
double | annealing = 1. | |||
) | const [virtual] |
Definition at line 57 of file SiTrackerMultiRecHitUpdator.cc.
References TSiTrackerMultiRecHit::build(), InvalidTransientRecHit::build(), calcParameters(), calcParametersError(), counter(), e, lat::endl(), Exception, funct::exp(), first, TrajectoryStateOnSurface::isValid(), iter, TrajectoryStateOnSurface::localPosition(), LogTrace, mymap, name, p, GloballyPositioned< T >::position(), TrackingRecHitPropagator::project(), r, edm::second(), funct::sqrt(), GeomDet::surface(), TrajectoryStateOnSurface::surface(), theChi2Cut, theHitPropagator, V, PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().
00059 { 00060 00061 if (tcomponents.empty()){ 00062 LogTrace("SiTrackerMultiRecHitUpdator") << "Empty components vector passed to SiTrackerMultiRecHitUpdator::update, returning an InvalidTransientRecHit "; 00063 return InvalidTransientRecHit::build(0); 00064 } 00065 00066 if(!tsos.isValid()) { 00067 LogTrace("SiTrackerMultiRecHitUpdator")<<"SiTrackerMultiRecHitUpdator::update: tsos NOT valid!!!, returning an InvalidTransientRecHit"; 00068 return InvalidTransientRecHit::build(0); 00069 } 00070 00071 std::vector<TransientTrackingRecHit::RecHitPointer> updatedcomponents; 00072 const GeomDet* geomdet = 0; 00073 for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator iter = tcomponents.begin(); iter != tcomponents.end(); iter++){ 00074 if (iter == tcomponents.begin()) { 00075 if (&((*iter)->det()->surface())!=&(tsos.surface())){ 00076 throw cms::Exception("SiTrackerMultiRecHitUpdator") << "the Trajectory state and the first rechit passed to the SiTrackerMultiRecHitUpdator lay on different surfaces!: state lays on surface " << tsos.surface().position() << " hit with detid " << (*iter)->det()->geographicalId().rawId() << " lays on surface " << (*iter)->det()->surface().position(); 00077 } 00078 geomdet = (*iter)->det(); 00079 LogTrace("SiTrackerMultiRecHitUpdator") << "Current reference surface located at " << geomdet->surface().position(); 00080 } 00081 if (&((*iter)->det()->surface())!=&(tsos.surface())){ 00082 TransientTrackingRecHit::RecHitPointer cloned = theHitPropagator->project<GenericProjectedRecHit2D>(*iter, *geomdet, tsos); 00083 LogTrace("SiTrackerMultiRecHitUpdator") << "Projecting a hit from surface " << (*iter)->det()->surface().position() 00084 << " to surface " << tsos.surface().position() << " original global position " 00085 << (*iter)->globalPosition() << " projected position " << cloned->globalPosition(); 00086 if (cloned->isValid()) updatedcomponents.push_back(cloned); 00087 } else { 00088 TransientTrackingRecHit::RecHitPointer cloned = (*iter)->clone(tsos); 00089 if (cloned->isValid()) updatedcomponents.push_back(cloned); 00090 } 00091 } 00092 int ierr; 00093 std::vector<std::pair<const TrackingRecHit*, float> > mymap; 00094 std::vector<std::pair<const TrackingRecHit*, float> > normmap; 00095 00096 float a_sum=0, c_sum=0; 00097 00098 AlgebraicVector tsospos(2); 00099 tsospos[0]=tsos.localPosition().x(); 00100 tsospos[1]=tsos.localPosition().y(); 00101 LogTrace("SiTrackerMultiRecHitUpdator")<< "TSOS position " << tsos.localPosition(); 00102 for(std::vector<TransientTrackingRecHit::RecHitPointer>::iterator ihit = updatedcomponents.begin(); ihit != updatedcomponents.end(); ihit++) { 00103 AlgebraicVector r((*ihit)->parameters() - tsospos); 00104 AlgebraicSymMatrix V((*ihit)->parametersError()); 00105 V *= annealing;//assume that TSOS is smoothed one 00106 //V += me.measuredError(*ihit);// result = b*V + H*C*H.T() 00107 AlgebraicSymMatrix W(V.inverse(ierr)); 00108 00109 if(ierr != 0) { 00110 LogTrace("SiTrackerMultiRecHitUpdator")<<"MultiRecHitUpdator::update: W not valid!"<<std::endl; 00111 LogTrace("SiTrackerMultiRecHitUpdator")<<"V: "<<V<<" AnnealingFactor: "<<annealing<<std::endl; 00112 } 00113 float Chi2 = W.similarity(r);// Chi2 = r.T()*W*r 00114 float a_i = exp(-0.5*Chi2)/(2.*M_PI*sqrt(V.determinant())); 00115 mymap.push_back(std::pair<const TrackingRecHit*, float>((*ihit)->hit(), a_i)); 00116 float c_i = exp(-0.5*theChi2Cut/annealing)/(2.*M_PI*sqrt(V.determinant())); 00117 a_sum += a_i; 00118 c_sum += c_i; 00119 } 00120 float total_sum = a_sum + c_sum; 00121 00122 unsigned int counter = 0; 00123 TransientTrackingRecHit::ConstRecHitContainer finalcomponents; 00124 for(std::vector<TransientTrackingRecHit::RecHitPointer>::iterator ihit = updatedcomponents.begin(); ihit != updatedcomponents.end(); ihit++) { 00125 //uncomment lines below to have like ORCA 00126 float p = ((mymap[counter].second)/total_sum > 1.e-6 ? (mymap[counter].second)/total_sum : 1.e-6); 00127 //float p = ((mymap[counter].second)/total_sum > 0.01 ? (mymap[counter].second)/total_sum : 1.e-6); 00128 normmap.push_back(std::pair<const TrackingRecHit*, float>(mymap[counter].first, p)); 00129 //let's store the weight in the component TransientTrackingRecHit too 00130 (*ihit)->setWeight(p); 00131 (*ihit)->setAnnealingFactor(annealing); 00132 finalcomponents.push_back(*ihit); 00133 LogTrace("SiTrackerMultiRecHitUpdator")<< "Component hit type " << typeid(*mymap[counter].first).name() 00134 << " position " << mymap[counter].first->localPosition() 00135 << " error " << mymap[counter].first->localPositionError() 00136 << " with weight " << p; 00137 counter++; 00138 } 00139 00140 mymap = normmap; 00141 LocalError er = calcParametersError(finalcomponents); 00142 LocalPoint p = calcParameters(finalcomponents, er); 00143 SiTrackerMultiRecHit updated(p, er, normmap.front().first->geographicalId(), normmap); 00144 LogTrace("SiTrackerMultiRecHitUpdator") << "Updated Hit position " << updated.localPosition() << " updated error " << updated.parametersError() << std::endl; 00145 //return new SiTrackerMultiRecHit(normmap); 00146 return TSiTrackerMultiRecHit::build(geomdet, &updated, finalcomponents, annealing); 00147 }
TransientTrackingRecHit::RecHitPointer SiTrackerMultiRecHitUpdator::update | ( | TransientTrackingRecHit::ConstRecHitPointer | original, | |
TrajectoryStateOnSurface | tsos, | |||
double | annealing = 1. | |||
) | const [virtual] |
Definition at line 36 of file SiTrackerMultiRecHitUpdator.cc.
References Exception, TrajectoryStateOnSurface::isValid(), and LogTrace.
Referenced by buildMultiRecHit(), and DAFTrackProducerAlgorithm::updateHits().
00038 { 00039 LogTrace("SiTrackerMultiRecHitUpdator") << "Calling SiTrackerMultiRecHitUpdator::update with AnnealingFactor: " << annealing; 00040 if (original->isValid()) 00041 LogTrace("SiTrackerMultiRecHitUpdator") << "Original Hit position " << original->localPosition() << " original error " 00042 << original->parametersError(); 00043 else LogTrace("SiTrackerMultiRecHitUpdator") << "Invalid hit"; 00044 00045 if(!tsos.isValid()) { 00046 //return original->clone(); 00047 throw cms::Exception("SiTrackerMultiRecHitUpdator") << "!!! MultiRecHitUpdator::update(..): tsos NOT valid!!! "; 00048 } 00049 00050 //check if to clone is the right thing 00051 if (original->transientHits().empty()) return original->clone(tsos); 00052 00053 TransientTrackingRecHit::ConstRecHitContainer tcomponents = original->transientHits(); 00054 return update(tcomponents, tsos, annealing); 00055 }
const std::vector<double> SiTrackerMultiRecHitUpdator::theAnnealingProgram [private] |
Definition at line 55 of file SiTrackerMultiRecHitUpdator.h.
Referenced by annealingProgram(), and getAnnealingProgram().
const TransientTrackingRecHitBuilder* SiTrackerMultiRecHitUpdator::theBuilder [private] |
double SiTrackerMultiRecHitUpdator::theChi2Cut [private] |
const TrackingRecHitPropagator* SiTrackerMultiRecHitUpdator::theHitPropagator [private] |