]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONCalibrationData.cxx
Removing obsolete macro
[u/mrichter/AliRoot.git] / MUON / AliMUONCalibrationData.cxx
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
16 // $Id$
17
18 #include "AliMUONCalibrationData.h"
19
20 #include "AliCDBEntry.h"
21 #include "AliCDBManager.h"
22 #include "AliLog.h"
23 #include "AliMUONTriggerEfficiencyCells.h"
24 #include "AliMUONTriggerLut.h"
25 #include "AliMUONV1DStore.h"
26 #include "AliMUONV2DStore.h"
27 #include "AliMUONVCalibParam.h"
28 #include "Riostream.h"
29
30 ///
31 /// This class is to be considered as a convenience class.
32 /// Its aim is to ease retrieval of calibration data from the 
33 /// condition database.
34 ///
35 /// It acts as a "facade" to a bunch of underlying 
36 /// containers/calibration classes.
37 ///
38
39 ClassImp(AliMUONCalibrationData)
40
41 //_____________________________________________________________________________
42 AliMUONCalibrationData::AliMUONCalibrationData(Int_t runNumber, 
43                                                Bool_t deferredInitialization) 
44 : TObject(), 
45 fIsValid(kTRUE),
46 fRunNumber(runNumber), 
47 fGains(0x0), 
48 fPedestals(0x0),
49 fDeadChannels(0x0),
50 fLocalTriggerBoardMasks(0x0),
51 fRegionalTriggerBoardMasks(0x0),
52 fGlobalTriggerBoardMasks(0x0),
53 fTriggerLut(0x0),
54 fTriggerEfficiency(0x0)
55 {
56   //
57   // Default ctor.
58   // If deferredInitialization is false, we read *all* calibrations
59   // at once.
60   // So when using this class to access only one kind of calibrations (e.g.
61   // only pedestals), you should put deferredInitialization to kTRUE, which
62   // will instruct this object to fetch the data only when neeeded.
63   //
64   if ( deferredInitialization == kFALSE )
65   {
66     OnDemandGains();
67     OnDemandPedestals();
68     OnDemandDeadChannels();
69     OnDemandLocalTriggerBoardMasks();
70     OnDemandRegionalTriggerBoardMasks();
71     OnDemandGlobalTriggerBoardMasks();
72     OnDemandTriggerLut();
73     OnDemandTriggerEfficiency();
74   }
75 }
76
77 //_____________________________________________________________________________
78 AliMUONCalibrationData::AliMUONCalibrationData(const AliMUONCalibrationData&)
79 : TObject()
80 {
81   AliFatal("Implement me if needed");
82 }
83
84 //_____________________________________________________________________________
85 AliMUONCalibrationData&
86 AliMUONCalibrationData::operator=(const AliMUONCalibrationData&)
87 {
88   AliFatal("Implement me if needed");
89   return *this;
90 }
91
92 //_____________________________________________________________________________
93 AliMUONCalibrationData::~AliMUONCalibrationData()
94 {
95   //
96   // dtor. Note that we're the owner of our pointers.
97   //
98   delete fPedestals;
99   delete fGains;
100   delete fDeadChannels;
101   delete fLocalTriggerBoardMasks;
102   delete fRegionalTriggerBoardMasks;
103   delete fGlobalTriggerBoardMasks;
104   delete fTriggerLut;
105   delete fTriggerEfficiency;
106 }
107
108 //_____________________________________________________________________________
109 AliMUONVCalibParam*
110 AliMUONCalibrationData::DeadChannels(Int_t detElemId, Int_t manuId) const
111 {
112   //
113   // Return the calibration for a given (detElemId, manuId) pair
114   // Note that for DeadChannel, it's "legal" to return 0x0 (e.g. if a manu
115   // is perfect, we might simply forget it in the store).
116   //
117   return
118   static_cast<AliMUONVCalibParam*>(OnDemandDeadChannels()->Get(detElemId,manuId));
119 }
120
121 //_____________________________________________________________________________
122 AliMUONV2DStore*
123 AliMUONCalibrationData::OnDemandDeadChannels() const
124 {
125   //
126   // Create (if needed) and return the internal store for DeadChannels.
127   //
128   if (!fDeadChannels)
129   {
130     AliCDBEntry* entry = GetEntry("MUON/Calib/DeadChannels");
131     if (entry)
132     {
133       fDeadChannels = dynamic_cast<AliMUONV2DStore*>(entry->GetObject());
134       if (!fDeadChannels)
135       {
136         AliError("fDeadChannels not of the expected type !!!");
137       }
138     }
139     else
140     {
141       AliError("Could not get dead channels !");
142     }
143   }
144   return fDeadChannels;
145 }
146
147 //_____________________________________________________________________________
148 AliCDBEntry*
149 AliMUONCalibrationData::GetEntry(const char* path) const
150 {
151   //
152   // Access the CDB for a given path (e.g. MUON/Calib/Pedestals),
153   // and return the corresponding CDBEntry.
154   //
155   return AliCDBManager::Instance()->Get(path,fRunNumber);
156 }
157
158 //_____________________________________________________________________________
159 AliMUONVCalibParam*
160 AliMUONCalibrationData::Gains(Int_t detElemId, Int_t manuId) const
161 {
162   //
163   // Return the gains for a given (detElemId, manuId) pair
164   // Note that, unlike the DeadChannel case, if the result is 0x0, that's an
165   // error (meaning that we should get gains for all channels).
166   //
167   AliMUONVCalibParam* gain = 
168     static_cast<AliMUONVCalibParam*>(OnDemandGains()->Get(detElemId,manuId));
169   if (!gain)
170   {
171     AliError(Form("Could not get gain for detElemId=%d manuId=%d ",
172                     detElemId,manuId));
173   }
174   return gain;
175 }
176
177 //_____________________________________________________________________________
178 AliMUONV2DStore*
179 AliMUONCalibrationData::OnDemandGains() const
180 {
181   //
182   // Create (if needed) and return the internal store for gains.
183   //
184   if (!fGains)
185   {
186     AliCDBEntry* entry = GetEntry("MUON/Calib/Gains");
187     if (entry)
188     {
189       fGains = dynamic_cast<AliMUONV2DStore*>(entry->GetObject());
190       if (!fGains)
191       {
192         AliError("Gains not of the expected type !!!");
193       }
194     }
195     else
196     {
197       AliError("Could not get gains !");
198     }
199   }
200   return fGains;
201 }
202
203 //_____________________________________________________________________________
204 AliMUONVCalibParam* 
205 AliMUONCalibrationData::GlobalTriggerBoardMasks() const
206 {
207   //
208   // Return the masks for the global trigger board.
209   //
210   return OnDemandGlobalTriggerBoardMasks();
211 }
212
213 //_____________________________________________________________________________
214 AliMUONVCalibParam*
215 AliMUONCalibrationData::OnDemandGlobalTriggerBoardMasks() const
216 {
217   //
218   // Create (if needed) and return the internal store for GlobalTriggerBoardMasks.
219   //
220   if (!fGlobalTriggerBoardMasks)
221   {
222     AliCDBEntry* entry = GetEntry("MUON/Calib/GlobalTriggerBoardMasks");
223     if (entry)
224     {
225       fGlobalTriggerBoardMasks = dynamic_cast<AliMUONVCalibParam*>(entry->GetObject());
226       if (!fGlobalTriggerBoardMasks)
227       {
228         AliError("fGlobalTriggerBoardMasks not of the expected type !!!");
229       }
230     }
231     else
232     {
233       AliError("Could not get global trigger board masks !");
234     }
235   }
236   return fGlobalTriggerBoardMasks;
237 }
238
239 //_____________________________________________________________________________
240 AliMUONVCalibParam* 
241 AliMUONCalibrationData::LocalTriggerBoardMasks(Int_t localBoardNumber) const
242 {
243   //
244   // Return the masks for a given trigger local board.
245   //
246   AliMUONVCalibParam* ltbm = 
247   static_cast<AliMUONVCalibParam*>(OnDemandLocalTriggerBoardMasks()->Get(localBoardNumber));
248   if (!ltbm)
249   {
250     AliError(Form("Could not get mask for localBoardNumber=%d",localBoardNumber));
251   }
252   return ltbm;  
253 }
254
255 //_____________________________________________________________________________
256 AliMUONV1DStore*
257 AliMUONCalibrationData::OnDemandLocalTriggerBoardMasks() const
258 {
259   //
260   // Create (if needed) and return the internal store for LocalTriggerBoardMasks.
261   //
262   if (!fLocalTriggerBoardMasks)
263   {
264     AliCDBEntry* entry = GetEntry("MUON/Calib/LocalTriggerBoardMasks");
265     if (entry)
266     {
267       fLocalTriggerBoardMasks = dynamic_cast<AliMUONV1DStore*>(entry->GetObject());
268       if (!fLocalTriggerBoardMasks)
269       {
270         AliError("fLocalTriggerBoardMasks not of the expected type !!!");
271       }
272     }
273     else
274     {
275       AliError("Could not get local trigger board masks !");
276     }
277   }
278   return fLocalTriggerBoardMasks;
279 }
280
281 //_____________________________________________________________________________
282 AliMUONV2DStore*
283 AliMUONCalibrationData::OnDemandPedestals() const
284 {
285   //
286   // Create (if needed) and return the internal storage for pedestals.
287   //
288   if (!fPedestals)
289   {
290     AliCDBEntry* entry = GetEntry("MUON/Calib/Pedestals");
291     if (entry)
292     {
293       fPedestals = dynamic_cast<AliMUONV2DStore*>(entry->GetObject());
294       if (!fPedestals)
295       {
296         AliError("fPedestals not of the expected type !!!");
297       }
298     }
299     else
300     {
301       AliError("Could not get pedestals !");
302     }
303   }
304   return fPedestals;
305 }
306
307 //_____________________________________________________________________________
308 void
309 AliMUONCalibrationData::Print(Option_t*) const
310 {
311   //
312   // A very basic dump of our guts.
313   //  
314   cout << "RunNumber " << RunNumber()
315   << " fGains=" << fGains
316   << " fPedestals=" << fPedestals
317   << " fDeadChannels=" << fDeadChannels
318   << " fLocalTriggerBoardMasks=" << fLocalTriggerBoardMasks
319   << " fRegionalTriggerBoardMasks=" << fRegionalTriggerBoardMasks
320   << " fGlobalTriggerBoardMasks=" << fGlobalTriggerBoardMasks
321   << " fTriggerLut=" << fTriggerLut
322   << endl;
323 }
324
325
326 //_____________________________________________________________________________
327 AliMUONVCalibParam*
328 AliMUONCalibrationData::Pedestals(Int_t detElemId, Int_t manuId) const
329 {
330   //
331   // Return the pedestals for a given (detElemId, manuId) pair.
332   // A return value of 0x0 is considered an error, meaning we should get
333   // pedestals for all channels.
334   //
335   AliMUONVCalibParam* ped = 
336     static_cast<AliMUONVCalibParam*>(OnDemandPedestals()->Get(detElemId,manuId));
337   if (!ped)
338   {
339     AliError(Form("Could not get pedestal for detElemId=%d manuId=%d ",
340                   detElemId,manuId));
341   }
342   return ped;
343 }
344
345 //_____________________________________________________________________________
346 AliMUONVCalibParam* 
347 AliMUONCalibrationData::RegionalTriggerBoardMasks(Int_t index) const
348 {
349   //
350   // Return the masks for a given trigger regional board.
351   //
352   AliMUONVCalibParam* rtbm = 
353   static_cast<AliMUONVCalibParam*>(OnDemandRegionalTriggerBoardMasks()->Get(index));
354   if (!rtbm)
355   {
356     AliError(Form("Could not get mask for regionalBoard index=%d",index));
357   }
358   return rtbm;  
359 }
360
361 //_____________________________________________________________________________
362 AliMUONV1DStore*
363 AliMUONCalibrationData::OnDemandRegionalTriggerBoardMasks() const
364 {
365   //
366   // Create (if needed) and return the internal store for RegionalTriggerBoardMasks.
367   //
368   if (!fRegionalTriggerBoardMasks)
369   {
370     AliCDBEntry* entry = GetEntry("MUON/Calib/RegionalTriggerBoardMasks");
371     if (entry)
372     {
373       fRegionalTriggerBoardMasks = dynamic_cast<AliMUONV1DStore*>(entry->GetObject());
374       if (!fRegionalTriggerBoardMasks)
375       {
376         AliError("fRegionalTriggerBoardMasks not of the expected type !!!");
377       }
378     }
379     else
380     {
381       AliError("Could not get regional trigger board masks !");
382     }
383   }
384   return fRegionalTriggerBoardMasks;
385 }
386
387 //_____________________________________________________________________________
388 AliMUONTriggerEfficiencyCells*
389 AliMUONCalibrationData::TriggerEfficiency() const
390 {
391   //
392   // Return the trigger efficiency.
393   //
394   return OnDemandTriggerEfficiency();
395 }
396
397 //_____________________________________________________________________________
398 AliMUONTriggerEfficiencyCells* 
399 AliMUONCalibrationData::OnDemandTriggerEfficiency() const
400 {
401   //
402   //
403   //
404   if (!fTriggerEfficiency)
405   {
406     AliCDBEntry* entry = GetEntry("MUON/Calib/TriggerEfficiency");
407     if (entry)
408     {
409       fTriggerEfficiency = dynamic_cast<AliMUONTriggerEfficiencyCells*>(entry->GetObject());
410       if (!fTriggerEfficiency)
411       {
412         AliError("fTriggerEfficiency not of the expected type !!!");
413       }
414     }
415     else
416     {
417       AliError("Could not get trigger efficiency !");
418     }
419   }
420   return fTriggerEfficiency;
421 }
422
423 //_____________________________________________________________________________
424 AliMUONTriggerLut*
425 AliMUONCalibrationData::TriggerLut() const
426 {
427   //
428   // Return the trigger look up table.
429   //
430   return OnDemandTriggerLut();
431 }
432
433 //_____________________________________________________________________________
434 AliMUONTriggerLut* 
435 AliMUONCalibrationData::OnDemandTriggerLut() const
436 {
437   //
438   //
439   //
440   if (!fTriggerLut)
441   {
442     AliCDBEntry* entry = GetEntry("MUON/Calib/TriggerLut");
443     if (entry)
444     {
445       fTriggerLut = dynamic_cast<AliMUONTriggerLut*>(entry->GetObject());
446       if (!fTriggerLut)
447       {
448         AliError("fTriggerLut not of the expected type !!!");
449       }
450     }
451     else
452     {
453       AliError("Could not get trigger lut !");
454     }
455   }
456   return fTriggerLut;
457 }
458
459
460