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' 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 "AliLog.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>
49 //====================================================================
50 ClassImp(AliFMDCalibFaker)
52 ; // This is here to keep Emacs for indenting the next line
55 //____________________________________________________________________
56 AliFMDCalibFaker::AliFMDCalibFaker(Int_t mask, const char* loc)
57 : TTask("FMDCalibFaker", loc),
72 // Default constructor
76 #define MAKE_META(meta) \
78 meta = new AliCDBMetaData; \
79 meta->SetResponsible(gSystem->GetUserInfo()->fRealName.Data()); \
80 meta->SetAliRootVersion(gROOT->GetVersion()); \
81 meta->SetBeamPeriod(1); \
82 meta->SetComment("Dummy data for testing"); } while (false);
85 //__________________________________________________________________
87 AliFMDCalibFaker::Exec(Option_t*)
90 AliCDBManager* cdb = AliCDBManager::Instance();
91 AliFMDParameters* param = AliFMDParameters::Instance();
92 Float_t maxADC = 1.F*param->GetAltroChannelSize();
95 if (GetTitle() && GetTitle()[0] != '\0') {
96 AliInfo(Form("Setting default storage to '%s'", GetTitle()));
97 cdb->SetDefaultStorage(GetTitle());
101 AliCDBMetaData* meta = 0;
102 if (TESTBIT(fMask, kPulseGain)) {
103 // Info("Exec","Default gain to %f = %d * %f / %d",
104 // (param->GetVA1MipRange() * param->GetEdepMip() / maxADC),
105 // param->GetVA1MipRange(), param->GetEdepMip(), Int_t(maxADC));
107 fGain = (param->GetVA1MipRange() * param->GetEdepMip() / maxADC);
109 fThreshold = fThresholdFactor * param->GetEdepMip();
110 AliFMDCalibGain* gain = MakePulseGain();
111 AliCDBId id(AliFMDParameters::PulseGainPath(), fRunMin, fRunMax);
113 meta->SetProperty("key1", gain);
114 cdb->Put(gain, id, meta);
118 if (TESTBIT(fMask, kPedestal)) {
119 fPedestalMin = TMath::Max(TMath::Min(fPedestalMin, maxADC), 0.F);
120 fPedestalMax = TMath::Max(TMath::Min(fPedestalMax, maxADC), fPedestalMin);
121 AliFMDCalibPedestal* pedestal = MakePedestal();
122 AliCDBId id(AliFMDParameters::PedestalPath(),fRunMin,fRunMax);
124 meta->SetProperty("key1", pedestal);
125 cdb->Put(pedestal, id, meta);
126 cleanup.Add(pedestal);
129 if (TESTBIT(fMask, kDeadMap)) {
130 fDeadChance = TMath::Max(TMath::Min(fDeadChance, 1.F), 0.F);
131 AliFMDCalibDeadMap* deadMap = MakeDeadMap();
132 AliCDBId id(AliFMDParameters::DeadPath(), fRunMin, fRunMax);
134 meta->SetProperty("key1", deadMap);
135 cdb->Put(deadMap, id, meta);
136 cleanup.Add(deadMap);
139 if (TESTBIT(fMask, kZeroSuppression)) {
140 fZeroThreshold = TMath::Min(fZeroThreshold, UShort_t(maxADC));
141 AliFMDCalibZeroSuppression* zeroSup = MakeZeroSuppression();
142 AliCDBId id(AliFMDParameters::ZeroSuppressionPath(),
145 meta->SetProperty("key1", zeroSup);
146 cdb->Put(zeroSup, id, meta);
147 cleanup.Add(zeroSup);
150 if (TESTBIT(fMask, kSampleRate)) {
151 fRate = TMath::Max(TMath::Min(fRate, UShort_t(8)), UShort_t(1));
152 AliFMDCalibSampleRate* rate = MakeSampleRate();
153 AliCDBId id(AliFMDParameters::SampleRatePath(),
156 meta->SetProperty("key1", rate);
157 cdb->Put(rate, id, meta);
161 if (TESTBIT(fMask, kStripRange)) {
162 fRate = TMath::Max(TMath::Min(fRate, UShort_t(8)), UShort_t(1));
163 AliFMDCalibStripRange* range = MakeStripRange();
164 AliCDBId id(AliFMDParameters::StripRangePath(),
167 meta->SetProperty("key1", range);
168 cdb->Put(range, id, meta);
172 if (TESTBIT(fMask, kAltroMap)) {
173 AliFMDAltroMapping* altroMap = MakeAltroMap();
174 AliCDBId id(AliFMDParameters::AltroMapPath(), fRunMin, fRunMax);
176 meta->SetProperty("key1", altroMap);
177 cdb->Put(altroMap, id, meta);
178 cleanup.Add(altroMap);
186 //__________________________________________________________________
188 AliFMDCalibFaker::MakePulseGain() const
190 // Make the actual data
191 AliFMDCalibGain* gain = new AliFMDCalibGain;
193 gain->Set(fThreshold);
194 for (UShort_t det = 1; det <= 3; det++) {
195 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
196 for (Char_t* ring = rings; *ring != '\0'; ring++) {
197 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
198 UShort_t nStr = ( *ring == 'I' ? 512 : 256 );
199 for (UShort_t sec = 0; sec < nSec; sec++) {
200 for (UShort_t str = 0; str < nStr; str++) {
201 gain->Set(det, *ring, sec, str,
202 gRandom->Gaus(fGain, .01 * fGain));
210 //__________________________________________________________________
212 AliFMDCalibFaker::MakePedestal() const
214 // Make the actual data
215 AliFMDCalibPedestal* pedestal = new AliFMDCalibPedestal;
216 for (UShort_t det = 1; det <= 3; det++) {
217 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
218 for (Char_t* ring = rings; *ring != '\0'; ring++) {
219 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
220 UShort_t nStr = ( *ring == 'I' ? 512 : 256 );
221 for (UShort_t sec = 0; sec < nSec; sec++) {
222 for (UShort_t str = 0; str < nStr; str++) {
223 pedestal->Set(det, *ring, sec, str,
224 gRandom->Uniform(fPedestalMin, fPedestalMax), 1.5);
232 //__________________________________________________________________
234 AliFMDCalibFaker::MakeDeadMap() const
236 // Make the actual data
237 AliFMDCalibDeadMap* deadmap = new AliFMDCalibDeadMap;
238 for (UShort_t det = 1; det <= 3; det++) {
239 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
240 for (Char_t* ring = rings; *ring != '\0'; ring++) {
241 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
242 UShort_t nStr = ( *ring == 'I' ? 512 : 256 );
243 for (UShort_t sec = 0; sec < nSec; sec++) {
244 for (UShort_t str = 0; str < nStr; str++) {
245 deadmap->operator()(det, *ring, sec, str) =
246 gRandom->Uniform(0, 1) < fDeadChance;
254 //__________________________________________________________________
255 AliFMDCalibZeroSuppression*
256 AliFMDCalibFaker::MakeZeroSuppression() const
258 // Make the actual data
259 AliFMDCalibZeroSuppression* zs = new AliFMDCalibZeroSuppression;
260 for (UShort_t det = 1; det <= 3; det++) {
261 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
262 for (Char_t* ring = rings; *ring != '\0'; ring++) {
263 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
264 UShort_t nStr = ( *ring == 'I' ? 512 : 256 );
265 for (UShort_t sec = 0; sec < nSec; sec++) {
266 for (UShort_t str = 0; str < nStr; str++) {
267 zs->operator()(det, *ring, sec, str) = fZeroThreshold;
275 //__________________________________________________________________
276 AliFMDCalibSampleRate*
277 AliFMDCalibFaker::MakeSampleRate() const
280 AliFMDCalibSampleRate* sampleRate = new AliFMDCalibSampleRate;
281 for (UShort_t det = 1; det <= 3; det++) {
282 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
283 for (Char_t* ring = rings; *ring != '\0'; ring++) {
284 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
285 for (UShort_t sec = 0; sec < nSec; sec++) {
286 sampleRate->Set(det, *ring, sec, 0, fRate);
293 //__________________________________________________________________
294 AliFMDCalibStripRange*
295 AliFMDCalibFaker::MakeStripRange() const
298 AliFMDCalibStripRange* striprange = new AliFMDCalibStripRange;
299 for (UShort_t det = 1; det <= 3; det++) {
300 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
301 for (Char_t* ring = rings; *ring != '\0'; ring++) {
302 UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
303 for (UShort_t sec = 0; sec < nSec; sec++) {
304 striprange->Set(det, *ring, sec, 0, fStripMin, fStripMax);
311 //__________________________________________________________________
313 AliFMDCalibFaker::MakeAltroMap() const
315 // Make hardware mapping
316 AliFMDAltroMapping* m = new AliFMDAltroMapping;
322 //____________________________________________________________________