20 #include <sys/types.h> 35 unsigned short format;
36 unsigned short software;
48 unsigned short samples;
59 int run( std::string s1 )
61 size_t p1 = s1.find(
"R");
62 size_t p2 = s1.find(
"_E");
64 int run = atoi((s1.substr(p1+1,p2-p1-1)).c_str());
70 int event( std::string s1 )
72 size_t p1 = s1.find(
"E");
73 size_t p2 = s1.find(
"_T");
75 int event = atoi((s1.substr(p1+1,p2-p1-1)).c_str());
81 bool compare( std::string s1, std::string s2 )
88 return r1 == r2 ? e1 < e2
94 std::vector<std::string> getsortedfiles( std::string
dir )
98 <<
"Vacuous directory name" << std::endl;
100 std::vector<std::string> files;
103 if( (dp = opendir(dir.c_str())) == NULL ) {
105 <<
"Error opening directory " << dir << std::endl;
108 dirent * dirp = NULL;
109 while( (dirp = readdir(dp)) != NULL ) {
110 std::string filename( dirp->d_name );
111 if( filename.find(
"bin") != std::string::npos ) {
112 files.push_back(filename);
117 sort( files.begin(), files.end(), compare );
122 struct EventFileSentry {
124 explicit EventFileSentry(std::string
const &filepath)
125 : infile(filepath.c_str(),
std::ios_base::
in |
std::ios_base::binary)
127 ~EventFileSentry() { infile.close(); }
129 std::ifstream infile;
133 void process_LAr_file(std::string dir,
134 std::string
const & filename,
135 std::vector<raw::RawDigit>& digitList,
137 std::vector<raw::ExternalTrigger>& extTrig)
143 EventFileSentry efs(dir+
"/"+filename);
144 std::ifstream &infile = efs.infile;
146 if( !infile.is_open() ) {
148 <<
"failed to open input file " << filename << std::endl;
152 unsigned int wiresPerPlane = 48;
153 unsigned int planes = 3;
154 int nwires = wiresPerPlane*planes;
161 infile.read((
char *) &h1,
sizeof h1);
163 time_t mytime = h1.time;
164 mytime = mytime << 32;
189 digitList.resize(wiresPerPlane*planes);
195 for(
int i = 0; i != nwires; ++i ) {
196 infile.read((
char *) &c1,
sizeof c1);
198 std::vector<short> adclist(c1.samples);
199 infile.read((
char*)&adclist[0],
sizeof(
short)*c1.samples);
205 for (
int ijk=0;ijk<c1.samples;++ijk) {
206 if (std::abs(adclist[ijk])<1
e-5)
212 for (
int ijk=0;ijk<c1.samples;++ijk) {
213 int mysig=adclist[ijk]-400;
214 adclist[ijk]=400-mysig;
223 digitList[i].SetPedestal(400.);
226 digitList[239-i] =
raw::RawDigit(239-i, c1.samples, adclist);
227 digitList[239-i].SetPedestal(400.);
237 for(
int i = 0; i < 16; ++i ) {
238 unsigned int utrigtime = 0;
239 infile.read((
char *) &c1,
sizeof c1);
241 std::vector<short> adclist(c1.samples);
242 infile.read((
char*)&adclist[0],
sizeof(
short)*c1.samples);
245 while (j<c1.samples){
246 float test = 400.0-adclist[j];
247 if (test>10 && j>0) {
274 , nextfile_ ( inputfiles_.
begin() )
275 , filesdone_ ( inputfiles_.
end() )
276 , currentSubRunID_ ( )
313 std::unique_ptr<std::vector<raw::RawDigit> > rdcollb (
new std::vector<raw::RawDigit> );
314 std::unique_ptr<std::vector<raw::ExternalTrigger> > etcollb (
new std::vector<raw::ExternalTrigger> );
320 std::unique_ptr<raw::DAQHeader> daqcollb(
new raw::DAQHeader(daqHeader) );
337 <<
"Encountered run #" << rn
Collection of charge vs time digitized from a single readout channel.
yes & test(std::ostream &)
std::enable_if_t< P::branch_type==InEvent||P::branch_type==InResults > put_product_in_principal(std::unique_ptr< T > &&product, P &principal, std::string const &module_label, std::string const &instance_name={})
SubRunPrincipal * makeSubRunPrincipal(SubRunAuxiliary const &subRunAux) const
Definition of basic raw digits.
RunPrincipal * makeRunPrincipal(RunAuxiliary const &runAux) const
TypeLabel const & reconstitutes(std::string const &modLabel, std::string const &instanceName={})
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Conversion of binary data to root files.
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
SubRunNumber_t subRun() const
EventPrincipal * makeEventPrincipal(EventAuxiliary const &eventAux, std::shared_ptr< History > &&history) const
art framework interface to geometry description
cet::coded_exception< error, detail::translate > exception
Event finding and building.
IDNumber_t< Level::Run > RunNumber_t