]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/trigger/AliHLTTrigger.cxx
temporarily reverting part of r36598
[u/mrichter/AliRoot.git] / HLT / trigger / AliHLTTrigger.cxx
CommitLineData
2974f8dc 1// $Id$
a9670afe 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 **************************************************************************/
5a806c0e 17
1b9a175e 18/// @file AliHLTTrigger.h
19/// @author Artur Szostak <artursz@iafrica.com>
20/// @date 12 Aug 2008
21/// @brief Implementation of the AliHLTTrigger base component class.
22///
23/// The AliHLTTrigger class is the base class from which all HLT trigger components
24/// should be derived.
25
4aa41877 26#include "AliHLTTrigger.h"
1b9a175e 27#include "AliHLTTriggerDecision.h"
15ede44e 28#include "AliHLTReadoutList.h"
2974f8dc 29#include "AliHLTTriggerDomain.h"
30#include "AliHLTDomainEntry.h"
5a806c0e 31
4aa41877 32ClassImp(AliHLTTrigger)
5a806c0e 33
5a806c0e 34
a9670afe 35AliHLTTrigger::AliHLTTrigger() :
36 AliHLTProcessor(),
37 fEventData(NULL),
38 fTriggerData(NULL),
39 fDecisionMade(false),
acc7214e 40 fClearInfo(true),
4adf50d6 41 fTriggerEventResult(0),
1b9a175e 42 fDescription(),
43 fReadoutList(),
44 fTriggerDomain()
5a806c0e 45{
5d79eb88 46 // Default constructor sets pointers to NULL.
5a806c0e 47}
48
5a806c0e 49
a9670afe 50AliHLTTrigger::~AliHLTTrigger()
5a806c0e 51{
5d79eb88 52 // Default destructor.
4adf50d6 53}
54
55
025443e0 56void AliHLTTrigger::GetInputDataTypes(AliHLTComponentDataTypeList& list) const
57{
58 // Returns the kAliHLTAnyDataType type as input.
59 list.push_back(kAliHLTAnyDataType);
60}
61
62
63void AliHLTTrigger::GetOutputDataTypes(AliHLTComponentDataTypeList& list) const
64{
65 // Returns the kAliHLTDataTypeTriggerDecision type as output.
66 list.push_back(kAliHLTDataTypeTriggerDecision);
67}
68
69
4adf50d6 70void AliHLTTrigger::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
71{
5d79eb88 72 // Returns output data size estimate.
73 // See header file for more details.
4adf50d6 74
61074420 75 // Matthias 2009-07-03 this is presumably to small as the streamed object might be
76 // bigger. This is actually the case in root v5-24-00
77 // Just take 2x the size of the object
78 constBase = 2*sizeof(AliHLTTriggerDecision);
4adf50d6 79 inputMultiplier = 1;
5a806c0e 80}
81
5a806c0e 82
a9670afe 83int AliHLTTrigger::DoEvent(const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData)
5a806c0e 84{
5d79eb88 85 // Sets the pointers to the evtData and trigData, then calls the DoTrigger to
86 // execute the actual trigger algorithm.
5a806c0e 87
a9670afe 88 fEventData = &evtData;
89 fTriggerData = &trigData;
90 fDecisionMade = false;
91 fTriggerEventResult = 0;
acc7214e 92 // Reset the description, readout list and trigger domain used by TriggerEvent
93 // if requested to do so.
94 if (fClearInfo)
95 {
96 fDescription = "";
97 fReadoutList.Clear();
98 fTriggerDomain.Clear();
99 }
a9670afe 100
101 int result = DoTrigger();
102 if (result != 0) return result;
103
104 // Fill in a default decision of false if none was made.
105 if (not fDecisionMade)
106 {
107 TriggerEvent(false);
108 }
4adf50d6 109
a9670afe 110 // Cleanup
111 fEventData = NULL;
112 fTriggerData = NULL;
113 return fTriggerEventResult;
5a806c0e 114}
115
5a806c0e 116
4654280e 117int AliHLTTrigger::TriggerEvent(bool value)
5a806c0e 118{
5d79eb88 119 // Sets the trigger decision for the current event.
120 // See header file for more details.
5a806c0e 121
4654280e 122 if (fTriggerEventResult != 0) return fTriggerEventResult; // Do not do anything if a previous call failed.
52f67e50 123 AliHLTTriggerDecision triggerResult(value, GetTriggerName(), fTriggerDomain, fDescription);
8b745301 124 // Append the readout list if it contains anything.
125 triggerResult.TriggerDomain().Add(fReadoutList);
72e31932 126 return TriggerEvent(&triggerResult, kAliHLTDataTypeTObject|kAliHLTDataOriginOut);
5d79eb88 127}
128
129
4654280e 130int AliHLTTrigger::TriggerEvent(
5d79eb88 131 AliHLTTriggerDecision* result, const AliHLTComponentDataType& type,
132 AliHLTUInt32_t spec
133 )
134{
135 // Sets a custom trigger decision for the current event.
136 // See header file for more details.
137
4654280e 138 if (fTriggerEventResult != 0) return fTriggerEventResult; // Do not do anything if a previous call failed.
5d79eb88 139 fTriggerEventResult = PushBack(result, type, spec);
f320d378 140 if (fTriggerEventResult == 0) {
025443e0 141 fTriggerEventResult = PushBack(result->ReadoutList().Buffer(), result->ReadoutList().BufferSize(), kAliHLTDataTypeReadoutList);
15ede44e 142 }
143
5d79eb88 144 if (fTriggerEventResult == 0) fDecisionMade = true;
4654280e 145 return fTriggerEventResult;
5d79eb88 146}
147
148
149void AliHLTTrigger::GetInputDataTypes(AliHLTComponentDataTypeList& list)
150{
151 // Calls the const version of this method.
152
153 // Assign to const temporary variable to make sure we call the constant version
154 // of the GetOutputDataTypes method.
155 const AliHLTTrigger* t = this;
4a0b19b6 156 t->GetInputDataTypes(list);
5d79eb88 157}
158
159
160int AliHLTTrigger::GetOutputDataTypes(AliHLTComponentDataTypeList& list)
161{
162 // Calls the const version of this method.
163
164 // Assign to const temporary variable to make sure we call the constant version
165 // of the GetOutputDataTypes method.
166 const AliHLTTrigger* t = this;
167 t->GetOutputDataTypes(list);
025443e0 168 list.push_back(kAliHLTDataTypeReadoutList);
5d79eb88 169 return list.size();
5a806c0e 170}
171
2974f8dc 172int AliHLTTrigger::CreateEventDoneReadoutFilter(const AliHLTTriggerDomain& domain, unsigned type)
173{
174 // add a readout filter to the EventDoneData
175 int iResult=0;
7b638b2a 176 unsigned nofEntries=domain.GetNofEntries();
2974f8dc 177 // we need:
178 // 1 word eventually for the monitor event command
179 // 1 word for the readout filter command
180 // 1 word for the readout filter size
181 // 4*n words for the filter list
7b638b2a 182 if ((iResult=ReserveEventDoneData((nofEntries*4 + 3) * sizeof(AliHLTUInt32_t)))<0) return iResult;
2974f8dc 183 AliHLTUInt32_t eddbuffer[4];
184 if (type==4) {
185 // in the case of the monitoring filter we also add the monitor event command
186 eddbuffer[0]=5;
187 if ((iResult=PushEventDoneData(eddbuffer[0]))<0) return iResult;
188 }
189
190 // now the readout list command and the block count
191 eddbuffer[0]=type;
192 if ((iResult=PushEventDoneData(eddbuffer[0]))<0) return iResult;
2974f8dc 193
7b638b2a 194 // find the valid entries
195 unsigned block=0;
196 vector<const AliHLTDomainEntry*> entries;
197 for (block=0; block<nofEntries; block++) {
2974f8dc 198 // skip all DAQ readout entries as they are handled by the readout list
199 if (domain[block]==AliHLTDomainEntry(kAliHLTDataTypeDAQRDOUT)) continue;
200 if (domain[block].Exclusive()) {
201 HLTWarning("exclusive trigger domain entries are currently not handled, skipping entry %s", domain[block].AsString().Data());
202 continue;
203 }
7b638b2a 204 entries.push_back(&(domain[block]));
205 }
206 eddbuffer[0]=entries.size();
207 if ((iResult=PushEventDoneData(eddbuffer[0]))<0) return iResult;
208
209 for (vector<const AliHLTDomainEntry*>::iterator entry=entries.begin();
210 entry!=entries.end(); entry++) {
211 (*entry)->AsBinary(eddbuffer);
2974f8dc 212 for (int n=0; n<4; n++)
213 if ((iResult=PushEventDoneData(eddbuffer[n]))<0) return iResult;
214 }
215 return iResult;
216}