21 legacyContainer(false),
25 truthTrackVec(nullptr),
26 truthDimuonVec(nullptr),
40 int ret = GetNodes(topNode);
43 ret = MakeNodes(topNode);
53 std::map<int, SRecTrack*> posTracks;
54 std::map<int, SRecTrack*> negTracks;
55 int nTracks = truthTrackVec->
size();
56 int nRecTracks = legacyContainer ? recEvent->
getNTracks() : recTrackVec->
size();
57 for(
int i = 0; i < nTracks; ++i)
61 if(recTrackIdx < 0 || recTrackIdx >= nRecTracks)
continue;
64 double z_vtx = trk->
get_pos_vtx().Z() + (vtxSmearing>0. ? rndm.Gaus(0., vtxSmearing) : 0.);
66 if(swimTrackToVertex(recTrack, z_vtx) < 0.)
continue;
81 int nTrueDimuons = truthDimuonVec->
size();
82 for(
int i = 0; i < nTrueDimuons; ++i)
87 if(posTracks.find(pid) == posTracks.end() || negTracks.find(mid) == negTracks.end())
continue;
90 double z_vtx = trueDimuon->
get_pos().Z() + (vtxSmearing>0. ? rndm.Gaus(0., vtxSmearing) : 0.);
91 if(!buildRecDimuon(z_vtx, posTracks[pid], negTracks[mid], &recDimuon))
continue;
136 truthTrackVec = findNode::getClass<SQTrackVector>(topNode,
"SQTruthTrackVector");
139 std::cerr <<
Name() <<
": failed finding truth track info, abort." << std::endl;
143 truthDimuonVec = findNode::getClass<SQDimuonVector>(topNode,
"SQTruthDimuonVector");
146 std::cout <<
Name() <<
": failed finding truth dimuon info, rec dimuon will be for reference only. " << std::endl;
151 recEvent = findNode::getClass<SRecEvent>(topNode,
"SRecEvent");
155 recTrackVec = findNode::getClass<SQTrackVector>(topNode,
"SQRecTrackVector");
158 if((!recEvent) && (!recTrackVec))
160 std::cerr <<
Name() <<
": failed finding rec track info, abort." << std::endl;
175 std::cerr <<
Name() <<
": cannot locate DST node, abort." << std::endl;
185 double SQTruthVertexing::swimTrackToVertex(
SRecTrack* track,
double z, TVector3* pos, TVector3* mom)
190 double chi2 = gftrk.swimToVertex(z, &p, &m);
191 if(chi2 < 0.)
return chi2;
201 pos->SetXYZ(p.X(), p.Y(), p.Z());
202 mom->SetXYZ(m.X(), m.Y(), m.Z());
212 if(fabs(p_pos.Z() - z_vtx) > 1.)
214 p_chi2 = swimTrackToVertex(posTrack, z_vtx, &p_pos, &p_mom);
215 if(p_chi2 < 0.)
return false;
225 if(fabs(m_pos.Z() - z_vtx) > 1.)
227 m_chi2 = swimTrackToVertex(negTrack, z_vtx, &p_pos, &p_mom);
228 if(m_chi2 < 0.)
return false;
239 dimuon->
vtx.SetXYZ(0., 0., z_vtx);
virtual const std::string Name() const
Returns the name of this module.
PHBoolean addNode(PHNode *)
virtual const SQDimuon * at(const size_t id) const =0
virtual size_t size() const =0
virtual void push_back(const SQDimuon *dim)=0
An SQ interface class to hold one true or reconstructed dimuon.
virtual void set_rec_dimuon_id(const int a)=0
virtual int get_track_id_neg() const =0
Return the track ID of the negative track.
virtual int get_track_id_pos() const =0
Return the track ID of the positive track.
virtual TVector3 get_pos() const =0
Return the dimuon position at vertex.
virtual const SQTrack * at(const size_t id) const =0
virtual size_t size() const =0
An SQ interface class to hold one true or reconstructed track.
virtual int get_track_id() const =0
Return the track ID, which is unique per event(?).
virtual TVector3 get_pos_vtx() const =0
Return the track position at vertex.
virtual int get_rec_track_id() const =0
Return the track ID of associated reconstructed track. Valid only if this object holds truth track in...
int Init(PHCompositeNode *topNode)
int End(PHCompositeNode *topNode)
Called at the end of all processing.
int process_event(PHCompositeNode *topNode)
SQTruthVertexing(const std::string &name="SQTruthVertexing")
int InitRun(PHCompositeNode *topNode)
TVector3 vtx
3-vector vertex position
void calcVariables(int choice=0)
Calculate the kinematic vairables, 0 = vertex, 1 = target, 2 = dump.
Int_t trackID_pos
Index of muon track used in host SRecEvent.
Double_t chisq_target
Chisq of three test position.
Double_t chisq_kf
Vertex fit chisqs.
TLorentzVector p_pos
4-momentum of the muon tracks after vertex fit
TVector3 proj_target_pos
Track projections at different location.
void insertDimuon(SRecDimuon dimuon)
Insert dimuon.
Int_t getNTracks()
Get tracks.
SRecTrack & getTrack(Int_t i)
Int_t getNDimuons()
Get dimuons.
Int_t getCharge() const
Gets.
Double_t getChisqTarget()
void setVertexPos(TVector3 pos)
Double_t getChisqUpstream()
void setVertexMom(TVector3 mom)
TVector3 getDumpPos()
Get mom/pos at a given location.
Double_t getChisqVertex()
void setChisqVertex(Double_t chisq)