16 #ifndef SimDataFormats_Associations_TTClusterAssociationMap_h 17 #define SimDataFormats_Associations_TTClusterAssociationMap_h 38 using MapClusToVecTP = std::map<TTClusterRefT<T>, std::vector<TrackingParticlePtr>>;
40 using MapTPToVecClus = std::map<TrackingParticlePtr, std::vector<TTClusterRefT<T>>>;
102 template <
typename T>
104 template <
typename T>
106 template <
typename T>
111 template <
typename T>
118 template <
typename T>
122 template <
typename T>
125 if (trackingParticleToClusterVectorMap_.find(aTrackingParticle) != trackingParticleToClusterVectorMap_.end()) {
126 return trackingParticleToClusterVectorMap_.find(aTrackingParticle)->second;
128 return nullVecClusterRef_;
132 template <
typename T>
135 if (clusterToTrackingParticleVectorMap_.find(aCluster) != clusterToTrackingParticleVectorMap_.end()) {
136 return clusterToTrackingParticleVectorMap_.find(aCluster)->second;
138 return nullVecTrackingParticlePtr_;
142 template <
typename T>
144 if (this->isGenuine(aCluster)) {
145 return this->findTrackingParticlePtrs(aCluster).at(0);
147 return nullTrackingParticlePtr_;
175 template <
typename T>
178 const std::vector<TrackingParticlePtr>& theseTrackingParticles = this->findTrackingParticlePtrs(aCluster);
181 if (theseTrackingParticles.empty())
185 unsigned int goodDifferentTPs = 0;
186 std::vector<const TrackingParticle*> tpAddressVector;
188 std::vector<float> tp_mom;
193 for (
const auto&
tp : theseTrackingParticles) {
201 tp_mom.push_back(curTP.
get()->
p4().pt());
202 tp_tot += curTP.
get()->
p4().pt();
209 for (
unsigned int itp = 0; itp < theseTrackingParticles.size(); itp++) {
214 if (tp_mom.at(itp) > 0.01 * tp_tot) {
217 tpAddressVector.push_back(curTP.
get());
222 std::sort(tpAddressVector.begin(), tpAddressVector.end());
223 tpAddressVector.erase(
std::unique(tpAddressVector.begin(), tpAddressVector.end()), tpAddressVector.end());
224 goodDifferentTPs = tpAddressVector.size();
226 return (goodDifferentTPs == 1);
229 template <
typename T>
232 const std::vector<TrackingParticlePtr>& theseTrackingParticles = this->findTrackingParticlePtrs(aCluster);
235 if (theseTrackingParticles.empty())
239 unsigned int goodDifferentTPs = 0;
240 std::vector<const TrackingParticle*> tpAddressVector;
243 for (
unsigned int itp = 0; itp < theseTrackingParticles.size(); itp++) {
251 tpAddressVector.push_back(curTP.
get());
256 std::sort(tpAddressVector.begin(), tpAddressVector.end());
257 tpAddressVector.erase(
std::unique(tpAddressVector.begin(), tpAddressVector.end()), tpAddressVector.end());
258 goodDifferentTPs = tpAddressVector.size();
261 return (goodDifferentTPs == 0);
264 template <
typename T>
267 const std::vector<TrackingParticlePtr>& theseTrackingParticles = this->findTrackingParticlePtrs(aCluster);
270 if (theseTrackingParticles.empty())
273 bool genuineClu = this->isGenuine(aCluster);
274 bool unknownClu = this->isUnknown(aCluster);
276 if (genuineClu || unknownClu)
282 unsigned int goodDifferentTPs = 0;
283 std::vector<const TrackingParticle*> tpAddressVector;
286 for (
unsigned int itp = 0; itp < theseTrackingParticles.size(); itp++) {
294 tpAddressVector.push_back(curTP.
get());
299 std::sort(tpAddressVector.begin(), tpAddressVector.end());
300 tpAddressVector.erase(
std::unique(tpAddressVector.begin(), tpAddressVector.end()), tpAddressVector.end());
301 goodDifferentTPs = tpAddressVector.size();
303 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