]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/trigger/AliHLTTrigger.cxx
Finished code for global HLT trigger and the trigger menu implementation.
[u/mrichter/AliRoot.git] / HLT / trigger / AliHLTTrigger.cxx
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  **************************************************************************/
16
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
25 #include "AliHLTTrigger.h"
26 #include "AliHLTTriggerDecision.h"
27
28 ClassImp(AliHLTTrigger)
29
30
31 AliHLTTrigger::AliHLTTrigger() :
32         AliHLTProcessor(),
33         fEventData(NULL),
34         fTriggerData(NULL),
35         fDecisionMade(false),
36         fTriggerEventResult(0),
37         fDescription(),
38         fReadoutList(),
39         fTriggerDomain()
40 {
41   // Default constructor sets pointers to NULL.
42 }
43
44
45 AliHLTTrigger::~AliHLTTrigger()
46 {
47   // Default destructor.
48 }
49
50
51 void AliHLTTrigger::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
52 {
53   // Returns output data size estimate.
54   // See header file for more details.
55
56   constBase = sizeof(AliHLTTriggerDecision);
57   inputMultiplier = 1;
58 }
59
60
61 int AliHLTTrigger::DoEvent(const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData)
62 {
63   // Sets the pointers to the evtData and trigData, then calls the DoTrigger to
64   // execute the actual trigger algorithm.
65
66   fEventData = &evtData;
67   fTriggerData = &trigData;
68   fDecisionMade = false;
69   fTriggerEventResult = 0;
70   
71   int result = DoTrigger();
72   if (result != 0) return result;
73   
74   // Fill in a default decision of false if none was made.
75   if (not fDecisionMade)
76   {
77     TriggerEvent(false);
78   }
79
80   // Cleanup
81   fEventData = NULL;
82   fTriggerData = NULL;
83   return fTriggerEventResult;
84 }
85
86
87 void AliHLTTrigger::TriggerEvent(bool value)
88 {
89   // Sets the trigger decision for the current event.
90   // See header file for more details.
91   
92   if (fTriggerEventResult != 0) return;  // Do not do anything if a previous call failed.
93   AliHLTTriggerDecision triggerResult(value, GetTriggerName(), fTriggerDomain, fDescription);
94   triggerResult.ReadoutList(fReadoutList);  // Append the readout list if it contains anything.
95   fTriggerEventResult = PushBack(&triggerResult, kAliHLTDataTypeTObject|kAliHLTDataOriginOut);
96   if (fTriggerEventResult == 0) fDecisionMade = true;
97 }
98
99
100 void AliHLTTrigger::TriggerEvent(
101     AliHLTTriggerDecision* result, const AliHLTComponentDataType& type,
102     AliHLTUInt32_t spec
103   )
104 {
105   // Sets a custom trigger decision for the current event.
106   // See header file for more details.
107   
108   if (fTriggerEventResult != 0) return;  // Do not do anything if a previous call failed.
109   fTriggerEventResult = PushBack(result, type, spec);
110   if (fTriggerEventResult == 0) fDecisionMade = true;
111 }
112
113
114 void AliHLTTrigger::GetInputDataTypes(AliHLTComponentDataTypeList& list)
115 {
116   // Calls the const version of this method.
117   
118   // Assign to const temporary variable to make sure we call the constant version
119   // of the GetOutputDataTypes method.
120   const AliHLTTrigger* t = this;
121   t->GetOutputDataTypes(list);
122 }
123
124
125 int AliHLTTrigger::GetOutputDataTypes(AliHLTComponentDataTypeList& list)
126 {
127   // Calls the const version of this method.
128   
129   // Assign to const temporary variable to make sure we call the constant version
130   // of the GetOutputDataTypes method.
131   const AliHLTTrigger* t = this;
132   t->GetOutputDataTypes(list);
133   list.push_back(kAliHLTDataTypeTObject|kAliHLTDataOriginOut);
134   return list.size();
135 }
136