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>
43 //====================================================================
44 ClassImp(AliFMDCalibFaker)
46 ; // This is here to keep Emacs for indenting the next line
49 //____________________________________________________________________
50 AliFMDCalibFaker::AliFMDCalibFaker(Int_t mask, const char* loc)
51 : TTask("FMDCalibFaker", loc),
64 // Default constructor
68 #define MAKE_META(meta) \
70 meta = new AliCDBMetaData; \
71 meta->SetResponsible(gSystem->GetUserInfo()->fRealName.Data()); \
72 meta->SetAliRootVersion(gROOT->GetVersion()); \
73 meta->SetBeamPeriod(1); \
74 meta->SetComment("Dummy data for testing"); } while (false);
77 //__________________________________________________________________
79 AliFMDCalibFaker::Exec(Option_t*)
82 AliCDBManager* cdb = AliCDBManager::Instance();
83 AliFMDParameters* param = AliFMDParameters::Instance();
84 Float_t maxADC = param->GetAltroChannelSize();
87 if (GetTitle()) cdb->SetDefaultStorage(GetTitle());
89 AliCDBMetaData* meta = 0;
90 if (TESTBIT(fMask, kPulseGain)) {
92 fGain = (param->GetVA1MipRange() * param->GetEdepMip() / maxADC);
93 fThreshold = fThresholdFactor * param->GetEdepMip();
94 AliFMDCalibGain* gain = MakePulseGain();
95 AliCDBId id(AliFMDParameters::fgkPulseGain, fRunMin, fRunMax);
97 meta->SetProperty("key1", gain);
98 cdb->Put(gain, id, meta);
102 if (TESTBIT(fMask, kPedestal)) {
103 fPedestalMin = TMath::Max(TMath::Min(fPedestalMin, maxADC), 0.F);
104 fPedestalMax = TMath::Max(TMath::Min(fPedestalMax, maxADC), fPedestalMin);
105 AliFMDCalibPedestal* pedestal = MakePedestal();
106 AliCDBId id(AliFMDParameters::fgkPedestal, fRunMin, fRunMax);
108 meta->SetProperty("key1", pedestal);
109 cdb->Put(pedestal, id, meta);
110 cleanup.Add(pedestal);
113 if (TESTBIT(fMask, kDeadMap)) {
114 fDeadChance = TMath::Max(TMath::Min(fDeadChance, 1.F), 0.F);
115 AliFMDCalibDeadMap* deadMap = MakeDeadMap();
116 AliCDBId id(AliFMDParameters::fgkDead, fRunMin, fRunMax);
118 meta->SetProperty("key1", deadMap);
119 cdb->Put(deadMap, id, meta);
120 cleanup.Add(deadMap);
123 if (TESTBIT(fMask, kZeroSuppression)) {
124 fZeroThreshold = TMath::Min(fZeroThreshold, UShort_t(maxADC));
125 AliFMDCalibZeroSuppression* zeroSup = MakeZeroSuppression();
126 AliCDBId id(AliFMDParameters::fgkZeroSuppression,
129 meta->SetProperty("key1", zeroSup);
130 cdb->Put(zeroSup, id, meta);
131 cleanup.Add(zeroSup);
134 if (TESTBIT(fMask, kSampleRate)) {
135 fRate = TMath::Max(TMath::Min(fRate, UShort_t(8)), UShort_t(1));
136 AliFMDCalibSampleRate* rate = MakeSampleRate();
137 AliCDBId id(AliFMDParameters::fgkSampleRate,fRunMin,fRunMax);
139 meta->SetProperty("key1", rate);
140 cdb->Put(rate, id, meta);
144 if (TESTBIT(fMask, kAltroMap)) {
145 AliFMDAltroMapping* altroMap = MakeAltroMap();
146 AliCDBId id(AliFMDParameters::fgkAltroMap, fRunMin, fRunMax);
148 meta->SetProperty("key1", altroMap);
149 cdb->Put(altroMap, id, meta);
150 cleanup.Add(altroMap);
158 //__________________________________________________________________
160 AliFMDCalibFaker::MakePulseGain()
162 // Make the actual data
163 AliFMDCalibGain* gain = new AliFMDCalibGain;
165 gain->Set(fThreshold);
166 for (UShort_t det = 1; det <= 3; det++) {
167 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
168 for (Char_t* ring = rings; *ring != '\0'; ring++) {
169 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
170 UShort_t nStr = ( *ring == 'I' ? 512 : 256 );
171 for (UShort_t sec = 0; sec < nSec; sec++) {
172 for (UShort_t str = 0; str < nStr; str++) {
173 gain->Set(det, *ring, sec, str,
174 gRandom->Gaus(fGain, .01 * fGain));
182 //__________________________________________________________________
184 AliFMDCalibFaker::MakePedestal()
186 // Make the actual data
187 AliFMDCalibPedestal* pedestal = new AliFMDCalibPedestal;
188 for (UShort_t det = 1; det <= 3; det++) {
189 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
190 for (Char_t* ring = rings; *ring != '\0'; ring++) {
191 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
192 UShort_t nStr = ( *ring == 'I' ? 512 : 256 );
193 for (UShort_t sec = 0; sec < nSec; sec++) {
194 for (UShort_t str = 0; str < nStr; str++) {
195 pedestal->Set(det, *ring, sec, str,
196 gRandom->Uniform(fPedestalMin, fPedestalMax), 1.5);
204 //__________________________________________________________________
206 AliFMDCalibFaker::MakeDeadMap()
208 // Make the actual data
209 AliFMDCalibDeadMap* deadmap = new AliFMDCalibDeadMap;
210 for (UShort_t det = 1; det <= 3; det++) {
211 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
212 for (Char_t* ring = rings; *ring != '\0'; ring++) {
213 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
214 UShort_t nStr = ( *ring == 'I' ? 512 : 256 );
215 for (UShort_t sec = 0; sec < nSec; sec++) {
216 for (UShort_t str = 0; str < nStr; str++) {
217 deadmap->operator()(det, *ring, sec, str) =
218 gRandom->Uniform(0, 1) < fDeadChance;
226 //__________________________________________________________________
227 AliFMDCalibZeroSuppression*
228 AliFMDCalibFaker::MakeZeroSuppression()
230 // Make the actual data
231 AliFMDCalibZeroSuppression* zs = new AliFMDCalibZeroSuppression;
232 for (UShort_t det = 1; det <= 3; det++) {
233 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
234 for (Char_t* ring = rings; *ring != '\0'; ring++) {
235 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
236 UShort_t nStr = ( *ring == 'I' ? 512 : 256 );
237 for (UShort_t sec = 0; sec < nSec; sec++) {
238 for (UShort_t str = 0; str < nStr; str++) {
239 zs->operator()(det, *ring, sec, str) = fZeroThreshold;
247 //__________________________________________________________________
248 AliFMDCalibSampleRate*
249 AliFMDCalibFaker::MakeSampleRate()
251 AliFMDCalibSampleRate* sampleRate = new AliFMDCalibSampleRate;
252 for (int i = 0; i < 3; i++)
253 sampleRate->Set(AliFMDParameters::kBaseDDL+i, fRate);
257 //__________________________________________________________________
259 AliFMDCalibFaker::MakeAltroMap()
261 AliFMDAltroMapping* m = new AliFMDAltroMapping;
267 //____________________________________________________________________