LCOV - code coverage report
Current view: top level - HLT/MUON/OnlineAnalysis - AliHLTMUONFullTrackerComponent.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 9 150 6.0 %
Date: 2016-06-14 17:26:59 Functions: 7 18 38.9 %

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

Generated by: LCOV version 1.11