LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
lris::LArRawInputDriverJP250L Class Reference

#include "LArRawInputDriverJP250L.h"

Public Member Functions

 LArRawInputDriverJP250L (fhicl::ParameterSet const &pset, art::ProductRegistryHelper &helper, art::SourceHelper const &pm)
 
void closeCurrentFile ()
 
void readFile (std::string const &name, art::FileBlock *&fb)
 
bool readNext (art::RunPrincipal *const &inR, art::SubRunPrincipal *const &inSR, art::RunPrincipal *&outR, art::SubRunPrincipal *&outSR, art::EventPrincipal *&outE)
 

Private Attributes

art::SourceHelper const & principalMaker_
 
TTree * m_eventTree
 TTree containing information from each trigger. More...
 
unsigned int m_nEvent
 number of triggers in the TTree More...
 
unsigned int m_current
 current entry in the TTree More...
 
unsigned short m_runID
 run ID, has to start from 1 More...
 
unsigned int m_unixtime
 unix timestamp of the start of the run More...
 
unsigned short m_nChannels
 number of channels in the detector More...
 
unsigned short m_nSamples
 number of time samples per channel More...
 
unsigned short * m_data
 the ADC of each time sample for each channel More...
 

Detailed Description

Definition at line 29 of file LArRawInputDriverJP250L.h.

Constructor & Destructor Documentation

lris::LArRawInputDriverJP250L::LArRawInputDriverJP250L ( fhicl::ParameterSet const &  pset,
art::ProductRegistryHelper helper,
art::SourceHelper const &  pm 
)

Class to fill the constraints on a template argument to the class, FileReaderSource

Definition at line 35 of file LArRawInputDriverJP250L.cxx.

References art::InEvent, art::InRun, and art::ProductRegistryHelper::reconstitutes().

38  : principalMaker_(pm), m_current(0), m_data(0)
39  {
41  helper.reconstitutes<std::vector<raw::RawDigit>, art::InEvent>("daq");
43  }
TypeLabel const & reconstitutes(std::string const &modLabel, std::string const &instanceName={})
unsigned short * m_data
the ADC of each time sample for each channel
art::SourceHelper const & principalMaker_
unsigned int m_current
current entry in the TTree

Member Function Documentation

void lris::LArRawInputDriverJP250L::closeCurrentFile ( )

Definition at line 46 of file LArRawInputDriverJP250L.cxx.

References m_data.

47  {
48  delete[] m_data;
49  }
unsigned short * m_data
the ADC of each time sample for each channel
void lris::LArRawInputDriverJP250L::readFile ( std::string const &  name,
art::FileBlock *&  fb 
)

Definition at line 52 of file LArRawInputDriverJP250L.cxx.

References m_data, m_eventTree, m_nChannels, m_nEvent, m_nSamples, m_runID, and m_unixtime.

53  {
54  TFile m_f(name.c_str());
55  TTree* runTree = dynamic_cast<TTree*>(m_f.Get("runTree"));
56 
57  m_eventTree = dynamic_cast<TTree*>(m_f.Get("eventTree"));
58  m_eventTree->SetDirectory(0);
59  m_nEvent = m_eventTree->GetEntries();
60 
61  // run information
62  runTree->SetBranchAddress("runID", &m_runID);
63  runTree->SetBranchAddress("unixtime", &m_unixtime);
64  runTree->SetBranchAddress("nChannels", &m_nChannels);
65  runTree->SetBranchAddress("nSamples", &m_nSamples);
66  runTree->GetEntry(0);
67 
68  // have to add 1 to the runID because it can't be zero
69  // adding 1 to every runID ensures that all runIDs are bumped in the same way
70  m_runID += 1;
71 
72  const int nLength = (m_nSamples + 4) * m_nChannels;
73  m_data = new unsigned short[nLength];
74  m_eventTree->SetBranchAddress("data", m_data);
75 
76  // Fill and return a new Fileblock.
77  // The string tells you what the version of the LArRawInputDriver is
78  fb = new art::FileBlock(art::FileFormatVersion(1, "LArRawInputJP250L 2013_01"), name);
79 
80  return;
81  }
unsigned int m_unixtime
unix timestamp of the start of the run
unsigned int m_nEvent
number of triggers in the TTree
unsigned short m_runID
run ID, has to start from 1
TTree * m_eventTree
TTree containing information from each trigger.
unsigned short * m_data
the ADC of each time sample for each channel
unsigned short m_nChannels
number of channels in the detector
unsigned short m_nSamples
number of time samples per channel
bool lris::LArRawInputDriverJP250L::readNext ( art::RunPrincipal *const &  inR,
art::SubRunPrincipal *const &  inSR,
art::RunPrincipal *&  outR,
art::SubRunPrincipal *&  outSR,
art::EventPrincipal *&  outE 
)

