BRAT 2.4.5
Class index
Full class index
brahmlib
BRAHMS
ROOT page
//____________________________________________________________________
//                                                                   
// BrDataObject is the base class for all BRAHMS classes containing
// data, either as raw data from the DAQ or calibrated data from the
// calibration procedures or the results from the reconstruction or
// analysis processors.
//                                                                   
// The main purpose of the BrDataObject class is to provide a uniform
// interface for bookkeeping, information exchange between procedural
// classes and persistent I/O
//                                                                   
// The individual data objects referring to one event are kept with
// the BrEvent object, where they are stored in a hash table using a
// unique name for retrieval.                    
//
// This class defines the method Print, which will print the basic
// information on a data obejct. Derived class should overload this
// method as: 
//
//   void <derived class>::Print(Option_t* option) const { 
//     // Print information on this instance of <derived class>
//     // Options:
//     //    <list options here>
//     // See also BrDataObject for additional options
//     BrDataObject::Print(option); 
//     <print the relevant information> 
//   }
//
// The overloaded method should not print the name or anything like
// that. That is taken care of in BrDataObject::Print. 
//                                                                   
//____________________________________________________________________

//____________________________________________________________________
//
// $Id: BrDataObject.cxx,v 1.1.1.1 2001/06/21 14:54:58 hagel Exp $
// $Author: hagel $
// $Date: 2001/06/21 14:54:58 $
// $Copyright: 2001 BRAHMS Collabortation
//
//____________________________________________________________________
#include "BrDataObject.h"
#include <iostream>
#ifndef ROOT_TClass
#include "TClass.h"
#endif

//____________________________________________________________________
ClassImp(BrDataObject);



//____________________________________________________________________
const Float_t BrDataObject::kInvalidValue = 1E200;


//____________________________________________________________________
 BrDataObject::BrDataObject()
{
  // Default constructor. Does nothing.
  // Don't use this constructor unless you have to and know
  // what you are doing
  // Use BrDataObject(Char_t *name) instead.
  fIsPersistent = kTRUE;
#ifdef _use_creation_id  
  fCreationID   = NULL;
#endif
}

//____________________________________________________________________
 BrDataObject::BrDataObject(const Char_t *name, const Char_t *title)
{
  // Constructor. Create the data container setting the name
  // (and title, if supplied)
  //
  
  SetName(name);
  SetTitle((title ? title : name));
  
  fIsPersistent = kTRUE;
#ifdef _use_creation_id
  fCreationID = NULL;
#endif
}

//____________________________________________________________________
 BrDataObject::~BrDataObject()
{
  // Destructor. Delete BrDataObject and all the data objects
  // currently owned by BrDataObject
#ifdef _use_creation_id  
  if(fCreationID)
    delete fCreationID;
#endif
}

//____________________________________________________________________
 void BrDataObject::SetCreationID(TObject *Creator)
{
  // Store the details on when, by which calling class and by
  // which user the data object was added to the event.
  
  //fCreationID = new BrCreationID(Creator);
#ifdef _use_creation_id    
  fCreationID = new BrCreationID(Creator);
#endif  
}

//____________________________________________________________________
 void BrDataObject::SetName(const Char_t *name) {
  // Set Name of object.  
  // This object does not inherit from TNamed as originally because
  // ROOT crashes when a BrDataObject is used in the top level of a
  // Tree with split=1.
  // Problem was traced back to TString not writing or reading (or
  // both) correctly.  We therefore inherit from TObject and set our
  // own name as a character variable. 
  if(strlen(name)>64) 
    strncpy(fName,name,64);
  else 
    strcpy(fName,name);
}

//____________________________________________________________________
 void BrDataObject::SetTitle(const Text_t *title) {
  // Set Title of object.  
  // This object does not inherit from TNamed as originally because
  // ROOT crashes when a BrDataObject is used in the top level of a
  // Tree with split=1.
  // Problem was traced back to TString not writing or reading (or
  // both) correctly.  We therefore inherit from TObject and set our
  // own title as a character variable. 
  if(strlen(title)>64) 
    strncpy(fTitle,title,64);
  else 
    strcpy(fTitle,title);
}

//____________________________________________________________________
 void BrDataObject::Copy(BrDataObject &dataobject) {
  // Copy method.  
  // Copy All elements of object from argument; also involk copy
  // method of object we inherit from.
  TObject::Copy(dataobject);
  dataobject.fIsPersistent = fIsPersistent;
  dataobject.SetName(fName);
  dataobject.SetTitle(fTitle);
  
  /*
    fIsPersistent = dataobject.IsPersistent();
    strcpy(fName,dataobject.GetName());
    strcpy(fTitle,dataobject.GetTitle());
  */
}

//____________________________________________________________________
 void BrDataObject::Print(Option_t* option) const 
{
  // Print information on this data object. 
  // Options: 
  //    D         Details 
  //    C         Creator information [not used yet]
  TString opt(option); 
  opt.ToLower(); 
  if (opt.Contains("d")) 
    cout << "[" << this << "]" << GetName() 
	 << "(Class: " << IsA()->GetName() << ") " 
	 << endl << "   " << GetTitle() << endl
	 << "Is " << (fIsPersistent ? "" : "n't") << " persistent" 
	 << endl;
  else
    cout << GetName() << " " << GetTitle() << endl;
#ifdef _use_creation_id  
  if (opt.Contains("c") && fCreationID)
    fCreationID->Print();
#endif
    
}

//____________________________________________________________________
// $Log: BrDataObject.cxx,v $
// Revision 1.1.1.1  2001/06/21 14:54:58  hagel
// Initial revision of brat2
//
// Revision 1.13  2001/06/01 15:46:40  cholm
// Fixed creation id class to be more clean.  Now sets the user name
// (if avaliable) has a Print method.
// PRint method in BrDataObject.
// Print method in BrDataTable
// Print method in BrEvent
// Print method in BrEventNode
//
// Revision 1.12  2001/01/29 19:58:49  cholm
// Added konstant kInvalidValue for general use
//
// Revision 1.11  2000/11/15 16:12:27  videbaek
//  file cleanup
//
// Revision 1.10  1999/05/12 16:22:20  hagel
// Implemented + , =+ and = operators for BrEventNode.  These will be useful
// for adding events together.  Has been tested for single pion events and seems
// to work. In the course of implementing this, several conflicts with const were
// identified.  These were cleaned up by adding appropriate const's where needed.
// It was checked that it did not break other things.
//
// Revision 1.9  1998/08/27 21:34:39  hagel
// Change Copy to copy from this to object
//
// Revision 1.7  1998/08/20 14:11:52  hagel
// Add Copy method
//
// Revision 1.6  1998/08/17 16:36:40  hagel
// Make BrDataObject inherit from TObject instead of TNamed
// Include fName and fTitle data members
// Include SetName, GetName, SetTitle, GetTitle methods
// All this done because TTree seems to have problems with TString that is
// used for fName and fTitle in TNamed.
//
// Revision 1.5  1998/08/14 21:26:24  videbaek
// Some cleanup mods
//
// Revision 1.4  1998/08/13 22:20:46  hagel
// Eliminate fCreationID for the moment
//
// Revision 1.3  1998/04/06 21:11:50  videbaek
// Clean up and additions for Win95
//
//

This page automatically generated by script docBrat by Christian Holm

Copyright ; 2002 BRAHMS Collaboration <brahmlib@rcf.rhic.bnl.gov>
Last Update on by

Validate HTML
Validate CSS