diff --git a/include/Fadc250Decode.h b/include/Fadc250Decoder.h similarity index 93% rename from include/Fadc250Decode.h rename to include/Fadc250Decoder.h index 858810c3f8f6ffbe5048eac8aa6e41fa27ba2f44..aa9479202467353fc1598736ad1a6ebfd20fea98 100644 --- a/include/Fadc250Decode.h +++ b/include/Fadc250Decoder.h @@ -1,5 +1,5 @@ -#ifndef FADC250_DECODE_H -#define FADC250_DECODE_H +#ifndef FADC250_DECODER_H +#define FADC250_DECODER_H #include <iostream> #include <iomanip> @@ -90,7 +90,7 @@ struct Fadc250Data }; -void fadc250_decode_helper(uint32_t *buf, uint32_t &id, Fadc250Data &fadc, uint32_t type = FillerWord); +void fadc250_decoder_helper(uint32_t *buf, uint32_t &id, Fadc250Data &fadc, uint32_t type = FillerWord); void print_word(uint32_t word) { std::cout << "0x" << std::hex << std::setw(8) << std::setfill('0') << word << std::dec << "\n"; @@ -117,7 +117,7 @@ inline uint32_t fill_in_words(uint32_t *buf, uint32_t beg, Container &raw_data, return nwords; } -Fadc250Data fadc250_decode(uint32_t header, uint32_t *buf, uint32_t /* len */) +Fadc250Data fadc250_decoder(uint32_t header, uint32_t *buf, uint32_t /* len */) { Fadc250Data res; @@ -130,12 +130,12 @@ Fadc250Data fadc250_decode(uint32_t header, uint32_t *buf, uint32_t /* len */) res.blk_num = (header >> 8) & 0x3FF; res.blk_nev = (header & 0xFF); uint32_t index = 0; - fadc250_decode_helper(buf, index, res); + fadc250_decoder_helper(buf, index, res); return res; } -void fadc250_decode_helper(uint32_t *buf, uint32_t &id, Fadc250Data &fadc, uint32_t type) +void fadc250_decoder_helper(uint32_t *buf, uint32_t &id, Fadc250Data &fadc, uint32_t type) { uint32_t data = buf[id]; @@ -227,7 +227,7 @@ void fadc250_decode_helper(uint32_t *buf, uint32_t &id, Fadc250Data &fadc, uint3 } id++; - fadc250_decode_helper(buf, id, fadc, type); + fadc250_decoder_helper(buf, id, fadc, type); } -#endif // FADC250_DECODE_H +#endif // FADC250_DECODER_H diff --git a/src/esb_analyze.cpp b/src/esb_analyze.cpp index f69262601e5381b2d15d32f419d528f800ac1f2a..5a34c6eda20791e0dd493c3132f0f359b25994d1 100644 --- a/src/esb_analyze.cpp +++ b/src/esb_analyze.cpp @@ -14,7 +14,7 @@ #include "TFile.h" #include "TH1.h" #include "simpleLib.h" -#include "Fadc250Decode.h" +#include "Fadc250Decoder.h" #define FADC_BANK 3 @@ -432,7 +432,7 @@ void write_raw_data(const std::string &dpath, const std::string &opath, int nev, evdata->LoadEvent(datafile.getEvBuffer()); evtype = evdata->GetEvType(); - if((++count % PROGRESS_COUNT) == 0) { + if((count % PROGRESS_COUNT) == 0) { std::cout << "Processed events - " << count << "\r" << std::flush; } @@ -440,26 +440,28 @@ void write_raw_data(const std::string &dpath, const std::string &opath, int nev, continue; } - // clear data buffer - for (auto &br : brdata) { - br.second.npul = 0; - br.second.nraw = 0; - } + // get block level + int blvl = 1; + simpleGetRocBlockLevel(modules.front().crate, FADC_BANK, &blvl); - // read data into event buffer int data_mode = -1; - for (auto &mod : modules) { - int blvl = 1; - simpleGetRocBlockLevel(mod.crate, FADC_BANK, &blvl); - - uint32_t header = 0; - auto status = simpleGetSlotBlockHeader(mod.crate, FADC_BANK, mod.slot, &header); - if (status <= 0) { - std::cout << "Error getting header for crate = " << mod.crate << ", slot = " << mod.slot << std::endl; - continue; + for (int ii = 0; ii < blvl; ++ii) { + // clear data buffer + for (auto &br : brdata) { + br.second.npul = 0; + br.second.nraw = 0; } - for (int ii = 0; ii < blvl; ++ii) { + // parse module data + for (auto &mod : modules) { + uint32_t header = 0; + auto status = simpleGetSlotBlockHeader(mod.crate, FADC_BANK, mod.slot, &header); + if (status <= 0) { + std::cout << "Error getting header for crate = " + << mod.crate << ", slot = " << mod.slot << std::endl; + continue; + } + uint32_t *dbuf; auto len = simpleGetSlotEventData(mod.crate, FADC_BANK, mod.slot, ii, &dbuf); if (len <= 0) { @@ -467,33 +469,36 @@ void write_raw_data(const std::string &dpath, const std::string &opath, int nev, << ", block_level = " << ii << std::endl; continue; } - auto slot_data = fadc250_decode(header, dbuf, len); + auto slot_data = fadc250_decoder(header, dbuf, len); // check data mode if (slot_data.GetMode() > 0 && data_mode < 0) { data_mode = slot_data.GetMode(); } - // fill branch data fill_branch(slot_data, mod, brdata); } - } - fill_tree(tree, brdata, init_tree, data_mode); + // fill event + fill_tree(tree, brdata, init_tree, data_mode); + count ++; - if (wpath.empty()) { continue; } - output << count; - for (auto &mod : modules) { - for (auto &ch : mod.channels) { - auto &bd = brdata[ch.name]; - output << csv_sep << "\"["; - for (uint32_t i = 0; i < 192; ++i) { - output << bd.raw[i] << csv_sep; + // output csv file + if (wpath.empty()) { continue; } + output << count; + for (auto &mod : modules) { + for (auto &ch : mod.channels) { + auto &bd = brdata[ch.name]; + output << csv_sep << "\"["; + for (uint32_t i = 0; i < 192; ++i) { + output << bd.raw[i] << csv_sep; + } + output << "]\""; } - output << "]\""; } + output << std::endl; } - output << std::endl; + } std::cout << "Processed events - " << count << std::endl;