All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
daq::PMTDecoder Class Reference

Turns PMT readout fragments from DAQ into LArSoft data products. More...

Inheritance diagram for daq::PMTDecoder:
daq::IDecoder

Classes

struct  BoardSetupConfig
 Configuration of the V1730 readout board setup. More...
 
struct  Config
 Main tool configuration. More...
 
struct  NeededBoardInfo_t
 Information used in decoding from a board. More...
 
struct  SplitTimestamp_t
 Data structure for trigger time. More...
 
struct  TreeData_EventID_t
 Data structure for basic event information in simple ROOT trees. More...
 
struct  TreeFragment_t
 Structure collecting all data for a fragment ROOT tree. More...
 

Public Types

using nanoseconds = util::quantities::intervals::nanoseconds
 Alias. More...
 
using Parameters = art::ToolConfigTable< Config >
 

Public Member Functions

 PMTDecoder (Parameters const &params)
 Constructor. More...
 
virtual void consumes (art::ConsumesCollector &consumerColl) override
 I hereby declare I will consume trigger and PMT configuration products. More...
 
virtual void produces (art::ProducesCollector &) override
 Each algorithm may have different objects it wants "produced" so use this to let the top level producer module "know" what it is outputting. More...
 
virtual void configure (const fhicl::ParameterSet &) override
 Reconfiguration is not supported: all configuration at construction time. More...
 
virtual void setupRun (art::Run const &run) override
 Reads the PMT configuration from the run. More...
 
virtual void setupEvent (art::Event const &event) override
 Will read trigger information one day if needed. More...
 
virtual void initializeDataProducts () override
 Initialize any data products the tool will output. More...
 
virtual void process_fragment (const artdaq::Fragment &fragment) override
 Given a set of recob hits, run DBscan to form 3D clusters. More...
 
virtual void outputDataProducts (art::Event &event) override
 Output the data products to the event store. More...
 
- Public Member Functions inherited from daq::IDecoder
virtual ~IDecoder () noexcept=default
 Virtual Destructor. More...
 

Private Types

enum  DataTrees : std::size_t { DataTrees::Fragments, DataTrees::N }
 Enumerate the supported data trees. More...
 
using TreeNameList_t = std::array< std::string, static_cast< std::size_t >(DataTrees::N)>
 
using OpDetWaveformCollection = std::vector< raw::OpDetWaveform >
 
using OpDetWaveformCollectionPtr = std::unique_ptr< OpDetWaveformCollection >
 

Private Member Functions

bool hasPMTconfiguration () const
 Returns whether PMT configuration information is expected to be available. More...
 
bool UpdatePMTConfiguration (sbn::PMTconfiguration const *PMTconfig)
 Updates the PMT configuration cache. How? Dunno. Placeholder. More...
 
details::BoardInfoLookup matchBoardConfigurationAndSetup (sbn::PMTconfiguration const *PMTconfig) const
 Returns a lookup object with board setup and configuration info. More...
 
NeededBoardInfo_t fetchNeededBoardInfo (details::BoardInfoLookup::BoardInfo_t const *boardInfo, unsigned int fragmentID) const
 Puts together all the needed information for a board. More...
 
template<std::size_t NBits, typename T >
constexpr std::pair
< std::array< std::size_t,
NBits >, std::size_t > 
setBitIndices (T value) noexcept
 Returns the count of set bits for each set bit. More...
 
void usesEventInfo ()
 Declares the use of event information. More...
 
void initTrees (std::vector< std::string > const &treeNames)
 Initializes all requested data trees. More...
 
void initEventIDtree (TTree &tree, TreeData_EventID_t &data)
 Initializes the event ID part of a tree. More...
 
void initFragmentsTree ()
 Initializes the fragment data tree (fTreeFragment). More...
 
void fillTreeEventID (art::Event const &event, TreeData_EventID_t &treeData) const
 Fills the base information of a tree data entry from an art event. More...
 
void assignEventInfo (TreeData_EventID_t &treeData) const
 Assigns the cached event information to the specified tree data. More...
 

Static Private Member Functions

static std::string listTreeNames (std::string const &sep="\n")
 Returns a string with all supported tree names. More...
 
static TreeNameList_t initTreeNames ()
 Static initialization. More...
 

