17Bool_t
CheckEvent(
const std::shared_ptr<TMidasEvent>& evt)
20 static std::map<Int_t, Bool_t> triggermap;
26 int banksize = evt->LocateBank(
nullptr,
"GRF2", &ptr);
30 banksize = evt->LocateBank(
nullptr,
"GRF1", &ptr);
33 uint32_t type = 0xffffffff;
34 uint32_t value = 0xffffffff;
41 for(
int x = 0; x < banksize; x++) {
42 value = *(
reinterpret_cast<int*
>(ptr) + x);
43 type = value & 0xf0000000;
55 if((value & 0xf0000000) != 0x80000000) {
58 chanadd = (value & 0x0003fff0) >> 4;
71 if((value & 0xf0000000) != 0x80000000) {
74 chanadd = (value & 0x000ffff0) >> 4;
80 default: printf(
"This bank not yet defined.\n");
break;
84 case 0x90000000: trigId = value & 0x0fffffff;
87 if(triggermap.find(chanadd) == triggermap.end()) {
88 triggermap[chanadd] =
false;
96 if(triggermap.find(chanadd)->second) {
100 triggermap.find(chanadd)->second =
true;
114 printf(
"Usage: ./bufferclear <input.mid> <output.mid>\n");
118 if(argv[1] == argv[2]) {
119 printf(
"input.mid and output.mid must have different names\n");
126 int runnumber = file->GetRunNumber();
127 int subrunnumber = file->GetSubRunNumber();
129 file->OutOpen(Form(
"cleanrun%05d_%03d.mid", runnumber, subrunnumber));
131 file->OutOpen(argv[2]);
134 std::ifstream in(file->GetFilename(), std::ifstream::in | std::ifstream::binary);
135 in.seekg(0, std::ifstream::end);
136 int64_t filesize = in.tellg();
140 int64_t bytesread = 0;
145 UInt_t num_bad_evt = 0;
147 std::shared_ptr<TMidasEvent>
event = std::make_shared<TMidasEvent>();
150 bytes = file->Read(event);
152 printf(
DMAGENTA "\tfile: %s ended on %s" RESET_COLOR "\n", file->GetFilename(), file->GetLastError());
153 if(file->GetLastErrno() == -1) {
160 switch(event->GetEventId()) {
162 printf(
"start of run\n");
169 printf(
"end of run\n");
188 if(num_evt % 5000 == 0) {
189 gSystem->ProcessEvents();
190 std::streamsize precision = std::cout.precision();
191 std::cout.precision(2);
192 std::cout <<
HIDE_CURSOR <<
" bad events " << num_bad_evt <<
"/" << num_evt <<
" have processed " <<
static_cast<double>(bytesread) / 1000000. <<
"MB/" <<
static_cast<double>(filesize) / 1000000. <<
" MB => " << std::setprecision(1) <<
static_cast<double>(bytesread) / 1000000 / w.RealTime() <<
" MB/s " <<
SHOW_CURSOR <<
"\r";
193 std::cout.precision(precision);