]> git.uio.no Git - u/mrichter/AliRoot.git/blame - FMD/AliFMDCalibSampleRate.cxx
Coding rule violations fixed.
[u/mrichter/AliRoot.git] / FMD / AliFMDCalibSampleRate.cxx
CommitLineData
8f6ee336 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 **************************************************************************/
8f6ee336 15/* $Id$ */
c2fc1258 16/** @file AliFMDCalibSampleRate.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*/
8f6ee336 21//____________________________________________________________________
22//
02a27b50 23// This class stores the sample rate (that is, how many times the
24// ATLRO's sample each VA1 channel). In principle these can be
25// controlled per half ring, but in real life it's most likely that
26// this value will be the same for all detectors. This value must be
27// retrived from DCS or the like.
8f6ee336 28//
29#include "AliFMDCalibSampleRate.h" // ALIFMDCALIBGAIN_H
6169f936 30// #include "AliFMDParameters.h" // ALIFMDPARAMETERS_H
f95a63c4 31// #include <AliLog.h>
bd727bee 32#include "TString.h"
f95a63c4 33#include "AliFMDDebug.h" // Better debug macros
43a19191 34#include "iostream"
8f6ee336 35
36//____________________________________________________________________
37ClassImp(AliFMDCalibSampleRate)
38#if 0
39 ; // This is here to keep Emacs for indenting the next line
40#endif
41
42//____________________________________________________________________
43AliFMDCalibSampleRate::AliFMDCalibSampleRate()
c2fc1258 44 : fRates(AliFMDMap::kMaxDetectors, AliFMDMap::kMaxRings, 2, 1)
45 // fRates(3)
8f6ee336 46{
02a27b50 47 // CTOR
c2fc1258 48 fRates.Reset(1);
8f6ee336 49}
50
51//____________________________________________________________________
52AliFMDCalibSampleRate::AliFMDCalibSampleRate(const AliFMDCalibSampleRate& o)
53 : TObject(o), fRates(o.fRates)
02a27b50 54{
55 // Copy ctor
56}
8f6ee336 57
58//____________________________________________________________________
59AliFMDCalibSampleRate&
60AliFMDCalibSampleRate::operator=(const AliFMDCalibSampleRate& o)
61{
02a27b50 62 // Assignment operator
8f6ee336 63 fRates = o.fRates;
64 return (*this);
65}
66
67//____________________________________________________________________
68void
c2fc1258 69AliFMDCalibSampleRate::Set(UShort_t det, Char_t ring,
70 UShort_t sector, UShort_t, UShort_t rate)
8f6ee336 71{
02a27b50 72 // Set values. Strip argument is ignored
43a19191 73 UInt_t nSec = (ring == 'I' ? 10 : 20);
c2fc1258 74 UInt_t board = sector / nSec;
75 fRates(det, ring, board, 0) = rate;
43a19191 76
8f6ee336 77}
78
79//____________________________________________________________________
80UShort_t
c2fc1258 81AliFMDCalibSampleRate::Rate(UShort_t det, Char_t ring,
82 UShort_t sec, UShort_t) const
8f6ee336 83{
02a27b50 84 // Get the sample rate
1f435e0c 85 UInt_t nSec = (ring == 'I' ? 10 : 20);
86 UInt_t board = sec / nSec;
87 UShort_t ret = fRates(det, ring, board, 0);
ef8e8623 88 AliFMDDebug(15, ("Getting sample rate for FMD%d%c[%2d,0] (board %d): %d",
1f435e0c 89 det, ring, sec, board, ret));
90 return ret;
8f6ee336 91}
bd727bee 92//____________________________________________________________________
93void
94AliFMDCalibSampleRate::WriteToFile(ofstream &outFile)
95{
96 outFile.write("# SampleRate \n",14);
97 for(Int_t det=1;det<=3;det++) {
98 UShort_t FirstRing = (det == 1 ? 1 : 0);
99 for (UShort_t ir = FirstRing; ir < 2; ir++) {
100 Char_t ring = (ir == 0 ? 'O' : 'I');
8f3f0bec 101 // UShort_t nsec = (ir == 0 ? 40 : 20);
102
103 for(UShort_t board = 0; board < 2; board++) {
104 outFile << det << ','
105 << ring << ','
106 << board << ','
107 << Rate(det,ring,board) << "\n";
bd727bee 108
109
110 }
111 }
112 }
113
114
115}
116//____________________________________________________________________
117void
118AliFMDCalibSampleRate::ReadFromFile(ifstream &inFile)
119{
120 TString line;
121 Bool_t readData=kFALSE;
122
123 while(line.ReadLine(inFile)) {
124 if(line.Contains("samplerate",TString::kIgnoreCase)) {
125 readData = kTRUE;
126 break;
127 }
128
129 }
130
8f3f0bec 131 UShort_t det, board;
bd727bee 132 Char_t ring;
133 UShort_t sampleRate;
134 Int_t thisline = inFile.tellg();
135 Char_t c[3];
136
43a19191 137 while( readData ) {
bd727bee 138 thisline = inFile.tellg();
43a19191 139 line.ReadLine(inFile);
bd727bee 140 if(line.Contains("# ",TString::kIgnoreCase)) {
141 readData = kFALSE;
142 continue;
143 }
144
145 inFile.seekg(thisline);
146 inFile >> det >> c[0]
147 >> ring >> c[1]
8f3f0bec 148 >> board >> c[2]
bd727bee 149 >> sampleRate;
150
8f3f0bec 151 UInt_t nSec = (ring == 'I' ? 10 : 20);
152 UShort_t sector = board*nSec;
153 Set(det,ring,sector,0,sampleRate);
43a19191 154
155
bd727bee 156 }
157
158 inFile.seekg(0);
159
160
161}
8f6ee336 162
163//____________________________________________________________________
164//
165// EOF
166//