ATLAS Offline Software
Loading...
Searching...
No Matches
DecodeSCT.cxx File Reference
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <utility>
#include <cstdint>
#include <filesystem>

Go to the source code of this file.

Functions

std::string str (const char *word)
void helpMessage ()
int main (int argc, char **argv)

Function Documentation

◆ helpMessage()

void helpMessage ( )

Definition at line 48 of file DecodeSCT.cxx.

48 {
49 std::cout<< "'DecodeSCT' takes exactly one argument, the bytestream filename." <<std::endl;
50}

◆ main()

int main ( int argc,
char ** argv )

Definition at line 53 of file DecodeSCT.cxx.

53 {
54 if (argc < 2){
56 return 1;
57 }
58 fs::path input_file = getFilename(argv[1]);
59 if (input_file.empty()) {
60 std::cerr << argv[1] <<" does not exist."<<std::endl;
61 return 2;
62 }
63 auto length = fs::file_size(input_file);
64 printf("Length: %lu\n", length);
65 auto fd = open(input_file.c_str(), O_RDONLY);
66 if(fd<0) {
67 perror("File open failed");
68 return 3;
69 }
70 uint32_t *buffer = (uint32_t *) mmap(0, length, PROT_READ, MAP_PRIVATE, fd, 0);
71 if(buffer == MAP_FAILED) {
72 close(fd);
73 perror("mmap failed");
74 return 4;
75 }
76 uint32_t *endBuffer = &buffer[length/4];
78 uint32_t *end{};
79 while(findNextEvent(begin, end, endBuffer, 0xee1234ee)) {
80 //cppcheck-suppress invalidPrintfArgType_sint
81 printf("Event from %li to %li\n", begin-buffer, end-buffer);
82 int length = static_cast<int>(end - 1l - begin);
83 decodeEvent(begin, length);
84 }
85 munmap(buffer, length);
86 close(fd);
87}
void helpMessage()
Definition DecodeSCT.cxx:48
double length(const pvec &v)
@ open
Definition BinningType.h:40
setEventNumber uint32_t

◆ str()

std::string str ( const char * word)
inline

Definition at line 43 of file DecodeSCT.cxx.

43 {
44 return word ? word : "";
45}