16 #ifndef L1_TRACK_TRIGGER_CLUSTER_ASSOCIATION_FORMAT_H 17 #define L1_TRACK_TRIGGER_CLUSTER_ASSOCIATION_FORMAT_H 39 using MapClusToVecTP = std::map<TTClusterRefT<T>, std::vector<TrackingParticlePtr>>;
41 using MapTPToVecClus = std::map<TrackingParticlePtr, std::vector<TTClusterRefT<T>>>;
103 template <
typename T>
105 template <
typename T>
107 template <
typename T>
112 template <
typename T>
119 template <
typename T>
123 template <
typename T>
126 if (trackingParticleToClusterVectorMap_.find(aTrackingParticle) != trackingParticleToClusterVectorMap_.end()) {
127 return trackingParticleToClusterVectorMap_.find(aTrackingParticle)->second;
129 return nullVecClusterRef_;
133 template <
typename T>
136 if (clusterToTrackingParticleVectorMap_.find(aCluster) != clusterToTrackingParticleVectorMap_.end()) {
137 return clusterToTrackingParticleVectorMap_.find(aCluster)->second;
139 return nullVecTrackingParticlePtr_;
143 template <
typename T>
145 if (this->isGenuine(aCluster)) {
146 return this->findTrackingParticlePtrs(aCluster).at(0);
148 return nullTrackingParticlePtr_;
176 template <
typename T>
179 const std::vector<TrackingParticlePtr>& theseTrackingParticles = this->findTrackingParticlePtrs(aCluster);
182 if (theseTrackingParticles.empty())
186 unsigned int nullTPs = 0;
187 unsigned int goodDifferentTPs = 0;
188 std::vector<const TrackingParticle*> tpAddressVector;
190 std::vector<float> tp_mom;
195 for (
const auto&
tp : theseTrackingParticles) {
204 tp_mom.push_back(curTP.
get()->
p4().pt());
205 tp_tot += curTP.
get()->
p4().pt();
212 for (
unsigned int itp = 0; itp < theseTrackingParticles.size(); itp++) {
217 if (tp_mom.at(itp) <= 0.01 * tp_tot) {
222 tpAddressVector.push_back(curTP.
get());
227 std::sort(tpAddressVector.begin(), tpAddressVector.end());
228 tpAddressVector.erase(
std::unique(tpAddressVector.begin(), tpAddressVector.end()), tpAddressVector.end());
229 goodDifferentTPs = tpAddressVector.size();
231 return (goodDifferentTPs == 1);
234 template <
typename T>
237 const std::vector<TrackingParticlePtr>& theseTrackingParticles = this->findTrackingParticlePtrs(aCluster);
240 if (theseTrackingParticles.empty())
244 unsigned int goodDifferentTPs = 0;
245 std::vector<const TrackingParticle*> tpAddressVector;
248 for (
unsigned int itp = 0; itp < theseTrackingParticles.size(); itp++) {
256 tpAddressVector.push_back(curTP.
get());
261 std::sort(tpAddressVector.begin(), tpAddressVector.end());
262 tpAddressVector.erase(
std::unique(tpAddressVector.begin(), tpAddressVector.end()), tpAddressVector.end());
263 goodDifferentTPs = tpAddressVector.size();
266 return (goodDifferentTPs == 0);
269 template <
typename T>
272 const std::vector<TrackingParticlePtr>& theseTrackingParticles = this->findTrackingParticlePtrs(aCluster);
275 if (theseTrackingParticles.empty())
278 bool genuineClu = this->isGenuine(aCluster);
279 bool unknownClu = this->isUnknown(aCluster);
281 if (genuineClu || unknownClu)
287 unsigned int nullTPs = 0;
288 unsigned int goodDifferentTPs = 0;
289 std::vector<const TrackingParticle*> tpAddressVector;
292 for (
unsigned int itp = 0; itp < theseTrackingParticles.size(); itp++) {
302 tpAddressVector.push_back(curTP.
get());
307 std::sort(tpAddressVector.begin(), tpAddressVector.end());
308 tpAddressVector.erase(
std::unique(tpAddressVector.begin(), tpAddressVector.end()), tpAddressVector.end());
309 goodDifferentTPs = tpAddressVector.size();
314 return (goodDifferentTPs > 1);
void setTTClusterToTrackingParticlesMap(const MapClusToVecTP< T > &aMap)
~TTClusterAssociationMap()
Destructor.
MapClusToVecTP< T > clusterToTrackingParticleVectorMap_
Data members.
const MapTPToVecClus< T > & getTrackingParticleToTTClustersMap() const
std::map< TTClusterRefT< T >, std::vector< TrackingParticlePtr > > MapClusToVecTP
NOTE: this is needed even if it seems not.
static const std::vector< TTClusterRefT< T > > nullVecClusterRef_
bool isUnknown(TTClusterRefT< T > aCluster) const
Cluster "unknown": i.e. not associated with any TP.
bool isCombinatoric(TTClusterRefT< T > aCluster) const
Cluster is not "genuine" or "unknown".
const TrackingParticlePtr & findTrackingParticlePtr(TTClusterRefT< T > aCluster) const
Get main TP associated to a cluster. (Non-NULL if isGenuine() below is true).
Stores association of Truth Particles (TP) to L1 Track-Trigger Clusters.
static const TrackingParticlePtr nullTrackingParticlePtr_
Close class.
bool isNull() const
Checks for null.
TTClusterAssociationMap()
Constructors.
def unique(seq, keepstr=True)
const MapClusToVecTP< T > & getTTClusterToTrackingParticlesMap() const
Get/set cluster <-> truth association maps.
void setTrackingParticleToTTClustersMap(const MapTPToVecClus< T > &aMap)
static const std::vector< TrackingParticlePtr > nullVecTrackingParticlePtr_
const std::vector< TTClusterRefT< T > > & findTTClusterRefs(TrackingParticlePtr aTrackingParticle) const
Operations.
T const * get() const
Returns C++ pointer to the item.
MapTPToVecClus< T > trackingParticleToClusterVectorMap_
const LorentzVector & p4() const
Four-momentum Lorentz vector. Note this is taken from the first SimTrack only.
std::map< TrackingParticlePtr, std::vector< TTClusterRefT< T > >> MapTPToVecClus
const std::vector< TrackingParticlePtr > & findTrackingParticlePtrs(TTClusterRefT< T > aCluster) const
Get all TPs associated to a cluster.
bool isGenuine(TTClusterRefT< T > aCluster) const