Skip to content

Commit

Permalink
code format
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristiano committed Feb 9, 2024
1 parent 2c29f78 commit 2c671c5
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 35 deletions.
9 changes: 3 additions & 6 deletions Validation/MtdValidation/plugins/EtlDigiHitsValidation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ class EtlDigiHitsValidation : public DQMEDAnalyzer {
MonitorElement* meHitQvsEta_[4];
MonitorElement* meHitTvsPhi_[4];
MonitorElement* meHitTvsEta_[4];

};

// ------------ constructor and destructor --------------
Expand All @@ -104,13 +103,13 @@ void EtlDigiHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSe
// Struct to identify the pixel
struct ETLPixelId {
const uint32_t detid_;
const uint8_t row_;
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 {
Expand All @@ -119,8 +118,6 @@ void EtlDigiHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSe
}
};



auto geometryHandle = iSetup.getTransientHandle(mtdgeoToken_);
const MTDGeometry* geom = geometryHandle.product();

Expand All @@ -130,7 +127,7 @@ void EtlDigiHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSe

std::array<std::unordered_map<ETLPixelId, uint32_t, PixelKey_hash>, 4> ndigiPerLGAD_;
MTDGeomUtil geomUtil;

unsigned int n_digi_etl[4] = {0, 0, 0, 0};
for (size_t i = 0; i < 4; i++) {
ndigiPerLGAD_[i].clear();
Expand Down
30 changes: 14 additions & 16 deletions Validation/MtdValidation/plugins/EtlLocalRecoValidation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,13 @@ void EtlLocalRecoValidation::analyze(const edm::Event& iEvent, const edm::EventS
// Struct to identify the pixel
struct ETLPixelId {
const uint32_t detid_;
const uint8_t row_;
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 {
Expand Down Expand Up @@ -226,7 +225,7 @@ void EtlLocalRecoValidation::analyze(const edm::Event& iEvent, const edm::EventS

// --- Loop over the ETL SIM hits
//std::unordered_map<uint32_t, MTDHit> m_etlSimHits[4];
std::unordered_map< ETLPixelId, MTDHit, PixelKey_hash> 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.)
Expand Down Expand Up @@ -254,7 +253,6 @@ void EtlLocalRecoValidation::analyze(const edm::Event& iEvent, const edm::EventS
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());

Expand Down Expand Up @@ -432,17 +430,17 @@ 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 detId(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());
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());

Local3DPoint local_point(topo.localX(recHit.row()), topo.localY(recHit.column()), 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);
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;
Expand All @@ -457,7 +455,7 @@ 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][pixelId].x),
Local3DPoint local_point_sim(convertMmToCm(m_etlSimHits[idet][pixelId].x),
convertMmToCm(m_etlSimHits[idet][pixelId].y),
convertMmToCm(m_etlSimHits[idet][pixelId].z));

Expand Down Expand Up @@ -550,13 +548,13 @@ void EtlLocalRecoValidation::analyze(const edm::Event& iEvent, const edm::EventS

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;
continue;

if (thedet == nullptr)
throw cms::Exception("EtlLocalRecoValidation") << "GeographicalID: " << std::hex << geoId.rawId() << " ("
Expand Down
13 changes: 6 additions & 7 deletions Validation/MtdValidation/plugins/EtlSimHitsValidation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,22 +109,21 @@ void EtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet
// Struct to identify the pixel
struct ETLPixelId {
const uint32_t detid_;
const uint8_t row_;
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_);
}
};

auto geometryHandle = iSetup.getTransientHandle(mtdgeoToken_);
const MTDGeometry* geom = geometryHandle.product();

Expand All @@ -133,8 +132,8 @@ void EtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet
auto etlSimHitsHandle = makeValid(iEvent.getHandle(etlSimHitsToken_));
MixCollection<PSimHit> etlSimHits(etlSimHitsHandle.product());

std::unordered_map< ETLPixelId, MTDHit, PixelKey_hash> m_etlHits[4];
std::unordered_map< ETLPixelId, std::set<int>, PixelKey_hash > m_etlTrkPerCell[4];
std::unordered_map<ETLPixelId, MTDHit, PixelKey_hash> m_etlHits[4];
std::unordered_map<ETLPixelId, std::set<int>, PixelKey_hash> m_etlTrkPerCell[4];

// --- Loop over the ETL SIM hits

Expand Down Expand Up @@ -205,7 +204,7 @@ void EtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet
// --- Get the SIM hit global position

ETLDetId detId;
detId=hit.first.detid_;
detId = hit.first.detid_;
DetId geoId = detId.geographicalId();
const MTDGeomDet* thedet = geom->idToDet(geoId);
if (thedet == nullptr)
Expand Down
11 changes: 5 additions & 6 deletions Validation/MtdValidation/plugins/MtdTracksValidation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -302,14 +302,13 @@ void MtdTracksValidation::analyze(const edm::Event& iEvent, const edm::EventSetu
// Struct to identify the pixel
struct ETLPixelId {
const uint32_t detid_;
const uint8_t row_;
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 {
Expand All @@ -326,7 +325,7 @@ void MtdTracksValidation::analyze(const edm::Event& iEvent, const edm::EventSetu
std::unordered_map<uint32_t, MTDHit> m_btlHits;
std::unordered_map<ETLPixelId, MTDHit, PixelKey_hash> m_etlHits;
std::unordered_map<uint32_t, std::set<unsigned long int>> m_btlTrkPerCell;
std::unordered_map<ETLPixelId, std::set<unsigned long int>, PixelKey_hash > m_etlTrkPerCell;
std::unordered_map<ETLPixelId, std::set<unsigned long int>, PixelKey_hash> m_etlTrkPerCell;
std::map<TrackingParticleRef, std::vector<uint32_t>> m_tp2detid;

const auto& tMtd = iEvent.get(tmtdToken_);
Expand Down Expand Up @@ -414,12 +413,12 @@ void MtdTracksValidation::analyze(const edm::Event& iEvent, const edm::EventSetu
}
}
for (auto const& cell : m_etlTrkPerCell) {
if (m_etlHits[cell.first].energy < depositETLthreshold_) {
if (m_etlHits[cell.first].energy < depositETLthreshold_) {
continue;
}
for (auto const& simtrack : cell.second) {
if (thisTId == simtrack) {
m_tp2detid[tpref].emplace_back(cell.first.detid_);
m_tp2detid[tpref].emplace_back(cell.first.detid_);
break;
}
}
Expand Down

0 comments on commit 2c671c5

Please sign in to comment.