Skip to content
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

MTD code: add debugging statements, clean ETL validation for obsolete one-disk scenario #42748

Merged
merged 2 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 28 additions & 4 deletions RecoMTD/TrackExtender/plugins/TrackExtenderWithMTD.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1025,8 +1025,13 @@ TransientTrackingRecHit::ConstRecHitContainer TrackExtenderWithMTDT<TrackCollect

TransientTrackingRecHit::ConstRecHitContainer output;
bestHit = MTDHitMatchingInfo();
for (const DetLayer* ilay : layers)
for (const DetLayer* ilay : layers) {
LogTrace("TrackExtenderWithMTD") << "Hit search: BTL layer at R= "
<< static_cast<const BarrelDetLayer*>(ilay)->specificSurface().radius();

fillMatchingHits(ilay, tsos, traj, pmag2, pathlength0, trs0, hits, prop, bs, vtxTime, matchVertex, output, bestHit);
}

return output;
}

Expand Down Expand Up @@ -1056,6 +1061,8 @@ TransientTrackingRecHit::ConstRecHitContainer TrackExtenderWithMTDT<TrackCollect
if (tsos.globalPosition().z() * diskZ < 0)
continue; // only propagate to the disk that's on the same side

LogTrace("TrackExtenderWithMTD") << "Hit search: ETL disk at Z = " << diskZ;

fillMatchingHits(ilay, tsos, traj, pmag2, pathlength0, trs0, hits, prop, bs, vtxTime, matchVertex, output, bestHit);
}

