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: Matthias Richter <Matthias.Richter@ift.uib.no> *
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 //**************************************************************************
18 /** @file AliHLTTPCOfflineClustererComponent.cxx
19 @author Matthias Richter
21 @brief Wrapper component to the TPC offline cluster finder
24 #include "AliHLTTPCOfflineClustererComponent.h"
25 #include "AliHLTTPCDefinitions.h"
26 #include "AliCDBManager.h"
27 #include "AliGeomManager.h"
28 #include "AliTPCRecoParam.h"
29 #include "AliTPCParam.h"
30 #include "AliTPCParamSR.h"
31 #include "AliRawReaderMemory.h"
32 #include "AliTPCclustererMI.h"
33 #include "AliTPCClustersRow.h"
34 #include "AliMagFMaps.h"
35 #include "AliTracker.h"
38 #include "TObjArray.h"
39 #include "TObjString.h"
42 /** ROOT macro for the implementation of ROOT specific class methods */
43 ClassImp(AliHLTTPCOfflineClustererComponent)
45 AliHLTTPCOfflineClustererComponent::AliHLTTPCOfflineClustererComponent()
47 fOutputPercentage(100),
48 fGeometryFileName(""),
55 // Default constructor
56 fGeometryFileName = getenv("ALICE_ROOT");
57 fGeometryFileName += "/HLT/TPCLib/offline/geometry.root";
60 AliHLTTPCOfflineClustererComponent::~AliHLTTPCOfflineClustererComponent()
65 const char* AliHLTTPCOfflineClustererComponent::GetComponentID()
67 // Return component ID
68 return "TPCOfflineClusterer";
71 void AliHLTTPCOfflineClustererComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
73 // Get the list of input data types
74 list.push_back(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC);
77 AliHLTComponentDataType AliHLTTPCOfflineClustererComponent::GetOutputDataType()
79 // Return output data type
80 // Tree or TObjArray of clusters
81 return kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC/*AliHLTTPCDefinitions::fgkOfflineClustersDataType*/;
85 void AliHLTTPCOfflineClustererComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
87 // Get output data size
89 inputMultiplier = ((double)fOutputPercentage)/100.0;
92 AliHLTComponent* AliHLTTPCOfflineClustererComponent::Spawn()
94 // Return a new instance of the class
95 return new AliHLTTPCOfflineClustererComponent;
98 int AliHLTTPCOfflineClustererComponent::DoInit( int argc, const char** argv )
100 // Perfom initialisation. Checks arguments (argc,argv)
101 // and make initialisation. Returns 0 if success.
104 HLTInfo("parsing %d arguments", argc);
107 TString configuration="";
110 // loop over input parameters
111 for (int i=0; i<argc && iResult>=0; i++) {
113 if (argument.IsNull()) continue;
115 if (argument.CompareTo("-geometry")==0) {
116 if ((bMissingParam=(++i>=argc))) break;
118 HLTInfo("got \'-geometry\' argument: %s", argv[i]);
119 fGeometryFileName = argv[i];
120 HLTInfo("Geometry file is: %s", fGeometryFileName.c_str());
122 // the remaining arguments are treated as configuration
124 if (!configuration.IsNull()) configuration+=" ";
125 configuration+=argument;
130 HLTError("missing parameter for argument %s", argument.Data());
134 if (iResult>=0 && !configuration.IsNull()) {
135 iResult=Configure(configuration.Data());
137 iResult=Reconfigure(NULL, NULL);
147 HLTInfo("Geometry file %s",fGeometryFileName.c_str());
148 AliGeomManager::LoadGeometry(fGeometryFileName.c_str());
149 if((AliGeomManager::GetGeometry()) == 0) {
150 HLTError("Cannot load geometry from file %s",fGeometryFileName.c_str());
155 fMagField = new AliMagFMaps("Maps","Maps", 2, 1.0, 10., 2);
156 AliTracker::SetFieldMap(fMagField,kFALSE);
161 fRawReader = new AliRawReaderMemory;
163 // TPC reconstruction parameters
164 fTPCRecoParam = AliTPCRecoParam::GetLowFluxParam();
166 fTPCRecoParam->SetClusterSharing(kTRUE);
169 // TPC geometry parameters
170 fTPCGeomParam = new AliTPCParamSR;
172 fTPCGeomParam->ReadGeoMatrices();
176 fClusterer = new AliTPCclustererMI(fTPCGeomParam,fTPCRecoParam);
178 if (!fRawReader || !fClusterer || !fTPCRecoParam || !fTPCGeomParam) {
179 HLTError("failed creating internal objects");
185 int AliHLTTPCOfflineClustererComponent::DoDeinit()
187 // Deinitialisation of the component
188 if (fTPCRecoParam) delete fTPCRecoParam; fTPCRecoParam=0;
189 if (fTPCGeomParam) delete fTPCGeomParam; fTPCGeomParam=0;
190 if (fRawReader) delete fRawReader; fRawReader=0;
191 if (fClusterer) delete fClusterer; fClusterer=0;
192 if (fMagField) delete fMagField; fMagField=0;
197 int AliHLTTPCOfflineClustererComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/)
199 // see header file for class documentation
200 HLTInfo("processing data");
203 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC);
204 pBlock!=NULL && iResult>=0;
205 pBlock=GetNextInputBlock()) {
206 int slice=AliHLTTPCDefinitions::GetMinSliceNr(pBlock->fSpecification);
207 int patch=AliHLTTPCDefinitions::GetMinPatchNr(pBlock->fSpecification);
209 if (slice!=AliHLTTPCDefinitions::GetMaxSliceNr(pBlock->fSpecification) ||
210 patch!=AliHLTTPCDefinitions::GetMaxPatchNr(pBlock->fSpecification)) {
211 HLTError("ambiguous readout partition (specification 0x%08x), skipping input block", pBlock->fSpecification);
214 if (slice<0 || slice>35 || patch<0 || patch>5) {
215 HLTError("invalid readout partition %d/%d (specification 0x%08x, skipping input block", slice, patch, pBlock->fSpecification);
219 if (fRawReader && fClusterer) {
220 // setup raw reader and cluster finder
221 fRawReader->SetMemory( reinterpret_cast<UChar_t*>( pBlock->fPtr ), pBlock->fSize );
222 int ddlId=AliDAQ::DdlIDOffset("TPC");
224 ddlId+=2*slice+patch;
227 ddlId+=4*slice+patch-2;
229 fRawReader->SetEquipmentID(ddlId);
231 // run the cluster finder
232 fClusterer->Digits2Clusters(fRawReader);
234 AliTPCClustersRow *clrow = 0x0;
235 Int_t nbClusters = 0;
236 Int_t lower = fClusterer->GetOutputArray()->LowerBound();
237 Int_t entries = fClusterer->GetOutputArray()->GetEntriesFast();
239 for (Int_t i=lower; i<entries; i++) {
240 clrow = (AliTPCClustersRow*) fClusterer->GetOutputArray()->At(i);
242 if(!clrow->GetArray()) continue;
244 nbClusters += clrow->GetArray()->GetEntries() ;
247 // insert TObjArray of clusters into output stream
248 PushBack(fClusterer->GetOutputArray(), kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC/*AliHLTTPCDefinitions::fgkOfflineClustersDataType*/, pBlock->fSpecification);
249 HLTInfo("processing done: DDL %d Number of clusters %d",ddlId, nbClusters);
252 HLTError("component not initialized");
260 int AliHLTTPCOfflineClustererComponent::Configure(const char* arguments)
262 // see header file for class documentation
264 if (!arguments) return iResult;
266 TString allArgs=arguments;
270 TObjArray* pTokens=allArgs.Tokenize(" ");
272 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
273 argument=((TObjString*)pTokens->At(i))->GetString();
274 if (argument.IsNull()) continue;
276 if (argument.CompareTo("-something")==0) {
277 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
280 HLTError("unknown argument %s", argument.Data());
288 HLTError("missing parameter for argument %s", argument.Data());
294 int AliHLTTPCOfflineClustererComponent::Reconfigure(const char* /*cdbEntry*/, const char* /*chainId*/)
296 // see header file for class documentation
298 // CDB stuff needs to be implemented