Private Attributes

bool const fDiagnosticOutput
 If true will spew endless messages to output. More...
 
bool const fRequireKnownBoards
 Whether info on all input boards is required. More...
 
bool const fRequireBoardConfig
 Whether setup info on all boards is required. More...
 
std::optional< art::InputTag >
const 
fPMTconfigTag
 Input tag of the PMT configuration. More...
 
art::InputTag const fTriggerTag
 Input tag of the global trigger. More...
 
std::vector
< details::BoardSetup_t >
const 
fBoardSetup
 All board setup settings. More...
 
std::string const fLogCategory
 Message facility category. More...
 
geo::GeometryCore const & fGeometry
 Geometry service provider. More...
 
detinfo::DetectorTimings const fDetTimings
 Interface to LArSoft configuration for detector timing. More...
 
icarusDB::IICARUSChannelMap const & fChannelMap
 Fragment/channel mapping database. More...
 
nanoseconds const fOpticalTick
 Duration of the optical detector readout sampling tick (i.e. 2 ns; shh!). More...
 
detinfo::timescales::electronics_time
const 
fNominalTriggerTime
 Trigger time as reported by DetectorClocks service. More...
 
OpDetWaveformCollectionPtr fOpDetWaveformCollection
 The output data collection pointer. More...
 
std::optional
< details::BoardInfoLookup
fBoardInfoLookup
 Find the information on a readout boards by fragment ID. More...
 
SplitTimestamp_t fTriggerTimestamp
 Trigger timestamp for the current event. More...
 
std::unique_ptr
< TreeData_EventID_t
fEventInfo
 Event ID for trees. More...
 
std::unique_ptr< TreeFragment_tfTreeFragment
 Tree with fragment information. More...
 

Static Private Attributes

static TreeNameList_t const TreeNames = daq::PMTDecoder::initTreeNames()
 

Detailed Description

Turns PMT readout fragments from DAQ into LArSoft data products.

The tool can read fragments from CAEN V1730 readout boards delivered by artDAQ.

This decoder must support both a off-line mode (for storage and downstream processing) and a on-line mode (for monitoring). In particular, the on-line workflow is such that it may not be possible to access the FHiCL configuration of the job and therefore the PMT configuration data (see icarus::PMTconfigurationExtraction module).

Configuration

The set of supported parameters can be seen on command line by running lar --print-description PMTDecoder.

Description of the configuration parameters:

Requirements

Services required include:

Waveform time stamp

All waveforms on the same readout board share the same timestamp.

The time stamp of the waveform is defined as the time when the first sample of the waveform started (that is, if the sample represent the value of the signal in an interval of 2 ns, the time stamp is pointing at the beginning of those 2 ns). Whether we can honour that definition, though, is a different matter. The representation of the time stamp is in the electronics time scale.

There are two "types" of waveforms: the ones acquired at global trigger time, and the ones acquired because of a "trigger primitive" which did not upgrade to global (likely because not in coincidence with the beam gate). In both cases, it is the same type of signal, a trigger primitive from the NI7820 FPGA, which initializes the acquisition of the waveform. Every delay between when that signal is emitted and when the PMT trigger is executed shifts the time stamp of the waveform backward.

We assign the the time stamp of the waveforms matching the global trigger as follow:

We do not assign the the time stamp of the waveforms not matching the global trigger because we have no clue how to do that. Ok, that is a to-do!

Each V1730 event record includes a trigger time tag (TTT), which is the value of an internal counter of the board at the time the board received a trigger. This can be used to relate the various waveforms (and the various fragments) in the art event.

Data trees

The tool supports the following ROOT trees production on demand:

Technical notes

In order to correctly reconstruct the time stamp, this tool needs several pieces of information. These include the size of the pre-trigger buffer, which is set by the readout board configuration, and the delay between the global trigger and the time that trigger is received and acted upon in the readout board, which needs to be measured. The first category of information, from readout board configuration, are read from the input file (sbn::PMTconfiguration), while the second category needs to be specified in the tool FHiCL configuration.

PMT configuration is optional, in the sense that it can be omitted; in that case, some standard values will be used for it. For a board to be served, an entry of that board must be present in the tool configuration (BoardSetup). It is an error for a fragment in input not to have an entry for the corresponding board setup.

