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://cdb' which is a directory in the current
33 #include "AliLog.h" // ALILOG_H
34 #include "AliFMDCalibFaker.h" // ALIFMDCALIBFAKER_H
35 #include "AliFMDCalibGain.h" // ALIFMDCALIBGAIN_H
36 #include "AliFMDCalibPedestal.h" // ALIFMDCALIBPEDESTAL_H
37 #include "AliFMDCalibSampleRate.h" // ALIFMDCALIBPEDESTAL_H
38 #include "AliFMDAltroMapping.h" // ALIFMDALTROMAPPING_H
39 #include "AliFMDCalibStripRange.h" // ALIFMDCALIBSTRIPRANGE_H
40 #include <AliCDBManager.h> // ALICDBMANAGER_H
41 #include <AliCDBEntry.h> // ALICDBMANAGER_H
42 //#include <Riostream.h>
48 //====================================================================
49 ClassImp(AliFMDCalibFaker)
51 ; // This is here to keep Emacs for indenting the next line
54 //____________________________________________________________________
55 AliFMDCalibFaker::AliFMDCalibFaker(Int_t mask, const char* loc)
56 : TTask("FMDCalibFaker", loc),
71 // Default constructor
75 #define MAKE_META(meta) \
77 meta = new AliCDBMetaData; \
78 meta->SetResponsible(gSystem->GetUserInfo()->fRealName.Data()); \
79 meta->SetAliRootVersion(gROOT->GetVersion()); \
80 meta->SetBeamPeriod(1); \
81 meta->SetComment("Dummy data for testing"); } while (false);
84 //__________________________________________________________________
86 AliFMDCalibFaker::Exec(Option_t*)
89 AliCDBManager* cdb = AliCDBManager::Instance();
90 AliFMDParameters* param = AliFMDParameters::Instance();
91 Float_t maxADC = param->GetAltroChannelSize();
94 if (GetTitle() && GetTitle()[0] != '\0') {
95 AliInfo(Form("Setting default storage to '%s'", GetTitle()));
96 cdb->SetDefaultStorage(GetTitle());
100 AliCDBMetaData* meta = 0;
101 if (TESTBIT(fMask, kPulseGain)) {
103 fGain = (param->GetVA1MipRange() * param->GetEdepMip() / maxADC);
104 fThreshold = fThresholdFactor * param->GetEdepMip();
105 AliFMDCalibGain* gain = MakePulseGain();
106 AliCDBId id(AliFMDParameters::PulseGainPath(), fRunMin, fRunMax);
108 meta->SetProperty("key1", gain);
109 cdb->Put(gain, id, meta);
113 if (TESTBIT(fMask, kPedestal)) {
114 fPedestalMin = TMath::Max(TMath::Min(fPedestalMin, maxADC), 0.F);
115 fPedestalMax = TMath::Max(TMath::Min(fPedestalMax, maxADC), fPedestalMin);
116 AliFMDCalibPedestal* pedestal = MakePedestal();
117 AliCDBId id(AliFMDParameters::PedestalPath(), fRunMin, fRunMax);
119 meta->SetProperty("key1", pedestal);
120 cdb->Put(pedestal, id, meta);
121 cleanup.Add(pedestal);
124 if (TESTBIT(fMask, kDeadMap)) {
125 fDeadChance = TMath::Max(TMath::Min(fDeadChance, 1.F), 0.F);
126 AliFMDCalibDeadMap* deadMap = MakeDeadMap();
127 AliCDBId id(AliFMDParameters::DeadPath(), fRunMin, fRunMax);
129 meta->SetProperty("key1", deadMap);
130 cdb->Put(deadMap, id, meta);
131 cleanup.Add(deadMap);
134 if (TESTBIT(fMask, kZeroSuppression)) {
135 fZeroThreshold = TMath::Min(fZeroThreshold, UShort_t(maxADC));
136 AliFMDCalibZeroSuppression* zeroSup = MakeZeroSuppression();
137 AliCDBId id(AliFMDParameters::ZeroSuppressionPath(),
140 meta->SetProperty("key1", zeroSup);
141 cdb->Put(zeroSup, id, meta);
142 cleanup.Add(zeroSup);
145 if (TESTBIT(fMask, kSampleRate)) {
146 fRate = TMath::Max(TMath::Min(fRate, UShort_t(8)), UShort_t(1));
147 AliFMDCalibSampleRate* rate = MakeSampleRate();
148 AliCDBId id(AliFMDParameters::SampleRatePath(),fRunMin,fRunMax);
150 meta->SetProperty("key1", rate);
151 cdb->Put(rate, id, meta);
155 if (TESTBIT(fMask, kStripRange)) {
156 fRate = TMath::Max(TMath::Min(fRate, UShort_t(8)), UShort_t(1));
157 AliFMDCalibStripRange* range = MakeStripRange();
158 AliCDBId id(AliFMDParameters::StripRangePath(),fRunMin,fRunMax);
160 meta->SetProperty("key1", range);
161 cdb->Put(range, id, meta);
165 if (TESTBIT(fMask, kAltroMap)) {
166 AliFMDAltroMapping* altroMap = MakeAltroMap();
167 AliCDBId id(AliFMDParameters::AltroMapPath(), fRunMin, fRunMax);
169 meta->SetProperty("key1", altroMap);
170 cdb->Put(altroMap, id, meta);
171 cleanup.Add(altroMap);
179 //__________________________________________________________________
181 AliFMDCalibFaker::MakePulseGain() const
183 // Make the actual data
184 AliFMDCalibGain* gain = new AliFMDCalibGain;
186 gain->Set(fThreshold);
187 for (UShort_t det = 1; det <= 3; det++) {
188 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
189 for (Char_t* ring = rings; *ring != '\0'; ring++) {
190 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
191 UShort_t nStr = ( *ring == 'I' ? 512 : 256 );
192 for (UShort_t sec = 0; sec < nSec; sec++) {
193 for (UShort_t str = 0; str < nStr; str++) {
194 gain->Set(det, *ring, sec, str,
195 gRandom->Gaus(fGain, .01 * fGain));
203 //__________________________________________________________________
205 AliFMDCalibFaker::MakePedestal() const
207 // Make the actual data
208 AliFMDCalibPedestal* pedestal = new AliFMDCalibPedestal;
209 for (UShort_t det = 1; det <= 3; det++) {
210 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
211 for (Char_t* ring = rings; *ring != '\0'; ring++) {
212 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
213 UShort_t nStr = ( *ring == 'I' ? 512 : 256 );
214 for (UShort_t sec = 0; sec < nSec; sec++) {
215 for (UShort_t str = 0; str < nStr; str++) {
216 pedestal->Set(det, *ring, sec, str,
217 gRandom->Uniform(fPedestalMin, fPedestalMax), 1.5);
225 //__________________________________________________________________
227 AliFMDCalibFaker::MakeDeadMap() const
229 // Make the actual data
230 AliFMDCalibDeadMap* deadmap = new AliFMDCalibDeadMap;
231 for (UShort_t det = 1; det <= 3; det++) {
232 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
233 for (Char_t* ring = rings; *ring != '\0'; ring++) {
234 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
235 UShort_t nStr = ( *ring == 'I' ? 512 : 256 );
236 for (UShort_t sec = 0; sec < nSec; sec++) {
237 for (UShort_t str = 0; str < nStr; str++) {
238 deadmap->operator()(det, *ring, sec, str) =
239 gRandom->Uniform(0, 1) < fDeadChance;
247 //__________________________________________________________________
248 AliFMDCalibZeroSuppression*
249 AliFMDCalibFaker::MakeZeroSuppression() const
251 // Make the actual data
252 AliFMDCalibZeroSuppression* zs = new AliFMDCalibZeroSuppression;
253 for (UShort_t det = 1; det <= 3; det++) {
254 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
255 for (Char_t* ring = rings; *ring != '\0'; ring++) {
256 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
257 UShort_t nStr = ( *ring == 'I' ? 512 : 256 );
258 for (UShort_t sec = 0; sec < nSec; sec++) {
259 for (UShort_t str = 0; str < nStr; str++) {
260 zs->operator()(det, *ring, sec, str) = fZeroThreshold;
268 //__________________________________________________________________
269 AliFMDCalibSampleRate*
270 AliFMDCalibFaker::MakeSampleRate() const
273 AliFMDCalibSampleRate* sampleRate = new AliFMDCalibSampleRate;
274 for (UShort_t det = 1; det <= 3; det++) {
275 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
276 for (Char_t* ring = rings; *ring != '\0'; ring++) {
277 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
278 for (UShort_t sec = 0; sec < nSec; sec++) {
279 sampleRate->Set(det, *ring, sec, 0, fRate);
286 //__________________________________________________________________
287 AliFMDCalibStripRange*
288 AliFMDCalibFaker::MakeStripRange() const
291 AliFMDCalibStripRange* striprange = new AliFMDCalibStripRange;
292 for (UShort_t det = 1; det <= 3; det++) {
293 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
294 for (Char_t* ring = rings; *ring != '\0'; ring++) {
295 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
296 for (UShort_t sec = 0; sec < nSec; sec++) {
297 striprange->Set(det, *ring, sec, 0, fStripMin, fStripMax);
304 //__________________________________________________________________
306 AliFMDCalibFaker::MakeAltroMap() const
308 // Make hardware mapping
309 AliFMDAltroMapping* m = new AliFMDAltroMapping;
315 //____________________________________________________________________