update coordinate transformation from chamber coordinates to global
[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
56void AliHLTTrigger::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
57{
5d79eb88 58 // Returns output data size estimate.
59 // See header file for more details.
4adf50d6 60
61074420 61 // Matthias 2009-07-03 this is presumably to small as the streamed object might be
62 // bigger. This is actually the case in root v5-24-00
63 // Just take 2x the size of the object
64 constBase = 2*sizeof(AliHLTTriggerDecision);
4adf50d6 65 inputMultiplier = 1;
5a806c0e 66}
67
5a806c0e 68
a9670afe 69int AliHLTTrigger::DoEvent(const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData)
5a806c0e 70{
5d79eb88 71 // Sets the pointers to the evtData and trigData, then calls the DoTrigger to
72 // execute the actual trigger algorithm.
5a806c0e 73
a9670afe 74 fEventData = &evtData;
75 fTriggerData = &trigData;
76 fDecisionMade = false;
77 fTriggerEventResult = 0;
acc7214e 78 // Reset the description, readout list and trigger domain used by TriggerEvent
79 // if requested to do so.
80 if (fClearInfo)
81 {
82 fDescription = "";
83 fReadoutList.Clear();
84 fTriggerDomain.Clear();
85 }
a9670afe 86
87 int result = DoTrigger();
88 if (result != 0) return result;
89
90 // Fill in a default decision of false if none was made.
91 if (not fDecisionMade)
92 {
93 TriggerEvent(false);
94 }
4adf50d6 95
a9670afe 96 // Cleanup
97 fEventData = NULL;
98 fTriggerData = NULL;
99 return fTriggerEventResult;
5a806c0e 100}
101
5a806c0e 102
4654280e 103int AliHLTTrigger::TriggerEvent(bool value)
5a806c0e 104{
5d79eb88 105 // Sets the trigger decision for the current event.
106 // See header file for more details.
5a806c0e 107
4654280e 108 if (fTriggerEventResult != 0) return fTriggerEventResult; // Do not do anything if a previous call failed.
52f67e50 109 AliHLTTriggerDecision triggerResult(value, GetTriggerName(), fTriggerDomain, fDescription);
8b745301 110 // Append the readout list if it contains anything.
111 triggerResult.TriggerDomain().Add(fReadoutList);
15ede44e 112 return TriggerEvent(&triggerResult, kAliHLTDataTypeTObject|kAliHLTDataOriginOut);
5d79eb88 113}
114
115
4654280e 116int AliHLTTrigger::TriggerEvent(
5d79eb88 117 AliHLTTriggerDecision* result, const AliHLTComponentDataType& type,
118 AliHLTUInt32_t spec
119 )
120{
121 // Sets a custom trigger decision for the current event.
122 // See header file for more details.
123
4654280e 124 if (fTriggerEventResult != 0) return fTriggerEventResult; // Do not do anything if a previous call failed.
5d79eb88 125 fTriggerEventResult = PushBack(result, type, spec);
f320d378 126 if (fTriggerEventResult == 0) {
127 fTriggerEventResult = PushBack(result->ReadoutList().Buffer(), result->ReadoutList().BufferSize(), "HLTRDLST", "HLT "/*kAliHLTDataTypeDAQRDOUT|kAliHLTDataOriginOut*/);
15ede44e 128 }
129
5d79eb88 130 if (fTriggerEventResult == 0) fDecisionMade = true;
4654280e 131 return fTriggerEventResult;
5d79eb88 132}
133
134
135void AliHLTTrigger::GetInputDataTypes(AliHLTComponentDataTypeList& list)
136{
137 // Calls the const version of this method.
138
139 // Assign to const temporary variable to make sure we call the constant version
140 // of the GetOutputDataTypes method.
141 const AliHLTTrigger* t = this;
4a0b19b6 142 t->GetInputDataTypes(list);
5d79eb88 143}
144
145
146int AliHLTTrigger::GetOutputDataTypes(AliHLTComponentDataTypeList& list)
147{
148 // Calls the const version of this method.
149
150 // Assign to const temporary variable to make sure we call the constant version
151 // of the GetOutputDataTypes method.
152 const AliHLTTrigger* t = this;
153 t->GetOutputDataTypes(list);
154 list.push_back(kAliHLTDataTypeTObject|kAliHLTDataOriginOut);
155 return list.size();
5a806c0e 156}
157
2974f8dc 158int AliHLTTrigger::CreateEventDoneReadoutFilter(const AliHLTTriggerDomain& domain, unsigned type)
159{
160 // add a readout filter to the EventDoneData
161 int iResult=0;
7b638b2a 162 unsigned nofEntries=domain.GetNofEntries();
2974f8dc 163 // we need:
164 // 1 word eventually for the monitor event command
165 // 1 word for the readout filter command
166 // 1 word for the readout filter size
167 // 4*n words for the filter list
7b638b2a 168 if ((iResult=ReserveEventDoneData((nofEntries*4 + 3) * sizeof(AliHLTUInt32_t)))<0) return iResult;
2974f8dc 169 AliHLTUInt32_t eddbuffer[4];
170 if (type==4) {
171 // in the case of the monitoring filter we also add the monitor event command
172 eddbuffer[0]=5;
173 if ((iResult=PushEventDoneData(eddbuffer[0]))<0) return iResult;
174 }
175
176 // now the readout list command and the block count
177 eddbuffer[0]=type;
178 if ((iResult=PushEventDoneData(eddbuffer[0]))<0) return iResult;
2974f8dc 179
7b638b2a 180 // find the valid entries
181 unsigned block=0;
182 vector<const AliHLTDomainEntry*> entries;
183 for (block=0; block<nofEntries; block++) {
2974f8dc 184 // skip all DAQ readout entries as they are handled by the readout list
185 if (domain[block]==AliHLTDomainEntry(kAliHLTDataTypeDAQRDOUT)) continue;
186 if (domain[block].Exclusive()) {
187 HLTWarning("exclusive trigger domain entries are currently not handled, skipping entry %s", domain[block].AsString().Data());
188 continue;
189 }
7b638b2a 190 entries.push_back(&(domain[block]));
191 }
192 eddbuffer[0]=entries.size();
193 if ((iResult=PushEventDoneData(eddbuffer[0]))<0) return iResult;
194
195 for (vector<const AliHLTDomainEntry*>::iterator entry=entries.begin();
196 entry!=entries.end(); entry++) {
197 (*entry)->AsBinary(eddbuffer);
2974f8dc 198 for (int n=0; n<4; n++)
199 if ((iResult=PushEventDoneData(eddbuffer[n]))<0) return iResult;
200 }
201 return iResult;
202}