LCOV - code coverage report
Current view: top level - RAW/RAWDatabase - AliAltroMapping.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 35 45 77.8 %
Date: 2016-06-14 17:26:59 Functions: 6 8 75.0 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       3             :  *                                                                        *
       4             :  * Author: The ALICE Off-line Project.                                    *
       5             :  * Contributors are mentioned in the code where appropriate.              *
       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             : 
      16             : // This class handles the mapping of the Altro channels
      17             : // The mapping is read from an external mapping files
      18             : // The class is used as a base class by TPC,PHOS and FMD
      19             : // Author: C.Cheshkov
      20             : 
      21             : #include "AliAltroMapping.h"
      22             : #include "AliLog.h"
      23             : #include <Riostream.h>
      24             : 
      25             : 
      26         128 : ClassImp(AliAltroMapping)
      27             : 
      28             : //_____________________________________________________________________________
      29          98 : AliAltroMapping::AliAltroMapping():
      30          98 :   fIn(NULL),
      31          98 :   fNumberOfChannels(0),
      32          98 :   fMaxHWAddress(0),
      33          98 :   fMappingSize(0),
      34          98 :   fMapping(NULL)
      35         294 : {
      36             :   // Default constructor
      37          98 : }
      38             : 
      39             : //_____________________________________________________________________________
      40         140 : AliAltroMapping::AliAltroMapping(const char *mappingFile):
      41         140 :   fIn(NULL),
      42         140 :   fNumberOfChannels(0),
      43         140 :   fMaxHWAddress(0),
      44         140 :   fMappingSize(0),
      45         140 :   fMapping(NULL)
      46         420 : {
      47             :   // Constructor
      48             :   // Reads the mapping from an external file
      49         140 :   if (mappingFile)
      50         140 :     OpenMappingFile(mappingFile);
      51             :   else
      52           0 :     AliFatal("Mapping file not specified !");
      53         140 : }
      54             : 
      55             : //_____________________________________________________________________________
      56             : AliAltroMapping::~AliAltroMapping()
      57         250 : {
      58             :   // destructor
      59         125 :   CloseMappingFile();
      60             : 
      61         369 :   if (fMapping) delete [] fMapping;
      62         125 : }
      63             : 
      64             : //_____________________________________________________________________________
      65             : Bool_t AliAltroMapping::OpenMappingFile(const char *mappingFile)
      66             : {
      67             :   // Initalizes the ALTRO mapping from a file
      68             :   // Look at the TPC module for the format of
      69             :   // the mapping file
      70         420 :   fIn = new ifstream(mappingFile);
      71         140 :   if (!*fIn) {
      72           0 :     AliFatal(Form("Missing mapping file (%s) !",mappingFile));
      73           0 :     CloseMappingFile();
      74           0 :     return kFALSE;
      75             :   }
      76         140 :   if (!(*fIn >> fNumberOfChannels)) {
      77           0 :     AliFatal(Form("Syntax of the mapping file is wrong (%s) !",mappingFile));
      78           0 :     CloseMappingFile();
      79           0 :     return kFALSE;
      80             :   }
      81         140 :   if (!(*fIn >> fMaxHWAddress)) {
      82           0 :     AliFatal(Form("Syntax of the mapping file is wrong (%s) !",mappingFile));
      83           0 :     CloseMappingFile();
      84           0 :     return kFALSE;
      85             :   }
      86             : 
      87         140 :   return kTRUE;
      88         140 : }
      89             : 
      90             : //_____________________________________________________________________________
      91             : void AliAltroMapping::CloseMappingFile()
      92             : {
      93             :   // Closes the external mapping
      94             :   // file
      95         530 :   if (fIn) {
      96         140 :     fIn->close();
      97         280 :     delete fIn;
      98         140 :     fIn = NULL;
      99         140 :   }
     100         265 : }

Generated by: LCOV version 1.11