The tool code extract the needed information and matches it into a sort-of-database keyed by fragment ID, so that it can be quickly applied when decoding a fragment. The matching is performed by board name.

Glossary

Definition at line 267 of file PMTDecoder_tool.cc.

Member Typedef Documentation

Alias.

Definition at line 284 of file PMTDecoder_tool.cc.

Definition at line 485 of file PMTDecoder_tool.cc.

Definition at line 486 of file PMTDecoder_tool.cc.

using daq::PMTDecoder::Parameters = art::ToolConfigTable<Config>

Definition at line 384 of file PMTDecoder_tool.cc.

using daq::PMTDecoder::TreeNameList_t = std::array<std::string, static_cast<std::size_t>(DataTrees::N)>
private

Definition at line 276 of file PMTDecoder_tool.cc.

Member Enumeration Documentation

enum daq::PMTDecoder::DataTrees : std::size_t
strongprivate

Enumerate the supported data trees.

Enumerator
Fragments 

Information about fragments.

N 

Counter.

Definition at line 271 of file PMTDecoder_tool.cc.

271  : std::size_t {
272  Fragments, ///< Information about fragments
273  N ///< Counter.
274  };
process_name largeant stream1 can override from command line with o or output physics producers generator N

Constructor & Destructor Documentation

daq::PMTDecoder::PMTDecoder ( Parameters const &  params)
explicit

Constructor.

Parameters
paramsconfiguration parameter set

Definition at line 680 of file PMTDecoder_tool.cc.

681  : fDiagnosticOutput{ params().DiagnosticOutput() }
682  , fRequireKnownBoards{ params().RequireKnownBoards() }
683  , fRequireBoardConfig{ params().RequireBoardConfig() }
684  , fPMTconfigTag{ ::util::fhicl::getOptionalValue(params().PMTconfigTag) }
685  , fTriggerTag{ params().TriggerTag() }
686  , fBoardSetup{ params().BoardSetup() }
687  , fLogCategory{ params().LogCategory() }
688  , fGeometry{ *(lar::providerFrom<geo::Geometry const>()) }
689  , fDetTimings
690  { art::ServiceHandle<detinfo::DetectorClocksService const>()->DataForJob() }
691  , fChannelMap{ *(art::ServiceHandle<icarusDB::IICARUSChannelMap const>{}) }
detinfo::DetectorTimings const fDetTimings
Interface to LArSoft configuration for detector timing.
icarusDB::IICARUSChannelMap const & fChannelMap
Fragment/channel mapping database.
std::vector< details::BoardSetup_t > const fBoardSetup
All board setup settings.
std::optional< typename Optional::value_type > getOptionalValue(Optional const &parameter)
Returns the value of an optional parameter as std::optional.
Definition: FHiCLutils.h:188
bool const fRequireKnownBoards
Whether info on all input boards is required.
geo::GeometryCore const & fGeometry
Geometry service provider.
std::optional< art::InputTag > const fPMTconfigTag
Input tag of the PMT configuration.
bool const fDiagnosticOutput
If true will spew endless messages to output.
bool const fRequireBoardConfig
Whether setup info on all boards is required.
std::string const fLogCategory
Message facility category.
art::InputTag const fTriggerTag
Input tag of the global trigger.

Member Function Documentation

void daq::PMTDecoder::assignEventInfo ( TreeData_EventID_t treeData) const
private

Assigns the cached event information to the specified tree data.

virtual void daq::PMTDecoder::configure ( const fhicl::ParameterSet &  )
overridevirtual

Reconfiguration is not supported: all configuration at construction time.

Implements daq::IDecoder.

virtual void daq::PMTDecoder::consumes ( art::ConsumesCollector &  consumerColl)
overridevirtual

I hereby declare I will consume trigger and PMT configuration products.

Reimplemented from daq::IDecoder.

NeededBoardInfo_t daq::PMTDecoder::fetchNeededBoardInfo ( details::BoardInfoLookup::BoardInfo_t const *  boardInfo,
unsigned int  fragmentID 
) const
private

Puts together all the needed information for a board.

void daq::PMTDecoder::fillTreeEventID ( art::Event const &  event,
TreeData_EventID_t treeData 
) const
private

