LCOV - code coverage report
Current view: top level - HLT/PHOS - AliHLTPHOSDigitMakerComponent.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 120 0.8 %
Date: 2016-06-14 17:26:59 Functions: 1 18 5.6 %

          Line data    Source code
       1             :  // $Id$
       2             : 
       3             :  /**************************************************************************
       4             :  * This file is property of and copyright by the ALICE HLT Project        *
       5             :  * All rights reserved.                                                   *
       6             :  *                                                                        *
       7             :  * Primary Authors: Oystein Djuvsland                                     *
       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             : #include "AliHLTPHOSDigitMakerComponent.h"
      19             : #include "AliHLTCaloDigitMaker.h"
      20             : #include "AliHLTCaloDigitDataStruct.h"
      21             : #include "AliHLTPHOSMapper.h"
      22             : #include "AliHLTCaloChannelDataHeaderStruct.h"
      23             : #include "AliHLTCaloChannelDataStruct.h"
      24             : #include "AliPHOSEmcBadChannelsMap.h"
      25             : #include "AliPHOSEmcCalibData.h"
      26             : #include "TFile.h"
      27             : #include "AliCDBEntry.h"
      28             : #include "AliCDBPath.h"
      29             : #include "AliCDBManager.h"
      30             : #include <sys/stat.h>
      31             : #include <sys/types.h>
      32             : 
      33             : 
      34             : /** 
      35             :  * @file   AliHLTPHOSDigitMakerComponent.cxx
      36             :  * @author Oystein Djuvsland
      37             :  * @date   
      38             :  * @brief  A digit maker component for PHOS HLT
      39             : */
      40             : 
      41             : // see below for class documentation
      42             : // or
      43             : // refer to README to build package
      44             : // or
      45             : // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
      46             : 
      47           6 : ClassImp(AliHLTPHOSDigitMakerComponent);
      48             : 
      49             : AliHLTPHOSDigitMakerComponent::AliHLTPHOSDigitMakerComponent() :
      50           0 :   AliHLTCaloProcessor(),
      51           0 :   AliHLTCaloConstantsHandler("PHOS"),
      52           0 :   fDigitMakerPtr(0),
      53           0 :   fDigitContainerPtr(0),
      54           0 :   fBadChannelMap(0),
      55           0 :   fCalibData(0),
      56           0 :   fBCMInitialised(true),
      57           0 :   fGainsInitialised(true)
      58           0 : {
      59             :   //see header file for documentation
      60           0 : }
      61             : 
      62             : 
      63           0 : AliHLTPHOSDigitMakerComponent::~AliHLTPHOSDigitMakerComponent()
      64           0 : {
      65             :   //see header file for documentation
      66           0 : }
      67             : 
      68             : int 
      69             : AliHLTPHOSDigitMakerComponent::Deinit()
      70             : { 
      71             :   //see header file for documentation
      72           0 :   if(fDigitMakerPtr)
      73             :     {
      74           0 :       delete fDigitMakerPtr;
      75           0 :       fDigitMakerPtr = 0;
      76           0 :     }
      77           0 :   return 0;
      78             : }
      79             : 
      80             : const char*
      81             : AliHLTPHOSDigitMakerComponent::GetComponentID()
      82             : {
      83             :   //see header file for documentation
      84           0 :   return "PhosDigitMaker";
      85             : }
      86             : 
      87             : 
      88             : void
      89             : AliHLTPHOSDigitMakerComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
      90             : { 
      91             :   //see header file for documentation
      92           0 :   list.clear();
      93           0 :   list.push_back(AliHLTPHOSDefinitions::fgkChannelDataType);
      94           0 : }
      95             : 
      96             : AliHLTComponentDataType 
      97             : AliHLTPHOSDigitMakerComponent::GetOutputDataType()
      98             : {
      99             :   //see header file for documentation
     100           0 :   return AliHLTPHOSDefinitions::fgkDigitDataType;
     101             : }
     102             : 
     103             : 
     104             : void 
     105             : AliHLTPHOSDigitMakerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
     106             : {
     107             :   //see header file for documentation
     108           0 :   constBase = 0;
     109           0 :   inputMultiplier = (float)sizeof(AliHLTCaloDigitDataStruct)/sizeof(AliHLTCaloChannelDataStruct) + 1;
     110           0 : }
     111             : 
     112             : int 
     113             : AliHLTPHOSDigitMakerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
     114             :                                         AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
     115             :                                         std::vector<AliHLTComponentBlockData>& outputBlocks)
     116             : {
     117             :   //see header file for documentation
     118             :   UInt_t offset           = 0; 
     119             :   UInt_t mysize           = 0;
     120             :   Int_t digitCount        = 0;
     121             :   Int_t ret               = 0;
     122             : 
     123             :   const AliHLTComponentBlockData* iter = 0; 
     124             :   unsigned long ndx; 
     125             : 
     126             :   UInt_t specification = 0;
     127             :   AliHLTCaloChannelDataHeaderStruct* tmpChannelData = 0;
     128             :   
     129             :   //  fDigitMakerPtr->SetDigitHeaderPtr(reinterpret_cast<AliHLTCaloDigitHeaderStruct*>(outputPtr));
     130             : 
     131           0 :   fDigitMakerPtr->SetDigitDataPtr(reinterpret_cast<AliHLTCaloDigitDataStruct*>(outputPtr));
     132             : 
     133           0 :   for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
     134             :     {
     135             :       
     136           0 :       iter = blocks+ndx;
     137             :       
     138           0 :       if(iter->fDataType != AliHLTPHOSDefinitions::fgkChannelDataType)
     139             :         {
     140             : //        HLTDebug("Data block is not of type fgkChannelDataType");
     141             :           continue;
     142             :         }
     143           0 :       if(!fBCMInitialised)
     144             :       {
     145           0 :          AliHLTPHOSMapper mapper;
     146           0 :          Int_t module = mapper.GetModuleFromSpec(iter->fSpecification);
     147           0 :          if(module >= 0)
     148             :            {
     149           0 :              for(Int_t x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++)
     150             :                {
     151           0 :                  for(Int_t z = 0; z < fCaloConstants->GetNZROWSMOD(); z++)
     152             :                    {
     153           0 :                      fDigitMakerPtr->SetBadChannel(x, z, fBadChannelMap->IsBadChannel(5-module, z+1, x+1));
     154             :                    }
     155             :                }
     156           0 :          }
     157             :          //delete fBadChannelMap;
     158           0 :          fBCMInitialised = true;
     159           0 :       }
     160           0 :       if(!fGainsInitialised)
     161             :       {
     162           0 :          AliHLTPHOSMapper mapper;
     163           0 :          Int_t module = mapper.GetModuleFromSpec(iter->fSpecification);
     164           0 :          if(module >= 0 && module < 5)
     165             :            {
     166           0 :              for(Int_t x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++)
     167             :                {
     168           0 :                  for(Int_t z = 0; z < fCaloConstants->GetNZROWSMOD(); z++)
     169             :                    {
     170           0 :                      fDigitMakerPtr->SetGain(x, z, fCalibData->GetHighLowRatioEmc(5-module, z+1, x+1), fCalibData->GetADCchannelEmc(5-module, z+1, x+1));
     171             :                    }
     172             :                }
     173           0 :              fGainsInitialised = true;
     174           0 :          }
     175             : 
     176           0 :       }
     177             : 
     178           0 :       specification |= iter->fSpecification;
     179           0 :       tmpChannelData = reinterpret_cast<AliHLTCaloChannelDataHeaderStruct*>(iter->fPtr);
     180             :     
     181           0 :       ret = fDigitMakerPtr->MakeDigits(tmpChannelData, size-(digitCount*sizeof(AliHLTCaloDigitDataStruct)));
     182           0 :       if(ret == -1) 
     183             :         {
     184           0 :           HLTError("Trying to write over buffer size");
     185           0 :           return -ENOBUFS;
     186             :         }
     187           0 :       digitCount += ret; 
     188           0 :     }
     189             :   
     190           0 :   mysize += digitCount*sizeof(AliHLTCaloDigitDataStruct);
     191             : 
     192             :   HLTDebug("# of digits: %d, used memory size: %d, available size: %d", digitCount, mysize, size);
     193             : 
     194           0 :   if(mysize > 0) 
     195             :     {
     196           0 :       AliHLTComponentBlockData bd;
     197           0 :       FillBlockData( bd );
     198           0 :       bd.fOffset = offset;
     199           0 :       bd.fSize = mysize;
     200           0 :       bd.fDataType = AliHLTPHOSDefinitions::fgkDigitDataType;
     201           0 :       bd.fSpecification = specification;
     202           0 :       outputBlocks.push_back(bd);
     203           0 :     }
     204             : 
     205           0 :   fDigitMakerPtr->Reset();
     206             : 
     207           0 :   size = mysize; 
     208             : 
     209           0 :   return 0;
     210           0 : }
     211             : 
     212             : int
     213             : AliHLTPHOSDigitMakerComponent::DoInit(int argc, const char** argv )
     214             : {
     215             :   //see header file for documentation
     216             : 
     217           0 :   fDigitMakerPtr = new AliHLTCaloDigitMaker("PHOS");
     218             : 
     219           0 :   AliHLTCaloMapper *mapper = new AliHLTPHOSMapper();
     220           0 :   fDigitMakerPtr->SetMapper(mapper);
     221             :   
     222             :   Float_t mintime = 0.;
     223             :   Float_t maxtime =50.;
     224             :   
     225           0 :   for(int i = 0; i < argc; i++)
     226             :     {
     227           0 :       if(!strcmp("-lowgainfactor", argv[i]))
     228             :         {
     229           0 :           fDigitMakerPtr->SetGlobalLowGainFactor(atof(argv[i+1]));
     230           0 :         }
     231           0 :       if(!strcmp("-highgainfactor", argv[i]))
     232             :         {
     233           0 :           fDigitMakerPtr->SetGlobalHighGainFactor(atof(argv[i+1]));
     234           0 :         }
     235           0 :         if(!strcmp("-mintime", argv[i]))
     236             :         {
     237           0 :            mintime = atof(argv[i+1]);
     238           0 :         }
     239           0 :         if(!strcmp("-maxtime", argv[i]))
     240             :         {
     241           0 :            maxtime = atof(argv[i+1]);
     242           0 :         }
     243             :     }
     244             :  
     245           0 :  fDigitMakerPtr->SetTimeWindow(mintime, maxtime);
     246             : 
     247           0 :  if(GetBCMFromCDB()) return -1;
     248           0 :  if(GetGainsFromCDB()) return -1;
     249             :   
     250             :   //fDigitMakerPtr->SetDigitThreshold(2);
     251             : 
     252           0 :   return 0;
     253           0 : }
     254             : 
     255             : 
     256             : int AliHLTPHOSDigitMakerComponent::GetBCMFromCDB()
     257             : {
     258           0 :    fBCMInitialised = false;
     259             :    
     260             : //   HLTInfo("Getting bad channel map...");
     261             : 
     262           0 :   AliCDBPath path("PHOS","Calib","EmcBadChannels");
     263           0 :   if(path.GetPath())
     264             :     {
     265             :       //      HLTInfo("configure from entry %s", path.GetPath());
     266           0 :       AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
     267           0 :         if (pEntry) 
     268             :         {
     269           0 :             fBadChannelMap = (AliPHOSEmcBadChannelsMap*)pEntry->GetObject();
     270             :         }
     271             :       else
     272             :         {
     273           0 :             HLTError("can not fetch object \"%s\" from CDB", path.GetPath().Data());
     274           0 :             return -1;
     275             :         }
     276           0 :     }
     277           0 :    if(!fBadChannelMap) return -1;
     278           0 :    return 0;
     279           0 : }
     280             : 
     281             : int AliHLTPHOSDigitMakerComponent::GetGainsFromCDB()
     282             : {
     283           0 :    fGainsInitialised = false;
     284             :    
     285             : //   HLTInfo("Getting bad channel map...");
     286             : 
     287           0 :   AliCDBPath path("PHOS","Calib","EmcGainPedestals");
     288           0 :   if(path.GetPath())
     289             :     {
     290             :       //      HLTInfo("configure from entry %s", path.GetPath());*/
     291           0 :       AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
     292           0 :       if (pEntry) 
     293             :         {
     294           0 :             fCalibData = (AliPHOSEmcCalibData*)pEntry->GetObject();
     295             :         }
     296             :       else      
     297             :         {
     298           0 :             HLTError("can not fetch object \"%s\" from CDB", path.GetPath().Data());
     299           0 :             return -1;
     300             :         }
     301           0 :     }
     302             :     
     303           0 :     if(!fCalibData) return -1;
     304           0 :    return 0;
     305             :    
     306           0 : }
     307             : 
     308             : 
     309             : AliHLTComponent*
     310             : AliHLTPHOSDigitMakerComponent::Spawn()
     311             : {
     312             :   //see header file for documentation
     313           0 :   return new AliHLTPHOSDigitMakerComponent();
     314           0 : }

Generated by: LCOV version 1.11