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: Jacek Otwinowski <J.Otwinowski@gsi.de> *
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 AliHLTTPCOfflineTrackerCalibComponent.cxx
19 @author Jacek Otwinowski & Matthias Richter
21 @brief Wrapper component to the TPC offline tracker (ONLY CALIBRATION)
24 #include "AliHLTTPCOfflineTrackerCalibComponent.h"
26 #include "TClonesArray.h"
27 #include "TObjArray.h"
28 #include "TObjString.h"
29 #include "AliVParticle.h"
30 #include "AliCDBManager.h"
31 #include "AliCDBEntry.h"
32 #include "AliGeomManager.h"
33 #include "AliTPCReconstructor.h"
34 #include "AliTPCParam.h"
35 #include "AliTPCRecoParam.h"
36 #include "AliTPCParamSR.h"
37 #include "AliTPCtrackerMI.h"
38 #include "AliTPCClustersRow.h"
39 #include "AliTPCseed.h"
40 #include "AliESDEvent.h"
41 #include "AliHLTTPCDefinitions.h"
43 /** ROOT macro for the implementation of ROOT specific class methods */
44 ClassImp(AliHLTTPCOfflineTrackerCalibComponent)
46 AliHLTTPCOfflineTrackerCalibComponent::AliHLTTPCOfflineTrackerCalibComponent() : AliHLTProcessor(),
47 fGeometryFileName(""),
52 // Default constructor
53 fGeometryFileName = getenv("ALICE_ROOT");
54 fGeometryFileName += "/HLT/TPCLib/offline/geometry.root";
57 AliHLTTPCOfflineTrackerCalibComponent::~AliHLTTPCOfflineTrackerCalibComponent()
59 // see header file for class documentation
62 const char* AliHLTTPCOfflineTrackerCalibComponent::GetComponentID()
64 // see header file for class documentation
65 return "TPCOfflineTrackerCalib";
68 void AliHLTTPCOfflineTrackerCalibComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
70 // get input data type
71 list.push_back(kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC/*AliHLTTPCDefinitions::fgkOfflineClustersDataType*/);
74 AliHLTComponentDataType AliHLTTPCOfflineTrackerCalibComponent::GetOutputDataType()
76 // create output data type
77 //return kAliHLTDataTypeESDObject|kAliHLTDataOriginTPC/*AliHLTTPCDefinitions::fgkOfflineTrackSegmentsDataType*/;
78 return kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC;
81 void AliHLTTPCOfflineTrackerCalibComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
83 // get output data size
88 AliHLTComponent* AliHLTTPCOfflineTrackerCalibComponent::Spawn()
90 // create instance of the component
91 return new AliHLTTPCOfflineTrackerCalibComponent;
94 int AliHLTTPCOfflineTrackerCalibComponent::DoInit( int argc, const char** argv )
99 #ifdef HAVE_NOT_TPCOFFLINE_REC
100 HLTFatal("AliRoot version > v4-13-Release required");
105 TString configuration="";
108 // loop over input parameters
109 for (int i=0; i<argc && iResult>=0; i++) {
111 if (argument.IsNull()) continue;
113 if (argument.CompareTo("-geometry")==0) {
114 if ((bMissingParam=(++i>=argc))) break;
116 HLTInfo("got \'-geometry\' argument: %s", argv[i]);
117 fGeometryFileName = argv[i];
118 HLTInfo("Geometry file is: %s", fGeometryFileName.c_str());
120 // the remaining arguments are treated as configuration
122 if (!configuration.IsNull()) configuration+=" ";
123 configuration+=argument;
128 HLTError("missing parameter for argument %s", argument.Data());
132 if (iResult>=0 && !configuration.IsNull()) {
133 iResult=Configure(configuration.Data());
135 iResult=Reconfigure(NULL, NULL);
143 AliGeomManager::LoadGeometry(fGeometryFileName.c_str());
144 if((AliGeomManager::GetGeometry()) == 0) {
145 HLTError("Cannot load geometry from file %s",fGeometryFileName.c_str());
149 // TPC reconstruction parameters
150 AliTPCRecoParam * tpcRecoParam = AliTPCRecoParam::GetHLTParam();
152 tpcRecoParam->SetClusterSharing(kTRUE);
154 AliTPCReconstructor tpcReconstructor;
155 tpcReconstructor.SetRecoParam(tpcRecoParam);
158 // TPC geometry parameters
159 fTPCGeomParam = new AliTPCParamSR;
161 fTPCGeomParam->ReadGeoMatrices();
165 fTracker = new AliTPCtrackerMI(fTPCGeomParam);
167 // AliESDEvent event needed by AliTPCtrackerMI
168 // output of the component
169 fESD = new AliESDEvent();
171 fESD->CreateStdContent();
174 if (!fTracker || !fESD || !fTPCGeomParam) {
175 HLTError("failed creating internal objects");
180 // read the default CDB entries
181 iResult=Reconfigure(NULL, NULL);
187 int AliHLTTPCOfflineTrackerCalibComponent::DoDeinit()
189 // deinit configuration
191 if(fTPCGeomParam) delete fTPCGeomParam; fTPCGeomParam = 0;
192 if(fTracker) delete fTracker; fTracker = 0;
193 if(fESD) delete fESD; fESD = 0;
198 int AliHLTTPCOfflineTrackerCalibComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/)
201 HLTInfo("DoEvent processing data");
204 TClonesArray *clusterArray=0;
205 TObjArray *seedArray=0;
208 const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC);
210 HLTError("Cannot get first data block 0x%08x ",pBlock);
211 iResult=-ENOMEM; return iResult;
213 int minSlice=AliHLTTPCDefinitions::GetMinSliceNr(pBlock->fSpecification);
214 int maxSlice=AliHLTTPCDefinitions::GetMaxSliceNr(pBlock->fSpecification);
215 int minPatch=AliHLTTPCDefinitions::GetMinPatchNr(pBlock->fSpecification);
216 int maxPatch=AliHLTTPCDefinitions::GetMaxPatchNr(pBlock->fSpecification);
218 if (fTracker && fESD) {
219 // loop over input data blocks: TClonesArrays of clusters
220 for (TObject *pObj = (TObject *)GetFirstInputObject(kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC/*AliHLTTPCDefinitions::fgkOfflineClustersDataType*/,"TClonesArray",0);
221 pObj !=0 && iResult>=0;
222 pObj = (TObject *)GetNextInputObject(0)) {
223 clusterArray = dynamic_cast<TClonesArray*>(pObj);
224 if (!clusterArray) continue;
226 HLTInfo("load %d clusters from block %s 0x%08x", clusterArray->GetEntries(), DataType2Text(GetDataType(pObj)).c_str(), GetSpecification(pObj));
227 slice=AliHLTTPCDefinitions::GetMinSliceNr(GetSpecification(pObj));
228 patch=AliHLTTPCDefinitions::GetMinPatchNr(GetSpecification(pObj));
230 if(slice < minSlice) minSlice=slice;
231 if(slice > maxSlice) maxSlice=slice;
232 if(patch < minPatch) minPatch=patch;
233 if(patch > maxPatch) maxPatch=patch;
234 #ifndef HAVE_NOT_TPCOFFLINE_REC
235 fTracker->LoadClusters(clusterArray);
236 #endif //HAVE_NOT_TPCOFFLINE_REC
238 clusterArray->Delete();
239 }// end loop over input objects
241 #ifndef HAVE_NOT_TPCOFFLINE_REC
242 // Load outer sectors
243 fTracker->LoadOuterSectors();
244 // Load inner sectors
245 fTracker->LoadInnerSectors();
248 // set magnetic field for the ESD, assumes correct initialization of
250 fESD->SetMagneticField(AliTracker::GetBz());
253 fTracker->Clusters2Tracks(fESD);
256 seedArray = fTracker->GetSeeds();
258 Int_t nTracks = fESD->GetNumberOfTracks();
259 HLTInfo("Number TPC tracks %d", nTracks);
261 // calculate specification from the specification of input data blocks
262 AliHLTUInt32_t iSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( minSlice, maxSlice, minPatch, maxPatch );
263 HLTInfo("minSlice %d, maxSlice %d, minPatch %d, maxPatch %d", minSlice, maxSlice, minPatch, maxPatch);
266 if(seedArray) PushBack(seedArray, kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC, iSpecification);
269 if(seedArray) seedArray->Delete();
272 fTracker->UnloadClusters();
274 // reset ESDs and ESDs friends
278 HLTError("component not initialized");
285 int AliHLTTPCOfflineTrackerCalibComponent::Configure(const char* arguments)
287 // see header file for class documentation
289 if (!arguments) return iResult;
291 TString allArgs=arguments;
295 TObjArray* pTokens=allArgs.Tokenize(" ");
297 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
298 argument=((TObjString*)pTokens->At(i))->GetString();
299 if (argument.IsNull()) continue;
301 if (argument.CompareTo("-solenoidBz")==0) {
302 if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
303 HLTWarning("argument -solenoidBz is deprecated, magnetic field set up globally (%f)", GetBz());
306 HLTError("unknown argument %s", argument.Data());
314 HLTError("missing parameter for argument %s", argument.Data());
320 int AliHLTTPCOfflineTrackerCalibComponent::Reconfigure(const char* cdbEntry, const char* chainId)
322 // see header file for class documentation
324 const char* path=kAliHLTCDBSolenoidBz;
325 const char* defaultNotify="";
328 defaultNotify=" (default)";
331 if (chainId) {} // just to get rid of warning, can not comment argument due to debug message
332 HLTDebug("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
333 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
335 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
337 HLTDebug("received configuration object string: \'%s\'", pString->GetString().Data());
338 iResult=Configure(pString->GetString().Data());
340 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
343 HLTError("can not fetch object \"%s\" from CDB", path);