ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/DataObject.h
Revision: 1.10
Committed: Thu Jul 17 16:37:37 2008 UTC (16 years, 9 months ago) by bendavid
Content type: text/plain
Branch: MAIN
Changes since 1.9: +30 -1 lines
Log Message:
Added ability to find parent collection of any data object

File Contents

# User Rev Content
1 loizides 1.1 //--------------------------------------------------------------------------------------------------
2 bendavid 1.10 // $Id: DataObject.h,v 1.9 2008/07/14 20:55:19 loizides Exp $
3 loizides 1.1 //
4     // DataObject
5     //
6 loizides 1.2 // This is the common base class for all objects in the tree.
7     //
8 loizides 1.1 // Authors: C.Loizides
9     //--------------------------------------------------------------------------------------------------
10    
11 loizides 1.4 #ifndef DATATREE_DATAOBJECT_H
12     #define DATATREE_DATAOBJECT_H
13    
14     #include <TObject.h>
15 bendavid 1.10 #include <TROOT.h>
16     #include <TClass.h>
17     #include <TBranchElement.h>
18     #include <TRefTable.h>
19     #include <TProcessID.h>
20 loizides 1.4 #include "MitAna/DataTree/interface/Types.h"
21    
22 loizides 1.1 namespace mithep
23     {
24     class DataObject : public TObject
25     {
26     public:
27     DataObject() {}
28     ~DataObject() {}
29 loizides 1.6
30 loizides 1.9 Bool_t MustClear() const { return TestBit(14); }
31     Bool_t MustDelete() const { return TestBit(15); }
32     Bool_t IsCached() const { return TestBit(23); }
33 bendavid 1.10 template <class Col> Col* ParentCol();
34 loizides 1.6
35     protected:
36     void SetClearBit() { SetBit(14); }
37 loizides 1.8 void SetDeleteBit() { SetBit(15); }
38     void SetCacheBit() { SetBit(23); }
39     void ResetCacheBit() { SetBit(23,0); }
40 loizides 1.6
41 loizides 1.5 ClassDef(DataObject, 1) // Basic data object class
42 loizides 1.1 };
43 loizides 1.2 }
44 bendavid 1.10
45     //--------------------------------------------------------------------------------------------------
46     template <class Col>
47     Col* mithep::DataObject::ParentCol()
48     {
49     // Return pointer to parent collection. SLOW!
50    
51     Col* colObj=0;
52     TRefTable *table = TRefTable::GetRefTable();
53     if (!table)
54     return colObj;
55     table->SetUID(this->GetUniqueID(), (TProcessID*)gROOT->GetUUIDs());
56     table->Notify();
57     TBranchElement *trackParent = (TBranchElement*)(table->GetParent(this->GetUniqueID(), TProcessID::GetProcessWithUID(this->GetUniqueID(),this)));
58     while (!colObj) {
59     if (!trackParent)
60     return colObj;
61     colObj = dynamic_cast<Col*>((TObject*)((TBranchElement*)trackParent)->GetObject());
62     if (!colObj)
63     trackParent = dynamic_cast<TBranchElement*>(trackParent->GetMother());
64     }
65     return colObj;
66     }
67 loizides 1.3 #endif