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 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
21 //____________________________________________________________________
23 // Gain value and width for each strip in the FMD.
29 #include "AliFMDCalibGain.h" // ALIFMDCALIBGAIN_H
33 #include "AliFMDDebug.h"
35 #include "AliFMDBoolMap.h"
38 //____________________________________________________________________
39 ClassImp(AliFMDCalibGain)
41 ; // This is here to keep Emacs for indenting the next line
44 //____________________________________________________________________
45 AliFMDCalibGain::AliFMDCalibGain()
46 : fValue(0), // nDet == 0 mean 51200 slots
54 //____________________________________________________________________
55 AliFMDCalibGain::AliFMDCalibGain(const AliFMDCalibGain& o)
58 fThreshold(o.fThreshold)
63 //____________________________________________________________________
65 AliFMDCalibGain::operator=(const AliFMDCalibGain& o)
67 // Assignment operator
68 if (&o == this) return *this;
70 fThreshold = o.fThreshold;
74 //____________________________________________________________________
76 AliFMDCalibGain::Set(UShort_t det, Char_t ring, UShort_t sec,
77 UShort_t str, Float_t val)
79 // Set the value for a strip
80 if (fValue.CheckIndex(det, ring, sec, str) < 0) return;
81 fValue(det, ring, sec, str) = val;
84 //____________________________________________________________________
86 AliFMDCalibGain::Value(UShort_t det, Char_t ring, UShort_t sec,
89 // Get the value for a strip
90 return fValue(det, ring, sec, str);
93 //____________________________________________________________________
95 struct MakeDead : public AliFMDMap::ForOne
97 MakeDead(AliFMDBoolMap* dead, Float_t min, Float_t max)
98 : fDead(dead), fMin(min), fMax(max), fCount(0)
100 MakeDead(const MakeDead& other)
101 : AliFMDMap::ForOne(other),
102 fDead(other.fDead), fMin(other.fMin), fMax(other.fMax),
105 MakeDead& operator=(const MakeDead& other)
107 if (&other == this) return *this;
111 fCount = other.fCount;
114 Bool_t operator()(UShort_t d, Char_t r, UShort_t s, UShort_t t, Float_t v)
116 AliDebugGeneral("AliFMDCalibGain::MakeDeadMap", 100,
117 Form("Checking if gain of FMD%d%c[%2d,%3d]=%f "
118 "is out of range [%f,%f]",
119 d, r, s, t, v, fMin, fMax));
120 if (v > fMax || v < fMin) {
121 fDead->operator()(d,r,s,t) = kTRUE;
126 Bool_t operator()(UShort_t, Char_t, UShort_t, UShort_t, Int_t)
128 Bool_t operator()(UShort_t, Char_t, UShort_t, UShort_t, UShort_t)
130 Bool_t operator()(UShort_t, Char_t, UShort_t, UShort_t, Bool_t)
132 AliFMDBoolMap* fDead;
139 //____________________________________________________________________
141 AliFMDCalibGain::MakeDeadMap(Float_t min, Float_t max,
142 AliFMDBoolMap* dead) const
145 dead = new AliFMDBoolMap(0,0,0,0);
148 MakeDead dm(dead, min, max);
150 AliFMDDebug(1, ("Found a total of %d dead channels", dm.fCount));
154 //____________________________________________________________________
156 AliFMDCalibGain::ReadFromFile(std::istream& in)
158 //Get header (how long is it ?)
162 if(!header.Contains("gains")) {
163 AliError("File does not contain gains!");
167 // Read column headers
172 while(in.peek()!=EOF) {
174 AliError(Form("Bad read at line %d of input", lineno));
177 UShort_t det, sec, strip;
180 Float_t gain,error, chi2ndf;
191 Set(det,ring,sec,strip,gain);
195 //____________________________________________________________________