diff --git a/tree/tree/inc/TTree.h b/tree/tree/inc/TTree.h index 314d1d9fd9dd20c5c498dc0aff934427f903b290..da69e08d5b0358ee00696652123b50a8c866ad63 100644 --- a/tree/tree/inc/TTree.h +++ b/tree/tree/inc/TTree.h @@ -207,6 +207,11 @@ public: kCircular = BIT(12) }; + // Split level modifier + enum { + kSplitCollectionOfPointers = 100 + }; + TTree(); TTree(const char* name, const char* title, Int_t splitlevel = 99); virtual ~TTree(); @@ -218,6 +223,7 @@ public: virtual TFriendElement *AddFriend(TTree* tree, const char* alias = "", Bool_t warn = kFALSE); virtual void AddTotBytes(Int_t tot) { fTotBytes += tot; } virtual void AddZipBytes(Int_t zip) { fZipBytes += zip; } + virtual void AutoFlush(); virtual Long64_t AutoSave(Option_t* option = ""); virtual Int_t Branch(TCollection* list, Int_t bufsize = 32000, Int_t splitlevel = 99, const char* name = ""); virtual Int_t Branch(TList* list, Int_t bufsize = 32000, Int_t splitlevel = 99); diff --git a/tree/tree/src/TBranchElement.cxx b/tree/tree/src/TBranchElement.cxx index 3d1882f4b58e249027103ca215e62080ab2ce659..81eb59525c712bf21d66aa6022d9894c584ca955 100644 --- a/tree/tree/src/TBranchElement.cxx +++ b/tree/tree/src/TBranchElement.cxx @@ -249,8 +249,8 @@ void TBranchElement::Init(TTree *tree, TBranch *parent,const char* bname, TStrea //--------------------------------------------------------------------------- // Handling the splitting of the STL collections of pointers //--------------------------------------------------------------------------- - Int_t splitSTLP = splitlevel - (splitlevel%100); - splitlevel %= 100; + Int_t splitSTLP = splitlevel - (splitlevel%TTree::kSplitCollectionOfPointers); + splitlevel %= TTree::kSplitCollectionOfPointers; fCompress = -1; if (fTree->GetDirectory()) { @@ -677,7 +677,7 @@ void TBranchElement::Init(TTree *tree, TBranch *parent, const char* bname, TClon SetAutoDelete(kFALSE); // create sub branches if requested by splitlevel - if (splitlevel%100 > 0) { + if (splitlevel%TTree::kSplitCollectionOfPointers > 0) { fType = 3; // ===> Create a leafcount TLeaf* leaf = new TLeafElement(this, name, fID, fStreamerType); @@ -812,8 +812,8 @@ void TBranchElement::Init(TTree *tree, TBranch *parent, const char* bname, TVirt SetAutoDelete(kFALSE); // create sub branches if requested by splitlevel - if ( (splitlevel%100 > 0 && fBranchClass.GetClass() && fBranchClass.GetClass()->CanSplit()) || - (cont->HasPointers() && splitlevel > 100 && cont->GetValueClass() && cont->GetValueClass()->CanSplit() ) ) + if ( (splitlevel%TTree::kSplitCollectionOfPointers > 0 && fBranchClass.GetClass() && fBranchClass.GetClass()->CanSplit()) || + (cont->HasPointers() && splitlevel > TTree::kSplitCollectionOfPointers && cont->GetValueClass() && cont->GetValueClass()->CanSplit() ) ) { fType = 4; // ===> Create a leafcount @@ -1373,7 +1373,7 @@ void TBranchElement::FillLeaves(TBuffer& b) Error("FillLeaves", "Cannot get streamer info for branch '%s'", GetName()); return; } - if( fSplitLevel >= 100 ) + if( fSplitLevel >= TTree::kSplitCollectionOfPointers ) si->WriteBufferSTLPtrs(b, GetCollectionProxy(), n, fID, fOffset ); else si->WriteBufferSTL(b, GetCollectionProxy(), n, fID, fOffset ); @@ -2064,7 +2064,7 @@ Double_t TBranchElement::GetValue(Int_t j, Int_t len, Bool_t subarr) const return GetInfo()->GetValueClones(clones, prID, j/len, j%len, fOffset); } else if (fType == 41) { TVirtualCollectionProxy::TPushPop helper(((TBranchElement*) this)->GetCollectionProxy(), object); - if( fSplitLevel < 100 ) + if( fSplitLevel < TTree::kSplitCollectionOfPointers ) { if (subarr) return GetInfo()->GetValueSTL(((TBranchElement*) this)->GetCollectionProxy(), prID, j, len, fOffset); @@ -2250,7 +2250,7 @@ void TBranchElement::InitializeOffsets() //------------------------------------------------------------------------ TString stlParentName; Bool_t stlParentNameUpdated = kFALSE; - if( fType == 4 && fSplitLevel > 100 ) + if( fType == 4 && fSplitLevel > TTree::kSplitCollectionOfPointers ) { TBranch *br = GetMother()->GetSubBranch( this ); stlParentName = br->GetName(); @@ -3173,7 +3173,7 @@ void TBranchElement::ReadLeaves(TBuffer& b) //------------------------------------------------------------------------ // We have split this stuff, so we need to create the the pointers //----------------------------------------------------------------------- - if( proxy->HasPointers() && fSplitLevel > 100 ) + if( proxy->HasPointers() && fSplitLevel > TTree::kSplitCollectionOfPointers ) { TClass *elClass = proxy->GetValueClass(); @@ -3202,7 +3202,7 @@ void TBranchElement::ReadLeaves(TBuffer& b) TStreamerInfo *info = GetInfo(); TVirtualCollectionProxy *proxy = GetCollectionProxy(); TVirtualCollectionProxy::TPushPop helper(proxy, fObject); - if( fSplitLevel >= 100 ) { + if( fSplitLevel >= TTree::kSplitCollectionOfPointers ) { info->ReadBufferSTLPtrs(b, proxy, fNdata, fID, fOffset); for(UInt_t ii=0; ii < fIDs.size(); ++ii) { info->ReadBufferSTLPtrs(b, proxy, fNdata, fIDs[ii], fOffset); @@ -4047,7 +4047,7 @@ void TBranchElement::SetupAddresses() //-------------------------------------------------------------------------- // Check if we are splited STL collection of pointers //-------------------------------------------------------------------------- - if( fType == 41 && fSplitLevel >= 100 ) + if( fType == 41 && fSplitLevel >= TTree::kSplitCollectionOfPointers ) { TBranchElement *parent = (TBranchElement *)GetMother()->GetSubBranch( this ); @@ -4247,8 +4247,8 @@ Int_t TBranchElement::Unroll(const char* name, TClass* clParent, TClass* cl, cha //---------------------------------------------------------------------------- // Handling the case of STL collections of pointers //---------------------------------------------------------------------------- - Int_t splitSTLP = splitlevel - (splitlevel%100); - splitlevel %= 100; + Int_t splitSTLP = splitlevel - (splitlevel%TTree::kSplitCollectionOfPointers); + splitlevel %= TTree::kSplitCollectionOfPointers; TString branchname; diff --git a/tree/tree/src/TTree.cxx b/tree/tree/src/TTree.cxx index 8edc1d8c93ab1c37334262d4a749d6e5b2720c9d..fe2b713ac7ac332f3215980100a887eb5110a015 100644 --- a/tree/tree/src/TTree.cxx +++ b/tree/tree/src/TTree.cxx @@ -134,9 +134,9 @@ // TBranch *branch = tree->Branch( branchname, STLcollection, buffsize, splitlevel); // STLcollection is the address of a pointer to std::vector, std::list, // std::deque, std::set or std::multiset containing pointers to objects. -// If the splitlevel is a value bigger than 100 then the collection -// will be written in split mode. Ie. if it contains objects of any -// types deriving from TTrack this function will sort the objects +// If the splitlevel is a value bigger than 100 (TTree::kSplitCollectionOfPointers) +// then the collection will be written in split mode. Ie. if it contains objects of +// any types deriving from TTrack this function will sort the objects // basing on their type and store them in separate branches in split // mode. // @@ -1842,7 +1842,7 @@ TBranch* TTree::BronchExec(const char* name, const char* classname, void* addr, // the collection contains pointers we can split it //------------------------------------------------------------------------- TBranch *branch; - if( splitlevel > 100 && collProxy->HasPointers() ) + if( splitlevel > kSplitCollectionOfPointers && collProxy->HasPointers() ) branch = new TBranchSTL( this, name, collProxy, bufsize, splitlevel ); else branch = new TBranchElement(this, name, collProxy, bufsize, splitlevel); @@ -1878,7 +1878,7 @@ TBranch* TTree::BronchExec(const char* name, const char* classname, void* addr, // The streamer info is not rebuilt unoptimized. // No dummy top-level branch is created. // No splitting is attempted. - TBranchElement* branch = new TBranchElement(this, name, (TClonesArray*) objptr, bufsize, splitlevel%100); + TBranchElement* branch = new TBranchElement(this, name, (TClonesArray*) objptr, bufsize, splitlevel%kSplitCollectionOfPointers); fBranches.Add(branch); if (isptrptr) { branch->SetAddress(addr); @@ -1950,7 +1950,7 @@ TBranch* TTree::BronchExec(const char* name, const char* classname, void* addr, // Do splitting, if requested. // - if (splitlevel%100 > 0) { + if (splitlevel%kSplitCollectionOfPointers > 0) { // Loop on all public data members of the class and its base classes and create branches for each one. TObjArray* blist = branch->GetListOfBranches(); TIter next(sinfo->GetElements()); @@ -2014,7 +2014,7 @@ TBranch* TTree::BronchExec(const char* name, const char* classname, void* addr, bname.Form("%s", element->GetFullName()); } - if( splitlevel > 100 && element->GetClass() && + if( splitlevel > kSplitCollectionOfPointers && element->GetClass() && element->GetClass()->GetCollectionProxy() && element->GetClass()->GetCollectionProxy()->HasPointers() ) { @@ -3751,11 +3751,11 @@ Int_t TTree::Fill() (fAutoFlush>0 && fEntries%TMath::Max((Long64_t)1,fAutoFlush) == 0) || (fAutoSave >0 && fEntries%TMath::Max((Long64_t)1,fAutoSave) == 0) ) { - //we take the opportunity to Optimizebaskets at this point (it calls FlushBaskets) - OptimizeBaskets(fTotBytes,1,""); - if (gDebug > 0) printf("OptimizeBaskets called at entry %lld, fZipBytes=%lld, fFlushedBytes=%lld\n",fEntries,fZipBytes,fFlushedBytes); + //we take the opportunity to Optimizebaskets at this point (it calls FlushBaskets) + OptimizeBaskets(fTotBytes,1,""); + if (gDebug > 0) Info("OptimizeBaskets called at entry %lld, fZipBytes=%lld, fFlushedBytes=%lld\n",fEntries,fZipBytes,fFlushedBytes); fFlushedBytes = fZipBytes; - fAutoFlush = fEntries; // Use test on entries rather than bytes + fAutoFlush = fEntries; // Use test on entries rather than bytes // subsequently in run if (fAutoSave < 0) { // Set fAutoSave to the largest integer multiple of @@ -3766,17 +3766,17 @@ Int_t TTree::Fill() fAutoSave = fEntries*(fAutoSave/fEntries); } if (fAutoSave!=0 && fEntries >= fAutoSave) AutoSave(); // FlushBaskets not called in AutoSave - if (gDebug > 0) printf("TTree::Fill: First AutoFlush. fAutoFlush = %lld, fAutoSave = %lld\n", fAutoFlush, fAutoSave); + if (gDebug > 0) Info("TTree::Fill: First AutoFlush. fAutoFlush = %lld, fAutoSave = %lld\n", fAutoFlush, fAutoSave); } } else if (fEntries > 1 && fEntries%fAutoFlush == 0) { if (fAutoSave != 0 && fEntries%fAutoSave == 0) { //We are at an AutoSave point. AutoSave flushes baskets and saves the Tree header AutoSave("flushbaskets"); - if (gDebug > 0) printf("AutoSave called at entry %lld, fZipBytes=%lld, fSavedBytes=%lld\n",fEntries,fZipBytes,fSavedBytes); + if (gDebug > 0) Info("AutoSave called at entry %lld, fZipBytes=%lld, fSavedBytes=%lld\n",fEntries,fZipBytes,fSavedBytes); } else { //We only FlushBaskets FlushBaskets(); - if (gDebug > 0) printf("FlushBasket called at entry %lld, fZipBytes=%lld, fFlushedBytes=%lld\n",fEntries,fZipBytes,fFlushedBytes); + if (gDebug > 0) Info("FlushBasket called at entry %lld, fZipBytes=%lld, fFlushedBytes=%lld\n",fEntries,fZipBytes,fFlushedBytes); } fFlushedBytes = fZipBytes; }