Line data Source code
1 : // $Id$
2 : /**************************************************************************
3 : * This file is property of and copyright by the ALICE HLT Project *
4 : * ALICE Experiment at CERN, All rights reserved. *
5 : * *
6 : * Primary Authors: Artur Szostak <artursz@iafrica.com> *
7 : * for The ALICE HLT Project. *
8 : * *
9 : * Permission to use, copy, modify and distribute this software and its *
10 : * documentation strictly for non-commercial purposes is hereby granted *
11 : * without fee, provided that the above copyright notice appears in all *
12 : * copies and that both the copyright notice and this permission notice *
13 : * appear in the supporting documentation. The authors make no claims *
14 : * about the suitability of this software for any purpose. It is *
15 : * provided "as is" without express or implied warranty. *
16 : **************************************************************************/
17 :
18 : /// @file AliHLTTriggerDecision.cxx
19 : /// @author Artur Szostak <artursz@iafrica.com>
20 : /// @date 21 Nov 2008
21 : /// @brief Implementation of the AliHLTTriggerDecision class.
22 : ///
23 : /// The trigger decision class stores the HLT decision from an AliHLTTrigger component.
24 :
25 : #include "AliHLTTriggerDecision.h"
26 : #include "Riostream.h"
27 :
28 126 : ClassImp(AliHLTTriggerDecision)
29 :
30 :
31 : AliHLTTriggerDecision::AliHLTTriggerDecision() :
32 0 : TObject(),
33 0 : fName(),
34 0 : fDescription(),
35 0 : fTriggerDomain()
36 0 : {
37 : // Default constructor.
38 0 : }
39 :
40 :
41 : AliHLTTriggerDecision::AliHLTTriggerDecision(const AliHLTTriggerDecision& obj) :
42 0 : TObject(obj),
43 0 : fName(obj.fName),
44 0 : fDescription(obj.fDescription),
45 0 : fTriggerDomain(obj.fTriggerDomain)
46 0 : {
47 : // Copy constructor performs a deep copy.
48 :
49 : // The following is a backward compatibility fix to be able to read trigger
50 : // decisions recorded before the fix in AliRoot trunk rev. 35998 correctly.
51 0 : if (obj.TestBits(15) == 15)
52 : {
53 0 : ResetBit(15); // We can clear 'this' objects bit because we performed a deep copy.
54 0 : SetBit(BIT(15));
55 0 : }
56 0 : }
57 :
58 :
59 : AliHLTTriggerDecision::AliHLTTriggerDecision(bool result, const char* name) :
60 8 : TObject(),
61 8 : fName(name),
62 8 : fDescription(),
63 8 : fTriggerDomain()
64 16 : {
65 : // Constructor specifying the name and result of the trigger decision.
66 :
67 8 : Result(result);
68 8 : }
69 :
70 :
71 : AliHLTTriggerDecision::AliHLTTriggerDecision(
72 : bool result, const char* name,
73 : const AliHLTTriggerDomain& triggerDomain,
74 : const char* description
75 : ) :
76 0 : TObject(),
77 0 : fName(name),
78 0 : fDescription(description),
79 0 : fTriggerDomain(triggerDomain)
80 0 : {
81 : // Constructor specifying all information fields.
82 :
83 0 : Result(result);
84 0 : }
85 :
86 :
87 : AliHLTTriggerDecision::~AliHLTTriggerDecision()
88 4 : {
89 : // Default destructor.
90 2 : }
91 :
92 :
93 : bool AliHLTTriggerDecision::Result() const
94 : {
95 : // Returns the result of the trigger decision.
96 :
97 : // The following is a backward compatibility fix to be able to read trigger
98 : // decisions recorded before the fix in AliRoot trunk rev. 35998 correctly.
99 16 : if (TestBits(15) == 15) return true;
100 :
101 8 : return TestBit(BIT(15)) == 1;
102 8 : }
103 :
104 :
105 : void AliHLTTriggerDecision::Result(bool value)
106 : {
107 : // Sets the result of the trigger decision.
108 25 : SetBit(BIT(15), value);
109 :
110 : // The following is a backward compatibility fix to be able to read trigger
111 : // decisions recorded before the fix in AliRoot trunk rev. 35998 correctly.
112 : // It looks like bit 1 and 2 of fBits are not used in the case of the
113 : // AliHLTTriggerDecision class, so reset those to prevent "TestBits(15) == 15"
114 : // from succeeding in the "Result() const" method above.
115 : // We do not touch the other two bits because they could affect memory handling
116 : // and cleanup.
117 25 : if (TestBits(15) == 15) ResetBit(6);
118 25 : }
119 :
120 :
121 : void AliHLTTriggerDecision::ReadoutList(const AliHLTReadoutList& value)
122 : {
123 : // Replaces the readout list in the trigger domain with the new value.
124 :
125 0 : AliHLTReadoutList fullReadout = ~ AliHLTReadoutList(0x0);
126 0 : fTriggerDomain.Remove(fullReadout);
127 0 : fTriggerDomain.Add(value);
128 0 : }
129 :
130 :
131 : void AliHLTTriggerDecision::Print(Option_t* option) const
132 : {
133 : // Prints the contents of the trigger decision.
134 :
135 0 : cout << "Trigger (" << fName.Data() << ") result = " << Result() << endl;
136 0 : TString opt(option);
137 0 : if (opt.Contains("short")) return;
138 0 : cout << "Description = \"" << fDescription.Data() << "\"" << endl;
139 0 : fTriggerDomain.Print();
140 0 : }
141 :
142 : void AliHLTTriggerDecision::Copy(TObject &object) const
143 : {
144 : // copy this to the specified object
145 :
146 8 : AliHLTTriggerDecision* pDecision=dynamic_cast<AliHLTTriggerDecision*>(&object);
147 2 : if (pDecision) {
148 : // copy members if target is a AliHLTTriggerDecision
149 2 : *pDecision=*this;
150 2 : }
151 :
152 : // copy the base class
153 2 : TObject::Copy(object);
154 2 : }
155 :
156 : TObject *AliHLTTriggerDecision::Clone(const char */*newname*/) const
157 : {
158 : // create a new clone, classname is ignored
159 :
160 0 : return new AliHLTTriggerDecision(*this);
161 0 : }
162 :
163 : Option_t *AliHLTTriggerDecision::GetOption() const
164 : {
165 : // Return the result of the trigger.
166 : // "0" or "1"
167 0 : if (Result()) return "1";
168 0 : return "0";
169 0 : }
170 :
171 :
172 : AliHLTTriggerDecision& AliHLTTriggerDecision::operator = (const AliHLTTriggerDecision& obj)
173 : {
174 : // Assignment operator performs a deep copy.
175 :
176 4 : if (this == &obj) return *this;
177 :
178 2 : TObject::operator = (obj);
179 : // The following is a backward compatibility fix to be able to read trigger
180 : // decisions recorded before the fix in AliRoot trunk rev. 35998 correctly.
181 2 : if (obj.TestBits(15) == 15)
182 : {
183 0 : ResetBit(15); // We can clear 'this' objects bit because we performed a deep copy.
184 0 : SetBit(BIT(15));
185 0 : }
186 :
187 2 : fName = obj.fName;
188 2 : fDescription = obj.fDescription;
189 2 : fTriggerDomain = obj.fTriggerDomain;
190 2 : return *this;
191 2 : }
192 :
193 :
194 : void AliHLTTriggerDecision::Clear(Option_t* option)
195 : {
196 : // Clears the trigger domain and resets the decision result.
197 :
198 34 : Result(false);
199 17 : fTriggerDomain.Clear(option);
200 17 : }
|