WaveformAndSimChannelDump_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: WaveformAndSimChannelDump
3 // Plugin Type: producer (art v2_10_03)
4 // File: WaveformAndSimChannelDump_module.cc
5 ////////////////////////////////////////////////////////////////////////
6 
15 #include "fhiclcpp/ParameterSet.h"
23 #include <memory>
24 #include <fstream>
25 
27 
28 
30 public:
32  // The compiler-generated destructor is fine for non-base
33  // classes without bare pointers or other resource use.
34 
35  // Plugins should not be copied or assigned.
40 
41  // Required functions.
42  void analyze(art::Event const& e) override;
43 
44 private:
45  // The module name of the raw digits we're reading in
50  size_t m_max_channel;
51  std::ofstream m_outputFile_tpc ;
52  std::ofstream m_outputFile_true_tpc;
53 };
54 
55 
57  : EDAnalyzer(p),
58  m_inputTagGEANT (p.get<std::string>("InputTagGEANT" , "largeant")),
59  m_inputTagTPC (p.get<std::string>("InputTagTPC" , "daq" )),
60  m_outputFilename_tpc (p.get<std::string>("OutputFileTPC" ,"OutputFileTPC.txt" )),
61  m_outputFilename_true_tpc(p.get<std::string>("OutputFileTrueTPC","OutputFileTrueTPC.txt")),
62  m_max_channel(p.get<size_t>("MaxChannels", 2560)),
65 {
66 }
67 
69 {
71 
72  // TPC Waveforms
73  size_t n_ticks_tpc = 0;
74  auto const& digits_handle_tpc=e.getValidHandle<std::vector<raw::RawDigit>>(m_inputTagTPC);
75  auto& digits_tpc_in =*digits_handle_tpc;
76  for (auto&& digit: digits_tpc_in) {
77  bool isCollection=geo->SignalType(digit.Channel())==geo::kCollection;
78  if (digit.Channel() >= m_max_channel) continue;
79  m_outputFile_tpc << e.event() << " "
80  << digit.Channel() << " "
81  << isCollection << " ";
82  for(auto const& adc: digit.ADCs()){
83  m_outputFile_tpc << adc << " ";
84  }
85  n_ticks_tpc=digits_tpc_in.at(0).ADCs().size();
86  m_outputFile_tpc << "\n";
87  }
88 
89  // TPC truth
90  auto const& truth_handle_tpc=e.getValidHandle<std::vector<sim::SimChannel>>(m_inputTagGEANT);
91  auto& truth_tpc_in =*truth_handle_tpc;
92  for (auto&& truth: truth_tpc_in) {
93  bool isCollection=geo->SignalType(truth.Channel())==geo::kCollection;
94  if (truth.Channel() >= m_max_channel) continue;
95  m_outputFile_true_tpc << e.event() << " "
96  << truth.Channel() <<" "
97  << isCollection << " ";
98  for(size_t ichge=0; ichge<n_ticks_tpc; ++ichge){
99  m_outputFile_true_tpc << truth.Charge(ichge) << " ";
100  }
101  m_outputFile_true_tpc << "\n";
102  }
103 }
104 
WaveformAndSimChannelDump(fhicl::ParameterSet const &p)
EventNumber_t event() const
Definition: DataViewImpl.cc:85
std::string string
Definition: nybbler.cc:12
int16_t adc
Definition: CRTFragment.hh:202
STL namespace.
SigType_t SignalType(geo::PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
art framework interface to geometry description
const double e
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:441
p
Definition: test.py:223
void analyze(art::Event const &e) override
Declaration of signal hit object.
WaveformAndSimChannelDump & operator=(WaveformAndSimChannelDump const &)=delete
auto const & get(AssnsNode< L, R, D > const &r)
Definition: AssnsNode.h:115
LArSoft geometry interface.
Definition: ChannelGeo.h:16
Signal from collection planes.
Definition: geo_types.h:146