From 12a0c14e2654fa60f5b3f1cbbef4779967fc2b31 Mon Sep 17 00:00:00 2001 From: Mu2e Date: Fri, 13 Mar 2026 22:36:00 -0500 Subject: [PATCH 1/6] add a list of panels to skip --- DAQ/fcl/prolog.fcl | 1 + DAQ/src/StrawHitFilter_module.cc | 27 ++++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/DAQ/fcl/prolog.fcl b/DAQ/fcl/prolog.fcl index 646da59aff..ab7dcd711b 100644 --- a/DAQ/fcl/prolog.fcl +++ b/DAQ/fcl/prolog.fcl @@ -37,6 +37,7 @@ DAQ : { minEDep : 0.0006 ## in MeV debugMode : false debugBits : [ "bit0:0" ] + panelsToSkip : [ ] ## by default all panels are good fillHistograms : false } } diff --git a/DAQ/src/StrawHitFilter_module.cc b/DAQ/src/StrawHitFilter_module.cc index afbb5122eb..1a8ce057ca 100644 --- a/DAQ/src/StrawHitFilter_module.cc +++ b/DAQ/src/StrawHitFilter_module.cc @@ -27,6 +27,9 @@ #include #include +#include "Offline/ProditionsService/inc/ProditionsHandle.hh" +#include "Offline/TrackerConditions/inc/TrackerPanelMap.hh" + namespace mu2e { class StrawHitFilter : public art::EDFilter { public: @@ -40,6 +43,7 @@ namespace mu2e { fhicl::Atom maxDt {Name("maxDt" ), Comment("max abs(DT)")}; fhicl::Atom minEDep {Name("minEDep" ), Comment("min EDep")}; fhicl::Atom minNGoodHits {Name("minNGoodHits" ), Comment("minNStrawDigis")}; + fhicl::Sequence mnidToSkip {Name("mnidToSkip" ), Comment("a list of panels to skip")}; fhicl::Atom fillHistograms{Name("fillHistograms"), Comment("fill histogrms, default:false")}; }; @@ -75,6 +79,7 @@ namespace mu2e { float _maxDt; float _minEDep; int _minNGoodHits; + std::vector _mnidToSkip; // panels not to look at when searching for good hits int _fillHistograms; int _nevt; @@ -82,7 +87,9 @@ namespace mu2e { int _nsht; int _nshg; - const mu2e::StrawHitCollection* _shc; + const mu2e::StrawHitCollection* _shc; + ProditionsHandle _tpm_h; + const TrackerPanelMap* _trkPanelMap; const art::Event* _event; int _rn; @@ -98,6 +105,7 @@ namespace mu2e { _maxDt (conf().maxDt ()), _minEDep (conf().minEDep ()), _minNGoodHits (conf().minNGoodHits()), + _mnidToSkip (conf().mnidToSkip()), _fillHistograms (conf().fillHistograms()) { //----------------------------------------------------------------------------- @@ -194,6 +202,8 @@ namespace mu2e { _event = &ArtEvent; // should always be the first line + _trkPanelMap = &_tpm_h.get(_event->id()); + if (_debugMode) print_("-- START"); ++_nevt; @@ -216,6 +226,21 @@ namespace mu2e { for (int i = 0; i<_nsht; ++i) { const mu2e::StrawHit* sh = &_shc->at(i); + + int pln = sh->strawId().plane(); + int pnl = sh->strawId().panel(); + const TrkPanelMap::Row* tpm = _trkPanelMap->panel_map_by_offline_ind(pln,pnl); + int hit_mnid = tpm->mnid(); + + bool skip = false; + for (auto mnid: _mnidToSkip) { + if (hit_mnid == mnid) { + skip = true; + break; + } + } + if (skip) continue; + if (fabs(sh->dt()) > _maxDt ) continue; if (sh->energyDep() < _minEDep) continue; _nshg++; From 78c2f8e94fd40e66598dfbbe48a7e69ddc3c2af3 Mon Sep 17 00:00:00 2001 From: Mu2e Date: Sat, 14 Mar 2026 00:08:04 -0500 Subject: [PATCH 2/6] fix fcl --- DAQ/fcl/prolog.fcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DAQ/fcl/prolog.fcl b/DAQ/fcl/prolog.fcl index ab7dcd711b..fa5cc3bdd0 100644 --- a/DAQ/fcl/prolog.fcl +++ b/DAQ/fcl/prolog.fcl @@ -37,7 +37,7 @@ DAQ : { minEDep : 0.0006 ## in MeV debugMode : false debugBits : [ "bit0:0" ] - panelsToSkip : [ ] ## by default all panels are good + mnidToSkip : [ ] ## by default all panels are good fillHistograms : false } } From abf0b5cf0b345b097faf846d5fb50ff0a98d508a Mon Sep 17 00:00:00 2001 From: edcallaghan Date: Fri, 17 Apr 2026 11:48:11 -0500 Subject: [PATCH 3/6] add digi-level pmp and pedestal into straw hit, to propagate into ntuples --- .../StrawDigisFromArtdaqFragments_module.cc | 134 ++++++++++-------- RecoDataProducts/inc/StrawHit.hh | 17 ++- TrkHitReco/inc/StrawHitRecoUtils.hh | 5 +- TrkHitReco/src/StrawHitRecoUtils.cc | 10 +- TrkHitReco/src/StrawHitReco_module.cc | 7 +- 5 files changed, 103 insertions(+), 70 deletions(-) diff --git a/DAQ/src/StrawDigisFromArtdaqFragments_module.cc b/DAQ/src/StrawDigisFromArtdaqFragments_module.cc index 32629ee139..6bef4020ec 100644 --- a/DAQ/src/StrawDigisFromArtdaqFragments_module.cc +++ b/DAQ/src/StrawDigisFromArtdaqFragments_module.cc @@ -234,11 +234,11 @@ void mu2e::StrawDigisFromArtdaqFragments::print_(const std::string& Message, con } //----------------------------------------------------------------------------- -// HEX print of a fragment, the data has to be in 2-byte words +// HEX print of a fragment, the Mu2e data come in 2-byte words //----------------------------------------------------------------------------- void mu2e::StrawDigisFromArtdaqFragments::print_fragment(const artdaq::Fragment* Frag) { ushort* buf = (ushort*) (Frag->dataBegin()); - int nw = buf[0]/2; + int nw = Frag->dataSizeBytes()/2; int loc = 0; for (int i=0; i>(); if (debugMode_ > 0) { - std::string msg = std::format("n(fragments):{}",fragmentHandles.size()); + std::string msg = std::format("n_fragment_collections):{}",fragmentHandles.size()); print_(msg); } @@ -315,8 +315,13 @@ void mu2e::StrawDigisFromArtdaqFragments::produce(art::Event& event) { // each artdaq fragment corresponds to a single DTC, or a plane // loop over them //----------------------------------------------------------------------------- - int nfrag = handle->size(); - for (int ifrag=0; ifragsize(); + + if (debugMode_) { + print_(std::format("-- next fragment collection with n_fragments:{}",n_fragments)); + } + + for (int ifrag=0; ifragat(ifrag); if (debugMode_ and (debugBit_[0] > 0)) { @@ -325,7 +330,10 @@ void mu2e::StrawDigisFromArtdaqFragments::produce(art::Event& event) { frag->typeString(),sizeof(DTCLib::DTC_SubEventHeader))); print_fragment(frag); } - +//----------------------------------------------------------------------------- +// skip CFO fragment (type = 12) +//----------------------------------------------------------------------------- + if (frag->type() == mu2e::FragmentType::CFO) continue; uint8_t* fdata = (uint8_t*) (frag->dataBegin()); if (not missingDTCHeaders_) { //----------------------------------------------------------------------------- @@ -376,16 +384,36 @@ void mu2e::StrawDigisFromArtdaqFragments::produce(art::Event& event) { // trust that but watch if it changes // so far, any corruptions we saw were contained withing the ROC payload, and nhits // was a reliable number +// 2026-03-20: don't store waveforms if only one packet per hit //----------------------------------------------------------------------------- mu2e::TrackerDataDecoder::TrackerDataPacket* h0; h0 = (mu2e::TrackerDataDecoder::TrackerDataPacket*) (roc_data+packet_size); +//----------------------------------------------------------------------------- +// don't expect zero ADC packets, the error seen was that one of the ROCs just +// doesn't send the second packet at all... work under that assumption +//----------------------------------------------------------------------------- + if (h0->NumADCPackets == 0) { + print_(std::format("ERROR: dtc_id:{} link_id:{} N(ADC packets) = 0, skip ROC data", + dtc_id,(int) rdh->linkID)); + + roc_data += (rdh->packetCount+1)*packet_size; + continue; + } nADCPackets_ = h0->NumADCPackets; nSamples_ = 3+12*nADCPackets_; np_per_hit_ = nADCPackets_+1; } uint32_t link_id = rdh->linkID; nhits = rdh->packetCount/(nADCPackets_+1); - +//----------------------------------------------------------------------------- +// there should not be more than 255 hits per ROC, if nhits>=255 it is a corruption, +// stop processing of the event +//----------------------------------------------------------------------------- + if (nhits > 255) { + print_(std::format("ERROR: nhits:{}, skip event",nhits)); + break; + } + const TrkPanelMap::Row* tpm(nullptr); if (not keyOnMnid_) { tpm = _trackerPanelMap->panel_map_by_online_ind(dtc_id,link_id); @@ -413,6 +441,11 @@ void mu2e::StrawDigisFromArtdaqFragments::produce(art::Event& event) { int offset = (ihit*np_per_hit_+1)*packet_size; // in bytes hit_data = (mu2e::TrackerDataDecoder::TrackerDataPacket*) (roc_data+offset); + if (roc_data+offset >= last_address) { + print_(std::format("ERROR: dtc_id:{} link_id:{} roc_data:{} offset:{} last_address:{} , SKIPPING", + dtc_id, link_id, (void*) roc_data, offset, (void*) last_address)); + break; + } //----------------------------------------------------------------------------- // at this point, check consistency between the channel_id, dtc_id and link_id for a given run // panel ID is a derivative of the DTC ID and the link iD @@ -422,9 +455,9 @@ void mu2e::StrawDigisFromArtdaqFragments::produce(art::Event& event) { uint16_t channel = static_cast(hit_data->StrawIndex); uint16_t chid = mu2e::StrawId(channel).straw(); // channel ID within the panel - if (chid > StrawId::_nstraws) { - print_(std::format("ERROR: hit with corrupted chid:{:04x} : straw:{} / dtc_id:{} link_id:{}, SKIPPING", - hit_data->StrawIndex, chid, dtc_id, link_id)); + if (chid >= StrawId::_nstraws) { + if (debugBit_[52] == 0) print_(std::format("ERROR: hit with corrupted chid:{:04x} : straw:{} / dtc_id:{} link_id:{}, SKIPPING", + hit_data->StrawIndex, chid, dtc_id, link_id)); continue; } @@ -436,7 +469,7 @@ void mu2e::StrawDigisFromArtdaqFragments::produce(art::Event& event) { //----------------------------------------------------------------------------- // bad mnid. Likely, corrupted data block. For now, skip the hit data and proceed with the next hit //----------------------------------------------------------------------------- - print_(std::format("ERROR: corrupted mnid:{}, skip hit data",mnid)); + if (debugBit_[51] == 0) print_(std::format("ERROR: corrupted mnid:{}, skip hit data",mnid)); continue; } } @@ -450,28 +483,6 @@ void mu2e::StrawDigisFromArtdaqFragments::produce(art::Event& event) { //----------------------------------------------------------------------------- digi_flag = mu2e::StrawDigiFlag::corrupted; } -// uint16_t panel_id; -// if (0 < minnesota_map_.count(mnid)){ -// panel_id = minnesota_map_[mnid]; -// } -// //----------------------------------------------------------------------------- -// // in case of a single channel ID error no need to skip the rest of the ROC data - -// // force geographical address and mark the produced digi -// //----------------------------------------------------------------------------- -// else{ -// print_(std::format("ERROR: hit chid:{:04x} inconsistent with the dtc_id:{} and link_id:{}\n", hit_data->StrawIndex, dtc_id, link_id)); -// mn_id = channel_map_[dtc_id][link_id]; -// if (mn_id == StrawDigisFromArtdaqFragments::invalid_minnesota_){ -// std::string msg = "encountered invalid PanelID"; -// throw cet::exception("StrawDigisFromArtdaqFragments") << msg << std::endl; -// } -// if (minnesota_map_.count(mn_id) < 1){ -// std::string msg = "undefined minnesota number in fallback mapping:" + std::to_string(mn_id); -// throw cet::exception("StrawDigisFromArtdaqFragments") << msg << std::endl; -// } -// panel_id = minnesota_map_[mn_id]; -// digi_flag = mu2e::StrawDigiFlag::corrupted; -// } if (hit_data->NumADCPackets != nADCPackets_) { int np = hit_data->NumADCPackets; @@ -507,35 +518,40 @@ void mu2e::StrawDigisFromArtdaqFragments::produce(art::Event& event) { auto digi = straw_digis->back(); digi.digiFlag() = digi_flag; //------------------------------------------------------------------------------ -// the corresponding waveform +// the corresponding waveform, store only if at least the second packet is present (nSamples_ = 15 or more) //----------------------------------------------------------------------------- if (saveWaveforms_) { - std::vector wf(nSamples_); - - wf[0] = hit_data->ADC00; - wf[1] = hit_data->ADC01(); - wf[2] = hit_data->ADC02; - - auto npackets = 0; - auto idx = 2; - auto adc_packet = (mu2e::TrackerDataDecoder::TrackerADCPacket*)((char*) hit_data + 16); // the packet size is 16 bytes - while (npackets < nADCPackets_) { - wf[++idx] = adc_packet->ADC0; - wf[++idx] = adc_packet->ADC1(); - wf[++idx] = adc_packet->ADC2; - wf[++idx] = adc_packet->ADC3; - wf[++idx] = adc_packet->ADC4(); - wf[++idx] = adc_packet->ADC5; - wf[++idx] = adc_packet->ADC6; - wf[++idx] = adc_packet->ADC7(); - wf[++idx] = adc_packet->ADC8; - wf[++idx] = adc_packet->ADC9; - wf[++idx] = adc_packet->ADC10(); - wf[++idx] = adc_packet->ADC11; - npackets++; - adc_packet++; + if (nSamples_ <= 3) { + print_(std::format("ERROR: nSamples:{}, do not store waveforms",nSamples_)); + } + else { + std::vector wf(nSamples_); + + wf[0] = hit_data->ADC00; + wf[1] = hit_data->ADC01(); + wf[2] = hit_data->ADC02; + + auto npackets = 0; + auto idx = 2; + auto adc_packet = (mu2e::TrackerDataDecoder::TrackerADCPacket*)((char*) hit_data + 16); // the packet size is 16 bytes + while (npackets < nADCPackets_) { + wf[++idx] = adc_packet->ADC0; + wf[++idx] = adc_packet->ADC1(); + wf[++idx] = adc_packet->ADC2; + wf[++idx] = adc_packet->ADC3; + wf[++idx] = adc_packet->ADC4(); + wf[++idx] = adc_packet->ADC5; + wf[++idx] = adc_packet->ADC6; + wf[++idx] = adc_packet->ADC7(); + wf[++idx] = adc_packet->ADC8; + wf[++idx] = adc_packet->ADC9; + wf[++idx] = adc_packet->ADC10(); + wf[++idx] = adc_packet->ADC11; + npackets++; + adc_packet++; + } + straw_digi_adcs->emplace_back(wf); } - straw_digi_adcs->emplace_back(wf); } } } diff --git a/RecoDataProducts/inc/StrawHit.hh b/RecoDataProducts/inc/StrawHit.hh index 66b80cb083..0b5d15817e 100644 --- a/RecoDataProducts/inc/StrawHit.hh +++ b/RecoDataProducts/inc/StrawHit.hh @@ -25,6 +25,8 @@ namespace mu2e { TrkTypes::TDCTimes _time; // (ns) TrkTypes::TOTTimes _tot; // (ns) float _energyDep; // (MeV) + float _digital_pmp; // adcs + float _digital_pedestal; // adcs public: @@ -32,7 +34,9 @@ namespace mu2e { _strawId(StrawId(-1)), _time{0.0,0.0}, _tot{0.0,0.0}, - _energyDep(0.){ + _energyDep(0.), + _digital_pmp(0.0), + _digital_pedestal(0.0){ } // Constructor for a hit that came from an unpacked digi, either @@ -40,9 +44,13 @@ namespace mu2e { StrawHit( StrawId strawId, TrkTypes::TDCTimes const& time, TrkTypes::TOTTimes const& tot, - float energyDep ): + float energyDep , + float digital_pmp, + float digital_pedestal): _strawId(strawId),_time(time),_tot(tot), - _energyDep(energyDep) { + _energyDep(energyDep), + _digital_pmp(digital_pmp), + _digital_pedestal(digital_pedestal){ } // Accessors @@ -53,6 +61,9 @@ namespace mu2e { float TOT(StrawEnd end=StrawEnd::cal) const { return _tot[end];} float energyDep() const { return _energyDep; } + float digitalPulseHeight() const { return _digital_pmp; } + float digitialPedestal() const { return _digital_pedestal; } + // Accept compiler generated versions of d'tor, copy c'tor, assignment operator. bool operator==(StrawHit const& other) const { return (_strawId==other._strawId&& diff --git a/TrkHitReco/inc/StrawHitRecoUtils.hh b/TrkHitReco/inc/StrawHitRecoUtils.hh index ea47dc6f16..941db3122c 100644 --- a/TrkHitReco/inc/StrawHitRecoUtils.hh +++ b/TrkHitReco/inc/StrawHitRecoUtils.hh @@ -3,6 +3,7 @@ #include #include +#include #include "Offline/RecoDataProducts/inc/CaloCluster.hh" #include "Offline/RecoDataProducts/inc/StrawDigi.hh" #include "Offline/RecoDataProducts/inc/StrawHit.hh" @@ -34,10 +35,10 @@ namespace mu2e { const CaloClusterCollection *caloClusters, double pbtOffset, StrawId const& sid, TrkTypes::TDCValues const& tdc, TrkTypes::TOTValues const& tot, - double pmp, + double pmp, double pedestal, TrackerStatus const& trackerStatus, StrawResponse const& srep, Tracker const& tt) const; - double peakMinusPedWF(TrkTypes::ADCWaveform const& adcData, StrawResponse const& srep, ADCWFIter& maxiter) const; + std::pair peakMinusPedWF(TrkTypes::ADCWaveform const& adcData, StrawResponse const& srep, ADCWFIter& maxiter) const; private: // algorith parameters diff --git a/TrkHitReco/src/StrawHitRecoUtils.cc b/TrkHitReco/src/StrawHitRecoUtils.cc index 1661c968fd..28634c2d5d 100644 --- a/TrkHitReco/src/StrawHitRecoUtils.cc +++ b/TrkHitReco/src/StrawHitRecoUtils.cc @@ -64,7 +64,7 @@ namespace mu2e { } } - double StrawHitRecoUtils::peakMinusPedWF(TrkTypes::ADCWaveform const& adcData, StrawResponse const& srep, ADCWFIter& maxiter) const { + std::pair StrawHitRecoUtils::peakMinusPedWF(TrkTypes::ADCWaveform const& adcData, StrawResponse const& srep, ADCWFIter& maxiter) const { auto wfstart = adcData.begin() + srep.nADCPreSamples(); auto pedestal = std::accumulate(adcData.begin(), wfstart, 0)/static_cast(srep.nADCPreSamples()); maxiter = wfstart; @@ -74,14 +74,16 @@ namespace mu2e { ++nextIter; } auto peak = *maxiter; - return (peak-pedestal); + auto pmp = peak - pedestal; + auto rv = std::make_pair(pmp, pedestal); + return rv; } bool StrawHitRecoUtils::createComboHit(EventWindowMarker const& ewm, size_t isd, std::unique_ptr const& chCol, std::unique_ptr const& shCol, const CaloClusterCollection* caloClusters, double pbtOffset, StrawId const& sid, TrkTypes::TDCValues const& tdc, TrkTypes::TOTValues const& tot, - double pmp, + double pmp, double pedestal, TrackerStatus const& trackerStatus, StrawResponse const& srep, Tracker const& tt) const { float minT = _minT; @@ -203,7 +205,7 @@ namespace mu2e { chCol->push_back(std::move(ch)); // optionally create legacy straw hit (for diagnostics and calibration) if(_writesh){ - StrawHit hit(sid,times,tots,energy); + StrawHit hit(sid,times,tots,energy,pmp,pedestal); shCol->push_back(std::move(hit)); } return true; diff --git a/TrkHitReco/src/StrawHitReco_module.cc b/TrkHitReco/src/StrawHitReco_module.cc index 1071e86aa4..093380b680 100644 --- a/TrkHitReco/src/StrawHitReco_module.cc +++ b/TrkHitReco/src/StrawHitReco_module.cc @@ -199,6 +199,7 @@ namespace mu2e { TrackerStatus const& trackerStatus = _trackerStatus_h.get(event.id()); double pmp(0.0); + double pedestal(0.0); for (size_t isd=0;isdat(isd).samples(); ADCWFIter maxiter; - pmp = _shrUtils.peakMinusPedWF(adcwf,srep,maxiter); + auto pair = _shrUtils.peakMinusPedWF(adcwf,srep,maxiter); + pmp = pair.first; + pedestal = pair.second; if(_diagLevel > 0)_maxiter->Fill( std::distance(adcwf.begin(),maxiter)); } _shrUtils.createComboHit(ewm, isd, chCol, shCol, caloClusters, pbtOffset, - digi.strawId(), digi.TDC(), digi.TOT(), pmp, + digi.strawId(), digi.TDC(), digi.TOT(), pmp, pedestal, trackerStatus, srep, tt); //flag straw and electronic cross-talk if(_flagXT){ From 6e3b1c96eb57abf7d2414c5424cb081611ccc301 Mon Sep 17 00:00:00 2001 From: edcallaghan Date: Fri, 17 Apr 2026 11:55:45 -0500 Subject: [PATCH 4/6] fix typo --- RecoDataProducts/inc/StrawHit.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RecoDataProducts/inc/StrawHit.hh b/RecoDataProducts/inc/StrawHit.hh index 0b5d15817e..530b6ed8c9 100644 --- a/RecoDataProducts/inc/StrawHit.hh +++ b/RecoDataProducts/inc/StrawHit.hh @@ -62,7 +62,7 @@ namespace mu2e { float energyDep() const { return _energyDep; } float digitalPulseHeight() const { return _digital_pmp; } - float digitialPedestal() const { return _digital_pedestal; } + float digitalPedestal() const { return _digital_pedestal; } // Accept compiler generated versions of d'tor, copy c'tor, assignment operator. bool operator==(StrawHit const& other) const { From 2cd256048f5034b19e2ea456699f505ca1d35dfd Mon Sep 17 00:00:00 2001 From: Mu2e Date: Fri, 17 Apr 2026 20:22:19 -0500 Subject: [PATCH 5/6] - in the trigger, disable individual straws --- DAQ/src/StrawHitFilter_module.cc | 35 +++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/DAQ/src/StrawHitFilter_module.cc b/DAQ/src/StrawHitFilter_module.cc index 1a8ce057ca..2449d27ecc 100644 --- a/DAQ/src/StrawHitFilter_module.cc +++ b/DAQ/src/StrawHitFilter_module.cc @@ -43,7 +43,7 @@ namespace mu2e { fhicl::Atom maxDt {Name("maxDt" ), Comment("max abs(DT)")}; fhicl::Atom minEDep {Name("minEDep" ), Comment("min EDep")}; fhicl::Atom minNGoodHits {Name("minNGoodHits" ), Comment("minNStrawDigis")}; - fhicl::Sequence mnidToSkip {Name("mnidToSkip" ), Comment("a list of panels to skip")}; + fhicl::Sequence channelsToSkip{Name("channelsToSkip"), Comment("a list of channels to skip")}; fhicl::Atom fillHistograms{Name("fillHistograms"), Comment("fill histogrms, default:false")}; }; @@ -54,6 +54,11 @@ namespace mu2e { TH1F* dt ; TH1F* edep; } _hist[2]; + // channels disabled from the trigger + struct Channel_t { + int mnid; + int straw; + }; using Parameters = art::EDFilter::Table; @@ -79,7 +84,7 @@ namespace mu2e { float _maxDt; float _minEDep; int _minNGoodHits; - std::vector _mnidToSkip; // panels not to look at when searching for good hits + std::vector _channelsToSkip; // channels not to look at when searching for good hits int _fillHistograms; int _nevt; @@ -105,7 +110,6 @@ namespace mu2e { _maxDt (conf().maxDt ()), _minEDep (conf().minEDep ()), _minNGoodHits (conf().minNGoodHits()), - _mnidToSkip (conf().mnidToSkip()), _fillHistograms (conf().fillHistograms()) { //----------------------------------------------------------------------------- @@ -120,6 +124,23 @@ namespace mu2e { sscanf(key,"bit%i:%i",&index,&value); _debugBit[index] = value; } +//----------------------------------------------------------------------------- +// parse channels to skip +//----------------------------------------------------------------------------- + int ndat = conf().channelsToSkip().size(); + for (int i=0; imnid, ch->straw); + } + _run_initialized = false; } @@ -233,12 +254,16 @@ namespace mu2e { int hit_mnid = tpm->mnid(); bool skip = false; - for (auto mnid: _mnidToSkip) { - if (hit_mnid == mnid) { + + int n_disabled_channels = _channelsToSkip.size(); + for (int i=0; imnid) and (sh->strawId().straw() == ch->straw)) { skip = true; break; } } + if (skip) continue; if (fabs(sh->dt()) > _maxDt ) continue; From 51ff44eb261373646436aa9ea65103a30dc818a2 Mon Sep 17 00:00:00 2001 From: Mu2e Date: Sat, 23 May 2026 10:02:19 -0500 Subject: [PATCH 6/6] - merge head of offline, update TrkPanelMap --- DAQ/fcl/prolog.fcl | 18 +-- ...CrvDigisFromArtdaqFragmentsFEBII_module.cc | 2 + .../StrawDigisFromArtdaqFragments_module.cc | 46 +++++-- TrackerConditions/data/TrkPanelMap.txt | 122 +++++++++++++++++- 4 files changed, 167 insertions(+), 21 deletions(-) diff --git a/DAQ/fcl/prolog.fcl b/DAQ/fcl/prolog.fcl index fa5cc3bdd0..47d8cba42d 100644 --- a/DAQ/fcl/prolog.fcl +++ b/DAQ/fcl/prolog.fcl @@ -6,13 +6,15 @@ BEGIN_PROLOG DAQ : { producers : { makeSD: { module_type: StrawDigisFromArtdaqFragments - diagLevel : 0 ## not used yet - debugMode : 0 ## - debugBits : [ "bit0:0", "bit1:0" ] ## 100 in total, configure printout details - saveWaveforms : false - missingDTCHeaders: false ## true for runs <= 107246 - keyOnMnid : false ## - geography : [] ## for now, a real job should include a real map + diagLevel : 0 ## not used yet + debugMode : 0 ## + debugBits : [ "bit0:0", "bit1:0" ] ## 100 in total, configure printout details + saveWaveforms : false + missingDTCHeaders : false ## true for runs <= 107246 + keyOnMnid : false ## + geography : [] ## for now, a real job should include a real map + allowOfflineFallbackWhenPanelMapMissing : false + forceOfflineAddressing : false } } @@ -37,7 +39,7 @@ DAQ : { minEDep : 0.0006 ## in MeV debugMode : false debugBits : [ "bit0:0" ] - mnidToSkip : [ ] ## by default all panels are good + channelsToSkip : [ ] ## by default all channels are good fillHistograms : false } } diff --git a/DAQ/src/CrvDigisFromArtdaqFragmentsFEBII_module.cc b/DAQ/src/CrvDigisFromArtdaqFragmentsFEBII_module.cc index 520cd05557..ede4d5828c 100644 --- a/DAQ/src/CrvDigisFromArtdaqFragmentsFEBII_module.cc +++ b/DAQ/src/CrvDigisFromArtdaqFragmentsFEBII_module.cc @@ -351,6 +351,8 @@ namespace mu2e if(_produceNZS) event.put(std::move(crvDigisNZS),"NZS"); event.put(std::move(crvDaqErrors)); event.put(std::move(crvStatus)); + + if(_diagLevel>1) std::cout << std::format("N(CRV digis):{}\n",crvDigis->size()); } } //namespace mu2e diff --git a/DAQ/src/StrawDigisFromArtdaqFragments_module.cc b/DAQ/src/StrawDigisFromArtdaqFragments_module.cc index 6bef4020ec..01ba51b3e4 100644 --- a/DAQ/src/StrawDigisFromArtdaqFragments_module.cc +++ b/DAQ/src/StrawDigisFromArtdaqFragments_module.cc @@ -66,12 +66,18 @@ class mu2e::StrawDigisFromArtdaqFragments : public art::EDProducer { public: struct Config { - fhicl::Atom diagLevel {fhicl::Name("diagLevel" ), fhicl::Comment("diagnostic severity level, default:0" )}; + fhicl::Atom diagLevel {fhicl::Name("diagLevel" ), fhicl::Comment("2026-04-25 PM: OBSOLETE, WILL BE REMOVED SOON")}; fhicl::Atom debugMode {fhicl::Name("debugMode" ), fhicl::Comment("debug mode, default:0" )}; fhicl::Sequence debugBits {fhicl::Name("debugBits" ), fhicl::Comment("debug bits" )}; fhicl::Atom saveWaveforms {fhicl::Name("saveWaveforms" ), fhicl::Comment("save StrawDigiADCWaveforms, default:true" )}; fhicl::Atom missingDTCHeaders{fhicl::Name("missingDTCHeaders"), fhicl::Comment("true for runs <= 107246, default:false" )}; fhicl::Atom keyOnMnid {fhicl::Name("keyOnMnid" ), fhicl::Comment("true if need to key on MnID, default:false")}; + fhicl::Atom allowOfflineFallbackWhenPanelMapMissing{ + fhicl::Name("allowOfflineFallbackWhenPanelMapMissing"), + fhicl::Comment("If TrackerPanelMap lookup fails, decode using offline StrawId(dtc,link,straw)")}; + fhicl::Atom forceOfflineAddressing{ + fhicl::Name("forceOfflineAddressing"), + fhicl::Comment("Ignore TrackerPanelMap/mnid and decode StrawId directly as (dtc,link,straw)")}; // individual tuple specifying a minnesota label, e.g. MN123, // with geographic plane/panel numbers, i.e. from DocDB-#888 @@ -145,6 +151,8 @@ class mu2e::StrawDigisFromArtdaqFragments : public art::EDProducer { bool saveWaveforms_; bool missingDTCHeaders_; bool keyOnMnid_; + bool allowOfflineFallbackWhenPanelMapMissing_; + bool forceOfflineAddressing_; // the rest int nADCPackets_{-1}; // N(ADC packets per hit) int nSamples_ {-1}; // N(ADC samples per hit) @@ -175,6 +183,8 @@ mu2e::StrawDigisFromArtdaqFragments::StrawDigisFromArtdaqFragments(const art::ED saveWaveforms_ (config().saveWaveforms()), missingDTCHeaders_(config().missingDTCHeaders()), keyOnMnid_ (config().keyOnMnid()), + allowOfflineFallbackWhenPanelMapMissing_(config().allowOfflineFallbackWhenPanelMapMissing()), + forceOfflineAddressing_(config().forceOfflineAddressing()), event_ (nullptr) { produces(); @@ -415,17 +425,21 @@ void mu2e::StrawDigisFromArtdaqFragments::produce(art::Event& event) { } const TrkPanelMap::Row* tpm(nullptr); - if (not keyOnMnid_) { + if (!forceOfflineAddressing_ && not keyOnMnid_) { tpm = _trackerPanelMap->panel_map_by_online_ind(dtc_id,link_id); if (tpm == nullptr) { + if (!allowOfflineFallbackWhenPanelMapMissing_) { //----------------------------------------------------------------------------- // either DTC ID or link ID are corrupted. Haven't seen that so far, switch to the next ROC anyway //----------------------------------------------------------------------------- - print_(std::format("ERROR: either dtc_id:{} or link_id:{} is corrupted, skip ROC data", + print_(std::format("ERROR: either dtc_id:{} or link_id:{} is corrupted, skip ROC data", + dtc_id,link_id)); + + roc_data += (nhits*np_per_hit_+1)*packet_size; + continue; + } + print_(std::format("WARNING: no panel map for dtc_id:{} link_id:{}, using offline fallback", dtc_id,link_id)); - - roc_data += (nhits*np_per_hit_+1)*packet_size; - continue; } } @@ -463,18 +477,21 @@ void mu2e::StrawDigisFromArtdaqFragments::produce(art::Event& event) { uint16_t mnid = channel >> mu2e::StrawId::_panelsft; - if (keyOnMnid_) { + if (!forceOfflineAddressing_ && keyOnMnid_) { tpm = _trackerPanelMap->panel_map_by_mnid(mnid); if (tpm == nullptr) { + if (!allowOfflineFallbackWhenPanelMapMissing_) { //----------------------------------------------------------------------------- // bad mnid. Likely, corrupted data block. For now, skip the hit data and proceed with the next hit //----------------------------------------------------------------------------- - if (debugBit_[51] == 0) print_(std::format("ERROR: corrupted mnid:{}, skip hit data",mnid)); - continue; + if (debugBit_[51] == 0) print_(std::format("ERROR: corrupted mnid:{}, skip hit data",mnid)); + continue; + } + print_(std::format("WARNING: no panel map for mnid:{}, using offline fallback",mnid)); } } // in principle, could this could become an 'else if' - if (tpm->mnid() != mnid) { + if (!forceOfflineAddressing_ && tpm != nullptr && tpm->mnid() != mnid) { print_(std::format("ERROR: mnid:{:3d} tpm->mnid():{:3d} hit chid:{:04x} inconsistent with the dtc_id:{:2d} and link_id:{}", mnid,tpm->mnid(),hit_data->StrawIndex, dtc_id, link_id)); //----------------------------------------------------------------------------- @@ -493,7 +510,9 @@ void mu2e::StrawDigisFromArtdaqFragments::produce(art::Event& event) { //----------------------------------------------------------------------------- // convert channel_id into a strawID //----------------------------------------------------------------------------- - mu2e::StrawId sid(tpm->uniquePlane(),tpm->panel(),chid); + mu2e::StrawId sid = (forceOfflineAddressing_ || tpm == nullptr) + ? mu2e::StrawId(dtc_id, link_id, chid) + : mu2e::StrawId(tpm->uniquePlane(), tpm->panel(), chid); mu2e::TrkTypes::TDCValues tdc = {hit_data->TDC0(), hit_data->TDC1()}; mu2e::TrkTypes::TOTValues tot = {hit_data->TOT0 , hit_data->TOT1 }; @@ -505,9 +524,12 @@ void mu2e::StrawDigisFromArtdaqFragments::produce(art::Event& event) { header_printed = 1; } + auto const planeForPrint = (tpm != nullptr) ? tpm->uniquePlane() : dtc_id; + auto const panelForPrint = (tpm != nullptr) ? tpm->panel() : link_id; + int ind = straw_digis->size(); std::cout << std::format("{:5} 0x{:04x} 0x{:04x} MN{:03d} {:3} {:3} 0x:{:04x} {:9} {:9} {:2} {:2} {:5}\n", - ind,offset,hit_data->StrawIndex,mnid,tpm->uniquePlane(),tpm->panel(),sid.straw(),hit_data->TDC0(), + ind,offset,hit_data->StrawIndex,mnid,planeForPrint,panelForPrint,sid.straw(),hit_data->TDC0(), hit_data->TDC1(),tot[0],tot[1],pmp); } diff --git a/TrackerConditions/data/TrkPanelMap.txt b/TrackerConditions/data/TrkPanelMap.txt index 709f3d3e85..1516c43917 100644 --- a/TrackerConditions/data/TrkPanelMap.txt +++ b/TrackerConditions/data/TrkPanelMap.txt @@ -172,7 +172,7 @@ TABLE TrkPanelMap 108000-120470 062, 15, 3, 25, 3, 5, 3 055, 15, 0, 25, 3, 3, 3 #------------------------------------------------------------------------------ -TABLE TrkPanelMap 120471-200000 +TABLE TrkPanelMap 120471-121699 # mnid dtcid link pln ppid pnl zfc #------------------------------------------------------------------------------ # root [1] print_trk_panel_map(0); // slot 0 @@ -244,3 +244,123 @@ TABLE TrkPanelMap 120471-200000 063, 14, 4, 25, 3, 1, 3 062, 14, 3, 25, 3, 5, 3 055, 14, 0, 25, 3, 3, 3 +#------------------------------------------------------------------------------ +TABLE TrkPanelMap 121700-200000 +# mnid dtcid link pln ppid pnl zfc +# root [11] print_trk_panel_map(9) +137, 1, 5, 18, 8, 2, 0 +045, 1, 2, 18, 8, 0, 0 +129, 1, 1, 18, 8, 4, 0 +106, 1, 4, 18, 8, 1, 1 +098, 1, 3, 18, 8, 5, 1 +078, 1, 0, 18, 8, 3, 1 +204, 2, 4, 19, 22, 1, 2 +208, 2, 1, 19, 22, 3, 2 +226, 2, 2, 19, 22, 5, 2 +230, 2, 5, 19, 22, 2, 3 +223, 2, 0, 19, 22, 4, 3 +228, 2, 3, 19, 22, 0, 3 +# root [12] print_trk_panel_map(10) +199, 17, 4, 20, 9, 1, 0 +080, 17, 1, 20, 9, 3, 0 +133, 17, 2, 20, 9, 5, 0 +278, 17, 5, 20, 9, 2, 1 +122, 17, 0, 20, 9, 4, 1 +150, 17, 3, 20, 9, 0, 1 +270, 18, 5, 21, 19, 2, 2 +202, 18, 2, 21, 19, 0, 2 +072, 18, 1, 21, 19, 4, 2 +200, 18, 4, 21, 19, 1, 3 +193, 18, 3, 21, 19, 5, 3 +112, 18, 0, 21, 19, 3, 3 +# root [4] print_trk_panel_map(11) +043, 16, 5, 22, 33, 2, 0 +169, 16, 2, 22, 33, 0, 0 +052, 16, 1, 22, 33, 4, 0 +039, 16, 4, 22, 33, 1, 1 +035, 16, 3, 22, 33, 5, 1 +053, 16, 0, 22, 33, 3, 1 +275, 15, 4, 23, 29, 1, 2 +254, 15, 1, 23, 29, 3, 2 +229, 15, 3, 23, 29, 0, 3 +274, 15, 5, 23, 29, 5, 3 +151, 15, 0, 23, 29, 4, 3 +225, 15, 2, 23, 29, 2, 3 +# root [10] print_trk_panel_map(12) +139, 14, 4, 24, 27, 1, 0 +145, 14, 1, 24, 27, 3, 0 +082, 14, 2, 24, 27, 5, 0 +155, 14, 5, 24, 27, 2, 1 +132, 14, 0, 24, 27, 4, 1 +207, 14, 3, 24, 27, 0, 1 +067, 13, 5, 25, 3, 2, 2 +064, 13, 2, 25, 3, 0, 2 +069, 13, 1, 25, 3, 4, 2 +063, 13, 4, 25, 3, 1, 3 +062, 13, 3, 25, 3, 5, 3 +055, 13, 0, 25, 3, 3, 3 +# root [9] print_trk_panel_map(13) +117, 36, 5, 26, 23, 2, 0 +233, 36, 2, 26, 23, 0, 0 +263, 36, 1, 26, 23, 4, 0 +066, 36, 4, 26, 23, 1, 1 +264, 36, 3, 26, 23, 5, 1 +138, 36, 0, 26, 23, 3, 1 +250, 35, 4, 27, 30, 1, 2 +280, 35, 1, 27, 30, 3, 2 +220, 35, 2, 27, 30, 5, 2 +272, 35, 5, 27, 30, 2, 3 +153, 35, 0, 27, 30, 4, 3 +158, 35, 3, 27, 30, 0, 3 +# root [8] print_trk_panel_map(14) +147, 4, 4, 28, 10, 1, 0 +258, 4, 1, 28, 10, 3, 2 +104, 4, 2, 28, 10, 5, 0 +084, 4, 5, 28, 10, 2, 1 +203, 4, 0, 28, 10, 4, 1 +103, 4, 3, 28, 10, 0, 1 +048, 3, 5, 29, 1, 2, 2 +057, 3, 2, 29, 1, 0, 2 +051, 3, 1, 29, 1, 4, 2 +047, 3, 4, 29, 1, 1, 3 +105, 3, 3, 29, 1, 5, 3 +128, 3, 0, 29, 1, 3, 3 +# root [5] print_trk_panel_map(15) +068, 5, 5, 30, 36, 2, 0 +251, 5, 2, 30, 36, 0, 0 +109, 5, 1, 30, 36, 4, 0 +231, 5, 4, 30, 36, 1, 1 +182, 5, 3, 30, 36, 5, 1 +142, 5, 0, 30, 36, 3, 1 +236, 6, 4, 31, 20, 1, 2 +206, 6, 0, 31, 20, 3, 2 +214, 6, 2, 31, 20, 5, 2 +041, 6, 5, 31, 20, 2, 3 +164, 6, 1, 31, 20, 4, 3 +174, 6, 3, 31, 20, 0, 3 +# root [6] print_trk_panel_map(16) +240, 8, 4, 32, 28, 1, 0 +271, 8, 1, 32, 28, 3, 0 +255, 8, 2, 32, 28, 5, 0 +265, 8, 5, 32, 28, 2, 1 +190, 8, 0, 32, 28, 4, 1 +281, 8, 3, 32, 28, 0, 1 +178, 7, 5, 33, 31, 2, 2 +241, 7, 3, 33, 31, 0, 2 +054, 7, 1, 33, 31, 4, 2 +086, 7, 4, 33, 31, 1, 3 +266, 7, 2, 33, 31, 5, 3 +061, 7, 0, 33, 31, 3, 3 +# root [7] print_trk_panel_map(17) +092, 11, 5, 34, 6, 2, 0 +097, 11, 2, 34, 6, 0, 0 +089, 11, 1, 34, 6, 4, 0 +123, 11, 4, 34, 6, 1, 1 +125, 11, 3, 34, 6, 5, 1 +121, 11, 0, 34, 6, 3, 1 +091, 12, 4, 35, 11, 1, 2 +107, 12, 1, 35, 11, 3, 2 +124, 12, 2, 35, 11, 5, 2 +071, 12, 5, 35, 11, 2, 3 +149, 12, 0, 35, 11, 4, 3 +160, 12, 3, 35, 11, 0, 3