]>
Commit | Line | Data |
---|---|---|
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 | |
89c2e505 | 19 | @author Matthias Richter & Jacek Otwinowski |
1ac82ce6 | 20 | @date |
21 | @brief Wrapper component to the TPC offline cluster finder | |
22 | */ | |
23 | ||
24 | #include "AliHLTTPCOfflineClustererComponent.h" | |
25 | #include "AliHLTTPCDefinitions.h" | |
aa40a4a1 | 26 | #include "AliCDBManager.h" |
27 | #include "AliGeomManager.h" | |
28 | #include "AliTPCRecoParam.h" | |
1ac82ce6 | 29 | #include "AliTPCParam.h" |
30 | #include "AliTPCParamSR.h" | |
aa40a4a1 | 31 | #include "AliRawReaderMemory.h" |
1ac82ce6 | 32 | #include "AliTPCclustererMI.h" |
aa40a4a1 | 33 | #include "AliTPCClustersRow.h" |
f7a1cc68 | 34 | #include "AliMagF.h" |
aa40a4a1 | 35 | #include "AliTracker.h" |
1ac82ce6 | 36 | #include "AliDAQ.h" |
37 | #include "TString.h" | |
38 | #include "TObjArray.h" | |
89c2e505 | 39 | #include "TClonesArray.h" |
1ac82ce6 | 40 | #include "TObjString.h" |
41 | #include "TTree.h" | |
42 | ||
43 | /** ROOT macro for the implementation of ROOT specific class methods */ | |
44 | ClassImp(AliHLTTPCOfflineClustererComponent) | |
45 | ||
aa40a4a1 | 46 | AliHLTTPCOfflineClustererComponent::AliHLTTPCOfflineClustererComponent() |
47 | : AliHLTProcessor(), | |
48 | fOutputPercentage(100), | |
49 | fGeometryFileName(""), | |
50 | fTPCRecoParam(0), | |
51 | fTPCGeomParam(0), | |
52 | fRawReader(0), | |
e642ae99 | 53 | fClusterer(0) |
1ac82ce6 | 54 | { |
aa40a4a1 | 55 | // Default constructor |
56 | fGeometryFileName = getenv("ALICE_ROOT"); | |
57 | fGeometryFileName += "/HLT/TPCLib/offline/geometry.root"; | |
1ac82ce6 | 58 | } |
59 | ||
60 | AliHLTTPCOfflineClustererComponent::~AliHLTTPCOfflineClustererComponent() | |
61 | { | |
aa40a4a1 | 62 | // Destructor |
1ac82ce6 | 63 | } |
64 | ||
65 | const char* AliHLTTPCOfflineClustererComponent::GetComponentID() | |
66 | { | |
aa40a4a1 | 67 | // Return component ID |
1ac82ce6 | 68 | return "TPCOfflineClusterer"; |
69 | } | |
70 | ||
71 | void AliHLTTPCOfflineClustererComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) | |
72 | { | |
aa40a4a1 | 73 | // Get the list of input data types |
1ac82ce6 | 74 | list.push_back(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC); |
75 | } | |
76 | ||
77 | AliHLTComponentDataType AliHLTTPCOfflineClustererComponent::GetOutputDataType() | |
78 | { | |
aa40a4a1 | 79 | // Return output data type |
89c2e505 | 80 | // TObjArray/TClonesArray of clusters |
aa40a4a1 | 81 | return kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC/*AliHLTTPCDefinitions::fgkOfflineClustersDataType*/; |
82 | ||
1ac82ce6 | 83 | } |
84 | ||
85 | void AliHLTTPCOfflineClustererComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier) | |
86 | { | |
aa40a4a1 | 87 | // Get output data size |
89c2e505 | 88 | constBase = 20000; |
aa40a4a1 | 89 | inputMultiplier = ((double)fOutputPercentage)/100.0; |
1ac82ce6 | 90 | } |
91 | ||
92 | AliHLTComponent* AliHLTTPCOfflineClustererComponent::Spawn() | |
93 | { | |
aa40a4a1 | 94 | // Return a new instance of the class |
1ac82ce6 | 95 | return new AliHLTTPCOfflineClustererComponent; |
96 | } | |
97 | ||
98 | int AliHLTTPCOfflineClustererComponent::DoInit( int argc, const char** argv ) | |
99 | { | |
aa40a4a1 | 100 | // Perfom initialisation. Checks arguments (argc,argv) |
101 | // and make initialisation. Returns 0 if success. | |
102 | // | |
c03e064d | 103 | #ifdef HAVE_NOT_TPCOFFLINE_REC |
104 | HLTError("AliRoot version > v4-13-Release required"); | |
105 | return -ENOSYS; | |
106 | #endif //HAVE_NOT_TPCOFFLINE_REC | |
107 | ||
1ac82ce6 | 108 | int iResult=0; |
aa40a4a1 | 109 | HLTInfo("parsing %d arguments", argc); |
1ac82ce6 | 110 | |
111 | TString argument=""; | |
112 | TString configuration=""; | |
113 | int bMissingParam=0; | |
aa40a4a1 | 114 | |
115 | // loop over input parameters | |
1ac82ce6 | 116 | for (int i=0; i<argc && iResult>=0; i++) { |
117 | argument=argv[i]; | |
118 | if (argument.IsNull()) continue; | |
119 | ||
aa40a4a1 | 120 | if (argument.CompareTo("-geometry")==0) { |
121 | if ((bMissingParam=(++i>=argc))) break; | |
122 | ||
123 | HLTInfo("got \'-geometry\' argument: %s", argv[i]); | |
124 | fGeometryFileName = argv[i]; | |
125 | HLTInfo("Geometry file is: %s", fGeometryFileName.c_str()); | |
126 | ||
127 | // the remaining arguments are treated as configuration | |
128 | } else { | |
129 | if (!configuration.IsNull()) configuration+=" "; | |
130 | configuration+=argument; | |
131 | } | |
132 | } // end loop | |
133 | ||
1ac82ce6 | 134 | if (bMissingParam) { |
135 | HLTError("missing parameter for argument %s", argument.Data()); | |
136 | iResult=-EINVAL; | |
137 | } | |
138 | ||
139 | if (iResult>=0 && !configuration.IsNull()) { | |
140 | iResult=Configure(configuration.Data()); | |
141 | } else { | |
142 | iResult=Reconfigure(NULL, NULL); | |
143 | } | |
144 | ||
aa40a4a1 | 145 | // |
146 | // initialisation | |
147 | // | |
aa40a4a1 | 148 | |
149 | // Load geometry | |
aa40a4a1 | 150 | AliGeomManager::LoadGeometry(fGeometryFileName.c_str()); |
151 | if((AliGeomManager::GetGeometry()) == 0) { | |
152 | HLTError("Cannot load geometry from file %s",fGeometryFileName.c_str()); | |
153 | iResult=-EINVAL; | |
154 | } | |
155 | ||
aa40a4a1 | 156 | // Raw Reader |
157 | fRawReader = new AliRawReaderMemory; | |
158 | ||
159 | // TPC reconstruction parameters | |
89c2e505 | 160 | fTPCRecoParam = AliTPCRecoParam::GetHLTParam(); |
aa40a4a1 | 161 | if (fTPCRecoParam) { |
162 | fTPCRecoParam->SetClusterSharing(kTRUE); | |
163 | } | |
164 | ||
165 | // TPC geometry parameters | |
166 | fTPCGeomParam = new AliTPCParamSR; | |
167 | if (fTPCGeomParam) { | |
168 | fTPCGeomParam->ReadGeoMatrices(); | |
169 | } | |
170 | ||
171 | // Init clusterer | |
172 | fClusterer = new AliTPCclustererMI(fTPCGeomParam,fTPCRecoParam); | |
89c2e505 | 173 | #ifndef HAVE_NOT_TPCOFFLINE_REC |
174 | fClusterer->StoreInClonesArray(kTRUE); // output clusters stored in one TClonesArray | |
175 | #endif | |
aa40a4a1 | 176 | |
177 | if (!fRawReader || !fClusterer || !fTPCRecoParam || !fTPCGeomParam) { | |
178 | HLTError("failed creating internal objects"); | |
179 | iResult=-ENOMEM; | |
180 | } | |
1ac82ce6 | 181 | return iResult; |
182 | } | |
183 | ||
184 | int AliHLTTPCOfflineClustererComponent::DoDeinit() | |
185 | { | |
aa40a4a1 | 186 | // Deinitialisation of the component |
187 | if (fTPCRecoParam) delete fTPCRecoParam; fTPCRecoParam=0; | |
188 | if (fTPCGeomParam) delete fTPCGeomParam; fTPCGeomParam=0; | |
189 | if (fRawReader) delete fRawReader; fRawReader=0; | |
190 | if (fClusterer) delete fClusterer; fClusterer=0; | |
aa40a4a1 | 191 | |
1ac82ce6 | 192 | return 0; |
193 | } | |
194 | ||
195 | int AliHLTTPCOfflineClustererComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/) | |
196 | { | |
197 | // see header file for class documentation | |
aa40a4a1 | 198 | HLTInfo("processing data"); |
199 | ||
1ac82ce6 | 200 | int iResult=0; |
c03e064d | 201 | int commonMinSlice=-1; |
202 | int commonMaxSlice=-1; | |
203 | int commonMinPatch=-1; | |
204 | int commonMaxPatch=-1; | |
205 | ||
1ac82ce6 | 206 | for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC); |
aa40a4a1 | 207 | pBlock!=NULL && iResult>=0; |
1ac82ce6 | 208 | pBlock=GetNextInputBlock()) { |
209 | int slice=AliHLTTPCDefinitions::GetMinSliceNr(pBlock->fSpecification); | |
210 | int patch=AliHLTTPCDefinitions::GetMinPatchNr(pBlock->fSpecification); | |
aa40a4a1 | 211 | |
1ac82ce6 | 212 | if (slice!=AliHLTTPCDefinitions::GetMaxSliceNr(pBlock->fSpecification) || |
aa40a4a1 | 213 | patch!=AliHLTTPCDefinitions::GetMaxPatchNr(pBlock->fSpecification)) { |
214 | HLTError("ambiguous readout partition (specification 0x%08x), skipping input block", pBlock->fSpecification); | |
215 | break; | |
1ac82ce6 | 216 | } |
5aebebf7 | 217 | if (slice<0 || slice>35 || patch<0 || patch>5) { |
218 | HLTError("invalid readout partition %d/%d (specification 0x%08x, skipping input block", slice, patch, pBlock->fSpecification); | |
1ac82ce6 | 219 | break; |
220 | } | |
221 | ||
c03e064d | 222 | if (commonMinPatch<0) { |
223 | commonMinSlice=slice; | |
224 | commonMaxSlice=slice; | |
225 | commonMinPatch=patch; | |
226 | commonMaxPatch=patch; | |
227 | } else { | |
228 | if (commonMinSlice<slice) commonMinSlice=slice; | |
229 | if (commonMaxSlice>slice) commonMinSlice=slice; | |
230 | if (commonMinPatch<patch) commonMinPatch=patch; | |
231 | if (commonMaxPatch>patch) commonMinPatch=patch; | |
232 | } | |
233 | ||
aa40a4a1 | 234 | if (fRawReader && fClusterer) { |
1ac82ce6 | 235 | // setup raw reader and cluster finder |
1ac82ce6 | 236 | int ddlId=AliDAQ::DdlIDOffset("TPC"); |
237 | if (patch<2) { | |
238 | ddlId+=2*slice+patch; | |
239 | } else { | |
240 | ddlId+=72; | |
aa40a4a1 | 241 | ddlId+=4*slice+patch-2; |
1ac82ce6 | 242 | } |
c03e064d | 243 | |
244 | #ifdef HAVE_NOT_ALIRAWREADERMEMORY_ADDBUFFER | |
245 | // AliRawReaderMemory does not support mulriple blocks, | |
246 | // process on block by block basis | |
247 | fRawReader->SetMemory( reinterpret_cast<UChar_t*>( pBlock->fPtr ), pBlock->fSize ); | |
aa40a4a1 | 248 | fRawReader->SetEquipmentID(ddlId); |
c03e064d | 249 | iResult=RunClusterer(pBlock->fSpecification); |
250 | #else //!HAVE_NOT_ALIRAWREADERMEMORY_ADDBUFFER | |
251 | // add all raw data blocks to one clusterer | |
252 | fRawReader->AddBuffer( reinterpret_cast<UChar_t*>( pBlock->fPtr ), pBlock->fSize, ddlId ); | |
253 | #endif //HAVE_NOT_ALIRAWREADERMEMORY_ADDBUFFER | |
254 | } | |
255 | } | |
1ac82ce6 | 256 | |
c03e064d | 257 | #ifndef HAVE_NOT_ALIRAWREADERMEMORY_ADDBUFFER |
258 | iResult=RunClusterer(AliHLTTPCDefinitions::EncodeDataSpecification(commonMinSlice, | |
259 | commonMaxSlice, | |
260 | commonMinPatch, | |
261 | commonMaxPatch)); | |
262 | fRawReader->ClearBuffers(); | |
263 | #endif //HAVE_NOT_ALIRAWREADERMEMORY_ADDBUFFER | |
264 | ||
265 | return iResult; | |
266 | } | |
267 | ||
268 | int AliHLTTPCOfflineClustererComponent::RunClusterer(AliHLTUInt32_t outspec) | |
269 | { | |
270 | // see header file for class documentation | |
271 | int iResult=0; | |
272 | { | |
273 | if (fRawReader && fClusterer) { | |
1ac82ce6 | 274 | // run the cluster finder |
aa40a4a1 | 275 | fClusterer->Digits2Clusters(fRawReader); |
276 | ||
aa40a4a1 | 277 | Int_t nbClusters = 0; |
89c2e505 | 278 | TClonesArray* outClrow=NULL; |
c03e064d | 279 | #ifndef HAVE_NOT_TPCOFFLINE_REC |
89c2e505 | 280 | outClrow=fClusterer->GetOutputClonesArray(); |
281 | ||
c03e064d | 282 | #endif //HAVE_NOT_TPCOFFLINE_REC |
89c2e505 | 283 | |
488581c1 | 284 | if (outClrow) { |
89c2e505 | 285 | nbClusters = outClrow->GetEntriesFast() ; |
1ac82ce6 | 286 | |
89c2e505 | 287 | // insert TClonesArray of clusters into output stream |
c03e064d | 288 | PushBack(outClrow, kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC/*AliHLTTPCDefinitions::fgkOfflineClustersDataType*/, outspec); |
488581c1 | 289 | |
dcb8a00c | 290 | // clear array |
291 | outClrow->Delete(); | |
488581c1 | 292 | } |
c03e064d | 293 | HLTInfo("processing done: Number of clusters %d (specification 0x%08x)", nbClusters, outspec); |
1ac82ce6 | 294 | |
1ac82ce6 | 295 | } else { |
aa40a4a1 | 296 | HLTError("component not initialized"); |
297 | iResult=-EFAULT; | |
1ac82ce6 | 298 | } |
299 | } | |
1ac82ce6 | 300 | return iResult; |
301 | } | |
302 | ||
303 | int AliHLTTPCOfflineClustererComponent::Configure(const char* arguments) | |
304 | { | |
305 | // see header file for class documentation | |
306 | int iResult=0; | |
307 | if (!arguments) return iResult; | |
308 | ||
309 | TString allArgs=arguments; | |
310 | TString argument; | |
311 | int bMissingParam=0; | |
312 | ||
313 | TObjArray* pTokens=allArgs.Tokenize(" "); | |
314 | if (pTokens) { | |
315 | for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) { | |
316 | argument=((TObjString*)pTokens->At(i))->GetString(); | |
317 | if (argument.IsNull()) continue; | |
318 | ||
319 | if (argument.CompareTo("-something")==0) { | |
320 | if ((bMissingParam=(++i>=pTokens->GetEntries()))) break; | |
321 | ||
322 | } else { | |
323 | HLTError("unknown argument %s", argument.Data()); | |
324 | iResult=-EINVAL; | |
325 | break; | |
326 | } | |
327 | } | |
328 | delete pTokens; | |
329 | } | |
330 | if (bMissingParam) { | |
331 | HLTError("missing parameter for argument %s", argument.Data()); | |
332 | iResult=-EINVAL; | |
333 | } | |
334 | return iResult; | |
335 | } | |
336 | ||
337 | int AliHLTTPCOfflineClustererComponent::Reconfigure(const char* /*cdbEntry*/, const char* /*chainId*/) | |
338 | { | |
339 | // see header file for class documentation | |
340 | int iResult=0; | |
341 | // CDB stuff needs to be implemented | |
342 | return iResult; | |
343 | } |