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 "AliHLTMUONMansoTracksBlockStruct.h"
38 ClassImp(AliHLTMUONFullTrackerComponent)
40 AliHLTMUONFullTrackerComponent::AliHLTMUONFullTrackerComponent() :
41 fOutputPercentage(100),
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::MansoTracksBlockDataType() );
94 //list.push_back( AliHLTMUONConstants::MansoCandidatesBlockDataType() );
98 void AliHLTMUONFullTrackerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
100 // see header file for class documentation
101 constBase = sizeof(AliHLTMUONMansoTracksBlockStruct) + 1024*1024;
108 // Spawn function, return new instance of this class
109 AliHLTComponent* AliHLTMUONFullTrackerComponent::Spawn()
111 // see header file for class documentation
112 return new AliHLTMUONFullTrackerComponent;
115 int AliHLTMUONFullTrackerComponent::DoInit( int argc, const char** argv )
117 // perform dummy initialization, will be properly implemented later
118 fOutputPercentage = 100;
123 HLTDebug("argv[%d] == %s", i, argv[i] );
124 if ( !strcmp( argv[i], "output_percentage" ) ||
125 !strcmp( argv[i], "-output_percentage" ))
129 HLTError("Missing output_percentage parameter");
132 HLTDebug("argv[%d+1] == %s", i, argv[i+1] );
133 fOutputPercentage = strtoul( argv[i+1], &cpErr, 0 );
136 HLTError("Cannot convert output_percentage parameter '%s'", argv[i+1] );
139 HLTInfo("Output percentage set to %lu %%", fOutputPercentage );
143 HLTError("Unknown option '%s'", argv[i] );
147 if (fTracker == NULL)
151 fTracker = new AliHLTMUONFullTracker;
153 catch (const std::bad_alloc&)
155 HLTError("Could not allocate a new AliHLTMUONFullTracker object. Ran out of memory.");
164 int AliHLTMUONFullTrackerComponent::DoDeinit()
166 // see header file for class documentation
168 if (fTracker != NULL)
177 int AliHLTMUONFullTrackerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
178 AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
179 AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
181 // see header file for class documentation
182 HLTDebug("Output percentage set to %lu %%", fOutputPercentage );
184 unsigned long totalSize = 0;
185 AliHLTUInt32_t specification = 0; // Contains the output data block spec bits.
186 // Loop over all input blocks in the event
188 HLTDebug("Processing event %llu with %u input data blocks.",
189 evtData.fEventID, evtData.fBlockCnt
192 if(evtData.fBlockCnt==3) return 0;
194 AliHLTMUONMansoTracksBlockWriter block(outputPtr, size);
196 if (not block.InitCommonHeader())
198 Logging(kHLTLogError,
199 "AliHLTMUONMansoTrackerFSMComponent::DoEvent",
201 "The buffer is only %d bytes in size. We need a minimum of %d bytes.",
202 size, sizeof(AliHLTMUONMansoTracksBlockWriter::HeaderType)
204 if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
205 size = 0; // Important to tell framework that nothing was generated.
209 for (AliHLTUInt32_t n = 0; n < evtData.fBlockCnt; n++){
210 HLTDebug("Handling block: %u, with fDataType = '%s', fPtr = %p and fSize = %u bytes.",
211 n, DataType2Text(blocks[n].fDataType).c_str(), blocks[n].fPtr, blocks[n].fSize
214 if (blocks[n].fDataType == AliHLTMUONConstants::RecHitsBlockDataType()){
215 specification |= blocks[n].fSpecification;
217 AliHLTMUONRecHitsBlockReader inblock(blocks[n].fPtr, blocks[n].fSize);
218 if (not BlockStructureOk(inblock)){
219 if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
223 if (inblock.Nentries() != 0)
224 fTracker->SetInput(AliHLTMUONUtils::SpecToDDLNumber(blocks[n].fSpecification), inblock.GetArray(), inblock.Nentries());
227 Logging(kHLTLogDebug,
228 "AliHLTMUONMansoTrackerFSMComponent::DoEvent",
230 "Received a reconstructed hits data block which contains no entries."
233 }else if (blocks[n].fDataType == AliHLTMUONConstants::TriggerRecordsBlockDataType()){
234 specification |= blocks[n].fSpecification;
236 AliHLTMUONTriggerRecordsBlockReader inblock(blocks[n].fPtr, blocks[n].fSize);
237 if (not BlockStructureOk(inblock)){
238 if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
242 if (inblock.Nentries() != 0)
243 fTracker->SetInput(AliHLTMUONUtils::SpecToDDLNumber(blocks[n].fSpecification), inblock.GetArray(), inblock.Nentries());
246 Logging(kHLTLogDebug,
247 "AliHLTMUONMansoTrackerFSMComponent::DoEvent",
249 "Received a reconstructed hits data block which contains no entries."
253 }//check if trigger block
256 }//loop over blocks array of rechit and trigrecs
258 AliHLTUInt32_t nofTracks = block.MaxNumberOfEntries();
261 if (evtData.fBlockCnt!=3)
262 if (not fTracker->Run(int(evtData.fEventID),block.GetArray(), nofTracks))
264 HLTError("Error while processing the full tracker algorithm.");
265 if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
266 size = totalSize; // Must tell the framework how much buffer space was used.
270 // nofTracks should now contain the number of reconstructed hits actually found
271 // and filled into the output data block, so we can set this number.
272 assert( nofTracks <= block.MaxNumberOfEntries() );
273 block.SetNumberOfEntries(nofTracks);
275 HLTDebug("Number of reconstructed tracks found is %d\n", nofTracks);
276 HLTDebug("sizeof %d\n", sizeof(AliHLTMUONMansoTrackStruct));
277 HLTDebug("Bytes Used is %d\n",block.BytesUsed());
278 HLTDebug("specification is %d\n", specification);
280 AliHLTComponentBlockData bd;
284 bd.fSize = block.BytesUsed();
285 bd.fDataType = AliHLTMUONConstants::MansoTracksBlockDataType();
286 bd.fSpecification = specification;
287 outputBlocks.push_back(bd);
288 totalSize = block.BytesUsed();
290 // Finally we set the total size of output memory we consumed.
297 int AliHLTMUONFullTrackerComponent::Configure(const char* arguments)
299 // see header file for class documentation
301 if (!arguments) return iResult;
302 HLTInfo("parsing configuration string \'%s\'", arguments);
304 TString allArgs=arguments;
308 TObjArray* pTokens=allArgs.Tokenize(" ");
310 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
311 argument=((TObjString*)pTokens->At(i))->GetString();
312 if (argument.IsNull()) continue;
315 if (argument.CompareTo("-config1")==0) {
316 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
317 HLTInfo("got \'-config1\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
320 } else if (argument.CompareTo("-config2")==0) {
321 HLTInfo("got \'-config2\'");
323 HLTError("unknown argument %s", argument.Data());
331 HLTError("missing parameter for argument %s", argument.Data());
337 int AliHLTMUONFullTrackerComponent::Reconfigure(const char* cdbEntry, const char* chainId)
339 // see header file for class documentation
341 const char* path="HLT/ConfigSample/FullTrackerComponent";
342 const char* defaultNotify="";
345 defaultNotify=" (default)";
348 HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
349 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
351 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
353 HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
354 iResult=Configure(pString->GetString().Data());
356 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
359 HLTError("can not fetch object \"%s\" from CDB", path);
365 int AliHLTMUONFullTrackerComponent::ReadPreprocessorValues(const char* modules)
367 // see header file for class documentation
369 TString detectors(modules!=NULL?modules:"");
370 HLTInfo("read preprocessor values for detector(s): %s", detectors.IsNull()?"none":detectors.Data());