LCOV - code coverage report
Current view: top level - FMD/FMDbase - AliFMDCalibStripRange.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 12 62 19.4 %
Date: 2016-06-14 17:26:59 Functions: 5 11 45.5 %

          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    AliFMDCalibStripRange.cxx
      17             :     @author  Christian Holm Christensen <cholm@nbi.dk>
      18             :     @date    Sun Mar 26 18:31:09 2006
      19             :     @brief   Per digitizer card pulser calibration 
      20             : */
      21             : //____________________________________________________________________
      22             : //                                                                          
      23             : // This class stores which strips are read-out.  
      24             : // In principle this can be set for each half-ring.   
      25             : // However, in real life, all the detectors will probably read out all
      26             : // strips, and dead areas can be handled off-line. 
      27             : // This information comes from DCS or the like.
      28             : //
      29             : // IMPORTANT:  The member function WriteToFile writes out the entries
      30             : // in the format 
      31             : //
      32             : //     det,ring,id,min,max
      33             : //
      34             : // Here, id is a number from 0 to 1, which represents the division in
      35             : // half-rings.  The mapping is as follows: 
      36             : //
      37             : //  Inner rings:              Outer Rings
      38             : //    id   Sectors   Board     id   Sectors   Board 
      39             : //   ----+---------+-------   ----+---------+-------
      40             : //     0 |  0 -  9 |  0x10     0  |  0 - 19 |  0x11
      41             : //     1 | 10 - 19 |  0x0      1  | 20 - 39 |  0x1
      42             : //
      43             : // The same mapping is used in the ReadFromFile member function
      44             : //
      45             : #include <iostream>
      46             : #include "AliFMDCalibStripRange.h"    // ALIFMDCALIBGAIN_H
      47             : #include "TString.h"
      48             : // #include "AliFMDParameters.h"           // ALIFMDPARAMETERS_H
      49             : 
      50             : //____________________________________________________________________
      51          12 : ClassImp(AliFMDCalibStripRange)
      52             : #if 0
      53             :   ; // This is here to keep Emacs for indenting the next line
      54             : #endif
      55             : 
      56             : //____________________________________________________________________
      57           3 : AliFMDCalibStripRange::AliFMDCalibStripRange()
      58           3 :   : fRanges(AliFMDMap::kMaxDetectors, AliFMDMap::kMaxRings, 2, 1)
      59             :   // fRanges(3)
      60          15 : {
      61             :   // CTOR 
      62           3 :   fRanges.Reset(1);
      63           6 : }
      64             : 
      65             : //____________________________________________________________________
      66             : AliFMDCalibStripRange::AliFMDCalibStripRange(const AliFMDCalibStripRange& o)
      67           0 :   : TObject(o), fRanges(o.fRanges)
      68           0 : {
      69             :   // Copy CTOR 
      70           0 : }
      71             : 
      72             : //____________________________________________________________________
      73             : AliFMDCalibStripRange&
      74             : AliFMDCalibStripRange::operator=(const AliFMDCalibStripRange& o)
      75             : {
      76             :   // Assignement operator
      77           0 :   fRanges     = o.fRanges;
      78           0 :   return (*this);
      79             : }
      80             : 
      81             : //____________________________________________________________________
      82             : void
      83             : AliFMDCalibStripRange::Set(UShort_t det, Char_t ring, 
      84             :                            UShort_t sector, UShort_t, UShort_t min, 
      85             :                            UShort_t max)
      86             : {
      87             :   // Set the min and max for a half-ring 
      88           0 :   UInt_t nSec  = (ring == 'I' ? 10 : 20);
      89           0 :   UInt_t board = sector / nSec;
      90           0 :   fRanges(det, ring, board, 0) = ((max & 0x7f) << 8) + (min & 0x7f);
      91           0 : }
      92             : 
      93             : //____________________________________________________________________
      94             : UShort_t
      95             : AliFMDCalibStripRange::Min(UShort_t det, Char_t ring, 
      96             :                            UShort_t sec, UShort_t) const
      97             : {
      98             :   // Get the min for a half-ring 
      99     1641600 :   UInt_t nSec  = (ring == 'I' ? 10 : 20);
     100      820800 :   UInt_t board = sec / nSec;
     101             :  
     102      820800 :   return (fRanges(det, ring, board, 0) & 0x7f);
     103             : }
     104             : 
     105             : //____________________________________________________________________
     106             : UShort_t
     107             : AliFMDCalibStripRange::Max(UShort_t det, Char_t ring, 
     108             :                            UShort_t sec, UShort_t) const
     109             : {
     110             :   // Get the max for a half-ring 
     111        3200 :   UInt_t nSec  = (ring == 'I' ? 10 : 20);
     112        1600 :   UInt_t board = sec / nSec;
     113        1600 :   return ((fRanges(det, ring, board, 0) >> 8) & 0x7f);
     114             : }
     115             : //____________________________________________________________________
     116             : void 
     117             : AliFMDCalibStripRange::WriteToFile(std::ostream &outFile, Bool_t* detectors)
     118             : {
     119           0 :   outFile.write("# StripRange \n",14);
     120           0 :   for(Int_t det=1;det<=3;det++) {
     121           0 :     if (detectors && !detectors[det-1]) { 
     122             :       continue;
     123             :     }
     124           0 :     UShort_t FirstRing = (det == 1 ? 1 : 0);
     125           0 :     for (UShort_t ir = FirstRing; ir < 2; ir++) {
     126           0 :       Char_t   ring = (ir == 0 ? 'O' : 'I');
     127           0 :       UInt_t   nSec = (ring == 'I' ? 10 : 20);
     128           0 :       for(UShort_t board =0; board < 2;  board++)  {
     129           0 :         UShort_t sector = board*nSec;
     130           0 :         outFile << det                     << ','
     131           0 :                 << ring                    << ','
     132           0 :                 << board                   << ','
     133           0 :                 << Min(det,ring,sector)    << ','
     134           0 :                 << Max(det,ring,sector)    << "\n";
     135             :           
     136             : 
     137             :       }
     138             :     }
     139           0 :   }
     140             :  
     141             :       
     142           0 : }
     143             : //____________________________________________________________________
     144             : void 
     145             : AliFMDCalibStripRange::ReadFromFile(std::istream &inFile)
     146             : {
     147           0 :   TString line;
     148             :   Bool_t readData=kFALSE;
     149             : 
     150           0 :   while(line.ReadLine(inFile)) {
     151           0 :     if(line.Contains("striprange",TString::kIgnoreCase)) {
     152             :       readData = kTRUE;
     153           0 :       break;
     154             :     }
     155             :     
     156             :   }
     157             :   
     158           0 :   UShort_t det, board;
     159           0 :   Char_t ring;
     160           0 :   UShort_t min, max;
     161             :   
     162           0 :   Int_t thisline = inFile.tellg();
     163           0 :   Char_t c[4];
     164             :   
     165           0 :   while( readData ) {
     166           0 :     thisline = inFile.tellg();
     167           0 :     line.ReadLine(inFile);
     168             :    
     169           0 :       if(line.Contains("# ",TString::kIgnoreCase)) {
     170             :         readData = kFALSE;
     171           0 :         continue;
     172             :       }
     173             :     
     174           0 :     inFile.seekg(thisline);
     175           0 :     inFile     >> det          >> c[0]
     176           0 :                >> ring         >> c[1]
     177           0 :                >> board        >> c[2]
     178           0 :                >> min          >> c[3]
     179           0 :                >> max;
     180             :     
     181           0 :     UInt_t nSec  = (ring == 'I' ? 10 : 20);
     182           0 :     UShort_t sector = board*nSec;
     183           0 :     Set(det,ring,sector,0,min,max);
     184             :    
     185             :   }
     186             :   
     187           0 :   inFile.seekg(0);
     188             :  
     189             :   
     190           0 : }
     191             : 
     192             : //____________________________________________________________________
     193             : //
     194             : // EOF
     195             : //

Generated by: LCOV version 1.11