gundam-organization / gundam

GUNDAM, for Generalized and Unified Neutrino Data Analysis Methods, is a suite of applications which aims at performing various statistical analysis with different purposes and setups.
GNU Lesser General Public License v2.1
13 stars 10 forks source link

Using TGraph object as Parameter #472

Open jedori0228 opened 4 months ago

jedori0228 commented 4 months ago

Hi! In our input MC rootfile, we are saving TGraph objects into the TTree;

*............................................................................*
*Br  138 :ZExpA1CCQE : TGraph                                                *
*Entries :     1632 : Total  Size=     405032 bytes  File Size  =      35914 *
*Baskets :       13 : Basket Size=      32000 bytes  Compression=  11.26     *
*............................................................................*

This object is an event-by-event reweights (i.e., a TGraph where x:sigmas, y:reweights) and we use this dial with a Parameter definition as follows:

- parameterName: "ZExpA1CCQE"
  isEnabled: true
  dialSetDefinitions:
    - dialType: Graph
      minimumGraphResponse: 0
      dialLeafName: "ZExpA1CCQE"

When I run gundamFitter, we saw an error message:

libc++abi: terminating due to uncaught exception of type std::runtime_error: GenericToolbox::BranchBuffer::buildBuffer(): empty buffer size for branch: ZExpA1CCQE

After tracking down the source of the error, I found that in cpp-generic-toolbox/include/GenericToolbox.Root.h#L1531, the Leaf of this Branch has l->GetNdata() = 1 and l->GetLenType() = 0, thus got bufferSize = 0. In our on-going analysis, we put this TGraph into a TClonesArray, and there I saw the Leaf got l->GetNdata() = 0 and l->GetLenType() = 4, then had no issue. We can keep using TClonesArray, but wonder if using TGraph (or TSpline3) directly without TClonesArray can be also supported, or our configuration needs to be updated.

nadrino commented 4 months ago

Hello Jaesung! (Nice to meet you!)

What is the type of TObject you put in the TTree for ZExpA1CCQE?

jedori0228 commented 4 months ago

Below is what we are basically doing:

    TGraph *gr = nullptr;
    theTree.Branch( "ZExpA1CCQE", &gr );
nadrino commented 4 months ago

Ok I see 🤔

We are actually using l->GetNdata() to figure out whether or not we should use an extended buffer for non-primitive objects. TClonesArray or TSpline3 typically return 0 here.

You could try to use TClonesArray in the meantime

jedori0228 commented 4 months ago

I also tested saving TSpline instead, but getting same error. TTree print out is:

*............................................................................*
*Br  138 :ZExpA1CCQE : TSpline3                                              *
*Entries :     1627 : Total  Size=     974351 bytes  File Size  =     155105 *
*Baskets :       31 : Basket Size=      32000 bytes  Compression=   6.28     *
*............................................................................*

, and also seeing

[JSKIMDEBUG][BranchBuffer::buildBuffer] _branchPtr_->GetName() = ZExpA1CCQE
[JSKIMDEBUG][BranchBuffer::buildBuffer] - nLeaves = 1
[JSKIMDEBUG][BranchBuffer::buildBuffer]   - iLeaf = 0
[JSKIMDEBUG][BranchBuffer::buildBuffer]     - l->GetNdata() = 1
[JSKIMDEBUG][BranchBuffer::buildBuffer]     - l->GetLenType() = 0
nadrino commented 4 months ago

Thank you very much @jedori0228

It seems like we need a new way to find out if a leaf is a TObject. TClonesArray should still work fine (we are actively using it for event-by-event dials).