TpcToolBasedRawDigitPrepService.h
Go to the documentation of this file.
1 // TpcToolBasedRawDigitPrepService.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 TpcData tools.
23 // CallgrindToolNames - Names of the tools for which callgrind should be enabled.
24 
25 #ifndef TpcToolBasedRawDigitPrepService_H
26 #define TpcToolBasedRawDigitPrepService_H
27 
30 #include <map>
31 #include <chrono>
32 
35 
37 
38 public:
39 
40  using Index = unsigned int;
41  using TpcDataToolPtr = std::unique_ptr<TpcDataTool>;
42  struct NamedTool {
44  const TpcDataTool* tool;
45  NamedTool(std::string a_name ="", const TpcDataTool* a_tool =nullptr) : name(a_name), tool(a_tool) { }
46  };
47  using TpcDataToolVector = std::vector<TpcDataToolPtr>;
48  using TpcDataNamedToolVector = 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
std::ostream & print(std::ostream &out=std::cout, std::string prefix="") const override
std::vector< TpcDataToolPtr > TpcDataToolVector
std::string string
Definition: nybbler.cc:12
std::chrono::duration< double > Duration
DECLARE_ART_SERVICE_INTERFACE_IMPL(MySharedService, art::test::MyServiceInterface, SHARED) DEFINE_ART_SERVICE_INTERFACE_IMPL(MySharedService
int beginEvent(const DuneEventInfo &devt) const override
std::unique_ptr< TpcDataTool > TpcDataToolPtr
int prepare(detinfo::DetectorClocksData const &clockData, AdcChannelDataMap &prepdigs, std::vector< recob::Wire > *pwires, WiredAdcChannelDataMap *pintStates) const override
Contains all timing reference information for the detector.
const AdcWireBuildingService * m_pWireBuildingService
int endEvent(const DuneEventInfo &devt) const override
std::map< AdcChannel, AdcChannelData > AdcChannelDataMap
NamedTool(std::string a_name="", const TpcDataTool *a_tool=nullptr)
TpcToolBasedRawDigitPrepService(fhicl::ParameterSet const &pset, art::ActivityRegistry &)