]>
Commit | Line | Data |
---|---|---|
c5bdf179 | 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 "AliMUONCalibParam.h" | |
24 | #include "AliLog.h" | |
25 | #include "AliMUONV3DStore.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 | { | |
39 | if ( deferredInitialization == kFALSE ) | |
40 | { | |
41 | Gains(); | |
42 | Pedestals(); | |
43 | } | |
44 | } | |
45 | ||
46 | ||
47 | //_____________________________________________________________________________ | |
48 | AliMUONCalibrationData::~AliMUONCalibrationData() | |
49 | { | |
50 | delete fPedestals; | |
51 | delete fGains; | |
52 | } | |
53 | ||
54 | //_____________________________________________________________________________ | |
55 | AliCDBEntry* | |
56 | AliMUONCalibrationData::GetEntry(const char* path) const | |
57 | { | |
58 | AliInfo(Form("Fetching %s from Condition DataBase for run %d",path,fRunNumber)); | |
59 | ||
60 | AliCDBManager* man = AliCDBManager::Instance(); | |
61 | if (!man->IsDefaultStorageSet()) | |
62 | { | |
63 | AliError("No default CDB storage set !"); | |
64 | fIsValid = kFALSE; | |
65 | return 0; | |
66 | } | |
67 | ||
68 | AliCDBStorage* storage = man->GetDefaultStorage(); | |
69 | ||
70 | AliCDBEntry* entry = storage->Get(path,fRunNumber); | |
71 | return entry; | |
72 | } | |
73 | ||
74 | //_____________________________________________________________________________ | |
75 | AliMUONCalibParam* | |
76 | AliMUONCalibrationData::Gain(Int_t detElemId, | |
77 | Int_t manuId, Int_t manuChannel) const | |
78 | { | |
79 | AliMUONCalibParam* gain = | |
80 | static_cast<AliMUONCalibParam*>(Gains()->Get(detElemId,manuId,manuChannel)); | |
81 | if (!gain) | |
82 | { | |
83 | AliError(Form("Could not get gain for detElemId=%d manuId=%d " | |
84 | "manuChannel=%d",detElemId,manuId,manuChannel)); | |
85 | } | |
86 | return gain; | |
87 | } | |
88 | ||
89 | //_____________________________________________________________________________ | |
90 | AliMUONV3DStore* | |
91 | AliMUONCalibrationData::Gains() const | |
92 | { | |
93 | if (!fGains) | |
94 | { | |
95 | AliCDBEntry* entry = GetEntry("MUON/Calib/Gains"); | |
96 | if (entry) | |
97 | { | |
98 | fGains = dynamic_cast<AliMUONV3DStore*>(entry->GetObject()); | |
99 | if (!fGains) | |
100 | { | |
101 | AliError("Gains not of the expected type !!!"); | |
102 | } | |
103 | } | |
104 | else | |
105 | { | |
106 | AliError("Could not get gains !"); | |
107 | } | |
108 | } | |
109 | return fGains; | |
110 | } | |
111 | ||
112 | //_____________________________________________________________________________ | |
113 | Bool_t | |
114 | AliMUONCalibrationData::IsValid() const | |
115 | { | |
116 | return fIsValid; | |
117 | } | |
118 | ||
119 | //_____________________________________________________________________________ | |
120 | AliMUONV3DStore* | |
121 | AliMUONCalibrationData::Pedestals() const | |
122 | { | |
123 | if (!fPedestals) | |
124 | { | |
125 | AliCDBEntry* entry = GetEntry("MUON/Calib/Pedestals"); | |
126 | if (entry) | |
127 | { | |
128 | fPedestals = dynamic_cast<AliMUONV3DStore*>(entry->GetObject()); | |
129 | if (!fPedestals) | |
130 | { | |
131 | AliError("fPedestals not of the expected type !!!"); | |
132 | } | |
133 | } | |
134 | else | |
135 | { | |
136 | AliError("Could not get pedestals !"); | |
137 | } | |
138 | } | |
139 | return fPedestals; | |
140 | } | |
141 | ||
142 | //_____________________________________________________________________________ | |
143 | void | |
144 | AliMUONCalibrationData::Print(Option_t*) const | |
145 | { | |
146 | cout << "RunNumber " << RunNumber() | |
147 | << " fGains=" << fGains | |
148 | << " fPedestals=" << fPedestals | |
149 | << endl; | |
150 | } | |
151 | ||
152 | //_____________________________________________________________________________ | |
153 | Int_t | |
154 | AliMUONCalibrationData::RunNumber() const | |
155 | { | |
156 | return fRunNumber; | |
157 | } | |
158 | ||
159 | //_____________________________________________________________________________ | |
160 | AliMUONCalibParam* | |
161 | AliMUONCalibrationData::Pedestal(Int_t detElemId, | |
162 | Int_t manuId, Int_t manuChannel) const | |
163 | { | |
164 | AliMUONCalibParam* ped = | |
165 | static_cast<AliMUONCalibParam*>(Pedestals()->Get(detElemId,manuId,manuChannel)); | |
166 | if (!ped) | |
167 | { | |
168 | AliError(Form("Could not get pedestal for detElemId=%d manuId=%d " | |
169 | "manuChannel=%d",detElemId,manuId,manuChannel)); | |
170 | } | |
171 | return ped; | |
172 | } | |
173 | ||
174 |