Fills the base information of a tree data entry from an art event.

bool daq::PMTDecoder::hasPMTconfiguration ( ) const
inlineprivate

Returns whether PMT configuration information is expected to be available.

Definition at line 499 of file PMTDecoder_tool.cc.

499 { return fPMTconfigTag.has_value(); }
std::optional< art::InputTag > const fPMTconfigTag
Input tag of the PMT configuration.
void daq::PMTDecoder::initEventIDtree ( TTree &  tree,
TreeData_EventID_t data 
)
private

Initializes the event ID part of a tree.

void daq::PMTDecoder::initFragmentsTree ( )
private

Initializes the fragment data tree (fTreeFragment).

virtual void daq::PMTDecoder::initializeDataProducts ( )
overridevirtual

Initialize any data products the tool will output.

Implements daq::IDecoder.

auto daq::PMTDecoder::initTreeNames ( )
staticprivate

Static initialization.

Definition at line 661 of file PMTDecoder_tool.cc.

661  {
663  names[static_cast<std::size_t>(DataTrees::Fragments)] = "PMTfragments";
664  return names;
665 } // daq::PMTDecoder::initTreeNames()
Information about fragments.
std::array< std::string, static_cast< std::size_t >(DataTrees::N)> TreeNameList_t
static const std::vector< std::string > names
void daq::PMTDecoder::initTrees ( std::vector< std::string > const &  treeNames)
private

Initializes all requested data trees.

std::string daq::PMTDecoder::listTreeNames ( std::string const &  sep = "\n")
staticprivate

Returns a string with all supported tree names.

Definition at line 667 of file PMTDecoder_tool.cc.

667  {
668  std::string l;
669  for (std::string const& name: TreeNames) {
670  if (!l.empty()) l += sep;
671  l += '\'';
672  l += name;
673  l += '\'';
674  } // for
675  return l;
676 } // daq::PMTDecoder::listTreeNames()
static TreeNameList_t const TreeNames
then echo fcl name
details::BoardInfoLookup daq::PMTDecoder::matchBoardConfigurationAndSetup ( sbn::PMTconfiguration const *  PMTconfig) const
private

Returns a lookup object with board setup and configuration info.

Parameters
PMTconfigthe PMT configuration, if available
Returns
an object working like lookup table for all fragment information

This method merges the setup information from the tool configuration with the PMT configuration specified in the argument, and returns an object that can look up all the information as a single record, with the fragment ID as key. In addition, a few intermediate quantities ("facts", see BoardFacts_t) are computed and stored in this object.

If a fragment ID is missing, it means that no PMT configuration was provided and that the setup information did not include a fragment ID. If some information (configuration or setup) is missing, the "facts" depending on the missing information will have default values.

virtual void daq::PMTDecoder::outputDataProducts ( art::Event &  event)
overridevirtual

Output the data products to the event store.

Parameters
eventThe event store objects

Implements daq::IDecoder.

virtual void daq::PMTDecoder::process_fragment ( const artdaq::Fragment &  fragment)
overridevirtual

Given a set of recob hits, run DBscan to form 3D clusters.

Parameters
fragmentThe artdaq fragment to process
rawDigitColllectionThe output RawDigits

Implements daq::IDecoder.

virtual void daq::PMTDecoder::produces ( art::ProducesCollector &  )
overridevirtual

Each algorithm may have different objects it wants "produced" so use this to let the top level producer module "know" what it is outputting.

Implements daq::IDecoder.

template<std::size_t NBits, typename T >
constexpr std::pair<std::array<std::size_t, NBits>, std::size_t> daq::PMTDecoder::setBitIndices ( value)
privatenoexcept

Returns the count of set bits for each set bit.

Template Parameters
NBitsthe number of bits to test
Parameters
valuethe bit mask to be analyzed
Returns
a pair: first an array with the NBits values, second the number of bits set

Much better to go with an example. Let's process setBitIndices<16U>(0x6701): value is 0110 0111 0000 0001, and we request the 16 least significant bits (NBits). There are six bit that are set, in position 0, 8, 9, 10, 13 and 14. The returned value includes the number of set bits (6) as the second element of the pair, an as first an array of 16 indices, one for each bit position. Its values are 0 at [0], 1 at [8], 2 at [9], 3 at [10], 4 at [13] and 5 at [14]. That is, each value represents the number of that bit in the list of set bits. All the other indices, associated to the bits which are not set, are assigned a value that is equal or larger than the number of bits set (i.e. 6 or larger).

