21int main(
int argc,
char* argv[])
23 const std::string genDigDile{
"ft0digits.root"};
24 const std::string decDigDile{
"o2_ft0digits.root"};
25 const std::string branchBC{
"FT0DIGITSBC"};
26 const std::string branchCH{
"FT0DIGITSCH"};
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::ft0::Digit> digitsBC, *ft0BCDataPtr = &digitsBC;
37 std::vector<o2::ft0::ChannelData> digitsCh, *ft0ChDataPtr = &digitsCh;
38 tree->SetBranchAddress(
"FT0DIGITSBC", &ft0BCDataPtr);
39 tree->SetBranchAddress(
"FT0DIGITSCH", &ft0ChDataPtr);
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::ft0::Digit> digitsBC2, *ft0BCDataPtr2 = &digitsBC2;
51 std::vector<o2::ft0::ChannelData> digitsCh2, *ft0ChDataPtr2 = &digitsCh2;
52 tree2->SetBranchAddress(
"FT0DIGITSBC", &ft0BCDataPtr2);
53 tree2->SetBranchAddress(
"FT0DIGITSCH", &ft0ChDataPtr2);
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) <<
"FT0 simulated: " << nbc <<
" triggers with " << nch <<
" channels";
80 LOG(info) <<
"FT0 decoded : " << nbc2 <<
" triggers with " << nch2 <<
" channels";
81 if (nbc != nbc2 || nch != nch2) {
82 LOG(fatal) <<
"Mismatch between the number of encoded and decoded objects";