]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/trigger/AliHLTTriggerSelectiveReadoutComponent.cxx
including the CTPData to the input objects of the HLTGlobalTriggerDecision
[u/mrichter/AliRoot.git] / HLT / trigger / AliHLTTriggerSelectiveReadoutComponent.cxx
CommitLineData
3daf4fbc 1//-*- Mode: C++ -*-
2// $Id$
3/**************************************************************************
4 * This file is property of and copyright by the ALICE HLT Project *
5 * ALICE Experiment at CERN, All rights reserved. *
6 * *
7 * Primary Authors: Jochen Thaeder <thaeder@kip.uni-heidelberg.de> *
8 * for The ALICE HLT Project. *
9 * *
10 * Permission to use, copy, modify and distribute this software and its *
11 * documentation strictly for non-commercial purposes is hereby granted *
12 * without fee, provided that the above copyright notice appears in all *
13 * copies and that both the copyright notice and this permission notice *
14 * appear in the supporting documentation. The authors make no claims *
15 * about the suitability of this software for any purpose. It is *
16 * provided "as is" without express or implied warranty. *
17 **************************************************************************/
18
19/** @file AliHLTTriggerSelectiveReadoutComponent.cxx
20 @author Jochen Thaeder
21 @date
22 @brief Component for the Selective Readout Trigger
23*/
24
25// see header file for class documentation
26// or
27// refer to README to build package
28// or
29// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
30
31#if __GNUC__ >= 3
32using namespace std;
33#endif
34
35#include "AliHLTTriggerSelectiveReadoutComponent.h"
36#include "AliHLTTPCDefinitions.h"
37
ed504011 38#include "TMath.h"
39
3daf4fbc 40#include <cstdlib>
41#include <cerrno>
42
43
44// ** This is a global object used for automatic component registration, do not use this
45AliHLTTriggerSelectiveReadoutComponent gAliHLTTriggerSelectivereadoutComponent;
46
47ClassImp(AliHLTTriggerSelectiveReadoutComponent)
48
49AliHLTTriggerSelectiveReadoutComponent::AliHLTTriggerSelectiveReadoutComponent() :
50 fDetector(),
51 fEnableThresholdSize(kFALSE) {
52 // see header file for class documentation
53 // or
54 // refer to README to build package
55 // or
56 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
57
58 memset( fThreshold, 0, (fkNThreshold * sizeof(AliHLTUInt32_t)) );
59}
60
61AliHLTTriggerSelectiveReadoutComponent::~AliHLTTriggerSelectiveReadoutComponent() {
62 // see header file for class documentation
63}
64
65// Public functions to implement AliHLTComponent's interface.
66// These functions are required for the registration process
67
68const char* AliHLTTriggerSelectiveReadoutComponent::GetComponentID() {
69 // see header file for class documentation
70 return "TriggerSelectiveReadout";
71}
72
73void AliHLTTriggerSelectiveReadoutComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list) {
74 // see header file for class documentation
75
76 list.clear();
77 list.push_back( kAliHLTDataTypeDDLRaw );
78}
79
80AliHLTComponentDataType AliHLTTriggerSelectiveReadoutComponent::GetOutputDataType() {
81 // see header file for class documentation
82
83 return kAliHLTMultipleDataType;
84}
85
86Int_t AliHLTTriggerSelectiveReadoutComponent::GetOutputDataTypes( AliHLTComponentDataTypeList& tgtList) {
87 // see header file for class documentation
88
89 tgtList.clear();
90 tgtList.push_back( kAliHLTDataTypeDDLRaw );
91 tgtList.push_back( kAliHLTDataTypeDDL );
854ef340 92 return tgtList.size();
3daf4fbc 93}
94
95void AliHLTTriggerSelectiveReadoutComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
96 // see header file for class documentation
97
98 constBase = sizeof( AliHLTEventDDL );
ed504011 99 inputMultiplier = 0.0;
3daf4fbc 100}
101
102// Spawn function, return new instance of this class
103AliHLTComponent* AliHLTTriggerSelectiveReadoutComponent::Spawn() {
104 // see header file for class documentation
105
106 return new AliHLTTriggerSelectiveReadoutComponent;
107}
108
109Int_t AliHLTTriggerSelectiveReadoutComponent::DoInit( int argc, const char** argv ) {
110 // see header file for class documentation
111
112 Int_t iResult = 0;
113 TString argument = "";
114 TString parameter = "";
115 Int_t bMissingParam=0;
116
117 for ( Int_t ii=0; ii<argc && iResult>=0; ii++ ) {
118
119 argument = argv[ii];
120
121 if ( argument.IsNull() ) continue;
122
123 // -detector
ed504011 124 if ( ! argument.CompareTo("-detector") ) {
3daf4fbc 125
126 if ( ( bMissingParam=( ++ii >= argc ) ) ) break;
127
128 fDetector = argv[ii];
129 fDetector.Remove(TString::kLeading, ' ');
ed504011 130 fDetector.Resize(4);
3daf4fbc 131
3daf4fbc 132 HLTInfo( "Detector has been set to '%s'.", fDetector.Data() );
133 }
134
135 // -enableThreshold
136 else if ( ! argument.CompareTo("-enableThreshold") ) {
137
138 if ( ( bMissingParam=( ++ii >= argc ) ) ) break;
3daf4fbc 139
ed504011 140 parameter = argv[ii];
141 parameter.Remove( TString::kLeading, ' ' );
142
3daf4fbc 143 if ( ! parameter.CompareTo("size") ) {
144 fEnableThresholdSize = kTRUE;
145 HLTInfo( "Threshold on data 'size' has been enabled." );
146 }
147 else {
148 HLTError( "This threshold '%s' has not been implemented.", parameter.Data() );
149 iResult = -EPROTO;
150 }
151 }
152
ed504011 153 // -threshold
154 else if ( ! argument.CompareTo("-threshold") ) {
155
156 if ( ( bMissingParam=( ++ii >= argc ) ) ) break;
157
158 Int_t jj = 0;
159
2ff24e4c 160 for ( jj = 0; ( jj < fkNThreshold ) && ( ( ii + jj ) < argc ); jj++ ) {
ed504011 161
162 parameter = argv[ii+jj];
163 parameter.Remove( TString::kLeading, ' ' );
164
165 if ( parameter.BeginsWith( '-' ) ) break;
166
167 if (parameter.IsDigit() ) {
168 fThreshold[jj] = (AliHLTUInt32_t) parameter.Atoi();
169 HLTInfo( "Threshold for %d is set to %d.", jj, fThreshold[jj] );
170 }
171 else {
172 HLTError( "Cannot convert %d. threshold specifier '%s'.", jj, parameter.Data() );
173 iResult = -EINVAL;
174 break;
175 }
176 } // for ( jj ; ( jj < fkNThreshold ) && ( ( ii + jj ) < argc ); jj++ ) {
177
178 ii += --jj;
3daf4fbc 179 }
180
181 // - unknow parameter
182 else {
183 iResult = -EINVAL;
184 HLTError("Unknown argument '%s'", argument.Data() );
185 }
186
187 } // for ( Int_t ii=0; ii<argc && iResult>=0; ii++ ) {
ed504011 188
3daf4fbc 189 if ( bMissingParam ) {
190 HLTError( "Missing parameter for argument '%s'.", argument.Data() );
191 iResult = -EPROTO;
192 }
193
ed504011 194 if ( fDetector.IsNull() ) {
195 HLTError( "No Detector has been supplied, this is mandatory." );
196 iResult = -EPROTO;
197 }
198
3daf4fbc 199 return iResult;
200}
201
202
203Int_t AliHLTTriggerSelectiveReadoutComponent::DoDeinit() {
204 // see header file for class documentation
205
206 return 0;
207}
208
2ff24e4c 209Int_t AliHLTTriggerSelectiveReadoutComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/ ) {
3daf4fbc 210 // see header file for class documentation
211
ed504011 212 // ** No readout list for SOR and EOR event
213 if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) )
214 return 0;
215
3daf4fbc 216 // ** Create empty Readoutlist
217 AliHLTEventDDL readoutList;
218 memset( &readoutList, 0, sizeof(AliHLTEventDDL) );
219
220 const AliHLTComponentBlockData* iter = NULL;
221 Int_t ddlId = 0;
222 AliHLTUInt8_t patch = 0;
223
224 // ** Loop over all input blocks and specify which data format should be read - only select Raw Data
ed504011 225 for ( iter = GetFirstInputBlock(kAliHLTDataTypeDDLRaw|fDetector.Data()); iter != NULL; iter = GetNextInputBlock() ) {
3daf4fbc 226
3daf4fbc 227 // ** Check if block has only the CDH Header ( 32 Bytes = gkAliHLTCommonHeaderCount *sizeof(AliHLTUInt32_t) )
228 if ( iter->fSize <= ( gkAliHLTCommonHeaderCount * sizeof(AliHLTUInt32_t) ) ) {
3daf4fbc 229 continue;
230 }
231
232 //
233 // ** Check for detector specifications
234 //
235
236 // ** Check for TPC specifc specification
ed504011 237 if ( ! fDetector.CompareTo("TPC ") ) {
3daf4fbc 238 // ** Get DDL ID
239 AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
240 patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
3daf4fbc 241 if (patch < 2) ddlId = 768 + (2 * slice) + patch;
242 else ddlId = 838 + (4*slice) + patch;
3daf4fbc 243 HLTDebug ( "Input Data - TPC - Slice/Patch: %d/%d - EquipmentID : %d.", slice, patch, ddlId );
ed504011 244 } // if ( ! fDetector.CompareTo("TPC ") ) {
3daf4fbc 245
246 // ** Check for other detector specifc specification
247 else {
248 HLTError("Detector '%s' has not been implemented yet.", fDetector.Data() );
3daf4fbc 249 continue;
250 }
ed504011 251
3daf4fbc 252 //
253 // ** Check if threshold should be considerd
254 //
3daf4fbc 255
ed504011 256 if ( fEnableThresholdSize ) {
3daf4fbc 257 // ** Check for TPC threshold
ed504011 258 if ( ! fDetector.CompareTo("TPC ") ) {
3daf4fbc 259 if ( patch < fkNThreshold ){
3daf4fbc 260 // ** if datablock to big, do not put it in HLT readout, enable for DAQ readout
261 if ( ( fThreshold[patch] !=0 ) && ( iter->fSize > fThreshold[patch] ) ) {
ed504011 262 EnableDDLBit( readoutList, ddlId );
263 HLTDebug ( "DDL Id %d enabled for DAQ readout - size %d > threshold %d.", ddlId, iter->fSize, fThreshold[patch] );
3daf4fbc 264 continue;
265 }
3daf4fbc 266 }
ed504011 267 } // if ( ! fDetector.CompareTo("TPC ") ) {
3daf4fbc 268
269 // ** Check for other detector threshold
270 else
271 HLTError("Check for size threshold as not been implemented yet for Detector '%s'.", fDetector.Data() );
272
273 } // if ( fEnableThresholdSize ) {
ed504011 274
275 //
276 // ** PushForward data block
277 //
278
3daf4fbc 279 PushBack( iter->fPtr , iter->fSize, iter->fDataType, iter->fSpecification);
280
ed504011 281 } // for ( iter = GetFirstInputBlock(kAliHLTDataTypeDDLRaw|fDetector.Data()); iter != NULL; iter = GetNextInputBlock() ) {
282
283 //
3daf4fbc 284 // ** PushBack readout list
ed504011 285 //
3daf4fbc 286
ed504011 287 PushBack( &readoutList, sizeof(AliHLTEventDDL), kAliHLTDataTypeDDL, (AliHLTUInt32_t) 0 );
288
3daf4fbc 289 return 0;
290}