1 /**************************************************************************
2 * This file is property of and copyright by the ALICE HLT Project *
3 * ALICE Experiment at CERN, All rights reserved. *
4 * Permission to use, copy, modify and distribute this software and its *
5 * documentation strictly for non-commercial purposes is hereby granted *
6 * without fee, provided that the above copyright notice appears in all *
7 * copies and that both the copyright notice and this permission notice *
8 * appear in the supporting documentation. The authors make no claims *
9 * about the suitability of this software for any purpose. It is *
10 * provided "as is" without express or implied warranty. *
11 **************************************************************************/
12 //-----------------------------------------------------------------------------
13 /// \class AliHLTMUONFullTrackerComponent
15 /// Component class for full tracker, see the detail description
16 /// of the full tracker in the full tracker header file
17 /// \author :Indranil Das, email : indra.das@saha.ac.in | indra.ehep@gmail.com , Saha Institute of Nuclear Physics
18 //-----------------------------------------------------------------------------
20 #include "AliHLTMUONFullTrackerComponent.h"
22 #include "TObjString.h"
23 #include "TObjArray.h"
24 #include "AliCDBEntry.h"
25 #include "AliCDBManager.h"
27 #include "AliHLTDefinitions.h"
29 #include "AliHLTMUONConstants.h"
31 #include "AliHLTMUONTracksBlockStruct.h"
35 ClassImp(AliHLTMUONFullTrackerComponent)
37 AliHLTMUONFullTrackerComponent::AliHLTMUONFullTrackerComponent() :
38 AliHLTMUONProcessor(),
41 // see header file for class documentation
45 AliHLTMUONFullTrackerComponent::~AliHLTMUONFullTrackerComponent()
47 // see header file for class documentation
49 if (fTracker != NULL) delete fTracker;
52 const char* AliHLTMUONFullTrackerComponent::GetComponentID()
54 // see header file for class documentation
55 return AliHLTMUONConstants::FullTrackerId();
58 void AliHLTMUONFullTrackerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
60 // see header file for class documentation
61 /* in order to be backward compatible we have to keep the old code, at
62 * least for a while. Remember to use the new const kAliHLTVoidDataType
63 * if you are using a more recent AliRoot version (from Jan 07)
64 list.push_back(kAliHLTAnyDataType); // We do not have any requirements for our input data type(s).
67 assert( list.empty() );
68 list.push_back( AliHLTMUONConstants::TriggerRecordsBlockDataType() );
69 list.push_back( AliHLTMUONConstants::RecHitsBlockDataType() );
73 AliHLTComponentDataType AliHLTMUONFullTrackerComponent::GetOutputDataType()
75 // see header file for class documentation
76 /* in order to be backward compatible we have to keep the old code, at
77 * least for a while. Remember to use the new const kAliHLTVoidDataType
78 * if you are using a more recent AliRoot version (from Jan 07)
79 return kAliHLTVoidDataType;
81 return kAliHLTMultipleDataType;
85 int AliHLTMUONFullTrackerComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& list)
87 /// Inherited from AliHLTComponent. Returns the output data types.
89 assert( list.empty() );
90 list.push_back( AliHLTMUONConstants::TracksBlockDataType() );
94 void AliHLTMUONFullTrackerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
96 // see header file for class documentation
97 constBase = sizeof(AliHLTMUONTracksBlockStruct) + 1024*1024;
104 // Spawn function, return new instance of this class
105 AliHLTComponent* AliHLTMUONFullTrackerComponent::Spawn()
107 // see header file for class documentation
108 return new AliHLTMUONFullTrackerComponent;
111 int AliHLTMUONFullTrackerComponent::DoInit( int argc, const char** argv )
113 // perform initialization
114 bool useFast = false;
115 int result = AliHLTMUONProcessor::DoInit(argc, argv);
116 if (result != 0) return result;
119 for (int i = 0; i < argc; i++){
121 // To keep the legacy behaviour we need to have the following check
122 // for -cdbpath here, before ArgumentAlreadyHandled.
123 if (ArgumentAlreadyHandled(i, argv[i])) continue;
125 if (strcmp(argv[i], "-usefast") == 0)
133 if (fTracker == NULL)
137 fTracker = new AliHLTMUONFullTracker;
139 catch (const std::bad_alloc&)
141 HLTError("Could not allocate a new AliHLTMUONFullTracker object. Ran out of memory.");
146 result = FetchMappingStores();
148 fTracker->FastTracking(useFast);
153 int AliHLTMUONFullTrackerComponent::DoDeinit()
155 // see header file for class documentation
157 if (fTracker != NULL)
166 int AliHLTMUONFullTrackerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
167 AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
168 AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
171 unsigned long totalSize = 0;
172 AliHLTUInt32_t specification = 0; // Contains the output data block spec bits.
173 bool resultOk = true;
174 // Loop over all input blocks in the event
176 HLTDebug("Processing iEvent %llu with %u input data blocks.",
177 evtData.fEventID, evtData.fBlockCnt
180 if (! IsDataEvent()){
186 //if(evtData.fBlockCnt==3) return 0;
188 AliHLTMUONTracksBlockWriter block(outputPtr, size);
189 if (not block.InitCommonHeader())
191 Logging(kHLTLogError,
192 "AliHLTMUONFullTrackerComponent::DoEvent",
194 "The buffer is only %d bytes in size. We need a minimum of %d bytes.",
195 size, sizeof(AliHLTMUONTracksBlockWriter::HeaderType)
197 if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
198 size = 0; // Important to tell framework that nothing was generated.
204 for (AliHLTUInt32_t n = 0; n < evtData.fBlockCnt; n++){
206 HLTDebug("Handling block: %u, with fDataType = '%s', fPtr = %p and fSize = %u bytes.",
207 n, DataType2Text(blocks[n].fDataType).c_str(), blocks[n].fPtr, blocks[n].fSize
210 if (not resultOk) break;
212 if (blocks[n].fDataType == AliHLTMUONConstants::RecHitsBlockDataType()){
213 specification |= blocks[n].fSpecification;
215 AliHLTMUONRecHitsBlockReader inblock(blocks[n].fPtr, blocks[n].fSize);
216 if (not BlockStructureOk(inblock)){
217 if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
222 resultOk = fTracker->SetInput(AliHLTMUONUtils::SpecToDDLNumber(blocks[n].fSpecification),
223 inblock.GetArray(), inblock.Nentries());
227 }else if (blocks[n].fDataType == AliHLTMUONConstants::TriggerRecordsBlockDataType()){
228 specification |= blocks[n].fSpecification;
229 AliHLTMUONTriggerRecordsBlockReader inblock(blocks[n].fPtr, blocks[n].fSize);
230 if (not BlockStructureOk(inblock)){
231 if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
236 resultOk = fTracker->SetInput(AliHLTMUONUtils::SpecToDDLNumber(blocks[n].fSpecification),
237 inblock.GetArray(),inblock.Nentries());
240 }//check if trigger block
241 }//loop over blocks array of rechit and trigrecs
243 AliHLTUInt32_t nofTracks = 0;
244 AliHLTUInt32_t emptyTrackBlockSize = block.BytesUsed();
246 nofTracks = block.MaxNumberOfEntries();
247 resultOk = fTracker->Run(evtData.fEventID,block.GetArray(), nofTracks);
251 assert( nofTracks <= block.MaxNumberOfEntries() );
252 block.SetNumberOfEntries(nofTracks);
254 HLTDebug("Number of reconstructed tracks found is %d, resultOk : %d, emptyTrackBlockSize : %d",
255 nofTracks,resultOk,emptyTrackBlockSize);
256 HLTDebug("sizeof %d", sizeof(AliHLTMUONTrackStruct));
257 HLTDebug("Bytes Used is %d",block.BytesUsed());
258 HLTDebug("Specification is %d", specification);
260 AliHLTComponentBlockData bd;
264 bd.fSize = block.BytesUsed();
265 bd.fDataType = AliHLTMUONConstants::TracksBlockDataType() ;
266 bd.fSpecification = specification;
268 outputBlocks.push_back(bd);
270 totalSize = block.BytesUsed();
274 HLTDebug("Error while processing the full tracker algorithm.");
275 if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
277 HLTDebug("Number of reconstructed tracks found is %d, resultOk : %d, emptyTrackBlockSize : %d",
278 nofTracks,resultOk,emptyTrackBlockSize);
279 HLTDebug("sizeof %d", sizeof(AliHLTMUONTrackStruct));
280 HLTDebug("Bytes Used is %d",block.BytesUsed());
281 HLTDebug("Specification is %d", specification);
283 AliHLTComponentBlockData bd;
287 bd.fSize = emptyTrackBlockSize;
288 bd.fDataType = AliHLTMUONConstants::TracksBlockDataType() ;
289 bd.fSpecification = specification;
291 outputBlocks.push_back(bd);
293 totalSize = emptyTrackBlockSize;
298 // Finally we set the total size of output memory we consumed.
299 size = totalSize; // Must tell the framework how much buffer space was used.
305 int AliHLTMUONFullTrackerComponent::Configure(const char* arguments)
307 // see header file for class documentation
309 if (!arguments) return iResult;
310 HLTInfo("parsing configuration string \'%s\'", arguments);
312 TString allArgs=arguments;
316 TObjArray* pTokens=allArgs.Tokenize(" ");
318 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
319 argument=((TObjString*)pTokens->At(i))->GetString();
320 if (argument.IsNull()) continue;
323 if (argument.CompareTo("-config1")==0) {
324 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
325 HLTInfo("got \'-config1\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
328 } else if (argument.CompareTo("-config2")==0) {
329 HLTInfo("got \'-config2\'");
331 HLTError("unknown argument %s", argument.Data());
339 HLTError("missing parameter for argument %s", argument.Data());
345 int AliHLTMUONFullTrackerComponent::Reconfigure(const char* cdbEntry, const char* chainId)
347 // see header file for class documentation
349 const char* path="HLT/ConfigSample/FullTrackerComponent";
350 const char* defaultNotify="";
353 defaultNotify=" (default)";
356 HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
357 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
359 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
361 HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
362 iResult=Configure(pString->GetString().Data());
364 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
367 HLTError("can not fetch object \"%s\" from CDB", path);
373 int AliHLTMUONFullTrackerComponent::ReadPreprocessorValues(const char* modules)
375 // see header file for class documentation
377 TString detectors(modules!=NULL?modules:"");
378 HLTInfo("read preprocessor values for detector(s): %s", detectors.IsNull()?"none":detectors.Data());