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 <Riostream.h>
50 //====================================================================
51 ClassImp(AliFMDCalibFaker)
53 ; // This is here to keep Emacs for indenting the next line
56 //____________________________________________________________________
57 AliFMDCalibFaker::AliFMDCalibFaker(Int_t mask, const char* loc)
58 : TTask("FMDCalibFaker", loc),
73 // Default constructor
77 #define MAKE_META(meta) \
79 meta = new AliCDBMetaData; \
80 meta->SetResponsible(gSystem->GetUserInfo()->fRealName.Data()); \
81 meta->SetAliRootVersion(gROOT->GetVersion()); \
82 meta->SetBeamPeriod(1); \
83 meta->SetComment("Dummy data for testing"); } while (false);
86 //__________________________________________________________________
88 AliFMDCalibFaker::Exec(Option_t*)
91 AliCDBManager* cdb = AliCDBManager::Instance();
92 AliFMDParameters* param = AliFMDParameters::Instance();
93 Float_t maxADC = 1.F*param->GetAltroChannelSize();
96 if (GetTitle() && GetTitle()[0] != '\0') {
97 AliInfo(Form("Setting default storage to '%s'", GetTitle()));
98 cdb->SetDefaultStorage(GetTitle());
102 AliCDBMetaData* meta = 0;
103 if (TESTBIT(fMask, kPulseGain)) {
104 // Info("Exec","Default gain to %f = %d * %f / %d",
105 // (param->GetVA1MipRange() * param->GetEdepMip() / maxADC),
106 // param->GetVA1MipRange(), param->GetEdepMip(), Int_t(maxADC));
108 fGain = (param->GetVA1MipRange() * param->GetEdepMip() / maxADC);
110 fThreshold = fThresholdFactor * param->GetEdepMip();
111 AliFMDCalibGain* gain = MakePulseGain();
112 AliCDBId id(AliFMDParameters::PulseGainPath(), fRunMin, fRunMax);
114 meta->SetProperty("key1", gain);
115 cdb->Put(gain, id, meta);
119 if (TESTBIT(fMask, kPedestal)) {
120 fPedestalMin = TMath::Max(TMath::Min(fPedestalMin, maxADC), 0.F);
121 fPedestalMax = TMath::Max(TMath::Min(fPedestalMax, maxADC), fPedestalMin);
122 AliFMDCalibPedestal* pedestal = MakePedestal();
123 AliCDBId id(AliFMDParameters::PedestalPath(),fRunMin,fRunMax);
125 meta->SetProperty("key1", pedestal);
126 cdb->Put(pedestal, id, meta);
127 cleanup.Add(pedestal);
130 if (TESTBIT(fMask, kDeadMap)) {
131 fDeadChance = TMath::Max(TMath::Min(fDeadChance, 1.F), 0.F);
132 AliFMDCalibDeadMap* deadMap = MakeDeadMap();
133 AliCDBId id(AliFMDParameters::DeadPath(), fRunMin, fRunMax);
135 meta->SetProperty("key1", deadMap);
136 cdb->Put(deadMap, id, meta);
137 cleanup.Add(deadMap);
140 if (TESTBIT(fMask, kZeroSuppression)) {
141 fZeroThreshold = TMath::Min(fZeroThreshold, UShort_t(maxADC));
142 AliFMDCalibZeroSuppression* zeroSup = MakeZeroSuppression();
143 AliCDBId id(AliFMDParameters::ZeroSuppressionPath(),
146 meta->SetProperty("key1", zeroSup);
147 cdb->Put(zeroSup, id, meta);
148 cleanup.Add(zeroSup);
151 if (TESTBIT(fMask, kSampleRate)) {
152 fRate = TMath::Max(TMath::Min(fRate, UShort_t(8)), UShort_t(1));
153 AliFMDCalibSampleRate* rate = MakeSampleRate();
154 AliCDBId id(AliFMDParameters::SampleRatePath(),
157 meta->SetProperty("key1", rate);
158 cdb->Put(rate, id, meta);
162 if (TESTBIT(fMask, kStripRange)) {
163 fRate = TMath::Max(TMath::Min(fRate, UShort_t(8)), UShort_t(1));
164 AliFMDCalibStripRange* range = MakeStripRange();
165 AliCDBId id(AliFMDParameters::StripRangePath(),
168 meta->SetProperty("key1", range);
169 cdb->Put(range, id, meta);
173 if (TESTBIT(fMask, kAltroMap)) {
174 AliFMDAltroMapping* altroMap = MakeAltroMap();
175 AliCDBId id(AliFMDParameters::AltroMapPath(), fRunMin, fRunMax);
177 meta->SetProperty("key1", altroMap);
178 cdb->Put(altroMap, id, meta);
179 cleanup.Add(altroMap);
187 //__________________________________________________________________
189 AliFMDCalibFaker::MakePulseGain() const
191 // Make the actual data
192 AliFMDCalibGain* gain = new AliFMDCalibGain;
194 gain->Set(fThreshold);
195 for (UShort_t det = 1; det <= 3; det++) {
196 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
197 for (Char_t* ring = rings; *ring != '\0'; ring++) {
198 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
199 UShort_t nStr = ( *ring == 'I' ? 512 : 256 );
200 for (UShort_t sec = 0; sec < nSec; sec++) {
201 for (UShort_t str = 0; str < nStr; str++) {
202 gain->Set(det, *ring, sec, str,
203 gRandom->Gaus(fGain, .01 * fGain));
211 //__________________________________________________________________
213 AliFMDCalibFaker::MakeNoise(Char_t ring, UShort_t str) const
215 const UShort_t innerN = 512;
216 const UShort_t outerN = 256;
217 const UShort_t innerCut = 350;
218 const UShort_t outerCut = 190;
219 const Float_t innerBase = 1.2;
220 const Float_t outerBase = 2.1;
221 const Float_t innerInc = 0.5;
222 const Float_t outerInc = 0.8;
223 Float_t cut, base, inc, n;
226 cut = innerCut; base = innerBase; inc = innerInc; n = innerN; break;
228 cut = outerCut; base = outerBase; inc = outerInc; n = outerN; break;
232 Float_t bare = base + (str < cut ?
234 inc - (str - cut) / (n - cut) * inc);
235 return bare + gRandom->Uniform(-.07, .07);
238 //__________________________________________________________________
240 AliFMDCalibFaker::MakePedestal() const
242 // Make the actual data
243 AliFMDCalibPedestal* pedestal = new AliFMDCalibPedestal;
245 for (UShort_t det = 1; det <= 3; det++) {
246 Char_t rings[] = { 'I', 'O', '\0' };
247 for (Char_t* ring = rings; *ring != '\0'; ring++) {
248 if (*ring == 'O' && det == 1) continue;
249 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
250 UShort_t nStr = ( *ring == 'I' ? 512 : 256 );
251 for (UShort_t sec = 0; sec < nSec; sec++) {
252 for (UShort_t str = 0; str < nStr; str++) {
253 Float_t noise = MakeNoise(*ring, str);
254 Float_t ped = gRandom->Uniform(fPedestalMin, fPedestalMax);
255 pedestal->Set(det, *ring, sec, str, ped, noise);
263 //__________________________________________________________________
265 AliFMDCalibFaker::MakeDeadMap() const
267 // Make the actual data
268 AliFMDCalibDeadMap* deadmap = new AliFMDCalibDeadMap;
269 for (UShort_t det = 1; det <= 3; det++) {
270 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
271 for (Char_t* ring = rings; *ring != '\0'; ring++) {
272 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
273 UShort_t nStr = ( *ring == 'I' ? 512 : 256 );
274 for (UShort_t sec = 0; sec < nSec; sec++) {
275 for (UShort_t str = 0; str < nStr; str++) {
276 deadmap->operator()(det, *ring, sec, str) =
277 gRandom->Uniform(0, 1) < fDeadChance;
285 //__________________________________________________________________
286 AliFMDCalibZeroSuppression*
287 AliFMDCalibFaker::MakeZeroSuppression() const
289 // Make the actual data
290 AliFMDCalibZeroSuppression* zs = new AliFMDCalibZeroSuppression;
291 for (UShort_t det = 1; det <= 3; det++) {
292 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
293 for (Char_t* ring = rings; *ring != '\0'; ring++) {
294 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
295 UShort_t nStr = ( *ring == 'I' ? 512 : 256 );
296 for (UShort_t sec = 0; sec < nSec; sec++) {
297 for (UShort_t str = 0; str < nStr; str++) {
298 zs->operator()(det, *ring, sec, str) = fZeroThreshold;
306 //__________________________________________________________________
307 AliFMDCalibSampleRate*
308 AliFMDCalibFaker::MakeSampleRate() const
311 AliFMDCalibSampleRate* sampleRate = new AliFMDCalibSampleRate;
312 for (UShort_t det = 1; det <= 3; det++) {
313 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
314 for (Char_t* ring = rings; *ring != '\0'; ring++) {
315 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
316 for (UShort_t sec = 0; sec < nSec; sec++) {
317 sampleRate->Set(det, *ring, sec, 0, fRate);
324 //__________________________________________________________________
325 AliFMDCalibStripRange*
326 AliFMDCalibFaker::MakeStripRange() const
329 AliFMDCalibStripRange* striprange = new AliFMDCalibStripRange;
330 for (UShort_t det = 1; det <= 3; det++) {
331 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
332 for (Char_t* ring = rings; *ring != '\0'; ring++) {
333 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
334 for (UShort_t sec = 0; sec < nSec; sec++) {
335 striprange->Set(det, *ring, sec, 0, fStripMin, fStripMax);
342 //__________________________________________________________________
344 AliFMDCalibFaker::MakeAltroMap() const
346 // Make hardware mapping
347 AliFMDAltroMapping* m = new AliFMDAltroMapping;
353 //____________________________________________________________________