I have a TTree containing a TClonesArrays in a branch, holding hit objects from my MC simulation output. The same tree has another branch containing a MC truth object. To be precise:
root [2] GGSEventsTree->Print()
******************************************************************************
*Tree :GGSEventsTree: GGS events tree. Info: Hits MCTruth *
*Entries : 1000 : Total = 2822366 bytes File Size = 1126428 *
* : : Tree compression factor = 2.50 *
******************************************************************************
*Br 0 :BARS-GGSIntHits : Int_t BARS-GGSIntHits_ *
*Entries : 1000 : Total Size= 12206 bytes File Size = 2821 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 2.87 *
*............................................................................*
*Br 1 :BARS-GGSIntHits.fUniqueID : UInt_t fUniqueID[BARS-GGSIntHits_] *
*Entries : 1000 : Total Size= 55332 bytes File Size = 2598 *
*Baskets : 2 : Basket Size= 32000 bytes Compression= 21.05 *
*............................................................................*
*Br 2 :BARS-GGSIntHits.fBits : UInt_t fBits[BARS-GGSIntHits_] *
*Entries : 1000 : Total Size= 55308 bytes File Size = 2625 *
*Baskets : 2 : Basket Size= 32000 bytes Compression= 20.83 *
*............................................................................*
*Br 3 :BARS-GGSIntHits.eDepTimeBin : TArrayF eDepTimeBin[BARS-GGSIntHits_]*
*Entries : 1000 : Total Size= 106026 bytes File Size = 43622 *
*Baskets : 4 : Basket Size= 32000 bytes Compression= 2.42 *
*............................................................................*
*Br 4 :BARS-GGSIntHits.time : Float_t time[BARS-GGSIntHits_] *
*Entries : 1000 : Total Size= 55302 bytes File Size = 47284 *
*Baskets : 2 : Basket Size= 32000 bytes Compression= 1.16 *
*............................................................................*
*Br 5 :BARS-GGSIntHits._volumeIndex : *
* | UInt_t _volumeIndex[BARS-GGSIntHits_] *
*Entries : 1000 : Total Size= 55350 bytes File Size = 24114 *
*Baskets : 2 : Basket Size= 32000 bytes Compression= 2.27 *
*............................................................................*
*Br 6 :BARS-GGSPartHits : TObjArray *
*Entries : 1000 : Total Size= 2374227 bytes File Size = 964293 *
*Baskets : 74 : Basket Size= 32000 bytes Compression= 2.46 *
*............................................................................*
*Branch :mcTruthInfo *
*Entries : 1000 : BranchElement (see below) *
*............................................................................*
*Br 7 :fUniqueID : UInt_t *
*Entries : 1000 : Total Size= 4579 bytes File Size = 135 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 30.26 *
*............................................................................*
*Br 8 :fBits : UInt_t *
*Entries : 1000 : Total Size= 8567 bytes File Size = 1394 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 5.80 *
*............................................................................*
*Br 9 :eventID : Int_t *
*Entries : 1000 : Total Size= 4569 bytes File Size = 1526 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 2.68 *
*............................................................................*
*Br 10 :nDiscarded : UInt_t *
*Entries : 1000 : Total Size= 4584 bytes File Size = 136 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 30.04 *
*............................................................................*
*Br 11 :_primaries : Int_t _primaries_ *
*Entries : 1000 : Total Size= 9855 bytes File Size = 141 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 28.98 *
*............................................................................*
*Br 12 :_primaries.fUniqueID : UInt_t fUniqueID[_primaries_] *
*Entries : 1000 : Total Size= 8728 bytes File Size = 1404 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 5.77 *
*............................................................................*
*Br 13 :_primaries.fBits : UInt_t fBits[_primaries_] *
*Entries : 1000 : Total Size= 8708 bytes File Size = 1408 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 5.75 *
*............................................................................*
*Br 14 :_primaries.PDGCode : Int_t PDGCode[_primaries_] *
*Entries : 1000 : Total Size= 8718 bytes File Size = 1408 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 5.75 *
*............................................................................*
*Br 15 :_primaries.trackID : Int_t trackID[_primaries_] *
*Entries : 1000 : Total Size= 8718 bytes File Size = 1408 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 5.75 *
*............................................................................*
*Br 16 :_primaries.pos[3] : Float_t pos[_primaries_] *
*Entries : 1000 : Total Size= 16704 bytes File Size = 10422 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 1.54 *
*............................................................................*
*Br 17 :_primaries.mom[3] : Float_t mom[_primaries_] *
*Entries : 1000 : Total Size= 16704 bytes File Size = 13157 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 1.22 *
*............................................................................*
*Br 18 :_primaries.time : Float_t time[_primaries_] *
*Entries : 1000 : Total Size= 8703 bytes File Size = 1400 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 5.78 *
*............................................................................*
*Br 19 :_primaries.isTrackKilled : UShort_t isTrackKilled[_primaries_] *
*Entries : 1000 : Total Size= 6748 bytes File Size = 1498 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 4.08 *
*............................................................................*
BARS-GGSIntHits is the TClonesArray and mcTruthInfo the MC truth object I defined. Since the hit array is very big I’d like to read only MC truth when my analysis doesn’t need the hit info. So I set the branch address only for the buffer for mcTruthInfo:
GGSTMCTruthInfo *mcInfoBuffer = NULL;
TTree *tree = (TTree*) (currFile->Get("GGSEventsTree"));
tree->SetBranchAddress("mcTruthInfo", &mcInfoBuffer);
for (int iEv = 0; iEv < tree->GetEntries(); iEv++) {
tree->GetEntry(iEv);
....
Doing this way, the readout is really slow; I thought that somehw Root is reading also the hit data, even if it resides in a different branch and even if I set the branch address only for MC truth. To verify the hypothesis, I produced a file without the hits TCloneasArray branch:
GGSEventsTree->Print()
[GGSTMCTruthInfo::~GGSTMCTruthInfo]
[GGSTParticle::~GGSTParticle]
******************************************************************************
*Tree :GGSEventsTree: GGS events tree. Info: MCTruth *
*Entries : 1000 : Total = 112246 bytes File Size = 37325 *
* : : Tree compression factor = 2.91 *
******************************************************************************
*Branch :mcTruthInfo *
*Entries : 1000 : BranchElement (see below) *
*............................................................................*
*Br 0 :fUniqueID : UInt_t *
*Entries : 1000 : Total Size= 4579 bytes File Size = 135 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 30.26 *
*............................................................................*
*Br 1 :fBits : UInt_t *
*Entries : 1000 : Total Size= 8567 bytes File Size = 1394 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 5.80 *
*............................................................................*
*Br 2 :eventID : Int_t *
*Entries : 1000 : Total Size= 4569 bytes File Size = 1526 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 2.68 *
*............................................................................*
*Br 3 :nDiscarded : UInt_t *
*Entries : 1000 : Total Size= 4584 bytes File Size = 136 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 30.04 *
*............................................................................*
*Br 4 :_primaries : Int_t _primaries_ *
*Entries : 1000 : Total Size= 9855 bytes File Size = 141 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 28.98 *
*............................................................................*
*Br 5 :_primaries.fUniqueID : UInt_t fUniqueID[_primaries_] *
*Entries : 1000 : Total Size= 8728 bytes File Size = 1404 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 5.77 *
*............................................................................*
*Br 6 :_primaries.fBits : UInt_t fBits[_primaries_] *
*Entries : 1000 : Total Size= 8708 bytes File Size = 1408 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 5.75 *
*............................................................................*
*Br 7 :_primaries.PDGCode : Int_t PDGCode[_primaries_] *
*Entries : 1000 : Total Size= 8718 bytes File Size = 1408 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 5.75 *
*............................................................................*
*Br 8 :_primaries.trackID : Int_t trackID[_primaries_] *
*Entries : 1000 : Total Size= 8718 bytes File Size = 1408 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 5.75 *
*............................................................................*
*Br 9 :_primaries.pos[3] : Float_t pos[_primaries_] *
*Entries : 1000 : Total Size= 16704 bytes File Size = 10422 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 1.54 *
*............................................................................*
*Br 10 :_primaries.mom[3] : Float_t mom[_primaries_] *
*Entries : 1000 : Total Size= 16704 bytes File Size = 13157 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 1.22 *
*............................................................................*
*Br 11 :_primaries.time : Float_t time[_primaries_] *
*Entries : 1000 : Total Size= 8703 bytes File Size = 1400 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 5.78 *
*............................................................................*
*Br 12 :_primaries.isTrackKilled : UShort_t isTrackKilled[_primaries_] *
*Entries : 1000 : Total Size= 6748 bytes File Size = 1498 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 4.08 *
*............................................................................*
applying the same analysis code to this file, the readout is much faster.
I fear that I didn’t correctly split the branches, so that when I request an entry from MC truth branch Root is forced to read from disk also the hits branch. My MC simulation program creates the branches in this way:
outTree->Branch("BARS-GGSIntHit", "TClonesArray", &intHitArray);
outTree->Branch("mcTruthInfo", "GGSTMCTruthInfo", &mcTruthInfo);
Am I doing something wrong? I can post the definitions of GGSTMCTruthInfo class if it can be of any help. Using Root 5.34.10.
Thanks.