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 goodDifferentTPs = 0;
187 std::vector<const TrackingParticle*> tpAddressVector;
189 std::vector<float> tp_mom;
194 for (
const auto&
tp : theseTrackingParticles) {
202 tp_mom.push_back(curTP.
get()->
p4().pt());
203 tp_tot += curTP.
get()->
p4().pt();
210 for (
unsigned int itp = 0; itp < theseTrackingParticles.size(); itp++) {
215 if (tp_mom.at(itp) > 0.01 * tp_tot) {
218 tpAddressVector.push_back(curTP.
get());
223 std::sort(tpAddressVector.begin(), tpAddressVector.end());
224 tpAddressVector.erase(
std::unique(tpAddressVector.begin(), tpAddressVector.end()), tpAddressVector.end());
225 goodDifferentTPs = tpAddressVector.size();
227 return (goodDifferentTPs == 1);
230 template <
typename T>
233 const std::vector<TrackingParticlePtr>& theseTrackingParticles = this->findTrackingParticlePtrs(aCluster);
236 if (theseTrackingParticles.empty())
240 unsigned int goodDifferentTPs = 0;
241 std::vector<const TrackingParticle*> tpAddressVector;
244 for (
unsigned int itp = 0; itp < theseTrackingParticles.size(); itp++) {
252 tpAddressVector.push_back(curTP.
get());
257 std::sort(tpAddressVector.begin(), tpAddressVector.end());
258 tpAddressVector.erase(
std::unique(tpAddressVector.begin(), tpAddressVector.end()), tpAddressVector.end());
259 goodDifferentTPs = tpAddressVector.size();
262 return (goodDifferentTPs == 0);
265 template <
typename T>
268 const std::vector<TrackingParticlePtr>& theseTrackingParticles = this->findTrackingParticlePtrs(aCluster);
271 if (theseTrackingParticles.empty())
274 bool genuineClu = this->isGenuine(aCluster);
275 bool unknownClu = this->isUnknown(aCluster);
277 if (genuineClu || unknownClu)
283 unsigned int goodDifferentTPs = 0;
284 std::vector<const TrackingParticle*> tpAddressVector;
287 for (
unsigned int itp = 0; itp < theseTrackingParticles.size(); itp++) {
295 tpAddressVector.push_back(curTP.
get());
300 std::sort(tpAddressVector.begin(), tpAddressVector.end());
301 tpAddressVector.erase(
std::unique(tpAddressVector.begin(), tpAddressVector.end()), tpAddressVector.end());
302 goodDifferentTPs = tpAddressVector.size();
304 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