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: Gaute Øvrebekk <st05886@alf.uib.no> *
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 AliHLTITSClusterFinderComponent.cxx
19 @author Gaute Øvrebekk <st05886@alf.uib.no>
21 @brief Component to run offline clusterfinders
28 #include "AliHLTITSClusterFinderComponent.h"
30 #include "AliCDBEntry.h"
31 #include "AliCDBManager.h"
32 #include "AliHLTDataTypes.h"
33 #include "AliITSgeomTGeo.h"
34 #include "AliITSRecPoint.h"
35 #include "AliHLTITSSpacePointData.h"
36 #include "AliHLTITSClusterDataFormat.h"
37 #include <AliHLTDAQ.h>
38 #include "AliGeomManager.h"
39 #include "AliITSRecoParam.h"
40 #include "AliITSReconstructor.h"
45 #include "TObjString.h"
48 /** ROOT macro for the implementation of ROOT specific class methods */
49 ClassImp(AliHLTITSClusterFinderComponent);
51 AliHLTITSClusterFinderComponent::AliHLTITSClusterFinderComponent(int mode)
63 // see header file for class documentation
65 // refer to README to build package
67 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
68 if (fModeSwitch!=kClusterFinderSPD &&
69 fModeSwitch!=kClusterFinderSDD &&
70 fModeSwitch!=kClusterFinderSSD) {
71 HLTFatal("unknown cluster finder");
75 AliHLTITSClusterFinderComponent::~AliHLTITSClusterFinderComponent() {
76 // see header file for class documentation
79 // Public functions to implement AliHLTComponent's interface.
80 // These functions are required for the registration process
82 const char* AliHLTITSClusterFinderComponent::GetComponentID()
84 // see header file for class documentation
86 case kClusterFinderSPD:
87 return "ITSClusterFinderSPD";
89 case kClusterFinderSDD:
90 return "ITSClusterFinderSDD";
92 case kClusterFinderSSD:
93 return "ITSClusterFinderSSD";
99 void AliHLTITSClusterFinderComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
100 // see header file for class documentation
103 case kClusterFinderSPD:
104 list.push_back( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginITSSPD );
106 case kClusterFinderSDD:
107 list.push_back( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginITSSDD );
109 case kClusterFinderSSD:
110 list.push_back( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginITSSSD );
115 AliHLTComponentDataType AliHLTITSClusterFinderComponent::GetOutputDataType() {
116 // see header file for class documentation
118 case kClusterFinderSPD:
119 return kAliHLTDataTypeClusters|kAliHLTDataOriginITSSPD;
121 case kClusterFinderSDD:
122 return kAliHLTDataTypeClusters|kAliHLTDataOriginITSSDD;
124 case kClusterFinderSSD:
125 return kAliHLTDataTypeClusters|kAliHLTDataOriginITSSSD;
128 return kAliHLTVoidDataType;
131 void AliHLTITSClusterFinderComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
132 // see header file for class documentation
134 inputMultiplier = 100;
137 AliHLTComponent* AliHLTITSClusterFinderComponent::Spawn() {
138 // see header file for class documentation
139 return new AliHLTITSClusterFinderComponent(fModeSwitch);
142 Int_t AliHLTITSClusterFinderComponent::DoInit( int /*argc*/, const char** /*argv*/ ) {
143 // see header file for class documentation
145 if(fModeSwitch==kClusterFinderSPD) {
146 HLTDebug("using ClusterFinder for SPD");
147 //fNModules=AliITSgeomTGeo::GetNDetectors(1)*AliITSgeomTGeo::GetNLadders(1) + AliITSgeomTGeo::GetNDetectors(2)*AliITSgeomTGeo::GetNLadders(2);
148 fId=AliHLTDAQ::DdlIDOffset("ITSSPD");
149 fNddl=AliHLTDAQ::NumberOfDdls("ITSSPD");
151 else if(fModeSwitch==kClusterFinderSDD) {
152 HLTDebug("using ClusterFinder for SDD");
153 //fNModules=AliITSgeomTGeo::GetNDetectors(3)*AliITSgeomTGeo::GetNLadders(3) + AliITSgeomTGeo::GetNDetectors(4)*AliITSgeomTGeo::GetNLadders(4);
154 fId=AliHLTDAQ::DdlIDOffset("ITSSDD");
155 fNddl=AliHLTDAQ::NumberOfDdls("ITSSDD");
157 else if(fModeSwitch==kClusterFinderSSD) {
158 HLTDebug("using ClusterFinder for SSD");
159 //fNModules=AliITSgeomTGeo::GetNDetectors(5)*AliITSgeomTGeo::GetNLadders(5) + AliITSgeomTGeo::GetNDetectors(6)*AliITSgeomTGeo::GetNLadders(6);
160 fId=AliHLTDAQ::DdlIDOffset("ITSSSD");
161 fNddl=AliHLTDAQ::NumberOfDdls("ITSSSD");
164 HLTFatal("No mode set for clusterfindercomponent");
167 //Removed the warning for loading default RecoParam in HLT
168 AliITSRecoParam *par = AliITSRecoParam::GetLowFluxParam();
169 AliITSReconstructor *rec = new AliITSReconstructor();
170 rec->SetRecoParam(par);
172 AliCDBManager* man = AliCDBManager::Instance();
173 if (!man->IsDefaultStorageSet()){
174 HLTError("Default CDB storage has not been set !");
178 if(AliGeomManager::GetGeometry()==NULL){
179 AliGeomManager::LoadGeometry();
181 //fgeomInit = new AliITSInitGeometry(kvSPD02,2);
182 fgeomInit = new AliITSInitGeometry(kvPPRasymmFMD,2);
183 //fgeomInit->InitAliITSgeom(fgeom);
184 fgeom = fgeomInit->CreateAliITSgeom();
186 fNModules = fgeom->GetIndexMax();
188 fClusters = new TClonesArray*[fNModules];
189 for (Int_t iModule = 0; iModule < fNModules; iModule++) {
190 fClusters[iModule] = NULL;
194 fDettype = new AliITSDetTypeRec();
195 fDettype->SetITSgeom(fgeom);
196 fDettype->SetDefaultClusterFindersV2(kTRUE);
197 fDettype->SetDefaults();
202 fRawReader = new AliRawReaderMemory();
207 Int_t AliHLTITSClusterFinderComponent::DoDeinit() {
208 // see header file for class documentation
222 for (Int_t iModule = 0; iModule < fNModules; iModule++) {
223 if(fClusters[iModule] != NULL){
224 fClusters[iModule]->Delete();
225 delete fClusters[iModule];
227 fClusters[iModule] = NULL;
233 Int_t AliHLTITSClusterFinderComponent::DoEvent( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& /*trigData*/)
234 { // see header file for class documentation
236 // -- Iterator over Data Blocks --
237 const AliHLTComponentBlockData* iter = NULL;
239 if (!IsDataEvent()) return 0;
241 if ( evtData.fBlockCnt<=0 )
243 HLTDebug("no blocks in event" );
246 AliHLTComponentDataType datatype;
247 if(fModeSwitch==kClusterFinderSPD) { datatype = kAliHLTDataTypeDDLRaw | kAliHLTDataOriginITSSPD;}
248 else if(fModeSwitch==kClusterFinderSDD) {datatype = kAliHLTDataTypeDDLRaw | kAliHLTDataOriginITSSDD;}
249 else if(fModeSwitch==kClusterFinderSSD) {datatype = kAliHLTDataTypeDDLRaw | kAliHLTDataOriginITSSSD;}
251 // -- Loop over blocks
252 for ( iter = GetFirstInputBlock(datatype); iter != NULL; iter = GetNextInputBlock() ) {
254 // -- Debug output of datatype --
255 HLTDebug("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
256 evtData.fEventID, evtData.fEventID,
257 DataType2Text(iter->fDataType).c_str(),
258 DataType2Text(datatype).c_str());
260 // -- Check for the correct data type
261 if ( iter->fDataType != (datatype) )
264 // -- Get equipment ID out of specification
265 AliHLTUInt32_t spec = iter->fSpecification;
268 for ( Int_t ii = 0; ii < fNddl ; ii++ ) { //number of ddl's
269 if ( spec & 0x00000001 ) {
276 // -- Set equipment ID to the raw reader
278 if(!fRawReader->AddBuffer((UChar_t*) iter->fPtr, iter->fSize, id)){
279 HLTWarning("Could not add buffer");
282 if(fModeSwitch==kClusterFinderSPD) {fDettype->DigitsToRecPoints(fRawReader,fClusters,"SPD");}
283 else if(fModeSwitch==kClusterFinderSDD) {fDettype->DigitsToRecPoints(fRawReader,fClusters,"SDD");}
284 else if(fModeSwitch==kClusterFinderSSD) {fDettype->DigitsToRecPoints(fRawReader,fClusters,"SSD");}
287 for(int i=0;i<fNModules;i++){
288 if(fClusters[i] != NULL){
289 nClusters += fClusters[i]->GetEntries();
293 UInt_t bufferSize = nClusters * sizeof(AliHLTITSSpacePointData) + sizeof(AliHLTITSClusterData);
294 AliHLTUInt8_t *buffer = new AliHLTUInt8_t[bufferSize];
295 AliHLTITSClusterData *outputClusters = reinterpret_cast<AliHLTITSClusterData*>(buffer);
296 outputClusters->fSpacePointCnt=nClusters;
299 for(int i=0;i<fNModules;i++){
300 if(fClusters[i] != NULL){
301 for(int j=0;j<fClusters[i]->GetEntries();j++){
302 AliITSRecPoint *recpoint = (AliITSRecPoint*) fClusters[i]->At(j);
303 outputClusters->fSpacePoints[clustIdx].fY=recpoint->GetY();
304 outputClusters->fSpacePoints[clustIdx].fZ=recpoint->GetZ();
305 outputClusters->fSpacePoints[clustIdx].fSigmaY2=recpoint->GetSigmaY2();
306 outputClusters->fSpacePoints[clustIdx].fSigmaZ2=recpoint->GetSigmaZ2();
307 outputClusters->fSpacePoints[clustIdx].fSigmaYZ=recpoint->GetSigmaYZ();
308 outputClusters->fSpacePoints[clustIdx].fQ=recpoint->GetQ();
309 outputClusters->fSpacePoints[clustIdx].fNy=recpoint->GetNy();
310 outputClusters->fSpacePoints[clustIdx].fNz=recpoint->GetNz();
311 outputClusters->fSpacePoints[clustIdx].fLayer=recpoint->GetLayer();
312 outputClusters->fSpacePoints[clustIdx].fIndex=recpoint->GetDetectorIndex() | recpoint->GetPindex() | recpoint->GetNindex();
313 outputClusters->fSpacePoints[clustIdx].fTracks[0]=recpoint->GetLabel(0);
314 outputClusters->fSpacePoints[clustIdx].fTracks[1]=recpoint->GetLabel(1);
315 outputClusters->fSpacePoints[clustIdx].fTracks[2]=recpoint->GetLabel(2);
322 if(fModeSwitch==kClusterFinderSPD) {PushBack(buffer,bufferSize,kAliHLTDataTypeClusters|kAliHLTDataOriginITSSPD,iter->fSpecification);}
323 else if(fModeSwitch==kClusterFinderSDD) {PushBack(buffer,bufferSize,kAliHLTDataTypeClusters|kAliHLTDataOriginITSSDD,iter->fSpecification);}
324 else if(fModeSwitch==kClusterFinderSSD) {PushBack(buffer,bufferSize,kAliHLTDataTypeClusters|kAliHLTDataOriginITSSSD,iter->fSpecification);}
327 fRawReader->ClearBuffers();
329 for (Int_t iModule = 0; iModule < fNModules; iModule++) {
330 if(fClusters[iModule] != NULL){
331 fClusters[iModule]->Delete();
332 delete fClusters[iModule];
334 fClusters[iModule] = NULL;
337 } // for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) {
342 int AliHLTITSClusterFinderComponent::Configure(const char* arguments)
347 if (!arguments) return iResult;
349 TString allArgs=arguments;
352 TObjArray* pTokens=allArgs.Tokenize(" ");
355 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
356 argument=((TObjString*)pTokens->At(i))->GetString();
357 if (argument.IsNull()) continue;
359 if (argument.CompareTo("")==0) {
364 else if (argument.CompareTo("")==0) {
370 HLTError("unknown argument %s", argument.Data());
381 int AliHLTITSClusterFinderComponent::Reconfigure(const char* cdbEntry, const char* chainId)
383 // see header file for class documentation
386 const char* path="HLT/ConfigITS/ClusterFinderComponent";
387 const char* defaultNotify="";
390 defaultNotify=" (default)";
393 HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
394 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path);
396 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
398 HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
399 iResult=Configure(pString->GetString().Data());
401 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
404 HLTError("can not fetch object \"%s\" from CDB", path);