Revision: | 1.22 |
Committed: | Mon Jul 13 11:00:25 2009 UTC (15 years, 9 months ago) by loizides |
Content type: | text/plain |
Branch: | MAIN |
CVS Tags: | Mit_025c_branch2, Mit_025c_branch1, Mit_025c_branch0, Mit_025d, Mit_025c, Mit_025b, Mit_025a, Mit_025, Mit_025pre2, Mit_024b, Mit_025pre1, Mit_024a, Mit_024, Mit_023, Mit_022a, Mit_022, Mit_020d, TMit_020d, Mit_020c, Mit_021, Mit_021pre2, Mit_021pre1, Mit_020b, Mit_020a, Mit_020, Mit_020pre1, Mit_018, Mit_017, Mit_017pre3, Mit_017pre2, Mit_017pre1, Mit_016, Mit_015b, Mit_015a, Mit_015, Mit_014e, Mit_014d, Mit_014c, Mit_014b, Mit_014a, Mit_014, Mit_014pre3, Mit_014pre2, Mit_014pre1, Mit_013d, Mit_013c, Mit_013b, Mit_013a, Mit_013, Mit_013pre1, Mit_012i, Mit_012h, Mit_012g, Mit_012f, Mit_012e, Mit_012d, Mit_012c, Mit_012b, Mit_012a, Mit_012, Mit_011a, Mit_011, Mit_010a, Mit_010 |
Branch point for: | Mit_025c_branch |
Changes since 1.21: | +1 -2 lines |
Log Message: | Include files checked. |
# | User | Rev | Content |
---|---|---|---|
1 | loizides | 1.1 | //-------------------------------------------------------------------------------------------------- |
2 | loizides | 1.22 | // $Id: DataObject.h,v 1.21 2009/06/19 07:41:34 loizides Exp $ |
3 | loizides | 1.1 | // |
4 | // DataObject | ||
5 | // | ||
6 | loizides | 1.15 | // This is the common base class for all objects in the tree that do require the TObject |
7 | loizides | 1.17 | // bits to be written out (as opposed to DataBase). Typically these are all objects that |
8 | // can be persistently linked. | ||
9 | loizides | 1.2 | // |
10 | bendavid | 1.11 | // Authors: C.Loizides, J.Bendavid |
11 | loizides | 1.1 | //-------------------------------------------------------------------------------------------------- |
12 | |||
13 | loizides | 1.13 | #ifndef MITANA_DATATREE_DATAOBJECT_H |
14 | #define MITANA_DATATREE_DATAOBJECT_H | ||
15 | loizides | 1.4 | |
16 | loizides | 1.17 | #include "MitAna/DataTree/interface/ObjTypes.h" |
17 | loizides | 1.4 | #include <TObject.h> |
18 | bendavid | 1.10 | #include <TROOT.h> |
19 | #include <TClass.h> | ||
20 | #include <TBranchElement.h> | ||
21 | #include <TRefTable.h> | ||
22 | #include <TProcessID.h> | ||
23 | loizides | 1.4 | |
24 | paus | 1.12 | namespace mithep |
25 | loizides | 1.1 | { |
26 | class DataObject : public TObject | ||
27 | { | ||
28 | public: | ||
29 | DataObject() {} | ||
30 | loizides | 1.6 | |
31 | loizides | 1.18 | Bool_t Is(EObjType t) const { return (ObjType()==t); } |
32 | Bool_t IsCached() const { return TestBit(23); } | ||
33 | Bool_t MustClear() const { return TestBit(14); } | ||
34 | Bool_t MustDelete() const { return TestBit(15); } | ||
35 | loizides | 1.21 | virtual Int_t ObjId() const { return ObjType()*1000; } |
36 | loizides | 1.18 | virtual EObjType ObjType() const { return kDataObject; } |
37 | loizides | 1.15 | template <class Col> |
38 | loizides | 1.18 | const Col *ParentCol() const; |
39 | loizides | 1.6 | |
40 | protected: | ||
41 | loizides | 1.20 | void ResetCacheBit() { SetBit(23,0); } |
42 | void SetCacheBit() { SetBit(23); } | ||
43 | void SetClearBit() { SetBit(14); } | ||
44 | void SetDeleteBit() { SetBit(15); } | ||
45 | loizides | 1.6 | |
46 | loizides | 1.19 | ClassDef(DataObject, 1) // Common base for objects that do get referenced |
47 | loizides | 1.1 | }; |
48 | loizides | 1.2 | } |
49 | bendavid | 1.10 | |
50 | //-------------------------------------------------------------------------------------------------- | ||
51 | template <class Col> | ||
52 | bendavid | 1.11 | const Col* mithep::DataObject::ParentCol() const |
53 | bendavid | 1.10 | { |
54 | loizides | 1.15 | // Return pointer to parent collection. SLOW, but faster than looping over collections! |
55 | // Also note this function will only work for objects which were referenced prior to being | ||
56 | // written. Otherwise a null pointer will be returned. | ||
57 | bendavid | 1.10 | |
58 | loizides | 1.19 | if (!this->TestBit(kIsReferenced)) |
59 | return 0; | ||
60 | bendavid | 1.16 | |
61 | bendavid | 1.10 | TRefTable *table = TRefTable::GetRefTable(); |
62 | if (!table) | ||
63 | loizides | 1.19 | return 0; |
64 | bendavid | 1.16 | |
65 | UInt_t uid = this->GetUniqueID(); | ||
66 | loizides | 1.19 | //cast away const is a hack, this is fixed in newer ROOT versions |
67 | bendavid | 1.16 | TProcessID *pid = TProcessID::GetProcessWithUID(uid, const_cast<DataObject*>(this)); |
68 | loizides | 1.19 | if (!pid) |
69 | return 0; | ||
70 | bendavid | 1.16 | table->SetUID(uid, pid); |
71 | table->Notify(); | ||
72 | loizides | 1.19 | |
73 | loizides | 1.15 | TBranchElement *trackParent = |
74 | bendavid | 1.16 | static_cast<TBranchElement*>(table->GetParent(uid, pid)); |
75 | loizides | 1.19 | if (!trackParent) |
76 | return 0; | ||
77 | |||
78 | const Col *colObj=0; | ||
79 | |||
80 | bendavid | 1.10 | while (!colObj) { |
81 | if (!trackParent) | ||
82 | return colObj; | ||
83 | loizides | 1.15 | colObj = dynamic_cast<Col*> |
84 | bendavid | 1.16 | (reinterpret_cast<TObject*>(static_cast<TBranchElement*>(trackParent)->GetObject())); |
85 | loizides | 1.15 | if (colObj) |
86 | break; | ||
87 | trackParent = static_cast<TBranchElement*>(trackParent->GetMother()); | ||
88 | bendavid | 1.10 | } |
89 | loizides | 1.15 | return colObj; |
90 | bendavid | 1.10 | } |
91 | loizides | 1.3 | #endif |