]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/trigger/AliHLTTrigger.cxx
bugfix: DAQ readout list was not sent due to incorrect check, readout list is now
[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 #include "AliHLTReadoutList.h"
28
29 ClassImp(AliHLTTrigger)
30
31
32 AliHLTTrigger::AliHLTTrigger() :
33         AliHLTProcessor(),
34         fEventData(NULL),
35         fTriggerData(NULL),
36         fDecisionMade(false),
37         fClearInfo(true),
38         fTriggerEventResult(0),
39         fDescription(),
40         fReadoutList(),
41         fTriggerDomain()
42 {
43   // Default constructor sets pointers to NULL.
44 }
45
46
47 AliHLTTrigger::~AliHLTTrigger()
48 {
49   // Default destructor.
50 }
51
52
53 void AliHLTTrigger::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
54 {
55   // Returns output data size estimate.
56   // See header file for more details.
57
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);
62   inputMultiplier = 1;
63 }
64
65
66 int AliHLTTrigger::DoEvent(const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData)
67 {
68   // Sets the pointers to the evtData and trigData, then calls the DoTrigger to
69   // execute the actual trigger algorithm.
70
71   fEventData = &evtData;
72   fTriggerData = &trigData;
73   fDecisionMade = false;
74   fTriggerEventResult = 0;
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   }
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   }
92
93   // Cleanup
94   fEventData = NULL;
95   fTriggerData = NULL;
96   return fTriggerEventResult;
97 }
98
99
100 int AliHLTTrigger::TriggerEvent(bool value)
101 {
102   // Sets the trigger decision for the current event.
103   // See header file for more details.
104   
105   if (fTriggerEventResult != 0) return fTriggerEventResult;  // Do not do anything if a previous call failed.
106   AliHLTTriggerDecision triggerResult(value, GetTriggerName(), fTriggerDomain, fDescription);
107   // Append the readout list if it contains anything.
108   triggerResult.TriggerDomain().Add(fReadoutList);
109   return TriggerEvent(&triggerResult, kAliHLTDataTypeTObject|kAliHLTDataOriginOut);
110 }
111
112
113 int AliHLTTrigger::TriggerEvent(
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   
121   if (fTriggerEventResult != 0) return fTriggerEventResult;  // Do not do anything if a previous call failed.
122   fTriggerEventResult = PushBack(result, type, spec);
123   if (fTriggerEventResult == 0) {
124     fTriggerEventResult = PushBack(result->ReadoutList().Buffer(), result->ReadoutList().BufferSize(), "HLTRDLST", "HLT "/*kAliHLTDataTypeDAQRDOUT|kAliHLTDataOriginOut*/);
125   }
126   
127   if (fTriggerEventResult == 0) fDecisionMade = true;
128   return fTriggerEventResult;
129 }
130
131
132 void 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;
139   t->GetInputDataTypes(list);
140 }
141
142
143 int 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();
153 }
154