2 //***************************************************************************
3 //* This file is property of and copyright by the ALICE HLT Project *
4 //* ALICE Experiment at CERN, All rights reserved. *
6 //* Primary Authors: Sergey Gorbunov <sergey.gorbunov@fias.uni-frankfurt.de *
7 //* for The ALICE HLT Project. *
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 AliHLTTPCClusterTransformationComponent.cxx
19 @author Sergey Gorbunov
24 #include "AliHLTTPCClusterTransformationComponent.h"
25 #include "AliHLTTPCClusterTransformation.h"
26 #include "AliHLTTPCDefinitions.h"
27 #include "AliHLTTPCTransform.h"
28 #include "AliHLTTPCRawCluster.h"
29 #include "AliHLTTPCClusterDataFormat.h"
30 #include "AliHLTErrorGuard.h"
32 #include "AliCDBManager.h"
33 #include "AliCDBEntry.h"
34 #include "AliTPCcalibDB.h"
37 #include "TObjString.h"
44 ClassImp(AliHLTTPCClusterTransformationComponent) //ROOT macro for the implementation of ROOT specific class methods
46 const char* AliHLTTPCClusterTransformationComponent::fgkOCDBEntryClusterTransformation="HLT/ConfigTPC/TPCClusterTransformation";
48 AliHLTTPCClusterTransformation AliHLTTPCClusterTransformationComponent::fgTransform;
49 Bool_t AliHLTTPCClusterTransformationComponent::fgTimeInitialisedFromEvent = 0;
51 AliHLTTPCClusterTransformationComponent::AliHLTTPCClusterTransformationComponent()
54 fBenchmark("ClusterTransformation")
56 // see header file for class documentation
58 // refer to README to build package
60 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
63 fBenchmark.SetTimer(0,"total");
66 AliHLTTPCClusterTransformationComponent::~AliHLTTPCClusterTransformationComponent()
71 const char* AliHLTTPCClusterTransformationComponent::GetComponentID() {
72 // see header file for class documentation
74 return "TPCClusterTransformation";
77 void AliHLTTPCClusterTransformationComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
78 // see header file for class documentation
81 list.push_back( AliHLTTPCDefinitions::fgkRawClustersDataType | kAliHLTDataOriginTPC );
82 list.push_back(AliHLTTPCDefinitions::fgkAliHLTDataTypeClusterMCInfo | kAliHLTDataOriginTPC );
85 AliHLTComponentDataType AliHLTTPCClusterTransformationComponent::GetOutputDataType() {
86 // see header file for class documentation
88 return kAliHLTMultipleDataType;
91 int AliHLTTPCClusterTransformationComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList) {
92 // see header file for class documentation
95 tgtList.push_back(AliHLTTPCDefinitions::fgkClustersDataType| kAliHLTDataOriginTPC);
96 tgtList.push_back(AliHLTTPCDefinitions::fgkAliHLTDataTypeClusterMCInfo | kAliHLTDataOriginTPC );
97 return tgtList.size();
100 void AliHLTTPCClusterTransformationComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
101 // see header file for class documentation
103 inputMultiplier = 2.0;
106 AliHLTComponent* AliHLTTPCClusterTransformationComponent::Spawn() {
107 // see header file for class documentation
109 return new AliHLTTPCClusterTransformationComponent();
112 int AliHLTTPCClusterTransformationComponent::DoInit( int argc, const char** argv )
114 // see header file for class documentation
116 AliTPCcalibDB *calib=AliTPCcalibDB::Instance();
118 HLTError("AliTPCcalibDB does not exist");
121 calib->SetRun(GetRunNo());
122 calib->UpdateRunInformations(GetRunNo());
124 if( !fgTransform.IsInitialised() ){
125 int err = fgTransform.Init( GetBz(), GetTimeStamp() );
127 HLTError(Form("Cannot retrieve offline transform from AliTPCcalibDB, AliHLTTPCClusterTransformation returns %d",err));
135 //!! iResult = ConfigureFromCDBTObjString(fgkOCDBEntryClusterTransformation);
137 if (iResult>=0 && argc>0)
138 iResult=ConfigureFromArgumentString(argc, argv);
143 int AliHLTTPCClusterTransformationComponent::DoDeinit() {
144 // see header file for class documentation
145 fgTransform.DeInit();
149 int AliHLTTPCClusterTransformationComponent::Reconfigure(const char* /*cdbEntry*/, const char* /*chainId*/) {
150 // see header file for class documentation
152 return 0;//!! ConfigureFromCDBTObjString(fgkOCDBEntryClusterTransformation);
155 int AliHLTTPCClusterTransformationComponent::ScanConfigurationArgument(int argc, const char** argv){
157 // see header file for class documentation
159 if (argc<=0) return 0;
161 TString argument=argv[i];
163 if (argument.CompareTo("-change-dataId")==0){
164 HLTDebug("Change data ID received.");
169 HLTInfo("Unknown argument %s",argv[i]);
176 int AliHLTTPCClusterTransformationComponent::DoEvent(const AliHLTComponentEventData& evtData,
177 const AliHLTComponentBlockData* blocks,
178 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr,
179 AliHLTUInt32_t& size,
180 vector<AliHLTComponentBlockData>& outputBlocks ){
181 // see header file for class documentation
183 UInt_t maxOutSize = size;
186 if(!IsDataEvent()) return 0;
188 if( !fgTransform.IsInitialised() ){
189 HLTError(" TPC Transformation is not initialised ");
193 fBenchmark.StartNewEvent();
196 // Initialise the transformation here once more for the case of off-line reprocessing
197 if( !fgTimeInitialisedFromEvent ){
198 Long_t currentTime = static_cast<AliHLTUInt32_t>(time(NULL));
199 Long_t eventTimeStamp = GetTimeStamp();
200 if( TMath::Abs( fgTransform.GetCurrentTimeStamp() - eventTimeStamp )>60 &&
201 TMath::Abs( currentTime - eventTimeStamp)>60*60*5 ){
202 int err = fgTransform.SetCurrentTimeStamp( eventTimeStamp );
204 HLTError(Form("Cannot set time stamp, AliHLTTPCClusterTransformation returns %d",err));
208 fgTimeInitialisedFromEvent = 1;
211 for( unsigned long ndx=0; ndx<evtData.fBlockCnt; ndx++ ){
213 const AliHLTComponentBlockData *iter = blocks+ndx;
215 fBenchmark.AddInput(iter->fSize);
217 HLTDebug("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s or $s",
218 evtData.fEventID, evtData.fEventID,
219 DataType2Text( iter->fDataType).c_str(),
220 DataType2Text(AliHLTTPCDefinitions::fgkRawClustersDataType).c_str(), DataType2Text(AliHLTTPCDefinitions::fgkAliHLTDataTypeClusterMCInfo).c_str());
222 if(iter->fDataType == (AliHLTTPCDefinitions::fgkAliHLTDataTypeClusterMCInfo | kAliHLTDataOriginTPC) ){
223 // simply forward MC labels
225 if( size+iter->fSize > maxOutSize ){
226 HLTWarning( "Output buffer (%db) is too small, required %db", maxOutSize, size+iter->fSize);
231 memcpy( outputPtr, iter->fPtr, iter->fSize );
233 AliHLTComponentBlockData bd;
236 bd.fSize = iter->fSize;
237 bd.fSpecification = iter->fSpecification;
238 bd.fDataType = iter->fDataType;
239 outputBlocks.push_back( bd );
240 fBenchmark.AddOutput(bd.fSize);
242 outputPtr += bd.fSize;
246 if(iter->fDataType != (AliHLTTPCDefinitions::fgkRawClustersDataType | kAliHLTDataOriginTPC)) continue;
248 UInt_t minSlice = AliHLTTPCDefinitions::GetMinSliceNr(*iter);
249 UInt_t minPartition = AliHLTTPCDefinitions::GetMinPatchNr(*iter);
252 if ((int)minPartition<AliHLTTPCTransform::GetNRowLow())
253 padpitch=AliHLTTPCTransform::GetPadPitchWidthLow();
255 padpitch=AliHLTTPCTransform::GetPadPitchWidthUp();
256 float zwidth=AliHLTTPCTransform::GetZWidth();
258 fBenchmark.SetName(Form("ClusterTransform slice %d patch %d",minSlice,minPartition));
260 HLTDebug("minSlice: %d, minPartition: %d", minSlice, minPartition);
262 AliHLTTPCRawClusterData* rawClusters = (AliHLTTPCRawClusterData*)(iter->fPtr);
263 if( !rawClusters ) continue;
265 AliHLTTPCClusterData* outPtr = (AliHLTTPCClusterData*)outputPtr;
266 outPtr->fSpacePointCnt=0;
268 long maxPoints = ((long)maxOutSize-size-sizeof(AliHLTTPCClusterData))/sizeof(AliHLTTPCSpacePointData);
270 if( rawClusters->fCount > maxPoints ){
271 HLTWarning("No more space to add clusters, exiting!");
276 for( int icl=0; icl<rawClusters->fCount; icl++){
278 const AliHLTTPCRawCluster &cl = rawClusters->fClusters[icl];
280 AliHLTTPCSpacePointData& c=outPtr->fSpacePoints[outPtr->fSpacePointCnt];
281 int padrow=cl.GetPadRow();
283 // something wrong here, padrow is stored in the cluster header
284 // word which has bit pattern 0x3 in bits bit 30 and 31 which was
286 ALIHLTERRORGUARD(1, "can not read cluster header word");
289 padrow+=AliHLTTPCTransform::GetFirstRow(minPartition);
290 AliHLTUInt32_t charge=cl.GetCharge();
292 float pad=cl.GetPad();
293 float time=cl.GetTime();
294 float sigmaY2=cl.GetSigmaY2();
295 float sigmaZ2=cl.GetSigmaZ2();
296 sigmaY2*=padpitch*padpitch;
297 sigmaZ2*=zwidth*zwidth;
300 c.SetSigmaY2(sigmaY2);
301 c.SetSigmaZ2(sigmaZ2);
302 c.SetQMax(cl.GetQMax());
305 int err = fgTransform.Transform( minSlice, padrow, pad, time, xyz );
307 HLTWarning(Form("Cannot transform the cluster, AliHLTTPCClusterTransformation returns error %d, %s",err, fgTransform.GetLastError()));
314 // set the cluster ID so that the cluster dump printout is the same for FCF and SCF
315 c.SetID( minSlice, minPartition, outPtr->fSpacePointCnt );
317 HLTDebug("Cluster number %d: %f, Y: %f, Z: %f, charge: %d \n", outPtr->fSpacePointCnt, cluster.fX, cluster.fY, cluster.fZ, (UInt_t)cluster.fCharge);
319 outPtr->fSpacePointCnt++;
320 } // end of loop over clusters
322 HLTDebug("Number of found clusters: %d", outPtr->fSpacePointCnt);
324 UInt_t mysize = sizeof(AliHLTTPCClusterData) + sizeof(AliHLTTPCSpacePointData)*outPtr->fSpacePointCnt;
326 AliHLTComponentBlockData bd;
330 bd.fSpecification = iter->fSpecification;
331 if(fDataId==kFALSE) bd.fDataType = AliHLTTPCDefinitions::fgkClustersDataType;
332 else bd.fDataType = AliHLTTPCDefinitions::fgkAlterClustersDataType;
334 //HLTDebug("datatype: %s", DataType2Text(bd.fDataType).c_str());
336 outputBlocks.push_back( bd );
338 fBenchmark.AddOutput(bd.fSize);
342 } // end of loop over data blocks
345 HLTInfo(fBenchmark.GetStatistics());
352 void AliHLTTPCClusterTransformationComponent::GetOCDBObjectDescription( TMap* const targetMap)
354 // Get a list of OCDB object description needed for the particular component
355 if (!targetMap) return;
357 // OCDB entries for component arguments
359 //!! targetMap->Add(new TObjString(fgkOCDBEntryClusterTransformation), new TObjString("component argument for the charge threshold"));
361 // OCDB entries to be fetched by the TAXI (access via the AliTPCcalibDB class)
362 targetMap->Add(new TObjString("TPC/Calib/Parameters"), new TObjString("unknown content"));
363 targetMap->Add(new TObjString("TPC/Calib/TimeDrift"), new TObjString("drift velocity calibration"));
364 targetMap->Add(new TObjString("TPC/Calib/TimeGain"), new TObjString("time gain calibration"));
365 targetMap->Add(new TObjString("TPC/Calib/Temperature"), new TObjString("temperature map"));
366 targetMap->Add(new TObjString("TPC/Calib/PadGainFactor"), new TObjString("gain factor pad by pad"));
367 targetMap->Add(new TObjString("TPC/Calib/ClusterParam"), new TObjString("cluster parameters"));
368 targetMap->Add(new TObjString("TPC/Calib/Correction"), new TObjString("coreection"));
369 targetMap->Add(new TObjString("TPC/Calib/RecoParam"), new TObjString("reconstruction parameters"));
371 // OCDB entries needed to be fetched by the Pendolino
372 targetMap->Add(new TObjString("TPC/Calib/AltroConfig"), new TObjString("contains the altro config, e.g. info about the L0 trigger timing"));
373 targetMap->Add(new TObjString("GRP/CTP/CTPtiming"), new TObjString("content used in the cluster coordinate transformation in relation to the L0 trigger timing"));
375 // OCDB entries necessary for replaying data on the HLT cluster
376 targetMap->Add(new TObjString("GRP/GRP/Data"), new TObjString("contains magnetic field info"));
378 // OCDB entries needed to suppress fatals/errors/warnings during reconstruction
379 targetMap->Add(new TObjString("TPC/Calib/Distortion"), new TObjString("distortion map"));
380 targetMap->Add(new TObjString("TPC/Calib/GainFactorDedx"), new TObjString("gain factor dedx"));
381 targetMap->Add(new TObjString("TPC/Calib/PadTime0"), new TObjString("time0 offset pad by pad"));
382 targetMap->Add(new TObjString("TPC/Calib/PadNoise"), new TObjString("pad noise values"));
383 targetMap->Add(new TObjString("TPC/Calib/Pedestals"), new TObjString("pedestal info"));
384 targetMap->Add(new TObjString("TPC/Calib/Pulser"), new TObjString("pulser info"));
385 targetMap->Add(new TObjString("TPC/Calib/CE"), new TObjString("CE laser calibration result"));
386 targetMap->Add(new TObjString("TPC/Calib/Raw"), new TObjString("unknown content"));
387 targetMap->Add(new TObjString("TPC/Calib/QA"), new TObjString("not important"));
388 targetMap->Add(new TObjString("TPC/Calib/Mapping"), new TObjString("unknown content"));
389 targetMap->Add(new TObjString("TPC/Calib/Goofie"), new TObjString("Goofie values, not used at the moment (05.03.2010)"));
390 targetMap->Add(new TObjString("TPC/Calib/HighVoltage"), new TObjString("high voltage values, not used"));
391 targetMap->Add(new TObjString("TPC/Calib/Ref"), new TObjString("unknown content"));