]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONTrackerOCDBDataMaker.cxx
Added QA for digits during reconstruction (Yves)
[u/mrichter/AliRoot.git] / MUON / AliMUONTrackerOCDBDataMaker.cxx
CommitLineData
0145e89a 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 "AliMUONTrackerOCDBDataMaker.h"
19
0145e89a 20#include "AliCDBManager.h"
21#include "AliCDBStorage.h"
1ffbeb9d 22#include "AliDCSValue.h"
23#include "AliLog.h"
24#include "AliMUON2DMap.h"
25#include "AliMUONCalibParamND.h"
0145e89a 26#include "AliMUONCalibrationData.h"
1ffbeb9d 27#include "AliMUONTrackerData.h"
0145e89a 28#include "AliMUONVStore.h"
1ffbeb9d 29#include "AliMpConstants.h"
30#include "AliMpDDLStore.h"
31#include "AliMpDetElement.h"
e83120bd 32#include "AliMpDEManager.h"
49e110ec 33#include "AliMpDCSNamer.h"
1ffbeb9d 34#include <TClass.h>
35#include <TMap.h>
36#include <TObjArray.h>
37#include <TObjString.h>
0145e89a 38#include <TString.h>
39
40///\class AliMUONTrackerOCDBDataMaker
41///
42/// Producer of AliMUONVTrackerData from OCDB data
43///
44///\author Laurent Aphecetche, Subatech
45
46///\cond CLASSIMP
47ClassImp(AliMUONTrackerOCDBDataMaker)
48///\endcond
49
50//_____________________________________________________________________________
51AliMUONTrackerOCDBDataMaker::AliMUONTrackerOCDBDataMaker(const char* ocdbPath,
52 Int_t runNumber,
53 const char* type)
54: AliMUONVTrackerDataMaker(),
55 fIsValid(kTRUE),
0145e89a 56 fData(0x0),
57 fSource(Form("%s-%010d-%s",ocdbPath,runNumber,type))
58{
143cd71a 59 /// Ctor
60 AliCDBStorage* storage = AliCDBManager::Instance()->GetDefaultStorage();
61
62 AliCDBManager::Instance()->SetDefaultStorage(ocdbPath);
63
64 AliMUONVStore* store(0x0);
65
66 TString stype(type);
67 stype.ToUpper();
68 Bool_t isSingleEvent(kTRUE);
69 Int_t startOfValidity(0);
70
71 if ( stype == "PEDESTALS" )
72 {
73 store = AliMUONCalibrationData::CreatePedestals(runNumber,&startOfValidity);
74 fData = CreateDataPedestals(startOfValidity);
75 }
2b8a1212 76 else if ( stype == "KILLMAP" )
77 {
78 store = AliMUONCalibrationData::CreateKillMap(runNumber,&startOfValidity);
79 fData = CreateDataKillMap(startOfValidity);
80 }
143cd71a 81 else if ( stype == "GAINS" )
82 {
83 AliMUONVStore* gains = AliMUONCalibrationData::CreateGains(runNumber,&startOfValidity);
84 fData = CreateDataGains(startOfValidity);
85 store = SplitQuality(*gains);
86 delete gains;
87 }
88 else if ( stype == "CAPACITANCES" )
89 {
90 store = AliMUONCalibrationData::CreateCapacitances(runNumber,&startOfValidity);
91 fData = CreateDataCapacitances(startOfValidity);
92 }
93 else if ( stype == "HV" )
94 {
95 TMap* m = AliMUONCalibrationData::CreateHV(runNumber,&startOfValidity);
96 fData = new AliMUONTrackerData(Form("HV%d",startOfValidity),"High Voltages",1,!isSingleEvent);
97 fData->SetDimensionName(0,"HV");
98 store = CreateHVStore(*m);
99 delete m;
100 }
101
102 AliCDBManager::Instance()->SetDefaultStorage(storage);
103
104 if (!store)
105 {
106 fIsValid = kFALSE;
107 delete fData;
108 fData = 0x0;
109 AliError("Could not create store");
110 return;
111 }
112
113 fData->Add(*store);
114
115 delete store;
0145e89a 116}
117
118//_____________________________________________________________________________
119AliMUONTrackerOCDBDataMaker::~AliMUONTrackerOCDBDataMaker()
120{
121 /// dtor
49419555 122 delete fData;
0145e89a 123}
49419555 124
1ffbeb9d 125//_____________________________________________________________________________
126AliMUONVTrackerData*
127AliMUONTrackerOCDBDataMaker::CreateDataCapacitances(Int_t runNumber)
128{
129 /// Create data to hold capa values
130
131 AliMUONVTrackerData* data = new AliMUONTrackerData(Form("CAPA%d",runNumber),"Capacitances",2,kTRUE);
132 data->SetDimensionName(0,"Capa");
133 data->SetDimensionName(1,"Injection gain");
134 return data;
135}
136
137//_____________________________________________________________________________
138AliMUONVTrackerData*
139AliMUONTrackerOCDBDataMaker::CreateDataGains(Int_t runNumber)
140{
141 /// Create data to hold gains values
142
143 AliMUONVTrackerData* data = new AliMUONTrackerData(Form("GAIN%d",runNumber),"Gains",6,kTRUE);
144 data->SetDimensionName(0,"a1");
145 data->SetDimensionName(1,"a2");
146 data->SetDimensionName(2,"thres");
147 data->SetDimensionName(3,"qual1");
148 data->SetDimensionName(4,"qual2");
149 data->SetDimensionName(5,"sat");
150 return data;
151}
152
153//_____________________________________________________________________________
154AliMUONVTrackerData*
155AliMUONTrackerOCDBDataMaker::CreateDataPedestals(Int_t runNumber)
156{
157 /// Create data to hold pedestal values
158
159 AliMUONVTrackerData* data = new AliMUONTrackerData(Form("PED%d",runNumber),"Pedestals",2,kTRUE);
160 data->SetDimensionName(0,"Mean");
161 data->SetDimensionName(1,"Sigma");
162 return data;
163}
164
2b8a1212 165//_____________________________________________________________________________
166AliMUONVTrackerData*
167AliMUONTrackerOCDBDataMaker::CreateDataKillMap(Int_t runNumber)
168{
169 /// Create data to hold pedestal values
170
171 AliMUONVTrackerData* data = new AliMUONTrackerData(Form("KILL%d",runNumber),"KillMap",1,kTRUE);
172 data->SetDimensionName(0,"Kill");
173 return data;
174}
175
1ffbeb9d 176//_____________________________________________________________________________
177AliMUONVStore*
178AliMUONTrackerOCDBDataMaker::CreateHVStore(TMap& m)
179{
180 /// Create a store from hv values
181
182 AliMUONVStore* store = new AliMUON2DMap(kTRUE);
183
184 TIter next(&m);
185 TObjString* s;
49e110ec 186 AliMpDCSNamer hvNamer("TRACKER");
1ffbeb9d 187
188 while ( ( s = static_cast<TObjString*>(next()) ) )
189 {
190 TString name(s->String());
191
192 Int_t detElemId = hvNamer.DetElemIdFromDCSAlias(name.Data());
193
e83120bd 194 if ( !AliMpDEManager::IsValidDetElemId(detElemId) )
195 {
196 AliErrorClass(Form("Got an invalid DE = %d from alias = %s",
197 detElemId,name.Data()));
198 continue;
199 }
200
1ffbeb9d 201 Int_t nindex = 1;
49e110ec 202 Int_t hvIndex = hvNamer.DCSIndexFromDCSAlias(name.Data());
1ffbeb9d 203
204 if ( hvIndex > 0 && detElemId >= 500 )
205 {
206 AliFatalClass("FIXME"); // there's now switch aliases which should be taken into account
207 }
208
209 if ( hvIndex == -2 ) // we should consider switch alias there...
210 {
211 nindex = hvNamer.NumberOfPCBs(detElemId);
212 hvIndex = 0;
213 }
214
215 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
216
217 for ( int i = 0 ; i < nindex; ++i )
218 {
219 Int_t index = hvIndex + i ;
220
221 const AliMpArrayI* manus = de->ManusForHV(index);
222
223 TPair* p = static_cast<TPair*>(m.FindObject(name.Data()));
224 TObjArray* a = static_cast<TObjArray*>(p->Value());
225 TIter n2(a);
226 AliDCSValue* v;
227 Float_t hvValue(0);
228 Int_t n(0);
229 while ( ( v = static_cast<AliDCSValue*>(n2()) ) )
230 {
231 hvValue += v->GetFloat();
232 ++n;
233 }
234 if ( n ) hvValue /= n;
235
72dae9ff 236 Int_t nofChannels(AliMpConstants::ManuNofChannels());
1ffbeb9d 237
238 for ( Int_t k = 0 ; k < manus->GetSize(); ++k )
239 {
240 Int_t manuId = manus->GetValue(k);
241 AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(store->FindObject(detElemId,manuId));
242 if ( ! param )
243 {
72dae9ff 244 param = new AliMUONCalibParamND(1,nofChannels,detElemId,manuId,0);
1ffbeb9d 245 store->Add(param);
246 }
72dae9ff 247 for ( Int_t j = 0 ; j < nofChannels; ++j )
1ffbeb9d 248 {
249 param->SetValueAsDouble(j,0,hvValue);
250 }
251 }
252 }
253 }
254
255 return store;
256
257}
258
49419555 259//_____________________________________________________________________________
260Long64_t
261AliMUONTrackerOCDBDataMaker::Merge(TCollection*)
262{
263 /// Merge
264 AliError("Not implemented. Does it have sense ?");
265 return 0;
266}
267
1ffbeb9d 268//_____________________________________________________________________________
269AliMUONVStore*
270AliMUONTrackerOCDBDataMaker::SplitQuality(const AliMUONVStore& gains)
271{
272 /// Create a new store, identical to source gain store, except that qual
273 /// dimension is "decompacted" in two separated values
274
275 AliMUONVStore* store = gains.Create();
276
277 TIter next(gains.CreateIterator());
278 AliMUONVCalibParam* param;
279
280 while ( ( param = static_cast<AliMUONVCalibParam*>(next()) ) )
281 {
282 AliMUONVCalibParam* nd = new AliMUONCalibParamND(param->Dimension()+1,
283 param->Size(),
284 param->ID0(),
285 param->ID1());
286 for ( Int_t i = 0; i < param->Size(); ++i )
287 {
288 for ( Int_t k = 0; k < param->Dimension(); ++k )
289 {
290 if ( k == 3 ) continue;
291 Int_t m = ( k < 3 ? k : k+1 ) ;
292 nd->SetValueAsDouble(i,m,param->ValueAsFloat(i,k));
293 }
294 Int_t qual = param->ValueAsInt(i,3);
cb377016 295
296 Int_t q1 = (qual & 0xF0) >> 4; // linear fit quality
297 Int_t q2 = qual & 0xF; // parabolic fit quality
298
1ffbeb9d 299 nd->SetValueAsInt(i,3,q1);
300 nd->SetValueAsInt(i,4,q2);
301 }
302 store->Add(nd);
303 }
304 return store;
305}