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