145 mf::LogInfo(
"PrimaryVertexFinder") <<
"------------------------------------------------------------------------------";
162 std::unique_ptr< std::vector<recob::Vertex> > vcol(
new std::vector<recob::Vertex>);
168 std::vector<recob::Track>
const& trkIn = *trackListHandle;
170 mf::LogInfo(
"PrimaryVertexFinder") <<
"number of tracks in this event = " << trkIn.size();
173 std::vector<recob::SpacePoint> startpoints_vec;
175 std::vector <TVector3> startvec;
178 std::vector <TVector3> endvec;
181 std::vector <TVector3> dircosvec;
184 std::vector< std::pair<art::Ptr<recob::Track>,
double> > trackpair;
189 for(
unsigned int i = 0; i<trkIn.size(); ++i){
191 std::tie(start, end) = trkIn[i].Extent();
192 startXYZ.SetXYZ(start.X(),start.Y(),start.Z());
193 endXYZ.SetXYZ(end.X(),end.Y(),end.Z());
196 double length = (endXYZ-startXYZ).Mag();
201 for(
size_t i = 0; i<trackpair.size(); ++i){
202 mf::LogInfo(
"PrimaryVertexFinder") <<
"track id is = " << (trackpair[i].first)->ID()
203 <<
" track length = " << (trackpair[i].second);
206 std::sort(trackpair.rbegin(), trackpair.rend(),
sort_pred2);
208 mf::LogInfo(
"PrimaryVertexFinder") <<
"AFTER SORTING ";
209 for(
size_t i = 0; i < trackpair.size(); ++i){
210 mf::LogInfo(
"PrimaryVertexFinder") <<
"track id is = " << (trackpair[i].first)->ID()
211 <<
" track length = " << (trackpair[i].second);
214 if(trackpair.size()>0)
217 if(trackpair.size()>1)
220 if(trackpair.size()>2)
223 if(trackpair.size()>3)
226 if(trackpair.size()>4)
229 for(
size_t j = 0; j < trackpair.size(); ++j) {
234 std::vector<recob::SpacePoint const*>
const& spacepoints
235 = TrackSpacePoints.at(track.
key());
237 startXYZ = trackpair[j].first->Vertex<TVector3>();
238 endXYZ = trackpair[j].first->End<TVector3>();
239 dircosXYZ = trackpair[j].first->VertexDirection<TVector3>();
241 startvec.push_back(startXYZ);
242 endvec.push_back(endXYZ);
243 dircosvec.push_back(dircosXYZ);
245 mf::LogInfo(
"PrimaryVertexFinder") <<
"PrimaryVertexFinder got "<< spacepoints.size()
246 <<
" 3D spacepoint(s) from Track3Dreco.cxx";
249 startpoints_vec.emplace_back(
250 spacepoints[0]->XYZ(), spacepoints[0]->ErrXYZ(),
251 spacepoints[0]->Chisq(), startpoints_vec.size()
256 for(
size_t i = 0; i < startvec.size(); ++i){
257 mf::LogInfo(
"PrimaryVertexFinder") <<
"Tvector3 start point SORTED = ";
260 for(
size_t i = 0; i < dircosvec.size(); ++i){
261 mf::LogInfo(
"PrimaryVertexFinder") <<
"Tvector3 dir cos SORTED = ";
262 dircosvec[i].Print();
265 std::vector<std::vector<int> > vertex_collection_int;
266 std::vector <std::vector <TVector3> > vertexcand_vec;
268 for (
unsigned int i=0; i<trackpair.size(); ++i){
269 for (
unsigned int j=i+1; j<trackpair.size(); ++j){
270 mf::LogInfo(
"PrimaryVertexFinder") <<
"distance between " << i <<
" and " << j
273 double GAMMA =
gammavalue(startvec[i], startvec[j], dircosvec[i], dircosvec[j]);
274 double ALPHA =
alphavalue(GAMMA, startvec[i], startvec[j], dircosvec[i], dircosvec[j]);
275 double MINDIST =
MinDist(ALPHA, GAMMA, startvec[i], startvec[j], dircosvec[i], dircosvec[j]);
276 mf::LogInfo(
"PrimaryVertexFinder") <<
"alpha = " << ALPHA <<
" gamma = " 277 << GAMMA <<
" MINIMUM DISTANCE = " << MINDIST;
282 mf::LogInfo(
"PrimaryVertexFinder") <<
"POINTS ON THE TRACKS ARE:: ";
291 std::vector<int> newvertex_int;
292 std::vector <TVector3> vertexcand;
293 newvertex_int.push_back(i);
294 newvertex_int.push_back(j);
295 vertex_collection_int.push_back(newvertex_int);
297 vertexcand.push_back(TRACK1POINT);
298 vertexcand.push_back(TRACK2POINT);
299 vertexcand_vec.push_back(vertexcand);
305 vertex_collection_int[index].push_back(i);
306 vertexcand_vec[index].push_back(TRACK1POINT);
309 vertex_collection_int[index].push_back(j);
310 vertexcand_vec[index].push_back(TRACK2POINT);
319 for(
size_t i = 0; i < trackpair.size(); ++i){
322 std::vector<int> temp;
323 std::vector <TVector3> temp1;
325 temp1.push_back(startvec[i]);
326 vertex_collection_int.push_back(temp);
327 vertexcand_vec.push_back(temp1);
333 std::vector<size_t> vTrackIndices, vShowerIndices;
343 for(
size_t i = 0; i < vertex_collection_int.size(); ++i){
349 mf::LogInfo(
"PrimaryVertexFinder") <<
"vector elements at index " << i <<
" are " << *itr
350 <<
"\ntrack original ID = " << (trackpair[*itr].first)->ID();
352 vTrackIndices.push_back(trackpair[*itr].first.key());
354 mf::LogInfo(
"PrimaryVertexFinder") <<
"------------";
362 elemsize = vertexcand_vec[i].size();
365 double avgx = x/elemsize;
366 double avgy = y/elemsize;
367 double avgz = z/elemsize;
369 Double_t vtxcoord[3];
375 vcol->push_back(the3Dvertex);
377 if(!vTrackIndices.empty()){
380 vcol->
size() - 1, vTrackIndices.begin(), vTrackIndices.end());
381 for(
size_t tIndex: vTrackIndices) {
382 std::vector<art::Ptr<recob::Hit>>
const&
hits = TrackHits.at(tIndex);
385 vTrackIndices.clear();
388 if(!vShowerIndices.empty()){
391 vcol->
size() - 1, vShowerIndices.begin(), vShowerIndices.end());
392 for(
size_t sIndex: vShowerIndices){
393 std::vector<art::Ptr<recob::Hit>>
const& hits = ShowerHits.at(sIndex);
396 vShowerIndices.clear();
402 LOG_VERBATIM(
"Summary") << std::setfill(
'-') << std::setw(175) <<
"-" << std::setfill(
' ');
403 LOG_VERBATIM(
"Summary") <<
"PrimaryVertexFinder Summary:";
404 for(
size_t i = 0; i < vcol->size(); ++i)
LOG_VERBATIM(
"Summary") << vcol->at(i) ;
406 evt.
put(std::move(vcol));
407 evt.
put(std::move(vtassn));
408 evt.
put(std::move(vhassn));
409 evt.
put(std::move(vsassn));
TVector3 PointOnExtendedTrack(double alphagamma, TVector3 startpoint, TVector3 dircos)
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
Definition of vertex object for LArSoft.
bool IsInNewVertex(int a, std::vector< int > newvertex)
int IndexInVertexCollection(int a, int b, std::vector< std::vector< int > > vertex_collection)
ProductID put(std::unique_ptr< PROD > &&product)
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
bool CreateAssn(PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t indx=UINT_MAX)
Creates a single one-to-one association.
std::string fTrackModuleLabel
double MinDist(double alpha, double gamma, TVector3 startpoint1, TVector3 startpoint2, TVector3 dircos1, TVector3 dircos2)
double StartPointSeperation(recob::SpacePoint sp1, recob::SpacePoint sp2)
bool sort_pred2(const std::pair< art::Ptr< recob::Track >, double > &left, const std::pair< art::Ptr< recob::Track >, double > &right)
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
bool IsInVertexCollection(int a, std::vector< std::vector< int > > vertex_collection)
tracking::Point_t Point_t
EventNumber_t event() const
double gammavalue(TVector3 startpoint1, TVector3 startpoint2, TVector3 dircos1, TVector3 dircos2)
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
double alphavalue(double gamma, TVector3 startpoint1, TVector3 startpoint2, TVector3 dircos1, TVector3 dircos2)
#define LOG_VERBATIM(category)