#include <RecoVertex/GaussianSumVertexFit/interface/GsfVertexUpdator.h>
Public Types | |
typedef VertexTrack < 5 >::RefCountedLinearizedTrackState | RefCountedLinearizedTrackState |
typedef CachingVertex < 5 >::RefCountedVertexTrack | RefCountedVertexTrack |
Public Member Functions | |
CachingVertex< 5 > | add (const CachingVertex< 5 > &oldVertex, const RefCountedVertexTrack track) const |
Method to add a track to an existing CachingVertex An invalid vertex is returned in case of problems during the update. | |
VertexUpdator< 5 > * | clone () const |
Clone method. | |
GsfVertexUpdator (bool limit=false, const GsfVertexMerger *merger=0) | |
CachingVertex< 5 > | remove (const CachingVertex< 5 > &oldVertex, const RefCountedVertexTrack track) const |
Method removing already used VertexTrack from existing CachingVertex This method is not yet implemented. | |
Private Types | |
typedef std::vector < RefCountedLinearizedTrackState > | LTC |
typedef std::pair< VertexState, double > | VertexChi2Pair |
typedef std::pair< VertexState, WeightChi2Pair > | VertexComponent |
typedef std::vector< VertexState > | VSC |
typedef std::pair< double, double > | WeightChi2Pair |
Private Member Functions | |
VertexChi2Pair | assembleVertexComponents (const vector< VertexComponent > &newVertexComponents) const |
VertexComponent | createNewComponent (const VertexState &oldVertex, const RefCountedLinearizedTrackState linTrack, float weight, int sign) const |
Where one component of the previous vertex gets updated with one component of the track. | |
Private Attributes | |
KalmanVertexUpdator< 5 > | kalmanVertexUpdator |
bool | limitComponents |
DeepCopyPointerByClone < GsfVertexMerger > | theMerger |
GsfVertexWeightCalculator | theWeightCalculator |
(c.f. Th.Speer & R. Fruewirth, Comp.Phys.Comm 174, 935 (2006) )
Definition at line 14 of file GsfVertexUpdator.h.
typedef std::vector<RefCountedLinearizedTrackState> GsfVertexUpdator::LTC [private] |
Definition at line 51 of file GsfVertexUpdator.h.
typedef VertexTrack<5>::RefCountedLinearizedTrackState GsfVertexUpdator::RefCountedLinearizedTrackState |
Definition at line 19 of file GsfVertexUpdator.h.
typedef std::pair<VertexState, double> GsfVertexUpdator::VertexChi2Pair [private] |
Definition at line 54 of file GsfVertexUpdator.h.
typedef std::pair<VertexState, WeightChi2Pair> GsfVertexUpdator::VertexComponent [private] |
Definition at line 53 of file GsfVertexUpdator.h.
typedef std::vector<VertexState> GsfVertexUpdator::VSC [private] |
Definition at line 50 of file GsfVertexUpdator.h.
typedef std::pair<double, double> GsfVertexUpdator::WeightChi2Pair [private] |
Definition at line 52 of file GsfVertexUpdator.h.
GsfVertexUpdator::GsfVertexUpdator | ( | bool | limit = false , |
|
const GsfVertexMerger * | merger = 0 | |||
) |
Definition at line 6 of file GsfVertexUpdator.cc.
References GsfVertexMerger::clone(), limitComponents, and theMerger.
Referenced by clone().
00006 : 00007 limitComponents (limit) 00008 { 00009 if (limitComponents) theMerger = merger->clone(); 00010 }
CachingVertex< 5 > GsfVertexUpdator::add | ( | const CachingVertex< 5 > & | oldVertex, | |
const RefCountedVertexTrack | track | |||
) | const |
Method to add a track to an existing CachingVertex An invalid vertex is returned in case of problems during the update.
Definition at line 13 of file GsfVertexUpdator.cc.
References KalmanVertexUpdator< N >::add(), assembleVertexComponents(), VertexState::components(), createNewComponent(), CachingVertex< N >::hasPrior(), kalmanVertexUpdator, limitComponents, CachingVertex< N >::priorError(), CachingVertex< N >::priorPosition(), theMerger, CachingVertex< N >::totalChiSquared(), CachingVertex< N >::tracks(), CachingVertex< N >::vertexState(), VertexState::weight(), and VertexState::weightTimesPosition().
Referenced by GsfVertexTrackCompatibilityEstimator::estimateNFittedTrack(), and GsfVertexSmoother::smooth().
00015 { 00016 00017 VSC prevVtxComponents = oldVertex.vertexState().components(); 00018 00019 // cout << "GsfVertexUpdator::Add new Track with " 00020 // << track->linearizedTrack()->components().size() << " components to vertex of " 00021 // << prevVtxComponents.size() << " components.\n"; 00022 00023 if (prevVtxComponents.empty()) { 00024 throw VertexException 00025 ("GsfVertexUpdator::(Previous) Vertex to update has no components"); 00026 } 00027 00028 LTC ltComponents = track->linearizedTrack()->components(); 00029 if (ltComponents.empty()) { 00030 throw VertexException 00031 ("GsfVertexUpdator::Track to add to vertex has no components"); 00032 } 00033 00034 if ((ltComponents.size()==1) && (prevVtxComponents.size()==1)) 00035 return kalmanVertexUpdator.add(oldVertex, track); 00036 00037 float trackWeight = track->weight(); 00038 00039 vector<VertexComponent> newVertexComponents; 00040 newVertexComponents.reserve(prevVtxComponents.size()*ltComponents.size()); 00041 00042 // for (LTC::iterator trackCompIter = ltComponents.begin(); 00043 // trackCompIter != ltComponents.end(); trackCompIter++ ) { 00044 // cout <<(**trackCompIter).state().globalPosition()<<endl; 00045 // } 00046 00047 for (VSC::iterator vertexCompIter = prevVtxComponents.begin(); 00048 vertexCompIter != prevVtxComponents.end(); vertexCompIter++ ) { 00049 for (LTC::iterator trackCompIter = ltComponents.begin(); 00050 trackCompIter != ltComponents.end(); trackCompIter++ ) { 00051 newVertexComponents.push_back( 00052 createNewComponent(*vertexCompIter, *trackCompIter, trackWeight, +1)); 00053 if (!newVertexComponents.back().first.isValid()) return CachingVertex<5>(); // return invalid vertex 00054 } 00055 } 00056 // cout << "updator components: "<<newVertexComponents.size()<<endl; 00057 00058 // Update tracks vector 00059 00060 vector<RefCountedVertexTrack> newVertexTracks = oldVertex.tracks(); 00061 newVertexTracks.push_back(track); 00062 // cout << "a \n "; 00063 00064 // Assemble VertexStates and compute Chi**2 00065 00066 VertexChi2Pair vertexChi2Pair = assembleVertexComponents(newVertexComponents); 00067 // cout << "b \n "; 00068 VertexState newVertexState = vertexChi2Pair.first; 00069 // cout << "c \n "; 00070 double chi2 = oldVertex.totalChiSquared() + vertexChi2Pair.second; 00071 00072 // Merge: 00073 if (limitComponents) newVertexState = theMerger->merge(newVertexState); 00074 00075 if (oldVertex.hasPrior()) { 00076 return CachingVertex<5>(oldVertex.priorPosition(), oldVertex.priorError(), 00077 newVertexState.weightTimesPosition(), 00078 newVertexState.weight(), newVertexTracks, chi2); 00079 } else { 00080 return CachingVertex<5>(newVertexState, newVertexTracks, chi2); 00081 } 00082 00083 00084 }
GsfVertexUpdator::VertexChi2Pair GsfVertexUpdator::assembleVertexComponents | ( | const vector< VertexComponent > & | newVertexComponents | ) | const [private] |
Definition at line 133 of file GsfVertexUpdator.cc.
References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), iter, and weight.
Referenced by add().
00135 { 00136 VSC vertexComponents; 00137 vertexComponents.reserve(newVertexComponents.size()); 00138 00139 //renormalize weights 00140 // cout << "assemble "<<newVertexComponents.size()<<endl; 00141 double totalWeight = 0.; 00142 double totalChi2 = 0.; 00143 00144 for (vector<VertexComponent>::const_iterator iter = newVertexComponents.begin(); 00145 iter != newVertexComponents.end(); iter ++) { 00146 totalWeight += iter->second.first; 00147 cout << iter->first.position()<<iter->second.first<<" "<<iter->second.second<<endl; 00148 } 00149 // cout << "totalWeight "<<totalWeight<<endl; 00150 if (totalWeight<DBL_MIN) { 00151 edm::LogWarning("GsfVertexUpdator") << "Updated Vertex has total weight of 0. " 00152 <<"The track is probably very far away."; 00153 return VertexChi2Pair( VertexState(), 0.); 00154 } 00155 00156 for (vector<VertexComponent>::const_iterator iter = newVertexComponents.begin(); 00157 iter != newVertexComponents.end(); iter ++) { 00158 double weight = iter->second.first/totalWeight; 00159 if (iter->second.first>DBL_MIN) { 00160 vertexComponents.push_back(VertexState(iter->first.weightTimesPosition(), 00161 iter->first.weight(), weight)); 00162 totalChi2 += iter->second.second * weight; 00163 } 00164 } 00165 // cout << "totalChi2 "<<totalChi2<<endl; 00166 // cout << "vertexComponents "<<vertexComponents.size()<<endl; 00167 00168 if (vertexComponents.empty()){ 00169 edm::LogWarning("GsfVertexUpdator") << "No Vertex State left after reweighting."; 00170 return VertexChi2Pair( VertexState(), 0.); 00171 } 00172 00173 return VertexChi2Pair( VertexState( new BasicMultiVertexState( vertexComponents)), 00174 totalChi2); 00175 }
VertexUpdator<5>* GsfVertexUpdator::clone | ( | void | ) | const [inline, virtual] |
Clone method.
Implements VertexUpdator< 5 >.
Definition at line 42 of file GsfVertexUpdator.h.
References GsfVertexUpdator().
00043 { 00044 return new GsfVertexUpdator(* this); 00045 }
GsfVertexUpdator::VertexComponent GsfVertexUpdator::createNewComponent | ( | const VertexState & | oldVertex, | |
const RefCountedLinearizedTrackState | linTrack, | |||
float | weight, | |||
int | sign | |||
) | const [private] |
Where one component of the previous vertex gets updated with one component of the track.
Definition at line 103 of file GsfVertexUpdator.cc.
References funct::abs(), GsfVertexWeightCalculator::calculate(), KalmanVertexUpdator< N >::chi2Increment(), VertexState::isValid(), kalmanVertexUpdator, KalmanVertexUpdator< N >::positionUpdate(), and theWeightCalculator.
Referenced by add().
00105 { 00106 00107 if(abs(sign) != 1) 00108 throw VertexException ("GsfVertexUpdator::sign not equal to 1."); 00109 00110 if(sign == -1) 00111 throw VertexException("GsfVertexUpdator::sign of -1 not yet implemented."); 00112 00113 00114 // Weight of the component in the mixture (non-normalized) 00115 double weightInMixture = theWeightCalculator.calculate(oldVertex, linTrack, 1.E9); 00116 if (weightInMixture < 0.) return VertexComponent(VertexState(), WeightChi2Pair(0.,0.)); 00117 00118 // position estimate of the component 00119 VertexState newVertex = kalmanVertexUpdator.positionUpdate(oldVertex, 00120 linTrack, weight, sign); 00121 if (!newVertex.isValid()) return VertexComponent(newVertex, WeightChi2Pair(0.,0.)); 00122 00123 //Chi**2 contribution of the component 00124 pair <bool, double> chi2P = kalmanVertexUpdator.chi2Increment(oldVertex, newVertex, 00125 linTrack, weight); 00126 if (!chi2P.first) return VertexComponent(VertexState(), WeightChi2Pair(0.,0.)); 00127 // cout << "Update: "<<oldVertex.position()<<" "<<newVertex.position()<<" "<<chi2 00128 // <<" "<<linTrack->weightInMixture()<<" "<<weightInMixture<<endl; 00129 00130 return VertexComponent(newVertex, WeightChi2Pair(weightInMixture, chi2P.second)); 00131 }
CachingVertex< 5 > GsfVertexUpdator::remove | ( | const CachingVertex< 5 > & | oldVertex, | |
const RefCountedVertexTrack | track | |||
) | const |
Method removing already used VertexTrack from existing CachingVertex This method is not yet implemented.
Definition at line 89 of file GsfVertexUpdator.cc.
00091 { 00092 throw VertexException("GsfVertexUpdator::Remove Methode not yet done"); 00093 // return CachingVertex<5>(); 00094 }
KalmanVertexUpdator<5> GsfVertexUpdator::kalmanVertexUpdator [private] |
bool GsfVertexUpdator::limitComponents [private] |