79 std::vector<TrackEnd> &usebeg, std::vector<float> &dca);
87 fPCut =
p.get<
float>(
"PCut",0.1);
88 fRCut =
p.get<
float>(
"RCut", 0.1);
89 fDCut =
p.get<
float>(
"DCut",20.);
102 consumes< std::vector<rec::Track> >(trackTag);
105 produces< std::vector<rec::Vee> >();
106 produces< art::Assns<rec::Track, rec::Vee, rec::TrackEnd> >();
110 std::unique_ptr< std::vector<rec::Vee> >
111 veeCol(
new std::vector<rec::Vee>);
113 auto trkVeeAssns = std::make_unique< art::Assns<rec::Track, rec::Vee, rec::TrackEnd> >();
118 auto const&
tracks = *trackHandle;
123 size_t nTrack = tracks.size();
125 const float m_prot = 0.9382723;
126 const float m_pi = 0.13957018;
132 std::vector<TrackPar> tplist;
133 std::vector<TrackEnd> usebeg;
134 for (
size_t iTrack=0; iTrack<nTrack-1; ++iTrack)
136 Track thisTrack = tracks.at(iTrack);
137 for (
int iEnd=0; iEnd<2; ++iEnd)
141 if (!
goodTrack(thisTrack,iEnd))
continue;
142 TVector3 thisEndinSpace;
146 TVector3 tmpv(thisTrack.
Vertex());
147 thisEndinSpace = tmpv;
148 TVector3 tmpv2(thisTrack.
VtxDir());
155 TVector3 tmpv(thisTrack.
End());
156 thisEndinSpace = tmpv;
157 TVector3 tmpv2(thisTrack.
EndDir());
163 tplist.emplace_back(thisTrack);
165 usebeg.push_back(iTrackEnd);
167 for (
size_t jTrack=iTrack+1; jTrack<nTrack; ++jTrack)
169 Track thatTrack = tracks.at(jTrack);
170 for (
int jEnd = 0; jEnd<2; ++jEnd)
174 if (!
goodTrack(thatTrack,jEnd))
continue;
175 TVector3 thatEndinSpace;
179 TVector3 tmpv(thatTrack.
Vertex());
180 thatEndinSpace = tmpv;
181 TVector3 tmpv2(thatTrack.
VtxDir());
188 TVector3 tmpv(thatTrack.
End());
189 thatEndinSpace = tmpv;
190 TVector3 tmpv2(thatTrack.
EndDir());
199 if ( (thisEndinSpace-thatEndinSpace).Mag() >
fDCut )
continue;
201 if (
fPrintLevel>1) std::cout <<
"veefinder: opening angle: " << thisP.Angle(thatP) <<
std::endl;
202 float openang = thisP.Angle(thatP);
208 if (thisCharge == 0 || thatCharge == 0)
212 std::cout <<
"veefinder: One of the track charges is zero: " << thisCharge <<
" " << thatCharge <<
std::endl;
215 if (thisCharge == thatCharge)
continue;
220 tplist.emplace_back(thatTrack);
222 usebeg.push_back(jTrackEnd);
224 std::vector<float> dcas;
225 std::vector<float> vpos;
226 std::vector<std::vector<float>> covmat;
229 int iret =
fitVertex(tplist,vpos,chisquared,covmat,time,usebeg,dcas);
231 if (iret != 0)
continue;
233 if (dcas[0] >
fRCut || dcas[1] >
fRCut)
continue;
236 TVector3 sumP = thisP + thatP;
237 TVector3 vposv(vpos.data());
243 size_t otherTrackCount = 0;
244 for (
size_t kTrack=0; kTrack<nTrack; ++kTrack)
246 if (kTrack == iTrack || kTrack == jTrack)
continue;
247 Track otherTrack = tracks.at(kTrack);
248 for (
int kEnd = 0; kEnd<2; ++kEnd)
260 std::vector<TLorentzVector> fourmomentumvec;
261 float energy_kshort_hyp =
262 TMath::Sqrt(thisP.Mag2() + m_pi*
m_pi) +
263 TMath::Sqrt(thatP.Mag2() + m_pi*
m_pi);
269 float energy_lambda1_hyp =
270 TMath::Sqrt(thisP.Mag2() + m_prot*m_prot) +
271 TMath::Sqrt(thatP.Mag2() + m_pi*
m_pi);
272 float energy_lambda2_hyp =
273 TMath::Sqrt(thisP.Mag2() + m_pi*
m_pi) +
274 TMath::Sqrt(thatP.Mag2() + m_prot*m_prot);
275 if (thisCharge == -1)
277 float tmp = energy_lambda1_hyp;
278 energy_lambda1_hyp = energy_lambda2_hyp;
279 energy_lambda2_hyp =
tmp;
281 fourmomentumvec.emplace_back(sumP,energy_kshort_hyp);
282 fourmomentumvec.emplace_back(sumP,energy_lambda1_hyp);
283 fourmomentumvec.emplace_back(sumP,energy_lambda2_hyp);
286 for (
size_t icm=0; icm<3; ++icm)
288 for (
size_t jcm=0;jcm<3; ++jcm)
290 covmatvec[icounter++] = covmat.at(icm).at(jcm);
294 veeCol->emplace_back(vpos.data(),covmatvec,chisquared,time,fourmomentumvec.data());
295 auto const veeptr = veePtrMaker(veeCol->size()-1);
296 auto const itrackptr = trackPtrMaker( iTrack );
297 auto const jtrackptr = trackPtrMaker( jTrack );
298 trkVeeAssns->addSingle(itrackptr,veeptr,iTrackEnd);
299 trkVeeAssns->addSingle(jtrackptr,veeptr,jTrackEnd);
316 std::vector<float> &xyz,
320 std::vector<TrackEnd> &usebeg,
321 std::vector<float> &dca
329 if (tracks.size() < 2)
return(1);
334 for (
size_t i=0; i<tracks.size(); ++i)
336 time += tracks.at(i).getTime();
338 if (tracks.size() > 0)
340 time /= tracks.size();
346 std::vector<TVectorF>
dir;
347 std::vector<TVectorF>
p;
349 for (
size_t itrack = 0; itrack < tracks.size(); ++itrack)
351 TVector3 trackbeg = tracks.at(itrack).getXYZBeg();
352 TVector3 trackend = tracks.at(itrack).getXYZEnd();
357 float tmppos[3] = {(
float) trackbeg.X(), (
float) trackbeg.Y(), (
float) trackbeg.Z()};
358 p.emplace_back(3,tmppos);
359 phi = tracks.at(itrack).getTrackParametersBegin()[3];
360 si = TMath::Tan(tracks.at(itrack).getTrackParametersBegin()[4]);
364 float tmppos[3] = {(
float) trackend.X(), (
float) trackend.Y(), (
float) trackend.Z()};
365 p.emplace_back(3,tmppos);
366 phi = tracks.at(itrack).getTrackParametersEnd()[3];
367 si = TMath::Tan(tracks.at(itrack).getTrackParametersEnd()[4]);
371 dtmp[1] = TMath::Sin(phi);
372 dtmp[2] = TMath::Cos(phi);
373 float norminv = 1.0/TMath::Sqrt(dtmp.Norm2Sqr());
390 for (
size_t itrack=0; itrack < tracks.size(); ++itrack)
392 for (
size_t i=0; i<3; ++i)
394 for (
size_t j=0; j<3; ++j)
396 VVT[i][j] = dir.at(itrack)[i]*dir.at(itrack)[j];
401 vsum += IMVVT*p.at(itrack);
405 if (det == 0)
return(1);
406 TVectorF xyzsol = A*vsum;
407 xyz.at(0) = xyzsol[0];
408 xyz.at(1) = xyzsol[1];
409 xyz.at(2) = xyzsol[2];
412 for (
size_t itrack=0; itrack < tracks.size(); ++itrack)
415 TVector3 dir3(dir.at(itrack)[0],dir.at(itrack)[1],dir.at(itrack)[2]);
416 TVectorF diff = xyzsol - p.at(itrack);
417 TVector3 diff3(diff[0],diff[1],diff[2]);
418 float dcatrack = (diff3.Cross(dir3)).Mag();
419 dca.push_back(dcatrack);
420 chisquared += dcatrack*dcatrack;
429 for (
size_t i=0;i<3;++i)
431 std::vector<float> cmr;
432 for (
size_t j=0; j<3; ++j)
436 covmat.push_back(cmr);
479 tep.SetXYZ(trk.
End()[0],trk.
End()[1],trk.
End()[2]);
481 TVector3 dv = tep - veepos;
482 float dve = dv.Mag();
float const & Momentum_beg() const
float fOpenAngMaxCut
opening angle cut in 3D
bool goodOtherTrack(Track &trk, TrackEnd usebeg, TVector3 &veepos, TVector3 &veep)
float fOpenAngMinCut
minimum opening angle cut in 3D
veefinder1 & operator=(veefinder1 const &)=delete
float fRCut
DCA cut from track to vee vertex.
size_t fNTPCClusPerTrack
min number of TPC clusters for a track to be identified as part of a vee
float fNearTrackAngCut
pointing requirement of the vee at the nearby track endpoint
int fPrintLevel
module print level
EDProducer(fhicl::ParameterSet const &pset)
std::string fTrackLabel
track module label
float fDCut
distance cut from endpoints of tracks
const float * VtxDir() const
veefinder1(fhicl::ParameterSet const &p)
int fitVertex(std::vector< TrackPar > &tracks, std::vector< float > &xyz, float &chisquared, std::vector< std::vector< float > > &covmat, double &time, std::vector< TrackEnd > &usebeg, std::vector< float > &dca)
const float * Vertex() const
#define DEFINE_ART_MODULE(klass)
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
bool goodTrack(Track &trk, TrackEnd usebeg)
float fPCut
min momentum for a track to be identified as part of a vee
bool fRequireOppositeCharge
whether or not to require opposite-sign tracks.
const float * End() const
float fNearTrackDMaxCut
maximum distance of nearby track to the vee vertex
General GArSoft Utilities.
TrackEnd const TrackEndBeg
size_t fNearTrackNTPCClus
number of nearby tracks' TPC cluster count requirement
float const & Momentum_end() const
size_t const & NHits() const
void produce(art::Event &e) override
float fNearTrackDMinCut
minimum distance of nearby track to the vee vertex
QTextStream & endl(QTextStream &s)
size_t fRequireNearTrack
number of nearby tracks to require (primary vertex)
const float * EndDir() const