adding support for EventDoneData to AliHLTSystem
[u/mrichter/AliRoot.git] / HLT / trigger / AliHLTTrigger.cxx
CommitLineData
a9670afe 1/**************************************************************************
2 * This file is property of and copyright by the ALICE HLT Project *
3 * ALICE Experiment at CERN, All rights reserved. *
4 * *
5 * Primary Authors: Artur Szostak <artursz@iafrica.com> *
6 * for The ALICE HLT Project. *
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 **************************************************************************/
5a806c0e 16
1b9a175e 17/// @file AliHLTTrigger.h
18/// @author Artur Szostak <artursz@iafrica.com>
19/// @date 12 Aug 2008
20/// @brief Implementation of the AliHLTTrigger base component class.
21///
22/// The AliHLTTrigger class is the base class from which all HLT trigger components
23/// should be derived.
24
4aa41877 25#include "AliHLTTrigger.h"
1b9a175e 26#include "AliHLTTriggerDecision.h"
15ede44e 27#include "AliHLTReadoutList.h"
5a806c0e 28
4aa41877 29ClassImp(AliHLTTrigger)
5a806c0e 30
5a806c0e 31
a9670afe 32AliHLTTrigger::AliHLTTrigger() :
33 AliHLTProcessor(),
34 fEventData(NULL),
35 fTriggerData(NULL),
36 fDecisionMade(false),
acc7214e 37 fClearInfo(true),
4adf50d6 38 fTriggerEventResult(0),
1b9a175e 39 fDescription(),
40 fReadoutList(),
41 fTriggerDomain()
5a806c0e 42{
5d79eb88 43 // Default constructor sets pointers to NULL.
5a806c0e 44}
45
5a806c0e 46
a9670afe 47AliHLTTrigger::~AliHLTTrigger()
5a806c0e 48{
5d79eb88 49 // Default destructor.
4adf50d6 50}
51
52
53void AliHLTTrigger::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
54{
5d79eb88 55 // Returns output data size estimate.
56 // See header file for more details.
4adf50d6 57
61074420 58 // Matthias 2009-07-03 this is presumably to small as the streamed object might be
59 // bigger. This is actually the case in root v5-24-00
60 // Just take 2x the size of the object
61 constBase = 2*sizeof(AliHLTTriggerDecision);
4adf50d6 62 inputMultiplier = 1;
5a806c0e 63}
64
5a806c0e 65
a9670afe 66int AliHLTTrigger::DoEvent(const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData)
5a806c0e 67{
5d79eb88 68 // Sets the pointers to the evtData and trigData, then calls the DoTrigger to
69 // execute the actual trigger algorithm.
5a806c0e 70
a9670afe 71 fEventData = &evtData;
72 fTriggerData = &trigData;
73 fDecisionMade = false;
74 fTriggerEventResult = 0;
acc7214e 75 // Reset the description, readout list and trigger domain used by TriggerEvent
76 // if requested to do so.
77 if (fClearInfo)
78 {
79 fDescription = "";
80 fReadoutList.Clear();
81 fTriggerDomain.Clear();
82 }
a9670afe 83
84 int result = DoTrigger();
85 if (result != 0) return result;
86
87 // Fill in a default decision of false if none was made.
88 if (not fDecisionMade)
89 {
90 TriggerEvent(false);
91 }
4adf50d6 92
a9670afe 93 // Cleanup
94 fEventData = NULL;
95 fTriggerData = NULL;
96 return fTriggerEventResult;
5a806c0e 97}
98
5a806c0e 99
4654280e 100int AliHLTTrigger::TriggerEvent(bool value)
5a806c0e 101{
5d79eb88 102 // Sets the trigger decision for the current event.
103 // See header file for more details.
5a806c0e 104
4654280e 105 if (fTriggerEventResult != 0) return fTriggerEventResult; // Do not do anything if a previous call failed.
52f67e50 106 AliHLTTriggerDecision triggerResult(value, GetTriggerName(), fTriggerDomain, fDescription);
8b745301 107 // Append the readout list if it contains anything.
108 triggerResult.TriggerDomain().Add(fReadoutList);
15ede44e 109 return TriggerEvent(&triggerResult, kAliHLTDataTypeTObject|kAliHLTDataOriginOut);
5d79eb88 110}
111
112
4654280e 113int AliHLTTrigger::TriggerEvent(
5d79eb88 114 AliHLTTriggerDecision* result, const AliHLTComponentDataType& type,
115 AliHLTUInt32_t spec
116 )
117{
118 // Sets a custom trigger decision for the current event.
119 // See header file for more details.
120
4654280e 121 if (fTriggerEventResult != 0) return fTriggerEventResult; // Do not do anything if a previous call failed.
5d79eb88 122 fTriggerEventResult = PushBack(result, type, spec);
f320d378 123 if (fTriggerEventResult == 0) {
124 fTriggerEventResult = PushBack(result->ReadoutList().Buffer(), result->ReadoutList().BufferSize(), "HLTRDLST", "HLT "/*kAliHLTDataTypeDAQRDOUT|kAliHLTDataOriginOut*/);
15ede44e 125 }
126
5d79eb88 127 if (fTriggerEventResult == 0) fDecisionMade = true;
4654280e 128 return fTriggerEventResult;
5d79eb88 129}
130
131
132void AliHLTTrigger::GetInputDataTypes(AliHLTComponentDataTypeList& list)
133{
134 // Calls the const version of this method.
135
136 // Assign to const temporary variable to make sure we call the constant version
137 // of the GetOutputDataTypes method.
138 const AliHLTTrigger* t = this;
4a0b19b6 139 t->GetInputDataTypes(list);
5d79eb88 140}
141
142
143int AliHLTTrigger::GetOutputDataTypes(AliHLTComponentDataTypeList& list)
144{
145 // Calls the const version of this method.
146
147 // Assign to const temporary variable to make sure we call the constant version
148 // of the GetOutputDataTypes method.
149 const AliHLTTrigger* t = this;
150 t->GetOutputDataTypes(list);
151 list.push_back(kAliHLTDataTypeTObject|kAliHLTDataOriginOut);
152 return list.size();
5a806c0e 153}
154