3 /**************************************************************************
4 * This file is property of and copyright by the ALICE HLT Project *
5 * ALICE Experiment at CERN, All rights reserved. *
7 * Primary Authors: Jochen Thaeder <thaeder@kip.uni-heidelberg.de> *
8 * for The ALICE HLT Project. *
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 **************************************************************************/
19 /** @file AliHLTTriggerSelectiveReadoutComponent.cxx
20 @author Jochen Thaeder
22 @brief Component for the Selective Readout Trigger
25 // see header file for class documentation
27 // refer to README to build package
29 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
35 #include "AliHLTTriggerSelectiveReadoutComponent.h"
36 #include "AliHLTTPCDefinitions.h"
44 // ** This is a global object used for automatic component registration, do not use this
45 AliHLTTriggerSelectiveReadoutComponent gAliHLTTriggerSelectivereadoutComponent;
47 ClassImp(AliHLTTriggerSelectiveReadoutComponent)
49 AliHLTTriggerSelectiveReadoutComponent::AliHLTTriggerSelectiveReadoutComponent() :
51 fEnableThresholdSize(kFALSE) {
52 // see header file for class documentation
54 // refer to README to build package
56 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
58 memset( fThreshold, 0, (fkNThreshold * sizeof(AliHLTUInt32_t)) );
61 AliHLTTriggerSelectiveReadoutComponent::~AliHLTTriggerSelectiveReadoutComponent() {
62 // see header file for class documentation
65 // Public functions to implement AliHLTComponent's interface.
66 // These functions are required for the registration process
68 const char* AliHLTTriggerSelectiveReadoutComponent::GetComponentID() {
69 // see header file for class documentation
70 return "TriggerSelectiveReadout";
73 void AliHLTTriggerSelectiveReadoutComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list) {
74 // see header file for class documentation
77 list.push_back( kAliHLTDataTypeDDLRaw );
80 AliHLTComponentDataType AliHLTTriggerSelectiveReadoutComponent::GetOutputDataType() {
81 // see header file for class documentation
83 return kAliHLTMultipleDataType;
86 Int_t AliHLTTriggerSelectiveReadoutComponent::GetOutputDataTypes( AliHLTComponentDataTypeList& tgtList) {
87 // see header file for class documentation
90 tgtList.push_back( kAliHLTDataTypeDDLRaw );
91 tgtList.push_back( kAliHLTDataTypeDDL );
92 return tgtList.size();
95 void AliHLTTriggerSelectiveReadoutComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
96 // see header file for class documentation
98 constBase = sizeof( AliHLTEventDDL );
99 inputMultiplier = 0.0;
102 // Spawn function, return new instance of this class
103 AliHLTComponent* AliHLTTriggerSelectiveReadoutComponent::Spawn() {
104 // see header file for class documentation
106 return new AliHLTTriggerSelectiveReadoutComponent;
109 Int_t AliHLTTriggerSelectiveReadoutComponent::DoInit( int argc, const char** argv ) {
110 // see header file for class documentation
113 TString argument = "";
114 TString parameter = "";
115 Int_t bMissingParam=0;
117 for ( Int_t ii=0; ii<argc && iResult>=0; ii++ ) {
121 if ( argument.IsNull() ) continue;
124 if ( ! argument.CompareTo("-detector") ) {
126 if ( ( bMissingParam=( ++ii >= argc ) ) ) break;
128 fDetector = argv[ii];
129 fDetector.Remove(TString::kLeading, ' ');
132 HLTInfo( "Detector has been set to '%s'.", fDetector.Data() );
136 else if ( ! argument.CompareTo("-enableThreshold") ) {
138 if ( ( bMissingParam=( ++ii >= argc ) ) ) break;
140 parameter = argv[ii];
141 parameter.Remove( TString::kLeading, ' ' );
143 if ( ! parameter.CompareTo("size") ) {
144 fEnableThresholdSize = kTRUE;
145 HLTInfo( "Threshold on data 'size' has been enabled." );
148 HLTError( "This threshold '%s' has not been implemented.", parameter.Data() );
154 else if ( ! argument.CompareTo("-threshold") ) {
156 if ( ( bMissingParam=( ++ii >= argc ) ) ) break;
160 for ( jj = 0; ( jj < fkNThreshold ) && ( ( ii + jj ) < argc ); jj++ ) {
162 parameter = argv[ii+jj];
163 parameter.Remove( TString::kLeading, ' ' );
165 if ( parameter.BeginsWith( '-' ) ) break;
167 if (parameter.IsDigit() ) {
168 fThreshold[jj] = (AliHLTUInt32_t) parameter.Atoi();
169 HLTInfo( "Threshold for %d is set to %d.", jj, fThreshold[jj] );
172 HLTError( "Cannot convert %d. threshold specifier '%s'.", jj, parameter.Data() );
176 } // for ( jj ; ( jj < fkNThreshold ) && ( ( ii + jj ) < argc ); jj++ ) {
181 // - unknow parameter
184 HLTError("Unknown argument '%s'", argument.Data() );
187 } // for ( Int_t ii=0; ii<argc && iResult>=0; ii++ ) {
189 if ( bMissingParam ) {
190 HLTError( "Missing parameter for argument '%s'.", argument.Data() );
194 if ( fDetector.IsNull() ) {
195 HLTError( "No Detector has been supplied, this is mandatory." );
203 Int_t AliHLTTriggerSelectiveReadoutComponent::DoDeinit() {
204 // see header file for class documentation
209 Int_t AliHLTTriggerSelectiveReadoutComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/ ) {
210 // see header file for class documentation
212 // ** No readout list for SOR and EOR event
213 if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) )
216 // ** Create empty Readoutlist
217 AliHLTEventDDL readoutList;
218 memset( &readoutList, 0, sizeof(AliHLTEventDDL) );
220 const AliHLTComponentBlockData* iter = NULL;
222 AliHLTUInt8_t patch = 0;
224 // ** Loop over all input blocks and specify which data format should be read - only select Raw Data
225 for ( iter = GetFirstInputBlock(kAliHLTDataTypeDDLRaw|fDetector.Data()); iter != NULL; iter = GetNextInputBlock() ) {
227 // ** Check if block has only the CDH Header ( 32 Bytes = gkAliHLTCommonHeaderCount *sizeof(AliHLTUInt32_t) )
228 if ( iter->fSize <= ( gkAliHLTCommonHeaderCount * sizeof(AliHLTUInt32_t) ) ) {
233 // ** Check for detector specifications
236 // ** Check for TPC specifc specification
237 if ( ! fDetector.CompareTo("TPC ") ) {
239 AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
240 patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
241 if (patch < 2) ddlId = 768 + (2 * slice) + patch;
242 else ddlId = 838 + (4*slice) + patch;
243 HLTDebug ( "Input Data - TPC - Slice/Patch: %d/%d - EquipmentID : %d.", slice, patch, ddlId );
244 } // if ( ! fDetector.CompareTo("TPC ") ) {
246 // ** Check for other detector specifc specification
248 HLTError("Detector '%s' has not been implemented yet.", fDetector.Data() );
253 // ** Check if threshold should be considerd
256 if ( fEnableThresholdSize ) {
257 // ** Check for TPC threshold
258 if ( ! fDetector.CompareTo("TPC ") ) {
259 if ( patch < fkNThreshold ){
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] ) ) {
262 EnableDDLBit( readoutList, ddlId );
263 HLTDebug ( "DDL Id %d enabled for DAQ readout - size %d > threshold %d.", ddlId, iter->fSize, fThreshold[patch] );
267 } // if ( ! fDetector.CompareTo("TPC ") ) {
269 // ** Check for other detector threshold
271 HLTError("Check for size threshold as not been implemented yet for Detector '%s'.", fDetector.Data() );
273 } // if ( fEnableThresholdSize ) {
276 // ** PushForward data block
279 PushBack( iter->fPtr , iter->fSize, iter->fDataType, iter->fSpecification);
281 } // for ( iter = GetFirstInputBlock(kAliHLTDataTypeDDLRaw|fDetector.Data()); iter != NULL; iter = GetNextInputBlock() ) {
284 // ** PushBack readout list
287 PushBack( &readoutList, sizeof(AliHLTEventDDL), kAliHLTDataTypeDDL, (AliHLTUInt32_t) 0 );