Skip to content
Snippets Groups Projects

Draft: Test if empty branches in the output file exist

Open Florian Uhlig requested to merge f.uhlig/cbmroot:test_for_empty_branches into master
3 unresolved threads

Add a macro which loops over all defined branches according to the BranchList folder and checks is empty branches exist. Empty branches indicate a problem. Add test to the CI which execute the macro for all created output files.

Merge request reports

Members who can merge are allowed to add commits.

Merge request pipeline #34934 failed

Merge request pipeline failed for 5af40460

Approval is optional

Set by to be merged automatically when the pipeline succeeds

Ready to merge by members who can write to the target branch.

Merge details

  • The source branch is 111 commits behind the target branch.
  • 1 commit and 1 merge commit will be added to .
  • Source branch will not be deleted.
  • Auto-merge enabled

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
23 std::unique_ptr<TList> _list{dynamic_cast<TList*>(_file->Get("BranchList"))};
24
25 Int_t retVal = 0;
26
27 // Loop over all branches defined in the BranchList folder. These are the
28 // branches which were registered by the framework
29 for (const auto&& obj : *_list) {
30 // The TList contains a list of TObjString
31 // access the content with GetString()
32 TString branchName = static_cast<TObjString*>(obj)->GetString();
33 std::cout << "Checking if branch " << branchName << " is empty" << std::endl;
34
35 TBranch* _branch = inTree->FindBranch(branchName);
36
37 // Skip branches which ends with a dot since these are not TClonesArrays
38 // or std::vector but some auxillary data
  • 8 #include "TLeaf.h"
    9 #include "TList.h"
    10 #include "TObjString.h"
    11 #include "TString.h"
    12 #include "TTree.h"
    13
    14 #include <algorithm>
    15 #include <iostream>
    16 #endif
    17
    18 int checkBranchFilled(TString inFile)
    19 {
    20 //Open the file and acces the Tree as well as the TList with branch names
    21 std::unique_ptr<TFile> _file{TFile::Open(inFile.Data(), "READ")};
    22 std::unique_ptr<TTree> inTree{dynamic_cast<TTree*>(_file->Get("cbmsim"))};
    23 std::unique_ptr<TList> _list{dynamic_cast<TList*>(_file->Get("BranchList"))};
  • 35 TBranch* _branch = inTree->FindBranch(branchName);
    36
    37 // Skip branches which ends with a dot since these are not TClonesArrays
    38 // or std::vector but some auxillary data
    39 // Also skip entries in the BranchList folder which do not contain a
    40 // branch name. This can happen if the branch was only present in memory
    41 // and wasn't written to file
    42 if (!_branch || branchName.EndsWith(".")) continue;
    43
    44 TObjArray* leaves = _branch->GetListOfLeaves();
    45 TObjArray* subbranch = _branch->GetListOfBranches();
    46
    47 // The following code I put together after one day of trial and error.
    48 // Unfortunately I can't really explain it but when the main branch
    49 // eg. MvdDigi_ is empty the maximum and the minimum extracted from the
    50 // leaf is equal which is used as trigger to indicate an empty branch
    • Comment on lines +47 to +50

      I hesitate to ask this question, but is it not enough to ask for the number of entries in the branch and its sub-branches?

      Plus: if there are a number of equal objects in the branch, will not this test also think its empty?

    • Please register or sign in to reply
  • added 451 commits

    Compare with previous version

  • Florian Uhlig added 15 commits

    added 15 commits

    Compare with previous version

  • added 112 commits

    Compare with previous version

  • added 44 commits

    Compare with previous version

  • Please register or sign in to reply
    Loading