virtual void daq::PMTDecoder::setupEvent ( art::Event const &  event)
overridevirtual

Will read trigger information one day if needed.

Reimplemented from daq::IDecoder.

virtual void daq::PMTDecoder::setupRun ( art::Run const &  run)
overridevirtual

Reads the PMT configuration from the run.

Reimplemented from daq::IDecoder.

bool daq::PMTDecoder::UpdatePMTConfiguration ( sbn::PMTconfiguration const *  PMTconfig)
private

Updates the PMT configuration cache. How? Dunno. Placeholder.

void daq::PMTDecoder::usesEventInfo ( )
private

Declares the use of event information.

Member Data Documentation

std::optional<details::BoardInfoLookup> daq::PMTDecoder::fBoardInfoLookup
private

Find the information on a readout boards by fragment ID.

Definition at line 491 of file PMTDecoder_tool.cc.

std::vector<details::BoardSetup_t> const daq::PMTDecoder::fBoardSetup
private

All board setup settings.

Definition at line 455 of file PMTDecoder_tool.cc.

icarusDB::IICARUSChannelMap const& daq::PMTDecoder::fChannelMap
private

Fragment/channel mapping database.

Definition at line 469 of file PMTDecoder_tool.cc.

detinfo::DetectorTimings const daq::PMTDecoder::fDetTimings
private

Interface to LArSoft configuration for detector timing.

Definition at line 467 of file PMTDecoder_tool.cc.

bool const daq::PMTDecoder::fDiagnosticOutput
private

If true will spew endless messages to output.

Definition at line 446 of file PMTDecoder_tool.cc.

std::unique_ptr<TreeData_EventID_t> daq::PMTDecoder::fEventInfo
private

Event ID for trees.

Definition at line 582 of file PMTDecoder_tool.cc.

geo::GeometryCore const& daq::PMTDecoder::fGeometry
private

Geometry service provider.

Definition at line 464 of file PMTDecoder_tool.cc.

std::string const daq::PMTDecoder::fLogCategory
private

Message facility category.

Definition at line 457 of file PMTDecoder_tool.cc.

detinfo::timescales::electronics_time const daq::PMTDecoder::fNominalTriggerTime
private

Trigger time as reported by DetectorClocks service.

Definition at line 480 of file PMTDecoder_tool.cc.

OpDetWaveformCollectionPtr daq::PMTDecoder::fOpDetWaveformCollection
private

The output data collection pointer.

Definition at line 488 of file PMTDecoder_tool.cc.

nanoseconds const daq::PMTDecoder::fOpticalTick
private

Duration of the optical detector readout sampling tick (i.e. 2 ns; shh!).

Definition at line 477 of file PMTDecoder_tool.cc.

std::optional<art::InputTag> const daq::PMTDecoder::fPMTconfigTag
private

Input tag of the PMT configuration.

Definition at line 451 of file PMTDecoder_tool.cc.

bool const daq::PMTDecoder::fRequireBoardConfig
private

Whether setup info on all boards is required.

Definition at line 449 of file PMTDecoder_tool.cc.

bool const daq::PMTDecoder::fRequireKnownBoards
private

Whether info on all input boards is required.

Definition at line 448 of file PMTDecoder_tool.cc.

std::unique_ptr<TreeFragment_t> daq::PMTDecoder::fTreeFragment
private

Tree with fragment information.

Definition at line 583 of file PMTDecoder_tool.cc.

art::InputTag const daq::PMTDecoder::fTriggerTag
private

Input tag of the global trigger.

Definition at line 453 of file PMTDecoder_tool.cc.

SplitTimestamp_t daq::PMTDecoder::fTriggerTimestamp
private

Trigger timestamp for the current event.

Definition at line 495 of file PMTDecoder_tool.cc.

daq::PMTDecoder::TreeNameList_t const daq::PMTDecoder::TreeNames = daq::PMTDecoder::initTreeNames()
staticprivate

Definition at line 277 of file PMTDecoder_tool.cc.


The documentation for this class was generated from the following file: