24 #include "cetlib_except/coded_exception.h" 25 #include "cetlib_except/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,
139 std::vector<raw::ExternalTrigger>& extTrig)
145 EventFileSentry efs(dir +
"/" + filename);
146 std::ifstream& infile = efs.infile;
148 if (!infile.is_open()) {
150 <<
"failed to open input file " << filename << std::endl;
154 unsigned int wiresPerPlane = 48;
155 unsigned int planes = 3;
156 int nwires = wiresPerPlane * planes;
163 infile.read((
char*)&h1,
sizeof h1);
165 time_t mytime = h1.time;
166 mytime = mytime << 32;
191 digitList.resize(wiresPerPlane * planes);
197 for (
int i = 0; i != nwires; ++i) {
198 infile.read((
char*)&c1,
sizeof c1);
200 std::vector<short> adclist(c1.samples);
201 infile.read((
char*)&adclist[0],
sizeof(
short) * c1.samples);
207 for (
int ijk = 0; ijk < c1.samples; ++ijk) {
208 if (
std::abs(adclist[ijk]) < 1
e-5) adclist[ijk] += 400;
212 if (i > 63 && i < 80) {
213 for (
int ijk = 0; ijk < c1.samples; ++ijk) {
214 int mysig = adclist[ijk] - 400;
215 adclist[ijk] = 400 - mysig;
224 digitList[i].SetPedestal(400.);
227 digitList[239 - i] =
raw::RawDigit(239 - i, c1.samples, adclist);
228 digitList[239 - i].SetPedestal(
239 for (
int i = 0; i < 16; ++i) {
240 unsigned int utrigtime = 0;
241 infile.read((
char*)&c1,
sizeof c1);
243 std::vector<short> adclist(c1.samples);
244 infile.read((
char*)&adclist[0],
sizeof(
short) * c1.samples);
247 while (j < c1.samples) {
248 float test = 400.0 - adclist[j];
249 if (test > 10 && j > 0) {
270 : principalMaker_(pm)
273 , nextfile_(inputfiles_.
begin())
274 , filesdone_(inputfiles_.
end())
310 std::unique_ptr<std::vector<raw::RawDigit>> rdcollb(
new std::vector<raw::RawDigit>);
311 std::unique_ptr<std::vector<raw::ExternalTrigger>> etcollb(
312 new std::vector<raw::ExternalTrigger>);
318 std::unique_ptr<raw::DAQHeader> daqcollb(
new raw::DAQHeader(daqHeader));
323 if (firstEventInRun) {
332 <<
"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
constexpr auto abs(T v)
Returns the absolute value of the argument.
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