LCOV - code coverage report
Current view: top level - FMD/FMDbase - AliFMDCalibPedestal.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 10 72 13.9 %
Date: 2016-06-14 17:26:59 Functions: 5 20 25.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             : /* $Id$ */
      16             : /** @file    AliFMDCalibPedestal.cxx
      17             :     @author  Christian Holm Christensen <cholm@nbi.dk>
      18             :     @date    Sun Mar 26 18:30:36 2006
      19             :     @brief   Per strip pedestal calibration 
      20             :     @ingroup FMD_base
      21             : */
      22             : //____________________________________________________________________
      23             : //                                                                          
      24             : // This class stores a pedestal and pedestal width for each strip in
      25             : // the FMD detectors. 
      26             : // The values are stored as floats, since they may be results from a
      27             : // fit. 
      28             : // Need to make algorithm that makes this data
      29             : //
      30             : #include "AliFMDCalibPedestal.h"      // ALIFMDCALIBPEDESTAL_H
      31             : #include <iostream>
      32             : #include <TString.h>
      33             : #include <AliLog.h>
      34             : #include "AliFMDDebug.h"
      35             : #include "AliFMDBoolMap.h"
      36             : 
      37             : //____________________________________________________________________
      38          12 : ClassImp(AliFMDCalibPedestal)
      39             : #if 0
      40             :   ; // This is here to keep Emacs for indenting the next line
      41             : #endif
      42             : 
      43             : //____________________________________________________________________
      44           3 : AliFMDCalibPedestal::AliFMDCalibPedestal()
      45           3 :   : fValue(0), // nDet == 0 mean 51200 entries 
      46           3 :     fWidth(0)  // nDet == 0 mean 51200 entries
      47          15 : {
      48             :   // CTOR 
      49           3 :   fValue.Reset(-1.);
      50           3 :   fWidth.Reset(-1.);
      51           6 : }
      52             : 
      53             : //____________________________________________________________________
      54             : AliFMDCalibPedestal::AliFMDCalibPedestal(const AliFMDCalibPedestal& o)
      55           0 :   : TObject(o), 
      56           0 :     fValue(o.fValue), 
      57           0 :     fWidth(o.fWidth)
      58           0 : {
      59             :   // Copy Ctor 
      60           0 : }
      61             : 
      62             : //____________________________________________________________________
      63             : AliFMDCalibPedestal&
      64             : AliFMDCalibPedestal::operator=(const AliFMDCalibPedestal& o)
      65             : {
      66             :   // Assignment operator 
      67           0 :   if (&o == this) return *this; 
      68           0 :   fValue = o.fValue;
      69           0 :   fWidth = o.fWidth;
      70           0 :   return (*this);
      71           0 : }
      72             : 
      73             : //____________________________________________________________________
      74             : void
      75             : AliFMDCalibPedestal::Set(UShort_t det, Char_t ring, UShort_t sec, 
      76             :                          UShort_t str, Float_t ped, Float_t pedW)
      77             : {
      78             :   // set value and width for a strip 
      79           0 :   if (fValue.CheckIndex(det, ring, sec, str) < 0) return;
      80           0 :   fValue(det, ring, sec, str) = ped;
      81           0 :   fWidth(det, ring, sec, str) = pedW;
      82           0 : }
      83             : 
      84             : //____________________________________________________________________
      85             : Float_t
      86             : AliFMDCalibPedestal::Value(UShort_t det, Char_t ring, UShort_t sec, 
      87             :                            UShort_t str)
      88             : {
      89             :   // Get pedestal value for a strip 
      90     2867200 :   return fValue(det, ring, sec, str);
      91             : }
      92             : 
      93             : //____________________________________________________________________
      94             : Float_t
      95             : AliFMDCalibPedestal::Width(UShort_t det, Char_t ring, UShort_t sec, 
      96             :                            UShort_t str)
      97             : {
      98             :   // Get pedestal width for a strip 
      99     2867200 :   return fWidth(det, ring, sec, str);
     100             : }
     101             : 
     102             : //____________________________________________________________________
     103             : namespace {
     104           0 :   struct MakeDead : public AliFMDMap::ForOne
     105             :   {
     106           0 :     MakeDead(AliFMDBoolMap* dead, Float_t max) 
     107           0 :       : fDead(dead), fMax(max), fCount(0)
     108           0 :     {}
     109             :     MakeDead(const MakeDead& other) 
     110             :       : AliFMDMap::ForOne(other),
     111             :         fDead(other.fDead), fMax(other.fMax), fCount(other.fCount)
     112             :     {}
     113             :     MakeDead& operator=(const MakeDead& other) 
     114             :     { 
     115             :       if (&other == this) return *this; 
     116             :       fDead   = other.fDead;
     117             :       fMax    = other.fMax;
     118             :       fCount  = other.fCount;
     119             :       return *this;
     120             :     }
     121             :     Bool_t operator()(UShort_t d, Char_t r, UShort_t s, UShort_t t, Float_t v)
     122             :     {
     123           0 :       AliDebugGeneral("AliFMDCalibPedestal::MakeDeadMap", 100, 
     124             :                       Form("Checking if noise of FMD%d%c[%2d,%3d]=%f "
     125             :                               "is larger than %f", d, r, s, t, v, fMax));
     126           0 :       if (v > fMax) {
     127           0 :         fDead->operator()(d,r,s,t) = kTRUE;
     128           0 :         fCount++;
     129           0 :       }
     130           0 :       return kTRUE;
     131             :     }
     132             :     Bool_t operator()(UShort_t, Char_t, UShort_t, UShort_t, Int_t) 
     133           0 :     { return kFALSE; }
     134             :     Bool_t operator()(UShort_t, Char_t, UShort_t, UShort_t, UShort_t)
     135           0 :     { return kFALSE; }
     136             :     Bool_t operator()(UShort_t, Char_t, UShort_t, UShort_t, Bool_t)
     137           0 :     { return kFALSE; }
     138             :     AliFMDBoolMap* fDead;
     139             :     Float_t        fMax;
     140             :     Int_t          fCount;
     141             :   };
     142             : }
     143             : 
     144             : //____________________________________________________________________
     145             : AliFMDBoolMap*
     146             : AliFMDCalibPedestal::MakeDeadMap(Float_t maxW, AliFMDBoolMap* dead) const
     147             : {
     148             :   // 
     149             :   // Make a dead map based on the noise of the channels.  If the noise
     150             :   // of a paraticular channel is larger than @a maxW, then the channel
     151             :   // is marked as dead. 
     152             :   //
     153             :   // If the argument @a dead is non-null, then the map passed is
     154             :   // modified.  That is, channels marked as dead in the map will
     155             :   // remain marked.   Channels that meat the criterion (noise larger
     156             :   // than @a maxW) will in addition be marked as dead. 
     157             :   //
     158             :   // If the argument @a dead is null, then a new map is created and a
     159             :   // pointer to this will be returned. 
     160             :   // 
     161             :   // Parameters:
     162             :   //    maxW Maximum value of noise for a channel before it is
     163             :   // marked as dead. 
     164             :   //    dead If non-null, then modify this map. 
     165             :   // 
     166             :   // Return:
     167             :   //    A pointer to possibly newly allocated dead map. 
     168             :   //
     169           0 :  if (!dead) { 
     170           0 :     dead = new AliFMDBoolMap(0,0,0,0);
     171           0 :     dead->Reset(kFALSE);
     172           0 :   }
     173           0 :   MakeDead dm(dead, maxW);
     174           0 :   fWidth.ForEach(dm);
     175           0 :   AliFMDDebug(1, ("Found a total of %d dead channels", dm.fCount));
     176             :   return dead;
     177           0 : }
     178             : 
     179             : //____________________________________________________________________
     180             : Bool_t
     181             : AliFMDCalibPedestal::ReadFromFile(std::istream& in)
     182             : {
     183             :   //
     184             :   // Read information from file and set values
     185             :   // 
     186             :   // Parameters:
     187             :   //    inFile inputFile
     188             :   //
     189           0 :   TString header;
     190           0 :   header.ReadLine(in);
     191           0 :   header.ToLower();
     192           0 :   if(!header.Contains("pedestals")) {
     193           0 :     AliError("File does not contain pedestals!");
     194           0 :     return kFALSE;
     195             :   }
     196             :     
     197             :   // Read columns line
     198             :   int lineno = 2;
     199           0 :   header.ReadLine(in);
     200             :     
     201             :   // Loop until EOF
     202           0 :   while(in.peek()!=EOF) {
     203           0 :     if(in.bad()) { 
     204           0 :       AliError(Form("Bad read at line %d in input", lineno));
     205             :       break;
     206             :     }
     207           0 :     UShort_t det, sec, strip;
     208           0 :     Char_t ring;
     209           0 :     Float_t ped, noise, mu, sigma, chi2ndf;
     210           0 :     Char_t c[8];
     211             :           
     212           0 :     in >> det      >> c[0] 
     213           0 :        >> ring     >> c[1]
     214           0 :        >> sec      >> c[2]
     215           0 :        >> strip    >> c[3]
     216           0 :        >> ped      >> c[4]
     217           0 :        >> noise    >> c[5]
     218           0 :        >> mu       >> c[6]
     219           0 :        >> sigma    >> c[7]
     220           0 :        >> chi2ndf;
     221           0 :     lineno++;
     222             :       
     223           0 :     Set(det,ring,sec,strip,ped,noise);
     224           0 :   }
     225             :   return kTRUE;
     226           0 : }
     227             : //____________________________________________________________________
     228             : //
     229             : // EOF
     230             : //

Generated by: LCOV version 1.11