Definition at line 84 of file LArRawInputDriverJP250L.cxx.

References raw::DAQHeader::GetEvent(), raw::DAQHeader::GetRun(), raw::DAQHeader::GetTimeStamp(), m_current, m_data, m_eventTree, m_nChannels, m_nEvent, m_nSamples, m_runID, m_unixtime, art::SourceHelper::makeEventPrincipal(), art::SourceHelper::makeRunPrincipal(), art::SourceHelper::makeSubRunPrincipal(), n, principalMaker_, art::put_product_in_principal(), raw::DAQHeader::SetEvent(), raw::DAQHeader::SetNChannels(), raw::DAQHeader::SetRun(), raw::DAQHeader::SetTimeStamp(), and sn.

89  {
90 
91  if (m_current > m_nEvent) return false;
92 
93  m_eventTree->GetEntry(m_current);
94 
95  raw::DAQHeader daqHeader;
96  daqHeader.SetRun(m_runID);
97  daqHeader.SetTimeStamp(m_unixtime);
98  daqHeader.SetNChannels(m_nChannels);
99  // set the event number to start at 1 - ART likes to start numbering
100  // things from 1
101  daqHeader.SetEvent(m_current + 1);
102 
103  // the following DAQHeader fields are not used by JP250L at this time
104  //daqHeader.SetStatus(1);
105  //daqHeader.SetFixedWord(h1.fixed);
106  //daqHeader.SetFileFormat(h1.format);
107  //daqHeader.SetSoftwareVersion(h1.software);
108  //daqHeader.SetSpareWord(h1.spare);
109 
110  // make unique_ptrs for the data products to store in the event
111  std::unique_ptr<raw::DAQHeader> daqcol(new raw::DAQHeader(daqHeader));
112  std::unique_ptr<std::vector<raw::RawDigit>> rdcol(new std::vector<raw::RawDigit>);
113 
114  // loop over the signals and break them into
115  // one RawDigit for each channel
116  std::vector<short> adcVec(m_nSamples, 0);
117  for (unsigned int n = 0; n < m_nChannels; ++n) {
118  adcVec.clear();
119  for (unsigned int i = 0; i < m_nSamples; ++i) {
120  adcVec.push_back(m_data[(m_nSamples + 4) * n + (4 + i)]);
121  }
122  rdcol->push_back(raw::RawDigit(n, m_nSamples, adcVec));
123  }
124 
125  art::RunNumber_t rn = daqHeader.GetRun();
127  art::EventNumber_t en = daqHeader.GetEvent();
128  art::Timestamp tstamp = daqHeader.GetTimeStamp();
129 
130  // Make the Run and SubRun principals
131  // this step is done once per run.
132  if (m_current < 1) {
133  std::unique_ptr<sumdata::RunData> rundata(new sumdata::RunData("jpl250l"));
134  outR = principalMaker_.makeRunPrincipal(rn, tstamp);
135  outSR = principalMaker_.makeSubRunPrincipal(rn, sn, tstamp);
136  art::put_product_in_principal(std::move(rundata), *outR, "daq");
137  }
138 
139  // make the Event principal
140  outE = principalMaker_.makeEventPrincipal(rn, sn, en, tstamp);
141 
142  // Put products in the event.
143  // first argument places the desired data product in the file
144  // second argument is event record to associate it to
145  // third argument is the label of the module storing the
146  // information. "daq" is standard in LArSoft
147  art::put_product_in_principal(std::move(rdcol), *outE,
148  "daq"); // Module label
149  art::put_product_in_principal(std::move(daqcol), *outE,
150  "daq"); // Module label
151 
152  // increment the entry to get out of the TTree for the next time through the loop
153  ++m_current;
154 
155  return true;
156  }
unsigned int m_unixtime
unix timestamp of the start of the run
unsigned int m_nEvent
number of triggers in the TTree
Collection of charge vs time digitized from a single readout channel.
Definition: RawDigit.h:68
void SetRun(unsigned short i)
Definition: DAQHeader.h:101
SubRunPrincipal * makeSubRunPrincipal(SubRunAuxiliary subRunAux) const
unsigned short m_runID
run ID, has to start from 1
void SetTimeStamp(time_t t)
Definition: DAQHeader.h:113
EventPrincipal * makeEventPrincipal(EventAuxiliary eventAux) const
TTree * m_eventTree
TTree containing information from each trigger.
Float_t sn
Definition: plot.C:23
IDNumber_t< Level::SubRun > SubRunNumber_t
Definition: IDNumber.h:119
void SetNChannels(uint32_t i)
Definition: DAQHeader.h:121
unsigned short * m_data
the ADC of each time sample for each channel
unsigned short m_nChannels
number of channels in the detector
RunPrincipal * makeRunPrincipal(RunAuxiliary runAux) const
Definition: SourceHelper.cc:89
std::enable_if_t<!detail::range_sets_supported(P::branch_type)> put_product_in_principal(std::unique_ptr< T > &&product, P &principal, std::string const &module_label, std::string const &instance_name={})
unsigned short m_nSamples
number of time samples per channel
unsigned short GetRun() const
Definition: DAQHeader.h:141
art::SourceHelper const & principalMaker_
IDNumber_t< Level::Event > EventNumber_t
Definition: IDNumber.h:118
unsigned short GetEvent() const
Definition: DAQHeader.h:149
Char_t n[5]
unsigned int m_current
current entry in the TTree
void SetEvent(unsigned short i)
Definition: DAQHeader.h:109
time_t GetTimeStamp() const
Definition: DAQHeader.h:153
IDNumber_t< Level::Run > RunNumber_t
Definition: IDNumber.h:120

