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 **************************************************************************/
18 //____________________________________________________________________
20 // Forward Multiplicity Detector based on Silicon wafers.
22 // This task creates fake calibrations. Which calibration, depends on
23 // the bit mask passed to the constructor, or added by `AddCalib'.
25 // The default is to write all calibration parameters to a local
26 // storage `local://cdb' which is a directory in the current
29 #include "AliLog.h" // ALILOG_H
30 #include "AliFMDCalibFaker.h" // ALIFMDCALIBFAKER_H
31 #include "AliFMDCalibGain.h" // ALIFMDCALIBGAIN_H
32 #include "AliFMDCalibPedestal.h" // ALIFMDCALIBPEDESTAL_H
33 #include "AliFMDCalibSampleRate.h" // ALIFMDCALIBPEDESTAL_H
34 #include "AliFMDAltroMapping.h" // ALIFMDALTROMAPPING_H
35 #include <AliCDBManager.h> // ALICDBMANAGER_H
36 #include <AliCDBEntry.h> // ALICDBMANAGER_H
37 #include <Riostream.h>
42 //====================================================================
43 ClassImp(AliFMDCalibFaker)
45 ; // This is here to keep Emacs for indenting the next line
48 //____________________________________________________________________
49 AliFMDCalibFaker::AliFMDCalibFaker(Int_t mask, const char* loc)
50 : TTask("FMDCalibFaker", loc),
63 // Default constructor
67 #define MAKE_META(meta) \
69 meta = new AliCDBMetaData; \
70 meta->SetResponsible(gSystem->GetUserInfo()->fRealName.Data()); \
71 meta->SetAliRootVersion(gROOT->GetVersion()); \
72 meta->SetBeamPeriod(1); \
73 meta->SetComment("Dummy data for testing"); } while (false);
76 //__________________________________________________________________
78 AliFMDCalibFaker::Exec(Option_t*)
81 AliCDBManager* cdb = AliCDBManager::Instance();
82 AliFMDParameters* param = AliFMDParameters::Instance();
83 Float_t maxADC = param->GetAltroChannelSize();
86 if (GetTitle()) cdb->SetDefaultStorage(GetTitle());
88 AliCDBMetaData* meta = 0;
89 if (TESTBIT(fMask, kPulseGain)) {
91 fGain = (param->GetVA1MipRange() * param->GetEdepMip() / maxADC);
92 fThreshold = fThresholdFactor * param->GetEdepMip();
93 AliFMDCalibGain* gain = MakePulseGain();
94 AliCDBId id(AliFMDParameters::fgkPulseGain, fRunMin, fRunMax);
96 meta->SetProperty("key1", gain);
97 cdb->Put(gain, id, meta);
101 if (TESTBIT(fMask, kPedestal)) {
102 fPedestalMin = TMath::Max(TMath::Min(fPedestalMin, maxADC), 0.F);
103 fPedestalMax = TMath::Max(TMath::Min(fPedestalMax, maxADC), fPedestalMin);
104 AliFMDCalibPedestal* pedestal = MakePedestal();
105 AliCDBId id(AliFMDParameters::fgkPedestal, fRunMin, fRunMax);
107 meta->SetProperty("key1", pedestal);
108 cdb->Put(pedestal, id, meta);
109 cleanup.Add(pedestal);
112 if (TESTBIT(fMask, kDeadMap)) {
113 fDeadChance = TMath::Max(TMath::Min(fDeadChance, 1.F), 0.F);
114 AliFMDCalibDeadMap* deadMap = MakeDeadMap();
115 AliCDBId id(AliFMDParameters::fgkDead, fRunMin, fRunMax);
117 meta->SetProperty("key1", deadMap);
118 cdb->Put(deadMap, id, meta);
119 cleanup.Add(deadMap);
122 if (TESTBIT(fMask, kZeroSuppression)) {
123 fZeroThreshold = TMath::Min(fZeroThreshold, UShort_t(maxADC));
124 AliFMDCalibZeroSuppression* zeroSup = MakeZeroSuppression();
125 AliCDBId id(AliFMDParameters::fgkZeroSuppression,
128 meta->SetProperty("key1", zeroSup);
129 cdb->Put(zeroSup, id, meta);
130 cleanup.Add(zeroSup);
133 if (TESTBIT(fMask, kSampleRate)) {
134 fRate = TMath::Max(TMath::Min(fRate, UShort_t(8)), UShort_t(1));
135 AliFMDCalibSampleRate* rate = MakeSampleRate();
136 AliCDBId id(AliFMDParameters::fgkSampleRate,fRunMin,fRunMax);
138 meta->SetProperty("key1", rate);
139 cdb->Put(rate, id, meta);
143 if (TESTBIT(fMask, kAltroMap)) {
144 AliFMDAltroMapping* altroMap = MakeAltroMap();
145 AliCDBId id(AliFMDParameters::fgkAltroMap, fRunMin, fRunMax);
147 meta->SetProperty("key1", altroMap);
148 cdb->Put(altroMap, id, meta);
149 cleanup.Add(altroMap);
157 //__________________________________________________________________
159 AliFMDCalibFaker::MakePulseGain()
161 // Make the actual data
162 AliFMDCalibGain* gain = new AliFMDCalibGain;
164 gain->Set(fThreshold);
165 for (UShort_t det = 1; det <= 3; det++) {
166 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
167 for (Char_t* ring = rings; *ring != '\0'; ring++) {
168 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
169 UShort_t nStr = ( *ring == 'I' ? 512 : 256 );
170 for (UShort_t sec = 0; sec < nSec; sec++) {
171 for (UShort_t str = 0; str < nStr; str++) {
172 gain->Set(det, *ring, sec, str,
173 gRandom->Gaus(fGain, .01 * fGain));
181 //__________________________________________________________________
183 AliFMDCalibFaker::MakePedestal()
185 // Make the actual data
186 AliFMDCalibPedestal* pedestal = new AliFMDCalibPedestal;
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 pedestal->Set(det, *ring, sec, str,
195 gRandom->Uniform(fPedestalMin, fPedestalMax), 1.5);
203 //__________________________________________________________________
205 AliFMDCalibFaker::MakeDeadMap()
207 // Make the actual data
208 AliFMDCalibDeadMap* deadmap = new AliFMDCalibDeadMap;
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 deadmap->operator()(det, *ring, sec, str) =
217 gRandom->Uniform(0, 1) < fDeadChance;
225 //__________________________________________________________________
226 AliFMDCalibZeroSuppression*
227 AliFMDCalibFaker::MakeZeroSuppression()
229 // Make the actual data
230 AliFMDCalibZeroSuppression* zs = new AliFMDCalibZeroSuppression;
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 zs->operator()(det, *ring, sec, str) = fZeroThreshold;
246 //__________________________________________________________________
247 AliFMDCalibSampleRate*
248 AliFMDCalibFaker::MakeSampleRate()
250 AliFMDCalibSampleRate* sampleRate = new AliFMDCalibSampleRate;
251 for (int i = 0; i < 3; i++)
252 sampleRate->Set(AliFMDParameters::kBaseDDL+i, fRate);
256 //__________________________________________________________________
258 AliFMDCalibFaker::MakeAltroMap()
260 AliFMDAltroMapping* m = new AliFMDAltroMapping;
266 //____________________________________________________________________