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 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
22 //____________________________________________________________________
24 // Forward Multiplicity Detector based on Silicon wafers.
26 // This task creates fake calibrations. Which calibration, depends on
27 // the bit mask passed to the constructor, or added by `AddCalib'.
29 // The default is to write all calibration parameters to a local
30 // storage `local://$ALICE_ROOT/OCDB' which is were the sources live (sigh!
31 // - why oh why do we need to shit where we eat - it's just not
34 #include "AliFMDDebug.h" // ALIFMDDEBUG_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
40 #include "AliFMDCalibStripRange.h" // ALIFMDCALIBSTRIPRANGE_H
41 #include <AliCDBManager.h> // ALICDBMANAGER_H
42 #include <AliCDBEntry.h> // ALICDBMANAGER_H
43 #include "AliFMDParameters.h" // ALIFMDPARAMETERS_H
44 //#include <Riostream.h>
51 //====================================================================
52 ClassImp(AliFMDCalibFaker)
54 ; // This is here to keep Emacs for indenting the next line
57 //____________________________________________________________________
58 AliFMDCalibFaker::AliFMDCalibFaker(Int_t mask, const char* loc)
59 : TTask("FMDCalibFaker", loc),
74 // Default constructor
78 #define MAKE_META(meta) \
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);
87 //__________________________________________________________________
89 AliFMDCalibFaker::Exec(Option_t*)
92 AliCDBManager* cdb = AliCDBManager::Instance();
93 AliFMDParameters* param = AliFMDParameters::Instance();
94 Float_t maxADC = 1.F*param->GetAltroChannelSize();
97 if (GetTitle() && GetTitle()[0] != '\0') {
98 AliInfo(Form("Setting default storage to '%s'", GetTitle()));
99 cdb->SetDefaultStorage(GetTitle());
103 AliCDBMetaData* meta = 0;
104 if (TESTBIT(fMask, kPulseGain)) {
105 // Info("Exec","Default gain to %f = %d * %f / %d",
106 // (param->GetVA1MipRange() * param->GetEdepMip() / maxADC),
107 // param->GetVA1MipRange(), param->GetEdepMip(), Int_t(maxADC));
109 fGain = (param->GetVA1MipRange() * param->GetEdepMip() / maxADC);
111 fThreshold = fThresholdFactor * param->GetEdepMip();
112 AliFMDCalibGain* gain = MakePulseGain();
113 AliCDBId id(AliFMDParameters::PulseGainPath(), fRunMin, fRunMax);
115 meta->SetProperty("key1", gain);
116 cdb->Put(gain, id, meta);
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();
124 AliCDBId id(AliFMDParameters::PedestalPath(),fRunMin,fRunMax);
126 meta->SetProperty("key1", pedestal);
127 cdb->Put(pedestal, id, meta);
128 cleanup.Add(pedestal);
131 if (TESTBIT(fMask, kDeadMap)) {
132 fDeadChance = TMath::Max(TMath::Min(fDeadChance, 1.F), 0.F);
133 AliFMDCalibDeadMap* deadMap = MakeDeadMap();
134 AliCDBId id(AliFMDParameters::DeadPath(), fRunMin, fRunMax);
136 meta->SetProperty("key1", deadMap);
137 cdb->Put(deadMap, id, meta);
138 cleanup.Add(deadMap);
141 if (TESTBIT(fMask, kZeroSuppression)) {
142 fZeroThreshold = TMath::Min(fZeroThreshold, UShort_t(maxADC));
143 AliFMDCalibZeroSuppression* zeroSup = MakeZeroSuppression();
144 AliCDBId id(AliFMDParameters::ZeroSuppressionPath(),
147 meta->SetProperty("key1", zeroSup);
148 cdb->Put(zeroSup, id, meta);
149 cleanup.Add(zeroSup);
152 if (TESTBIT(fMask, kSampleRate)) {
153 fRate = TMath::Max(TMath::Min(fRate, UShort_t(8)), UShort_t(1));
154 AliFMDCalibSampleRate* rate = MakeSampleRate();
155 AliCDBId id(AliFMDParameters::SampleRatePath(),
158 meta->SetProperty("key1", rate);
159 cdb->Put(rate, id, meta);
163 if (TESTBIT(fMask, kStripRange)) {
164 fRate = TMath::Max(TMath::Min(fRate, UShort_t(8)), UShort_t(1));
165 AliFMDCalibStripRange* range = MakeStripRange();
166 AliCDBId id(AliFMDParameters::StripRangePath(),
169 meta->SetProperty("key1", range);
170 cdb->Put(range, id, meta);
174 if (TESTBIT(fMask, kAltroMap)) {
175 AliFMDAltroMapping* altroMap = MakeAltroMap();
176 AliCDBId id(AliFMDParameters::AltroMapPath(), fRunMin, fRunMax);
178 meta->SetProperty("key1", altroMap);
179 cdb->Put(altroMap, id, meta);
180 cleanup.Add(altroMap);
188 //__________________________________________________________________
190 AliFMDCalibFaker::MakePulseGain() const
192 // Make the actual data
193 AliFMDCalibGain* gain = new AliFMDCalibGain;
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));
212 //__________________________________________________________________
214 AliFMDCalibFaker::MakeNoise(Char_t ring, UShort_t str) const
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;
227 cut = innerCut; base = innerBase; inc = innerInc; n = innerN; break;
229 cut = outerCut; base = outerBase; inc = outerInc; n = outerN; break;
233 Float_t bare = base + (str < cut ?
235 inc - (str - cut) / (n - cut) * inc);
236 return bare + gRandom->Uniform(-.07, .07);
239 //__________________________________________________________________
241 AliFMDCalibFaker::MakePedestal() const
243 // Make the actual data
244 AliFMDCalibPedestal* pedestal = new AliFMDCalibPedestal;
246 for (UShort_t det = 1; det <= 3; det++) {
247 Char_t rings[] = { 'I', 'O', '\0' };
248 for (Char_t* ring = rings; *ring != '\0'; ring++) {
249 if (*ring == 'O' && det == 1) continue;
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++) {
254 Float_t noise = MakeNoise(*ring, str);
255 Float_t ped = gRandom->Uniform(fPedestalMin, fPedestalMax);
256 pedestal->Set(det, *ring, sec, str, ped, noise);
264 //__________________________________________________________________
266 AliFMDCalibFaker::MakeDeadMap() const
268 // Make the actual data
269 AliFMDCalibDeadMap* deadmap = new AliFMDCalibDeadMap(0);
270 TRandom* random = new TRandom(0);
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) =
279 random->Uniform(0, 1) < fDeadChance;
284 if (AliDebugLevel() > 20) deadmap->Print();
288 //__________________________________________________________________
289 AliFMDCalibZeroSuppression*
290 AliFMDCalibFaker::MakeZeroSuppression() const
292 // Make the actual data
293 AliFMDCalibZeroSuppression* zs = new AliFMDCalibZeroSuppression(0);
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;
309 //__________________________________________________________________
310 AliFMDCalibSampleRate*
311 AliFMDCalibFaker::MakeSampleRate() const
314 AliFMDCalibSampleRate* sampleRate = new AliFMDCalibSampleRate;
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);
327 //__________________________________________________________________
328 AliFMDCalibStripRange*
329 AliFMDCalibFaker::MakeStripRange() const
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);
345 //__________________________________________________________________
347 AliFMDCalibFaker::MakeAltroMap() const
349 // Make hardware mapping
350 AliFMDAltroMapping* m = new AliFMDAltroMapping;
356 //____________________________________________________________________