19 #include "cetlib_except/coded_exception.h" 46 unsigned short format;
47 unsigned short software;
58 unsigned short samples;
68 int run(std::string s1)
70 size_t p1 = s1.find(
"R");
71 size_t p2 = s1.find(
"_E");
73 int run = atoi((s1.substr(p1 + 1, p2 - p1 - 1)).c_str());
78 int event(std::string s1)
80 size_t p1 = s1.find(
"E");
81 size_t p2 = s1.find(
"_T");
83 int event = atoi((s1.substr(p1 + 1, p2 - p1 - 1)).c_str());
88 bool compare(std::string s1, std::string s2)
95 return r1 == r2 ? e1 < e2 : r1 < r2;
99 std::vector<std::string> getsortedfiles(std::string
dir)
104 std::vector<std::string> files;
107 if ((dp = opendir(dir.c_str())) == NULL) {
109 <<
"Error opening directory " << dir << std::endl;
113 while ((dirp = readdir(dp)) != NULL) {
114 std::string filename(dirp->d_name);
115 if (filename.find(
"bin") != std::string::npos) { files.push_back(filename); }
119 sort(files.begin(), files.end(), compare);
124 struct EventFileSentry {
126 explicit EventFileSentry(std::string
const& filepath)
127 : infile(filepath.c_str(),
std::ios_base::
in |
std::ios_base::binary)
129 ~EventFileSentry() { infile.close(); }
131 std::ifstream infile;
135 void process_LAr_file(std::string dir,
136 std::string
const& filename,
137 std::vector<raw::RawDigit>& digitList,
144 EventFileSentry efs(dir +
"/" + filename);
145 std::ifstream& infile = efs.infile;
147 if (!infile.is_open()) {
149 <<
"failed to open input file " << filename << std::endl;
152 unsigned int wiresPerPlane = 240;
153 unsigned int planes = 2;
160 infile.read((
char*)&h1,
sizeof h1);
162 time_t mytime = h1.time;
163 mytime = mytime << 32;
188 digitList.resize(wiresPerPlane * planes);
190 for (
int i = 0; i != h1.nchan; ++i) {
191 infile.read((
char*)&c1,
sizeof c1);
193 std::vector<short> adclist(c1.samples);
194 infile.read((
char*)&adclist[0],
sizeof(
short) * c1.samples);
203 digitList[i].SetPedestal(400.);
206 infile.read((
char*)&f1,
sizeof f1);
219 : principalMaker_(pm)
222 , nextfile_(inputfiles_.
begin())
223 , filesdone_(inputfiles_.
end())
258 std::unique_ptr<std::vector<raw::RawDigit>> rdcol(
new std::vector<raw::RawDigit>);
264 std::unique_ptr<raw::DAQHeader> daqcol(
new raw::DAQHeader(daqHeader));
269 if (firstEventInRun) {
270 std::unique_ptr<sumdata::RunData> rundata(
new sumdata::RunData(
"argoneut"));
278 <<
"Encountered run #" << rn <<
" while processing events from run #"
Collection of charge vs time digitized from a single readout channel.
SubRunPrincipal * makeSubRunPrincipal(SubRunAuxiliary subRunAux) const
EventPrincipal * makeEventPrincipal(EventAuxiliary eventAux) const
Definition of basic raw digits.
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
TypeLabel const & reconstitutes(std::string const &modLabel, std::string const &instanceName={})
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
RunPrincipal * makeRunPrincipal(RunAuxiliary runAux) const
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={})
Conversion of binary data to root files.
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
SubRunNumber_t subRun() const
cet::coded_exception< error, detail::translate > exception
Event finding and building.
IDNumber_t< Level::Run > RunNumber_t