Hi Sue, Pasha, enums are not recognized by TTree::Branch in split mode. They are supported by TTree::Bronch in 3.00/06. You can make a test by replacing the line: tree -> Branch("Validity","VldContext",&valid,32000,1); by: tree -> Bronch("Validity","VldContext",&valid,32000,1); Read TTree::Bronch for more info. I am now finishing the implementation of the new split mode. The new split mode (Bronch) has no limitation compared to the non-split mode. With the next major release 3.01 scheduled for early June, Bronch will be renamed Branch. The new split/no-split mode in Trees will have several new features. In addition to the extended C++ support described at http://root.cern.ch/root/SchemaEvolution.html , the new Trees will also be connected with the TFolder structure. Trees can be generated automatically from an existing TFolder hierarchy and vice-versa a TFolder hierarchy automatically generated from a Tree structure. This new functionality will be included in the first development releases of 3.01 in 2 or 3 weeks. Rene Brun Susan Kasahara wrote: > > Hi rooters, > I am having a problem with the ROOT tree splitting method. > I have a simple class "VldContext" with just two data members: > > DetectorType::Detector_t fDetector; > Int_t fTimeStamp; > > The first data member is of an enumerated type Detector_t defined > in a separate class DetectorType. What I would like is to have these > two data members, fDetector and fTimeStamp, be stored on two separate > subbranches of the same TTree. > > I set up a tree with one main branch to hold these VldContext objects > in split mode (split level = 1), using the form: > > TTree* tree = new TTree("TestTree","test tree"); > VldContext* valid = 0; > tree -> Branch("Validity","VldContext",&valid,32000,1); > > And have noticed that although a subbranch is created for the fTimeStamp > data member as expected, no subbranch is created for the fDetector > data member. I am assuming the problem has something to do with > fDetector's specialized enumerated data type that is somehow not being > recognized by ROOT. > > I am attaching the code for the test driver program, the VldContext > class, and the DetectorType class. These tests are being run on a > RH Linux system using gcc 2.95.2 and ROOT version 3.00.04. > > Any ideas as to how to fix this? > > Thanks, > Sue Kasahara > > **************** The test driver program ********************************** > #include <iostream.h> > #include "TROOT.h" > #include "TFile.h" > #include "TTree.h" > #include "VldContext.h" > > TROOT root("TestWrt","MINOS Persistency Package Test Write"); > > int main() { > > TFile* file = TFile::Open("test.root","RECREATE","test file"); > TTree* tree = new TTree("TestTree","test tree"); > > VldContext* valid = 0; > tree -> Branch("Validity","VldContext",&valid,32000,1); > > // Begin entry loop > Int_t nent = 100; > for (Int_t ient=0; ient < nent; ient++) { > DetectorType::Detector_t dtype = DetectorType::kCalib; // detector type > Int_t tstamp = 100; > VldContext* valid = new VldContext(dtype,tstamp); > if (valid) { > tree -> Fill(); > } > delete valid; // clean up validity object > } > > tree -> Write(); > tree -> Print(); > file -> Close(); > > return 0; > > } > > **************** The VldContext class ********************************** > > #include "TObject.h" > #include "DetectorType.h" > > class VldContext : public TObject { > > public: > > VldContext(); > VldContext(const DetectorType::Detector_t &detector, > const Int_t &time); > virtual ~VldContext(); > > protected: > > DetectorType::Detector_t fDetector; > Int_t fTimeStamp; > > private: > > ClassDef(VldContext,1) // VldContext version 1 > }; > > #include "VldContext.h" > > ClassImp(VldContext) > > VldContext::VldContext() > { > // Default constructor > } > > VldContext::VldContext(const DetectorType::Detector_t &detector, > const Int_t &tstamp) > : fDetector(detector), fTimeStamp(tstamp) > { > // normal constructor > } > > VldContext::~VldContext() > { > // delete all the owned sub-objects > > } > > ********************The DetectorType class********************************** > > #include "Rtypes.h" > > class DetectorType { > public: > typedef enum EDetectorType { > kNear = 0x01, > kFar = 0x02, > kCalib = 0x04, > kTestStand = 0x08, > kMapper = 0x10 > } Detector_t; > > // no ctor or dtor's - this class consists of only static members > > // Translation from enum to character strings > > static char *AsString(Detector_t detector) { > switch (detector) { > case kNear: return "Near"; break; > case kFar: return "Far"; break; > case kCalib: return "Calib"; break; > case kTestStand: return "TestStand"; break; > case kMapper: return "Mapper"; break; > default: return "Unknown"; break; > } > } > > ClassDef(DetectorType,1) > > }; > > #include "DetectorType.h" > > ClassImp(DetectorType)
This archive was generated by hypermail 2b29 : Fri Jun 08 2001 - 11:51:21 MEST