]> git.uio.no Git - u/mrichter/AliRoot.git/blame - FMD/FMDutil/AliFMDCalibFaker.cxx
Debug msg
[u/mrichter/AliRoot.git] / FMD / FMDutil / 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
162637e4 30// storage `local://$ALICE_ROOT/OCDB' which is were the sources live (sigh!
6169f936 31// - why oh why do we need to shit where we eat - it's just not
32// healty).
20345ac5 33//
f95a63c4 34#include "AliFMDDebug.h" // ALIFMDDEBUG_H ALILOG_H
20345ac5 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
09b6c804 43#include "AliFMDParameters.h" // ALIFMDPARAMETERS_H
02a27b50 44//#include <Riostream.h>
20345ac5 45#include <TSystem.h>
02a27b50 46// #include <TMath.h>
1e8f773e 47#include <TROOT.h>
20345ac5 48#include <TRandom.h>
a9579262 49#include <TF1.h>
20345ac5 50
51//====================================================================
52ClassImp(AliFMDCalibFaker)
53#if 0
54 ; // This is here to keep Emacs for indenting the next line
55#endif
56
57//____________________________________________________________________
58AliFMDCalibFaker::AliFMDCalibFaker(Int_t mask, const char* loc)
59 : TTask("FMDCalibFaker", loc),
60 fMask(mask),
61 fGain(-1),
62 fThresholdFactor(.1),
63 fThreshold(-1),
64 fPedestalMin(20),
65 fPedestalMax(30),
66 fDeadChance(0),
2aeec17d 67 fRate(4),
20345ac5 68 fZeroThreshold(0),
69 fRunMin(0),
c2fc1258 70 fRunMax(10),
71 fStripMin(0),
72 fStripMax(127)
20345ac5 73{
74 // Default constructor
75}
76
77
78#define MAKE_META(meta) \
79 do { \
80 meta = new AliCDBMetaData; \
81 meta->SetResponsible(gSystem->GetUserInfo()->fRealName.Data()); \
82 meta->SetAliRootVersion(gROOT->GetVersion()); \
83 meta->SetBeamPeriod(1); \
84 meta->SetComment("Dummy data for testing"); } while (false);
85
86
87//__________________________________________________________________
88void
89AliFMDCalibFaker::Exec(Option_t*)
90{
91 // Make the objects.
92 AliCDBManager* cdb = AliCDBManager::Instance();
93 AliFMDParameters* param = AliFMDParameters::Instance();
8ec606c2 94 Float_t maxADC = 1.F*param->GetAltroChannelSize();
20345ac5 95 TObjArray cleanup;
96
c2fc1258 97 if (GetTitle() && GetTitle()[0] != '\0') {
98 AliInfo(Form("Setting default storage to '%s'", GetTitle()));
99 cdb->SetDefaultStorage(GetTitle());
100 }
101
20345ac5 102
103 AliCDBMetaData* meta = 0;
104 if (TESTBIT(fMask, kPulseGain)) {
8ec606c2 105 // Info("Exec","Default gain to %f = %d * %f / %d",
106 // (param->GetVA1MipRange() * param->GetEdepMip() / maxADC),
107 // param->GetVA1MipRange(), param->GetEdepMip(), Int_t(maxADC));
108 if (fGain <= 0) {
109 fGain = (param->GetVA1MipRange() * param->GetEdepMip() / maxADC);
110 }
20345ac5 111 fThreshold = fThresholdFactor * param->GetEdepMip();
112 AliFMDCalibGain* gain = MakePulseGain();
02a27b50 113 AliCDBId id(AliFMDParameters::PulseGainPath(), fRunMin, fRunMax);
20345ac5 114 MAKE_META(meta);
115 meta->SetProperty("key1", gain);
116 cdb->Put(gain, id, meta);
117 cleanup.Add(gain);
118 cleanup.Add(meta);
119 }
120 if (TESTBIT(fMask, kPedestal)) {
121 fPedestalMin = TMath::Max(TMath::Min(fPedestalMin, maxADC), 0.F);
122 fPedestalMax = TMath::Max(TMath::Min(fPedestalMax, maxADC), fPedestalMin);
123 AliFMDCalibPedestal* pedestal = MakePedestal();
8ec606c2 124 AliCDBId id(AliFMDParameters::PedestalPath(),fRunMin,fRunMax);
20345ac5 125 MAKE_META(meta);
126 meta->SetProperty("key1", pedestal);
127 cdb->Put(pedestal, id, meta);
128 cleanup.Add(pedestal);
129 cleanup.Add(meta);
130 }
131 if (TESTBIT(fMask, kDeadMap)) {
132 fDeadChance = TMath::Max(TMath::Min(fDeadChance, 1.F), 0.F);
133 AliFMDCalibDeadMap* deadMap = MakeDeadMap();
02a27b50 134 AliCDBId id(AliFMDParameters::DeadPath(), fRunMin, fRunMax);
20345ac5 135 MAKE_META(meta);
136 meta->SetProperty("key1", deadMap);
137 cdb->Put(deadMap, id, meta);
138 cleanup.Add(deadMap);
139 cleanup.Add(meta);
140 }
141 if (TESTBIT(fMask, kZeroSuppression)) {
142 fZeroThreshold = TMath::Min(fZeroThreshold, UShort_t(maxADC));
143 AliFMDCalibZeroSuppression* zeroSup = MakeZeroSuppression();
02a27b50 144 AliCDBId id(AliFMDParameters::ZeroSuppressionPath(),
20345ac5 145 fRunMin, fRunMax);
146 MAKE_META(meta);
147 meta->SetProperty("key1", zeroSup);
148 cdb->Put(zeroSup, id, meta);
149 cleanup.Add(zeroSup);
150 cleanup.Add(meta);
151 }
152 if (TESTBIT(fMask, kSampleRate)) {
153 fRate = TMath::Max(TMath::Min(fRate, UShort_t(8)), UShort_t(1));
154 AliFMDCalibSampleRate* rate = MakeSampleRate();
8ec606c2 155 AliCDBId id(AliFMDParameters::SampleRatePath(),
156 fRunMin,fRunMax);
20345ac5 157 MAKE_META(meta);
158 meta->SetProperty("key1", rate);
159 cdb->Put(rate, id, meta);
160 cleanup.Add(rate);
161 cleanup.Add(meta);
162 }
c2fc1258 163 if (TESTBIT(fMask, kStripRange)) {
164 fRate = TMath::Max(TMath::Min(fRate, UShort_t(8)), UShort_t(1));
165 AliFMDCalibStripRange* range = MakeStripRange();
8ec606c2 166 AliCDBId id(AliFMDParameters::StripRangePath(),
167 fRunMin,fRunMax);
c2fc1258 168 MAKE_META(meta);
169 meta->SetProperty("key1", range);
170 cdb->Put(range, id, meta);
171 cleanup.Add(range);
172 cleanup.Add(meta);
173 }
20345ac5 174 if (TESTBIT(fMask, kAltroMap)) {
175 AliFMDAltroMapping* altroMap = MakeAltroMap();
02a27b50 176 AliCDBId id(AliFMDParameters::AltroMapPath(), fRunMin, fRunMax);
20345ac5 177 MAKE_META(meta);
178 meta->SetProperty("key1", altroMap);
179 cdb->Put(altroMap, id, meta);
180 cleanup.Add(altroMap);
181 cleanup.Add(meta);
182 }
183 cdb->Destroy();
184 cleanup.Delete();
185}
186
187
188//__________________________________________________________________
189AliFMDCalibGain*
02a27b50 190AliFMDCalibFaker::MakePulseGain() const
20345ac5 191{
192 // Make the actual data
193 AliFMDCalibGain* gain = new AliFMDCalibGain;
194 // Set threshold
195 gain->Set(fThreshold);
196 for (UShort_t det = 1; det <= 3; det++) {
197 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
198 for (Char_t* ring = rings; *ring != '\0'; ring++) {
199 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
200 UShort_t nStr = ( *ring == 'I' ? 512 : 256 );
201 for (UShort_t sec = 0; sec < nSec; sec++) {
202 for (UShort_t str = 0; str < nStr; str++) {
203 gain->Set(det, *ring, sec, str,
204 gRandom->Gaus(fGain, .01 * fGain));
205 }
206 }
207 }
208 }
209 return gain;
210}
211
a9579262 212//__________________________________________________________________
213Float_t
214AliFMDCalibFaker::MakeNoise(Char_t ring, UShort_t str) const
215{
216 const UShort_t innerN = 512;
217 const UShort_t outerN = 256;
218 const UShort_t innerCut = 350;
219 const UShort_t outerCut = 190;
220 const Float_t innerBase = 1.2;
221 const Float_t outerBase = 2.1;
222 const Float_t innerInc = 0.5;
223 const Float_t outerInc = 0.8;
224 Float_t cut, base, inc, n;
225 switch (ring) {
226 case 'I':
227 cut = innerCut; base = innerBase; inc = innerInc; n = innerN; break;
228 case 'O':
229 cut = outerCut; base = outerBase; inc = outerInc; n = outerN; break;
230 default:
231 return -1;
232 }
233 Float_t bare = base + (str < cut ?
234 str / cut * inc :
235 inc - (str - cut) / (n - cut) * inc);
236 return bare + gRandom->Uniform(-.07, .07);
237}
238
20345ac5 239//__________________________________________________________________
240AliFMDCalibPedestal*
02a27b50 241AliFMDCalibFaker::MakePedestal() const
20345ac5 242{
243 // Make the actual data
244 AliFMDCalibPedestal* pedestal = new AliFMDCalibPedestal;
a9579262 245
20345ac5 246 for (UShort_t det = 1; det <= 3; det++) {
a9579262 247 Char_t rings[] = { 'I', 'O', '\0' };
20345ac5 248 for (Char_t* ring = rings; *ring != '\0'; ring++) {
a9579262 249 if (*ring == 'O' && det == 1) continue;
20345ac5 250 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
251 UShort_t nStr = ( *ring == 'I' ? 512 : 256 );
252 for (UShort_t sec = 0; sec < nSec; sec++) {
253 for (UShort_t str = 0; str < nStr; str++) {
a9579262 254 Float_t noise = MakeNoise(*ring, str);
255 Float_t ped = gRandom->Uniform(fPedestalMin, fPedestalMax);
256 pedestal->Set(det, *ring, sec, str, ped, noise);
257 }
20345ac5 258 }
259 }
260 }
261 return pedestal;
262}
263
264//__________________________________________________________________
265AliFMDCalibDeadMap*
02a27b50 266AliFMDCalibFaker::MakeDeadMap() const
20345ac5 267{
268 // Make the actual data
133f1578 269 AliFMDCalibDeadMap* deadmap = new AliFMDCalibDeadMap(0);
270 TRandom* random = new TRandom(0);
20345ac5 271 for (UShort_t det = 1; det <= 3; det++) {
272 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
273 for (Char_t* ring = rings; *ring != '\0'; ring++) {
274 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
275 UShort_t nStr = ( *ring == 'I' ? 512 : 256 );
276 for (UShort_t sec = 0; sec < nSec; sec++) {
277 for (UShort_t str = 0; str < nStr; str++) {
278 deadmap->operator()(det, *ring, sec, str) =
133f1578 279 random->Uniform(0, 1) < fDeadChance;
20345ac5 280 }
281 }
282 }
283 }
133f1578 284 if (AliDebugLevel() > 20) deadmap->Print();
20345ac5 285 return deadmap;
286}
287
288//__________________________________________________________________
289AliFMDCalibZeroSuppression*
02a27b50 290AliFMDCalibFaker::MakeZeroSuppression() const
20345ac5 291{
292 // Make the actual data
133f1578 293 AliFMDCalibZeroSuppression* zs = new AliFMDCalibZeroSuppression(0);
20345ac5 294 for (UShort_t det = 1; det <= 3; det++) {
295 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
296 for (Char_t* ring = rings; *ring != '\0'; ring++) {
297 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
298 UShort_t nStr = ( *ring == 'I' ? 512 : 256 );
299 for (UShort_t sec = 0; sec < nSec; sec++) {
300 for (UShort_t str = 0; str < nStr; str++) {
301 zs->operator()(det, *ring, sec, str) = fZeroThreshold;
302 }
303 }
304 }
305 }
306 return zs;
307}
308
309//__________________________________________________________________
310AliFMDCalibSampleRate*
02a27b50 311AliFMDCalibFaker::MakeSampleRate() const
20345ac5 312{
02a27b50 313 // Make sample rates
20345ac5 314 AliFMDCalibSampleRate* sampleRate = new AliFMDCalibSampleRate;
c2fc1258 315 for (UShort_t det = 1; det <= 3; det++) {
316 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
317 for (Char_t* ring = rings; *ring != '\0'; ring++) {
318 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
319 for (UShort_t sec = 0; sec < nSec; sec++) {
320 sampleRate->Set(det, *ring, sec, 0, fRate);
321 }
322 }
323 }
20345ac5 324 return sampleRate;
325}
326
c2fc1258 327//__________________________________________________________________
328AliFMDCalibStripRange*
02a27b50 329AliFMDCalibFaker::MakeStripRange() const
c2fc1258 330{
02a27b50 331 // Make strip ranges
c2fc1258 332 AliFMDCalibStripRange* striprange = new AliFMDCalibStripRange;
333 for (UShort_t det = 1; det <= 3; det++) {
334 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
335 for (Char_t* ring = rings; *ring != '\0'; ring++) {
336 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
337 for (UShort_t sec = 0; sec < nSec; sec++) {
338 striprange->Set(det, *ring, sec, 0, fStripMin, fStripMax);
339 }
340 }
341 }
342 return striprange;
343}
344
20345ac5 345//__________________________________________________________________
346AliFMDAltroMapping*
02a27b50 347AliFMDCalibFaker::MakeAltroMap() const
20345ac5 348{
02a27b50 349 // Make hardware mapping
20345ac5 350 AliFMDAltroMapping* m = new AliFMDAltroMapping;
351 return m;
352}
353
354
355
356//____________________________________________________________________
357//
358// EOF
359//