LCOV - code coverage report
Current view: top level - HLT/EMCAL - AliHLTEMCALRawAnalyzerComponentSTU.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 11 82 13.4 %
Date: 2016-06-14 17:26:59 Functions: 7 17 41.2 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * This file is property of and copyright by the ALICE HLT Project        *
       3             :  * All rights reserved.                                                   *
       4             :  *                                                                        *
       5             :  * Primary Authors: Markus Fasel                                          *
       6             :  *                                                                        *
       7             :  * Permission to use, copy, modify and distribute this software and its   *
       8             :  * documentation strictly for non-commercial purposes is hereby granted   *
       9             :  * without fee, provided that the above copyright notice appears in all   *
      10             :  * copies and that both the copyright notice and this permission notice   *
      11             :  * appear in the supporting documentation. The authors make no claims     *
      12             :  * about the suitability of this software for any purpose. It is          *
      13             :  * provided "as is" without express or implied warranty.                  *
      14             :  **************************************************************************/
      15             : #include "AliHLTCaloTriggerRawDigitDataStruct.h"
      16             : #include "AliCaloRawStreamV3.h"
      17             : #include "AliEMCALTriggerData.h"
      18             : #include "AliEMCALTriggerSTURawStream.h"
      19             : #include "AliHLTEMCALDefinitions.h"
      20             : #include "AliHLTEMCALGeometry.h"
      21             : #include "AliHLTEMCALMapper.h"
      22             : #include "AliHLTEMCALRawAnalyzerComponentSTU.h"
      23             : #include "AliHLTEMCALSTURawDigitMaker.h"
      24             : #include "AliHLTEMCALSTUHeaderStruct.h"
      25             : #include "AliRawReaderMemory.h"
      26             : #include "AliDAQ.h"
      27             : 
      28           6 : ClassImp(AliHLTEMCALRawAnalyzerComponentSTU)
      29             : 
      30             : AliHLTEMCALRawAnalyzerComponentSTU::AliHLTEMCALRawAnalyzerComponentSTU():
      31           3 : AliHLTCaloProcessor(),
      32           9 : AliHLTCaloConstantsHandler("EMCAL"),
      33           3 : fSTURawDigitMaker(NULL),
      34           3 : fGeometry(NULL)
      35          18 : {
      36           6 : }
      37             : 
      38          18 : AliHLTEMCALRawAnalyzerComponentSTU::~AliHLTEMCALRawAnalyzerComponentSTU() {
      39           3 :   if(fGeometry) delete fGeometry;
      40           9 : }
      41             : 
      42             : int AliHLTEMCALRawAnalyzerComponentSTU::DoInit(int argc, const char **argv){
      43           0 :   fGeometry = new AliHLTEMCALGeometry(GetRunNo());
      44             : 
      45           0 :   fSTURawDigitMaker = new AliHLTEMCALSTURawDigitMaker;
      46           0 :   fSTURawDigitMaker->SetGeometry(fGeometry);
      47             : 
      48           0 :   return 0;
      49           0 : }
      50             : 
      51             : int AliHLTEMCALRawAnalyzerComponentSTU::DoDeinit(){
      52           0 :   if(fGeometry) delete fGeometry;
      53           0 :   fGeometry = NULL;
      54           0 :   return 0;
      55             : }
      56             : 
      57             : const char* AliHLTEMCALRawAnalyzerComponentSTU::GetComponentID(){
      58         294 :   return "EmcalStuAnalyzer";
      59             : }
      60             : 
      61             : void AliHLTEMCALRawAnalyzerComponentSTU::GetInputDataTypes( std::vector <AliHLTComponentDataType>& list){
      62           0 :   list.clear();
      63           0 :   list.push_back( AliHLTEMCALDefinitions::fgkDDLRawDataType   | kAliHLTDataOriginEMCAL );
      64           0 : }
      65             : 
      66             : AliHLTComponentDataType AliHLTEMCALRawAnalyzerComponentSTU::GetOutputDataType(){
      67           0 :   return AliHLTEMCALDefinitions::fgkTriggerSTUDataType;
      68             : }
      69             : 
      70             : void AliHLTEMCALRawAnalyzerComponentSTU::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier){
      71             :   //
      72           0 :   constBase = sizeof(AliHLTEMCALSTUHeaderStruct) + 10000 * sizeof(AliHLTCaloTriggerRawDigitDataStruct);
      73             :   //inputMultiplier = 5.;
      74           0 : }
      75             : 
      76             : AliHLTComponent* AliHLTEMCALRawAnalyzerComponentSTU::Spawn(){
      77           0 :   return new AliHLTEMCALRawAnalyzerComponentSTU;
      78           0 : }
      79             : 
      80             : bool AliHLTEMCALRawAnalyzerComponentSTU::CheckInputDataType(const AliHLTComponentDataType &datatype) {
      81             :   //comment
      82           0 :   vector <AliHLTComponentDataType> validTypes;
      83           0 :   GetInputDataTypes(validTypes);
      84             : 
      85           0 :   for(UInt_t i=0; i < validTypes.size(); i++) {
      86           0 :     if ( datatype  ==  validTypes.at(i) ) {
      87           0 :       return true;
      88             :     }
      89             :   }
      90             : 
      91             :   HLTDebug("Invalid Datatype");
      92           0 :   return false;
      93           0 : }
      94             : 
      95             : int AliHLTEMCALRawAnalyzerComponentSTU::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
      96             :          AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
      97             :          AliHLTUInt32_t& size, std::vector<AliHLTComponentBlockData>& outputBlocks ){
      98             : 
      99           0 :   if(!IsDataEvent()) {
     100           0 :     size = 0;
     101           0 :     return 0;
     102             :   }
     103             : 
     104             :   UInt_t totSize = 0, ndigitddl = 0;
     105             :   const AliHLTComponentBlockData* iter = NULL;
     106             :   unsigned long ndx;
     107             : 
     108             : 
     109             :   // Get pointers to output buffer
     110           0 :   AliHLTEMCALSTUHeaderStruct *headerPtr = reinterpret_cast<AliHLTEMCALSTUHeaderStruct *>(outputPtr);
     111           0 :   AliHLTCaloTriggerRawDigitDataStruct *dataIter = reinterpret_cast<AliHLTCaloTriggerRawDigitDataStruct *>(outputPtr + sizeof(AliHLTEMCALSTUHeaderStruct)),
     112             :       *nextFastor(NULL);
     113             :   totSize += sizeof(AliHLTEMCALSTUHeaderStruct);
     114             : 
     115           0 :   AliHLTUInt32_t availableSize = size;
     116           0 :   if(availableSize < sizeof(AliHLTEMCALSTUHeaderStruct)){
     117           0 :           HLTWarning("Not enough size in writeout buffer");
     118           0 :           return 1;
     119             :   }
     120           0 :   availableSize -= sizeof(AliHLTEMCALSTUHeaderStruct);
     121             : 
     122             :   bool headerInitialized = false;
     123             :   int ndigittotal = 0;
     124           0 :   fSTURawDigitMaker->Reset();
     125             : 
     126           0 :   for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) {
     127           0 :     iter = blocks+ndx;
     128           0 :     if(  ! CheckInputDataType(iter->fDataType) ) {
     129             :       continue;
     130             :     }
     131           0 :     if(iter->fSpecification < AliDAQ::GetFirstSTUDDL() || iter->fSpecification > AliDAQ::GetLastSTUDDL()) // check for STU DDLs
     132             :       continue;
     133             : 
     134             :     // Initialize raw reader from input data
     135           0 :     AliRawReaderMemory rawReaderMemoryPtr;
     136           0 :     rawReaderMemoryPtr.SetMemory(reinterpret_cast<UChar_t*>( iter->fPtr ), static_cast<ULong_t>(iter->fSize));
     137           0 :     rawReaderMemoryPtr.SetEquipmentID(iter->fSpecification + fCaloConstants->GetDDLOFFSET());
     138           0 :     rawReaderMemoryPtr.Reset();
     139           0 :     rawReaderMemoryPtr.NextEvent();
     140             : 
     141           0 :     fSTURawDigitMaker->Reset();
     142             : 
     143           0 :     AliEMCALTriggerSTURawStream stustream(&rawReaderMemoryPtr);
     144           0 :     fSTURawDigitMaker->ProcessSTUStream(&stustream, iter->fSpecification == AliDAQ::GetFirstSTUDDL() ? 0 : 1);
     145           0 :     const AliEMCALTriggerData *triggerData = fSTURawDigitMaker->GetTriggerData();
     146             : 
     147           0 :     if(!headerInitialized){
     148             :       // Set Header
     149           0 :       for (int i = 0; i < 2; i++) {
     150           0 :         headerPtr->fL1Threshold[2*i] = triggerData->GetL1JetThreshold(i);
     151           0 :         headerPtr->fL1Threshold[2*i+1] = triggerData->GetL1GammaThreshold(i);
     152             :       }
     153           0 :       headerPtr->fL1FrameMask = triggerData->GetL1FrameMask();
     154             :       headerInitialized = true;
     155           0 :     }
     156           0 :     int digitoutputsize = fSTURawDigitMaker->WriteRawDigitsBuffer(dataIter, availableSize);
     157           0 :     ndigitddl = digitoutputsize/(sizeof(AliHLTCaloTriggerRawDigitDataStruct));
     158           0 :     dataIter += ndigitddl; // fSTURawDigitMaker->GetNumberOfRawDigits();
     159           0 :     ndigittotal += ndigitddl;
     160           0 :     totSize += digitoutputsize;
     161           0 :   }
     162             : 
     163           0 :   headerPtr->fNRawDigits = ndigittotal;
     164             :   HLTDebug("Successfully decoded %d digits.", headerPtr->fNRawDigits);
     165             : 
     166           0 :   if (ndigittotal == 0) return 0; //Do not push an empty block
     167             : 
     168           0 :   AliHLTComponentBlockData bdChannelData;
     169           0 :   FillBlockData( bdChannelData );
     170           0 :   bdChannelData.fOffset = 0; //FIXME
     171           0 :   bdChannelData.fSize = totSize;
     172           0 :   bdChannelData.fDataType = GetOutputDataType();
     173           0 :   bdChannelData.fSpecification = 0;
     174           0 :   outputBlocks.push_back(bdChannelData);
     175           0 :   outputPtr += totSize; //Updating position of the output buffer
     176           0 :   size = totSize;
     177             :   return 0;
     178           0 : }

Generated by: LCOV version 1.11