recobWireCheck_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: recobWireCheck
3 // Plugin Type: analyzer (art v3_02_06)
4 // File: recobWireCheck_module.cc
5 //
6 // Generated at Thu Oct 3 14:07:32 2019 by Vyacheslav Galymov using cetskelgen
7 // from cetlib version v3_07_02.
8 //
9 // Get some statistics on recob::Wire objects built by DataPrep
10 //
11 ////////////////////////////////////////////////////////////////////////
12 #include <iostream>
13 
21 #include "fhiclcpp/ParameterSet.h"
23 
24 #include "art_root_io/TFileService.h"
25 
26 #include "lardataobj/RawData/raw.h"
27 //#include "lardataobj/RawData/RawDigit.h"
29 
30 #include <TTree.h>
31 
32 
33 #include <algorithm>
34 
35 namespace pddp {
36  class recobWireCheck;
37 }
38 
39 
41 public:
42  explicit recobWireCheck(fhicl::ParameterSet const& p);
43  // The compiler-generated destructor is fine for non-base
44  // classes without bare pointers or other resource use.
45 
46  // Plugins should not be copied or assigned.
47  recobWireCheck(recobWireCheck const&) = delete;
48  recobWireCheck(recobWireCheck&&) = delete;
49  recobWireCheck& operator=(recobWireCheck const&) = delete;
51 
52  // Required functions.
53  void analyze(art::Event const& e) override;
54 
55  // Selected optional functions.
56  void beginJob() override;
57  void endJob() override;
58 
59 private:
60 
61  // Declare member data here.
62  int fLogLevel;
64 
65  //
66  TTree *fTree;
67 
68  float fAdcMax;
69  float fAdcSum;
70  unsigned fChanId;
71  unsigned fTicks;
73  int fEndTick;
74  //int fMaxTick;
75 };
76 
77 
79  : EDAnalyzer{p},
80  fLogLevel( p.get< int >("LogLevel") ),
81  fInputLabel( p.get< std::string >("InputLabel") )
82 {
83  // Call appropriate consumes<>() for any products to be retrieved by this module.
84  //fWireToken = consumes< std::vector<recob::Wire> >(fInputLabel);
85 }
86 
87 //
89 {
90  //auto const& wireHandle = e.getValidHandle(fWireToken);
91  auto wireHandle = e.getHandle< std::vector<recob::Wire> >(fInputLabel);
92  if( !wireHandle )
93  {
94  std::cerr<<"Product "<<fInputLabel<<" was not found\n";
95  }
96 
97  for(size_t wireIter = 0; wireIter < wireHandle->size(); wireIter++)
98  {
99  art::Ptr<recob::Wire> wire(wireHandle, wireIter);
100  fChanId = wire->Channel();
101  const recob::Wire::RegionsOfInterest_t& signals = wire->SignalROI();
102 
103  if( fLogLevel >= 2 ) {
104  std::cout<<"Channel "<<fChanId<<" has number of ROIs "<<signals.n_ranges()<<std::endl;
105  }
106 
107  // loop over regions of interest
108  for (const auto& range : signals.get_ranges())
109  {
110  fStartTick = range.begin_index();
111  fEndTick = range.end_index();
112  fTicks = range.size();
113 
114  fAdcMax = -9999; //*(std::max_element( range.begin(), range.end() ));
115  fAdcSum = 0;
116  for( float adc: range.data() )
117  {
118  fAdcSum += adc;
119  if( adc > fAdcMax ) fAdcMax = adc;
120  }
121 
122  //
123  fTree->Fill();
124  }
125  }
126 }
127 
129 {
131  fTree = tfs->make<TTree>("recobWireTree","recobWire summary tree");
132  fTree->Branch("fChanId", &fChanId, "fChanId/i");
133  fTree->Branch("fTicks", &fTicks, "fTicks/i");
134  fTree->Branch("fStartTick", &fStartTick, "fStartTick/I");
135  fTree->Branch("fEndTick", &fEndTick, "fEndTick/I");
136  fTree->Branch("fAdcMax", &fAdcMax, "fAdcMax/F");
137  fTree->Branch("fAdcSum", &fAdcSum, "fAdcSum/F");
138 }
139 
141 {
142  // Implementation of optional member function here.
143 }
144 
size_type n_ranges() const
Returns the internal list of non-void ranges.
Handle< PROD > getHandle(SelectorBase const &) const
Definition: DataViewImpl.h:382
std::string string
Definition: nybbler.cc:12
recobWireCheck & operator=(recobWireCheck const &)=delete
int16_t adc
Definition: CRTFragment.hh:202
const range_list_t & get_ranges() const
Returns the internal list of non-void ranges.
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
const double e
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
raw::ChannelID_t Channel() const
Returns the ID of the channel (or InvalidChannelID)
Definition: Wire.h:231
p
Definition: test.py:223
const RegionsOfInterest_t & SignalROI() const
Returns the list of regions of interest.
Definition: Wire.h:228
void analyze(art::Event const &e) override
recobWireCheck(fhicl::ParameterSet const &p)
Declaration of basic channel signal object.
QTextStream & endl(QTextStream &s)