]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONCalibrationData.cxx
Adding protected copy constructor and assignment operator
[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 "AliCDBStorage.h"
23 #include "AliLog.h"
24 #include "AliMUONV2DStore.h"
25 #include "AliMUONVCalibParam.h"
26 #include "Riostream.h"
27
28 ClassImp(AliMUONCalibrationData)
29
30 //_____________________________________________________________________________
31 AliMUONCalibrationData::AliMUONCalibrationData(Int_t runNumber, 
32                                                Bool_t deferredInitialization) 
33 : TObject(), 
34 fIsValid(kTRUE),
35 fRunNumber(runNumber), 
36 fGains(0x0), 
37 fPedestals(0x0),
38 fDeadChannels(0x0)
39 {
40   //
41   // Default ctor.
42   // If deferredInitialization is false, we read *all* calibrations
43   // at once.
44   // So when using this class to access only one kind of calibrations (e.g.
45   // only pedestals), you should put deferredInitialization to kTRUE, which
46   // will instruct this object to fetch the data only when neeeded.
47   //
48   if ( deferredInitialization == kFALSE )
49   {
50     Gains();
51     Pedestals();
52     DeadChannels();
53   }
54 }
55
56 //______________________________________________________________________________
57 AliMUONCalibrationData::AliMUONCalibrationData(const AliMUONCalibrationData& right) 
58   : TObject(right) 
59 {  
60 /// Protected copy constructor (not implemented)
61
62   AliFatal("Copy constructor not provided.");
63 }
64
65 //_____________________________________________________________________________
66 AliMUONCalibrationData::~AliMUONCalibrationData()
67 {
68   //
69   // dtor. Note that we're the owner of our pointers.
70   //
71   delete fPedestals;
72   delete fGains;
73   delete fDeadChannels;
74 }
75
76 //______________________________________________________________________________
77 AliMUONCalibrationData& 
78 AliMUONCalibrationData::operator=(const AliMUONCalibrationData& right)
79 {
80 /// Protected assignement operator (not implemented)
81
82   // check assignement to self
83   if (this == &right) return *this;
84
85   AliFatal("Assignement operator not provided.");
86     
87   return *this;  
88 }    
89
90 //_____________________________________________________________________________
91 AliMUONVCalibParam*
92 AliMUONCalibrationData::DeadChannel(Int_t detElemId, Int_t manuId) const
93 {
94   //
95   // Return the calibration for a given (detElemId, manuId) pair
96   // Note that for DeadChannel, it's "legal" to return 0x0 (e.g. if a manu
97   // is perfect, we might simply forget it in the store).
98   //
99   return
100   static_cast<AliMUONVCalibParam*>(DeadChannels()->Get(detElemId,manuId));
101 }
102
103 //_____________________________________________________________________________
104 AliMUONV2DStore*
105 AliMUONCalibrationData::DeadChannels() const
106 {
107   //
108   // Create (if needed) and return the internal store for DeadChannels.
109   //
110   if (!fDeadChannels)
111   {
112     AliCDBEntry* entry = GetEntry("MUON/Calib/DeadChannels");
113     if (entry)
114     {
115       fDeadChannels = dynamic_cast<AliMUONV2DStore*>(entry->GetObject());
116       if (!fDeadChannels)
117       {
118         AliError("fDeadChannels not of the expected type !!!");
119       }
120     }
121     else
122     {
123       AliError("Could not get dead channels !");
124     }
125   }
126   return fDeadChannels;
127 }
128
129 //_____________________________________________________________________________
130 AliCDBEntry*
131 AliMUONCalibrationData::GetEntry(const char* path) const
132 {
133   //
134   // Access the CDB for a given path (e.g. MUON/Calib/Pedestals),
135   // and return the corresponding CDBEntry.
136   //
137   AliInfo(Form("Fetching %s from Condition DataBase for run %d",path,fRunNumber));
138   
139   AliCDBManager* man = AliCDBManager::Instance();
140   if (!man->IsDefaultStorageSet())
141   {
142     AliError("No default CDB storage set !");
143     fIsValid = kFALSE;
144     return 0;
145   }
146   
147   AliCDBStorage* storage = man->GetDefaultStorage();
148   
149   AliCDBEntry* entry = storage->Get(path,fRunNumber);
150   return entry;
151 }
152
153 //_____________________________________________________________________________
154 AliMUONVCalibParam*
155 AliMUONCalibrationData::Gain(Int_t detElemId, Int_t manuId) const
156 {
157   //
158   // Return the gains for a given (detElemId, manuId) pair
159   // Note that, unlike the DeadChannel case, if the result is 0x0, that's an
160   // error (meaning that we should get gains for all channels).
161   //
162   AliMUONVCalibParam* gain = 
163     static_cast<AliMUONVCalibParam*>(Gains()->Get(detElemId,manuId));
164   if (!gain)
165   {
166     AliError(Form("Could not get gain for detElemId=%d manuId=%d ",
167                     detElemId,manuId));
168   }
169   return gain;
170 }
171
172 //_____________________________________________________________________________
173 AliMUONV2DStore*
174 AliMUONCalibrationData::Gains() const
175 {
176   //
177   // Create (if needed) and return the internal store for gains.
178   //
179   if (!fGains)
180   {
181     AliCDBEntry* entry = GetEntry("MUON/Calib/Gains");
182     if (entry)
183     {
184       fGains = dynamic_cast<AliMUONV2DStore*>(entry->GetObject());
185       if (!fGains)
186       {
187         AliError("Gains not of the expected type !!!");
188       }
189     }
190     else
191     {
192       AliError("Could not get gains !");
193     }
194   }
195   return fGains;
196 }
197
198 //_____________________________________________________________________________
199 AliMUONV2DStore*
200 AliMUONCalibrationData::Pedestals() const
201 {
202   //
203   // Create (if needed) and return the internal storage for pedestals.
204   //
205   if (!fPedestals)
206   {
207     AliCDBEntry* entry = GetEntry("MUON/Calib/Pedestals");
208     if (entry)
209     {
210       fPedestals = dynamic_cast<AliMUONV2DStore*>(entry->GetObject());
211       if (!fPedestals)
212       {
213         AliError("fPedestals not of the expected type !!!");
214       }
215     }
216     else
217     {
218       AliError("Could not get pedestals !");
219     }
220   }
221   return fPedestals;
222 }
223
224 //_____________________________________________________________________________
225 void
226 AliMUONCalibrationData::Print(Option_t*) const
227 {
228   //
229   // A very basic dump of our guts.
230   //  
231   cout << "RunNumber " << RunNumber()
232     << " fGains=" << fGains
233     << " fPedestals=" << fPedestals
234     << " fDeadChannels=" << fDeadChannels
235   << endl;
236 }
237
238
239 //_____________________________________________________________________________
240 AliMUONVCalibParam*
241 AliMUONCalibrationData::Pedestal(Int_t detElemId, Int_t manuId) const
242 {
243   //
244   // Return the pedestals for a given (detElemId, manuId) pair.
245   // A return value of 0x0 is considered an error, meaning we should get
246   // pedestals for all channels.
247   //
248   AliMUONVCalibParam* ped = 
249     static_cast<AliMUONVCalibParam*>(Pedestals()->Get(detElemId,manuId));
250   if (!ped)
251   {
252     AliError(Form("Could not get pedestal for detElemId=%d manuId=%d ",
253                   detElemId,manuId));
254   }
255   return ped;
256 }
257
258