]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/ITS/AliHLTITSAgent.cxx
Adjust matching rules for queued output buffers which have not been used
[u/mrichter/AliRoot.git] / HLT / ITS / AliHLTITSAgent.cxx
1 // $Id$
2
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: Matthias Richter <Matthias.Richter@ift.uib.no>        *
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   AliHLTITSAgent.cxx
20     @author Matthias Richter
21     @date   25.08.2008
22     @brief  Agent of the libAliHLTITS library
23 */
24
25 #include <cassert>
26 #include "AliHLTITSAgent.h"
27 #include "AliHLTConfiguration.h"
28 #include "AliHLTOUT.h"
29 //#include "AliDAQ.h"
30
31 // header files of library components
32
33 // header file of the module preprocessor
34 #include "AliHLTITSCompressRawDataSDDComponent.h"
35 #include "AliHLTITSClusterFinderSPDComponent.h"
36 #include "AliHLTITSClusterFinderSSDComponent.h"
37
38 /** global instance for agent registration */
39 AliHLTITSAgent gAliHLTITSAgent;
40
41 /** ROOT macro for the implementation of ROOT specific class methods */
42 ClassImp(AliHLTITSAgent)
43
44 AliHLTITSAgent::AliHLTITSAgent()
45   :
46   AliHLTModuleAgent("ITS"),
47   fRawDataHandler(NULL)
48 {
49   // see header file for class documentation
50   // or
51   // refer to README to build package
52   // or
53   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
54 }
55
56 AliHLTITSAgent::~AliHLTITSAgent()
57 {
58   // see header file for class documentation
59 }
60
61 int AliHLTITSAgent::CreateConfigurations(AliHLTConfigurationHandler* /*handler*/,
62                                             AliRawReader* /*rawReader*/,
63                                             AliRunLoader* /*runloader*/) const
64 {
65   // see header file for class documentation
66   return 0;
67 }
68
69 const char* AliHLTITSAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
70                                                        AliRunLoader* /*runloader*/) const
71 {
72   // see header file for class documentation
73
74   return "";
75 }
76
77 const char* AliHLTITSAgent::GetRequiredComponentLibraries() const
78 {
79   // see header file for class documentation
80   return "";
81 }
82
83 int AliHLTITSAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const
84 {
85   // see header file for class documentation
86   assert(pHandler);
87   if (!pHandler) return -EINVAL;
88   pHandler->AddComponent(new AliHLTITSCompressRawDataSDDComponent);
89   pHandler->AddComponent(new AliHLTITSClusterFinderSPDComponent);
90   pHandler->AddComponent(new AliHLTITSClusterFinderSSDComponent);
91
92   return 0;
93 }
94
95 AliHLTModulePreprocessor* AliHLTITSAgent::GetPreprocessor()
96 {
97   // see header file for class documentation
98   return NULL;
99 }
100
101 int AliHLTITSAgent::GetHandlerDescription(AliHLTComponentDataType dt,
102                                              AliHLTUInt32_t spec,
103                                              AliHLTOUTHandlerDesc& desc) const
104 {
105   // see header file for class documentation
106
107   // Handlers for ITS raw data. Even though there are 3 detectors
108   // everything is handled in one module library and one HLTOUT handler.
109   // This assumes that the data blocks are sent with data type
110   // {DDL_RAW :ISDD} and the bit set in the specification corresponding.
111   // to detector DDL id.
112   // An HLTOUT handler is implemented to extract the equipment id from
113   // the specification.
114   // Note: Future versions of the framework will provide a default handler
115   // class with that functionality.
116   if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD)) {
117       desc=AliHLTOUTHandlerDesc(kRawReader, dt, GetModuleId());
118       HLTInfo("module %s handles data block type %s specification %d (0x%x)", 
119               GetModuleId(), AliHLTComponent::DataType2Text(dt).c_str(), spec, spec);
120       return 1;
121   }
122   return 0;
123 }
124
125 AliHLTOUTHandler* AliHLTITSAgent::GetOutputHandler(AliHLTComponentDataType dt,
126                                                    AliHLTUInt32_t /*spec*/)
127 {
128   // see header file for class documentation
129   if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD)) {
130     // use the default handler
131     if (!fRawDataHandler) {
132       fRawDataHandler=new AliHLTOUTSDDRawDataHandler;
133     }
134     return fRawDataHandler;
135   }
136   return NULL;
137 }
138
139 int AliHLTITSAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
140 {
141   // see header file for class documentation
142   if (pInstance==NULL) return -EINVAL;
143
144   if (pInstance==fRawDataHandler) {
145     delete fRawDataHandler;
146     fRawDataHandler=NULL;
147     return 0;
148   }
149
150   delete pInstance;
151   return 0;
152 }
153
154 int AliHLTITSAgent::AliHLTOUTSDDRawDataHandler::ProcessData(AliHLTOUT* pData)
155 {
156   // see header file for class documentation
157   if (!pData) return -EINVAL;
158   static int errorCount=0;
159   const int maxErrorCount=10;
160   AliHLTComponentDataType dt=kAliHLTVoidDataType;
161   AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
162   int iResult=pData->GetDataBlockDescription(dt, spec);
163   if (iResult>=0) {
164     if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD)) {
165       int ddlOffset=256;//AliDAQ::DdlIDOffset("ITSSDD");
166       int numberOfDDLs=24;//AliDAQ::NumberOfDdls("ITSSDD");
167       int ddlNo=0;
168       for (;ddlNo<32 && ddlNo<numberOfDDLs; ddlNo++) {
169         if (spec&(0x1<<ddlNo)) break;
170       }
171       if (ddlNo>=32 || ddlNo>=numberOfDDLs) {
172         HLTError("invalid specification 0x%08x: can not extract DDL id for data block %s", spec, AliHLTComponent::DataType2Text(dt).c_str());
173         iResult=-ENODEV;
174       } else if (spec^(0x1<<ddlNo)) {
175         iResult=-EEXIST;
176         HLTError("multiple links set in specification 0x%08x: can not extract DDL id for data block %s", spec, AliHLTComponent::DataType2Text(dt).c_str());
177       } else {
178         iResult=ddlOffset+ddlNo;
179       }
180     } else {
181       if (errorCount++<10) {
182         HLTError("wrong data type: expecting %s, got %s; %s",
183                  AliHLTComponent::DataType2Text(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD).c_str(),
184                  AliHLTComponent::DataType2Text(dt).c_str(),
185                    errorCount==maxErrorCount?"suppressing further error messages":"");
186       }
187       iResult=-EFAULT;
188     }
189   }
190   return iResult;
191 }