]>
Commit | Line | Data |
---|---|---|
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 | // |
bd8f72a4 | 29 | // IMPORTANT: The member function WriteToFile writes out the entries |
30 | // in the format | |
31 | // | |
32 | // det,ring,id,rate | |
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 | // | |
8f6ee336 | 45 | #include "AliFMDCalibSampleRate.h" // ALIFMDCALIBGAIN_H |
6169f936 | 46 | // #include "AliFMDParameters.h" // ALIFMDPARAMETERS_H |
f95a63c4 | 47 | // #include <AliLog.h> |
bd727bee | 48 | #include "TString.h" |
f95a63c4 | 49 | #include "AliFMDDebug.h" // Better debug macros |
408bf2b4 | 50 | #include <iostream> |
8f6ee336 | 51 | |
52 | //____________________________________________________________________ | |
53 | ClassImp(AliFMDCalibSampleRate) | |
54 | #if 0 | |
55 | ; // This is here to keep Emacs for indenting the next line | |
56 | #endif | |
57 | ||
58 | //____________________________________________________________________ | |
59 | AliFMDCalibSampleRate::AliFMDCalibSampleRate() | |
c2fc1258 | 60 | : fRates(AliFMDMap::kMaxDetectors, AliFMDMap::kMaxRings, 2, 1) |
61 | // fRates(3) | |
8f6ee336 | 62 | { |
02a27b50 | 63 | // CTOR |
c2fc1258 | 64 | fRates.Reset(1); |
8f6ee336 | 65 | } |
66 | ||
67 | //____________________________________________________________________ | |
68 | AliFMDCalibSampleRate::AliFMDCalibSampleRate(const AliFMDCalibSampleRate& o) | |
69 | : TObject(o), fRates(o.fRates) | |
02a27b50 | 70 | { |
71 | // Copy ctor | |
72 | } | |
8f6ee336 | 73 | |
74 | //____________________________________________________________________ | |
75 | AliFMDCalibSampleRate& | |
76 | AliFMDCalibSampleRate::operator=(const AliFMDCalibSampleRate& o) | |
77 | { | |
02a27b50 | 78 | // Assignment operator |
8f6ee336 | 79 | fRates = o.fRates; |
80 | return (*this); | |
81 | } | |
82 | ||
83 | //____________________________________________________________________ | |
84 | void | |
c2fc1258 | 85 | AliFMDCalibSampleRate::Set(UShort_t det, Char_t ring, |
86 | UShort_t sector, UShort_t, UShort_t rate) | |
8f6ee336 | 87 | { |
02a27b50 | 88 | // Set values. Strip argument is ignored |
43a19191 | 89 | UInt_t nSec = (ring == 'I' ? 10 : 20); |
c2fc1258 | 90 | UInt_t board = sector / nSec; |
91 | fRates(det, ring, board, 0) = rate; | |
bd8f72a4 | 92 | AliFMDDebug(15, ("Setting sample rate for FMD%d%c[%2d,0] (board %d): %d", |
93 | det, ring, sector, board, rate)); | |
43a19191 | 94 | |
8f6ee336 | 95 | } |
96 | ||
97 | //____________________________________________________________________ | |
98 | UShort_t | |
c2fc1258 | 99 | AliFMDCalibSampleRate::Rate(UShort_t det, Char_t ring, |
100 | UShort_t sec, UShort_t) const | |
8f6ee336 | 101 | { |
02a27b50 | 102 | // Get the sample rate |
1f435e0c | 103 | UInt_t nSec = (ring == 'I' ? 10 : 20); |
104 | UInt_t board = sec / nSec; | |
105 | UShort_t ret = fRates(det, ring, board, 0); | |
ef8e8623 | 106 | AliFMDDebug(15, ("Getting sample rate for FMD%d%c[%2d,0] (board %d): %d", |
1f435e0c | 107 | det, ring, sec, board, ret)); |
108 | return ret; | |
8f6ee336 | 109 | } |
bd727bee | 110 | //____________________________________________________________________ |
111 | void | |
408bf2b4 | 112 | AliFMDCalibSampleRate::WriteToFile(std::ostream &outFile, Bool_t* detectors) |
bd727bee | 113 | { |
114 | outFile.write("# SampleRate \n",14); | |
115 | for(Int_t det=1;det<=3;det++) { | |
408bf2b4 | 116 | if (detectors && !detectors[det-1]) { |
117 | continue; | |
118 | } | |
bd727bee | 119 | UShort_t FirstRing = (det == 1 ? 1 : 0); |
120 | for (UShort_t ir = FirstRing; ir < 2; ir++) { | |
121 | Char_t ring = (ir == 0 ? 'O' : 'I'); | |
bd8f72a4 | 122 | UShort_t nsec = (ir == 0 ? 40 : 20) / 2; |
8f3f0bec | 123 | |
124 | for(UShort_t board = 0; board < 2; board++) { | |
bd8f72a4 | 125 | UShort_t sector = board*nsec; |
126 | outFile << det << ',' | |
127 | << ring << ',' | |
128 | << board << ',' | |
129 | << Rate(det,ring,sector) << "\n"; | |
bd727bee | 130 | |
131 | ||
132 | } | |
133 | } | |
134 | } | |
135 | ||
136 | ||
137 | } | |
138 | //____________________________________________________________________ | |
139 | void | |
408bf2b4 | 140 | AliFMDCalibSampleRate::ReadFromFile(std::istream &inFile) |
bd727bee | 141 | { |
142 | TString line; | |
143 | Bool_t readData=kFALSE; | |
144 | ||
145 | while(line.ReadLine(inFile)) { | |
146 | if(line.Contains("samplerate",TString::kIgnoreCase)) { | |
147 | readData = kTRUE; | |
148 | break; | |
149 | } | |
150 | ||
151 | } | |
152 | ||
8f3f0bec | 153 | UShort_t det, board; |
bd727bee | 154 | Char_t ring; |
155 | UShort_t sampleRate; | |
156 | Int_t thisline = inFile.tellg(); | |
157 | Char_t c[3]; | |
158 | ||
43a19191 | 159 | while( readData ) { |
bd727bee | 160 | thisline = inFile.tellg(); |
43a19191 | 161 | line.ReadLine(inFile); |
bd727bee | 162 | if(line.Contains("# ",TString::kIgnoreCase)) { |
163 | readData = kFALSE; | |
164 | continue; | |
165 | } | |
166 | ||
167 | inFile.seekg(thisline); | |
168 | inFile >> det >> c[0] | |
169 | >> ring >> c[1] | |
8f3f0bec | 170 | >> board >> c[2] |
bd727bee | 171 | >> sampleRate; |
172 | ||
bd8f72a4 | 173 | UInt_t nSec = (ring == 'I' ? 20 : 40)/2; |
8f3f0bec | 174 | UShort_t sector = board*nSec; |
175 | Set(det,ring,sector,0,sampleRate); | |
43a19191 | 176 | |
177 | ||
bd727bee | 178 | } |
179 | ||
180 | inFile.seekg(0); | |
181 | ||
182 | ||
183 | } | |
8f6ee336 | 184 | |
185 | //____________________________________________________________________ | |
186 | // | |
187 | // EOF | |
188 | // |