31 using std::ostringstream;
39 m_ChannelStatusOnline(false),
40 m_WiresWithoutROIFlag(2),
41 m_DoDump(false), m_DumpChannel(0), m_DumpTick(0),
42 m_pChannelMappingService(0),
43 m_pChannelStatusProvider(nullptr),
44 m_pExtractSvc(nullptr),
45 m_pmitigateSvc(nullptr),
46 m_pAdcSignalFindingService(nullptr),
47 m_pNoiseRemoval(nullptr),
48 m_pPedestalEvaluation(nullptr),
49 m_pDeconvolutionService(nullptr),
50 m_pRoiBuildingService(nullptr),
51 m_pWireBuildingService(nullptr),
52 m_pAdcChannelDataCopyService(nullptr) {
53 const string myname =
"StandardRawDigitPrepService::ctor: ";
71 if (
m_LogLevel ) cout << myname <<
"Fetching extract service." <<
endl;
73 if ( m_SkipBad || m_SkipNoisy ) {
75 if (
m_LogLevel ) cout << myname <<
"Fetching channel mapping service." <<
endl;
77 if (
m_LogLevel ) cout << myname <<
" Channel mapping service: @" 80 if (
m_LogLevel ) cout << myname <<
"Fetching channel status provider." <<
endl;
82 if (
m_LogLevel ) cout << myname <<
" Channel status provider: @" 86 if ( m_DoMitigation ) {
87 if (
m_LogLevel ) cout << myname <<
"Fetching mitigation service." <<
endl;
91 if ( m_DoEarlySignalFinding ) {
92 if (
m_LogLevel ) cout << myname <<
"Fetching signal finding service." <<
endl;
96 if ( m_DoNoiseRemoval ) {
97 if (
m_LogLevel ) cout << myname <<
"Fetching noise removal service." <<
endl;
101 if ( m_DoPedestalAdjustment ) {
102 if (
m_LogLevel ) cout << myname <<
"Fetching pedestal evaluation service." <<
endl;
106 if ( m_DoDeconvolution ) {
107 if (
m_LogLevel ) cout << myname <<
"Fetching deconvolution service." <<
endl;
112 if (
m_LogLevel ) cout << myname <<
"Fetching ROI building service." <<
endl;
117 if (
m_LogLevel ) cout << myname <<
"Fetching wire building service." <<
endl;
121 if ( m_DoIntermediateStates > 0 ) {
122 if (
m_LogLevel ) cout << myname <<
"Fetching intermediate state copying building service." <<
endl;
126 if ( m_DoWires && !m_DoROI ) {
132 if ( ptm ==
nullptr ) {
133 cout << myname <<
"ERROR: Unable to retrieve tool manaager." <<
endl;
135 cout << myname <<
" Fetching display tools: " <<
endl;
137 if (
m_LogLevel ) cout << myname <<
" Fetching " << tname <<
endl;
140 if (
m_LogLevel ) cout << myname <<
" Display tool " << tname <<
": @" << padv.get() <<
endl;
144 cout << myname <<
"ERROR: Unable to retrieve display tool " << tname <<
endl;
158 const string myname =
"StandardRawDigitPrepService:prepare: ";
161 cout << myname <<
"Processing digits..." <<
endl;
162 cout << myname <<
" # input digits: " << datamap.size() <<
endl;
168 vector<AdcChannel> skipChannels;
169 for ( AdcChannelDataMap::value_type& iacd : datamap ) {
172 if (
m_LogLevel >= 3 ) cout << myname <<
"Processing digit for channel " << chan <<
endl;
173 if ( data.
digit ==
nullptr ) {
174 if (
m_LogLevel >= 2 ) cout << myname <<
"Skipping null digit." <<
endl;
175 skipChannels.push_back(chan);
180 cout << myname <<
"ERROR: Inconsistent channel number!" <<
endl;
181 skipChannels.push_back(chan);
185 unsigned int chanstat = chan;
191 if (
m_LogLevel >= 3 ) cout << myname <<
"Skipping bad channel " << chanstat <<
endl;
192 skipChannels.push_back(chan);
196 if (
m_LogLevel >= 3 ) cout << myname <<
"Skipping noisy channel " << chanstat <<
endl;
197 skipChannels.push_back(chan);
201 string state =
"extracted";
203 if (
m_LogLevel >= 3 ) cout << myname <<
"Saving intermediate state " << state <<
"." <<
endl;
205 snames.insert(state);
209 string state =
"mitigated";
211 if (
m_LogLevel >= 3 ) cout << myname <<
"Saving intermediate state " << state <<
"." <<
endl;
213 snames.insert(state);
225 cout << myname <<
"Dumping channel " <<
m_DumpChannel <<
", Tick " << isig <<
endl;
227 if ( datamap.size() == 0 ) {
228 cout <<
"Prepared data is empty." <<
endl;
231 cout <<
" First channel is " << datamap.begin()->first <<
endl;
232 cout <<
" Last channel is " << datamap.end()->first <<
endl;
235 cout << myname <<
" Pedestal: " << datamap[ichan].pedestal <<
endl;
236 if ( isig >= datamap[ichan].
raw.size() ) {
237 cout << myname <<
"Raw data does not include tick. Size is " << datamap[ichan].raw.size() <<
"." <<
endl;
239 cout << myname <<
" raw: " << datamap[ichan].raw[isig] <<
endl;
240 cout << myname <<
" flag: " << datamap[ichan].
flags[isig] <<
endl;
241 cout << myname <<
" After ext: " << datamap[ichan].samples[isig] <<
endl;
247 string state =
"noiseRemoved";
249 if (
m_LogLevel >= 3 ) cout << myname <<
"Saving intermediate state " << state <<
"." <<
endl;
250 for (
const auto& idat : datamap ) {
254 snames.insert(state);
259 for ( AdcChannelDataMap::value_type& chdata : datamap ) {
263 if (
m_DoDump ) cout << myname <<
" After dco: " << datamap[ichan].samples[isig] <<
endl;
265 for (
auto& chdata : datamap ) {
273 for (
auto& chdata : datamap ) {
276 if (
m_DoDump && chdata.first == ichan ) {
278 for (
AdcRoi roi : acd.
rois )
if ( isig >= roi.first && isig <= roi.second ) rois.push_back(roi);
279 cout << myname <<
" After roi: " << rois.size() <<
" of " << acd.
rois.size() <<
" match: ";
280 for (
AdcRoi roi : rois ) cout <<
" (" << roi.first <<
" , " << roi.second <<
")";
288 cout << myname <<
"WARNING: Wire building requested without ROI building." <<
endl;
292 for (
auto& chdata : datamap ) {
296 cout << myname <<
" Wire: " << pwires->back().Signal().at(isig) <<
endl;
299 for (
string sname : snames ) {
301 auto inamedacdmap = intStates.
dataMaps.find(sname);
302 if ( inamedacdmap == intStates.
dataMaps.end() ) {
303 cout << myname <<
"WARNING: State " << sname <<
" does not have data." <<
endl;
306 auto inamedwires = intStates.
wires.find(sname);
307 if ( inamedwires == intStates.
wires.end() ) {
308 cout << myname <<
"WARNING: State " << sname <<
" does not have a wire container." <<
endl;
312 std::vector<recob::Wire>* pwiresState = inamedwires->second;
313 for (
auto& chdata : acdmapState ) {
322 cout << myname <<
" State " << sname <<
" wire: " 323 << pwires->back().Signal().at(isig) <<
endl;
329 unsigned int idto = 0;
330 if (
m_LogLevel >= 2 ) cout << myname <<
"Running display tools." <<
endl;
335 padv->viewMap(datamap);
347 out << prefix <<
"StandardRawDigitPrepService:" <<
endl;
366 cout << prefix <<
" Display tools:";
368 cout <<
" " << tname;
372 cout << prefix <<
"No display tools." <<
endl;
virtual bool IsBad(raw::ChannelID_t channel) const =0
Returns whether the specified channel is bad in the current run.
virtual int update(AdcChannelData &data) const =0
Collection of charge vs time digitized from a single readout channel.
virtual int find(AdcChannelData &data) const =0
virtual int build(AdcChannelData &data) const =0
virtual bool IsNoisy(raw::ChannelID_t channel) const =0
Returns whether the specified channel is noisy in the current run.
const AdcNoiseRemovalService * m_pNoiseRemoval
ChannelID_t Channel() const
DAQ channel this raw data was read from.
std::pair< AdcIndex, AdcIndex > AdcRoi
std::vector< std::string > m_DisplayTools
virtual int evaluate(const AdcChannelData &data, AdcSignal *pped=nullptr, AdcSignal *prms=nullptr, AdcSignal *ppederr=nullptr, AdcSignal *prmserr=nullptr) const =0
bool m_ChannelStatusOnline
const ChannelMappingService * m_pChannelMappingService
const AdcChannelDataCopyService * m_pAdcChannelDataCopyService
const raw::RawDigit * digit
const AdcMitigationService * m_pmitigateSvc
int prepare(detinfo::DetectorClocksData const &clockData, AdcChannelDataMap &prepdigs, std::vector< recob::Wire > *pwires, WiredAdcChannelDataMap *pintStates) const override
const PedestalEvaluationService * m_pPedestalEvaluation
bool m_DoPedestalAdjustment
std::map< Name, AdcChannelDataMap > dataMaps
virtual int build(AdcChannelData &data, WireVector *wires) const =0
virtual int copy(const AdcChannelData &oldacd, AdcChannelData &newacd) const =0
StandardRawDigitPrepService(fhicl::ParameterSet const &pset, art::ActivityRegistry &)
const AdcRoiBuildingService * m_pRoiBuildingService
const AdcWireBuildingService * m_pWireBuildingService
T get(std::string const &key) const
const AdcSignalFindingService * m_pAdcSignalFindingService
std::vector< AdcChannelToolPtr > m_DisplayToolPtrs
const AdcDeconvolutionService * m_pDeconvolutionService
unsigned int m_WiresWithoutROIFlag
virtual int update(AdcChannelDataMap &datamap) const =0
bool m_DoEarlySignalFinding
const lariov::ChannelStatusProvider * m_pChannelStatusProvider
std::map< Name, WireContainer * > wires
bool m_DoIntermediateStates
Contains all timing reference information for the detector.
std::optional< T > get_if_present(std::string const &key) const
Interface for experiment-specific channel quality info provider.
unsigned int m_DumpChannel
std::unique_ptr< AdcChannelTool > AdcChannelToolPtr
std::map< AdcChannel, AdcChannelData > AdcChannelDataMap
Interface for experiment-specific service for channel quality info.
const RawDigitExtractService * m_pExtractSvc
virtual int update(detinfo::DetectorClocksData const &clockData, AdcChannelData &data) const =0
std::vector< std::string > m_FoundDisplayToolNames
QTextStream & endl(QTextStream &s)
virtual Channel online(Channel offlineChannel) const =0
std::ostream & print(std::ostream &out=std::cout, std::string prefix="") const override
#define DEFINE_ART_SERVICE_INTERFACE_IMPL(svc, iface)