]> git.uio.no Git - u/mrichter/AliRoot.git/blame - FMD/AliFMDCalibStripRange.cxx
Compatibility with the trunk of ROOT
[u/mrichter/AliRoot.git] / FMD / AliFMDCalibStripRange.cxx
CommitLineData
c2fc1258 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//
02a27b50 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.
c2fc1258 28//
bd8f72a4 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//
408bf2b4 45#include <iostream>
c2fc1258 46#include "AliFMDCalibStripRange.h" // ALIFMDCALIBGAIN_H
433a88bd 47#include "TString.h"
6169f936 48// #include "AliFMDParameters.h" // ALIFMDPARAMETERS_H
c2fc1258 49
50//____________________________________________________________________
51ClassImp(AliFMDCalibStripRange)
52#if 0
53 ; // This is here to keep Emacs for indenting the next line
54#endif
55
56//____________________________________________________________________
57AliFMDCalibStripRange::AliFMDCalibStripRange()
02a27b50 58 : fRanges(AliFMDMap::kMaxDetectors, AliFMDMap::kMaxRings, 2, 1)
59 // fRanges(3)
c2fc1258 60{
02a27b50 61 // CTOR
62 fRanges.Reset(1);
c2fc1258 63}
64
65//____________________________________________________________________
66AliFMDCalibStripRange::AliFMDCalibStripRange(const AliFMDCalibStripRange& o)
02a27b50 67 : TObject(o), fRanges(o.fRanges)
68{
69 // Copy CTOR
70}
c2fc1258 71
72//____________________________________________________________________
73AliFMDCalibStripRange&
74AliFMDCalibStripRange::operator=(const AliFMDCalibStripRange& o)
75{
02a27b50 76 // Assignement operator
77 fRanges = o.fRanges;
c2fc1258 78 return (*this);
79}
80
81//____________________________________________________________________
82void
83AliFMDCalibStripRange::Set(UShort_t det, Char_t ring,
84 UShort_t sector, UShort_t, UShort_t min,
85 UShort_t max)
86{
02a27b50 87 // Set the min and max for a half-ring
43a19191 88 UInt_t nSec = (ring == 'I' ? 10 : 20);
c2fc1258 89 UInt_t board = sector / nSec;
02a27b50 90 fRanges(det, ring, board, 0) = ((max & 0x7f) << 8) + (min & 0x7f);
c2fc1258 91}
92
93//____________________________________________________________________
94UShort_t
95AliFMDCalibStripRange::Min(UShort_t det, Char_t ring,
96 UShort_t sec, UShort_t) const
97{
02a27b50 98 // Get the min for a half-ring
43a19191 99 UInt_t nSec = (ring == 'I' ? 10 : 20);
c2fc1258 100 UInt_t board = sec / nSec;
43a19191 101
02a27b50 102 return (fRanges(det, ring, board, 0) & 0x7f);
c2fc1258 103}
104
105//____________________________________________________________________
106UShort_t
107AliFMDCalibStripRange::Max(UShort_t det, Char_t ring,
108 UShort_t sec, UShort_t) const
109{
02a27b50 110 // Get the max for a half-ring
43a19191 111 UInt_t nSec = (ring == 'I' ? 10 : 20);
c2fc1258 112 UInt_t board = sec / nSec;
02a27b50 113 return ((fRanges(det, ring, board, 0) >> 8) & 0x7f);
c2fc1258 114}
433a88bd 115//____________________________________________________________________
116void
408bf2b4 117AliFMDCalibStripRange::WriteToFile(std::ostream &outFile, Bool_t* detectors)
433a88bd 118{
119 outFile.write("# StripRange \n",14);
120 for(Int_t det=1;det<=3;det++) {
408bf2b4 121 if (detectors && !detectors[det-1]) {
122 continue;
123 }
433a88bd 124 UShort_t FirstRing = (det == 1 ? 1 : 0);
125 for (UShort_t ir = FirstRing; ir < 2; ir++) {
126 Char_t ring = (ir == 0 ? 'O' : 'I');
bd8f72a4 127 UInt_t nSec = (ring == 'I' ? 10 : 20);
8f3f0bec 128 for(UShort_t board =0; board < 2; board++) {
bd8f72a4 129 UShort_t sector = board*nSec;
8f3f0bec 130 outFile << det << ','
131 << ring << ','
132 << board << ','
bd8f72a4 133 << Min(det,ring,sector) << ','
134 << Max(det,ring,sector) << "\n";
433a88bd 135
136
137 }
138 }
139 }
140
141
142}
143//____________________________________________________________________
144void
408bf2b4 145AliFMDCalibStripRange::ReadFromFile(std::istream &inFile)
433a88bd 146{
147 TString line;
148 Bool_t readData=kFALSE;
149
150 while(line.ReadLine(inFile)) {
151 if(line.Contains("striprange",TString::kIgnoreCase)) {
152 readData = kTRUE;
153 break;
154 }
155
156 }
157
8f3f0bec 158 UShort_t det, board;
433a88bd 159 Char_t ring;
160 UShort_t min, max;
8f3f0bec 161
433a88bd 162 Int_t thisline = inFile.tellg();
163 Char_t c[4];
164
43a19191 165 while( readData ) {
433a88bd 166 thisline = inFile.tellg();
43a19191 167 line.ReadLine(inFile);
168
169 if(line.Contains("# ",TString::kIgnoreCase)) {
170 readData = kFALSE;
171 continue;
172 }
433a88bd 173
174 inFile.seekg(thisline);
175 inFile >> det >> c[0]
176 >> ring >> c[1]
8f3f0bec 177 >> board >> c[2]
433a88bd 178 >> min >> c[3]
179 >> max;
180
8f3f0bec 181 UInt_t nSec = (ring == 'I' ? 10 : 20);
182 UShort_t sector = board*nSec;
183 Set(det,ring,sector,0,min,max);
abdc44c9 184
433a88bd 185 }
186
187 inFile.seekg(0);
188
189
190}
c2fc1258 191
192//____________________________________________________________________
193//
194// EOF
195//