1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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
22 //____________________________________________________________________
24 // This class stores a pedestal and pedestal width for each strip in
26 // The values are stored as floats, since they may be results from a
28 // Need to make algorithm that makes this data
30 #include "AliFMDCalibPedestal.h" // ALIFMDCALIBPEDESTAL_H
34 #include "AliFMDDebug.h"
35 #include "AliFMDBoolMap.h"
37 //____________________________________________________________________
38 ClassImp(AliFMDCalibPedestal)
40 ; // This is here to keep Emacs for indenting the next line
43 //____________________________________________________________________
44 AliFMDCalibPedestal::AliFMDCalibPedestal()
45 : fValue(0), // nDet == 0 mean 51200 entries
46 fWidth(0) // nDet == 0 mean 51200 entries
53 //____________________________________________________________________
54 AliFMDCalibPedestal::AliFMDCalibPedestal(const AliFMDCalibPedestal& o)
62 //____________________________________________________________________
64 AliFMDCalibPedestal::operator=(const AliFMDCalibPedestal& o)
66 // Assignment operator
72 //____________________________________________________________________
74 AliFMDCalibPedestal::Set(UShort_t det, Char_t ring, UShort_t sec,
75 UShort_t str, Float_t ped, Float_t pedW)
77 // set value and width for a strip
78 if (fValue.CheckIndex(det, ring, sec, str) < 0) return;
79 fValue(det, ring, sec, str) = ped;
80 fWidth(det, ring, sec, str) = pedW;
83 //____________________________________________________________________
85 AliFMDCalibPedestal::Value(UShort_t det, Char_t ring, UShort_t sec,
88 // Get pedestal value for a strip
89 return fValue(det, ring, sec, str);
92 //____________________________________________________________________
94 AliFMDCalibPedestal::Width(UShort_t det, Char_t ring, UShort_t sec,
97 // Get pedestal width for a strip
98 return fWidth(det, ring, sec, str);
101 //____________________________________________________________________
103 struct MakeDead : public AliFMDMap::ForOne
105 MakeDead(AliFMDBoolMap* dead, Float_t max)
106 : fDead(dead), fMax(max), fCount(0)
108 MakeDead(const MakeDead& other)
109 : AliFMDMap::ForOne(other),
110 fDead(other.fDead), fMax(other.fMax), fCount(other.fCount)
112 MakeDead& operator=(const MakeDead& other)
116 fCount = other.fCount;
119 Bool_t operator()(UShort_t d, Char_t r, UShort_t s, UShort_t t, Float_t v)
121 AliDebugGeneral("AliFMDCalibPedestal::MakeDeadMap", 100,
122 Form("Checking if noise of FMD%d%c[%2d,%3d]=%f "
123 "is larger than %f", d, r, s, t, v, fMax));
125 fDead->operator()(d,r,s,t) = kTRUE;
130 Bool_t operator()(UShort_t, Char_t, UShort_t, UShort_t, Int_t)
132 Bool_t operator()(UShort_t, Char_t, UShort_t, UShort_t, UShort_t)
134 Bool_t operator()(UShort_t, Char_t, UShort_t, UShort_t, Bool_t)
136 AliFMDBoolMap* fDead;
142 //____________________________________________________________________
144 AliFMDCalibPedestal::MakeDeadMap(Float_t maxW, AliFMDBoolMap* dead) const
147 // Make a dead map based on the noise of the channels. If the noise
148 // of a paraticular channel is larger than @a maxW, then the channel
149 // is marked as dead.
151 // If the argument @a dead is non-null, then the map passed is
152 // modified. That is, channels marked as dead in the map will
153 // remain marked. Channels that meat the criterion (noise larger
154 // than @a maxW) will in addition be marked as dead.
156 // If the argument @a dead is null, then a new map is created and a
157 // pointer to this will be returned.
160 // maxW Maximum value of noise for a channel before it is
162 // dead If non-null, then modify this map.
165 // A pointer to possibly newly allocated dead map.
168 dead = new AliFMDBoolMap(0,0,0,0);
171 MakeDead dm(dead, maxW);
173 AliFMDDebug(1, ("Found a total of %d dead channels", dm.fCount));
177 //____________________________________________________________________
179 AliFMDCalibPedestal::ReadFromFile(std::istream& in)
182 // Read information from file and set values
190 if(!header.Contains("pedestals")) {
191 AliError("File does not contain pedestals!");
200 while(in.peek()!=EOF) {
202 AliError(Form("Bad read at line %d in input", lineno));
205 UShort_t det, sec, strip;
207 Float_t ped, noise, mu, sigma, chi2ndf;
221 Set(det,ring,sec,strip,ped,noise);
225 //____________________________________________________________________