2828#include " sbndcode/Geometry/GeometryWrappers/CRTGeoService.h"
2929#include " sbndcode/Decoders/PTB/sbndptb.h"
3030#include " sbndcode/Timing/SBNDRawTimingObj.h"
31+ #include " sbndcode/ChannelMaps/CRT/CRTChannelMapService.h"
3132
3233#include < memory>
3334#include < bitset>
@@ -56,7 +57,8 @@ class sbnd::crt::CRTStripHitProducer : public art::EDProducer {
5657
5758private:
5859
59- art::ServiceHandle<CRTGeoService> fCRTGeoService ;
60+ art::ServiceHandle<CRTGeoService> fCRTGeoService ;
61+ art::ServiceHandle<SBND::CRTChannelMapService> fCRTChannelMapService ;
6062
6163 std::string fFEBDataModuleLabel ;
6264 uint16_t fADCThreshold ;
@@ -205,14 +207,15 @@ std::vector<sbnd::crt::CRTStripHit> sbnd::crt::CRTStripHitProducer::CreateStripH
205207{
206208 std::vector<CRTStripHit> stripHits;
207209
208- const uint32_t mac5 = data->Mac5 ();
209- uint32_t unixs = data->UnixS ();
210+ const uint32_t offline_module_id = data->Mac5 ();
211+ uint32_t unixs = data->UnixS ();
210212
211213 // Only consider "real data" readouts, not clock resets etc
212214 if (!(data->Flags () == 3 || (fAllowFlag1 && data->Flags () == 1 )))
213215 return stripHits;
214-
215- const CRTModuleGeo module = fCRTGeoService ->GetModule (mac5 * 32 );
216+
217+ const uint32_t offline_channel_id = fCRTChannelMapService ->ConstructOfflineChannelIDFromOfflineModuleIDAndOfflineLocalChannel (offline_module_id, 0 );
218+ const CRTModuleGeo module = fCRTGeoService ->GetModule (offline_channel_id);
216219
217220 // Correct for FEB readout cable length
218221 // (time is FEB-by-FEB not channel-by-channel)
@@ -257,11 +260,11 @@ std::vector<sbnd::crt::CRTStripHit> sbnd::crt::CRTStripHitProducer::CreateStripH
257260 for (unsigned adc_i = 0 ; adc_i < 32 ; adc_i+=2 )
258261 {
259262 // Calculate SiPM channel number
260- const uint16_t channel = mac5 * 32 + adc_i;
263+ const uint16_t offline_channel_id = fCRTChannelMapService -> ConstructOfflineChannelIDFromOfflineModuleIDAndOfflineLocalChannel (offline_module_id, adc_i) ;
261264
262- const CRTStripGeo strip = fCRTGeoService ->GetStrip (channel );
263- const CRTSiPMGeo sipm1 = fCRTGeoService ->GetSiPM (channel );
264- const CRTSiPMGeo sipm2 = fCRTGeoService ->GetSiPM (channel +1 );
265+ const CRTStripGeo strip = fCRTGeoService ->GetStrip (offline_channel_id );
266+ const CRTSiPMGeo sipm1 = fCRTGeoService ->GetSiPM (offline_channel_id );
267+ const CRTSiPMGeo sipm2 = fCRTGeoService ->GetSiPM (offline_channel_id +1 );
265268
266269 if (sipm1.status == CRTChannelStatus::kDeadChannel || sipm2.status == CRTChannelStatus::kDeadChannel )
267270 continue ;
@@ -287,7 +290,7 @@ std::vector<sbnd::crt::CRTStripHit> sbnd::crt::CRTStripHitProducer::CreateStripH
287290 if (pos - err < 0 )
288291 err = pos;
289292
290- stripHits.emplace_back (channel , t0, t1, ref_time_s, pos, err, adc1, adc2);
293+ stripHits.emplace_back (offline_channel_id , t0, t1, ref_time_s, pos, err, adc1, adc2);
291294 }
292295 }
293296
0 commit comments