Member Data Documentation

unsigned int lris::LArRawInputDriverJP250L::m_current
private

current entry in the TTree

Definition at line 54 of file LArRawInputDriverJP250L.h.

Referenced by readNext().

unsigned short* lris::LArRawInputDriverJP250L::m_data
private

the ADC of each time sample for each channel

Definition at line 59 of file LArRawInputDriverJP250L.h.

Referenced by closeCurrentFile(), readFile(), and readNext().

TTree* lris::LArRawInputDriverJP250L::m_eventTree
private

TTree containing information from each trigger.

Definition at line 52 of file LArRawInputDriverJP250L.h.

Referenced by readFile(), and readNext().

unsigned short lris::LArRawInputDriverJP250L::m_nChannels
private

number of channels in the detector

Definition at line 57 of file LArRawInputDriverJP250L.h.

Referenced by readFile(), and readNext().

unsigned int lris::LArRawInputDriverJP250L::m_nEvent
private

number of triggers in the TTree

Definition at line 53 of file LArRawInputDriverJP250L.h.

Referenced by readFile(), and readNext().

unsigned short lris::LArRawInputDriverJP250L::m_nSamples
private

number of time samples per channel

Definition at line 58 of file LArRawInputDriverJP250L.h.

Referenced by readFile(), and readNext().

unsigned short lris::LArRawInputDriverJP250L::m_runID
private

run ID, has to start from 1

Definition at line 55 of file LArRawInputDriverJP250L.h.

Referenced by readFile(), and readNext().

unsigned int lris::LArRawInputDriverJP250L::m_unixtime
private

unix timestamp of the start of the run

Definition at line 56 of file LArRawInputDriverJP250L.h.

Referenced by readFile(), and readNext().

art::SourceHelper const& lris::LArRawInputDriverJP250L::principalMaker_
private

Definition at line 49 of file LArRawInputDriverJP250L.h.

Referenced by readNext().


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