]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/MUON/OnlineAnalysis/AliHLTMUONFullTrackerComponent.cxx
AliTPCcalibDButil.h: Undo changes for forward declaraiton, to make depending code...
[u/mrichter/AliRoot.git] / HLT / MUON / OnlineAnalysis / AliHLTMUONFullTrackerComponent.cxx
CommitLineData
52c6d8aa 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
14///
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//-----------------------------------------------------------------------------
19
20
21#if __GNUC__== 3
22using namespace std;
23#endif
24
25#include "AliHLTMUONFullTrackerComponent.h"
26#include "TString.h"
27#include "TObjString.h"
28#include "TObjArray.h"
29#include "AliCDBEntry.h"
30#include "AliCDBManager.h"
31
32#include "AliHLTDefinitions.h"
33
34#include "AliHLTMUONConstants.h"
35
d24a4636 36#include "AliHLTMUONTracksBlockStruct.h"
52c6d8aa 37
38ClassImp(AliHLTMUONFullTrackerComponent)
39
40AliHLTMUONFullTrackerComponent::AliHLTMUONFullTrackerComponent() :
fd5b812e 41 AliHLTMUONProcessor(),
52c6d8aa 42 fTracker(NULL)
43{
44 // see header file for class documentation
45
46}
47
48AliHLTMUONFullTrackerComponent::~AliHLTMUONFullTrackerComponent()
49{
50 // see header file for class documentation
51
52 if (fTracker != NULL) delete fTracker;
53}
54
55const char* AliHLTMUONFullTrackerComponent::GetComponentID()
56{
57 // see header file for class documentation
58 return AliHLTMUONConstants::FullTrackerId();
59}
60
61void AliHLTMUONFullTrackerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
62{
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).
68 */
69
70 assert( list.empty() );
71 list.push_back( AliHLTMUONConstants::TriggerRecordsBlockDataType() );
72 list.push_back( AliHLTMUONConstants::RecHitsBlockDataType() );
73
74}
75
76AliHLTComponentDataType AliHLTMUONFullTrackerComponent::GetOutputDataType()
77{
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;
83 */
84 return kAliHLTMultipleDataType;
85
86}
87
88int AliHLTMUONFullTrackerComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& list)
89{
90 /// Inherited from AliHLTComponent. Returns the output data types.
91
92 assert( list.empty() );
d24a4636 93 list.push_back( AliHLTMUONConstants::TracksBlockDataType() );
52c6d8aa 94 return list.size();
95}
96
97void AliHLTMUONFullTrackerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
98{
99 // see header file for class documentation
d24a4636 100 constBase = sizeof(AliHLTMUONTracksBlockStruct) + 1024*1024;
52c6d8aa 101 inputMultiplier = 1;
102
103}
104
105
106
107// Spawn function, return new instance of this class
108AliHLTComponent* AliHLTMUONFullTrackerComponent::Spawn()
109{
110 // see header file for class documentation
111 return new AliHLTMUONFullTrackerComponent;
112}
113
114int AliHLTMUONFullTrackerComponent::DoInit( int argc, const char** argv )
115{
aa205fc6 116 // perform initialization
117 bool useFast = false;
fd5b812e 118 int result = AliHLTMUONProcessor::DoInit(argc, argv);
119 if (result != 0) return result;
120
121
122 for (int i = 0; i < argc; i++){
123
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;
d24a4636 127
aa205fc6 128 if (strcmp(argv[i], "-usefast") == 0)
129 {
130 useFast = true;
131 }
132
fd5b812e 133 }
134
52c6d8aa 135
136 if (fTracker == NULL)
137 {
138 try
139 {
140 fTracker = new AliHLTMUONFullTracker;
141 }
142 catch (const std::bad_alloc&)
143 {
144 HLTError("Could not allocate a new AliHLTMUONFullTracker object. Ran out of memory.");
145 return -ENOMEM;
146 }
147 }
148
fd5b812e 149 result = FetchMappingStores();
52c6d8aa 150 fTracker->Init();
aa205fc6 151 fTracker->FastTracking(useFast);
fd5b812e 152
52c6d8aa 153 return 0;
154}
155
156int AliHLTMUONFullTrackerComponent::DoDeinit()
157{
158 // see header file for class documentation
159
160 if (fTracker != NULL)
161 {
162 delete fTracker;
163 fTracker = NULL;
164 }
165
166 return 0;
167}
168
169int AliHLTMUONFullTrackerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
170 AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
171 AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
172{
52c6d8aa 173 // Process an event
174 unsigned long totalSize = 0;
175 AliHLTUInt32_t specification = 0; // Contains the output data block spec bits.
a038ee7d 176 bool resultOk = true;
52c6d8aa 177 // Loop over all input blocks in the event
178
179 HLTDebug("Processing event %llu with %u input data blocks.",
180 evtData.fEventID, evtData.fBlockCnt
181 );
182
fd5b812e 183 //if(evtData.fBlockCnt==3) return 0;
52c6d8aa 184
d24a4636 185 AliHLTMUONTracksBlockWriter block(outputPtr, size);
186 if (not block.InitCommonHeader())
52c6d8aa 187 {
188 Logging(kHLTLogError,
d24a4636 189 "AliHLTMUONFullTrackerComponent::DoEvent",
52c6d8aa 190 "Buffer overflow",
191 "The buffer is only %d bytes in size. We need a minimum of %d bytes.",
d24a4636 192 size, sizeof(AliHLTMUONTracksBlockWriter::HeaderType)
52c6d8aa 193 );
194 if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
195 size = 0; // Important to tell framework that nothing was generated.
a038ee7d 196 resultOk = false;
52c6d8aa 197 return -ENOBUFS;
198 }
d24a4636 199
52c6d8aa 200
201 for (AliHLTUInt32_t n = 0; n < evtData.fBlockCnt; n++){
fd5b812e 202
203 //if(evtData.fBlockCnt==3) continue;
204
52c6d8aa 205 HLTDebug("Handling block: %u, with fDataType = '%s', fPtr = %p and fSize = %u bytes.",
fd5b812e 206 n, DataType2Text(blocks[n].fDataType).c_str(), blocks[n].fPtr, blocks[n].fSize
207 );
208
52c6d8aa 209 if (blocks[n].fDataType == AliHLTMUONConstants::RecHitsBlockDataType()){
210 specification |= blocks[n].fSpecification;
211
212 AliHLTMUONRecHitsBlockReader inblock(blocks[n].fPtr, blocks[n].fSize);
213 if (not BlockStructureOk(inblock)){
fd5b812e 214 if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
a038ee7d 215 resultOk = false;
fd5b812e 216 continue;
52c6d8aa 217 }
fd5b812e 218
219 fTracker->SetInput(AliHLTMUONUtils::SpecToDDLNumber(blocks[n].fSpecification), inblock.GetArray(), inblock.Nentries());
220
221
52c6d8aa 222 }else if (blocks[n].fDataType == AliHLTMUONConstants::TriggerRecordsBlockDataType()){
223 specification |= blocks[n].fSpecification;
52c6d8aa 224 AliHLTMUONTriggerRecordsBlockReader inblock(blocks[n].fPtr, blocks[n].fSize);
225 if (not BlockStructureOk(inblock)){
fd5b812e 226 if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
a038ee7d 227 resultOk = false;
fd5b812e 228 continue;
52c6d8aa 229 }
230
fd5b812e 231 fTracker->SetInput(AliHLTMUONUtils::SpecToDDLNumber(blocks[n].fSpecification), inblock.GetArray(),inblock.Nentries());
52c6d8aa 232 }//check if trigger block
52c6d8aa 233 }//loop over blocks array of rechit and trigrecs
a038ee7d 234
235 AliHLTUInt32_t nofTracks = 0;
236 if( resultOk ){
52c6d8aa 237
a038ee7d 238 nofTracks = block.MaxNumberOfEntries();
239 // if (evtData.fBlockCnt!=3){
240 resultOk = fTracker->Run(int(evtData.fEventID),block.GetArray(), nofTracks);
241 }
242
fd5b812e 243 if (resultOk){
244 assert( nofTracks <= block.MaxNumberOfEntries() );
245 block.SetNumberOfEntries(nofTracks);
52c6d8aa 246
fd5b812e 247 HLTDebug("Number of reconstructed tracks found is %d\n", nofTracks);
248 HLTDebug("sizeof %d\n", sizeof(AliHLTMUONMansoTrackStruct));
249 HLTDebug("Bytes Used is %d\n",block.BytesUsed());
250 HLTDebug("specification is %d\n", specification);
251
252 AliHLTComponentBlockData bd;
253 FillBlockData(bd);
254 bd.fPtr = outputPtr;
255 bd.fOffset = 0;
256 bd.fSize = block.BytesUsed();
d24a4636 257 bd.fDataType = AliHLTMUONConstants::TracksBlockDataType() ;
258
fd5b812e 259 bd.fSpecification = specification;
260 outputBlocks.push_back(bd);
261 totalSize = block.BytesUsed();
262 }else{
263 HLTDebug("Error while processing the full tracker algorithm.");
264 if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
265 size = totalSize; // Must tell the framework how much buffer space was used.
266 //return -EIO;
267 return 0;
268 }
52c6d8aa 269
270 // Finally we set the total size of output memory we consumed.
271 size = totalSize;
272 return 0;
273
274}
275
276
277int AliHLTMUONFullTrackerComponent::Configure(const char* arguments)
278{
279 // see header file for class documentation
280 int iResult=0;
281 if (!arguments) return iResult;
282 HLTInfo("parsing configuration string \'%s\'", arguments);
283
284 TString allArgs=arguments;
285 TString argument;
286 int bMissingParam=0;
287
288 TObjArray* pTokens=allArgs.Tokenize(" ");
289 if (pTokens) {
290 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
291 argument=((TObjString*)pTokens->At(i))->GetString();
292 if (argument.IsNull()) continue;
293
294 // -config1
295 if (argument.CompareTo("-config1")==0) {
296 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
297 HLTInfo("got \'-config1\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
298
299 // -config2
300 } else if (argument.CompareTo("-config2")==0) {
301 HLTInfo("got \'-config2\'");
302 } else {
303 HLTError("unknown argument %s", argument.Data());
304 iResult=-EINVAL;
305 break;
306 }
307 }
308 delete pTokens;
309 }
310 if (bMissingParam) {
311 HLTError("missing parameter for argument %s", argument.Data());
312 iResult=-EINVAL;
313 }
314 return iResult;
315}
316
317int AliHLTMUONFullTrackerComponent::Reconfigure(const char* cdbEntry, const char* chainId)
318{
319 // see header file for class documentation
320 int iResult=0;
321 const char* path="HLT/ConfigSample/FullTrackerComponent";
322 const char* defaultNotify="";
323 if (cdbEntry) {
324 path=cdbEntry;
325 defaultNotify=" (default)";
326 }
327 if (path) {
328 HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
329 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
330 if (pEntry) {
331 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
332 if (pString) {
333 HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
334 iResult=Configure(pString->GetString().Data());
335 } else {
336 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
337 }
338 } else {
339 HLTError("can not fetch object \"%s\" from CDB", path);
340 }
341 }
342 return iResult;
343}
344
345int AliHLTMUONFullTrackerComponent::ReadPreprocessorValues(const char* modules)
346{
347 // see header file for class documentation
348 int iResult=0;
349 TString detectors(modules!=NULL?modules:"");
350 HLTInfo("read preprocessor values for detector(s): %s", detectors.IsNull()?"none":detectors.Data());
351 return iResult;
352}