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

Public Member Functions

 SSPDump (fhicl::ParameterSet const &pset)
 
virtual ~SSPDump ()
 
virtual void analyze (art::Event const &evt) override
 
- 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 () override
 
void endJob () override
 
void beginEvent (art::EventNumber_t eventNumber)
 
void endEvent (art::EventNumber_t eventNumber)
 

Private Attributes

std::string raw_data_label_
 
std::string frag_type_
 
uint32_t verb_adcs_
 
bool verb_meta_
 
TH1D * adc_values_
 
uint32_t n_adc_counter_
 
uint64_t adc_cumulative_
 

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 34 of file SSPDump_module.cc.

Constructor & Destructor Documentation

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

Definition at line 63 of file SSPDump_module.cc.

64  : EDAnalyzer(pset),
65  raw_data_label_(pset.get<std::string>("raw_data_label")),
66  frag_type_(pset.get<std::string>("frag_type")),
67  //verb_microslice_ids_(pset.get<std::vector<int>>("verbose_microslice_ids", std::vector<int>(1,0))),
68  //verb_nanoslice_ids_ (pset.get<std::vector<int>>("verbose_nanoslice_ids", std::vector<int>(1,0))),
69  verb_adcs_(pset.get<uint32_t> ("verbose_adcs", 10000)),
70  verb_meta_(pset.get<bool> ("verbose_metadata", true)),
71  adc_values_(nullptr),
72  n_adc_counter_(0),
74 {
75 }
std::string string
Definition: nybbler.cc:12
uint64_t adc_cumulative_
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:27
uint32_t verb_adcs_
unsigned int uint32_t
Definition: stdint.h:126
std::string raw_data_label_
uint32_t n_adc_counter_
std::string frag_type_
lbne::SSPDump::~SSPDump ( )
virtual

Definition at line 104 of file SSPDump_module.cc.

105 {
106 }

Member Function Documentation

void lbne::SSPDump::analyze ( art::Event const &  evt)
overridevirtual

Implements art::EDAnalyzer.

Definition at line 108 of file SSPDump_module.cc.

