Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:18:11

0001 /**
0002  * @file trackbase/TrackVertexCrossingAssoc_v1.cc
0003  * @author Tony Frawley
0004  * @date April 2024
0005  * @brief TrackVertexCrossingAssoc implementation
0006  */
0007 
0008 #include "TrackVertexCrossingAssoc_v1.h"
0009 #include "TrkrDefs.h"
0010 
0011 #include <ostream>  // for operator<<, endl, basic_ostream, ostream, basic_o...
0012 
0013 namespace
0014 {
0015   TrackVertexCrossingAssoc_v1::Map dummy_map;
0016 }
0017 
0018 //_________________________________________________________________________
0019 void TrackVertexCrossingAssoc_v1::Reset()
0020 {
0021   // delete all entries
0022   Map empty_trackmap;
0023   empty_trackmap.swap(_track_assoc_map);
0024   empty_trackmap.clear();
0025   _track_assoc_map.clear();
0026 
0027   Map empty_vertexmap;
0028   empty_vertexmap.swap(_vertex_assoc_map);
0029   empty_vertexmap.clear();
0030   _vertex_assoc_map.clear();
0031 }
0032 
0033 //_________________________________________________________________________
0034 void TrackVertexCrossingAssoc_v1::identify(std::ostream& os) const
0035 {
0036   std::multimap<TrkrDefs::cluskey, TrkrDefs::hitkey>::const_iterator iter;
0037   os << "-----TrackVertexCrossingAssoc_v1-----" << std::endl;
0038   os << "Number of vertex associations: " << sizeVertices()  << "Number of track associations: " << sizeTracks() << std::endl;
0039   for (const auto& cross : _crossing_set)
0040     { 
0041       auto vtxit = _vertex_assoc_map.equal_range(cross);
0042       os << "Crossing " << cross << std::endl;
0043       os << "   vertex ID's:  ";
0044       for (auto itr = vtxit.first; itr != vtxit.second; ++itr)
0045     {
0046       os << itr->second << "  ";
0047     } 
0048       os << std::endl;
0049 
0050       auto trit = _track_assoc_map.equal_range(cross);
0051       os << "   track ID's:  ";
0052       for (auto itr = trit.first; itr != trit.second; ++itr)
0053     {
0054       os << itr->second << "  ";
0055     } 
0056       os << std::endl;
0057 
0058     }
0059 
0060   return;
0061 }
0062 
0063 //_________________________________________________________________________
0064 void TrackVertexCrossingAssoc_v1::addTrackAssoc(short int crossing, unsigned int trackid)
0065 {
0066   // insert association
0067   _track_assoc_map.insert(std::make_pair(crossing, trackid));
0068   _crossing_set.insert(crossing);
0069 }
0070 
0071 //_________________________________________________________________________
0072 void TrackVertexCrossingAssoc_v1::addVertexAssoc(short int crossing, unsigned int vertexid)
0073 {
0074   // insert association
0075   _vertex_assoc_map.insert(std::make_pair(crossing, vertexid));
0076   _crossing_set.insert(crossing);
0077 }
0078 
0079 //_________________________________________________________________________
0080 std::set<short int> TrackVertexCrossingAssoc_v1::getCrossings() const
0081 {
0082   return _crossing_set;
0083 }
0084 
0085 //_________________________________________________________________________
0086 TrackVertexCrossingAssoc_v1::ConstRange TrackVertexCrossingAssoc_v1::getTracks(short int crossing) const
0087 {
0088   const auto range = _track_assoc_map.equal_range(crossing);
0089   return range;
0090 }
0091 
0092 //_________________________________________________________________________
0093 TrackVertexCrossingAssoc_v1::ConstRange TrackVertexCrossingAssoc_v1::getVertices(short int crossing) const
0094 {
0095   const auto range = _vertex_assoc_map.equal_range(crossing);
0096   return range;
0097 }
0098 
0099 //_________________________________________________________________________
0100 unsigned int TrackVertexCrossingAssoc_v1::sizeTracks() const
0101 {
0102   unsigned int size = 0;
0103   size = _track_assoc_map.size();
0104 
0105   return size;
0106 }
0107 
0108 //_________________________________________________________________________
0109 unsigned int TrackVertexCrossingAssoc_v1::sizeVertices() const
0110 {
0111   unsigned int size = 0;
0112   size = _vertex_assoc_map.size();
0113 
0114   return size;
0115 }
0116