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

Public Member Functions

 APAIORdWriter (fhicl::ParameterSet const &p)
 
 APAIORdWriter (APAIORdWriter const &)=delete
 
 APAIORdWriter (APAIORdWriter &&)=delete
 
APAIORdWriteroperator= (APAIORdWriter const &)=delete
 
APAIORdWriteroperator= (APAIORdWriter &&)=delete
 
void analyze (art::Event const &e) 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 (SharedResources const &resources)
 
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 &)
 
fhicl::ParameterSetID selectorConfig () 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 Attributes

std::string fRawDigitLabel
 
std::string fOutputDirBaseName
 

Additional Inherited Members

- Public Types inherited from art::EDAnalyzer
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 
- Protected Member Functions inherited from art::Observer
std::string const & processName () const
 
bool wantAllEvents () const noexcept
 
bool wantEvent (ScheduleID id, Event const &e) const
 
Handle< TriggerResultsgetTriggerResults (Event const &e) const
 
 Observer (fhicl::ParameterSet const &config)
 
 Observer (std::vector< std::string > const &select_paths, std::vector< std::string > const &reject_paths, fhicl::ParameterSet const &config)
 
- 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 27 of file APAIORdWriter_module.cc.

Constructor & Destructor Documentation

APAIORdWriter::APAIORdWriter ( fhicl::ParameterSet const &  p)
explicit

Definition at line 52 of file APAIORdWriter_module.cc.

53  : EDAnalyzer{p} // ,
54  // More initializers here.
55 {
56  // Call appropriate consumes<>() for any products to be retrieved by this module.
57 
58  fRawDigitLabel = p.get<std::string>("RawDigitLabel","daq");
59  fOutputDirBaseName = p.get<std::string>("OutputDirBaseName","APAIO");
60  consumes<std::vector<raw::RawDigit>>(fRawDigitLabel);
61 }
std::string string
Definition: nybbler.cc:12
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
std::string fOutputDirBaseName
std::string fRawDigitLabel
p
Definition: test.py:223
APAIORdWriter::APAIORdWriter ( APAIORdWriter const &  )
delete
APAIORdWriter::APAIORdWriter ( APAIORdWriter &&  )
delete

Member Function Documentation

void APAIORdWriter::analyze ( art::Event const &  e)
overridevirtual

Implements art::EDAnalyzer.

Definition at line 63 of file APAIORdWriter_module.cc.

64 {
65  auto runno = e.run();
66  auto subrunno = e.subRun();
67  auto eventno = e.event();
68 
69  auto rdighandle = e.getValidHandle<std::vector<raw::RawDigit>>(fRawDigitLabel);
70  if (rdighandle->size()==0) return;
71 
72  TString outdir=fOutputDirBaseName;
73  outdir += "r";
74  TString rnst="";
75  rnst.Form("%08d",runno);
76  outdir += rnst;
77  outdir += "s";
78  TString srnst="";
79  srnst.Form("%05d",subrunno);
80  outdir += srnst;
81  outdir += "e";
82  TString est="";
83  est.Form("%08d",eventno);
84  outdir += est;
85 
86  TString cmd;
87  cmd = "touch " + outdir;
88  gSystem->Exec(cmd); // todo -- test these system commands for failure
89  cmd = "rm -rf " + outdir;
90  gSystem->Exec(cmd);
91  cmd = "mkdir " + outdir;
92  gSystem->Exec(cmd);
93 
94  // todo -- get these from the geometry
95  size_t napas = 150;
96  size_t nchans_per_apa = 2560;
97 
98  size_t version = 1; // data format version
99 
100  // todo -- make an index of channel ID's found in the raw digits and sort them. Then look in the sorted vector using lower_bound
101  // so we don't have to do a double loop of APAs*channels. This may be fast enough as is.
102 
103  for (uint32_t iapaindex = 0; iapaindex < napas; ++iapaindex)
104  {
105  //std::cout << "Writing output for apa: " << iapaindex << std::endl;
106  FILE *ofile=NULL;
107  TString ofilename=outdir;
108  ofilename += "/apa";
109  TString apast="";
110  apast.Form("%03d",iapaindex);
111  ofilename += apast;
112  for (auto const& rawdigit : *rdighandle)
113  {
114  uint32_t chan = rawdigit.Channel();
115  uint32_t apa = chan / nchans_per_apa;
116  if (apa == iapaindex)
117  {
118  if (ofile == NULL)
119  {
120  ofile = fopen(ofilename,"w");
121  }
122  fwrite(&version,sizeof(version),1,ofile);
123  fwrite(&chan,sizeof(chan),1,ofile);
124  uint32_t samples = rawdigit.Samples();
125  fwrite(&samples,sizeof(samples),1,ofile);
126  raw::Compress_t compression = rawdigit.Compression();
127  fwrite(&compression,sizeof(compression),1,ofile);
128  float pedestal = rawdigit.GetPedestal();
129  float sigma = rawdigit.GetSigma();
130  fwrite (&pedestal,sizeof(pedestal),1,ofile);
131  fwrite (&sigma,sizeof(sigma),1,ofile);
132 
133  // todo: optionally compress data further
134  auto adcs = rawdigit.ADCs();
135  uint32_t nadc = adcs.size();
136  fwrite(&nadc,sizeof(nadc),1,ofile);
137  //std::cout << "writing " << adcs.size() << " adcs with size: " << sizeof(adcs.front()) << " for channel: " << chan << std::endl;
138  fwrite(adcs.data(),sizeof(adcs.front()),adcs.size(),ofile);
139  }
140  }
141  if (ofile != NULL) fclose(ofile);
142  }
143 }
enum raw::_compress Compress_t
const double e
std::string fOutputDirBaseName
std::string fRawDigitLabel
list cmd
Definition: getreco.py:22
APAIORdWriter& APAIORdWriter::operator= ( APAIORdWriter const &  )
delete
APAIORdWriter& APAIORdWriter::operator= ( APAIORdWriter &&  )
delete

Member Data Documentation

std::string APAIORdWriter::fOutputDirBaseName
private

Definition at line 47 of file APAIORdWriter_module.cc.

std::string APAIORdWriter::fRawDigitLabel
private

Definition at line 46 of file APAIORdWriter_module.cc.


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