LCOV - code coverage report
Current view: top level - MUON/MUONcalib - AliMUONTriggerEfficiencyCells.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 23 117 19.7 %
Date: 2016-06-14 17:26:59 Functions: 6 18 33.3 %

          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 "AliMUONTriggerEfficiencyCells.h"
      19             : 
      20             : #include "AliLog.h"
      21             : #include "AliMpConstants.h"
      22             : 
      23             : #include "TH1.h"
      24             : #include "TList.h"
      25             : #include "TFile.h"
      26             : 
      27             : #include <fstream>
      28             : #include <cassert>
      29             : 
      30             : 
      31             : //-----------------------------------------------------------------------------
      32             : /// \class AliMUONTriggerEfficiencyCells
      33             : /// A class to store and give access to the numerator and denominator 
      34             : /// histograms for the trigger chamber efficiency calculation.
      35             : ///
      36             : /// \author Diego Stocco; Subatech, Nantes
      37             : //-----------------------------------------------------------------------------
      38             : 
      39             : /// \cond CLASSIMP
      40          18 : ClassImp(AliMUONTriggerEfficiencyCells)
      41             : /// \endcond
      42             : 
      43             : //__________________________________________________________________________
      44             : AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells()
      45             : :
      46           3 : TObject(),
      47           3 : fCountHistoList(0x0),
      48           3 : fNoCountHistoList(0x0),
      49           3 : fFiredStrips(0x0)
      50          15 : {
      51             : ///  Default constructor.
      52           3 :   CheckConstants();
      53           3 :   ResetHistos();
      54           6 : }
      55             : 
      56             : //__________________________________________________________________________
      57             : AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells(const Char_t* filename,
      58             :                                                              const Char_t* listname)
      59             : :
      60           0 : TObject(),
      61           0 : fCountHistoList(0x0),
      62           0 : fNoCountHistoList(0x0),
      63           0 : fFiredStrips(0x0)
      64           0 : {
      65             : ///  Constructor using an ASCII file.
      66           0 :   CheckConstants();
      67           0 :   ResetHistos();
      68           0 :   ReadFile(filename, listname);
      69           0 : }
      70             : 
      71             : //__________________________________________________________________________
      72             : AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells(TList *countHistoList)
      73             : :
      74           0 : TObject(),
      75           0 : fCountHistoList(countHistoList),
      76           0 : fNoCountHistoList(0x0),
      77           0 : fFiredStrips(0x0)
      78           0 : {
      79             : ///  Constructor using a list of histograms with counts.
      80           0 :   CheckConstants();
      81           0 :   ResetHistos();
      82           0 : }
      83             : 
      84             : //_____________________________________________________________________________
      85             : AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells(const AliMUONTriggerEfficiencyCells& other)
      86             : :
      87           0 : TObject(other),
      88           0 : fCountHistoList(other.fCountHistoList),
      89           0 : fNoCountHistoList(other.fNoCountHistoList),
      90           0 : fFiredStrips(other.fFiredStrips)
      91           0 : {
      92             : /// Copy constructor
      93             : 
      94           0 :   for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
      95           0 :     fBoardEfficiency[chCath] = other.fBoardEfficiency[chCath];
      96           0 :     fSlatEfficiency[chCath] = other.fSlatEfficiency[chCath];
      97             :   }
      98           0 : }
      99             : 
     100             : //_____________________________________________________________________________
     101             : AliMUONTriggerEfficiencyCells& AliMUONTriggerEfficiencyCells::operator=(const AliMUONTriggerEfficiencyCells& other)
     102             : {
     103             :   /// Asignment operator
     104             :   // check assignement to self
     105           0 :   if (this == &other)
     106           0 :     return *this;
     107             : 
     108           0 :   for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
     109           0 :     fBoardEfficiency[chCath] = other.fBoardEfficiency[chCath];
     110           0 :     fSlatEfficiency[chCath] = other.fSlatEfficiency[chCath];
     111             :   }
     112             : 
     113           0 :   fCountHistoList = other.fCountHistoList;
     114           0 :   fNoCountHistoList = other.fNoCountHistoList;
     115           0 :   fFiredStrips = other.fFiredStrips;
     116             :     
     117           0 :   return *this;
     118           0 : }
     119             : 
     120             : //__________________________________________________________________________
     121             : AliMUONTriggerEfficiencyCells::~AliMUONTriggerEfficiencyCells()
     122           0 : {
     123             : ///  Destructor.
     124             :   //delete [] fBoardEfficiency;
     125             :   //delete [] fSlatEfficiency;
     126           0 :   ResetHistos(kTRUE);
     127           0 :   delete fCountHistoList;
     128           0 :   delete fNoCountHistoList;
     129           0 :   delete fFiredStrips;
     130           0 : }
     131             : 
     132             : 
     133             : //_____________________________________________________________________________
     134             : void AliMUONTriggerEfficiencyCells::CheckConstants() const
     135             : {
     136             : /// Check consistence of redefined constants 
     137             : 
     138           6 :   assert(fgkNcathodes == AliMpConstants::NofCathodes());    
     139           3 :   assert(fgkNchambers == AliMpConstants::NofTriggerChambers());    
     140           3 :   assert(fgkNplanes == AliMpConstants::NofTriggerChambers() * fgkNcathodes);    
     141           3 : }
     142             : 
     143             : 
     144             : //__________________________________________________________________________
     145             : void
     146             : AliMUONTriggerEfficiencyCells::ResetHistos(Bool_t deleteObjects)
     147             : {
     148             : ///  Sets our internal array contents to zero.
     149             : 
     150          54 :   for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
     151          24 :     if ( deleteObjects ) {
     152           0 :       delete fBoardEfficiency[chCath];
     153           0 :       delete fSlatEfficiency[chCath];
     154             :     }
     155          24 :     fBoardEfficiency[chCath] = 0x0;
     156          24 :     fSlatEfficiency[chCath] = 0x0;
     157             :   }
     158           3 : }
     159             : 
     160             : 
     161             : //__________________________________________________________________________
     162             : void AliMUONTriggerEfficiencyCells::ReadFile(const Char_t* filename, const Char_t* listname)
     163             : {
     164             : ///  Structure of file (.root) containing local board efficency
     165           0 :     TFile *file = TFile::Open(filename);
     166           0 :     if(!file || !file->IsOpen()) {
     167           0 :       AliError(Form("Can't read file %s",filename));
     168           0 :       return;
     169             :     }
     170             : 
     171           0 :     if ( ! fCountHistoList ) {
     172           0 :       fCountHistoList = new TList();
     173           0 :       fCountHistoList->SetOwner();
     174           0 :     }
     175             : 
     176             :     TH1F *histo = 0x0;
     177             :     const Char_t* histoName;
     178             : 
     179             :     TList* listInFile = 0x0;
     180           0 :     TString listNameString(listname);
     181           0 :     if ( ! listNameString.IsNull() )
     182           0 :       listInFile = (TList*)file->FindObjectAny(listname);
     183             : 
     184           0 :     for ( Int_t ide=0; ide<=kHchamberCount; ide++){
     185           0 :       for(Int_t ich=0; ich<fgkNchambers; ich++){
     186             : 
     187             :         // Efficiency per chamber is provided by 1 histogram only
     188           0 :         if ( ide == kHchamberCount ) ich = fgkNchambers;
     189             : 
     190           0 :         for(Int_t hType=0; hType<kNcounts; hType++){
     191           0 :           histoName = GetHistoName(ide, hType, ich);
     192           0 :           histo = ( listInFile ) ? (TH1F*)listInFile->FindObject(histoName) : (TH1F*)file->Get(histoName);
     193           0 :           if ( ! histo ) {
     194           0 :             AliWarning(Form("Cannot find %s in file. Skip histogram", histoName));
     195             :             continue;
     196             :           }
     197           0 :           histo->SetDirectory(0);
     198           0 :           fCountHistoList->Add(histo);
     199             : 
     200           0 :           AliDebug(5,Form("Adding histogram %s\n",histoName));
     201             : 
     202             :           // Do not fill efficiency per chamber histos
     203           0 :           if ( ide == kHchamberCount )
     204             :             continue;
     205             : 
     206             :           // Fill old historgrams for consistency
     207           0 :           if ( hType < kBothPlanesEff ){
     208           0 :             TString newName = histoName;
     209           0 :             newName.ReplaceAll("Counts","Eff");
     210           0 :             TH1F* auxHisto = (TH1F*)histo->Clone(newName.Data());
     211           0 :             auxHisto->SetDirectory(0);
     212           0 :             if ( ide == kHboardCount )
     213           0 :               fBoardEfficiency[fgkNchambers*hType+ich] = auxHisto;
     214           0 :             else if ( ide == kHslatCount )
     215           0 :               fSlatEfficiency[fgkNchambers*hType+ich] = auxHisto;
     216             : 
     217           0 :             AliDebug(5,Form("Creating histogram %s\n",auxHisto->GetName()));
     218           0 :           }
     219           0 :           else if ( hType == kAllTracks ){
     220           0 :             for ( Int_t icath=0; icath<2; icath++){
     221           0 :               if ( ide == kHboardCount )
     222           0 :                 fBoardEfficiency[fgkNchambers*icath+ich]->Divide(histo);
     223           0 :               else if ( ide == kHslatCount )
     224           0 :                 fSlatEfficiency[fgkNchambers*icath+ich]->Divide(histo);
     225             :             }
     226           0 :           }
     227             :         } // loop on count types
     228             :       } // loop on chambers
     229             :     } // loop on detection element type
     230             : 
     231           0 :     file->Close();
     232           0 : }
     233             : 
     234             : 
     235             : //__________________________________________________________________________
     236             : const Char_t*
     237             : AliMUONTriggerEfficiencyCells::GetHistoName(Int_t histoType, Int_t countType, 
     238             :                                             Int_t chamber)
     239             : {
     240             :   //
     241             :   /// Return the name of the histogram for efficiency calculation
     242             :   //
     243         160 :   TString histoTypeName[kNcounts] = {"bendPlane", "nonBendPlane", "bothPlanes", "allTracks"};
     244             : 
     245          32 :   switch ( histoType ) {
     246             :   case kHchamberCount:
     247           0 :     return Form("%sCountChamber", histoTypeName[countType].Data());
     248             :   case kHslatCount:
     249          48 :     return Form("%sCountSlatCh%i", histoTypeName[countType].Data(), 11+chamber);
     250             :   case kHboardCount:
     251          48 :     return Form("%sCountBoardCh%i", histoTypeName[countType].Data(), 11+chamber);
     252             :   }
     253             : 
     254           0 :   return 0x0;
     255         192 : }
     256             : 
     257             : //__________________________________________________________________________
     258             : TH1F* AliMUONTriggerEfficiencyCells::GetOldEffHisto(Int_t histoType,
     259             :                                                     Int_t ich, Int_t icath) const
     260             : {
     261             :   //
     262             :   /// Compatibility with old class
     263             :   /// Gets the efficiency from the array
     264             :   /// (which are empty in the new implementation)
     265             : 
     266           0 :   switch ( histoType ) {
     267             :   case kHboardCount:
     268           0 :     return fBoardEfficiency[fgkNchambers*icath+ich];
     269             :   case kHslatCount:
     270           0 :     return fSlatEfficiency[fgkNchambers*icath+ich];
     271             :   }
     272           0 :   return 0x0;
     273           0 : }

Generated by: LCOV version 1.11