]>
Commit | Line | Data |
---|---|---|
450e0b36 | 1 | /************************************************************************** |
2 | * This file is property of and copyright by the ALICE HLT Project * | |
3 | * All rights reserved. * | |
4 | * * | |
5 | * Primary Authors: * | |
6 | * Artur Szostak <artursz@iafrica.com> * | |
7 | * * | |
8 | * Permission to use, copy, modify and distribute this software and its * | |
9 | * documentation strictly for non-commercial purposes is hereby granted * | |
10 | * without fee, provided that the above copyright notice appears in all * | |
11 | * copies and that both the copyright notice and this permission notice * | |
12 | * appear in the supporting documentation. The authors make no claims * | |
13 | * about the suitability of this software for any purpose. It is * | |
14 | * provided "as is" without express or implied warranty. * | |
15 | **************************************************************************/ | |
16 | ||
17 | /* $Id: $ */ | |
18 | ||
19 | /// | |
20 | /// @file AliHLTMUONEvent.cxx | |
21 | /// @author Artur Szostak <artursz@iafrica.com> | |
22 | /// @date 29 Sep 2007 | |
23 | /// @brief Implementation of the AliHLTMUONEvent class. | |
24 | /// | |
25 | /// The class is used to store all ROOTified data objects from the dHLT chain | |
26 | /// for a single event together. | |
27 | ||
28 | #include "AliHLTMUONEvent.h" | |
29 | #include "AliHLTMUONDecision.h" | |
f30da7b8 | 30 | #include "AliLog.h" |
450e0b36 | 31 | #include <iostream> |
32 | ||
33 | ClassImp(AliHLTMUONEvent); | |
34 | ||
35 | ||
f30da7b8 | 36 | AliHLTMUONEvent::AliHLTMUONEvent(const AliHLTMUONEvent& event) : |
92aebaf3 | 37 | TObject(event), |
f30da7b8 | 38 | fEventId(event.fEventId), |
39 | fArray() | |
40 | { | |
41 | /// Copy constructor performs a deep copy of the object. | |
42 | ||
43 | fEventId = event.fEventId; | |
44 | fArray.SetOwner(kTRUE); | |
45 | TIter next(&event.fArray); | |
46 | TObject* obj = NULL; | |
47 | while ( (obj = next()) != NULL ) | |
48 | { | |
49 | fArray.Add(obj->Clone()); | |
50 | } | |
51 | } | |
52 | ||
53 | ||
54 | AliHLTMUONEvent& AliHLTMUONEvent::operator = (const AliHLTMUONEvent& event) | |
55 | { | |
56 | /// The assignment operator performs a deep copy of the object. | |
57 | ||
92aebaf3 | 58 | if (this == &event) return *this; |
f30da7b8 | 59 | TObject::operator = (event); |
60 | fEventId = event.fEventId; | |
61 | fArray.Clear(); | |
62 | TIter next(&event.fArray); | |
63 | TObject* obj = NULL; | |
64 | while ( (obj = next()) != NULL ) | |
65 | { | |
66 | fArray.Add(obj->Clone()); | |
67 | } | |
68 | return *this; | |
69 | } | |
70 | ||
71 | ||
450e0b36 | 72 | const AliHLTMUONDecision* AliHLTMUONEvent::FindDecision() const |
73 | { | |
74 | /// Finds the decision object in the event from the list of dHLT objects. | |
75 | /// There should only be one such object in the event. If not, then only | |
76 | /// the first object found is returned. You will need to manually search | |
77 | /// for the other objects. | |
78 | /// \returns The AliHLTMUONDecision object in the event or NULL if none exists. | |
79 | ||
80 | for (Int_t i = 0; i < fArray.GetEntriesFast(); i++) | |
81 | { | |
82 | if (fArray[i]->IsA() == AliHLTMUONDecision::Class()) | |
83 | { | |
84 | return static_cast<const AliHLTMUONDecision*>(fArray[i]); | |
85 | } | |
86 | } | |
87 | ||
88 | return NULL; | |
89 | } | |
90 | ||
91 | ||
92 | void AliHLTMUONEvent::Print(Option_t* option) const | |
93 | { | |
94 | /// | |
95 | /// Inherited from TObject. Prints the contents of the event objects in fArray. | |
96 | /// \param option This is an option string that is just passed on to individual | |
97 | /// objects in the event's fArray list of objects. | |
98 | /// | |
99 | ||
100 | std::cout << "################## EVENT: " << fEventId << " ##################" << std::endl; | |
101 | for (Int_t i = 0; i < fArray.GetEntriesFast(); i++) | |
102 | if (fArray[i] != NULL) fArray[i]->Print(option); | |
103 | } | |
f30da7b8 | 104 | |
105 | ||
106 | void AliHLTMUONEvent::Clear(Option_t* option) | |
107 | { | |
108 | /// Clears the internal array of event objects. | |
109 | ||
110 | fEventId = AliHLTEventID_t(-1); | |
111 | fArray.Clear(option); | |
112 | } | |
113 | ||
114 | ||
115 | void AliHLTMUONEvent::Copy(TObject& object) const | |
116 | { | |
117 | /// Deep copy this object to the target object. | |
118 | /// \param object The target object to copy to. | |
119 | ||
120 | if (object.IsA() != this->IsA()) | |
121 | { | |
122 | AliError(Form("Cannot copy an object of type %s to a type of %s.", | |
123 | this->ClassName(), object.ClassName() | |
124 | )); | |
125 | return; | |
126 | } | |
127 | ||
128 | TObject::Copy(object); | |
129 | AliHLTMUONEvent& event = static_cast<AliHLTMUONEvent&>(object); | |
130 | event.fEventId = fEventId; | |
131 | event.fArray.Clear(); | |
132 | TIter next(&fArray); | |
133 | TObject* obj = NULL; | |
134 | while ( (obj = next()) != NULL ) | |
135 | { | |
136 | event.fArray.Add(obj->Clone()); | |
137 | } | |
138 | } | |
139 |