25 #include "rave/Plane.h"
35 std::vector < rave::Track >
37 std::vector < genfit::MeasuredStateOnPlane* > * GFStates,
38 std::map<int, genfit::trackAndState>& IdGFTrackStateMap,
41 unsigned int ntracks(GFTracks.size());
43 if (GFStates !=
nullptr)
44 if (GFTracks.size() != GFStates->size()) {
45 Exception exc(
"GFTracksToTracks ==> GFStates has not the same size as GFTracks!",__LINE__,__FILE__);
49 std::vector < rave::Track > ravetracks;
54 if (GFTracks[
i] ==
nullptr) {
55 Exception exc(
"GFTracksToTracks ==> genfit::Track is nullptr",__LINE__,__FILE__);
60 if (!GFTracks[
i]->getFitStatus(GFTracks[
i]->getCardinalRep())->isFitConverged())
continue;
62 if (IdGFTrackStateMap.count(startID) > 0){
63 Exception exc(
"GFTracksToTracks ==> IdGFTrackStateMap has already an entry for this id",__LINE__,__FILE__);
66 IdGFTrackStateMap[startID].track_ = GFTracks[
i];
67 if (GFStates ==
nullptr)
70 IdGFTrackStateMap[startID].state_ = (*GFStates)[
i];
72 ravetracks.push_back(
GFTrackToTrack(IdGFTrackStateMap[startID], startID) );
85 if (trackAndState.
track_ ==
nullptr) {
86 Exception exc(
"GFTrackToTrack ==> originaltrack is nullptr",__LINE__,__FILE__);
91 Exception exc(
"GFTrackToTrack ==> Trackfit is not converged",__LINE__,__FILE__);
101 rave::Vector6D ravestate(pos.X(), pos.Y(), pos.Z(),
102 mom.X(), mom.Y(), mom.Z());
105 rave::Covariance6D ravecov(
cov(0,0),
cov(1,0),
cov(2,0),
121 static_cast<void*
>(
const_cast<Track*
>(trackAndState.
track_)), tag);
133 state->
setPosMomCov(TVector3(orig.state().x(), orig.state().y(), orig.state().z()),
134 TVector3(orig.state().px(), orig.state().py(), orig.state().pz()),
142 const std::map<int, genfit::trackAndState>& IdGFTrackStateMap){
144 if (!(raveVertex.isValid())) {
145 Exception exc(
"RaveToGFVertex ==> rave Vertex is not valid!",__LINE__,__FILE__);
149 std::vector < std::pair < float, rave::Track > > raveWeightedTracks(raveVertex.weightedTracks());
150 std::vector < std::pair < float, rave::Track > > raveSmoothedTracks(raveVertex.weightedRefittedTracks());
153 unsigned int nTrks(raveWeightedTracks.size());
156 bool smoothing(
true);
157 if (! (raveVertex.hasRefittedTracks()) ) {
162 if (smoothing && nTrks != raveSmoothedTracks.size()){
163 Exception exc(
"RaveToGFVertex ==> number of smoothed tracks != number of tracks",__LINE__,__FILE__);
168 std::vector < GFRaveTrackParameters* > trackParameters;
169 trackParameters.reserve(nTrks);
172 for (
unsigned int i=0;
i<nTrks; ++
i){
173 id = raveWeightedTracks[
i].second.id();
175 if (IdGFTrackStateMap.count(
id) == 0){
176 Exception exc(
"RaveToGFVertex ==> rave track id is not present in IdGFTrackStateMap",__LINE__,__FILE__);
185 IdGFTrackStateMap.at(
id).state_,
186 raveWeightedTracks[
i].first,
194 IdGFTrackStateMap.at(
id).state_,
195 raveWeightedTracks[
i].first,
200 trackParameters.push_back(trackparams);
206 raveVertex.ndf(), raveVertex.chiSquared(), raveVertex.id());
211 const std::vector<rave::Vertex> & raveVertices,
212 const std::map<int, genfit::trackAndState>& IdGFTrackStateMap){
214 unsigned int nVert(raveVertices.size());
216 GFVertices->reserve(nVert);
218 for (
unsigned int i=0;
i<nVert; ++
i){
219 GFVertices->push_back(
RaveToGFVertex(raveVertices[
i], IdGFTrackStateMap));
233 return TVector3(v.x(), v.y(), v.z());
238 return TVector3(v.x(), v.y(), v.z());
246 cov(0,0) = ravecov.dxx();
247 cov(0,1) = ravecov.dxy();
248 cov(0,2) = ravecov.dxz();
250 cov(1,0) = ravecov.dxy();
251 cov(1,1) = ravecov.dyy();
252 cov(1,2) = ravecov.dyz();
254 cov(2,0) = ravecov.dxz();
255 cov(2,1) = ravecov.dyz();
256 cov(2,2) = ravecov.dzz();
266 vec[0] = ravevec.x();
267 vec[1] = ravevec.y();
268 vec[2] = ravevec.z();
270 vec[3] = ravevec.px();
271 vec[4] = ravevec.py();
272 vec[5] = ravevec.pz();
282 cov(0,0) = ravecov.dxx();
283 cov(0,1) = ravecov.dxy();
284 cov(0,2) = ravecov.dxz();
285 cov(0,3) = ravecov.dxpx();
286 cov(0,4) = ravecov.dxpy();
287 cov(0,5) = ravecov.dxpz();
289 cov(1,0) = ravecov.dxy();
290 cov(1,1) = ravecov.dyy();
291 cov(1,2) = ravecov.dyz();
292 cov(1,3) = ravecov.dypx();
293 cov(1,4) = ravecov.dypy();
294 cov(1,5) = ravecov.dypz();
296 cov(2,0) = ravecov.dxz();
297 cov(2,1) = ravecov.dyz();
298 cov(2,2) = ravecov.dzz();
299 cov(2,3) = ravecov.dzpx();
300 cov(2,4) = ravecov.dzpy();
301 cov(2,5) = ravecov.dzpz();
303 cov(3,0) = ravecov.dxpx();
304 cov(3,1) = ravecov.dypx();
305 cov(3,2) = ravecov.dzpx();
306 cov(3,3) = ravecov.dpxpx();
307 cov(3,4) = ravecov.dpxpy();
308 cov(3,5) = ravecov.dpxpz();
310 cov(4,0) = ravecov.dxpy();
311 cov(4,1) = ravecov.dypy();
312 cov(4,2) = ravecov.dzpy();
313 cov(4,3) = ravecov.dpxpy();
314 cov(4,4) = ravecov.dpypy();
315 cov(4,5) = ravecov.dpypz();
317 cov(5,0) = ravecov.dxpz();
318 cov(5,1) = ravecov.dypz();
319 cov(5,2) = ravecov.dzpz();
320 cov(5,3) = ravecov.dpxpz();
321 cov(5,4) = ravecov.dpypz();
322 cov(5,5) = ravecov.dpzpz();
330 return rave::Point3D(vec.X(), vec.Y(), vec.Z());
336 if (matrix.GetNrows()!=3) {
337 Exception exc(
"TMatrixDSymToCovariance3D ==> TMatrixDSym is not 3x3!",__LINE__,__FILE__);
341 return rave::Covariance3D(matrix(0,0), matrix(0,1), matrix(0,2),
342 matrix(1,1), matrix(1,2), matrix(2,2));