21int main(
int argc,
char* argv[])
23 const std::string genDigDile{
"fdddigits.root"};
24 const std::string decDigDile{
"o2_fdddigits.root"};
25 const std::string branchBC{
"FDDDIGITSBC"};
26 const std::string branchCH{
"FDDDIGITSCH"};
28 if (!std::filesystem::exists(genDigDile)) {
29 LOG(fatal) <<
"Generated digits file " << genDigDile <<
" is absent";
31 TFile
flIn(genDigDile.c_str());
32 std::unique_ptr<TTree>
tree((TTree*)
flIn.Get(
"o2sim"));
34 LOG(fatal) <<
"Failed to get tree from generated digits file " << genDigDile;
36 std::vector<o2::fdd::Digit> digitsBC, *fddBCDataPtr = &digitsBC;
37 std::vector<o2::fdd::ChannelData> digitsCh, *fddChDataPtr = &digitsCh;
38 tree->SetBranchAddress(
"FDDDIGITSBC", &fddBCDataPtr);
39 tree->SetBranchAddress(
"FDDDIGITSCH", &fddChDataPtr);
41 if (!std::filesystem::exists(decDigDile)) {
42 LOG(fatal) <<
"Decoded digits file " << genDigDile <<
" is absent";
45 TFile flIn2(decDigDile.c_str());
46 std::unique_ptr<TTree> tree2((TTree*)flIn2.Get(
"o2sim"));
47 if (!flIn2.IsOpen() || flIn2.IsZombie() || !tree2) {
48 LOG(fatal) <<
"Failed to get tree from decoded digits file " << genDigDile;
50 std::vector<o2::fdd::Digit> digitsBC2, *fddBCDataPtr2 = &digitsBC2;
51 std::vector<o2::fdd::ChannelData> digitsCh2, *fddChDataPtr2 = &digitsCh2;
52 tree2->SetBranchAddress(
"FDDDIGITSBC", &fddBCDataPtr2);
53 tree2->SetBranchAddress(
"FDDDIGITSCH", &fddChDataPtr2);
55 int nbc = 0, nbc2 = 0, nch = 0, nch2 = 0;
56 for (
int ient = 0; ient <
tree->GetEntries(); ient++) {
58 int nbcEntry = digitsBC.size();
60 for (
int ibc = 0; ibc < nbcEntry; ibc++) {
61 auto& bcd = digitsBC[ibc];
63 auto channels = bcd.getBunchChannelData(digitsCh);
68 for (
int ient = 0; ient < tree2->GetEntries(); ient++) {
69 tree2->GetEntry(ient);
70 int nbc2Entry = digitsBC2.size();
72 for (
int ibc = 0; ibc < nbc2Entry; ibc++) {
73 auto& bcd2 = digitsBC2[ibc];
74 int bc2 = bcd2.getBC();
75 auto channels2 = bcd2.getBunchChannelData(digitsCh2);
76 nch2 += channels2.size();
79 LOG(info) <<
"FDD simulated: " << nbc <<
" triggers with " << nch <<
" channels";
80 LOG(info) <<
"FDD decoded : " << nbc2 <<
" triggers with " << nch2 <<
" channels";
81 if (nbc != nbc2 || nch != nch2) {
82 LOG(fatal) <<
"Mismatch between the number of encoded and decoded objects";