]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/AliHLTGlobalTriggerDecision.cxx
adding support for the new AliESDHLTDecision class which will allow to store
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTGlobalTriggerDecision.cxx
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   AliHLTGlobalTriggerDecision.cxx
19 /// @author Artur Szostak <artursz@iafrica.com>
20 /// @date   26 Nov 2008
21 /// @brief  Implementation of the AliHLTGlobalTriggerDecision class.
22 /// 
23 /// The global trigger decision class stores the global HLT decision.
24
25 #include "AliHLTGlobalTriggerDecision.h"
26 #include "Riostream.h"
27 #include "TClass.h"
28 #include "AliHLTMisc.h"
29
30 ClassImp(AliHLTGlobalTriggerDecision)
31
32
33 AliHLTGlobalTriggerDecision::AliHLTGlobalTriggerDecision() :
34 AliHLTTriggerDecision(0, "HLTGlobalTrigger"),
35   fContributingTriggers(AliHLTTriggerDecision::Class()),
36   fInputObjects(),
37   fCounters()
38 {
39   // Default constructor.
40 }
41
42
43 AliHLTGlobalTriggerDecision::AliHLTGlobalTriggerDecision(
44     bool result, const AliHLTTriggerDomain& triggerDomain, const char* description
45   ) :
46   AliHLTTriggerDecision(result, "HLTGlobalTrigger", triggerDomain, description),
47   fContributingTriggers(AliHLTTriggerDecision::Class()),
48   fInputObjects(),
49   fCounters()
50 {
51   // Constructor specifying multiple information fields.
52   
53   Result(result);
54   fInputObjects.SetOwner(kTRUE);
55 }
56
57
58 AliHLTGlobalTriggerDecision::~AliHLTGlobalTriggerDecision()
59 {
60   // Default destructor.
61 }
62
63
64 void AliHLTGlobalTriggerDecision::Print(Option_t* option) const
65 {
66   // Prints the contents of the trigger decision.
67   
68   TString opt(option);
69   if (opt.Contains("compact"))
70   {
71     cout << "Global ";
72     AliHLTTriggerDecision::Print("");
73   }
74   else if (opt.Contains("short"))
75   {
76     cout << "Global ";
77     AliHLTTriggerDecision::Print(option);
78     cout << "#################### Input trigger decisions ####################" << endl;
79     for (Int_t i = 0; i < NumberOfTriggerInputs(); i++)
80     {
81       if (TriggerInput(i)) TriggerInput(i)->Print(option);
82     }
83     if (NumberOfTriggerInputs() == 0)
84     {
85       cout << "(none)" << endl;
86     }
87   }
88   else if (opt.Contains("counters"))
89   {
90     cout << "Counter\tValue" << endl;
91     for (Int_t i = 0; i < fCounters.GetSize(); i++)
92     {
93       cout << i << "\t" << fCounters[i] << endl;
94     }
95     if (fCounters.GetSize() == 0)
96     {
97       cout << "(none)" << endl;
98     }
99   }
100   else
101   {
102     cout << "Global ";
103     AliHLTTriggerDecision::Print(option);
104     cout << "#################### Input trigger decisions ####################" << endl;
105     for (Int_t i = 0; i < NumberOfTriggerInputs(); i++)
106     {
107       cout << "-------------------- Input trigger decision " << i << " --------------------" << endl;
108       if (TriggerInput(i)) TriggerInput(i)->Print(option);
109     }
110     if (NumberOfTriggerInputs() == 0)
111     {
112       cout << "(none)" << endl;
113     }
114     cout << "###################### Other input objects ######################" << endl;
115     for (Int_t i = 0; i < NumberOfInputObjects(); i++)
116     {
117       cout << "------------------------ Input object " << i << " ------------------------" << endl;
118       if (InputObject(i)) InputObject(i)->Print(option);
119     }
120     if (NumberOfInputObjects() == 0)
121     {
122       cout << "(none)" << endl;
123     }
124     cout << "#################### Event class counters ####################" << endl;
125     cout << "Counter\tValue" << endl;
126     for (Int_t i = 0; i < fCounters.GetSize(); i++)
127     {
128       cout << i << "\t" << fCounters[i] << endl;
129     }
130     if (fCounters.GetSize() == 0)
131     {
132       cout << "(none)" << endl;
133     }
134   }
135 }
136
137 void AliHLTGlobalTriggerDecision::Copy(TObject &object) const
138 {
139   // copy this to the specified object
140
141   if (object.IsA() == AliHLTMisc::Instance().IsAliESDHLTDecision()) {
142     AliHLTMisc::Instance().Copy(this, &object);
143     return;
144   }
145
146   AliHLTGlobalTriggerDecision* pDecision=dynamic_cast<AliHLTGlobalTriggerDecision*>(&object);
147   if (pDecision)
148   {
149     // copy members if target is a AliHLTGlobalTriggerDecision
150     *pDecision=*this;
151   }
152   // copy the base class
153   AliHLTTriggerDecision::Copy(object);
154 }
155
156 TObject *AliHLTGlobalTriggerDecision::Clone(const char */*newname*/) const
157 {
158   // create a new clone, classname is ignored
159
160   return new AliHLTGlobalTriggerDecision(*this);
161 }
162
163 AliHLTGlobalTriggerDecision::AliHLTGlobalTriggerDecision(const AliHLTGlobalTriggerDecision& src) :
164   AliHLTTriggerDecision(src),
165   fContributingTriggers(AliHLTTriggerDecision::Class()),
166   fInputObjects(),
167   fCounters()
168 {
169   // copy constructor
170   *this=src;
171 }
172
173 AliHLTGlobalTriggerDecision& AliHLTGlobalTriggerDecision::operator=(const AliHLTGlobalTriggerDecision& src)
174 {
175   // assignment operator
176
177   fContributingTriggers.Delete();
178   for (int triggerInput=0; triggerInput<src.NumberOfTriggerInputs(); triggerInput++) {
179     const AliHLTTriggerDecision* pTriggerObject=src.TriggerInput(triggerInput);
180     if (pTriggerObject) {
181       // the AddTriggerInput function uses the copy constructor and
182       // makes a new object from the reference
183       AddTriggerInput(*pTriggerObject);
184     } else {
185       //Error("failed to get trigger input #%d", triggerInput);
186     }
187   }
188
189   fInputObjects.Delete();
190   for (int inputObject=0; inputObject<src.NumberOfTriggerInputs(); inputObject++) {
191     const TObject* pInputObject=src.InputObject(inputObject);
192     if (pInputObject) {
193       // the AddInputObject function uses Clone() and
194       // makes a new object from the reference
195       AddInputObject(pInputObject);
196     } else {
197       //Error("failed to get trigger input #%d", inputObject);
198     }
199   }
200   
201   SetCounters(src.Counters());
202
203   return *this;
204 }
205
206 void AliHLTGlobalTriggerDecision::SetCounters(const TArrayL64& counters, Long64_t eventCount)
207 {
208   // Sets the counter array.
209   // If the number of events is specified, an additional counter is added at the end.
210   fCounters = counters;
211   if (eventCount>=0) {
212     int size=fCounters.GetSize();
213     fCounters.Set(size+1);
214     fCounters[size]=eventCount;
215   }
216 }