00001 00002 // 00003 // DemoNtupleRecord 00004 // 00005 // DemoNtupleRecord is a demo ntuple record class 00006 // 00007 // Author: S. Kasahara Feb, 2003 00009 00010 #include <iostream> 00011 using std::endl; 00012 00013 #include "TClonesArray.h" 00014 #include "Record/RecArrayAllocator.h" 00015 #include "Record/demo/DemoNtupleRecord.h" 00016 00017 ClassImp(DemoNtupleRecord) 00018 00019 // Definition of methods (alphabetical order) 00020 // *************************************************** 00021 00022 DemoNtupleRecord::DemoNtupleRecord() : fMyData(-1),fVectors(0) { 00023 // 00024 // Purpose: Default constructor. 00025 // 00026 // Arguments: none. 00027 // 00028 // Contact: S. Kasahara 00029 // 00030 00031 this -> Init(); 00032 00033 00034 } 00035 00036 DemoNtupleRecord::DemoNtupleRecord(const RecHeader& hdr) : 00037 RecRecordImp<RecHeader>(hdr),fMyData(-1),fVectors(0) { 00038 // 00039 // Purpose: Normal constructor. 00040 // 00041 // Arguments: header. 00042 // 00043 // Contact: S. Kasahara 00044 // 00045 00046 this -> Init(); 00047 00048 } 00049 00050 DemoNtupleRecord::~DemoNtupleRecord() { 00051 // 00052 // Purpose: Destructor 00053 // 00054 // Arguments: n/a 00055 // 00056 // Return: n/a 00057 // 00058 // Contact: S. Kasahara 00059 // 00060 00061 RecArrayAllocator& allocator = RecArrayAllocator::Instance(); 00062 if ( fVectors ) { allocator.ReleaseArray( fVectors ); fVectors = 0; } 00063 00064 } 00065 00066 void DemoNtupleRecord::Init() { 00067 // 00068 // Purpose: Perform customized initialization appropriate for SR records 00069 // 00070 // Arguments: none. 00071 // 00072 // Return: none. 00073 // 00074 // Contact: S. Kasahara 00075 // 00076 00077 // See description in RecArrayAllocator for description & reason for use 00078 RecArrayAllocator& allocator = RecArrayAllocator::Instance(); 00079 if ( !fVectors ) fVectors = allocator.GetArray("TVector3"); 00080 00081 } 00082 00083 std::ostream& DemoNtupleRecord::Print(std::ostream& os) const { 00084 // 00085 // Purpose: Print status of ntuple record on ostream. 00086 // 00087 // Arguments: os ostream to display on. 00088 // 00089 // Return: ostream reference. 00090 // 00091 // Contact: S. Kasahara 00092 // 00093 00094 os << "DemoNtupleRecord::Print" << endl; 00095 RecRecordImp<RecHeader>::Print(os); 00096 os << "MyData = " << fMyData << endl; 00097 os << "Vectors TClonesArray has " << fVectors->GetEntriesFast() 00098 << " entries" << endl; 00099 for ( int i = 0; i < fVectors->GetEntriesFast(); i++ ) { 00100 fVectors->At(i)->Print(); 00101 } 00102 00103 return os; 00104 00105 } 00106 00107 void DemoNtupleRecord::Print(const Option_t* /* option */) const { 00108 // 00109 // Purpose: Print record in form supported by TObject::Print. 00110 // 00111 // Arguments: option (not used). 00112 // 00113 // Return: none. 00114 // 00115 // Contact: S. Kasahara 00116 // 00117 00118 Print(std::cout); 00119 return; 00120 00121 } 00122 00123 00124 00125 00126 00127 00128 00129 00130
1.3.9.1