LCOV - code coverage report
Current view: top level - HLT/CALO/offline - AliHLTCaloDigitHandler.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 61 1.6 %
Date: 2016-06-14 17:26:59 Functions: 1 12 8.3 %

          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             :  *                                                                        *
       5             :  * Primary Authors: Oystein Djuvsland <oysteind@ift.uib.no>               *
       6             :  *                  for The ALICE HLT Project.                            *
       7             :  *                                                                        *
       8             :  * Permission to use, copy, modify and distribute this software and its   *
       9             :  * documentation strictly for non-commercial purposes is hereby granted   *
      10             :  * without fee, provided that the above copyright notice appears in all   *
      11             :  * copies and that both the copyright notice and this permission notice   *
      12             :  * appear in the supporting documentation. The authors make no claims     *
      13             :  * about the suitability of this software for any purpose. It is          *
      14             :  * provided "as is" without express or implied warranty.                  *
      15             :  **************************************************************************/
      16             : 
      17             : #include "AliHLTCaloDigitHandler.h"
      18             : #include "AliHLTCaloDigitDataStruct.h"
      19             : #include "AliRunLoader.h"
      20             : #include "AliLoader.h"
      21             : #include "TTree.h"
      22             : #include "TClonesArray.h"
      23             : #include "AliHLTCaloGeometry.h"
      24             : #include "AliDigitNew.h"
      25             : 
      26           6 : ClassImp(AliHLTCaloDigitHandler);
      27             : 
      28           0 : AliHLTCaloDigitHandler::AliHLTCaloDigitHandler(TString detName) : AliHLTLogging(), AliHLTCaloConstantsHandler(detName.Data())
      29           0 :         ,fRunLoader(0)
      30           0 :         ,fDetLoader(0)
      31           0 :         ,fNumberOfEvents(0)
      32           0 :         ,fDigitTree(0)
      33           0 :         ,fDigits(0)
      34           0 :         ,fDigitsInModule(0)
      35           0 :         ,fGeometry(0)
      36           0 :         ,fCurrentEvent(999999)
      37           0 : {
      38             :     // See header file for class documentation
      39           0 : }
      40             : 
      41           0 : AliHLTCaloDigitHandler::~AliHLTCaloDigitHandler()
      42           0 : {
      43             :     // See header file for class documentation
      44           0 :     if (fDigits)
      45             :     {
      46           0 :         for (Int_t m = 0; m < fCaloConstants->GetNMODULES(); m++)
      47             :         {
      48           0 :             delete [] fDigits[m];
      49             :         }
      50           0 :     }
      51           0 :     if (fDigitsInModule)
      52             :     {
      53           0 :         delete [] fDigitsInModule;
      54             :     }
      55           0 : }
      56             : 
      57             : Int_t AliHLTCaloDigitHandler::Init(AliRunLoader *runLoader)
      58             : {
      59             :     // See header file for class documentation
      60             : 
      61           0 :     fGeometry->InitialiseGeometry();
      62             : 
      63           0 :     fRunLoader = runLoader;
      64             : 
      65           0 :     if (!fRunLoader)
      66             :     {
      67           0 :         HLTFatal("Run loader is NULL pointer");
      68           0 :         return -1;
      69             :     }
      70             : 
      71           0 :     fNumberOfEvents = fRunLoader->GetNumberOfEvents();
      72           0 :     HLTInfo("Found %d events", fNumberOfEvents);
      73             :     
      74           0 :     InitDigitArray();
      75             : 
      76           0 :     return fNumberOfEvents;
      77             : 
      78           0 : }
      79             : 
      80             : 
      81             : Int_t AliHLTCaloDigitHandler::GetDigits(Int_t module, AliHLTCaloDigitDataStruct* buffer)
      82             : {
      83           0 :     for (Int_t iDig = 0; iDig < fDigitsInModule[module]; iDig++)
      84             :     {
      85           0 :         buffer[iDig] = fDigits[module][iDig];
      86             :     }
      87           0 :     return fDigitsInModule[module];
      88             : }
      89             : 
      90             : 
      91             : void AliHLTCaloDigitHandler::InitDigitArray()
      92             : {
      93             : 
      94             :     // See header file for class documentation
      95             : 
      96           0 :     fDigitsInModule = new Int_t[fCaloConstants->GetNMODULES()];
      97             : 
      98           0 :     fDigits = new AliHLTCaloDigitDataStruct*[fCaloConstants->GetNMODULES()];
      99           0 :     for (Int_t m = 0; m < fCaloConstants->GetNMODULES(); m++)
     100             :     {
     101           0 :         fDigits[m] = new AliHLTCaloDigitDataStruct[fCaloConstants->GetNXCOLUMNSMOD()*fCaloConstants->GetNZROWSMOD()];
     102             :     }
     103           0 : }
     104             : 
     105             : void AliHLTCaloDigitHandler::ResetDigitArray()
     106             : {
     107             :     // See header file for class documentation
     108             : 
     109           0 :     for (Int_t m = 0; m < fCaloConstants->GetNMODULES(); m++)
     110             :     {
     111           0 :         fDigitsInModule[m] = 0;
     112             :     }
     113           0 : }
     114             : 
     115             : 
     116             : Int_t AliHLTCaloDigitHandler::ProcessEvent(UInt_t ev)
     117             : {
     118           0 :     if (fCurrentEvent != ev)
     119             :     {
     120           0 :         ResetDigitArray();
     121           0 :         fCurrentEvent = ev;
     122           0 :         if (fRunLoader)
     123             :         {
     124           0 :             fRunLoader->GetEvent(ev);
     125           0 :             fDetLoader->LoadDigits("read");
     126           0 :             TTree *tree = fDetLoader->TreeD();
     127           0 :             if (!tree)
     128             :             {
     129           0 :                 HLTFatal("Could not get digit tree");
     130           0 :                 return -1;
     131             :             }
     132           0 :             TClonesArray *digits = 0;
     133           0 :             tree->SetBranchAddress(fCaloConstants->GetDETNAME(), &digits);
     134           0 :             tree->GetEvent(0);
     135           0 :             Int_t nDigits = digits->GetEntries();
     136             :             HLTDebug("Found %d digits for branch: %s", nDigits, fCaloConstants->GetDETNAME().Data());
     137           0 :             for (Int_t iDig = 0; iDig < nDigits; iDig++)
     138             :             {
     139           0 :               ConvertDigit(dynamic_cast<AliDigitNew*>(digits->At(iDig)));
     140             :             }
     141           0 :         }
     142             :     }
     143           0 :     return 0;
     144           0 : }

Generated by: LCOV version 1.11