109 {
110
111
113
114
115 auto track1Ptr = recoTracks[0]->getRelated<Track>("Tracks");
116 auto track2Ptr = recoTracks[1]->getRelated<Track>("Tracks");
117 if (!track1Ptr or !track2Ptr) return false;
118
119
120 auto tfr1Ptr = track1Ptr->getTrackFitResultWithClosestMass(
Const::pion);
121 auto tfr2Ptr = track2Ptr->getTrackFitResultWithClosestMass(
Const::pion);
122 if (!tfr1Ptr or !tfr2Ptr) return false;
123
124
125 if (tfr1Ptr->getPValue() <= 0 or tfr2Ptr->getPValue() <= 0) return false;
126
127
128 if (tfr1Ptr->getChargeSign() * tfr2Ptr->getChargeSign() >= 0) return false;
129
130
132 B2DEBUG(20, "B Field = " << bField << " T");
134 analysis::RaveVertexFitter rvf;
135 try {
136 rvf.addTrack(tfr1Ptr);
137 rvf.addTrack(tfr2Ptr);
138 } catch (...) {
139 B2DEBUG(20, "Adding tracks to RaveVertexFitter failed.");
140 return false;
141 }
142 if (rvf.fit() == 0) return false;
143
144 auto vertex = rvf.getPos();
145
147
148
152 B2DEBUG(20,
"Vertex = (" <<
m_vx
155 << ")");
156
157
158 DBObjPtr<BeamSpot> beamSpotDB;
159 auto ip = ROOT::Math::XYZVector(beamSpotDB->getIPPosition());
160 if (tfr1Ptr->getChargeSign() > 0) {
161 m_track_p.setValues(*recoTracks[0], ip, recoTracksName, pxdInterceptsName, pxdTrackClustersName);
162 m_track_m.setValues(*recoTracks[1], ip, recoTracksName, pxdInterceptsName, pxdTrackClustersName);
163 } else {
164 m_track_p.setValues(*recoTracks[1], ip, recoTracksName, pxdInterceptsName, pxdTrackClustersName);
165 m_track_m.setValues(*recoTracks[0], ip, recoTracksName, pxdInterceptsName, pxdTrackClustersName);
166 }
167 return true;
168 }
static ROOT::Math::XYZVector getFieldInTesla(const ROOT::Math::XYZVector &pos)
return the magnetic field at a given position in Tesla.
static const ChargedStable pion
charged pion particle
float m_vy
Position of the vertex in y.
float m_vz
Position of the vertex in z.
T m_track_m
Track with the negative charge.
float m_vx
Position of the vertex in x.
T m_track_p
Track with the positive charge.
bool isValid() const
Check wether the array was registered.
int getEntries() const
Get the number of objects in the array.
static void initialize(int verbosity=1, double MagneticField=1.5)
Set everything up so everything needed for vertex fitting is there.
static RaveSetup * getInstance()
get the pointer to the instance to get/set any of options stored in RaveSetup
void reset()
frees memory allocated by initialize().