109 {
110  art::EventNumber_t eventNumber = evt.event();
111  beginEvent(eventNumber);
112 
113  // TFile f("hists.root","RECREATE");
114  // ***********************
115  // *** SSP Fragments ***
116  // ***********************
117 
118  // look for raw SSP data
119 
121  evt.getByLabel(raw_data_label_, frag_type_, raw);
122 
123  if (raw.isValid()) {
124  std::cout << "######################################################################" << std::endl;
125  std::cout << std::endl;
126  std::cout << "Run " << evt.run() << ", subrun " << evt.subRun()
127  << ", event " << eventNumber << " has " << raw->size()
128  << " fragment(s) of type " << frag_type_ << std::endl;
129 
130  for (size_t idx = 0; idx < raw->size(); ++idx) {
131  const auto& frag((*raw)[idx]);
132 
133  SSPFragment sspf(frag);
134 
135  std::cout << std::endl;
136  std::cout << "SSP fragment " << frag.fragmentID()
137  << " has total size: " << sspf.hdr_event_size()
138  << " and run number: " << sspf.hdr_run_number()
139  << " with " << sspf.total_adc_values() << " total ADC values"
140  << std::endl;
141  std::cout << std::endl;
142 
143  const SSPDAQ::MillisliceHeader* meta=0;
144  //get the information from the header
145  if(frag.hasMetadata())
146  {
147  meta = &(frag.metadata<SSPFragment::Metadata>()->sliceHeader);
148 
149  std::cout
150  <<"===Slice metadata:"<<std::endl
151  <<"Start time "<<meta->startTime<<std::endl
152  <<"End time "<<meta->endTime<<std::endl
153  <<"Packet length "<<meta->length<<std::endl
154  <<"Number of triggers "<<meta->nTriggers<<std::endl<<std::endl;
155  }
156  else
157  {
158  std::cout << "SSP fragment has no metadata associated with it." << std::endl;
159  }
160 
161  const unsigned int* dataPointer = sspf.dataBegin();
162 
163  unsigned int triggersProcessed=0;
164  while((meta==0||triggersProcessed<meta->nTriggers)&&dataPointer<sspf.dataEnd()){
165  const SSPDAQ::EventHeader* daqHeader=reinterpret_cast<const SSPDAQ::EventHeader*>(dataPointer);
166 
167  uint32_t peaksum = ((daqHeader->group3 & 0x00FF) >> 16) + daqHeader->peakSumLow;
168  if(peaksum & 0x00800000) {
169  peaksum |= 0xFF000000;
170  }
171  if(verb_meta_) {
172  std::cout
173  << "Header: " << daqHeader->header << std::endl
174  << "Length: " << daqHeader->length << std::endl
175  << "Trigger type: " << ((daqHeader->group1 & 0xFF00) >> 8) << std::endl
176  << "Status flags: " << ((daqHeader->group1 & 0x00F0) >> 4) << std::endl
177  << "Header type: " << ((daqHeader->group1 & 0x000F) >> 0) << std::endl
178  << "Trigger ID: " << daqHeader->triggerID << std::endl
179  << "Module ID: " << ((daqHeader->group2 & 0xFFF0) >> 4) << std::endl
180  << "Channel ID: " << ((daqHeader->group2 & 0x000F) >> 0) << std::endl
181  << "External timestamp (FP mode): " << std::endl
182  << " Sync delay: " << ((unsigned int)(daqHeader->timestamp[1]) << 16) + (unsigned int)(daqHeader->timestamp[0]) << std::endl
183  << " Sync count: " << ((unsigned int)(daqHeader->timestamp[3]) << 16) + (unsigned int)(daqHeader->timestamp[2]) << std::endl
184  << "External timestamp (NOvA mode): " << (unsigned long)daqHeader->timestamp[3] << 48 + (unsigned long)daqHeader->timestamp[2] << 32
185  + (unsigned long)daqHeader->timestamp[1] << 16 + (unsigned long)daqHeader->timestamp[0] <<std::endl
186  << "Peak sum: " << peaksum << std::endl
187  << "Peak time: " << ((daqHeader->group3 & 0xFF00) >> 8) << std::endl
188  << "Prerise: " << ((daqHeader->group4 & 0x00FF) << 16) + daqHeader->preriseLow << std::endl
189  << "Integrated sum: " << ((unsigned int)(daqHeader->intSumHigh) << 8) + (((unsigned int)(daqHeader->group4) & 0xFF00) >> 8) << std::endl
190  << "Baseline: " << daqHeader->baseline << std::endl
191  << "CFD Timestamp interpolation points: " << daqHeader->cfdPoint[0] << " " << daqHeader->cfdPoint[1] << " " << daqHeader->cfdPoint[2] << " " << daqHeader->cfdPoint[3] << std::endl
192  << "Internal interpolation point: " << daqHeader->intTimestamp[0] << std::endl
193  << "Internal timestamp: " << ((uint64_t)((uint64_t)daqHeader->intTimestamp[3] << 32)) + ((uint64_t)((uint64_t)daqHeader->intTimestamp[2]) << 16) + ((uint64_t)((uint64_t)daqHeader->intTimestamp[1])) << std::endl
194  << std::endl;
195  }
196  dataPointer+=sizeof(SSPDAQ::EventHeader)/sizeof(unsigned int);
197 
198 
199  //get the information from the data
200  bool verb_values = true;
201  unsigned int nADC=(daqHeader->length-sizeof(SSPDAQ::EventHeader)/sizeof(unsigned int))*2;
202  const unsigned short* adcPointer=reinterpret_cast<const unsigned short*>(dataPointer);
203  char histName[100];
204  sprintf(histName,"event%d",triggersProcessed);
205  //TH1F* hist=new TH1F(histName,histName,nADC,0,nADC*1./150.);
206  // hist->SetDirectory(&f);
207  for(size_t idata = 0; idata < nADC; idata++) {
208  if(idata >= verb_adcs_)
209  verb_values = false;
210  else if(idata == 0&&verb_adcs_>0)
211  std::cout << "Data values: ";
212 
213  const unsigned short* adc = adcPointer + idata;
214  adc_values_->Fill(*adc);
215  n_adc_counter_++;
216  adc_cumulative_ += (uint64_t)(*adc);
217  // hist->SetBinContent(idata+1,*adc);
218 
219  if(verb_values)
220  std::cout << *adc << " ";
221  }
222  dataPointer+=nADC/2;
223  ++triggersProcessed;
224  std::cout<<std::endl<<"Triggers processed: "<<triggersProcessed<<std::endl<<std::endl;
225  }
226  }
227  std::cout << std::endl
228  << "Event ADC average is (from counter): " << (double)adc_cumulative_/(double)n_adc_counter_
229  << std::endl
230  << "Event ADC average is (from histogram): " << adc_values_->GetMean()
231  << std::endl;
232  }//raw.IsValid()?
233  else {
234  std::cout << "Run " << evt.run() << ", subrun " << evt.subRun()
235  << ", event " << eventNumber << " has zero"
236  << " SSP fragments." << std::endl;
237  }
238  std::cout << std::endl;
239  // f.Write();
240  beginEvent(eventNumber);
241 }
unsigned int event
Definition: DataStructs.h:574
unsigned int run
Definition: DataStructs.h:575
uint64_t adc_cumulative_
STL namespace.
Raw data description.
uint32_t verb_adcs_
bool isValid() const
Definition: Handle.h:183
unsigned int uint32_t
Definition: stdint.h:126
std::string raw_data_label_
void beginEvent(art::EventNumber_t eventNumber)
uint32_t n_adc_counter_
unsigned __int64 uint64_t
Definition: stdint.h:136
IDNumber_t< Level::Event > EventNumber_t
Definition: IDNumber.h:118
unsigned int subRun
Definition: DataStructs.h:576
TCEvent evt
Definition: DataStructs.cxx:7
std::string frag_type_
QTextStream & endl(QTextStream &s)
void lbne::SSPDump::beginEvent ( art::EventNumber_t  eventNumber)
private

