LCOV - code coverage report
Current view: top level - MUON/MUONshuttle - AliMUONOccupancySubprocessor.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 52 1.9 %
Date: 2016-06-14 17:26:59 Functions: 1 10 10.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             : // $Id$
      17             : 
      18             : #include "AliMUONOccupancySubprocessor.h"
      19             : 
      20             : #include "AliCDBMetaData.h"
      21             : #include "AliMUON2DMap.h"
      22             : #include "AliMUONPreprocessor.h"
      23             : #include "AliMUONTrackerIO.h"
      24             : #include "TObjString.h"
      25             : #include "TSystem.h"
      26             : 
      27             : //-----------------------------------------------------------------------------
      28             : /// \class AliMUONOccupancySubprocessor
      29             : ///
      30             : /// Implementation of AliMUONVSubprocessor class to deal with MUON TRK occupancy.
      31             : ///
      32             : /// Values to compute the occupancy are read in from an ascii file,
      33             : /// with the format :               \n
      34             : ///---------------------------------------------------------------------------\n
      35             : /// BUS_PATCH MANU_ADDR SUM_N NEVENTS
      36             : ///---------------------------------------------------------------------------\n
      37             : ///
      38             : /// \author L. Aphecetche
      39             : //-----------------------------------------------------------------------------
      40             : 
      41             : /// \cond CLASSIMP
      42          12 : ClassImp(AliMUONOccupancySubprocessor)
      43             : /// \endcond
      44             : 
      45             : //_____________________________________________________________________________
      46             : AliMUONOccupancySubprocessor::AliMUONOccupancySubprocessor(AliMUONPreprocessor* master)
      47           0 : : AliMUONVSubprocessor(master,"Occupancy","Upload MUON Tracker occupancy to OCDB"),
      48           0 : fOccupancyMap(0x0)
      49           0 : {
      50             :   /// Default ctor
      51           0 : }
      52             : 
      53             : //_____________________________________________________________________________
      54             : AliMUONOccupancySubprocessor::~AliMUONOccupancySubprocessor()
      55           0 : {
      56             :   /// dtor
      57           0 :   delete fOccupancyMap;
      58           0 : }
      59             : 
      60             : //_____________________________________________________________________________
      61             : Bool_t 
      62             : AliMUONOccupancySubprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
      63             : {
      64             :   /// When starting a new run, reads in the occupancy ASCII files.
      65             :   
      66             :   const Int_t kSystem = AliMUONPreprocessor::kDAQ;
      67             :   const char* kId = "OCCUPANCY";
      68             :   
      69           0 :   delete fOccupancyMap;
      70           0 :   fOccupancyMap = new AliMUON2DMap(kTRUE);
      71             :   
      72           0 :   Master()->Log(Form("Reading occupancy file for Run %d startTime %u endTime %u",
      73             :                      run,startTime,endTime));
      74             :   
      75           0 :   TList* sources = Master()->GetFileSources(kSystem,kId);
      76           0 :   TIter next(sources);
      77             :   TObjString* o(0x0);
      78             :   Int_t n(0);
      79             :   
      80           0 :   while ( ( o = static_cast<TObjString*>(next()) ) )
      81             :   {
      82           0 :     TString fileName(Master()->GetFile(kSystem,kId,o->GetName()));
      83           0 :     Int_t ok = ReadFile(fileName.Data());
      84           0 :     if ( ok>0 || ok == AliMUONTrackerIO::kNoInfoFile )
      85             :     {
      86           0 :       n += ok;
      87           0 :     }
      88           0 :   }
      89             :   
      90           0 :   delete sources;
      91             : 
      92           0 :   if (!n)
      93             :   {
      94           0 :     Master()->Log("Failed to read any occupancy");
      95           0 :     delete fOccupancyMap;
      96           0 :     fOccupancyMap = 0;
      97           0 :     return kFALSE;
      98             :   }
      99           0 :   return kTRUE;
     100           0 : }
     101             : 
     102             : //_____________________________________________________________________________
     103             : UInt_t 
     104             : AliMUONOccupancySubprocessor::Process(TMap* /*dcsAliasMap*/)
     105             : {
     106             :   /// Store the occupancy map into the CDB
     107             :   
     108           0 :   if (!fOccupancyMap) 
     109             :   {
     110             :     // this is the only reason to fail for the moment : getting no occupancy
     111             :     // at all.
     112           0 :     return 1;
     113             :   }
     114             :   
     115           0 :   if ( fOccupancyMap->GetSize() )
     116             :   {
     117           0 :     Master()->Log("Storing occupancy map");
     118             :   
     119           0 :     AliCDBMetaData metaData;
     120           0 :     metaData.SetBeamPeriod(0);
     121           0 :     metaData.SetResponsible("MUON TRK");
     122           0 :     TString comment("Computed by AliMUONOccupancySubprocessor $Id$");
     123           0 :     comment.ReplaceAll("$","");
     124           0 :     metaData.SetComment(comment.Data());
     125             :     
     126             :     Bool_t validToInfinity = kFALSE;
     127           0 :     Bool_t result = Master()->Store("Calib", "OccupancyMap", fOccupancyMap, &metaData, 0, validToInfinity);
     128             :   
     129           0 :     return ( result != kTRUE ); // return 0 if everything is ok.  
     130           0 :   }
     131             :   else
     132             :   {
     133           0 :     Master()->Log("No occupancy map to store");
     134           0 :     return 0;
     135             :   }
     136           0 : }
     137             : 
     138             : //_____________________________________________________________________________
     139             : Int_t
     140             : AliMUONOccupancySubprocessor::ReadFile(const char* filename)
     141             : {
     142             :   /// Read the occupancy from an ASCII file.                                  \n
     143             :   /// Return kFALSE if reading was not successfull.                           \n
     144             :   ///
     145             :   
     146           0 :   TString sFilename(gSystem->ExpandPathName(filename));
     147             :   
     148           0 :   Master()->Log(Form("Reading %s",sFilename.Data()));
     149             :   
     150           0 :   Int_t n = AliMUONTrackerIO::ReadOccupancy(sFilename.Data(),*fOccupancyMap);
     151             :   
     152           0 :   switch (n)
     153             :   {
     154             :     case -1:
     155           0 :       Master()->Log(Form("Could not open %s",sFilename.Data()));
     156             :       break;
     157             :   }
     158             :   
     159             :   return n;
     160           0 : }
     161             : 
     162             : 
     163             : //_____________________________________________________________________________
     164             : void
     165             : AliMUONOccupancySubprocessor::Print(Option_t* opt) const
     166             : {
     167             :   /// ouput to screen
     168           0 :   if (fOccupancyMap) fOccupancyMap->Print("",opt);
     169           0 : }
     170             : 

Generated by: LCOV version 1.11