-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43913 from martinamalberti/mm_MTDAssociationMaps
[MTD simulation, validation]: implementation of MTD clusters association maps
- Loading branch information
Showing
36 changed files
with
2,215 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
SimDataFormats/Associations/interface/MtdRecoClusterToSimLayerClusterAssociationMap.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#ifndef SimDataFormats_Associations_MtdRecoClusterToSimLayerClusterAssociationMap_h | ||
#define SimDataFormats_Associations_MtdRecoClusterToSimLayerClusterAssociationMap_h | ||
|
||
#include "DataFormats/Provenance/interface/ProductID.h" | ||
#include "DataFormats/Common/interface/HandleBase.h" | ||
#include "DataFormats/FTLRecHit/interface/FTLClusterCollections.h" | ||
#include "SimDataFormats/CaloAnalysis/interface/MtdSimLayerClusterFwd.h" | ||
|
||
#include <vector> | ||
#include <utility> | ||
#include <algorithm> | ||
|
||
/** | ||
* Maps FTLCluserRef to SimLayerClusterRef | ||
* | ||
*/ | ||
class MtdRecoClusterToSimLayerClusterAssociationMap { | ||
public: | ||
using key_type = FTLClusterRef; | ||
using mapped_type = MtdSimLayerClusterRef; | ||
using value_type = std::pair<key_type, std::vector<mapped_type>>; | ||
using map_type = std::vector<value_type>; | ||
using const_iterator = typename map_type::const_iterator; | ||
using range = std::pair<const_iterator, const_iterator>; | ||
|
||
/// Constructor | ||
MtdRecoClusterToSimLayerClusterAssociationMap(); | ||
/// Destructor | ||
~MtdRecoClusterToSimLayerClusterAssociationMap(); | ||
|
||
void emplace_back(const FTLClusterRef& recoClus, std::vector<MtdSimLayerClusterRef>& simClusVect) { | ||
map_.emplace_back(recoClus, simClusVect); | ||
} | ||
|
||
void post_insert() { std::sort(map_.begin(), map_.end(), compare); } | ||
|
||
bool empty() const { return map_.empty(); } | ||
size_t size() const { return map_.size(); } | ||
|
||
const_iterator begin() const { return map_.begin(); } | ||
const_iterator cbegin() const { return map_.cbegin(); } | ||
const_iterator end() const { return map_.end(); } | ||
const_iterator cend() const { return map_.cend(); } | ||
|
||
range equal_range(const FTLClusterRef& key) const { | ||
return std::equal_range(map_.begin(), map_.end(), value_type(key, std::vector<MtdSimLayerClusterRef>()), compare); | ||
} | ||
|
||
const map_type& map() const { return map_; } | ||
|
||
private: | ||
static bool compare(const value_type& i, const value_type& j) { return (i.first < j.first); } | ||
|
||
map_type map_; | ||
}; | ||
|
||
#endif |
49 changes: 49 additions & 0 deletions
49
SimDataFormats/Associations/interface/MtdRecoClusterToSimLayerClusterAssociator.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#ifndef SimDataFormats_Associations_MtdRecoClusterToSimLayerClusterAssociator_h | ||
#define SimDataFormats_Associations_MtdRecoClusterToSimLayerClusterAssociator_h | ||
// Original Author: Martina Malberti | ||
|
||
// system include files | ||
#include <memory> | ||
|
||
// user include files | ||
#include "SimDataFormats/Associations/interface/MtdRecoClusterToSimLayerClusterAssociatorBaseImpl.h" | ||
|
||
// forward declarations | ||
|
||
namespace reco { | ||
|
||
class MtdRecoClusterToSimLayerClusterAssociator { | ||
public: | ||
MtdRecoClusterToSimLayerClusterAssociator(std::unique_ptr<reco::MtdRecoClusterToSimLayerClusterAssociatorBaseImpl>); | ||
MtdRecoClusterToSimLayerClusterAssociator() = default; | ||
MtdRecoClusterToSimLayerClusterAssociator(MtdRecoClusterToSimLayerClusterAssociator &&) = default; | ||
MtdRecoClusterToSimLayerClusterAssociator &operator=(MtdRecoClusterToSimLayerClusterAssociator &&) = default; | ||
MtdRecoClusterToSimLayerClusterAssociator(const MtdRecoClusterToSimLayerClusterAssociator &) = | ||
delete; // stop default | ||
|
||
~MtdRecoClusterToSimLayerClusterAssociator() = default; | ||
const MtdRecoClusterToSimLayerClusterAssociator &operator=(const MtdRecoClusterToSimLayerClusterAssociator &) = | ||
delete; // stop default | ||
|
||
// ---------- const member functions --------------------- | ||
/// Associate RecoCluster to MtdSimLayerCluster | ||
reco::RecoToSimCollectionMtd associateRecoToSim(const edm::Handle<FTLClusterCollection> &btlRecoClusH, | ||
const edm::Handle<FTLClusterCollection> &etlRecoClusH, | ||
const edm::Handle<MtdSimLayerClusterCollection> &simClusH) const { | ||
return m_impl->associateRecoToSim(btlRecoClusH, etlRecoClusH, simClusH); | ||
}; | ||
|
||
/// Associate MtdSimLayerCluster to RecoCluster | ||
reco::SimToRecoCollectionMtd associateSimToReco(const edm::Handle<FTLClusterCollection> &btlRecoClusH, | ||
const edm::Handle<FTLClusterCollection> &etlRecoClusH, | ||
const edm::Handle<MtdSimLayerClusterCollection> &simClusH) const { | ||
return m_impl->associateSimToReco(btlRecoClusH, etlRecoClusH, simClusH); | ||
}; | ||
|
||
private: | ||
// ---------- member data -------------------------------- | ||
std::unique_ptr<MtdRecoClusterToSimLayerClusterAssociatorBaseImpl> m_impl; | ||
}; | ||
} // namespace reco | ||
|
||
#endif |
37 changes: 37 additions & 0 deletions
37
SimDataFormats/Associations/interface/MtdRecoClusterToSimLayerClusterAssociatorBaseImpl.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#ifndef SimDataFormats_Associations_MtdRecoClusterToSimLayerClusterAssociatorBaseImpl_h | ||
#define SimDataFormats_Associations_MtdRecoClusterToSimLayerClusterAssociatorBaseImpl_h | ||
|
||
#include "DataFormats/Common/interface/Handle.h" | ||
#include "DataFormats/FTLRecHit/interface/FTLClusterCollections.h" | ||
#include "SimDataFormats/CaloAnalysis/interface/MtdSimLayerCluster.h" | ||
#include "SimDataFormats/CaloAnalysis/interface/MtdSimLayerClusterFwd.h" | ||
#include "SimDataFormats/Associations/interface/MtdRecoClusterToSimLayerClusterAssociationMap.h" | ||
#include "SimDataFormats/Associations/interface/MtdSimLayerClusterToRecoClusterAssociationMap.h" | ||
|
||
namespace reco { | ||
|
||
using RecoToSimCollectionMtd = MtdRecoClusterToSimLayerClusterAssociationMap; | ||
using SimToRecoCollectionMtd = MtdSimLayerClusterToRecoClusterAssociationMap; | ||
|
||
class MtdRecoClusterToSimLayerClusterAssociatorBaseImpl { | ||
public: | ||
/// Constructor | ||
MtdRecoClusterToSimLayerClusterAssociatorBaseImpl(); | ||
/// Destructor | ||
virtual ~MtdRecoClusterToSimLayerClusterAssociatorBaseImpl(); | ||
|
||
/// Associate a MtdRecoCluster to MtdSimLayerClusters | ||
virtual reco::RecoToSimCollectionMtd associateRecoToSim( | ||
const edm::Handle<FTLClusterCollection> &btlRecoClusH, | ||
const edm::Handle<FTLClusterCollection> &etlRecoClusH, | ||
const edm::Handle<MtdSimLayerClusterCollection> &simClusH) const; | ||
|
||
/// Associate a MtdSimLayerClusters to MtdRecoClusters | ||
virtual reco::SimToRecoCollectionMtd associateSimToReco( | ||
const edm::Handle<FTLClusterCollection> &btlRecoClusH, | ||
const edm::Handle<FTLClusterCollection> &etlRecoClusH, | ||
const edm::Handle<MtdSimLayerClusterCollection> &simClusH) const; | ||
}; | ||
} // namespace reco | ||
|
||
#endif |
70 changes: 70 additions & 0 deletions
70
SimDataFormats/Associations/interface/MtdSimLayerClusterToRecoClusterAssociationMap.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#ifndef SimDataFormats_Associations_MtdSimLayerClusterToRecoClusterAssociationMap_h | ||
#define SimDataFormats_Associations_MtdSimLayerClusterToRecoClusterAssociationMap_h | ||
|
||
#include "DataFormats/Provenance/interface/ProductID.h" | ||
#include "DataFormats/Common/interface/HandleBase.h" | ||
#include "DataFormats/FTLRecHit/interface/FTLClusterCollections.h" | ||
#include "SimDataFormats/CaloAnalysis/interface/MtdSimLayerClusterFwd.h" | ||
|
||
#include <vector> | ||
#include <utility> | ||
#include <algorithm> | ||
|
||
/** | ||
* Maps MtdSimLayerCluserRef to FTLClusterRef | ||
* | ||
*/ | ||
class MtdSimLayerClusterToRecoClusterAssociationMap { | ||
public: | ||
using key_type = MtdSimLayerClusterRef; | ||
using mapped_type = FTLClusterRef; | ||
using value_type = std::pair<key_type, std::vector<mapped_type>>; | ||
using map_type = std::vector<value_type>; | ||
using const_iterator = typename map_type::const_iterator; | ||
using range = std::pair<const_iterator, const_iterator>; | ||
|
||
/// Constructor | ||
MtdSimLayerClusterToRecoClusterAssociationMap(); | ||
/// Destructor | ||
~MtdSimLayerClusterToRecoClusterAssociationMap(); | ||
|
||
void emplace_back(const MtdSimLayerClusterRef& simClus, std::vector<FTLClusterRef>& recoClusVect) { | ||
map_.emplace_back(simClus, recoClusVect); | ||
} | ||
|
||
void post_insert() { std::sort(map_.begin(), map_.end(), compare); } | ||
|
||
bool empty() const { return map_.empty(); } | ||
size_t size() const { return map_.size(); } | ||
|
||
const_iterator begin() const { return map_.begin(); } | ||
const_iterator cbegin() const { return map_.cbegin(); } | ||
const_iterator end() const { return map_.end(); } | ||
const_iterator cend() const { return map_.cend(); } | ||
|
||
range equal_range(const MtdSimLayerClusterRef& key) const { | ||
return std::equal_range(map_.begin(), map_.end(), value_type(key, std::vector<FTLClusterRef>()), compare); | ||
} | ||
|
||
const map_type& map() const { return map_; } | ||
|
||
private: | ||
static bool compare(const value_type& i, const value_type& j) { | ||
const auto& i_hAndE = (i.first)->hits_and_energies(); | ||
const auto& j_hAndE = (j.first)->hits_and_energies(); | ||
|
||
auto imin = std::min_element(i_hAndE.begin(), | ||
i_hAndE.end(), | ||
[](std::pair<uint64_t, float> a, std::pair<uint64_t, float> b) { return a < b; }); | ||
|
||
auto jmin = std::min_element(j_hAndE.begin(), | ||
j_hAndE.end(), | ||
[](std::pair<uint64_t, float> a, std::pair<uint64_t, float> b) { return a < b; }); | ||
|
||
return (*imin < *jmin); | ||
} | ||
|
||
map_type map_; | ||
}; | ||
|
||
#endif |
46 changes: 46 additions & 0 deletions
46
SimDataFormats/Associations/interface/MtdSimLayerClusterToTPAssociator.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#ifndef SimDataFormats_Associations_MtdSimLayerClusterToTPAssociator_h | ||
#define SimDataFormats_Associations_MtdSimLayerClusterToTPAssociator_h | ||
// Author: M. Malberti | ||
|
||
// system include files | ||
#include <memory> | ||
|
||
// user include files | ||
|
||
#include "SimDataFormats/Associations/interface/MtdSimLayerClusterToTPAssociatorBaseImpl.h" | ||
|
||
// forward declarations | ||
|
||
namespace reco { | ||
class MtdSimLayerClusterToTPAssociator { | ||
public: | ||
MtdSimLayerClusterToTPAssociator(std::unique_ptr<reco::MtdSimLayerClusterToTPAssociatorBaseImpl>); | ||
MtdSimLayerClusterToTPAssociator() = default; | ||
MtdSimLayerClusterToTPAssociator(MtdSimLayerClusterToTPAssociator &&) = default; | ||
MtdSimLayerClusterToTPAssociator &operator=(MtdSimLayerClusterToTPAssociator &&) = default; | ||
MtdSimLayerClusterToTPAssociator(const MtdSimLayerClusterToTPAssociator &) = delete; // stop default | ||
const MtdSimLayerClusterToTPAssociator &operator=(const MtdSimLayerClusterToTPAssociator &) = | ||
delete; // stop default | ||
|
||
~MtdSimLayerClusterToTPAssociator() = default; | ||
|
||
// ---------- const member functions --------------------- | ||
/// Associate MtdSimLayerCluster to TrackingParticle | ||
reco::SimToTPCollectionMtd associateSimToTP(const edm::Handle<MtdSimLayerClusterCollection> &simClusH, | ||
const edm::Handle<TrackingParticleCollection> &trackingParticleH) const { | ||
return m_impl->associateSimToTP(simClusH, trackingParticleH); | ||
}; | ||
|
||
/// Associate TrackingParticle to MtdSimLayerCluster | ||
reco::TPToSimCollectionMtd associateTPToSim(const edm::Handle<MtdSimLayerClusterCollection> &simClusH, | ||
const edm::Handle<TrackingParticleCollection> &trackingParticleH) const { | ||
return m_impl->associateTPToSim(simClusH, trackingParticleH); | ||
}; | ||
|
||
private: | ||
// ---------- member data -------------------------------- | ||
std::unique_ptr<MtdSimLayerClusterToTPAssociatorBaseImpl> m_impl; | ||
}; | ||
} // namespace reco | ||
|
||
#endif |
48 changes: 48 additions & 0 deletions
48
SimDataFormats/Associations/interface/MtdSimLayerClusterToTPAssociatorBaseImpl.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#ifndef SimDataFormats_Associations_MtdSimLayerClusterToTPAssociatorBaseImpl_h | ||
#define SimDataFormats_Associations_MtdSimLayerClusterToTPAssociatorBaseImpl_h | ||
|
||
/** \class MtdSimLayerClusterToTPAssociatorBaseImpl | ||
* | ||
* Base class for MtdSimLayerClusterToTPAssociator. Methods take as input | ||
* the handles of MtdSimLayerCluster and TrackingParticle collections and return an | ||
* AssociationMap (oneToMany) | ||
* | ||
* \author M. Malberti | ||
*/ | ||
|
||
#include "DataFormats/Common/interface/Handle.h" | ||
#include "SimDataFormats/CaloAnalysis/interface/MtdSimLayerCluster.h" | ||
#include "SimDataFormats/CaloAnalysis/interface/MtdSimLayerClusterFwd.h" | ||
#include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h" | ||
#include "SimDataFormats/TrackingAnalysis/interface/TrackingParticleFwd.h" | ||
#include "DataFormats/Common/interface/OneToManyWithQualityGeneric.h" | ||
#include "DataFormats/Common/interface/OneToMany.h" | ||
#include "DataFormats/Common/interface/AssociationMap.h" | ||
|
||
namespace reco { | ||
|
||
typedef edm::AssociationMap<edm::OneToMany<MtdSimLayerClusterCollection, TrackingParticleCollection> > | ||
SimToTPCollectionMtd; | ||
typedef edm::AssociationMap<edm::OneToMany<TrackingParticleCollection, MtdSimLayerClusterCollection> > | ||
TPToSimCollectionMtd; | ||
|
||
class MtdSimLayerClusterToTPAssociatorBaseImpl { | ||
public: | ||
/// Constructor | ||
MtdSimLayerClusterToTPAssociatorBaseImpl(); | ||
/// Destructor | ||
virtual ~MtdSimLayerClusterToTPAssociatorBaseImpl(); | ||
|
||
/// Associate a MtdSimLayerCluster to TrackingParticle | ||
virtual SimToTPCollectionMtd associateSimToTP( | ||
const edm::Handle<MtdSimLayerClusterCollection> &simClusH, | ||
const edm::Handle<TrackingParticleCollection> &trackingParticleH) const; | ||
|
||
/// Associate a TrackingParticle to MtdSimLayerCluster | ||
virtual TPToSimCollectionMtd associateTPToSim( | ||
const edm::Handle<MtdSimLayerClusterCollection> &simClusH, | ||
const edm::Handle<TrackingParticleCollection> &trackingParticleH) const; | ||
}; | ||
} // namespace reco | ||
|
||
#endif |
5 changes: 5 additions & 0 deletions
5
SimDataFormats/Associations/src/MtdRecoClusterToSimLayerClusterAssociationMap.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include "SimDataFormats/Associations/interface/MtdRecoClusterToSimLayerClusterAssociationMap.h" | ||
|
||
MtdRecoClusterToSimLayerClusterAssociationMap::MtdRecoClusterToSimLayerClusterAssociationMap() {} | ||
|
||
MtdRecoClusterToSimLayerClusterAssociationMap::~MtdRecoClusterToSimLayerClusterAssociationMap() {} |
5 changes: 5 additions & 0 deletions
5
SimDataFormats/Associations/src/MtdRecoClusterToSimLayerClusterAssociator.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include "SimDataFormats/Associations/interface/MtdRecoClusterToSimLayerClusterAssociator.h" | ||
|
||
reco::MtdRecoClusterToSimLayerClusterAssociator::MtdRecoClusterToSimLayerClusterAssociator( | ||
std::unique_ptr<reco::MtdRecoClusterToSimLayerClusterAssociatorBaseImpl> ptr) | ||
: m_impl(std::move(ptr)) {} |
21 changes: 21 additions & 0 deletions
21
SimDataFormats/Associations/src/MtdRecoClusterToSimLayerClusterAssociatorBaseImpl.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include "SimDataFormats/Associations/interface/MtdRecoClusterToSimLayerClusterAssociatorBaseImpl.h" | ||
|
||
namespace reco { | ||
MtdRecoClusterToSimLayerClusterAssociatorBaseImpl::MtdRecoClusterToSimLayerClusterAssociatorBaseImpl(){}; | ||
MtdRecoClusterToSimLayerClusterAssociatorBaseImpl::~MtdRecoClusterToSimLayerClusterAssociatorBaseImpl(){}; | ||
|
||
reco::RecoToSimCollectionMtd MtdRecoClusterToSimLayerClusterAssociatorBaseImpl::associateRecoToSim( | ||
const edm::Handle<FTLClusterCollection> &btlRecoClusH, | ||
const edm::Handle<FTLClusterCollection> &etlRecoClusH, | ||
const edm::Handle<MtdSimLayerClusterCollection> &simClusH) const { | ||
return reco::RecoToSimCollectionMtd(); | ||
} | ||
|
||
reco::SimToRecoCollectionMtd MtdRecoClusterToSimLayerClusterAssociatorBaseImpl::associateSimToReco( | ||
const edm::Handle<FTLClusterCollection> &btlRecoClusH, | ||
const edm::Handle<FTLClusterCollection> &etlRecoClusH, | ||
const edm::Handle<MtdSimLayerClusterCollection> &simClusH) const { | ||
return reco::SimToRecoCollectionMtd(); | ||
} | ||
|
||
} // namespace reco |
5 changes: 5 additions & 0 deletions
5
SimDataFormats/Associations/src/MtdSimLayerClusterToRecoClusterAssociationMap.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include "SimDataFormats/Associations/interface/MtdSimLayerClusterToRecoClusterAssociationMap.h" | ||
|
||
MtdSimLayerClusterToRecoClusterAssociationMap::MtdSimLayerClusterToRecoClusterAssociationMap() {} | ||
|
||
MtdSimLayerClusterToRecoClusterAssociationMap::~MtdSimLayerClusterToRecoClusterAssociationMap() {} |
5 changes: 5 additions & 0 deletions
5
SimDataFormats/Associations/src/MtdSimLayerClusterToTPAssociator.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include "SimDataFormats/Associations/interface/MtdSimLayerClusterToTPAssociator.h" | ||
|
||
reco::MtdSimLayerClusterToTPAssociator::MtdSimLayerClusterToTPAssociator( | ||
std::unique_ptr<reco::MtdSimLayerClusterToTPAssociatorBaseImpl> ptr) | ||
: m_impl(std::move(ptr)) {} |
Oops, something went wrong.