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