PDDPTPCRawDecoderTest_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: PDDPTPCRawDecoderTest
3 // Plugin Type: analyzer (art v3_02_05)
4 // File: PDDPTPCRawDecoderTest_module.cc
5 //
6 // Generated at Tue Jun 11 16:37:45 2019 by Vyacheslav Galymov using cetskelgen
7 // from cetlib version v3_07_02.
8 ////////////////////////////////////////////////////////////////////////
9 
16 #include "art_root_io/TFileService.h"
18 #include "fhiclcpp/ParameterSet.h"
20 
21 #include "lardataobj/RawData/raw.h"
23 
24 //#include "TH1.h"
25 #include "TH2.h"
26 
27 #include <string>
28 
30 
31 
33 public:
35  // The compiler-generated destructor is fine for non-base
36  // classes without bare pointers or other resource use.
37 
38  // Plugins should not be copied or assigned.
43 
44  // Required functions.
45  void analyze(art::Event const& e) override;
46 
47  // Selected optional functions.
48  void beginJob() override;
49  void endJob() override;
50 
51 private:
52  // Declare member data here.
54  unsigned __Ticks;
55  unsigned __Chans;
56 
57  TH2I* __AdcData;
58 };
59 
60 
62  : EDAnalyzer{p} // ,
63  // More initializers here.
64 {
65  // Call appropriate consumes<>() for any products to be retrieved by this module.
66  __RawDigitLabel = p.get< std::string >("RawDigitLabel");
67  __Ticks = p.get< unsigned >("Ticks");
68  __Chans = p.get< unsigned >("Chans");
69 
70 }
71 
73 {
74  auto Raw = e.getHandle< std::vector<raw::RawDigit> >(__RawDigitLabel);
75  std::vector< art::Ptr<raw::RawDigit> > Digits;
76  art::fill_ptr_vector(Digits, Raw);
77 
78  //loop through all RawDigits (over entire channels)
79  mf::LogInfo("") << "Total number of channels "<<Digits.size();
80 
81  for(auto &digit : Digits)
82  {
83  auto chan = digit->Channel();
84  auto samples = digit->Samples();
85  //mf::LogInfo("") << "vector size " << chan <<" "<< samples;
86 
88  // note: only works with uncompressed data for now
89  raw::Uncompress(digit->ADCs(), data, digit->Compression());
90 
91  if( chan >= __Chans ) break; //continue;
92  unsigned tick = 0;
93  for( auto &adc : data )
94  {
95  if( tick >= __Ticks ) break;
96  __AdcData->Fill( chan, tick++, adc );
97  }
98  }
99 }
100 
102 {
103  // Implementation of optional member function here.
105 
106  // put all channels in single histogram
107  __AdcData = tfs->make<TH2I>( "amc_data","AMC Data",
108  __Chans, 0, __Chans, __Ticks, 0, __Ticks );
109 }
110 
112 {
113  // Implementation of optional member function here.
114 }
115 
void analyze(art::Event const &e) override
Handle< PROD > getHandle(SelectorBase const &) const
Definition: DataViewImpl.h:382
std::string string
Definition: nybbler.cc:12
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::vector< short > ADCvector_t
Type representing a (compressed) vector of ADC counts.
Definition: RawDigit.h:73
int16_t adc
Definition: CRTFragment.hh:202
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
PDDPTPCRawDecoderTest & operator=(PDDPTPCRawDecoderTest const &)=delete
PDDPTPCRawDecoderTest(fhicl::ParameterSet const &p)
const double e
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
Definition: electronics.h:75
p
Definition: test.py:223
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
void Uncompress(const std::vector< short > &adc, std::vector< short > &uncompressed, raw::Compress_t compress)
Uncompresses a raw data buffer.
Definition: raw.cxx:776