Definition at line 83 of file SSPDump_module.cc.

84 {
85  //reset ADC histogram
86  adc_values_->Reset();
87  //reset counters
88  n_adc_counter_ = 0;
89  adc_cumulative_ = 0;
90 }
uint64_t adc_cumulative_
uint32_t n_adc_counter_
void lbne::SSPDump::beginJob ( )
overrideprivatevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 77 of file SSPDump_module.cc.

78 {
80  adc_values_ = tfs->make<TH1D>("adc_values","adc_values",4096,-0.5,4095.5);
81 }
void lbne::SSPDump::endEvent ( art::EventNumber_t  eventNumber)
private

Definition at line 92 of file SSPDump_module.cc.

93 {
94  //write the ADC histogram for the given event
95  if(n_adc_counter_)
96  adc_values_->Write(Form("adc_values:event_%d", eventNumber));
97 }
uint32_t n_adc_counter_
void lbne::SSPDump::endJob ( )
overrideprivatevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 99 of file SSPDump_module.cc.

100 {
101  delete adc_values_;
102 }

Member Data Documentation

uint64_t lbne::SSPDump::adc_cumulative_
private

Definition at line 59 of file SSPDump_module.cc.

TH1D* lbne::SSPDump::adc_values_
private

Definition at line 57 of file SSPDump_module.cc.

std::string lbne::SSPDump::frag_type_
private

Definition at line 48 of file SSPDump_module.cc.

uint32_t lbne::SSPDump::n_adc_counter_
private

Definition at line 58 of file SSPDump_module.cc.

std::string lbne::SSPDump::raw_data_label_
private

Definition at line 47 of file SSPDump_module.cc.

uint32_t lbne::SSPDump::verb_adcs_
private

Definition at line 53 of file SSPDump_module.cc.

bool lbne::SSPDump::verb_meta_
private

Definition at line 54 of file SSPDump_module.cc.


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