LCOV - code coverage report
Current view: top level - HLT/TPCLib - AliHLTTPCOfflinePreprocessorWrapperComponent.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 7 148 4.7 %
Date: 2016-06-14 17:26:59 Functions: 7 20 35.0 %

          Line data    Source code
       1             : 
       2             : //***************************************************************************
       3             : //* This file is property of and copyright by the ALICE HLT Project         *
       4             : //* ALICE Experiment at CERN, All rights reserved.                          *
       5             : //*                                                                         *
       6             : //* Primary Authors: Sergey Gorbunov <sergey.gorbunov@fias.uni-frankfurt.de *
       7             : //*                  for The ALICE HLT Project.                             *
       8             : //*                                                                         *
       9             : //* Permission to use, copy, modify and distribute this software and its    *
      10             : //* documentation strictly for non-commercial purposes is hereby granted    *
      11             : //* without fee, provided that the above copyright notice appears in all    *
      12             : //* copies and that both the copyright notice and this permission notice    *
      13             : //* appear in the supporting documentation. The authors make no claims      *
      14             : //* about the suitability of this software for any purpose. It is           *
      15             : //* provided "as is" without express or implied warranty.                   *
      16             : //***************************************************************************
      17             : 
      18             : /** @file   AliHLTTPCOfflinePreprocessorWrapperComponent.cxx
      19             :     @author Sergey Gorbunov
      20             :     @date   
      21             :     @brief 
      22             : */
      23             : 
      24             : #include "AliHLTTPCOfflinePreprocessorWrapperComponent.h"
      25             : #include "AliHLTTPCClusterTransformation.h"
      26             : #include "AliHLTTPCDefinitions.h"
      27             : #include "AliHLTTPCGeometry.h"
      28             : #include "AliHLTTPCRawCluster.h"
      29             : #include "AliHLTTPCClusterDataFormat.h"
      30             : #include "AliHLTErrorGuard.h"
      31             : #include "AliHLTTPCFastTransformObject.h"
      32             : 
      33             : #include "AliCDBManager.h"
      34             : #include "AliCDBEntry.h"
      35             : #include "AliAnalysisDataContainer.h"
      36             : #include "AliTPCPreprocessorOffline.h"
      37             : #include "AliTPCcalibTime.h"
      38             : #include "AliHLTMessage.h"
      39             : 
      40             : #include "TMath.h"
      41             : #include "TObjString.h" 
      42             : #include "TStopwatch.h"
      43             : #include <cstdlib>
      44             : #include <cerrno>
      45             : #include <sys/time.h>
      46             : 
      47             : class AliTPCcalibTime;
      48             : 
      49             : using namespace std;
      50             : 
      51           6 : ClassImp(AliHLTTPCOfflinePreprocessorWrapperComponent) //ROOT macro for the implementation of ROOT specific class methods
      52             : 
      53           3 : AliHLTTPCOfflinePreprocessorWrapperComponent::AliHLTTPCOfflinePreprocessorWrapperComponent() :
      54           3 :   fAsyncProcessor()
      55          18 :   {}
      56             : 
      57             : AliHLTTPCOfflinePreprocessorWrapperComponent::~AliHLTTPCOfflinePreprocessorWrapperComponent()
      58          18 : { 
      59             :   // destructor
      60           9 : }
      61             : 
      62             : const char* AliHLTTPCOfflinePreprocessorWrapperComponent::GetComponentID() { 
      63             : // see header file for class documentation
      64             : 
      65         378 :   return "TPCOfflinePreprocessorWrapper";
      66             : }
      67             : 
      68             : void AliHLTTPCOfflinePreprocessorWrapperComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) { 
      69             :   // see header file for class documentation
      70             : 
      71           0 :   list.clear(); 
      72           0 :   list.push_back( kAliHLTDataTypeTObject | kAliHLTDataOriginHLT );
      73           0 : }
      74             : 
      75             : AliHLTComponentDataType AliHLTTPCOfflinePreprocessorWrapperComponent::GetOutputDataType() { 
      76             :   // see header file for class documentation
      77             : 
      78           0 :   return kAliHLTDataTypeTObject;
      79             : }
      80             : 
      81             : void AliHLTTPCOfflinePreprocessorWrapperComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) { 
      82             :   // see header file for class documentation
      83           0 :   constBase = 1000000;
      84           0 :   inputMultiplier = 1.0;
      85           0 : }
      86             : 
      87             : AliHLTComponent* AliHLTTPCOfflinePreprocessorWrapperComponent::Spawn() { 
      88             :   // see header file for class documentation
      89             : 
      90           0 :   return new AliHLTTPCOfflinePreprocessorWrapperComponent();
      91           0 : }
      92             : 
      93             : AliCDBEntry* AliHLTTPCOfflinePreprocessorWrapperComponent::RunPreprocessor(AliAnalysisDataContainer* dataContainer)
      94             : {
      95           0 :         if (fAsyncProcess)
      96             :         {
      97           0 :                 AliHLTAsyncProcessor::AliHLTAsyncProcessorBuffer* buffer = (AliHLTAsyncProcessor::AliHLTAsyncProcessorBuffer*) dataContainer;
      98           0 :                 TObject* tmpObject = AliHLTMessage::Extract(buffer->fPtr, buffer->fSize);
      99           0 :                 if (tmpObject == NULL)
     100             :                 {
     101           0 :                         HLTError("Error deserializing object");
     102           0 :                         return(NULL);
     103             :                 }
     104           0 :                 fAsyncProcessor.FreeBuffer(buffer);
     105           0 :                 dataContainer = GetDataContainer((TObject*) tmpObject);
     106           0 :         }
     107           0 :         AliTPCcalibTime* timeObj = dynamic_cast<AliTPCcalibTime*>(dataContainer->GetData());
     108             :         AliCDBEntry* retVal = NULL;
     109           0 :         if (timeObj == NULL)
     110             :         {
     111           0 :                 HLTError("Error obtaining AliTPCcalibTime Object from received calibration object, cannot reinitialize transformation map");
     112             :         }
     113             :         else
     114             :         {
     115           0 :                 HLTImportant("TPC Offline Preprocessor preparing drift time cdb object");
     116           0 :                 AliCDBManager* cdbManager = AliCDBManager::Instance();
     117             :                 
     118           0 :                 static AliTPCPreprocessorOffline* preprocessor = new AliTPCPreprocessorOffline;
     119           0 :                 preprocessor->CalibTimeVdrift(timeObj, GetRunNo(), GetRunNo());
     120           0 :                 preprocessor->CreateDriftCDBentryObject(GetRunNo(), GetRunNo());
     121           0 :                 retVal = preprocessor->GetDriftCDBentry();
     122           0 :                 preprocessor->TakeOwnershipDriftCDBEntry();
     123             :         }
     124           0 :         delete dataContainer;
     125             :         //TODO: Memory Leaks: We can NOT delete fNewCalibObject. The CDBEntry created by the Preprocessor contains a TObjArray that links to some data in fNewCalibObject.
     126             :         //We have no control over where in AliRoot someone queries that CDBEntry and we do not know when it is no longer needed!
     127             :         
     128           0 :         if (fAsyncProcess)
     129             :         {
     130           0 :                 void* serRetVal = fAsyncProcessor.SerializeIntoBuffer(retVal, this);
     131           0 :                 delete retVal;
     132           0 :                 return((AliCDBEntry*) serRetVal);
     133             :         }
     134             :         
     135           0 :         return(retVal);
     136           0 : }
     137             : 
     138             : void* AliHLTTPCOfflinePreprocessorWrapperComponent::AsyncRunPreprocessor(void* obj)
     139             : {
     140           0 :         return((void*) RunPreprocessor((AliAnalysisDataContainer*) obj));
     141             : }
     142             : 
     143             : int AliHLTTPCOfflinePreprocessorWrapperComponent::DoInit( int argc, const char** argv ) 
     144             : { 
     145             :   // see header file for class documentation
     146             :   
     147             :   int iResult=0;
     148             :   //!! iResult = ConfigureFromCDBTObjString(fgkOCDBEntryClusterTransformation);
     149             : 
     150           0 :   if (iResult>=0 && argc>0)
     151           0 :     iResult=ConfigureFromArgumentString(argc, argv);
     152             :   
     153           0 :   if (fAsyncProcessor.Initialize(fAsyncProcessorQueueDepth, fAsyncProcess, fAsyncProcess ? 100000000 : 0)) return(1);
     154             : 
     155           0 :   return iResult;
     156           0 : } // end DoInit()
     157             : 
     158             : int AliHLTTPCOfflinePreprocessorWrapperComponent::DoDeinit() { 
     159             :   // see header file for class documentation
     160           0 :   if (fAsyncProcessor.GetNumberOfAsyncTasksInQueue())
     161             :   {
     162             :     //We just dump all remaining tasks, since we do not need the transformation maps anymore
     163           0 :         fAsyncProcessor.WaitForTasks(0);
     164           0 :         while (fAsyncProcessor.IsQueuedTaskCompleted()) fAsyncProcessor.RetrieveQueuedTaskResult();
     165             :   }
     166           0 :   fAsyncProcessor.Deinitialize();
     167           0 :   return 0;
     168             : }
     169             : 
     170             : int AliHLTTPCOfflinePreprocessorWrapperComponent::Reconfigure(const char* /*cdbEntry*/, const char* /*chainId*/) { 
     171             :   // see header file for class documentation
     172           0 :   return 0;//!! ConfigureFromCDBTObjString(fgkOCDBEntryClusterTransformation);
     173             : }
     174             : 
     175             : int AliHLTTPCOfflinePreprocessorWrapperComponent::ScanConfigurationArgument(int argc, const char** argv){
     176             : 
     177             :   // see header file for class documentation
     178             : 
     179           0 :   if (argc<=0) return 0;
     180             :   int iRet = 0;
     181           0 :   for( int i=0; i<argc; i++ ){
     182           0 :     TString argument=argv[i];  
     183           0 :     if (argument.CompareTo("-QueueDepth")==0){
     184           0 :           if (++i >= argc)
     185             :           {
     186           0 :             HLTError("Value missing for -QueueDepth parameter");
     187           0 :                 return(-EINVAL);
     188             :           }
     189           0 :           fAsyncProcessorQueueDepth = atoi(argv[i]);
     190           0 :       HLTInfo("Queue Depth set to %d.", fAsyncProcessorQueueDepth);
     191           0 :       iRet+=2;
     192           0 :           }
     193           0 :     else if (argument.CompareTo("-AsyncProcess")==0){
     194           0 :           fAsyncProcess = 1;
     195           0 :       iRet++;
     196           0 :     } else {
     197             :       iRet = -EINVAL;
     198           0 :       HLTError("Unknown argument %s",argv[i]);     
     199             :     }
     200           0 :   } 
     201           0 :   return iRet;
     202           0 : }
     203             : 
     204             : AliAnalysisDataContainer* AliHLTTPCOfflinePreprocessorWrapperComponent::GetDataContainer(TObject* obj)
     205             : {
     206             :         AliAnalysisDataContainer* tmpContainer = NULL;
     207           0 :         TObjArray* tmpArray = (TObjArray*) dynamic_cast<const TObjArray*>(obj);
     208           0 :         tmpContainer = tmpArray ? NULL : (AliAnalysisDataContainer*) dynamic_cast<const AliAnalysisDataContainer*>(obj);
     209           0 :         if (tmpContainer)
     210             :         {
     211           0 :                 if (!fAsyncProcess) RemoveInputObjectFromCleanupList(tmpContainer);
     212             :         }
     213           0 :         else if (tmpArray)
     214             :         {
     215           0 :                 for (int i = 0;i <= tmpArray->GetLast();i++)
     216             :                 {
     217           0 :                         tmpContainer = (AliAnalysisDataContainer*) dynamic_cast<const AliAnalysisDataContainer*>((*tmpArray)[i]);
     218           0 :                         if (tmpContainer != NULL && strcmp(tmpContainer->GetName(), "calibTime") == 0)
     219             :                         {
     220           0 :                                 if (!fAsyncProcess) RemoveInputObjectFromCleanupList(tmpArray);
     221           0 :                                 tmpArray->Remove(tmpContainer);
     222           0 :                                 break;
     223             :                         }
     224             :                         else
     225             :                         {
     226             :                                 tmpContainer = NULL;
     227             :                         }
     228             :                 }
     229           0 :         }
     230             :         
     231           0 :         if (!tmpContainer)
     232             :         {
     233           0 :                 HLTImportant("TPC Offline Preprocessor component received object that is no AliAnalysisDataContainer!");
     234             :         }
     235           0 :         return(tmpContainer);
     236             : }
     237             : 
     238             : Int_t AliHLTTPCOfflinePreprocessorWrapperComponent::DoEvent(const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& /*trigData*/) {
     239             :         // see header file for class documentation
     240             : 
     241             :         // -- Only use data event
     242           0 :         if (IsDataEvent())
     243             :         {
     244             :                 AliAnalysisDataContainer* tmpContainer = NULL;
     245           0 :                 if (fAsyncProcess)
     246             :                 {
     247           0 :                         const AliHLTComponentBlockData* blk = GetFirstInputBlock(kAliHLTDataTypeTObject);
     248           0 :                         if (blk)
     249             :                         {
     250           0 :                                 AliHLTAsyncProcessor::AliHLTAsyncProcessorBuffer* myBuffer = fAsyncProcessor.AllocateBuffer(blk->fSize);
     251           0 :                                 if (myBuffer == NULL)
     252             :                                 {
     253           0 :                                         HLTError("No shared buffer available (Buf Size %d, Requested %d)", (int) fAsyncProcessor.BufferSize(), blk->fSize);
     254             :                                 }
     255             :                                 else
     256             :                                 {
     257           0 :                                         memcpy(myBuffer->fPtr, blk->fPtr, blk->fSize);
     258           0 :                                         myBuffer->fSize = blk->fSize;
     259           0 :                                         if (fAsyncProcessor.QueueAsyncMemberTask(this, &AliHLTTPCOfflinePreprocessorWrapperComponent::AsyncRunPreprocessor, myBuffer))
     260             :                                         {
     261           0 :                                                 fAsyncProcessor.FreeBuffer(myBuffer);
     262           0 :                                         }
     263             :                                 }
     264           0 :                         }
     265           0 :                 }
     266             :                 else
     267             :                 {
     268           0 :                         for (const TObject *iter = GetFirstInputObject(kAliHLTDataTypeTObject); iter != NULL; iter = GetNextInputObject())
     269             :                         {
     270           0 :                                 if ((tmpContainer = GetDataContainer((TObject*) iter))) break;
     271             :                         }
     272           0 :                         if (tmpContainer)
     273             :                         {
     274           0 :                                 if (fAsyncProcessor.QueueAsyncMemberTask(this, &AliHLTTPCOfflinePreprocessorWrapperComponent::AsyncRunPreprocessor, tmpContainer))
     275             :                                 {
     276           0 :                                         delete tmpContainer;
     277             :                                 }
     278             :                         }
     279             :                 }
     280           0 :         }
     281             :         
     282           0 :         if (!IsDataEvent() && GetFirstInputBlock(kAliHLTDataTypeEOR | kAliHLTDataOriginAny))
     283             :         {
     284           0 :                 fAsyncProcessor.WaitForTasks(0);
     285           0 :         }
     286             : 
     287           0 :         while (fAsyncProcessor.IsQueuedTaskCompleted())
     288             :         {
     289             :                 AliCDBEntry* retVal;
     290             :                 int pushResult;
     291           0 :                 if (fAsyncProcess)
     292             :                 {
     293           0 :                         AliHLTAsyncProcessor::AliHLTAsyncProcessorBuffer* buf = (AliHLTAsyncProcessor::AliHLTAsyncProcessorBuffer*) fAsyncProcessor.RetrieveQueuedTaskResult();
     294           0 :                         pushResult = PushBack(buf->fPtr, buf->fSize, kAliHLTDataTypeTObject | kAliHLTDataOriginHLT);
     295           0 :                         fAsyncProcessor.FreeBuffer(buf);
     296           0 :                 }
     297             :                 else
     298             :                 {
     299           0 :                         retVal = (AliCDBEntry*) fAsyncProcessor.RetrieveQueuedTaskResult();
     300           0 :                         pushResult = PushBack(dynamic_cast<TObject*>(retVal), kAliHLTDataTypeTObject | kAliHLTDataOriginHLT);
     301           0 :                         delete retVal;
     302             :                 }
     303           0 :                 if (pushResult) HLTImportant("Offline Preprocessor pushed CDB entry (%d bytes)", pushResult);
     304             :         }
     305             : 
     306           0 :         return 0;
     307             : }
     308             : 
     309             : void AliHLTTPCOfflinePreprocessorWrapperComponent::GetOCDBObjectDescription( TMap* const targetMap)
     310             : {
     311             :   // Get a list of OCDB object description needed for the particular component
     312           0 :   if (!targetMap) return;
     313             :   
     314             :   // OCDB entries for component arguments
     315             : 
     316             :   //!! targetMap->Add(new TObjString(fgkOCDBEntryClusterTransformation), new TObjString("component argument for the charge threshold"));
     317             :   
     318             :   // OCDB entries to be fetched by the TAXI (access via the AliTPCcalibDB class)
     319           0 :   targetMap->Add(new TObjString("TPC/Calib/Parameters"),    new TObjString("unknown content"));
     320           0 :   targetMap->Add(new TObjString("TPC/Calib/TimeDrift"),     new TObjString("drift velocity calibration"));
     321           0 :   targetMap->Add(new TObjString("TPC/Calib/TimeGain"),      new TObjString("time gain  calibration"));
     322           0 :   targetMap->Add(new TObjString("TPC/Calib/Temperature"),   new TObjString("temperature map"));
     323           0 :   targetMap->Add(new TObjString("TPC/Calib/PadGainFactor"), new TObjString("gain factor pad by pad"));
     324           0 :   targetMap->Add(new TObjString("TPC/Calib/ClusterParam"),  new TObjString("cluster parameters"));
     325           0 :   targetMap->Add(new TObjString("TPC/Calib/Correction"),  new TObjString("coreection"));
     326           0 :   targetMap->Add(new TObjString("TPC/Calib/RecoParam"),  new TObjString("reconstruction parameters"));
     327             :  
     328             :   // OCDB entries needed to be fetched by the Pendolino
     329           0 :   targetMap->Add(new TObjString("TPC/Calib/AltroConfig"), new TObjString("contains the altro config, e.g. info about the L0 trigger timing"));
     330           0 :   targetMap->Add(new TObjString("GRP/CTP/CTPtiming"),     new TObjString("content used in the cluster coordinate transformation in relation to the L0 trigger timing"));
     331             : 
     332             :   // OCDB entries necessary for replaying data on the HLT cluster
     333           0 :   targetMap->Add(new TObjString("GRP/GRP/Data"), new TObjString("contains magnetic field info"));  
     334             :  
     335             :   // OCDB entries needed to suppress fatals/errors/warnings during reconstruction
     336           0 :   targetMap->Add(new TObjString("TPC/Calib/Distortion"),  new TObjString("distortion map"));
     337           0 :   targetMap->Add(new TObjString("TPC/Calib/GainFactorDedx"), new TObjString("gain factor dedx"));
     338           0 :   targetMap->Add(new TObjString("TPC/Calib/PadTime0"),    new TObjString("time0 offset pad by pad"));
     339           0 :   targetMap->Add(new TObjString("TPC/Calib/PadNoise"),    new TObjString("pad noise values"));
     340           0 :   targetMap->Add(new TObjString("TPC/Calib/Pedestals"),   new TObjString("pedestal info"));
     341           0 :   targetMap->Add(new TObjString("TPC/Calib/Pulser"),      new TObjString("pulser info"));
     342           0 :   targetMap->Add(new TObjString("TPC/Calib/CE"),          new TObjString("CE laser calibration result"));
     343           0 :   targetMap->Add(new TObjString("TPC/Calib/Raw"),         new TObjString("unknown content"));
     344           0 :   targetMap->Add(new TObjString("TPC/Calib/QA"),          new TObjString("not important"));
     345           0 :   targetMap->Add(new TObjString("TPC/Calib/Mapping"),     new TObjString("unknown content"));
     346           0 :   targetMap->Add(new TObjString("TPC/Calib/Goofie"),      new TObjString("Goofie values, not used at the moment (05.03.2010)"));
     347           0 :   targetMap->Add(new TObjString("TPC/Calib/HighVoltage"), new TObjString("high voltage values, not used"));
     348           0 :   targetMap->Add(new TObjString("TPC/Calib/Ref"),         new TObjString("unknown content"));
     349           0 : }

Generated by: LCOV version 1.11