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 = 1.F*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)) {
102 // Info("Exec","Default gain to %f = %d * %f / %d",
103 // (param->GetVA1MipRange() * param->GetEdepMip() / maxADC),
104 // param->GetVA1MipRange(), param->GetEdepMip(), Int_t(maxADC));
106 fGain = (param->GetVA1MipRange() * param->GetEdepMip() / maxADC);
108 fThreshold = fThresholdFactor * param->GetEdepMip();
109 AliFMDCalibGain* gain = MakePulseGain();
110 AliCDBId id(AliFMDParameters::PulseGainPath(), fRunMin, fRunMax);
112 meta->SetProperty("key1", gain);
113 cdb->Put(gain, id, meta);
117 if (TESTBIT(fMask, kPedestal)) {
118 fPedestalMin = TMath::Max(TMath::Min(fPedestalMin, maxADC), 0.F);
119 fPedestalMax = TMath::Max(TMath::Min(fPedestalMax, maxADC), fPedestalMin);
120 AliFMDCalibPedestal* pedestal = MakePedestal();
121 AliCDBId id(AliFMDParameters::PedestalPath(),fRunMin,fRunMax);
123 meta->SetProperty("key1", pedestal);
124 cdb->Put(pedestal, id, meta);
125 cleanup.Add(pedestal);
128 if (TESTBIT(fMask, kDeadMap)) {
129 fDeadChance = TMath::Max(TMath::Min(fDeadChance, 1.F), 0.F);
130 AliFMDCalibDeadMap* deadMap = MakeDeadMap();
131 AliCDBId id(AliFMDParameters::DeadPath(), fRunMin, fRunMax);
133 meta->SetProperty("key1", deadMap);
134 cdb->Put(deadMap, id, meta);
135 cleanup.Add(deadMap);
138 if (TESTBIT(fMask, kZeroSuppression)) {
139 fZeroThreshold = TMath::Min(fZeroThreshold, UShort_t(maxADC));
140 AliFMDCalibZeroSuppression* zeroSup = MakeZeroSuppression();
141 AliCDBId id(AliFMDParameters::ZeroSuppressionPath(),
144 meta->SetProperty("key1", zeroSup);
145 cdb->Put(zeroSup, id, meta);
146 cleanup.Add(zeroSup);
149 if (TESTBIT(fMask, kSampleRate)) {
150 fRate = TMath::Max(TMath::Min(fRate, UShort_t(8)), UShort_t(1));
151 AliFMDCalibSampleRate* rate = MakeSampleRate();
152 AliCDBId id(AliFMDParameters::SampleRatePath(),
155 meta->SetProperty("key1", rate);
156 cdb->Put(rate, id, meta);
160 if (TESTBIT(fMask, kStripRange)) {
161 fRate = TMath::Max(TMath::Min(fRate, UShort_t(8)), UShort_t(1));
162 AliFMDCalibStripRange* range = MakeStripRange();
163 AliCDBId id(AliFMDParameters::StripRangePath(),
166 meta->SetProperty("key1", range);
167 cdb->Put(range, id, meta);
171 if (TESTBIT(fMask, kAltroMap)) {
172 AliFMDAltroMapping* altroMap = MakeAltroMap();
173 AliCDBId id(AliFMDParameters::AltroMapPath(), fRunMin, fRunMax);
175 meta->SetProperty("key1", altroMap);
176 cdb->Put(altroMap, id, meta);
177 cleanup.Add(altroMap);
185 //__________________________________________________________________
187 AliFMDCalibFaker::MakePulseGain() const
189 // Make the actual data
190 AliFMDCalibGain* gain = new AliFMDCalibGain;
192 gain->Set(fThreshold);
193 for (UShort_t det = 1; det <= 3; det++) {
194 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
195 for (Char_t* ring = rings; *ring != '\0'; ring++) {
196 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
197 UShort_t nStr = ( *ring == 'I' ? 512 : 256 );
198 for (UShort_t sec = 0; sec < nSec; sec++) {
199 for (UShort_t str = 0; str < nStr; str++) {
200 gain->Set(det, *ring, sec, str,
201 gRandom->Gaus(fGain, .01 * fGain));
209 //__________________________________________________________________
211 AliFMDCalibFaker::MakePedestal() const
213 // Make the actual data
214 AliFMDCalibPedestal* pedestal = new AliFMDCalibPedestal;
215 for (UShort_t det = 1; det <= 3; det++) {
216 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
217 for (Char_t* ring = rings; *ring != '\0'; ring++) {
218 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
219 UShort_t nStr = ( *ring == 'I' ? 512 : 256 );
220 for (UShort_t sec = 0; sec < nSec; sec++) {
221 for (UShort_t str = 0; str < nStr; str++) {
222 pedestal->Set(det, *ring, sec, str,
223 gRandom->Uniform(fPedestalMin, fPedestalMax), 1.5);
231 //__________________________________________________________________
233 AliFMDCalibFaker::MakeDeadMap() const
235 // Make the actual data
236 AliFMDCalibDeadMap* deadmap = new AliFMDCalibDeadMap;
237 for (UShort_t det = 1; det <= 3; det++) {
238 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
239 for (Char_t* ring = rings; *ring != '\0'; ring++) {
240 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
241 UShort_t nStr = ( *ring == 'I' ? 512 : 256 );
242 for (UShort_t sec = 0; sec < nSec; sec++) {
243 for (UShort_t str = 0; str < nStr; str++) {
244 deadmap->operator()(det, *ring, sec, str) =
245 gRandom->Uniform(0, 1) < fDeadChance;
253 //__________________________________________________________________
254 AliFMDCalibZeroSuppression*
255 AliFMDCalibFaker::MakeZeroSuppression() const
257 // Make the actual data
258 AliFMDCalibZeroSuppression* zs = new AliFMDCalibZeroSuppression;
259 for (UShort_t det = 1; det <= 3; det++) {
260 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
261 for (Char_t* ring = rings; *ring != '\0'; ring++) {
262 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
263 UShort_t nStr = ( *ring == 'I' ? 512 : 256 );
264 for (UShort_t sec = 0; sec < nSec; sec++) {
265 for (UShort_t str = 0; str < nStr; str++) {
266 zs->operator()(det, *ring, sec, str) = fZeroThreshold;
274 //__________________________________________________________________
275 AliFMDCalibSampleRate*
276 AliFMDCalibFaker::MakeSampleRate() const
279 AliFMDCalibSampleRate* sampleRate = new AliFMDCalibSampleRate;
280 for (UShort_t det = 1; det <= 3; det++) {
281 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
282 for (Char_t* ring = rings; *ring != '\0'; ring++) {
283 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
284 for (UShort_t sec = 0; sec < nSec; sec++) {
285 sampleRate->Set(det, *ring, sec, 0, fRate);
292 //__________________________________________________________________
293 AliFMDCalibStripRange*
294 AliFMDCalibFaker::MakeStripRange() const
297 AliFMDCalibStripRange* striprange = new AliFMDCalibStripRange;
298 for (UShort_t det = 1; det <= 3; det++) {
299 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
300 for (Char_t* ring = rings; *ring != '\0'; ring++) {
301 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
302 for (UShort_t sec = 0; sec < nSec; sec++) {
303 striprange->Set(det, *ring, sec, 0, fStripMin, fStripMax);
310 //__________________________________________________________________
312 AliFMDCalibFaker::MakeAltroMap() const
314 // Make hardware mapping
315 AliFMDAltroMapping* m = new AliFMDAltroMapping;
321 //____________________________________________________________________