]> git.uio.no Git - u/mrichter/AliRoot.git/blame - FMD/AliFMDCalibFaker.cxx
RICH becomes HMPID
[u/mrichter/AliRoot.git] / FMD / AliFMDCalibFaker.cxx
CommitLineData
20345ac5 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 **************************************************************************/
20345ac5 15/* $Id$ */
c2fc1258 16/** @file AliFMDCalibFaker.cxx
17 @author Christian Holm Christensen <cholm@nbi.dk>
18 @date Sun Mar 26 18:29:21 2006
19 @brief Make fake calibration data
02a27b50 20 @ingroup FMD_util
c2fc1258 21*/
20345ac5 22//____________________________________________________________________
23//
24// Forward Multiplicity Detector based on Silicon wafers.
25//
26// This task creates fake calibrations. Which calibration, depends on
27// the bit mask passed to the constructor, or added by `AddCalib'.
28//
29// The default is to write all calibration parameters to a local
6169f936 30// storage `local://$ALICE_ROOT' which is were the sources live (sigh!
31// - why oh why do we need to shit where we eat - it's just not
32// healty).
20345ac5 33//
34#include "AliLog.h" // ALILOG_H
35#include "AliFMDCalibFaker.h" // ALIFMDCALIBFAKER_H
36#include "AliFMDCalibGain.h" // ALIFMDCALIBGAIN_H
37#include "AliFMDCalibPedestal.h" // ALIFMDCALIBPEDESTAL_H
38#include "AliFMDCalibSampleRate.h" // ALIFMDCALIBPEDESTAL_H
39#include "AliFMDAltroMapping.h" // ALIFMDALTROMAPPING_H
c2fc1258 40#include "AliFMDCalibStripRange.h" // ALIFMDCALIBSTRIPRANGE_H
20345ac5 41#include <AliCDBManager.h> // ALICDBMANAGER_H
42#include <AliCDBEntry.h> // ALICDBMANAGER_H
02a27b50 43//#include <Riostream.h>
20345ac5 44#include <TSystem.h>
02a27b50 45// #include <TMath.h>
1e8f773e 46#include <TROOT.h>
20345ac5 47#include <TRandom.h>
48
49//====================================================================
50ClassImp(AliFMDCalibFaker)
51#if 0
52 ; // This is here to keep Emacs for indenting the next line
53#endif
54
55//____________________________________________________________________
56AliFMDCalibFaker::AliFMDCalibFaker(Int_t mask, const char* loc)
57 : TTask("FMDCalibFaker", loc),
58 fMask(mask),
59 fGain(-1),
60 fThresholdFactor(.1),
61 fThreshold(-1),
62 fPedestalMin(20),
63 fPedestalMax(30),
64 fDeadChance(0),
65 fRate(1),
66 fZeroThreshold(0),
67 fRunMin(0),
c2fc1258 68 fRunMax(10),
69 fStripMin(0),
70 fStripMax(127)
20345ac5 71{
72 // Default constructor
73}
74
75
76#define MAKE_META(meta) \
77 do { \
78 meta = new AliCDBMetaData; \
79 meta->SetResponsible(gSystem->GetUserInfo()->fRealName.Data()); \
80 meta->SetAliRootVersion(gROOT->GetVersion()); \
81 meta->SetBeamPeriod(1); \
82 meta->SetComment("Dummy data for testing"); } while (false);
83
84
85//__________________________________________________________________
86void
87AliFMDCalibFaker::Exec(Option_t*)
88{
89 // Make the objects.
90 AliCDBManager* cdb = AliCDBManager::Instance();
91 AliFMDParameters* param = AliFMDParameters::Instance();
8ec606c2 92 Float_t maxADC = 1.F*param->GetAltroChannelSize();
20345ac5 93 TObjArray cleanup;
94
c2fc1258 95 if (GetTitle() && GetTitle()[0] != '\0') {
96 AliInfo(Form("Setting default storage to '%s'", GetTitle()));
97 cdb->SetDefaultStorage(GetTitle());
98 }
99
20345ac5 100
101 AliCDBMetaData* meta = 0;
102 if (TESTBIT(fMask, kPulseGain)) {
8ec606c2 103 // Info("Exec","Default gain to %f = %d * %f / %d",
104 // (param->GetVA1MipRange() * param->GetEdepMip() / maxADC),
105 // param->GetVA1MipRange(), param->GetEdepMip(), Int_t(maxADC));
106 if (fGain <= 0) {
107 fGain = (param->GetVA1MipRange() * param->GetEdepMip() / maxADC);
108 }
20345ac5 109 fThreshold = fThresholdFactor * param->GetEdepMip();
110 AliFMDCalibGain* gain = MakePulseGain();
02a27b50 111 AliCDBId id(AliFMDParameters::PulseGainPath(), fRunMin, fRunMax);
20345ac5 112 MAKE_META(meta);
113 meta->SetProperty("key1", gain);
114 cdb->Put(gain, id, meta);
115 cleanup.Add(gain);
116 cleanup.Add(meta);
117 }
118 if (TESTBIT(fMask, kPedestal)) {
119 fPedestalMin = TMath::Max(TMath::Min(fPedestalMin, maxADC), 0.F);
120 fPedestalMax = TMath::Max(TMath::Min(fPedestalMax, maxADC), fPedestalMin);
121 AliFMDCalibPedestal* pedestal = MakePedestal();
8ec606c2 122 AliCDBId id(AliFMDParameters::PedestalPath(),fRunMin,fRunMax);
20345ac5 123 MAKE_META(meta);
124 meta->SetProperty("key1", pedestal);
125 cdb->Put(pedestal, id, meta);
126 cleanup.Add(pedestal);
127 cleanup.Add(meta);
128 }
129 if (TESTBIT(fMask, kDeadMap)) {
130 fDeadChance = TMath::Max(TMath::Min(fDeadChance, 1.F), 0.F);
131 AliFMDCalibDeadMap* deadMap = MakeDeadMap();
02a27b50 132 AliCDBId id(AliFMDParameters::DeadPath(), fRunMin, fRunMax);
20345ac5 133 MAKE_META(meta);
134 meta->SetProperty("key1", deadMap);
135 cdb->Put(deadMap, id, meta);
136 cleanup.Add(deadMap);
137 cleanup.Add(meta);
138 }
139 if (TESTBIT(fMask, kZeroSuppression)) {
140 fZeroThreshold = TMath::Min(fZeroThreshold, UShort_t(maxADC));
141 AliFMDCalibZeroSuppression* zeroSup = MakeZeroSuppression();
02a27b50 142 AliCDBId id(AliFMDParameters::ZeroSuppressionPath(),
20345ac5 143 fRunMin, fRunMax);
144 MAKE_META(meta);
145 meta->SetProperty("key1", zeroSup);
146 cdb->Put(zeroSup, id, meta);
147 cleanup.Add(zeroSup);
148 cleanup.Add(meta);
149 }
150 if (TESTBIT(fMask, kSampleRate)) {
151 fRate = TMath::Max(TMath::Min(fRate, UShort_t(8)), UShort_t(1));
152 AliFMDCalibSampleRate* rate = MakeSampleRate();
8ec606c2 153 AliCDBId id(AliFMDParameters::SampleRatePath(),
154 fRunMin,fRunMax);
20345ac5 155 MAKE_META(meta);
156 meta->SetProperty("key1", rate);
157 cdb->Put(rate, id, meta);
158 cleanup.Add(rate);
159 cleanup.Add(meta);
160 }
c2fc1258 161 if (TESTBIT(fMask, kStripRange)) {
162 fRate = TMath::Max(TMath::Min(fRate, UShort_t(8)), UShort_t(1));
163 AliFMDCalibStripRange* range = MakeStripRange();
8ec606c2 164 AliCDBId id(AliFMDParameters::StripRangePath(),
165 fRunMin,fRunMax);
c2fc1258 166 MAKE_META(meta);
167 meta->SetProperty("key1", range);
168 cdb->Put(range, id, meta);
169 cleanup.Add(range);
170 cleanup.Add(meta);
171 }
20345ac5 172 if (TESTBIT(fMask, kAltroMap)) {
173 AliFMDAltroMapping* altroMap = MakeAltroMap();
02a27b50 174 AliCDBId id(AliFMDParameters::AltroMapPath(), fRunMin, fRunMax);
20345ac5 175 MAKE_META(meta);
176 meta->SetProperty("key1", altroMap);
177 cdb->Put(altroMap, id, meta);
178 cleanup.Add(altroMap);
179 cleanup.Add(meta);
180 }
181 cdb->Destroy();
182 cleanup.Delete();
183}
184
185
186//__________________________________________________________________
187AliFMDCalibGain*
02a27b50 188AliFMDCalibFaker::MakePulseGain() const
20345ac5 189{
190 // Make the actual data
191 AliFMDCalibGain* gain = new AliFMDCalibGain;
192 // Set threshold
193 gain->Set(fThreshold);
194 for (UShort_t det = 1; det <= 3; det++) {
195 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
196 for (Char_t* ring = rings; *ring != '\0'; ring++) {
197 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
198 UShort_t nStr = ( *ring == 'I' ? 512 : 256 );
199 for (UShort_t sec = 0; sec < nSec; sec++) {
200 for (UShort_t str = 0; str < nStr; str++) {
201 gain->Set(det, *ring, sec, str,
202 gRandom->Gaus(fGain, .01 * fGain));
203 }
204 }
205 }
206 }
207 return gain;
208}
209
210//__________________________________________________________________
211AliFMDCalibPedestal*
02a27b50 212AliFMDCalibFaker::MakePedestal() const
20345ac5 213{
214 // Make the actual data
215 AliFMDCalibPedestal* pedestal = new AliFMDCalibPedestal;
216 for (UShort_t det = 1; det <= 3; det++) {
217 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
218 for (Char_t* ring = rings; *ring != '\0'; ring++) {
219 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
220 UShort_t nStr = ( *ring == 'I' ? 512 : 256 );
221 for (UShort_t sec = 0; sec < nSec; sec++) {
222 for (UShort_t str = 0; str < nStr; str++) {
223 pedestal->Set(det, *ring, sec, str,
224 gRandom->Uniform(fPedestalMin, fPedestalMax), 1.5);
225 }
226 }
227 }
228 }
229 return pedestal;
230}
231
232//__________________________________________________________________
233AliFMDCalibDeadMap*
02a27b50 234AliFMDCalibFaker::MakeDeadMap() const
20345ac5 235{
236 // Make the actual data
237 AliFMDCalibDeadMap* deadmap = new AliFMDCalibDeadMap;
238 for (UShort_t det = 1; det <= 3; det++) {
239 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
240 for (Char_t* ring = rings; *ring != '\0'; ring++) {
241 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
242 UShort_t nStr = ( *ring == 'I' ? 512 : 256 );
243 for (UShort_t sec = 0; sec < nSec; sec++) {
244 for (UShort_t str = 0; str < nStr; str++) {
245 deadmap->operator()(det, *ring, sec, str) =
246 gRandom->Uniform(0, 1) < fDeadChance;
247 }
248 }
249 }
250 }
251 return deadmap;
252}
253
254//__________________________________________________________________
255AliFMDCalibZeroSuppression*
02a27b50 256AliFMDCalibFaker::MakeZeroSuppression() const
20345ac5 257{
258 // Make the actual data
259 AliFMDCalibZeroSuppression* zs = new AliFMDCalibZeroSuppression;
260 for (UShort_t det = 1; det <= 3; det++) {
261 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
262 for (Char_t* ring = rings; *ring != '\0'; ring++) {
263 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
264 UShort_t nStr = ( *ring == 'I' ? 512 : 256 );
265 for (UShort_t sec = 0; sec < nSec; sec++) {
266 for (UShort_t str = 0; str < nStr; str++) {
267 zs->operator()(det, *ring, sec, str) = fZeroThreshold;
268 }
269 }
270 }
271 }
272 return zs;
273}
274
275//__________________________________________________________________
276AliFMDCalibSampleRate*
02a27b50 277AliFMDCalibFaker::MakeSampleRate() const
20345ac5 278{
02a27b50 279 // Make sample rates
20345ac5 280 AliFMDCalibSampleRate* sampleRate = new AliFMDCalibSampleRate;
c2fc1258 281 for (UShort_t det = 1; det <= 3; det++) {
282 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
283 for (Char_t* ring = rings; *ring != '\0'; ring++) {
284 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
285 for (UShort_t sec = 0; sec < nSec; sec++) {
286 sampleRate->Set(det, *ring, sec, 0, fRate);
287 }
288 }
289 }
20345ac5 290 return sampleRate;
291}
292
c2fc1258 293//__________________________________________________________________
294AliFMDCalibStripRange*
02a27b50 295AliFMDCalibFaker::MakeStripRange() const
c2fc1258 296{
02a27b50 297 // Make strip ranges
c2fc1258 298 AliFMDCalibStripRange* striprange = new AliFMDCalibStripRange;
299 for (UShort_t det = 1; det <= 3; det++) {
300 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
301 for (Char_t* ring = rings; *ring != '\0'; ring++) {
302 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
303 for (UShort_t sec = 0; sec < nSec; sec++) {
304 striprange->Set(det, *ring, sec, 0, fStripMin, fStripMax);
305 }
306 }
307 }
308 return striprange;
309}
310
20345ac5 311//__________________________________________________________________
312AliFMDAltroMapping*
02a27b50 313AliFMDCalibFaker::MakeAltroMap() const
20345ac5 314{
02a27b50 315 // Make hardware mapping
20345ac5 316 AliFMDAltroMapping* m = new AliFMDAltroMapping;
317 return m;
318}
319
320
321
322//____________________________________________________________________
323//
324// EOF
325//