DataDump_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: DataDump
3 // Plugin Type: analyzer (art v3_03_01)
4 // File: DataDump_module.cc
5 //
6 // Generated at Tue Nov 19 13:37:52 2019 by Tingjun Yang using cetskelgen
7 // from cetlib version v3_08_00.
8 ////////////////////////////////////////////////////////////////////////
9 
17 #include "fhiclcpp/ParameterSet.h"
19 #include "art_root_io/TFileService.h"
20 
24 
25 #include "TTree.h"
26 #include "TTimeStamp.h"
27 
28 #include <fstream>
29 #include <vector>
30 
31 namespace pdune {
32  class DataDump;
33 }
34 
35 
37 public:
38  explicit DataDump(fhicl::ParameterSet const& p);
39  // The compiler-generated destructor is fine for non-base
40  // classes without bare pointers or other resource use.
41 
42  // Plugins should not be copied or assigned.
43  DataDump(DataDump const&) = delete;
44  DataDump(DataDump&&) = delete;
45  DataDump& operator=(DataDump const&) = delete;
46  DataDump& operator=(DataDump&&) = delete;
47 
48  // Required functions.
49  void analyze(art::Event const& e) override;
50 
51  // Selected optional functions.
52  void beginJob() override;
53 
54 private:
55 
56 //geo::GeometryCore const* fGeom;
57  TTree *fTree;
58  unsigned int run;
59  unsigned int event;
60  double evttime;
61  std::vector<unsigned short> channel;
62  std::vector<unsigned short> tick;
63  std::vector<float> adc;
64 };
65 
66 
68  : EDAnalyzer{p} // ,
69  // More initializers here.
70 {
71  // Call appropriate consumes<>() for any products to be retrieved by this module.
72 }
73 
75 {
76 
77 //fGeom = &*(art::ServiceHandle<geo::Geometry>());
78 
79  run = e.run();
80  event = e.id().event();
81 
82  art::Timestamp ts = e.time();
83  if (ts.timeHigh() == 0){
84  TTimeStamp tts(ts.timeLow());
85  evttime = tts.AsDouble();
86  }
87  else{
88  TTimeStamp tts(ts.timeHigh(), ts.timeLow());
89  evttime = tts.AsDouble();
90  }
91  channel.clear();
92  tick.clear();
93  adc.clear();
94 
95  //std::ofstream outfile (Form("r%de%d.txt",run,event));
96 
97  auto const& wires =
98  e.getValidHandle<std::vector<recob::Wire> >("caldata:dataprep");
99 
100  for (auto & wire : * wires){
101  int channel_no = wire.Channel();
102  std::cout<<"Channel = "<<channel_no<<std::endl;
103  if (channel_no<2080 || channel_no > 2559) continue;
104  //for (auto & adc : wire.Signal()){
105  for (size_t i = 0; i < wire.Signal().size(); ++i){
106  //outfile<<channel<<" "<<i<<" "<<wire.Signal()[i]<<std::endl;
107  channel.push_back(channel_no);
108  tick.push_back(i);
109  adc.push_back(wire.Signal()[i]);
110  }
111  }
112  fTree->Fill();
113  //outfile.close();
114 }
115 
117 {
119  fTree = tfs->make<TTree>("spt","space point tree");
120  fTree->Branch("run",&run,"run/I");
121  fTree->Branch("event",&event,"event/I");
122  fTree->Branch("evttime",&evttime,"evttime/D");
123  fTree->Branch("channel", &channel);
124  fTree->Branch("tick",&tick);
125  fTree->Branch("adc",&adc);
126 }
unsigned int event
constexpr std::uint32_t timeLow() const
Definition: Timestamp.h:29
void beginJob() override
std::vector< float > adc
constexpr std::uint32_t timeHigh() const
Definition: Timestamp.h:34
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
art framework interface to geometry description
std::vector< unsigned short > tick
const double e
Timestamp time() const
#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
RunNumber_t run() const
Definition: DataViewImpl.cc:71
unsigned int run
DataDump & operator=(DataDump const &)=delete
std::vector< unsigned short > channel
EventNumber_t event() const
Definition: EventID.h:116
Declaration of basic channel signal object.
DataDump(fhicl::ParameterSet const &p)
void analyze(art::Event const &e) override
EventID id() const
Definition: Event.cc:34
QTextStream & endl(QTextStream &s)
Event finding and building.