AliRoot Core  3dc7879 (3dc7879)
AliFMDCalibFaker.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
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  **************************************************************************/
15 /* $Id$ */
22 //____________________________________________________________________
23 //
24 // Forward Multiplicity Detector based on Silicon wafers.
25 //
26 // This task creates fake calibrations. Which calibration, depends on
27 // the bit mask passed to the constructor, or added by `AddCalib'.
28 //
29 // The default is to write all calibration parameters to a local
30 // storage `local://$ALICE_ROOT/OCDB' which is were the sources live (sigh!
31 // - why oh why do we need to shit where we eat - it's just not
32 // healty).
33 //
34 #include "AliFMDDebug.h" // ALIFMDDEBUG_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 "AliFMDParameters.h" // ALIFMDPARAMETERS_H
44 //#include <Riostream.h>
45 #include <TSystem.h>
46 // #include <TMath.h>
47 #include <TROOT.h>
48 #include <TRandom.h>
49 #include <TF1.h>
50 
51 //====================================================================
52 ClassImp(AliFMDCalibFaker)
53 #if 0
54  ; // This is here to keep Emacs for indenting the next line
55 #endif
56 
57 //____________________________________________________________________
58 AliFMDCalibFaker::AliFMDCalibFaker(Int_t mask, const char* loc)
59  : TTask("FMDCalibFaker", loc),
60  fMask(mask),
61  fGain(-1),
62  fThresholdFactor(.1),
63  fThreshold(-1),
64  fPedestalMin(20),
65  fPedestalMax(30),
66  fDeadChance(0),
67  fRate(4),
68  fZeroThreshold(0),
69  fRunMin(0),
70  fRunMax(10),
71  fStripMin(0),
72  fStripMax(127)
73 {
74  // Default constructor
75 }
76 
77 
78 #define MAKE_META(meta) \
79  do { \
80  meta = new AliCDBMetaData; \
81  meta->SetResponsible(gSystem->GetUserInfo()->fRealName.Data()); \
82  meta->SetAliRootVersion(gROOT->GetVersion()); \
83  meta->SetBeamPeriod(1); \
84  meta->SetComment("Dummy data for testing"); } while (false);
85 
86 
87 //__________________________________________________________________
88 void
90 {
91  // Make the objects.
94  Float_t maxADC = 1.F*param->GetAltroChannelSize();
95  TObjArray cleanup;
96 
97  if (GetTitle() && GetTitle()[0] != '\0') {
98  AliInfo(Form("Setting default storage to '%s'", GetTitle()));
99  cdb->SetDefaultStorage(GetTitle());
100  }
101 
102 
103  AliCDBMetaData* meta = 0;
104  if (TESTBIT(fMask, kPulseGain)) {
105  // Info("Exec","Default gain to %f = %d * %f / %d",
106  // (param->GetVA1MipRange() * param->GetEdepMip() / maxADC),
107  // param->GetVA1MipRange(), param->GetEdepMip(), Int_t(maxADC));
108  if (fGain <= 0) {
109  fGain = (param->GetVA1MipRange() * param->GetEdepMip() / maxADC);
110  }
112  AliFMDCalibGain* gain = MakePulseGain();
114  MAKE_META(meta);
115  meta->SetProperty("key1", gain);
116  cdb->Put(gain, id, meta);
117  cleanup.Add(gain);
118  cleanup.Add(meta);
119  }
120  if (TESTBIT(fMask, kPedestal)) {
121  fPedestalMin = TMath::Max(TMath::Min(fPedestalMin, maxADC), 0.F);
122  fPedestalMax = TMath::Max(TMath::Min(fPedestalMax, maxADC), fPedestalMin);
123  AliFMDCalibPedestal* pedestal = MakePedestal();
125  MAKE_META(meta);
126  meta->SetProperty("key1", pedestal);
127  cdb->Put(pedestal, id, meta);
128  cleanup.Add(pedestal);
129  cleanup.Add(meta);
130  }
131  if (TESTBIT(fMask, kDeadMap)) {
132  fDeadChance = TMath::Max(TMath::Min(fDeadChance, 1.F), 0.F);
133  AliFMDCalibDeadMap* deadMap = MakeDeadMap();
135  MAKE_META(meta);
136  meta->SetProperty("key1", deadMap);
137  cdb->Put(deadMap, id, meta);
138  cleanup.Add(deadMap);
139  cleanup.Add(meta);
140  }
141  if (TESTBIT(fMask, kZeroSuppression)) {
142  fZeroThreshold = TMath::Min(fZeroThreshold, UShort_t(maxADC));
145  fRunMin, fRunMax);
146  MAKE_META(meta);
147  meta->SetProperty("key1", zeroSup);
148  cdb->Put(zeroSup, id, meta);
149  cleanup.Add(zeroSup);
150  cleanup.Add(meta);
151  }
152  if (TESTBIT(fMask, kSampleRate)) {
153  fRate = TMath::Max(TMath::Min(fRate, UShort_t(8)), UShort_t(1));
156  fRunMin,fRunMax);
157  MAKE_META(meta);
158  meta->SetProperty("key1", rate);
159  cdb->Put(rate, id, meta);
160  cleanup.Add(rate);
161  cleanup.Add(meta);
162  }
163  if (TESTBIT(fMask, kStripRange)) {
164  fRate = TMath::Max(TMath::Min(fRate, UShort_t(8)), UShort_t(1));
167  fRunMin,fRunMax);
168  MAKE_META(meta);
169  meta->SetProperty("key1", range);
170  cdb->Put(range, id, meta);
171  cleanup.Add(range);
172  cleanup.Add(meta);
173  }
174  if (TESTBIT(fMask, kAltroMap)) {
175  AliFMDAltroMapping* altroMap = MakeAltroMap();
177  MAKE_META(meta);
178  meta->SetProperty("key1", altroMap);
179  cdb->Put(altroMap, id, meta);
180  cleanup.Add(altroMap);
181  cleanup.Add(meta);
182  }
183  cdb->Destroy();
184  cleanup.Delete();
185 }
186 
187 
188 //__________________________________________________________________
191 {
192  // Make the actual data
193  AliFMDCalibGain* gain = new AliFMDCalibGain;
194  // Set threshold
195  gain->Set(fThreshold);
196  for (UShort_t det = 1; det <= 3; det++) {
197  Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
198  for (Char_t* ring = rings; *ring != '\0'; ring++) {
199  UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
200  UShort_t nStr = ( *ring == 'I' ? 512 : 256 );
201  for (UShort_t sec = 0; sec < nSec; sec++) {
202  for (UShort_t str = 0; str < nStr; str++) {
203  gain->Set(det, *ring, sec, str,
204  gRandom->Gaus(fGain, .01 * fGain));
205  }
206  }
207  }
208  }
209  return gain;
210 }
211 
212 //__________________________________________________________________
213 Float_t
214 AliFMDCalibFaker::MakeNoise(Char_t ring, UShort_t str) const
215 {
216  const UShort_t innerN = 512;
217  const UShort_t outerN = 256;
218  const UShort_t innerCut = 350;
219  const UShort_t outerCut = 190;
220  const Float_t innerBase = 1.2;
221  const Float_t outerBase = 2.1;
222  const Float_t innerInc = 0.5;
223  const Float_t outerInc = 0.8;
224  Float_t cut, base, inc, n;
225  switch (ring) {
226  case 'I':
227  cut = innerCut; base = innerBase; inc = innerInc; n = innerN; break;
228  case 'O':
229  cut = outerCut; base = outerBase; inc = outerInc; n = outerN; break;
230  default:
231  return -1;
232  }
233  Float_t bare = base + (str < cut ?
234  str / cut * inc :
235  inc - (str - cut) / (n - cut) * inc);
236  return bare + gRandom->Uniform(-.07, .07);
237 }
238 
239 //__________________________________________________________________
242 {
243  // Make the actual data
245 
246  for (UShort_t det = 1; det <= 3; det++) {
247  Char_t rings[] = { 'I', 'O', '\0' };
248  for (Char_t* ring = rings; *ring != '\0'; ring++) {
249  if (*ring == 'O' && det == 1) continue;
250  UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
251  UShort_t nStr = ( *ring == 'I' ? 512 : 256 );
252  for (UShort_t sec = 0; sec < nSec; sec++) {
253  for (UShort_t str = 0; str < nStr; str++) {
254  Float_t noise = MakeNoise(*ring, str);
255  Float_t ped = gRandom->Uniform(fPedestalMin, fPedestalMax);
256  pedestal->Set(det, *ring, sec, str, ped, noise);
257  }
258  }
259  }
260  }
261  return pedestal;
262 }
263 
264 //__________________________________________________________________
267 {
268  // Make the actual data
269  AliFMDCalibDeadMap* deadmap = new AliFMDCalibDeadMap(0);
270  TRandom* random = new TRandom(0);
271  for (UShort_t det = 1; det <= 3; det++) {
272  Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
273  for (Char_t* ring = rings; *ring != '\0'; ring++) {
274  UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
275  UShort_t nStr = ( *ring == 'I' ? 512 : 256 );
276  for (UShort_t sec = 0; sec < nSec; sec++) {
277  for (UShort_t str = 0; str < nStr; str++) {
278  deadmap->operator()(det, *ring, sec, str) =
279  random->Uniform(0, 1) < fDeadChance;
280  }
281  }
282  }
283  }
284  if (AliDebugLevel() > 20) deadmap->Print();
285  return deadmap;
286 }
287 
288 //__________________________________________________________________
291 {
292  // Make the actual data
294  for (UShort_t det = 1; det <= 3; det++) {
295  Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
296  for (Char_t* ring = rings; *ring != '\0'; ring++) {
297  UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
298  UShort_t nStr = ( *ring == 'I' ? 512 : 256 );
299  for (UShort_t sec = 0; sec < nSec; sec++) {
300  for (UShort_t str = 0; str < nStr; str++) {
301  zs->operator()(det, *ring, sec, str) = fZeroThreshold;
302  }
303  }
304  }
305  }
306  return zs;
307 }
308 
309 //__________________________________________________________________
312 {
313  // Make sample rates
315  for (UShort_t det = 1; det <= 3; det++) {
316  Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
317  for (Char_t* ring = rings; *ring != '\0'; ring++) {
318  UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
319  for (UShort_t sec = 0; sec < nSec; sec++) {
320  sampleRate->Set(det, *ring, sec, 0, fRate);
321  }
322  }
323  }
324  return sampleRate;
325 }
326 
327 //__________________________________________________________________
330 {
331  // Make strip ranges
333  for (UShort_t det = 1; det <= 3; det++) {
334  Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
335  for (Char_t* ring = rings; *ring != '\0'; ring++) {
336  UShort_t nSec = ( *ring == 'I' ? 20 : 40 );
337  for (UShort_t sec = 0; sec < nSec; sec++) {
338  striprange->Set(det, *ring, sec, 0, fStripMin, fStripMax);
339  }
340  }
341  }
342  return striprange;
343 }
344 
345 //__________________________________________________________________
348 {
349  // Make hardware mapping
351  return m;
352 }
353 
354 
355 
356 //____________________________________________________________________
357 //
358 // EOF
359 //
Map of an integer per strip.
virtual AliFMDCalibStripRange * MakeStripRange() const
virtual AliFMDCalibZeroSuppression * MakeZeroSuppression() const
static const char * DeadPath()
#define AliDebugLevel()
#define TObjArray
static const char * AltroMapPath()
void Set(UShort_t det, Char_t ring, UShort_t sec, UShort_t str, UShort_t rate)
AliFMDUShortMap AliFMDCalibZeroSuppression
This class is a singleton that handles various parameters of the FMD detectors. This class reads from...
Manager of FMD parameters.
virtual void Print(Option_t *option="") const
Definition: AliFMDMap.cxx:362
void Set(UShort_t det, Char_t ring, UShort_t sec, UShort_t str, Float_t val)
Per digitizer card pulser calibration.
static const char * PedestalPath()
static void Destroy()
virtual AliFMDCalibSampleRate * MakeSampleRate() const
AliFMDBoolMap AliFMDCalibDeadMap
void Set(UShort_t det, Char_t ring, UShort_t sec, UShort_t str, Float_t ped, Float_t pedW)
Float_t GetEdepMip() const
Per strip pedestal calibration.
Gain value and width for each strip in the FMD.
Per digitizer card pulser calibration.
virtual AliFMDCalibGain * MakePulseGain() const
Per digitizer card pulser calibration.
virtual AliFMDAltroMapping * MakeAltroMap() const
Map HW address to detector coordinates and back again.
MAp of per strip boolean values.
Definition: AliFMDBoolMap.h:29
Per strip gain calibration.
#define AliInfo(message)
Definition: AliLog.h:484
static const char * SampleRatePath()
Class that encodes a map to/from ALTRO hardware address to FMD detector coordinates.
Float_t range[5]
virtual AliFMDCalibDeadMap * MakeDeadMap() const
Class to make fake calibration parameters.
static AliFMDParameters * Instance()
Bool_t Put(TObject *object, const AliCDBId &id, AliCDBMetaData *metaData, const char *mirrors="", DataType type=kPrivate)
void Set(UShort_t det, Char_t ring, UShort_t sec, UShort_t str, UShort_t min, UShort_t max)
static const char * StripRangePath()
void Exec(Option_t *option="")
void SetDefaultStorage(const char *dbString)
static const char * ZeroSuppressionPath()
static const char * PulseGainPath()
Per digitizer card pulser calibration.
void SetProperty(const char *property, TObject *object)
virtual AliFMDCalibPedestal * MakePedestal() const
AliFMDCalibFaker(Int_t mask=kAll, const char *loc="local://cdb")
TCut cut
Definition: MakeGlobalFit.C:75
static AliCDBManager * Instance(TMap *entryCache=NULL, Int_t run=-1)
virtual Float_t MakeNoise(Char_t ring, UShort_t str) const
UShort_t GetAltroChannelSize() const
Pedestal value and width for each strip in the FMD.
Make fake calibration data.
UShort_t GetVA1MipRange() const
#define MAKE_META(meta)