]>
Commit | Line | Data |
---|---|---|
b3c7c475 | 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 | /// By Laurent Aphecetche | |
19 | ||
20 | #if !defined(__CINT__) || defined(__MAKECINT__) | |
d29760d6 | 21 | |
b3c7c475 | 22 | #include "MUONCDB.h" |
d29760d6 | 23 | |
b3c7c475 | 24 | #include "AliCDBEntry.h" |
25 | #include "AliCDBManager.h" | |
c3357e6d | 26 | #include "AliDCSValue.h" |
d29760d6 | 27 | #include "AliMUON1DArray.h" |
8f7d7575 | 28 | #include "AliMUON2DMap.h" |
c3357e6d | 29 | #include "AliMUON2DStoreValidator.h" |
8f7d7575 | 30 | #include "AliMUONCalibParam1I.h" |
31 | #include "AliMUONCalibParam2F.h" | |
d29760d6 | 32 | #include "AliMUONConstants.h" |
c3357e6d | 33 | #include "AliMUONHVNamer.h" |
5322694c | 34 | #include "AliMUONObjectPair.h" |
35 | #include "AliMUONTriggerEfficiencyCells.h" | |
d29760d6 | 36 | #include "AliMUONTriggerLut.h" |
37 | #include "AliMUONV2DStore.h" | |
38 | #include "AliMUONVCalibParam.h" | |
c3357e6d | 39 | #include "AliMUONVCalibParam.h" |
5322694c | 40 | #include "AliMUONVDataIterator.h" |
b3c7c475 | 41 | #include "AliMpDEIterator.h" |
42 | #include "AliMpDEManager.h" | |
5322694c | 43 | #include "AliMpManuList.h" |
3e8e7033 | 44 | #include "AliMpSegmentation.h" |
3e8e7033 | 45 | #include "AliMpStationType.h" |
c3357e6d | 46 | #include "AliMpVSegmentation.h" |
b3c7c475 | 47 | #include "Riostream.h" |
c3357e6d | 48 | #include "TArrayI.h" |
b3c7c475 | 49 | #include "TH1F.h" |
50 | #include "TList.h" | |
c3357e6d | 51 | #include "TMap.h" |
52 | #include "TObjString.h" | |
b3c7c475 | 53 | #include "TRandom.h" |
54 | #include "TStopwatch.h" | |
55 | #include "TSystem.h" | |
c3357e6d | 56 | #include <map> |
d29760d6 | 57 | |
c3357e6d | 58 | #endif |
8f7d7575 | 59 | |
60 | //_____________________________________________________________________________ | |
5322694c | 61 | AliMUONV2DStore* diff(AliMUONV2DStore& store1, AliMUONV2DStore& store2, |
62 | const char* /* opt */) | |
b3c7c475 | 63 | { |
5322694c | 64 | // creates a store which contains store1-store2 |
65 | // if opt="abs" the difference is absolute one, | |
66 | // if opt="rel" then what is stored is (store1-store2)/store1 | |
b3c7c475 | 67 | |
5322694c | 68 | AliMUONV2DStore* d = static_cast<AliMUONV2DStore*>(store1.Clone()); |
69 | ||
70 | AliMUONVDataIterator* it = d->Iterator(); | |
71 | ||
72 | AliMUONObjectPair* p; | |
b3c7c475 | 73 | |
5322694c | 74 | while ( ( p = dynamic_cast<AliMUONObjectPair*>(it->Next() ) ) ) |
b3c7c475 | 75 | { |
5322694c | 76 | AliMpIntPair* dm = dynamic_cast<AliMpIntPair*>(p->Key()); |
77 | //FIXME: this might happen (if a full manu is missing, for instance) | |
78 | //handle it. | |
79 | assert(dm!=0); | |
80 | AliMUONVCalibParam* param = dynamic_cast<AliMUONVCalibParam*>(p->Value()); | |
81 | //FIXMENOT: this should *not* happen | |
82 | assert(param!=0); | |
83 | ||
84 | AliMUONVCalibParam* param2 = dynamic_cast<AliMUONVCalibParam*>(store2.Get(dm->GetFirst(),dm->GetSecond())); | |
85 | //FIXME: this might happen. Handle it. | |
86 | assert(param2!=0); | |
87 | ||
88 | for ( Int_t i = 0; i < param->Size(); ++i ) | |
89 | { | |
90 | for ( Int_t j = 0; j < param->Dimension(); ++j ) | |
91 | { | |
92 | param->SetValueAsFloat(i,j,param->ValueAsFloat(i,j) - param2->ValueAsFloat(i,j)); | |
93 | } | |
94 | } | |
b3c7c475 | 95 | } |
5322694c | 96 | return d; |
97 | } | |
98 | ||
99 | //_____________________________________________________________________________ | |
100 | void getBoundaries(const AliMUONV2DStore& store, | |
101 | Float_t& x0min, Float_t& x0max, | |
102 | Float_t& x1min, Float_t& x1max) | |
103 | { | |
104 | x0min=1E30; | |
105 | x0max=-1E30; | |
106 | x1min=1E30; | |
107 | x1max=-1E30; | |
108 | ||
109 | TList* list = AliMpManuList::ManuList(); | |
110 | TIter next(list); | |
111 | AliMpIntPair* p; | |
112 | ||
113 | while ( ( p = (AliMpIntPair*)next() ) ) | |
b3c7c475 | 114 | { |
5322694c | 115 | Int_t detElemId = p->GetFirst(); |
116 | Int_t manuId = p->GetSecond(); | |
117 | ||
3e8e7033 | 118 | const AliMpVSegmentation* seg = |
119 | AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId,manuId); | |
5322694c | 120 | |
121 | AliMUONVCalibParam* value = | |
122 | dynamic_cast<AliMUONVCalibParam*>(store.Get(detElemId,manuId)); | |
123 | ||
124 | if (!value) continue; | |
125 | ||
126 | for ( Int_t manuChannel = 0; manuChannel < value->Size(); ++manuChannel ) | |
127 | { | |
128 | AliMpPad pad = seg->PadByLocation(AliMpIntPair(manuId,manuChannel),kFALSE); | |
129 | if (!pad.IsValid()) continue; | |
130 | ||
131 | Float_t x0 = value->ValueAsFloat(manuChannel,0); | |
132 | ||
133 | x0min = TMath::Min(x0min,x0); | |
134 | x0max = TMath::Max(x0max,x0); | |
135 | if ( value->Dimension()>1 ) | |
136 | { | |
137 | Float_t x1 = value->ValueAsFloat(manuChannel,1); | |
138 | x1min = TMath::Min(x1min,x1); | |
139 | x1max = TMath::Max(x1max,x1); | |
140 | } | |
141 | } | |
142 | } | |
143 | delete list; | |
144 | } | |
145 | ||
146 | //_____________________________________________________________________________ | |
147 | void plot(const AliMUONV2DStore& store, const char* name, Int_t nbins) | |
148 | { | |
149 | Float_t x0min, x0max, x1min, x1max; | |
150 | ||
151 | getBoundaries(store,x0min,x0max,x1min,x1max); | |
152 | ||
153 | if ( x0min > x0max ) | |
154 | { | |
155 | cerr << Form("Something is wrong with boundaries : x0(min,max)=%e,%e", | |
156 | x0min,x0max) << endl; | |
157 | return; | |
8f7d7575 | 158 | } |
5322694c | 159 | |
160 | if ( TMath::Abs(x0min-x0max) < 1E-3 ) | |
8f7d7575 | 161 | { |
5322694c | 162 | x0min -= 1; |
163 | x0max += 1; | |
b3c7c475 | 164 | } |
5322694c | 165 | |
166 | TH1* h0 = new TH1F(Form("%s_0",name),Form("%s_0",name), | |
167 | nbins,x0min,x0max); | |
168 | ||
169 | TH1* h1(0); | |
170 | ||
171 | if ( x1max > x1min ) | |
b3c7c475 | 172 | { |
5322694c | 173 | h1 = new TH1F(Form("%s_1",name),Form("%s_1",name), |
174 | nbins,x1min,x1max); | |
b3c7c475 | 175 | } |
176 | ||
5322694c | 177 | TList* list = AliMpManuList::ManuList(); |
178 | TIter next(list); | |
8f7d7575 | 179 | AliMpIntPair* p; |
180 | Int_t n(0); | |
8f7d7575 | 181 | Int_t nPerStation[7]; |
182 | ||
183 | for ( Int_t i = 0; i < 7; ++i ) nPerStation[i]=0; | |
b3c7c475 | 184 | |
8f7d7575 | 185 | while ( ( p = (AliMpIntPair*)next() ) ) |
b3c7c475 | 186 | { |
8f7d7575 | 187 | Int_t detElemId = p->GetFirst(); |
188 | Int_t manuId = p->GetSecond(); | |
aaf6e802 | 189 | Int_t station = AliMpDEManager::GetChamberId(detElemId); |
8f7d7575 | 190 | |
3e8e7033 | 191 | const AliMpVSegmentation* seg = |
192 | AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId,manuId); | |
5322694c | 193 | |
8f7d7575 | 194 | AliMUONVCalibParam* value = |
5322694c | 195 | dynamic_cast<AliMUONVCalibParam*>(store.Get(detElemId,manuId)); |
b3c7c475 | 196 | |
b3c7c475 | 197 | if (value) |
198 | { | |
8f7d7575 | 199 | for ( Int_t manuChannel = 0; manuChannel < value->Size(); ++manuChannel ) |
200 | { | |
5322694c | 201 | AliMpPad pad = seg->PadByLocation(AliMpIntPair(manuId,manuChannel),kFALSE); |
202 | if (!pad.IsValid()) continue; | |
203 | ||
8f7d7575 | 204 | ++n; |
205 | ++nPerStation[station]; | |
5322694c | 206 | Float_t x = value->ValueAsFloat(manuChannel,0); |
207 | h0->Fill(x); | |
208 | if (h1) | |
8f7d7575 | 209 | { |
5322694c | 210 | h1->Fill(value->ValueAsFloat(manuChannel,1)); |
8f7d7575 | 211 | } |
212 | } | |
b3c7c475 | 213 | } |
214 | else | |
215 | { | |
216 | cout << "Got a null value for DE=" << detElemId << " manuId=" | |
5322694c | 217 | << manuId << endl; |
b3c7c475 | 218 | } |
219 | } | |
220 | ||
8f7d7575 | 221 | cout << "Number of channels = " << n << endl; |
222 | for ( Int_t i = 0; i < 7; ++i ) | |
223 | { | |
224 | cout << "Station " << (i+1) << " " << nPerStation[i] << endl; | |
225 | } | |
226 | ||
5322694c | 227 | delete list; |
228 | } | |
229 | ||
b3c7c475 | 230 | //_____________________________________________________________________________ |
8f7d7575 | 231 | void testReadStore(const AliMUONV2DStore& store, Int_t n) |
b3c7c475 | 232 | { |
5322694c | 233 | TList* list = AliMpManuList::ManuList(); |
234 | TIter next(list); | |
8f7d7575 | 235 | AliMpIntPair* p; |
b3c7c475 | 236 | |
8f7d7575 | 237 | while ( ( p = (AliMpIntPair*)next() ) ) |
b3c7c475 | 238 | { |
239 | for ( Int_t i = 0; i < n; ++i ) | |
240 | { | |
8f7d7575 | 241 | store.Get(p->GetFirst(),p->GetSecond()); |
b3c7c475 | 242 | } |
243 | } | |
5322694c | 244 | delete list; |
b3c7c475 | 245 | } |
246 | ||
c3357e6d | 247 | //_____________________________________________________________________________ |
248 | Int_t makeHVStore(TMap& aliasMap, Bool_t defaultValues) | |
249 | { | |
250 | AliMUONHVNamer hvNamer; | |
251 | TRandom random; | |
252 | ||
253 | TObjArray* aliases = hvNamer.GenerateAliases(); | |
254 | ||
255 | Int_t nSwitch(0); | |
256 | Int_t nChannels(0); | |
257 | ||
258 | for ( Int_t i = 0; i < aliases->GetEntries(); ++i ) | |
259 | { | |
260 | TObjString* alias = static_cast<TObjString*>(aliases->At(i)); | |
261 | TString& aliasName = alias->String(); | |
262 | if ( aliasName.Contains("sw") ) | |
263 | { | |
264 | // HV Switch (St345 only) | |
265 | TObjArray* valueSet = new TObjArray; | |
266 | valueSet->SetOwner(kTRUE); | |
267 | ||
268 | Bool_t value = kTRUE; | |
269 | ||
270 | if (!defaultValues) | |
271 | { | |
272 | Float_t r = random.Uniform(); | |
273 | if ( r < 0.007 ) value = kFALSE; | |
274 | } | |
275 | ||
276 | for ( UInt_t timeStamp = 0; timeStamp < 60*3; timeStamp += 60 ) | |
277 | { | |
278 | AliDCSValue* dcsValue = new AliDCSValue(value,timeStamp); | |
279 | valueSet->Add(dcsValue); | |
280 | } | |
281 | aliasMap.Add(new TObjString(*alias),valueSet); | |
282 | ++nSwitch; | |
283 | } | |
284 | else | |
285 | { | |
286 | TObjArray* valueSet = new TObjArray; | |
287 | valueSet->SetOwner(kTRUE); | |
288 | for ( UInt_t timeStamp = 0; timeStamp < 60*15; timeStamp += 120 ) | |
289 | { | |
290 | Float_t value = 1500; | |
291 | if (!defaultValues) value = random.Gaus(1750,62.5); | |
292 | AliDCSValue* dcsValue = new AliDCSValue(value,timeStamp); | |
293 | valueSet->Add(dcsValue); | |
294 | } | |
295 | aliasMap.Add(new TObjString(*alias),valueSet); | |
296 | ++nChannels; | |
297 | } | |
298 | } | |
299 | ||
300 | delete aliases; | |
301 | ||
302 | cout << nChannels << " HV channels and " << nSwitch << " switches" << endl; | |
303 | ||
304 | return nChannels+nSwitch; | |
305 | } | |
306 | ||
b3c7c475 | 307 | //_____________________________________________________________________________ |
5322694c | 308 | Int_t makePedestalStore(AliMUONV2DStore& pedestalStore, Bool_t defaultValues) |
309 | { | |
310 | TList* list = AliMpManuList::ManuList(); | |
311 | TIter next(list); | |
b3c7c475 | 312 | |
8f7d7575 | 313 | AliMpIntPair* p; |
b3c7c475 | 314 | |
5322694c | 315 | Int_t nchannels(0); |
316 | Int_t nmanus(0); | |
b3c7c475 | 317 | |
318 | Bool_t replace = kFALSE; | |
319 | ||
8f7d7575 | 320 | const Int_t nChannels(64); |
5322694c | 321 | const Float_t kPedestalMeanMean(150); |
322 | const Float_t kPedestalMeanSigma(10); | |
323 | const Float_t kPedestalSigmaMean(1.0); | |
324 | const Float_t kPedestalSigmaSigma(0.2); | |
8f7d7575 | 325 | |
326 | while ( ( p = (AliMpIntPair*)next() ) ) | |
b3c7c475 | 327 | { |
5322694c | 328 | ++nmanus; |
329 | AliMUONVCalibParam* ped = new AliMUONCalibParam2F(nChannels,AliMUONVCalibParam::InvalidFloatValue()); | |
330 | ||
331 | Int_t detElemId = p->GetFirst(); | |
b70d763d | 332 | |
5322694c | 333 | Int_t manuId = p->GetSecond(); |
334 | ||
3e8e7033 | 335 | const AliMpVSegmentation* seg = |
336 | AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId,manuId); | |
5322694c | 337 | |
8f7d7575 | 338 | for ( Int_t manuChannel = 0; manuChannel < nChannels; ++manuChannel ) |
b3c7c475 | 339 | { |
5322694c | 340 | AliMpPad pad = seg->PadByLocation(AliMpIntPair(manuId,manuChannel),kFALSE); |
341 | if (!pad.IsValid()) continue; | |
342 | ||
343 | ++nchannels; | |
344 | ||
8f7d7575 | 345 | Float_t meanPedestal; |
346 | Float_t sigmaPedestal; | |
5322694c | 347 | |
8f7d7575 | 348 | if ( defaultValues ) |
b3c7c475 | 349 | { |
8f7d7575 | 350 | meanPedestal = 0.0; |
351 | sigmaPedestal = 1.0; | |
b3c7c475 | 352 | } |
8f7d7575 | 353 | else |
b3c7c475 | 354 | { |
8f7d7575 | 355 | meanPedestal = -1; |
356 | while ( meanPedestal < 0 ) | |
357 | { | |
5322694c | 358 | meanPedestal = gRandom->Gaus(kPedestalMeanMean,kPedestalMeanSigma); |
8f7d7575 | 359 | } |
360 | sigmaPedestal = -1; | |
361 | while ( sigmaPedestal < 0 ) | |
362 | { | |
5322694c | 363 | sigmaPedestal = gRandom->Gaus(kPedestalSigmaMean,kPedestalSigmaSigma); |
8f7d7575 | 364 | } |
b3c7c475 | 365 | } |
8f7d7575 | 366 | ped->SetValueAsFloat(manuChannel,0,meanPedestal); |
367 | ped->SetValueAsFloat(manuChannel,1,sigmaPedestal); | |
8f7d7575 | 368 | |
5322694c | 369 | } |
370 | Bool_t ok = pedestalStore.Set(detElemId,manuId,ped,replace); | |
371 | if (!ok) | |
372 | { | |
373 | cout << "Could not set DetElemId=" << detElemId << " manuId=" | |
374 | << manuId << endl; | |
375 | } | |
376 | } | |
377 | ||
378 | delete list; | |
379 | cout << nmanus << " Manus and " << nchannels << " channels." << endl; | |
380 | return nchannels; | |
381 | ||
382 | } | |
383 | ||
384 | //_____________________________________________________________________________ | |
385 | Int_t makeGainStore(AliMUONV2DStore& gainStore, Bool_t defaultValues) | |
386 | { | |
387 | TList* list = AliMpManuList::ManuList(); | |
388 | TIter next(list); | |
389 | ||
390 | AliMpIntPair* p; | |
391 | ||
392 | Int_t nchannels(0); | |
393 | Int_t nmanus(0); | |
394 | ||
395 | Bool_t replace = kFALSE; | |
396 | ||
397 | const Int_t nChannels(64); | |
398 | const Double_t kSaturation(3000); | |
399 | const Double_t kGainMean(1.0); | |
400 | const Double_t kGainSigma(0.05); | |
401 | ||
402 | while ( ( p = (AliMpIntPair*)next() ) ) | |
403 | { | |
404 | ++nmanus; | |
405 | AliMUONVCalibParam* gain = new AliMUONCalibParam2F(nChannels,AliMUONVCalibParam::InvalidFloatValue()); | |
406 | ||
407 | Int_t detElemId = p->GetFirst(); | |
408 | Int_t manuId = p->GetSecond(); | |
409 | ||
3e8e7033 | 410 | const AliMpVSegmentation* seg = |
411 | AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId,manuId); | |
5322694c | 412 | |
413 | for ( Int_t manuChannel = 0; manuChannel < nChannels; ++manuChannel ) | |
414 | { | |
415 | AliMpPad pad = seg->PadByLocation(AliMpIntPair(manuId,manuChannel),kFALSE); | |
416 | if (!pad.IsValid()) continue; | |
417 | ||
418 | ++nchannels; | |
419 | ||
420 | Float_t meanGain; | |
421 | Float_t saturation(kSaturation); | |
422 | ||
423 | if ( defaultValues ) | |
b3c7c475 | 424 | { |
5322694c | 425 | meanGain = 1.0; |
426 | } | |
427 | else | |
428 | { | |
429 | meanGain = -1; | |
430 | while ( meanGain < 0 ) | |
8f7d7575 | 431 | { |
5322694c | 432 | meanGain = gRandom->Gaus(kGainMean,kGainSigma); |
8f7d7575 | 433 | } |
b3c7c475 | 434 | } |
5322694c | 435 | gain->SetValueAsFloat(manuChannel,0,meanGain); |
436 | gain->SetValueAsFloat(manuChannel,1,saturation); | |
437 | ||
b3c7c475 | 438 | } |
5322694c | 439 | Bool_t ok = gainStore.Set(detElemId,manuId,gain,replace); |
440 | if (!ok) | |
b3c7c475 | 441 | { |
442 | cout << "Could not set DetElemId=" << detElemId << " manuId=" | |
8f7d7575 | 443 | << manuId << endl; |
b3c7c475 | 444 | } |
b3c7c475 | 445 | } |
446 | ||
5322694c | 447 | delete list; |
448 | cout << nmanus << " Manus and " << nchannels << " channels." << endl; | |
449 | return nchannels; | |
b3c7c475 | 450 | } |
451 | ||
b3c7c475 | 452 | //_____________________________________________________________________________ |
8f7d7575 | 453 | void testMakeStores(Int_t readLoop) |
b3c7c475 | 454 | { |
8f7d7575 | 455 | AliMUONV2DStore* pedestalStore = new AliMUON2DMap; |
456 | AliMUONV2DStore* gainStore = new AliMUON2DMap; | |
b3c7c475 | 457 | |
458 | TStopwatch timer; | |
459 | ||
460 | cout << "Creating" << endl; | |
461 | ||
5322694c | 462 | Bool_t defaultValues = kTRUE; |
463 | ||
b3c7c475 | 464 | timer.Start(kTRUE); |
5322694c | 465 | makePedestalStore(*pedestalStore,defaultValues); |
466 | makeGainStore(*gainStore,defaultValues); | |
b3c7c475 | 467 | timer.Print(); |
468 | ||
469 | cout << "Reading..." << endl; | |
470 | timer.Start(kTRUE); | |
471 | testReadStore(*pedestalStore,readLoop); | |
472 | testReadStore(*gainStore,readLoop); | |
473 | cout << timer.CpuTime()/readLoop << " CPUs (mean of " << readLoop | |
474 | <<" samples." << endl; | |
475 | ||
476 | delete pedestalStore; | |
477 | delete gainStore; | |
478 | } | |
479 | ||
d29760d6 | 480 | //_____________________________________________________________________________ |
481 | void generateTrigger(const char* cdbpath) | |
482 | { | |
483 | // | |
484 | // Generate trigger related conditions : | |
485 | // | |
486 | // - trigger masks for board (locals, regionals, global) | |
487 | // - trigger lut | |
488 | // - trigger efficiency | |
489 | // - trigger switches (to be implemented FIXME) | |
490 | // | |
491 | const Int_t nlboards = 234; | |
492 | AliMUONV1DStore* localBoardMasks = new AliMUON1DArray(nlboards+1); | |
493 | ||
494 | // Generate fake mask values for 234 localboards and put that into | |
495 | // one single container (localBoardMasks) | |
496 | for ( Int_t i = 1; i <= nlboards; ++i ) | |
497 | { | |
498 | AliMUONVCalibParam* localBoard = new AliMUONCalibParam1I(8); | |
499 | for ( Int_t x = 0; x < 2; ++x ) | |
500 | { | |
501 | for ( Int_t y = 0; y < 4; ++y ) | |
502 | { | |
503 | Int_t index = x*4+y; | |
504 | localBoard->SetValueAsInt(index,0,0xFFFF); | |
505 | } | |
506 | } | |
507 | localBoardMasks->Set(i,localBoard,kFALSE); | |
508 | } | |
509 | ||
510 | // Generate values for regional boards | |
511 | const Int_t nrboards = 16; | |
512 | AliMUONV1DStore* regionalBoardMasks = new AliMUON1DArray(16); | |
513 | ||
514 | for ( Int_t i = 0; i < nrboards; ++i ) | |
515 | { | |
516 | AliMUONVCalibParam* regionalBoard = new AliMUONCalibParam1I(16); | |
517 | for ( Int_t j = 0; j < 16; ++j ) | |
518 | { | |
519 | regionalBoard->SetValueAsInt(j,0,0x3F); | |
520 | } | |
521 | regionalBoardMasks->Set(i,regionalBoard,kFALSE); | |
522 | } | |
523 | ||
524 | // Generate values for global board | |
525 | AliMUONVCalibParam* globalBoardMasks = new AliMUONCalibParam1I(16); | |
526 | ||
527 | for ( Int_t j = 0; j < 16; ++j ) | |
528 | { | |
529 | globalBoardMasks->SetValueAsInt(j,0,0xFFF); | |
530 | } | |
531 | ||
532 | AliMUONTriggerLut lut; | |
bc6da0f1 | 533 | lut.ReadFromFile("$(ALICE_ROOT)/MUON/data/lutAptLpt1Hpt1p7.root"); |
d29760d6 | 534 | |
535 | AliMUONTriggerEfficiencyCells cells("$ALICE_ROOT/MUON/data/efficiencyCells.dat"); | |
536 | ||
537 | //-------------------------------------------- | |
538 | // Store the resulting containers into the CDB | |
539 | Int_t ever = 99999999; | |
540 | ||
541 | AliCDBId id("MUON/Calib/LocalTriggerBoardMasks",0,ever); | |
542 | ||
543 | AliCDBMetaData md; | |
544 | md.SetBeamPeriod(1); | |
545 | md.SetAliRootVersion(gROOT->GetVersion()); | |
546 | md.SetComment("Test with default values"); | |
547 | md.SetResponsible("Rachid Guernane"); | |
548 | ||
549 | AliCDBManager* man = AliCDBManager::Instance(); | |
550 | man->SetDefaultStorage(cdbpath); | |
551 | man->Put(localBoardMasks,id,&md); | |
552 | ||
553 | id.SetPath("MUON/Calib/RegionalTriggerBoardMasks"); | |
554 | ||
555 | man->Put(regionalBoardMasks,id,(AliCDBMetaData*)md.Clone()); | |
556 | ||
557 | id.SetPath("MUON/Calib/GlobalTriggerBoardMasks"); | |
558 | ||
559 | man->Put(globalBoardMasks,id,(AliCDBMetaData*)md.Clone()); | |
560 | ||
561 | id.SetPath("MUON/Calib/TriggerLut"); | |
562 | ||
563 | man->Put(&lut,id,(AliCDBMetaData*)md.Clone()); | |
564 | ||
565 | id.SetPath("MUON/Calib/TriggerEfficiency"); | |
566 | md.SetResponsible("Diego Stocco"); | |
567 | ||
568 | man->Put(&cells,id,(AliCDBMetaData*)md.Clone()); | |
569 | ||
570 | delete localBoardMasks; | |
571 | delete regionalBoardMasks; | |
572 | delete globalBoardMasks; | |
573 | } | |
574 | ||
5322694c | 575 | |
b3c7c475 | 576 | //_____________________________________________________________________________ |
5322694c | 577 | void writeToCDB(const char* cdbpath, const char* calibpath, TObject* object, |
578 | Int_t startRun, Int_t endRun, Bool_t defaultValues) | |
b3c7c475 | 579 | { |
5322694c | 580 | AliCDBId id(calibpath,startRun,endRun); |
b3c7c475 | 581 | AliCDBMetaData md; |
582 | md.SetBeamPeriod(1); | |
583 | md.SetAliRootVersion(gROOT->GetVersion()); | |
584 | if ( defaultValues ) | |
585 | { | |
586 | md.SetComment("Test with default values"); | |
587 | } | |
588 | else | |
589 | { | |
590 | md.SetComment("Test with random values"); | |
591 | } | |
592 | md.SetResponsible("Laurent Aphecetche"); | |
593 | ||
594 | AliCDBManager* man = AliCDBManager::Instance(); | |
595 | man->SetDefaultStorage(cdbpath); | |
5322694c | 596 | man->Put(object,id,&md); |
597 | } | |
598 | ||
c3357e6d | 599 | //_____________________________________________________________________________ |
600 | void writeHV(const char* cdbpath, Bool_t defaultValues, | |
601 | Int_t startRun, Int_t endRun) | |
602 | { | |
603 | /// generate HV values (either cste = 1500 V) if defaultValues=true or random | |
604 | /// if defaultValues=false, see makeHVStore) and | |
605 | /// store them into CDB located at cdbpath, with a validity period | |
606 | /// ranging from startRun to endRun | |
607 | ||
608 | TMap* hvStore = new TMap; | |
609 | Int_t ngenerated = makeHVStore(*hvStore,defaultValues); | |
610 | cout << "Ngenerated = " << ngenerated << endl; | |
611 | ||
612 | writeToCDB(cdbpath,"MUON/Calib/HV",hvStore,startRun,endRun,defaultValues); | |
613 | ||
614 | delete hvStore; | |
615 | } | |
616 | ||
5322694c | 617 | //_____________________________________________________________________________ |
618 | void writePedestals(const char* cdbpath, Bool_t defaultValues, | |
619 | Int_t startRun, Int_t endRun) | |
620 | { | |
c3357e6d | 621 | /// generate pedestal values (either 0 if defaultValues=true or random |
622 | /// if defaultValues=false, see makePedestalStore) and | |
623 | /// store them into CDB located at cdbpath, with a validity period | |
624 | /// ranging from startRun to endRun | |
625 | ||
5322694c | 626 | AliMUONV2DStore* pedestalStore = new AliMUON2DMap; |
627 | Int_t ngenerated = makePedestalStore(*pedestalStore,defaultValues); | |
628 | cout << "Ngenerated = " << ngenerated << endl; | |
b3c7c475 | 629 | |
5322694c | 630 | writeToCDB(cdbpath,"MUON/Calib/Pedestals",pedestalStore,startRun,endRun,defaultValues); |
c3357e6d | 631 | delete pedestalStore; |
5322694c | 632 | } |
633 | ||
634 | //_____________________________________________________________________________ | |
635 | void writeGains(const char* cdbpath, Bool_t defaultValues, | |
636 | Int_t startRun, Int_t endRun) | |
637 | { | |
c3357e6d | 638 | /// generate gain values (either 1 if defaultValues=true or random |
639 | /// if defaultValues=false, see makePedestalStore) and | |
640 | /// store them into CDB located at cdbpath, with a validity period | |
641 | /// ranging from startRun to endRun | |
642 | ||
5322694c | 643 | AliMUONV2DStore* gainStore = new AliMUON2DMap; |
644 | Int_t ngenerated = makeGainStore(*gainStore,defaultValues); | |
645 | cout << "Ngenerated = " << ngenerated << endl; | |
8f7d7575 | 646 | |
5322694c | 647 | writeToCDB(cdbpath,"MUON/Calib/Gains",gainStore,startRun,endRun,defaultValues); |
c3357e6d | 648 | delete gainStore; |
5322694c | 649 | } |
650 | ||
651 | //_____________________________________________________________________________ | |
c3357e6d | 652 | Bool_t check1I(const AliMUONVCalibParam& calib, Int_t channel) |
5322694c | 653 | { |
c3357e6d | 654 | /// |
655 | ||
656 | return ( calib.ValueAsInt(channel) == 0); | |
657 | } | |
658 | ||
659 | //_____________________________________________________________________________ | |
660 | void validate1I(const AliMUONV2DStore& store) | |
661 | { | |
662 | AliMUON2DStoreValidator validator; | |
663 | ||
664 | TObjArray* a = validator.Validate(store,check1I); | |
665 | ||
666 | if (a) a->Print(); | |
667 | ||
668 | TList lines; | |
669 | ||
670 | validator.Report(lines); | |
671 | ||
672 | lines.Print(); | |
673 | } | |
674 | ||
675 | //_____________________________________________________________________________ | |
676 | void validate2F(const AliMUONV2DStore& store) | |
677 | { | |
678 | AliMUON2DStoreValidator validator; | |
679 | ||
680 | TObjArray* a = validator.Validate(store,AliMUONCalibParam2F::InvalidFloatValue()); | |
681 | ||
682 | if (a) a->Print(); | |
683 | ||
684 | TList lines; | |
685 | ||
686 | validator.Report(lines); | |
687 | ||
688 | lines.Print(); | |
689 | } | |
690 | ||
691 | //_____________________________________________________________________________ | |
692 | void dump(const TArrayI& a, const char* what) | |
693 | { | |
694 | cout << what << " " << a.GetSize() << " manus" << endl; | |
695 | for ( Int_t i = 0; i < a.GetSize(); ++i ) | |
696 | { | |
697 | cout << Form(" %5d ",a[i]); | |
698 | } | |
699 | cout << endl; | |
700 | } | |
701 | ||
702 | //_____________________________________________________________________________ | |
703 | void countManus() | |
704 | { | |
705 | AliMpDEIterator it; | |
706 | ||
707 | it.First(); | |
708 | ||
709 | Int_t b(0); | |
710 | Int_t nb(0); | |
711 | ||
712 | while (!it.IsDone()) | |
713 | { | |
714 | Int_t detElemId = it.CurrentDEId(); | |
715 | AliMp::StationType stationType = AliMpDEManager::GetStationType(detElemId); | |
716 | if ( stationType != AliMp::kStationTrigger ) | |
717 | { | |
718 | const AliMpVSegmentation* seg0 = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::kCath0); | |
719 | const AliMpVSegmentation* seg1 = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::kCath1); | |
720 | TArrayI a1; | |
721 | TArrayI a0; | |
722 | seg0->GetAllElectronicCardIDs(a0); | |
723 | seg1->GetAllElectronicCardIDs(a1); | |
724 | ||
725 | cout << Form("DE %5d B %4d NB %4d Total %5d",detElemId, | |
726 | a0.GetSize(),a1.GetSize(),a0.GetSize()+a1.GetSize()) | |
727 | << endl; | |
728 | ||
729 | b += a0.GetSize(); | |
730 | nb += a1.GetSize(); | |
731 | ||
732 | if ( detElemId == 500 ) | |
733 | { | |
734 | dump(a0,"B"); | |
735 | dump(a1,"NB"); | |
736 | } | |
737 | } | |
738 | it.Next(); | |
739 | } | |
740 | ||
741 | cout << Form("B %5d NB %5d Total %5d",b,nb,b+nb) << endl; | |
742 | } | |
743 | ||
744 | //_____________________________________________________________________________ | |
745 | void count(const AliMUONV2DStore& store) | |
746 | { | |
747 | AliMUONVDataIterator* it = store.Iterator(); | |
748 | AliMUONObjectPair* pair; | |
749 | std::map<int,std::pair<int,int> > demap; | |
750 | ||
751 | while ( ( pair = static_cast<AliMUONObjectPair*>(it->Next()) ) ) | |
752 | { | |
753 | AliMpIntPair* ip = static_cast<AliMpIntPair*>(pair->First()); | |
754 | ||
755 | Int_t detElemId = ip->GetFirst(); | |
756 | ||
757 | Int_t manuId = ip->GetSecond(); | |
758 | ||
759 | const AliMpVSegmentation* seg = | |
760 | AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId,manuId); | |
761 | ||
762 | if ( seg->PlaneType() == AliMp::kNonBendingPlane ) | |
763 | { | |
764 | demap[detElemId].second++; | |
765 | } | |
766 | else | |
767 | { | |
768 | demap[detElemId].first++; | |
769 | } | |
770 | } | |
771 | ||
772 | std::map<int,std::pair<int,int> >::const_iterator mit; | |
773 | ||
774 | Int_t b(0); | |
775 | Int_t nb(0); | |
776 | ||
777 | for ( mit = demap.begin(); mit != demap.end(); ++mit ) | |
778 | { | |
779 | cout << Form("DE %5d B %4d NB %4d Total %5d",mit->first, | |
780 | mit->second.first,mit->second.second, | |
781 | mit->second.first+mit->second.second) << endl; | |
782 | b += mit->second.first; | |
783 | nb += mit->second.second; | |
784 | } | |
8f7d7575 | 785 | |
c3357e6d | 786 | cout << Form("B %5d NB %5d Total %5d",b,nb,b+nb) << endl; |
b3c7c475 | 787 | } |
788 | ||
789 |