26 std::array<edm::Handle<FTLClusterCollection>, 2> inputRecoClusH{{btlRecoClusH, etlRecoClusH}};
28 const auto& simClusters = *simClusH.
product();
31 std::map<uint32_t, std::vector<MtdSimLayerClusterRef>> simClusIdsMap;
32 for (
auto simClusIt = simClusters.begin(); simClusIt != simClusters.end(); simClusIt++) {
33 const auto& simClus = *simClusIt;
38 std::vector<std::pair<uint32_t, std::pair<uint8_t, uint8_t>>> detIdsAndRows = simClus.detIds_and_rows();
39 std::vector<uint32_t> detIds(detIdsAndRows.size());
43 [](
const std::pair<uint32_t, std::pair<uint8_t, uint8_t>>& pair) {
return pair.first; });
48 simClusIdsMap[modId].push_back(simClusterRef);
50 LogDebug(
"MtdRecoClusterToSimLayerClusterAssociatorByHitsImpl") <<
"Sim cluster detId = " << modId << std::endl;
53 for (
auto const& recoClusH : inputRecoClusH) {
55 for (
const auto& detSet : *recoClusH) {
57 for (
const auto& recoClus : detSet) {
60 LogDebug(
"MtdRecoClusterToSimLayerClusterAssociatorByHitsImpl") <<
"Reco cluster : " << clusId;
62 std::vector<uint64_t> recoClusHitIds;
65 for (
int ihit = 0; ihit < recoClus.size(); ++ihit) {
66 int hit_row = recoClus.minHitRow() + recoClus.hitOffset()[ihit * 2];
67 int hit_col = recoClus.minHitCol() + recoClus.hitOffset()[ihit * 2 + 1];
71 uniqueId |= hit_row << 16;
73 recoClusHitIds.push_back(uniqueId);
75 LogDebug(
"MtdRecoClusterToSimLayerClusterAssociatorByHitsImpl")
76 <<
" ======= cluster raw Id : " << clusId.
rawId() <<
" row : " << hit_row <<
" column: " << hit_col
77 <<
" recHit uniqueId : " << uniqueId;
81 std::vector<MtdSimLayerClusterRef> simClusterRefs;
83 for (
const auto& simClusterRef : simClusIdsMap[clusId.
rawId()]) {
84 const auto& simClus = *simClusterRef;
87 std::vector<std::pair<uint32_t, std::pair<uint8_t, uint8_t>>> detIdsAndRows = simClus.detIds_and_rows();
88 std::vector<uint64_t> simClusHitIds(detIdsAndRows.size());
89 for (
unsigned int i = 0;
i < detIdsAndRows.size();
i++) {
94 uniqueId |= detIdsAndRows[
i].second.first << 16;
95 uniqueId |= detIdsAndRows[
i].second.second;
96 simClusHitIds.push_back(uniqueId);
100 std::vector<uint64_t> sharedHitIds;
102 recoClusHitIds.end(),
103 simClusHitIds.begin(),
105 std::back_inserter(sharedHitIds));
107 if (sharedHitIds.empty())
110 float dE = recoClus.energy() * 0.001 / simClus.simLCEnergy();
111 float dtSig =
std::abs((recoClus.time() - simClus.simLCTime()) / recoClus.timeError());
114 if (!sharedHitIds.empty() &&
117 simClusterRefs.push_back(simClusterRef);
119 LogDebug(
"MtdRecoClusterToSimLayerClusterAssociatorByHitsImpl")
120 <<
"RecoToSim --> Found " << sharedHitIds.size() <<
" shared hits";
121 LogDebug(
"MtdRecoClusterToSimLayerClusterAssociatorByHitsImpl")
122 <<
"E_recoClus = " << recoClus.energy() <<
" E_simClus = " << simClus.simLCEnergy()
123 <<
" E_recoClus/E_simClus = " << dE;
124 LogDebug(
"MtdRecoClusterToSimLayerClusterAssociatorByHitsImpl")
125 <<
"(t_recoClus-t_simClus)/sigma_t = " << dtSig;
131 outputCollection.
emplace_back(recoClusterRef, simClusterRefs);
138 return outputCollection;
148 const auto& simClusters = *simClusH.
product();
150 std::array<edm::Handle<FTLClusterCollection>, 2> inputH{{btlRecoClusH, etlRecoClusH}};
153 for (
auto simClusIt = simClusters.begin(); simClusIt != simClusters.end(); simClusIt++) {
154 const auto& simClus = *simClusIt;
157 std::vector<std::pair<uint32_t, std::pair<uint8_t, uint8_t>>> detIdsAndRows = simClus.detIds_and_rows();
158 std::vector<uint64_t> simClusHitIds(detIdsAndRows.size());
160 for (
unsigned int i = 0;
i < detIdsAndRows.size();
i++) {
165 uniqueId |= detIdsAndRows[
i].second.first << 16;
166 uniqueId |= detIdsAndRows[
i].second.second;
167 simClusHitIds.push_back(uniqueId);
170 DetId simClusId(modId);
172 std::vector<FTLClusterRef> recoClusterRefs;
175 for (
auto const& recoClusH : inputH) {
177 for (
const auto& detSet : *recoClusH) {
178 if (detSet.id() != simClusId.
rawId())
182 for (
const auto& recoClus : detSet) {
185 std::vector<uint64_t> recoClusHitIds;
188 for (
int ihit = 0; ihit < recoClus.size(); ++ihit) {
189 int hit_row = recoClus.minHitRow() + recoClus.hitOffset()[ihit * 2];
190 int hit_col = recoClus.minHitCol() + recoClus.hitOffset()[ihit * 2 + 1];
194 uniqueId |= hit_row << 16;
196 recoClusHitIds.push_back(uniqueId);
198 LogDebug(
"MtdRecoClusterToSimLayerClusterAssociatorByHitsImpl")
199 <<
" ======= cluster raw Id : " << clusId.
rawId() <<
" row : " << hit_row <<
" column: " << hit_col
200 <<
" recHit uniqueId : " << uniqueId;
204 std::vector<uint64_t> sharedHitIds;
207 recoClusHitIds.begin(),
208 recoClusHitIds.end(),
209 std::back_inserter(sharedHitIds));
210 if (sharedHitIds.empty())
213 float dE = recoClus.energy() * 0.001 / simClus.simLCEnergy();
214 float dtSig =
std::abs((recoClus.time() - simClus.simLCTime()) / recoClus.timeError());
217 if (!sharedHitIds.empty() &&
223 recoClusterRefs.push_back(recoClusterRef);
225 LogDebug(
"MtdRecoClusterToSimLayerClusterAssociatorByHitsImpl")
226 <<
"SimToReco --> Found " << sharedHitIds.size() <<
" shared hits";
227 LogDebug(
"MtdRecoClusterToSimLayerClusterAssociatorByHitsImpl")
228 <<
"E_recoClus = " << recoClus.energy() <<
" E_simClus = " << simClus.simLCEnergy()
229 <<
" E_recoClus/E_simClus = " << dE;
230 LogDebug(
"MtdRecoClusterToSimLayerClusterAssociatorByHitsImpl")
231 <<
"(t_recoClus-t_simClus)/sigma_t = " << dtSig;
241 outputCollection.
emplace_back(simClusterRef, recoClusterRefs);
246 return outputCollection;
edm::Ref< typename HandleT::element_type, typename HandleT::element_type::value_type::value_type > makeRefTo(const HandleT &iHandle, typename HandleT::element_type::value_type::const_iterator itIter)
void emplace_back(const MtdSimLayerClusterRef &simClus, std::vector< FTLClusterRef > &recoClusVect)
T const * product() const
int mtdSubDetector() const
mtd::MTDGeomUtil geomTools_
Detector identifier base class for the MIP Timing Layer.
MtdRecoClusterToSimLayerClusterAssociatorByHitsImpl(edm::EDProductGetter const &, double, double, mtd::MTDGeomUtil &)
Abs< T >::type abs(const T &t)
uint32_t sensorModuleId(const DetId &id) const
unsigned long long uint64_t
reco::SimToRecoCollectionMtd associateSimToReco(const edm::Handle< FTLClusterCollection > &btlRecoClusH, const edm::Handle< FTLClusterCollection > &etlRecoClusH, const edm::Handle< MtdSimLayerClusterCollection > &simClusH) const override
Associate a MtdSimLayerClusters to MtdRecoClusters.
constexpr uint32_t rawId() const
get the raw id
reco::RecoToSimCollectionMtd associateRecoToSim(const edm::Handle< FTLClusterCollection > &btlRecoClusH, const edm::Handle< FTLClusterCollection > &etlRecoClusH, const edm::Handle< MtdSimLayerClusterCollection > &simClusH) const override
Associate a MtdRecoCluster to MtdSimLayerClusters.
EDProductGetter const * productGetter(std::atomic< void const *> const &iCache)
void emplace_back(const FTLClusterRef &recoClus, std::vector< MtdSimLayerClusterRef > &simClusVect)