Public Member Functions | Private Member Functions | Private Attributes | List of all members
lbne::TpcMilliSliceDump Class Reference
Inheritance diagram for lbne::TpcMilliSliceDump:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Public Member Functions

 TpcMilliSliceDump (fhicl::ParameterSet const &pset)
 
virtual ~TpcMilliSliceDump ()
 
virtual void analyze (art::Event const &evt)
 
- Public Member Functions inherited from art::EDAnalyzer
 EDAnalyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDAnalyzer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Analyzer
virtual ~Analyzer () noexcept
 
 Analyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 Analyzer (Table< Config > const &config)
 
void doBeginJob ()
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Observer
 ~Observer () noexcept
 
 Observer (Observer const &)=delete
 
 Observer (Observer &&)=delete
 
Observeroperator= (Observer const &)=delete
 
Observeroperator= (Observer &&)=delete
 
void registerProducts (ProductDescriptions &, ModuleDescription const &)
 
void fillDescriptions (ModuleDescription const &)
 
std::string const & processName () const
 
bool wantAllEvents () const
 
bool wantEvent (Event const &e)
 
fhicl::ParameterSetID selectorConfig () const
 
Handle< TriggerResultsgetTriggerResults (Event const &e) const
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Member Functions

void beginJob ()
 

Private Attributes

std::string raw_data_label_
 
std::string frag_type_
 
std::vector< int > verb_microslice_ids_
 
std::vector< int > verb_nanoslice_ids_
 
uint32_t verb_nanoslice_adcs_
 
TH1D * adc_values_
 

Additional Inherited Members

- Public Types inherited from art::EDAnalyzer
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 
- Protected Member Functions inherited from art::Observer
 Observer (fhicl::ParameterSet const &config)
 
 Observer (std::vector< std::string > const &paths, fhicl::ParameterSet const &config)
 
detail::ProcessAndEventSelectorsprocessAndEventSelectors ()
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Definition at line 33 of file TpcMilliSliceDump_module.cc.

Constructor & Destructor Documentation

lbne::TpcMilliSliceDump::TpcMilliSliceDump ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 52 of file TpcMilliSliceDump_module.cc.

53 : EDAnalyzer(pset),
54  raw_data_label_(pset.get<std::string>("raw_data_label")),
55  frag_type_(pset.get<std::string>("frag_type")),
56  verb_microslice_ids_(pset.get<std::vector<int>>("verbose_microslice_ids", std::vector<int>(1,0))),
57  verb_nanoslice_ids_ (pset.get<std::vector<int>>("verbose_nanoslice_ids", std::vector<int>(1,0))),
58  verb_nanoslice_adcs_(pset.get<uint32_t> ("verbose_nanoslice_adcs", 6)),
59  adc_values_(nullptr)
60 {
61 }
std::vector< int > verb_microslice_ids_
std::string string
Definition: nybbler.cc:12
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:27
unsigned int uint32_t
Definition: stdint.h:126
std::vector< int > verb_nanoslice_ids_
lbne::TpcMilliSliceDump::~TpcMilliSliceDump ( )
virtual

Definition at line 69 of file TpcMilliSliceDump_module.cc.

70 {
71 }

Member Function Documentation

void lbne::TpcMilliSliceDump::analyze ( art::Event const &  evt)
virtual

Implements art::EDAnalyzer.

Definition at line 73 of file TpcMilliSliceDump_module.cc.

