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