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 //-----------------------------------------------------------------------------
25 #include "AliHLTMUONFullTrackerComponent.h"
27 #include "TObjString.h"
28 #include "TObjArray.h"
29 #include "AliCDBEntry.h"
30 #include "AliCDBManager.h"
32 #include "AliHLTDefinitions.h"
34 #include "AliHLTMUONConstants.h"
36 #include "AliHLTMUONTracksBlockStruct.h"
38 ClassImp(AliHLTMUONFullTrackerComponent)
40 AliHLTMUONFullTrackerComponent::AliHLTMUONFullTrackerComponent() :
41 AliHLTMUONProcessor(),
44 // see header file for class documentation
48 AliHLTMUONFullTrackerComponent::~AliHLTMUONFullTrackerComponent()
50 // see header file for class documentation
52 if (fTracker != NULL) delete fTracker;
55 const char* AliHLTMUONFullTrackerComponent::GetComponentID()
57 // see header file for class documentation
58 return AliHLTMUONConstants::FullTrackerId();
61 void AliHLTMUONFullTrackerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
63 // see header file for class documentation
64 /* in order to be backward compatible we have to keep the old code, at
65 * least for a while. Remember to use the new const kAliHLTVoidDataType
66 * if you are using a more recent AliRoot version (from Jan 07)
67 list.push_back(kAliHLTAnyDataType); // We do not have any requirements for our input data type(s).
70 assert( list.empty() );
71 list.push_back( AliHLTMUONConstants::TriggerRecordsBlockDataType() );
72 list.push_back( AliHLTMUONConstants::RecHitsBlockDataType() );
76 AliHLTComponentDataType AliHLTMUONFullTrackerComponent::GetOutputDataType()
78 // see header file for class documentation
79 /* in order to be backward compatible we have to keep the old code, at
80 * least for a while. Remember to use the new const kAliHLTVoidDataType
81 * if you are using a more recent AliRoot version (from Jan 07)
82 return kAliHLTVoidDataType;
84 return kAliHLTMultipleDataType;
88 int AliHLTMUONFullTrackerComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& list)
90 /// Inherited from AliHLTComponent. Returns the output data types.
92 assert( list.empty() );
93 list.push_back( AliHLTMUONConstants::TracksBlockDataType() );
97 void AliHLTMUONFullTrackerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
99 // see header file for class documentation
100 constBase = sizeof(AliHLTMUONTracksBlockStruct) + 1024*1024;
107 // Spawn function, return new instance of this class
108 AliHLTComponent* AliHLTMUONFullTrackerComponent::Spawn()
110 // see header file for class documentation
111 return new AliHLTMUONFullTrackerComponent;
114 int AliHLTMUONFullTrackerComponent::DoInit( int argc, const char** argv )
116 // perform initialization
117 bool useFast = false;
118 int result = AliHLTMUONProcessor::DoInit(argc, argv);
119 if (result != 0) return result;
122 for (int i = 0; i < argc; i++){
124 // To keep the legacy behaviour we need to have the following check
125 // for -cdbpath here, before ArgumentAlreadyHandled.
126 if (ArgumentAlreadyHandled(i, argv[i])) continue;
128 if (strcmp(argv[i], "-usefast") == 0)
136 if (fTracker == NULL)
140 fTracker = new AliHLTMUONFullTracker;
142 catch (const std::bad_alloc&)
144 HLTError("Could not allocate a new AliHLTMUONFullTracker object. Ran out of memory.");
149 result = FetchMappingStores();
151 fTracker->FastTracking(useFast);
156 int AliHLTMUONFullTrackerComponent::DoDeinit()
158 // see header file for class documentation
160 if (fTracker != NULL)
169 int AliHLTMUONFullTrackerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
170 AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
171 AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
174 unsigned long totalSize = 0;
175 AliHLTUInt32_t specification = 0; // Contains the output data block spec bits.
176 bool resultOk = true;
177 // Loop over all input blocks in the event
179 HLTDebug("Processing iEvent %llu with %u input data blocks.",
180 evtData.fEventID, evtData.fBlockCnt
183 if (! IsDataEvent()){
189 //if(evtData.fBlockCnt==3) return 0;
191 AliHLTMUONTracksBlockWriter block(outputPtr, size);
192 if (not block.InitCommonHeader())
194 Logging(kHLTLogError,
195 "AliHLTMUONFullTrackerComponent::DoEvent",
197 "The buffer is only %d bytes in size. We need a minimum of %d bytes.",
198 size, sizeof(AliHLTMUONTracksBlockWriter::HeaderType)
200 if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
201 size = 0; // Important to tell framework that nothing was generated.
207 for (AliHLTUInt32_t n = 0; n < evtData.fBlockCnt; n++){
209 HLTDebug("Handling block: %u, with fDataType = '%s', fPtr = %p and fSize = %u bytes.",
210 n, DataType2Text(blocks[n].fDataType).c_str(), blocks[n].fPtr, blocks[n].fSize
213 if (not resultOk) break;
215 if (blocks[n].fDataType == AliHLTMUONConstants::RecHitsBlockDataType()){
216 specification |= blocks[n].fSpecification;
218 AliHLTMUONRecHitsBlockReader inblock(blocks[n].fPtr, blocks[n].fSize);
219 if (not BlockStructureOk(inblock)){
220 if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
225 resultOk = fTracker->SetInput(AliHLTMUONUtils::SpecToDDLNumber(blocks[n].fSpecification),
226 inblock.GetArray(), inblock.Nentries());
230 }else if (blocks[n].fDataType == AliHLTMUONConstants::TriggerRecordsBlockDataType()){
231 specification |= blocks[n].fSpecification;
232 AliHLTMUONTriggerRecordsBlockReader inblock(blocks[n].fPtr, blocks[n].fSize);
233 if (not BlockStructureOk(inblock)){
234 if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
239 resultOk = fTracker->SetInput(AliHLTMUONUtils::SpecToDDLNumber(blocks[n].fSpecification),
240 inblock.GetArray(),inblock.Nentries());
243 }//check if trigger block
244 }//loop over blocks array of rechit and trigrecs
246 AliHLTUInt32_t nofTracks = 0;
247 AliHLTUInt32_t emptyTrackBlockSize = block.BytesUsed();
249 nofTracks = block.MaxNumberOfEntries();
250 resultOk = fTracker->Run(evtData.fEventID,block.GetArray(), nofTracks);
254 assert( nofTracks <= block.MaxNumberOfEntries() );
255 block.SetNumberOfEntries(nofTracks);
257 HLTDebug("Number of reconstructed tracks found is %d, resultOk : %d, emptyTrackBlockSize : %d",
258 nofTracks,resultOk,emptyTrackBlockSize);
259 HLTDebug("sizeof %d", sizeof(AliHLTMUONTrackStruct));
260 HLTDebug("Bytes Used is %d",block.BytesUsed());
261 HLTDebug("Specification is %d", specification);
263 AliHLTComponentBlockData bd;
267 bd.fSize = block.BytesUsed();
268 bd.fDataType = AliHLTMUONConstants::TracksBlockDataType() ;
269 bd.fSpecification = specification;
271 outputBlocks.push_back(bd);
273 totalSize = block.BytesUsed();
277 HLTDebug("Error while processing the full tracker algorithm.");
278 if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
280 HLTDebug("Number of reconstructed tracks found is %d, resultOk : %d, emptyTrackBlockSize : %d",
281 nofTracks,resultOk,emptyTrackBlockSize);
282 HLTDebug("sizeof %d", sizeof(AliHLTMUONTrackStruct));
283 HLTDebug("Bytes Used is %d",block.BytesUsed());
284 HLTDebug("Specification is %d", specification);
286 AliHLTComponentBlockData bd;
290 bd.fSize = emptyTrackBlockSize;
291 bd.fDataType = AliHLTMUONConstants::TracksBlockDataType() ;
292 bd.fSpecification = specification;
294 outputBlocks.push_back(bd);
296 totalSize = emptyTrackBlockSize;
301 // Finally we set the total size of output memory we consumed.
302 size = totalSize; // Must tell the framework how much buffer space was used.
308 int AliHLTMUONFullTrackerComponent::Configure(const char* arguments)
310 // see header file for class documentation
312 if (!arguments) return iResult;
313 HLTInfo("parsing configuration string \'%s\'", arguments);
315 TString allArgs=arguments;
319 TObjArray* pTokens=allArgs.Tokenize(" ");
321 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
322 argument=((TObjString*)pTokens->At(i))->GetString();
323 if (argument.IsNull()) continue;
326 if (argument.CompareTo("-config1")==0) {
327 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
328 HLTInfo("got \'-config1\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
331 } else if (argument.CompareTo("-config2")==0) {
332 HLTInfo("got \'-config2\'");
334 HLTError("unknown argument %s", argument.Data());
342 HLTError("missing parameter for argument %s", argument.Data());
348 int AliHLTMUONFullTrackerComponent::Reconfigure(const char* cdbEntry, const char* chainId)
350 // see header file for class documentation
352 const char* path="HLT/ConfigSample/FullTrackerComponent";
353 const char* defaultNotify="";
356 defaultNotify=" (default)";
359 HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
360 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
362 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
364 HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
365 iResult=Configure(pString->GetString().Data());
367 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
370 HLTError("can not fetch object \"%s\" from CDB", path);
376 int AliHLTMUONFullTrackerComponent::ReadPreprocessorValues(const char* modules)
378 // see header file for class documentation
380 TString detectors(modules!=NULL?modules:"");
381 HLTInfo("read preprocessor values for detector(s): %s", detectors.IsNull()?"none":detectors.Data());