]> git.uio.no Git - u/mrichter/AliRoot.git/blame - FMD/AliFMDCalibGain.cxx
Fixed warning (Christian)
[u/mrichter/AliRoot.git] / FMD / AliFMDCalibGain.cxx
CommitLineData
a3537838 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 **************************************************************************/
a3537838 15/* $Id$ */
c2fc1258 16/** @file AliFMDCalibGain.cxx
17 @author Christian Holm Christensen <cholm@nbi.dk>
18 @date Sun Mar 26 18:30:02 2006
19 @brief Per strip gain calibration
20*/
a3537838 21//____________________________________________________________________
22//
02a27b50 23// Gain value and width for each strip in the FMD.
24// Foo
25// Bar
26// Baz
27// Gnus
a3537838 28//
29#include "AliFMDCalibGain.h" // ALIFMDCALIBGAIN_H
e064ab4a 30#include <iostream>
31#include <TString.h>
32#include <AliLog.h>
f560b28c 33#include "AliFMDDebug.h"
34
35#include "AliFMDBoolMap.h"
36
e064ab4a 37
a3537838 38//____________________________________________________________________
39ClassImp(AliFMDCalibGain)
40#if 0
41 ; // This is here to keep Emacs for indenting the next line
42#endif
43
44//____________________________________________________________________
45AliFMDCalibGain::AliFMDCalibGain()
021f1396 46 : fValue(0), // nDet == 0 mean 51200 slots
b5ee4425 47 fThreshold(-1.)
a3537838 48{
02a27b50 49 // CTOR
a3537838 50 fValue.Reset(-1.);
51 fThreshold = -1.;
52}
53
54//____________________________________________________________________
55AliFMDCalibGain::AliFMDCalibGain(const AliFMDCalibGain& o)
b5ee4425 56 : TObject(o),
57 fValue(o.fValue),
58 fThreshold(o.fThreshold)
02a27b50 59{
60 // Copy CTOR
61}
a3537838 62
63//____________________________________________________________________
64AliFMDCalibGain&
65AliFMDCalibGain::operator=(const AliFMDCalibGain& o)
66{
02a27b50 67 // Assignment operator
a3537838 68 fValue = o.fValue;
69 fThreshold = o.fThreshold;
70 return (*this);
71}
72
73//____________________________________________________________________
74void
75AliFMDCalibGain::Set(UShort_t det, Char_t ring, UShort_t sec,
76 UShort_t str, Float_t val)
77{
02a27b50 78 // Set the value for a strip
a3537838 79 if (fValue.CheckIndex(det, ring, sec, str) < 0) return;
80 fValue(det, ring, sec, str) = val;
81}
82
83//____________________________________________________________________
84Float_t
85AliFMDCalibGain::Value(UShort_t det, Char_t ring, UShort_t sec,
86 UShort_t str)
87{
02a27b50 88 // Get the value for a strip
a3537838 89 return fValue(det, ring, sec, str);
90}
91
f560b28c 92//____________________________________________________________________
93namespace {
94 struct MakeDead : public AliFMDMap::ForOne
95 {
96 MakeDead(AliFMDBoolMap* dead, Float_t min, Float_t max)
97 : fDead(dead), fMin(min), fMax(max), fCount(0)
98 {}
99 MakeDead(const MakeDead& other)
dbac3484 100 : AliFMDMap::ForOne(other),
101 fDead(other.fDead), fMin(other.fMin), fMax(other.fMax),
f560b28c 102 fCount(other.fCount)
103 {}
104 MakeDead& operator=(const MakeDead& other)
105 {
106 fDead = other.fDead;
107 fMin = other.fMin;
108 fMax = other.fMax;
109 fCount = other.fCount;
110 return *this;
111 }
112 Bool_t operator()(UShort_t d, Char_t r, UShort_t s, UShort_t t, Float_t v)
113 {
114 AliDebugGeneral("AliFMDCalibGain::MakeDeadMap", 100,
115 Form("Checking if gain of FMD%d%c[%2d,%3d]=%f "
116 "is out of range [%f,%f]",
117 d, r, s, t, v, fMin, fMax));
118 if (v > fMax || v < fMin) {
119 fDead->operator()(d,r,s,t) = kTRUE;
120 fCount++;
121 }
122 return kTRUE;
123 }
124 Bool_t operator()(UShort_t, Char_t, UShort_t, UShort_t, Int_t)
125 { return kFALSE; }
126 Bool_t operator()(UShort_t, Char_t, UShort_t, UShort_t, UShort_t)
127 { return kFALSE; }
128 Bool_t operator()(UShort_t, Char_t, UShort_t, UShort_t, Bool_t)
129 { return kFALSE; }
130 AliFMDBoolMap* fDead;
131 Float_t fMin;
132 Float_t fMax;
133 Int_t fCount;
134 };
135}
136
137//____________________________________________________________________
138AliFMDBoolMap*
139AliFMDCalibGain::MakeDeadMap(Float_t min, Float_t max,
140 AliFMDBoolMap* dead) const
141{
142 if (!dead) {
143 dead = new AliFMDBoolMap(0,0,0,0);
144 dead->Reset(kFALSE);
145 }
146 MakeDead dm(dead, min, max);
147 fValue.ForEach(dm);
148 AliFMDDebug(1, ("Found a total of %d dead channels", dm.fCount));
149 return dead;
150}
151
e064ab4a 152//____________________________________________________________________
153Bool_t
154AliFMDCalibGain::ReadFromFile(std::istream& in)
155{
156 //Get header (how long is it ?)
157 TString header;
158 header.ReadLine(in);
159 header.ToLower();
160 if(!header.Contains("gains")) {
161 AliError("File does not contain gains!");
162 return kFALSE;;
163 }
164
165 // Read column headers
166 header.ReadLine(in);
167
168 int lineno = 2;
169 // Read until EOF
170 while(in.peek()!=EOF) {
171 if(in.bad()) {
172 AliError(Form("Bad read at line %d of input", lineno));
173 break;
174 }
175 UShort_t det, sec, strip;
176 Char_t ring;
177
178 Float_t gain,error, chi2ndf;
179 Char_t c[6];
180
181 in >> det >> c[0]
182 >> ring >> c[1]
183 >> sec >> c[2]
184 >> strip >> c[3]
185 >> gain >> c[4]
186 >> error >> c[5]
187 >> chi2ndf;
188 lineno++;
189 Set(det,ring,sec,strip,gain);
190 }
191 return kTRUE;
192}
a3537838 193//____________________________________________________________________
194//
195// EOF
196//