Expand Down Expand Up @@ -1115,7 +1122,7 @@ void TrackExtenderWithMTDT<TrackCollection>::fillMatchingHits(const DetLayer* il
if (!hitsInLayer.empty()) {
//check hits to pass minimum quality matching requirements
auto const& firstHit = *hitsInLayer.begin();
LogTrace("TrackExtenderWithMTD") << "TrackExtenderWithMTD: estChi2= " << firstHit.estChi2
LogTrace("TrackExtenderWithMTD") << "TrackExtenderWithMTD: matching trial 1: estChi2= " << firstHit.estChi2
<< " timeChi2= " << firstHit.timeChi2;
if (firstHit.estChi2 < spaceChi2Cut && firstHit.timeChi2 < timeChi2Cut) {
hitMatched = true;
Expand All @@ -1131,7 +1138,7 @@ void TrackExtenderWithMTDT<TrackCollection>::fillMatchingHits(const DetLayer* il
find_hits(0, false);
if (!hitsInLayer.empty()) {
auto const& firstHit = *hitsInLayer.begin();
LogTrace("TrackExtenderWithMTD") << "TrackExtenderWithMTD: estChi2= " << firstHit.estChi2
LogTrace("TrackExtenderWithMTD") << "TrackExtenderWithMTD: matching trial 2: estChi2= " << firstHit.estChi2
<< " timeChi2= " << firstHit.timeChi2;
if (firstHit.timeChi2 < timeChi2Cut) {
if (firstHit.estChi2 < spaceChi2Cut) {
Expand All @@ -1143,6 +1150,15 @@ void TrackExtenderWithMTDT<TrackCollection>::fillMatchingHits(const DetLayer* il
}
}
}

#ifdef EDM_ML_DEBUG
if (hitMatched) {
LogTrace("TrackExtenderWithMTD") << "TrackExtenderWithMTD: matched hit with time: " << bestHit.hit->time()
<< " +/- " << bestHit.hit->timeError();
} else {
LogTrace("TrackExtenderWithMTD") << "TrackExtenderWithMTD: no matched hit";
}
#endif
}

//below is unfortunately ripped from other places but
Expand Down Expand Up @@ -1221,6 +1237,9 @@ reco::Track TrackExtenderWithMTDT<TrackCollection>::buildTrack(const reco::Track
}
}

LogTrace("TrackExtenderWithMTD") << "TrackExtenderWithMTD: selected #hits " << ihitcount << " from ETL "
<< ietlcount;

auto ihit1 = trajWithMtd.measurements().cbegin();
if (ihitcount == 1) {
const MTDTrackingRecHit* mtdhit = static_cast<const MTDTrackingRecHit*>((*ihit1).recHit()->hit());
Expand Down Expand Up @@ -1261,12 +1280,17 @@ reco::Track TrackExtenderWithMTDT<TrackCollection>::buildTrack(const reco::Track
thiterror = 1.f / (err1 + err2);
thit = (tofInfo.dt * err1 + mtdhit2->time() * err2) * thiterror;
thiterror = std::sqrt(thiterror);
LogDebug("TrackExtenderWithMTD")
LogTrace("TrackExtenderWithMTD")
<< "TrackExtenderWithMTD: p trk = " << p.mag() << " ETL hits times/errors: " << mtdhit1->time()
<< " +/- " << mtdhit1->timeError() << " , " << mtdhit2->time() << " +/- " << mtdhit2->timeError()
<< " extrapolated time1: " << tofInfo.dt << " +/- " << tofInfo.dterror << " average = " << thit
<< " +/- " << thiterror;
validmtd = true;
} else {
LogTrace("TrackExtenderWithMTD")
<< "TrackExtenderWithMTD: issue with layer2 extrapolation to layer1, time difference "
<< (tofInfo.dt - mtdhit2->time()) << " larger than maximal uncertainty "
<< (err1 + err2) * etlTimeChi2Cut_;
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions SimFastTiming/FastTimingCommon/src/ETLDeviceSim.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ void ETLDeviceSim::getHitsResponse(const std::vector<std::tuple<int, uint32_t, f

//loop over sorted hits
const int nchits = hitRefs.size();
LogTrace("ETLDeviceSim") << "Processing " << nchits << " SIM hits";
for (int i = 0; i < nchits; ++i) {
const int hitidx = std::get<0>(hitRefs[i]);
const uint32_t id = std::get<1>(hitRefs[i]);
Expand Down Expand Up @@ -64,11 +65,16 @@ void ETLDeviceSim::getHitsResponse(const std::vector<std::tuple<int, uint32_t, f
//The following lines check whether the pixel point is actually out of the active area.
//If that is the case it simply ignores the point but in the future some more sophisticated function could be applied.
if (!topo.isInPixel(simscaled)) {
LogDebug("ETLDeviceSim") << "Skipping hit ouf of pixel # " << hitidx << " DetId " << etlid.rawId() << " tof "
<< toa;
continue;
}
const auto& thepixel = topo.pixel(simscaled);
const uint8_t row(thepixel.first), col(thepixel.second);

LogDebug("ETLDeviceSim") << "Processing hit in pixel # " << hitidx << " DetId " << etlid.rawId() << " row/col "
<< (uint32_t)row << " " << (uint32_t)col << " tof " << toa;

auto simHitIt =
simHitAccumulator->emplace(mtd_digitizer::MTDCellId(id, row, col), mtd_digitizer::MTDCellInfo()).first;

Expand Down
75 changes: 22 additions & 53 deletions Validation/MtdValidation/plugins/EtlDigiHitsValidation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,6 @@ void EtlDigiHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSe
auto geometryHandle = iSetup.getTransientHandle(mtdgeoToken_);
const MTDGeometry* geom = geometryHandle.product();

auto topologyHandle = iSetup.getTransientHandle(mtdtopoToken_);
const MTDTopology* topology = topologyHandle.product();

bool topo1Dis = false;
bool topo2Dis = false;
if (MTDTopologyMode::etlLayoutFromTopoMode(topology->getMTDTopologyMode()) == ETLDetId::EtlLayout::tp) {
topo1Dis = true;
} else {
topo2Dis = true;
}

auto etlDigiHitsHandle = makeValid(iEvent.getHandle(etlDigiHitsToken_));

// --- Loop over the ETL DIGI hits
Expand All @@ -120,6 +109,8 @@ void EtlDigiHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSe
ndigiPerLGAD_[i].clear();
}

size_t index(0);

for (const auto& dataFrame : *etlDigiHitsHandle) {
// --- Get the on-time sample
int isample = 2;
Expand All @@ -140,34 +131,25 @@ void EtlDigiHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSe
// --- Fill the histograms

int idet = 999;

if (topo1Dis) {
if (detId.zside() == -1) {
idet = 0;
} else if (detId.zside() == 1) {
idet = 2;
} else {
continue;
}
if (detId.discSide() == 1) {
weight = -weight;
}

if (topo2Dis) {
if (detId.discSide() == 1) {
weight = -weight;
}
if ((detId.zside() == -1) && (detId.nDisc() == 1)) {
idet = 0;
} else if ((detId.zside() == -1) && (detId.nDisc() == 2)) {
idet = 1;
} else if ((detId.zside() == 1) && (detId.nDisc() == 1)) {
idet = 2;
} else if ((detId.zside() == 1) && (detId.nDisc() == 2)) {
idet = 3;
} else {
continue;
}
if ((detId.zside() == -1) && (detId.nDisc() == 1)) {
idet = 0;
} else if ((detId.zside() == -1) && (detId.nDisc() == 2)) {
idet = 1;
} else if ((detId.zside() == 1) && (detId.nDisc() == 1)) {
idet = 2;
} else if ((detId.zside() == 1) && (detId.nDisc() == 2)) {
idet = 3;
} else {
edm::LogWarning("EtlDigiHitsValidation") << "Unknown ETL DetId configuration: " << detId;
continue;
}

index++;
LogDebug("EtlDigiHitsValidation") << "Digi # " << index << " DetId " << detId.rawId() << " idet " << idet;

meHitCharge_[idet]->Fill(sample.data());
meHitTime_[idet]->Fill(sample.toa());
meOccupancy_[idet]->Fill(global_point.x(), global_point.y(), weight);
Expand Down Expand Up @@ -204,23 +186,10 @@ void EtlDigiHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSe

} // dataFrame loop

if (topo1Dis) {
meNhits_[0]->Fill(log10(n_digi_etl[0]));
meNhits_[2]->Fill(log10(n_digi_etl[2]));
for (const auto& thisNdigi : ndigiPerLGAD_[0]) {
meNhitsPerLGAD_[0]->Fill(thisNdigi.second);
}
for (const auto& thisNdigi : ndigiPerLGAD_[2]) {
meNhitsPerLGAD_[2]->Fill(thisNdigi.second);
}
}

if (topo2Dis) {
for (int i = 0; i < 4; i++) {
meNhits_[i]->Fill(log10(n_digi_etl[i]));
for (const auto& thisNdigi : ndigiPerLGAD_[i]) {
meNhitsPerLGAD_[i]->Fill(thisNdigi.second);
}
for (int i = 0; i < 4; i++) {
meNhits_[i]->Fill(log10(n_digi_etl[i]));
for (const auto& thisNdigi : ndigiPerLGAD_[i]) {
meNhitsPerLGAD_[i]->Fill(thisNdigi.second);
}
}
}
Expand Down
Loading