74 {
75  //counter of total number of ALL adc values in the event
76  uint32_t n_adc_counter(0);
77  //cumulative total of ALL adc values in the event
78  uint64_t adc_cumulative(0);
79 
80  art::EventNumber_t eventNumber = evt.event();
81 
82  // ***********************
83  // *** TpcMilliSlice Fragments ***
84  // ***********************
85 
86  // look for raw TpcMilliSlice data
87 
89  evt.getByLabel(raw_data_label_, frag_type_, raw);
90 
91  if (raw.isValid()) {
92  std::cout << "######################################################################" << std::endl;
93  std::cout << std::endl;
94  std::cout << "Run " << evt.run() << ", subrun " << evt.subRun()
95  << ", event " << eventNumber << " has " << raw->size()
96  << " fragment(s) of type " << frag_type_ << std::endl;
97 
98  for (size_t idx = 0; idx < raw->size(); ++idx)
99  {
100  const auto& frag((*raw)[idx]);
101 
102  TpcMilliSliceFragment msf(frag);
103 
104  std::cout << std::endl;
105  std::cout << "TpcMilliSlice fragment " << frag.fragmentID() << " consists of: " << msf.size() << " bytes containing "
106  << msf.microSliceCount() << " microslices" << std::endl;
107  std::cout << std::endl;
108 
109  for (uint32_t i_ms = 0; i_ms < msf.microSliceCount(); ++i_ms)
110  {
111  bool verb_microslice = (std::find(verb_microslice_ids_.begin(), verb_microslice_ids_.end(), i_ms) != verb_microslice_ids_.end()) ? true : false;
112 
113  std::unique_ptr<const TpcMicroSlice> microslice = msf.microSlice(i_ms);
114 
115  if (!microslice) {
116  throw cet::exception("Error in TpcMilliSliceDump module: unable to find requested microslice");
117  }
118 
119  if(verb_microslice) {
120  std::cout << "TpcMilliSlice fragment " << frag.fragmentID()
121  << ", microslice " << i_ms
122  << " has sequence ID " << microslice->sequence_id()
123  << " size " << microslice->size()
124  << " and consists of: "<< microslice->nanoSliceCount() << " nanoslices" << std::endl;
125  }
126 
127  if (microslice->nanoSliceCount() == 0) continue;
128 
129  // First pass through nanoslices listed for verbose output. This is faster than iterating through many nanoslices
130  // and searching for the index in the verbose list
131 
132  for (std::vector<int>::iterator i_nano = verb_nanoslice_ids_.begin(); i_nano != verb_nanoslice_ids_.end(); i_nano++)
133  {
134  bool verb_nanoslice_header = verb_microslice;
135  if (verb_nanoslice_header && (std::find(verb_nanoslice_ids_.begin(), verb_nanoslice_ids_.end(), *i_nano) == verb_nanoslice_ids_.end()))
136  {
137  verb_nanoslice_header = false;
138  }
139 
140  std::unique_ptr<const TpcNanoSlice> nanoslice = microslice->nanoSlice(*i_nano);
141  if (! nanoslice )
142  {
143  throw cet::exception("Error in TpcMilliSliceDump module: Unable to locate requested nanoslice");
144  }
145  if (verb_nanoslice_header)
146  {
147 
148  std::cout << " NanoSlice " << *i_nano << " size " << nanoslice->size() << " bytes" << std::endl << std::endl;
149 
150  const uint64_t* nanoslice_raw = nanoslice->raw();
151 
152  std::cout << " Raw Header : 0x"
153  << std::hex << std::setw(16) << std::setfill('0') << nanoslice_raw[0] <<std::dec << std::endl;
154 
155  std::cout << " Raw Data Payload:" << std::endl << " ";
156  uint16_t num_nanoslice_words = (nanoslice->size() - sizeof(lbne::TpcNanoSlice::Header))/sizeof(uint64_t);
157  size_t word_offset = sizeof(lbne::TpcNanoSlice::Header)/sizeof(uint64_t);
158 
159  for (int i_adc_word = 0; i_adc_word < num_nanoslice_words; i_adc_word++)
160  {
161  std::cout << "0x" << std::hex << std::setfill('0') << std::setw(16) << nanoslice_raw[word_offset+i_adc_word] << std::dec << " ";
162  if ((i_adc_word % 4) == 3) std::cout << std::endl << " ";
163  }
164  std::cout << std::endl;
165 
166  //std::cout << " Decoded Header:" << std::endl;
167  std::cout << " NOvA timestamp : 0x" << std::hex << std::setw(14) << std::setfill('0')
168  << nanoslice->nova_timestamp() << std::dec << std::endl;
169 
170 
171  std::cout << " Decoded ADC Values:" << std::endl << " ";
172  for (uint32_t i_samp = 0; i_samp < nanoslice->getNChannels(); ++i_samp)
173  {
175  nanoslice->sampleValue(i_samp, val);
176  std::cout << std::setfill(' ') << std::setw(4) << i_samp << " : " << std::setw(4) << val << " ";
177  if ((i_samp % 8) == 7) std::cout << std::endl << " ";
178 
179  } // i_samp
180  std::cout << std::endl;
181  }
182  } // i_nano
183 
184  std::cout << std::endl;
185 
186  // Make a second pass through all nanoslices to build some statistics and fill histograms
187  for (uint32_t i_nano = 0; i_nano < microslice->nanoSliceCount(); i_nano++)
188  {
189  std::unique_ptr<const TpcNanoSlice> nanoslice = microslice->nanoSlice(i_nano);
190 
191  if (!nanoslice)
192  {
193  throw cet::exception("Error in TpcMilliSliceDump module: Unable to find requested nanoslice");
194  }
195 
196  for (uint32_t i_samp = 0; i_samp < nanoslice->sampleCount(); i_samp++)
197  {
199  bool success = nanoslice->sampleValue(i_samp, val);
200 
201  if (!success)
202  {
203  throw cet::exception("Error in TpcMilliSliceDump module: Unable to find the requested sample value in nanoslice");
204  }
205  n_adc_counter++;
206  adc_cumulative += (uint64_t)val;
207  adc_values_->Fill(val);
208  } // i_samp
209  } // i_nano
210  } // i_ms
211 
212  } //idx
213 
214  std::cout << std::endl
215  << "Event ADC average is (from counter): " << (double)adc_cumulative/(double)n_adc_counter
216  << std::endl
217  << "Event ADC average is (from histogram): " << adc_values_->GetMean()
218  << std::endl;
219 
220  }//raw.IsValid()?
221  else {
222  std::cout << "Run " << evt.run() << ", subrun " << evt.subRun()
223  << ", event " << eventNumber << " has zero"
224  << " TpcMilliSlice fragments." << std::endl;
225  }
226  std::cout << std::endl;
227 
228 }
intermediate_table::iterator iterator
std::vector< int > verb_microslice_ids_
unsigned int event
Definition: DataStructs.h:574
unsigned int run
Definition: DataStructs.h:575
STL namespace.
unsigned short uint16_t
Definition: stdint.h:125
Raw data description.
QTextStream & hex(QTextStream &s)
bool isValid() const
Definition: Handle.h:183
unsigned int uint32_t
Definition: stdint.h:126
unsigned __int64 uint64_t
Definition: stdint.h:136
static int max(int a, int b)
QTextStream & dec(QTextStream &s)
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
std::vector< int > verb_nanoslice_ids_
IDNumber_t< Level::Event > EventNumber_t
Definition: IDNumber.h:118
unsigned int subRun
Definition: DataStructs.h:576
TCEvent evt
Definition: DataStructs.cxx:7
Q_EXPORT QTSManip setfill(int f)
Definition: qtextstream.h:337
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
void lbne::TpcMilliSliceDump::beginJob ( )
privatevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 63 of file TpcMilliSliceDump_module.cc.

64 {
66  adc_values_ = tfs->make<TH1D>("adc_values","adc_values",4096,-0.5,4095.5);
67 }

Member Data Documentation

TH1D* lbne::TpcMilliSliceDump::adc_values_
private

Definition at line 48 of file TpcMilliSliceDump_module.cc.

std::string lbne::TpcMilliSliceDump::frag_type_
private

Definition at line 44 of file TpcMilliSliceDump_module.cc.

std::string lbne::TpcMilliSliceDump::raw_data_label_
private

Definition at line 43 of file TpcMilliSliceDump_module.cc.

std::vector<int> lbne::TpcMilliSliceDump::verb_microslice_ids_
private

Definition at line 45 of file TpcMilliSliceDump_module.cc.

uint32_t lbne::TpcMilliSliceDump::verb_nanoslice_adcs_
private

Definition at line 47 of file TpcMilliSliceDump_module.cc.

std::vector<int> lbne::TpcMilliSliceDump::verb_nanoslice_ids_
private

Definition at line 46 of file TpcMilliSliceDump_module.cc.


The documentation for this class was generated from the following file: