ToolBasedRawDigitPrepService.h
Go to the documentation of this file.
1 // ToolBasedRawDigitPrepService.h
2 //
3 // David Adams
4 // April 2018
5 //
6 // Implementation of service that prepares TPC raw digits for reconstruction.
7 // It receives an ADC channel data map, applies a sequence of ADC channel
8 // tools (calling updateMap) and then constructs wires.
9 //
10 // There is an option to list tools for which callgrind should collect statistics.
11 // If any tools are listed, callgrind should be invoked with "--collect-atstart=no".
12 // Otherwise, callgrind will be disabled when those tools are run.
13 //
14 // Confguration parameters.
15 // LogLevel - logging level
16 // 0 - errors only
17 // 1 - initilization information including configuration
18 // 2 - one line per processed map
19 // 3 - one line for each step (tool call)
20 // 4 - display result from each step
21 // DoWires - If true, the wire building service is called after processing.
22 // ToolNames - Names of the ADC channel tools.
23 // CallgrindToolNames - Names of the tools for which callgrind should be enabled.
24 
25 #ifndef ToolBasedRawDigitPrepService_H
26 #define ToolBasedRawDigitPrepService_H
27 
30 #include <map>
31 #include <chrono>
32 
35 
37 
38 public:
39 
40  using Index = unsigned int;
41  using AdcChannelToolPtr = std::unique_ptr<AdcChannelTool>;
42  struct NamedTool {
45  NamedTool(std::string a_name ="", const AdcChannelTool* a_tool =nullptr) : name(a_name), tool(a_tool) { }
46  };
47  using AdcChannelToolVector = std::vector<AdcChannelToolPtr>;
48  using AdcChannelNamedToolVector = std::vector<NamedTool>;
49 
52 
53  // Called at begin and end of event processing.
54  // Calls the same method for each tool.
55  int beginEvent(const DuneEventInfo& devt) const override;
56  int endEvent(const DuneEventInfo& devt) const override;
57 
58  int prepare(detinfo::DetectorClocksData const& clockData,
59  AdcChannelDataMap& prepdigs,
60  std::vector<recob::Wire>* pwires,
61  WiredAdcChannelDataMap* pintStates) const override;
62 
63  std::ostream& print(std::ostream& out =std::cout, std::string prefix ="") const override;
64 
65 private:
66 
67  // Configuration parameters.
69  bool m_DoWires;
70  std::vector<std::string> m_ToolNames;
71  std::vector<std::string> m_CallgrindToolNames;
72 
76  std::set<std::string> m_cgset;
77 
78  using Clock = std::chrono::steady_clock;
79  using Duration = std::chrono::duration<double>;
80  class State {
81  public:
82  Index nevtBegin = 0;
83  Index nevtEnd = 0;
84  Index ncall = 0;
85  // Timing.
86  std::vector<Duration> toolTimes;
87  };
88  std::unique_ptr<State> m_pstate;
89  State& state() const { return *m_pstate; }
90 
91 };
92 
94 
95 #endif
const AdcWireBuildingService * m_pWireBuildingService
std::chrono::duration< double > Duration
std::vector< AdcChannelToolPtr > AdcChannelToolVector
std::string string
Definition: nybbler.cc:12
DECLARE_ART_SERVICE_INTERFACE_IMPL(MySharedService, art::test::MyServiceInterface, SHARED) DEFINE_ART_SERVICE_INTERFACE_IMPL(MySharedService
NamedTool(std::string a_name="", const AdcChannelTool *a_tool=nullptr)
std::vector< std::string > m_ToolNames
std::ostream & print(std::ostream &out=std::cout, std::string prefix="") const override
int beginEvent(const DuneEventInfo &devt) const override
ToolBasedRawDigitPrepService(fhicl::ParameterSet const &pset, art::ActivityRegistry &)
AdcChannelNamedToolVector m_AdcChannelNamedTools
std::vector< NamedTool > AdcChannelNamedToolVector
int endEvent(const DuneEventInfo &devt) const override
std::unique_ptr< AdcChannelTool > AdcChannelToolPtr
int prepare(detinfo::DetectorClocksData const &clockData, AdcChannelDataMap &prepdigs, std::vector< recob::Wire > *pwires, WiredAdcChannelDataMap *pintStates) const override
std::vector< std::string > m_CallgrindToolNames
Contains all timing reference information for the detector.
std::map< AdcChannel, AdcChannelData > AdcChannelDataMap