]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/offline/AliHLTTPCOfflineClustererComponent.cxx
- tutorial and sample macros updated
[u/mrichter/AliRoot.git] / HLT / TPCLib / offline / AliHLTTPCOfflineClustererComponent.cxx
CommitLineData
1ac82ce6 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//* *
9//* Permission to use, copy, modify and distribute this software and its *
10//* documentation strictly for non-commercial purposes is hereby granted *
11//* without fee, provided that the above copyright notice appears in all *
12//* copies and that both the copyright notice and this permission notice *
13//* appear in the supporting documentation. The authors make no claims *
14//* about the suitability of this software for any purpose. It is *
15//* provided "as is" without express or implied warranty. *
16//**************************************************************************
17
18/** @file AliHLTTPCOfflineClustererComponent.cxx
19 @author Matthias Richter
20 @date
21 @brief Wrapper component to the TPC offline cluster finder
22*/
23
24#include "AliHLTTPCOfflineClustererComponent.h"
25#include "AliHLTTPCDefinitions.h"
26#include "AliRawReaderMemory.h"
27#include "AliTPCParam.h"
28#include "AliTPCParamSR.h"
29#include "AliTPCclustererMI.h"
30#include "AliDAQ.h"
31#include "TString.h"
32#include "TObjArray.h"
33#include "TObjString.h"
34#include "TTree.h"
35
36/** ROOT macro for the implementation of ROOT specific class methods */
37ClassImp(AliHLTTPCOfflineClustererComponent)
38
39AliHLTTPCOfflineClustererComponent::AliHLTTPCOfflineClustererComponent()
40{
41 // see header file for class documentation
42 // or
43 // refer to README to build package
44 // or
45 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
46}
47
48AliHLTTPCOfflineClustererComponent::~AliHLTTPCOfflineClustererComponent()
49{
50 // see header file for class documentation
51}
52
53const char* AliHLTTPCOfflineClustererComponent::GetComponentID()
54{
55 // see header file for class documentation
56 return "TPCOfflineClusterer";
57}
58
59void AliHLTTPCOfflineClustererComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
60{
61 // see header file for class documentation
62 list.push_back(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC);
63}
64
65AliHLTComponentDataType AliHLTTPCOfflineClustererComponent::GetOutputDataType()
66{
67 // see header file for class documentation
68 return kAliHLTDataTypeAliTreeR|kAliHLTDataOriginTPC;
69}
70
71void AliHLTTPCOfflineClustererComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
72{
73 // see header file for class documentation
74 constBase = 0;inputMultiplier = 1;
75}
76
77AliHLTComponent* AliHLTTPCOfflineClustererComponent::Spawn()
78{
79 // see header file for class documentation
80 return new AliHLTTPCOfflineClustererComponent;
81}
82
83int AliHLTTPCOfflineClustererComponent::DoInit( int argc, const char** argv )
84{
85 // see header file for class documentation
86 int iResult=0;
87
88 TString argument="";
89 TString configuration="";
90 int bMissingParam=0;
91 for (int i=0; i<argc && iResult>=0; i++) {
92 argument=argv[i];
93 if (argument.IsNull()) continue;
94
95 }
96 if (bMissingParam) {
97 HLTError("missing parameter for argument %s", argument.Data());
98 iResult=-EINVAL;
99 }
100
101 if (iResult>=0 && !configuration.IsNull()) {
102 iResult=Configure(configuration.Data());
103 } else {
104 iResult=Reconfigure(NULL, NULL);
105 }
106
107 return iResult;
108}
109
110int AliHLTTPCOfflineClustererComponent::DoDeinit()
111{
112 // see header file for class documentation
113 return 0;
114}
115
116int AliHLTTPCOfflineClustererComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/)
117{
118 // see header file for class documentation
119 int iResult=0;
120 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC);
121 pBlock!=NULL;
122 pBlock=GetNextInputBlock()) {
123 int slice=AliHLTTPCDefinitions::GetMinSliceNr(pBlock->fSpecification);
124 int patch=AliHLTTPCDefinitions::GetMinPatchNr(pBlock->fSpecification);
125 if (slice!=AliHLTTPCDefinitions::GetMaxSliceNr(pBlock->fSpecification) ||
126 patch!=AliHLTTPCDefinitions::GetMaxPatchNr(pBlock->fSpecification)) {
5aebebf7 127 HLTError("ambiguous readout partition (specification 0x%08x), skipping input block", pBlock->fSpecification);
1ac82ce6 128 break;
129 }
5aebebf7 130 if (slice<0 || slice>35 || patch<0 || patch>5) {
131 HLTError("invalid readout partition %d/%d (specification 0x%08x, skipping input block", slice, patch, pBlock->fSpecification);
1ac82ce6 132 break;
133 }
134
135 TTree* pTreeR=new TTree("TreeR", "Reconstructed Points Container");
136 AliRawReaderMemory* pRawReader=new AliRawReaderMemory;
137
138 // TODO: choose the right parameter
139 AliTPCParam* pParam = new AliTPCParamSR;
140 AliTPCclustererMI* pClusterer = new AliTPCclustererMI(pParam);
141
142 if (pTreeR && pRawReader && pClusterer) {
143 // setup raw reader and cluster finder
144 pRawReader->SetMemory( reinterpret_cast<UChar_t*>( pBlock->fPtr ), pBlock->fSize );
145 int ddlId=AliDAQ::DdlIDOffset("TPC");
146 if (patch<2) {
147 ddlId+=2*slice+patch;
148 } else {
149 ddlId+=72;
150 ddlId+=4*slice+patch;
151 }
152 pRawReader->SetEquipmentID(ddlId);
153
154 // TODO: find out from the data
155 //pClusterer->SetOldRCUFormat(kTRUE);
156
157 // run the cluster finder
158 pClusterer->SetOutput(pTreeR);
159 pClusterer->Digits2Clusters(pRawReader);
160
161 // insert tree into output stream
162 PushBack(pTreeR, kAliHLTDataTypeAliTreeR|kAliHLTDataOriginTPC, pBlock->fSpecification);
163
164 if (pClusterer) delete pClusterer; pClusterer=NULL;
165 if (pParam) delete pParam; pParam=NULL;
166 if (pRawReader) delete pRawReader; pRawReader=NULL;
167 if (pTreeR) delete pTreeR; pTreeR=NULL;
168 } else {
169 iResult=-ENOMEM;
170 }
171 }
172
173 return iResult;
174}
175
176int AliHLTTPCOfflineClustererComponent::Configure(const char* arguments)
177{
178 // see header file for class documentation
179 int iResult=0;
180 if (!arguments) return iResult;
181
182 TString allArgs=arguments;
183 TString argument;
184 int bMissingParam=0;
185
186 TObjArray* pTokens=allArgs.Tokenize(" ");
187 if (pTokens) {
188 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
189 argument=((TObjString*)pTokens->At(i))->GetString();
190 if (argument.IsNull()) continue;
191
192 if (argument.CompareTo("-something")==0) {
193 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
194
195 } else {
196 HLTError("unknown argument %s", argument.Data());
197 iResult=-EINVAL;
198 break;
199 }
200 }
201 delete pTokens;
202 }
203 if (bMissingParam) {
204 HLTError("missing parameter for argument %s", argument.Data());
205 iResult=-EINVAL;
206 }
207 return iResult;
208}
209
210int AliHLTTPCOfflineClustererComponent::Reconfigure(const char* /*cdbEntry*/, const char* /*chainId*/)
211{
212 // see header file for class documentation
213 int iResult=0;
214 // CDB stuff needs to be implemented
215 return iResult;
216}