17 printf(
"Usage: ./offsetadd <input.mid> <output.mid>\n");
23 std::shared_ptr<TMidasEvent>
event = std::make_shared<TMidasEvent>();
26 printf(
"ERROR: Cannot overwrite midas file %s\n",
argv[1]);
29 infile->Open(
argv[1]);
30 outfile->OutOpen(
argv[2]);
32 while(infile->Read(event) > 0) {
33 switch(event->GetEventId()) {
35 printf(
"start of run\n");
36 outfile->Write(event);
40 printf(
"end of run\n");
42 outfile->Write(event);
58 if(event->GetEventId() != 1) {
59 outfile->
Write(event,
"q");
67 int banksize =
event->LocateBank(
nullptr,
"GRF1", &ptr);
69 uint32_t type = 0xffffffff;
70 int value = 0xffffffff;
80 for(
int x = 0; x < banksize; x++) {
81 value = *(
reinterpret_cast<int*
>(ptr) + x);
82 type = value & 0xf0000000;
86 dettype = value & 0x0000000f;
87 chanadd = (value & 0x0003fff0) >> 4;
89 case 0xa0000000: timelow = value & 0x0fffffff;
break;
90 case 0xb0000000: timehigh = value & 0x00003fff;
break;
103 if((dettype == 1) || (dettype == 5)) {
106 outfile->
Write(event,
"q");
110 if(((chanadd & 0x0000ff00) == 0x00000000) || ((chanadd & 0x0000ff00) == 0x00001000) ||
111 ((chanadd & 0x0000ff00) == 0x00001100) || ((chanadd & 0x0000ff00) == 0x00001200)) {
114 outfile->
Write(event,
"q");
120 time |= timelow & 0x0fffffff;
126 switch(chanadd & 0x0000ff00) {
145 time += 0x3ffffffffff;
146 }
else if(time > 0x3ffffffffff) {
147 time -= 0x3ffffffffff;
160 std::shared_ptr<TMidasEvent> copyevent = std::make_shared<TMidasEvent>(*event);
161 copyevent->SetBankList();
163 banksize = copyevent->LocateBank(
nullptr,
"GRF1", &ptr);
164 for(
int x = 0; x < banksize; x++) {
165 value = *(
reinterpret_cast<int*
>(ptr) + x);
166 type = value & 0xf0000000;
170 timelow = time & 0x0fffffff;
171 timelow += 0xa0000000;
172 *(
reinterpret_cast<int*
>(ptr) + x) = timelow;
175 timehigh = (time & 0x3fff0000000) >> 28;
176 int tempdead = value & 0xffffc000;
177 timehigh += tempdead;
178 *(
reinterpret_cast<int*
>(ptr) + x) = timehigh;
189 outfile->
Write(copyevent,
"q");
bool Write(const std::shared_ptr< TMidasEvent > &midasEvent, Option_t *opt="")
Write one event to the output file.
Reader for MIDAS .mid files.
int main(int argc, char **argv)
void ProcessEvent(const std::shared_ptr< TMidasEvent > &, TMidasFile *)