-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correction of MTD ETL Validation: hits accumulation on a pixel-basis #43928
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
618dc98
fix of ETL simHit accumulation on a pixel basis
0fb5456
cleaning
d880143
fix of ETL digiHits accumulation on a pixel basis
81f1b48
fix of ETL localReco Validation: resolution on a pixel basis
cdffeca
cleaning
2c29f78
fix in track validation>: ETL hits handled on a pixel basis
2c671c5
code format
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ | |
#include "Geometry/MTDGeometryBuilder/interface/RectangularMTDTopology.h" | ||
#include "Geometry/MTDNumberingBuilder/interface/MTDTopology.h" | ||
#include "Geometry/MTDCommonData/interface/MTDTopologyMode.h" | ||
#include "Geometry/MTDGeometryBuilder/interface/MTDGeomUtil.h" | ||
|
||
#include "RecoLocalFastTime/Records/interface/MTDCPERecord.h" | ||
#include "RecoLocalFastTime/FTLClusterizer/interface/MTDClusterParameterEstimator.h" | ||
|
@@ -175,6 +176,27 @@ void EtlLocalRecoValidation::analyze(const edm::Event& iEvent, const edm::EventS | |
using namespace edm; | ||
using namespace std; | ||
using namespace geant_units::operators; | ||
using namespace mtd; | ||
|
||
// Struct to identify the pixel | ||
struct ETLPixelId { | ||
const uint32_t detid_; | ||
const uint8_t row_; | ||
const uint8_t col_; | ||
ETLPixelId() : detid_(0), row_(0), col_(0) {} | ||
ETLPixelId(const ETLDetId& id, uint8_t row, uint8_t col) : detid_(id.rawId()), row_(row), col_(col) {} | ||
bool operator==(const ETLPixelId& other) const { | ||
return detid_ == other.detid_ && row_ == other.row_ && col_ == other.col_; | ||
} | ||
}; | ||
|
||
struct PixelKey_hash { | ||
size_t operator()(const ETLPixelId& key) const { | ||
return std::hash<uint32_t>{}(key.detid_) ^ std::hash<uint8_t>{}(key.row_) ^ std::hash<uint8_t>{}(key.col_); | ||
} | ||
}; | ||
|
||
MTDGeomUtil geomUtil; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the use of MTDGeomUtil is possible if geometry and topology are properly initialised with the set methods: For ETL at least the geometry needs to be set otherwise the code will happily crash. The comment is valid for all classes affected by this PR. |
||
|
||
auto geometryHandle = iSetup.getTransientHandle(mtdgeoToken_); | ||
const MTDGeometry* geom = geometryHandle.product(); | ||
|
@@ -202,7 +224,8 @@ void EtlLocalRecoValidation::analyze(const edm::Event& iEvent, const edm::EventS | |
#endif | ||
|
||
// --- Loop over the ETL SIM hits | ||
std::unordered_map<uint32_t, MTDHit> m_etlSimHits[4]; | ||
//std::unordered_map<uint32_t, MTDHit> m_etlSimHits[4]; | ||
std::unordered_map<ETLPixelId, MTDHit, PixelKey_hash> m_etlSimHits[4]; | ||
for (auto const& simHit : etlSimHits) { | ||
// --- Use only hits compatible with the in-time bunch-crossing | ||
if (simHit.tof() < 0 || simHit.tof() > 25.) | ||
|
@@ -225,7 +248,10 @@ void EtlLocalRecoValidation::analyze(const edm::Event& iEvent, const edm::EventS | |
continue; | ||
} | ||
|
||
auto simHitIt = m_etlSimHits[idet].emplace(id.rawId(), MTDHit()).first; | ||
//auto simHitIt = m_etlSimHits[idet].emplace(id.rawId(), MTDHit()).first; | ||
std::pair<uint8_t, uint8_t> pixel = geomUtil.pixelInModule(id, simHit.localPosition()); | ||
ETLPixelId pixelId(id.rawId(), pixel.first, pixel.second); | ||
auto simHitIt = m_etlSimHits[idet].emplace(pixelId, MTDHit()).first; | ||
|
||
// --- Accumulate the energy (in MeV) of SIM hits in the same detector cell | ||
(simHitIt->second).energy += convertUnitsTo(0.001_MeV, simHit.energyLoss()); | ||
|
@@ -312,16 +338,19 @@ void EtlLocalRecoValidation::analyze(const edm::Event& iEvent, const edm::EventS | |
meHitTvsEta_[idet]->Fill(global_point.eta(), recHit.time()); | ||
|
||
// Resolution histograms | ||
if (m_etlSimHits[idet].count(detId.rawId()) == 1) { | ||
if (m_etlSimHits[idet][detId.rawId()].energy > hitMinEnergy2Dis_) { | ||
float time_res = recHit.time() - m_etlSimHits[idet][detId.rawId()].time; | ||
float energy_res = recHit.energy() - m_etlSimHits[idet][detId.rawId()].energy; | ||
std::pair<uint8_t, uint8_t> pixel = geomUtil.pixelInModule(detId, local_point); | ||
ETLPixelId pixelId(detId.rawId(), pixel.first, pixel.second); | ||
|
||
if (m_etlSimHits[idet].count(pixelId) == 1) { | ||
if (m_etlSimHits[idet][pixelId].energy > hitMinEnergy2Dis_) { | ||
float time_res = recHit.time() - m_etlSimHits[idet][pixelId].time; | ||
float energy_res = recHit.energy() - m_etlSimHits[idet][pixelId].energy; | ||
|
||
meTimeRes_->Fill(time_res); | ||
meEnergyRes_->Fill(energy_res); | ||
|
||
meTPullvsEta_->Fill(std::abs(global_point.eta()), time_res / recHit.timeError()); | ||
meTPullvsE_->Fill(m_etlSimHits[idet][detId.rawId()].energy, time_res / recHit.timeError()); | ||
meTPullvsE_->Fill(m_etlSimHits[idet][pixelId].energy, time_res / recHit.timeError()); | ||
} | ||
} | ||
|
||
|
@@ -401,13 +430,23 @@ void EtlLocalRecoValidation::analyze(const edm::Event& iEvent, const edm::EventS | |
|
||
// Match the RECO hit to the corresponding SIM hit | ||
for (const auto& recHit : *etlRecHitsHandle) { | ||
ETLDetId hitId(recHit.id().rawId()); | ||
ETLDetId detId(recHit.id().rawId()); | ||
|
||
DetId geoId = detId.geographicalId(); | ||
const MTDGeomDet* thedet = geom->idToDet(geoId); | ||
const ProxyMTDTopology& topoproxy = static_cast<const ProxyMTDTopology&>(thedet->topology()); | ||
const RectangularMTDTopology& topo = static_cast<const RectangularMTDTopology&>(topoproxy.specificTopology()); | ||
|
||
if (m_etlSimHits[idet].count(hitId.rawId()) == 0) | ||
Local3DPoint local_point(topo.localX(recHit.row()), topo.localY(recHit.column()), 0.); | ||
|
||
std::pair<uint8_t, uint8_t> pixel = geomUtil.pixelInModule(detId, local_point); | ||
ETLPixelId pixelId(detId.rawId(), pixel.first, pixel.second); | ||
|
||
if (m_etlSimHits[idet].count(pixelId) == 0) | ||
continue; | ||
|
||
// Check the hit position | ||
if (hitId.zside() != cluId.zside() || hitId.mtdRR() != cluId.mtdRR() || hitId.module() != cluId.module() || | ||
if (detId.zside() != cluId.zside() || detId.mtdRR() != cluId.mtdRR() || detId.module() != cluId.module() || | ||
recHit.row() != hit_row || recHit.column() != hit_col) | ||
continue; | ||
|
||
|
@@ -416,18 +455,18 @@ void EtlLocalRecoValidation::analyze(const edm::Event& iEvent, const edm::EventS | |
continue; | ||
|
||
// SIM hit's position in the module reference frame | ||
Local3DPoint local_point_sim(convertMmToCm(m_etlSimHits[idet][recHit.id().rawId()].x), | ||
convertMmToCm(m_etlSimHits[idet][recHit.id().rawId()].y), | ||
convertMmToCm(m_etlSimHits[idet][recHit.id().rawId()].z)); | ||
Local3DPoint local_point_sim(convertMmToCm(m_etlSimHits[idet][pixelId].x), | ||
convertMmToCm(m_etlSimHits[idet][pixelId].y), | ||
convertMmToCm(m_etlSimHits[idet][pixelId].z)); | ||
|
||
// Calculate the SIM cluster's position in the module reference frame | ||
cluLocXSIM += local_point_sim.x() * m_etlSimHits[idet][recHit.id().rawId()].energy; | ||
cluLocYSIM += local_point_sim.y() * m_etlSimHits[idet][recHit.id().rawId()].energy; | ||
cluLocZSIM += local_point_sim.z() * m_etlSimHits[idet][recHit.id().rawId()].energy; | ||
cluLocXSIM += local_point_sim.x() * m_etlSimHits[idet][pixelId].energy; | ||
cluLocYSIM += local_point_sim.y() * m_etlSimHits[idet][pixelId].energy; | ||
cluLocZSIM += local_point_sim.z() * m_etlSimHits[idet][pixelId].energy; | ||
|
||
// Calculate the SIM cluster energy and time | ||
cluEneSIM += m_etlSimHits[idet][recHit.id().rawId()].energy; | ||
cluTimeSIM += m_etlSimHits[idet][recHit.id().rawId()].time * m_etlSimHits[idet][recHit.id().rawId()].energy; | ||
cluEneSIM += m_etlSimHits[idet][pixelId].energy; | ||
cluTimeSIM += m_etlSimHits[idet][pixelId].time * m_etlSimHits[idet][pixelId].energy; | ||
|
||
break; | ||
|
||
|
@@ -500,31 +539,33 @@ void EtlLocalRecoValidation::analyze(const edm::Event& iEvent, const edm::EventS | |
|
||
for (const auto& uRecHit : *etlUncalibRecHitsHandle) { | ||
ETLDetId detId = uRecHit.id(); | ||
|
||
int idet = detId.zside() + detId.nDisc(); | ||
|
||
// --- Skip UncalibratedRecHits not matched to SimHits | ||
if (m_etlSimHits[idet].count(detId.rawId()) != 1) | ||
continue; | ||
|
||
DetId geoId = detId.geographicalId(); | ||
const MTDGeomDet* thedet = geom->idToDet(geoId); | ||
if (thedet == nullptr) | ||
throw cms::Exception("EtlLocalRecoValidation") << "GeographicalID: " << std::hex << geoId.rawId() << " (" | ||
<< detId.rawId() << ") is invalid!" << std::dec << std::endl; | ||
|
||
const ProxyMTDTopology& topoproxy = static_cast<const ProxyMTDTopology&>(thedet->topology()); | ||
const RectangularMTDTopology& topo = static_cast<const RectangularMTDTopology&>(topoproxy.specificTopology()); | ||
|
||
Local3DPoint local_point(topo.localX(uRecHit.row()), topo.localY(uRecHit.column()), 0.); | ||
const auto& global_point = thedet->toGlobal(local_point); | ||
|
||
std::pair<uint8_t, uint8_t> pixel = geomUtil.pixelInModule(detId, local_point); | ||
ETLPixelId pixelId(detId.rawId(), pixel.first, pixel.second); | ||
|
||
// --- Skip UncalibratedRecHits not matched to SimHits | ||
if (m_etlSimHits[idet].count(pixelId) == 0) | ||
continue; | ||
|
||
if (thedet == nullptr) | ||
throw cms::Exception("EtlLocalRecoValidation") << "GeographicalID: " << std::hex << geoId.rawId() << " (" | ||
<< detId.rawId() << ") is invalid!" << std::dec << std::endl; | ||
|
||
// --- Fill the histograms | ||
|
||
if (uRecHit.amplitude().first < hitMinAmplitude_) | ||
continue; | ||
|
||
float time_res = uRecHit.time().first - m_etlSimHits[idet][detId.rawId()].time; | ||
float time_res = uRecHit.time().first - m_etlSimHits[idet][pixelId].time; | ||
|
||
int iside = (detId.zside() == -1 ? 0 : 1); | ||
|
||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ctarricone the update of this class is not needed, because of the meaning of this counter: number of DIGIs per LGAD. Each pixel has its own separate DIGI, and there is one DIGI per pixel by construction, see https://github.com/cms-sw/cmssw/blob/master/SimFastTiming/FastTimingCommon/src/ETLDeviceSim.cc#L130
and the definition of
MTDCellId
.Counting DIGIs per LGAD means counting how many pixels have fired in an LGAD for a given event, and this is what we are interested to monitor here. In the case of your class, you might see just either zero or one.