]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONCDB.cxx
Creation of vertex constrained track parameters is moved to AliHLTVertexer,
[u/mrichter/AliRoot.git] / MUON / AliMUONCDB.cxx
CommitLineData
de01cdf0 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
3d1463c8 18//-----------------------------------------------------------------------------
a99c3449 19/// \namespace AliMUONCDB
de01cdf0 20///
a99c3449 21/// Helper functions to experience the OCDB
22///
23/// They allow to read magnetic field, mapping and recoParam from OCDB
24///
25/// And also to generate dummy (but complete) containers for all the
de01cdf0 26/// calibration data types we have for tracker and trigger, and to write
27/// them into OCDB.
28///
a99c3449 29/// For more information, please see READMEcalib
de01cdf0 30///
31// \author Laurent Aphecetche
3d1463c8 32//-----------------------------------------------------------------------------
de01cdf0 33
34#include "AliMUONCDB.h"
35
de01cdf0 36#include "AliMUON1DArray.h"
37#include "AliMUON1DMap.h"
38#include "AliMUON2DMap.h"
39#include "AliMUON2DStoreValidator.h"
7eafe398 40#include "AliMUONCalibParamND.h"
de01cdf0 41#include "AliMUONCalibParamNF.h"
42#include "AliMUONCalibParamNI.h"
43#include "AliMUONConstants.h"
0045b488 44#include "AliMUONRejectList.h"
49419555 45#include "AliMUONTrackerIO.h"
de01cdf0 46#include "AliMUONTriggerEfficiencyCells.h"
47#include "AliMUONTriggerLut.h"
a0eca509 48#include "AliMUONVStore.h"
de01cdf0 49#include "AliMUONVCalibParam.h"
50#include "AliMUONVCalibParam.h"
92c23b09 51#include "AliMUONGlobalCrateConfig.h"
52#include "AliMUONRegionalTriggerConfig.h"
a99c3449 53#include "AliMUONRecoParam.h"
92e36663 54
25e1df3e 55#include "AliMpCDB.h"
a0eca509 56#include "AliMpConstants.h"
a99c3449 57#include "AliMpDEStore.h"
de01cdf0 58#include "AliMpDDLStore.h"
ab167304 59#include "AliMpManuStore.h"
de01cdf0 60#include "AliMpDEManager.h"
61#include "AliMpDetElement.h"
92c23b09 62#include "AliMpFiles.h"
49e110ec 63#include "AliMpDCSNamer.h"
409de10f 64#include "AliMpManuIterator.h"
de01cdf0 65#include "AliMpSegmentation.h"
66#include "AliMpStationType.h"
67#include "AliMpVSegmentation.h"
92e36663 68
69#include "AliCodeTimer.h"
70#include "AliCDBEntry.h"
71#include "AliCDBManager.h"
a99c3449 72#include "AliGRPManager.h"
92e36663 73#include "AliDCSValue.h"
74#include "AliLog.h"
75
de01cdf0 76#include <Riostream.h>
77#include <TArrayI.h>
78#include <TClass.h>
79#include <TH1F.h>
80#include <TList.h>
81#include <TMap.h>
82#include <TObjString.h>
83#include <TROOT.h>
84#include <TRandom.h>
85#include <TStopwatch.h>
86#include <TSystem.h>
cf27231a 87#include <TMath.h>
a99c3449 88#include <TGeoGlobalMagField.h>
de01cdf0 89
c05673c9 90
de01cdf0 91namespace
92{
409de10f 93 //_____________________________________________________________________________
94AliMUONVStore* Create2DMap()
95{
96 return new AliMUON2DMap(true);
97}
98
99 //_____________________________________________________________________________
046e5fd4 100void getBoundaries(const AliMUONVStore& store, Int_t dim,
101 Float_t* xmin, Float_t* xmax)
de01cdf0 102{
046e5fd4 103 /// Assuming the store contains AliMUONVCalibParam objects, compute the
104 /// limits of the value contained in the VCalibParam, for each of its dimensions
105 /// xmin and xmax must be of dimension dim
106
107 for ( Int_t i = 0; i < dim; ++i )
108 {
109 xmin[i]=1E30;
110 xmax[i]=-1E30;
111 }
de01cdf0 112
a0eca509 113 TIter next(store.CreateIterator());
114 AliMUONVCalibParam* value;
de01cdf0 115
a0eca509 116 while ( ( value = dynamic_cast<AliMUONVCalibParam*>(next() ) ) )
de01cdf0 117 {
a0eca509 118 Int_t detElemId = value->ID0();
119 Int_t manuId = value->ID1();
de01cdf0 120
121 const AliMpVSegmentation* seg =
122 AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId,manuId);
123
124 for ( Int_t manuChannel = 0; manuChannel < value->Size(); ++manuChannel )
125 {
168e9c4d 126 AliMpPad pad = seg->PadByLocation(manuId,manuChannel,kFALSE);
de01cdf0 127 if (!pad.IsValid()) continue;
128
046e5fd4 129 for ( Int_t i = 0; i < dim; ++i )
de01cdf0 130 {
046e5fd4 131 Float_t x0 = value->ValueAsFloat(manuChannel,i);
132
133 xmin[i] = TMath::Min(xmin[i],x0);
134 xmax[i] = TMath::Max(xmax[i],x0);
de01cdf0 135 }
136 }
046e5fd4 137 }
138
139 for ( Int_t i = 0; i < dim; ++i )
140 {
141 if ( TMath::Abs(xmin[i]-xmax[i]) < 1E-3 )
142 {
143 xmin[i] -= 1;
144 xmax[i] += 1;
145 }
146 }
de01cdf0 147}
148
cf27231a 149//_____________________________________________________________________________
150Double_t GetRandom(Double_t mean, Double_t sigma, Bool_t mustBePositive)
151{
152 Double_t x(-1);
153 if ( mustBePositive )
154 {
155 while ( x < 0 )
156 {
157 x = gRandom->Gaus(mean,sigma);
158 }
159 }
160 else
161 {
162 x = gRandom->Gaus(mean,sigma);
163 }
164 return x;
165}
166
de01cdf0 167}
168
169//_____________________________________________________________________________
a99c3449 170Bool_t AliMUONCDB::CheckOCDB(Bool_t pathOnly)
de01cdf0 171{
a99c3449 172 /// Check that OCDB path and run number are properly set
173
174 AliCDBManager* man = AliCDBManager::Instance();
175
176 // first OCDB path
177 if (!man->IsDefaultStorageSet()) {
178 AliErrorGeneral("AliMUONCDB", "OCDB path must be properly set");
179 return kFALSE;
180 }
181
182 // then run number if required
183 if (pathOnly) return kTRUE;
184 if (man->GetRun() < 0) {
185 AliErrorGeneral("AliMUONCDB", "Run number must be properly set");
186 return kFALSE;
187 }
188
189 return kTRUE;
190
191}
192
193//_____________________________________________________________________________
194Bool_t AliMUONCDB::CheckMapping(Bool_t segmentationOnly)
195{
196 /// Check that the mapping has been loaded
197
198 // first the segmentation
199 if (!AliMpSegmentation::Instance(false)) {
200 AliErrorGeneral("AliMUONCDB", "Mapping segmentation must be loaded first");
201 return kFALSE;
202 }
203
204 // then the others if required
205 if (segmentationOnly) return kTRUE;
206 if (!AliMpDDLStore::Instance(false) || !AliMpDEStore::Instance(false) || !AliMpManuStore::Instance(false)) {
207 AliErrorGeneral("AliMUONCDB", "Full mapping must be loaded first");
208 return kFALSE;
209 }
210
211 return kTRUE;
212
213}
214
215//_____________________________________________________________________________
216Bool_t AliMUONCDB::LoadField()
217{
218 /// Load magnetic field (existing field will be deleted).
219 /// OCDB path and run number are supposed to be set.
220
221 AliInfoGeneral("AliMUONCDB","Loading field map from GRP...");
222
223 if (!AliMUONCDB::CheckOCDB()) return kFALSE;
224
225 AliGRPManager grpMan;
226
227 // make sure the old field is deleted even if it is locked
228 if(TGeoGlobalMagField::Instance()->IsLocked()) delete TGeoGlobalMagField::Instance();
229
230 if (!grpMan.ReadGRPEntry() || !grpMan.SetMagField()) {
231 AliErrorGeneral("AliMUONCDB", "failed to load magnetic field from OCDB");
232 return kFALSE;
233 }
234
235 return kTRUE;
236
237}
ab167304 238
a99c3449 239//_____________________________________________________________________________
240Bool_t AliMUONCDB::LoadMapping(Bool_t segmentationOnly)
241{
242 /// Load mapping (existing mapping will be unloaded).
243 /// OCDB path and run number are supposed to be set.
244
245 AliInfoGeneral("AliMUONCDB", "Loading mapping from OCDB...");
246
247 if (!AliMUONCDB::CheckOCDB()) return kFALSE;
248
249 // in case it has already been set
250 AliMpCDB::UnloadAll();
251
252 if (segmentationOnly) {
253
254 if (!AliMpCDB::LoadMpSegmentation(kTRUE)){
255 AliErrorGeneral("AliMUONCDB", "failed to load segmentation from OCDB");
256 return kFALSE;
257 }
258
259 } else {
260
261 if (!AliMpCDB::LoadAll(kTRUE)) {
262 AliErrorGeneral("AliMUONCDB", "failed to load mapping from OCDB");
263 return kFALSE;
ab167304 264 }
a99c3449 265
266 }
267
268 return kTRUE;
269
de01cdf0 270}
271
272//_____________________________________________________________________________
a99c3449 273AliMUONRecoParam* AliMUONCDB::LoadRecoParam()
de01cdf0 274{
a99c3449 275 /// Load and return reconstruction parameters.
276 /// OCDB path is supposed to be set.
277
278 AliInfoGeneral("AliMUONCDB", "Loading RecoParam from OCDB...");
279
280 if (!AliMUONCDB::CheckOCDB()) return kFALSE;
281
282 AliMUONRecoParam* recoParam = 0x0;
283 AliCDBEntry* entry = AliCDBManager::Instance()->Get("MUON/Calib/RecoParam");
284
285 if(entry) {
286
287 // load recoParam according OCDB content (single or array)
288 if (!(recoParam = dynamic_cast<AliMUONRecoParam*>(entry->GetObject()))) {
289
290 TObjArray* recoParamArray = static_cast<TObjArray*>(entry->GetObject());
291
292 for(Int_t i = 0; i < recoParamArray->GetEntriesFast(); i++) {
293 recoParam = static_cast<AliMUONRecoParam*>(recoParamArray->UncheckedAt(i));
294 if (recoParam->IsDefault()) break;
295 recoParam = 0x0;
296 }
297
298 }
299
300 }
301
302 if (!recoParam) AliErrorGeneral("AliMUONCDB", "failed to load RecoParam from OCDB");
303
304 return recoParam;
305
a0eca509 306}
307
308//_____________________________________________________________________________
309AliMUONVStore*
310AliMUONCDB::Diff(AliMUONVStore& store1, AliMUONVStore& store2,
de01cdf0 311 const char* opt)
312{
313 /// creates a store which contains store1-store2
314 /// if opt="abs" the difference is absolute one,
315 /// if opt="rel" then what is stored is (store1-store2)/store1
046e5fd4 316 /// if opt="percent" then what is stored is rel*100
317 ///
de01cdf0 318 /// WARNING Works only for stores which holds AliMUONVCalibParam objects
319
320 TString sopt(opt);
321 sopt.ToUpper();
322
046e5fd4 323 if ( !sopt.Contains("ABS") && !sopt.Contains("REL") && !sopt.Contains("PERCENT") )
de01cdf0 324 {
a99c3449 325 AliErrorGeneral("AliMUONCDB", Form("opt %s not supported. Only ABS, REL, PERCENT are",opt));
de01cdf0 326 return 0x0;
327 }
328
a0eca509 329 AliMUONVStore* d = static_cast<AliMUONVStore*>(store1.Clone());
de01cdf0 330
a0eca509 331 TIter next(d->CreateIterator());
de01cdf0 332
a0eca509 333 AliMUONVCalibParam* param;
de01cdf0 334
a0eca509 335 while ( ( param = dynamic_cast<AliMUONVCalibParam*>(next() ) ) )
de01cdf0 336 {
a0eca509 337 Int_t detElemId = param->ID0();
338 Int_t manuId = param->ID1();
de01cdf0 339
a0eca509 340 AliMUONVCalibParam* param2 = dynamic_cast<AliMUONVCalibParam*>(store2.FindObject(detElemId,manuId));
de01cdf0 341 //FIXME: this might happen. Handle it.
342 if (!param2)
343 {
344 cerr << "param2 is null : FIXME : this might happen !" << endl;
345 delete d;
346 return 0;
347 }
348
349 for ( Int_t i = 0; i < param->Size(); ++i )
350 {
351 for ( Int_t j = 0; j < param->Dimension(); ++j )
352 {
353 Float_t value(0);
354 if ( sopt.Contains("ABS") )
355 {
356 value = param->ValueAsFloat(i,j) - param2->ValueAsFloat(i,j);
357 }
046e5fd4 358 else if ( sopt.Contains("REL") || sopt.Contains("PERCENT") )
de01cdf0 359 {
360 if ( param->ValueAsFloat(i,j) )
361 {
362 value = (param->ValueAsFloat(i,j) - param2->ValueAsFloat(i,j))/param->ValueAsFloat(i,j);
363 }
364 else
365 {
366 continue;
367 }
046e5fd4 368 if ( sopt.Contains("PERCENT") ) value *= 100.0;
de01cdf0 369 }
370 param->SetValueAsFloat(i,j,value);
371 }
372 }
de01cdf0 373 }
374 return d;
375}
376
377//_____________________________________________________________________________
378void
a0eca509 379AliMUONCDB::Plot(const AliMUONVStore& store, const char* name, Int_t nbins)
de01cdf0 380{
046e5fd4 381 /// Make histograms of each dimension of the AliMUONVCalibParam
de01cdf0 382 /// contained inside store.
383 /// It produces histograms named name_0, name_1, etc...
384
a99c3449 385 if (!AliMUONCDB::CheckMapping(kTRUE)) return;
386
046e5fd4 387 TIter next(store.CreateIterator());
388 AliMUONVCalibParam* param;
de01cdf0 389 Int_t n(0);
046e5fd4 390 const Int_t kNStations = AliMpConstants::NofTrackingChambers()/2;
391 Int_t* nPerStation = new Int_t[kNStations];
392 TH1** h(0x0);
de01cdf0 393
046e5fd4 394 for ( Int_t i = 0; i < kNStations; ++i ) nPerStation[i]=0;
de01cdf0 395
046e5fd4 396 while ( ( param = static_cast<AliMUONVCalibParam*>(next()) ) )
de01cdf0 397 {
046e5fd4 398 if (!h)
399 {
400 Int_t dim = param->Dimension();
401 h = new TH1*[dim];
402 Float_t* xmin = new Float_t[dim];
403 Float_t* xmax = new Float_t[dim];
404 getBoundaries(store,dim,xmin,xmax);
405
406 for ( Int_t i = 0; i < dim; ++i )
407 {
408 h[i] = new TH1F(Form("%s_%d",name,i),Form("%s_%d",name,i),
409 nbins,xmin[i],xmax[i]);
a99c3449 410 AliInfoGeneral("AliMUONCDB", Form("Created histogram %s",h[i]->GetName()));
046e5fd4 411 }
412 }
413
414 Int_t detElemId = param->ID0();
415 Int_t manuId = param->ID1();
416 Int_t station = AliMpDEManager::GetChamberId(detElemId)/2;
de01cdf0 417
418 const AliMpVSegmentation* seg =
419 AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId,manuId);
420
046e5fd4 421 for ( Int_t manuChannel = 0; manuChannel < param->Size(); ++manuChannel )
de01cdf0 422 {
168e9c4d 423 AliMpPad pad = seg->PadByLocation(manuId,manuChannel,kFALSE);
046e5fd4 424 if (!pad.IsValid()) continue;
de01cdf0 425
046e5fd4 426 ++n;
427 ++nPerStation[station];
428
429 for ( Int_t dim = 0; dim < param->Dimension(); ++dim )
430 {
431 h[dim]->Fill(param->ValueAsFloat(manuChannel,dim));
de01cdf0 432 }
433 }
046e5fd4 434 }
de01cdf0 435
046e5fd4 436 for ( Int_t i = 0; i < kNStations; ++i )
de01cdf0 437 {
a99c3449 438 AliInfoGeneral("AliMUONCDB", Form("Station %d %d ",(i+1),nPerStation[i]));
de01cdf0 439 }
046e5fd4 440
a99c3449 441 AliInfoGeneral("AliMUONCDB", Form("Number of channels = %d",n));
046e5fd4 442
443 delete[] nPerStation;
de01cdf0 444}
445
446//_____________________________________________________________________________
447Int_t
448AliMUONCDB::MakeHVStore(TMap& aliasMap, Bool_t defaultValues)
449{
450 /// Create a HV store
451
a99c3449 452 if (!AliMUONCDB::CheckMapping()) return 0;
453
49e110ec 454 AliMpDCSNamer hvNamer("TRACKER");
de01cdf0 455
456 TObjArray* aliases = hvNamer.GenerateAliases();
457
458 Int_t nSwitch(0);
459 Int_t nChannels(0);
460
461 for ( Int_t i = 0; i < aliases->GetEntries(); ++i )
462 {
463 TObjString* alias = static_cast<TObjString*>(aliases->At(i));
464 TString& aliasName = alias->String();
465 if ( aliasName.Contains("sw") )
466 {
467 // HV Switch (St345 only)
468 TObjArray* valueSet = new TObjArray;
469 valueSet->SetOwner(kTRUE);
470
471 Bool_t value = kTRUE;
472
473 if (!defaultValues)
474 {
a0eca509 475 Float_t r = gRandom->Uniform();
de01cdf0 476 if ( r < 0.007 ) value = kFALSE;
477 }
478
479 for ( UInt_t timeStamp = 0; timeStamp < 60*3; timeStamp += 60 )
480 {
481 AliDCSValue* dcsValue = new AliDCSValue(value,timeStamp);
482 valueSet->Add(dcsValue);
483 }
484 aliasMap.Add(new TObjString(*alias),valueSet);
485 ++nSwitch;
486 }
487 else
488 {
489 TObjArray* valueSet = new TObjArray;
490 valueSet->SetOwner(kTRUE);
491 for ( UInt_t timeStamp = 0; timeStamp < 60*15; timeStamp += 120 )
492 {
493 Float_t value = 1500;
cf27231a 494 if (!defaultValues) value = GetRandom(1750,62.5,true);
de01cdf0 495 AliDCSValue* dcsValue = new AliDCSValue(value,timeStamp);
496 valueSet->Add(dcsValue);
497 }
498 aliasMap.Add(new TObjString(*alias),valueSet);
499 ++nChannels;
500 }
501 }
502
503 delete aliases;
504
a99c3449 505 AliInfoGeneral("AliMUONCDB", Form("%d HV channels and %d switches",nChannels,nSwitch));
de01cdf0 506
507 return nChannels+nSwitch;
508}
509
49e110ec 510//_____________________________________________________________________________
511Int_t
512AliMUONCDB::MakeTriggerDCSStore(TMap& aliasMap, Bool_t defaultValues)
513{
514 /// Create a Trigger HV and Currents store
515
a99c3449 516 if (!AliMUONCDB::CheckMapping()) return 0;
517
49e110ec 518 AliMpDCSNamer triggerDCSNamer("TRIGGER");
519
520 TObjArray* aliases = triggerDCSNamer.GenerateAliases();
521
522 Int_t nChannels[2] = {0, 0};
523
524 for ( Int_t i = 0; i < aliases->GetEntries(); ++i )
525 {
526 TObjString* alias = static_cast<TObjString*>(aliases->At(i));
527 TString& aliasName = alias->String();
528
529 TObjArray* valueSet = new TObjArray;
530 valueSet->SetOwner(kTRUE);
531 Int_t measureType = triggerDCSNamer.DCSvariableFromDCSAlias(aliasName.Data());
532 for ( UInt_t timeStamp = 0; timeStamp < 60*15; timeStamp += 120 )
533 {
534 Float_t value =
9b1e069f 535 (measureType == AliMpDCSNamer::kDCSI) ? 2. : 8000.;
49e110ec 536 if (!defaultValues) {
537 switch (measureType){
538 case AliMpDCSNamer::kDCSI:
9b1e069f 539 value = GetRandom(2.,0.4,true);
49e110ec 540 break;
541 case AliMpDCSNamer::kDCSHV:
9b1e069f 542 value = GetRandom(8000.,16.,true);
49e110ec 543 break;
544 }
545 }
546 AliDCSValue* dcsValue = new AliDCSValue(value,timeStamp);
547 valueSet->Add(dcsValue);
548 }
549 aliasMap.Add(new TObjString(*alias),valueSet);
550 ++nChannels[measureType];
551 }
552
553 delete aliases;
554
a99c3449 555 AliInfoGeneral("AliMUONCDB", Form("Trigger channels I -> %i HV -> %i",nChannels[0], nChannels[1]));
49e110ec 556
557 return nChannels[0] + nChannels[1];
558}
559
de01cdf0 560//_____________________________________________________________________________
561Int_t
a0eca509 562AliMUONCDB::MakePedestalStore(AliMUONVStore& pedestalStore, Bool_t defaultValues)
de01cdf0 563{
564 /// Create a pedestal store. if defaultValues=true, ped.mean=ped.sigma=1,
565 /// otherwise mean and sigma are from a gaussian (with parameters
566 /// defined below by the kPedestal* constants)
409de10f 567
a99c3449 568 AliCodeTimerAutoGeneral("",0);
569
570 if (!AliMUONCDB::CheckMapping()) return 0;
de01cdf0 571
572 Int_t nchannels(0);
573 Int_t nmanus(0);
574
a0eca509 575 const Int_t kChannels(AliMpConstants::ManuNofChannels());
e7ee8d13 576
577 // bending
578 const Float_t kPedestalMeanMeanB(200.);
579 const Float_t kPedestalMeanSigmaB(10.);
580 const Float_t kPedestalSigmaMeanB(1.);
581 const Float_t kPedestalSigmaSigmaB(0.2);
582
583 // non bending
584 const Float_t kPedestalMeanMeanNB(200.);
585 const Float_t kPedestalMeanSigmaNB(10.);
586 const Float_t kPedestalSigmaMeanNB(1.);
587 const Float_t kPedestalSigmaSigmaNB(0.2);
588
589 const Float_t kFractionOfDeadManu(0.); // within [0.,1.]
409de10f 590
591 Int_t detElemId;
592 Int_t manuId;
593
594 AliMpManuIterator it;
de01cdf0 595
409de10f 596 while ( it.Next(detElemId,manuId) )
de01cdf0 597 {
e7ee8d13 598 // skip a given fraction of manus
599 if (kFractionOfDeadManu > 0. && gRandom->Uniform() < kFractionOfDeadManu) continue;
600
de01cdf0 601 ++nmanus;
a0eca509 602
046e5fd4 603 AliMUONVCalibParam* ped =
604 new AliMUONCalibParamNF(2,kChannels,detElemId,manuId,AliMUONVCalibParam::InvalidFloatValue());
409de10f 605
606 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
de01cdf0 607
608 for ( Int_t manuChannel = 0; manuChannel < kChannels; ++manuChannel )
609 {
409de10f 610 if ( ! de->IsConnectedChannel(manuId,manuChannel) ) continue;
de01cdf0 611
612 ++nchannels;
613
614 Float_t meanPedestal;
615 Float_t sigmaPedestal;
616
617 if ( defaultValues )
618 {
619 meanPedestal = 0.0;
620 sigmaPedestal = 1.0;
621 }
622 else
623 {
cf27231a 624 Bool_t positive(kTRUE);
046e5fd4 625 meanPedestal = 0.0;
e7ee8d13 626
627 if ( manuId & AliMpConstants::ManuMask(AliMp::kNonBendingPlane) ) { // manu in non bending plane
628
629 while ( meanPedestal == 0.0 ) // avoid strict zero
630 {
631 meanPedestal = GetRandom(kPedestalMeanMeanNB,kPedestalMeanSigmaNB,positive);
632 }
633 sigmaPedestal = GetRandom(kPedestalSigmaMeanNB,kPedestalSigmaSigmaNB,positive);
634
635 } else { // manu in bending plane
636
637 while ( meanPedestal == 0.0 ) // avoid strict zero
638 {
639 meanPedestal = GetRandom(kPedestalMeanMeanB,kPedestalMeanSigmaB,positive);
640 }
641 sigmaPedestal = GetRandom(kPedestalSigmaMeanB,kPedestalSigmaSigmaB,positive);
642
643 }
644
de01cdf0 645 }
e7ee8d13 646
de01cdf0 647 ped->SetValueAsFloat(manuChannel,0,meanPedestal);
648 ped->SetValueAsFloat(manuChannel,1,sigmaPedestal);
649
650 }
a0eca509 651 Bool_t ok = pedestalStore.Add(ped);
de01cdf0 652 if (!ok)
653 {
a99c3449 654 AliErrorGeneral("AliMUONCDB", Form("Could not set DetElemId=%d manuId=%d",detElemId,manuId));
de01cdf0 655 }
656 }
657
a99c3449 658 AliInfoGeneral("AliMUONCDB", Form("%d Manus and %d channels.",nmanus,nchannels));
de01cdf0 659 return nchannels;
de01cdf0 660}
661
0045b488 662//_____________________________________________________________________________
663AliMUONRejectList*
664AliMUONCDB::MakeRejectListStore(Bool_t defaultValues)
665{
666 /// Create a reject list
667
a99c3449 668 AliCodeTimerAutoGeneral("",0);
0045b488 669
670 AliMUONRejectList* rl = new AliMUONRejectList;
671
672 if (!defaultValues)
673 {
674 rl->SetDetectionElementProbability(510);
675 rl->SetDetectionElementProbability(508);
676 return rl;
677 }
678
679 return rl;
680}
681
2b8a1212 682//_____________________________________________________________________________
683Int_t
7eafe398 684AliMUONCDB::MakeOccupancyMapStore(AliMUONVStore& occupancyMapStore, Bool_t defaultValues)
2b8a1212 685{
7eafe398 686 /// Create an occupancy map.
2b8a1212 687
a99c3449 688 AliCodeTimerAutoGeneral("",0);
689
690 if (!AliMUONCDB::CheckMapping()) return 0;
2b8a1212 691
2b8a1212 692 Int_t nmanus(0);
693
2b8a1212 694 Int_t detElemId;
695 Int_t manuId;
696
697 AliMpManuIterator it;
698
7eafe398 699 Int_t nevents(1000);
700
2b8a1212 701 while ( it.Next(detElemId,manuId) )
702 {
2b8a1212 703 ++nmanus;
704
7eafe398 705 AliMUONVCalibParam* occupancy = new AliMUONCalibParamND(5,1,detElemId,manuId,0);
2b8a1212 706
7eafe398 707 Double_t occ = 0.0;
708
2b8a1212 709 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
710
7eafe398 711 Int_t numberOfChannelsInManu = de->NofChannelsInManu(manuId);
712
a99c3449 713 if (!defaultValues) occ = gRandom->Rndm(1);
7eafe398 714
715 Double_t sumn = occ*nevents;
716
717 occupancy->SetValueAsFloat(0,0,sumn);
718 occupancy->SetValueAsFloat(0,1,sumn);
719 occupancy->SetValueAsFloat(0,2,sumn);
720 occupancy->SetValueAsInt(0,3,numberOfChannelsInManu);
721 occupancy->SetValueAsInt(0,4,nevents);
722
723 Bool_t ok = occupancyMapStore.Add(occupancy);
2b8a1212 724 if (!ok)
725 {
a99c3449 726 AliErrorGeneral("AliMUONCDB", Form("Could not set DetElemId=%d manuId=%d",detElemId,manuId));
2b8a1212 727 }
2b8a1212 728 }
729
7eafe398 730 return nmanus;
2b8a1212 731}
732
25e1df3e 733//_____________________________________________________________________________
734Int_t
735AliMUONCDB::MakeCapacitanceStore(AliMUONVStore& capaStore, const char* file)
736{
6687de6d 737 /// Read the capacitance values from file and append them to the capaStore
738
a99c3449 739 if (!AliMUONCDB::CheckMapping()) return 0;
740
49419555 741 return AliMUONTrackerIO::ReadCapacitances(file,capaStore);
25e1df3e 742}
743
de01cdf0 744//_____________________________________________________________________________
745Int_t
a0eca509 746AliMUONCDB::MakeCapacitanceStore(AliMUONVStore& capaStore, Bool_t defaultValues)
de01cdf0 747{
748 /// Create a capacitance store. if defaultValues=true, all capa are 1.0,
749 /// otherwise they are from a gaussian with parameters defined in the
750 /// kCapa* constants below.
409de10f 751
a99c3449 752 AliCodeTimerAutoGeneral("",0);
753
754 if (!AliMUONCDB::CheckMapping()) return 0;
de01cdf0 755
756 Int_t nchannels(0);
757 Int_t nmanus(0);
758 Int_t nmanusOK(0); // manus for which we got the serial number
a0eca509 759
25e1df3e 760 const Float_t kCapaMean(0.3);
761 const Float_t kCapaSigma(0.1);
762 const Float_t kInjectionGainMean(3);
763 const Float_t kInjectionGainSigma(1);
409de10f 764
765 Int_t detElemId;
766 Int_t manuId;
767
768 AliMpManuIterator it;
de01cdf0 769
409de10f 770 while ( it.Next(detElemId,manuId) )
de01cdf0 771 {
772 ++nmanus;
773
de01cdf0 774 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
ab167304 775 Int_t serialNumber = AliMpManuStore::Instance()->GetManuSerial(detElemId, manuId);
de01cdf0 776
a0eca509 777 if ( serialNumber <= 0 ) continue;
778
779 ++nmanusOK;
de01cdf0 780
a0eca509 781 AliMUONVCalibParam* capa = static_cast<AliMUONVCalibParam*>(capaStore.FindObject(serialNumber));
de01cdf0 782
783 if (!capa)
784 {
25e1df3e 785 capa = new AliMUONCalibParamNF(2,AliMpConstants::ManuNofChannels(),serialNumber,0,1.0);
a0eca509 786 Bool_t ok = capaStore.Add(capa);
de01cdf0 787 if (!ok)
788 {
a99c3449 789 AliErrorGeneral("AliMUONCDB", Form("Could not set serialNumber=%d manuId=%d",serialNumber,manuId));
de01cdf0 790 }
791 }
792
793 for ( Int_t manuChannel = 0; manuChannel < capa->Size(); ++manuChannel )
794 {
409de10f 795 if ( ! de->IsConnectedChannel(manuId,manuChannel) ) continue;
de01cdf0 796
797 ++nchannels;
798
799 Float_t capaValue;
25e1df3e 800 Float_t injectionGain;
de01cdf0 801
802 if ( defaultValues )
803 {
804 capaValue = 1.0;
25e1df3e 805 injectionGain = 1.0;
de01cdf0 806 }
807 else
808 {
cf27231a 809 capaValue = GetRandom(kCapaMean,kCapaSigma,kTRUE);
25e1df3e 810 injectionGain = GetRandom(kInjectionGainMean,kInjectionGainSigma,kTRUE);
de01cdf0 811 }
812 capa->SetValueAsFloat(manuChannel,0,capaValue);
25e1df3e 813 capa->SetValueAsFloat(manuChannel,1,injectionGain);
de01cdf0 814 }
815 }
816
817 Float_t percent = 0;
818 if ( nmanus ) percent = 100*nmanusOK/nmanus;
a99c3449 819 AliInfoGeneral("AliMUONCDB", Form("%5d manus with serial number (out of %5d manus = %3.0f%%)",
de01cdf0 820 nmanusOK,nmanus,percent));
a99c3449 821 AliInfoGeneral("AliMUONCDB", Form("%5d channels",nchannels));
de01cdf0 822 if ( percent < 100 )
823 {
a99c3449 824 AliWarningGeneral("AliMUONCDB", "Did not get all serial numbers. capaStore is incomplete !!!!");
de01cdf0 825 }
826 return nchannels;
827
828}
829
830//_____________________________________________________________________________
831Int_t
a0eca509 832AliMUONCDB::MakeGainStore(AliMUONVStore& gainStore, Bool_t defaultValues)
de01cdf0 833{
cf27231a 834 /// Create a gain store. if defaultValues=true, all gains set so that
835 /// charge = (adc-ped)
836 ///
837 /// otherwise parameters are taken from gaussians with parameters
838 /// defined in the k* constants below.
de01cdf0 839
a99c3449 840 AliCodeTimerAutoGeneral("",0);
841
842 if (!AliMUONCDB::CheckMapping()) return 0;
de01cdf0 843
844 Int_t nchannels(0);
845 Int_t nmanus(0);
a0eca509 846
cf27231a 847 const Int_t kSaturation(3000);
848 const Double_t kA0Mean(1.2);
409de10f 849 const Double_t kA0Sigma(0.1);
850 const Double_t kA1Mean(1E-5);
851 const Double_t kA1Sigma(1E-6);
cf27231a 852 const Double_t kQualMean(0xFF);
853 const Double_t kQualSigma(0x10);
854 const Int_t kThresMean(1600);
409de10f 855 const Int_t kThresSigma(100);
856
857 Int_t detElemId;
858 Int_t manuId;
de01cdf0 859
409de10f 860 AliMpManuIterator it;
861
862 while ( it.Next(detElemId,manuId) )
de01cdf0 863 {
864 ++nmanus;
de01cdf0 865
a0eca509 866 AliMUONVCalibParam* gain =
cf27231a 867 new AliMUONCalibParamNF(5,AliMpConstants::ManuNofChannels(),
a0eca509 868 detElemId,
869 manuId,
870 AliMUONVCalibParam::InvalidFloatValue());
871
409de10f 872 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
de01cdf0 873
874 for ( Int_t manuChannel = 0; manuChannel < gain->Size(); ++manuChannel )
875 {
409de10f 876 if ( ! de->IsConnectedChannel(manuId,manuChannel) ) continue;
de01cdf0 877
878 ++nchannels;
879
de01cdf0 880 if ( defaultValues )
881 {
cf27231a 882 gain->SetValueAsFloat(manuChannel,0,1.0);
883 gain->SetValueAsFloat(manuChannel,1,0.0);
884 gain->SetValueAsInt(manuChannel,2,4095);
885 gain->SetValueAsInt(manuChannel,3,1);
886 gain->SetValueAsInt(manuChannel,4,kSaturation);
de01cdf0 887 }
888 else
889 {
cf27231a 890 Bool_t positive(kTRUE);
891 gain->SetValueAsFloat(manuChannel,0,GetRandom(kA0Mean,kA0Sigma,positive));
892 gain->SetValueAsFloat(manuChannel,1,GetRandom(kA1Mean,kA1Sigma,!positive));
893 gain->SetValueAsInt(manuChannel,2,(Int_t)TMath::Nint(GetRandom(kThresMean,kThresSigma,positive)));
894 gain->SetValueAsInt(manuChannel,3,(Int_t)TMath::Nint(GetRandom(kQualMean,kQualSigma,positive)));
895 gain->SetValueAsInt(manuChannel,4,kSaturation);
de01cdf0 896 }
de01cdf0 897
898 }
a0eca509 899 Bool_t ok = gainStore.Add(gain);
de01cdf0 900 if (!ok)
901 {
a99c3449 902 AliErrorGeneral("AliMUONCDB", Form("Could not set DetElemId=%d manuId=%d",detElemId,manuId));
de01cdf0 903 }
904 }
905
a99c3449 906 AliInfoGeneral("AliMUONCDB", Form("%d Manus and %d channels.",nmanus,nchannels));
de01cdf0 907 return nchannels;
908}
909
910//_____________________________________________________________________________
911Int_t
a99c3449 912AliMUONCDB::MakeLocalTriggerMaskStore(AliMUONVStore& localBoardMasks)
de01cdf0 913{
914 /// Generate local trigger masks store. All masks are set to FFFF
915
a99c3449 916 AliCodeTimerAutoGeneral("",0);
409de10f 917
de01cdf0 918 Int_t ngenerated(0);
630711ed 919 // Generate fake mask values for all localboards and put that into
de01cdf0 920 // one single container (localBoardMasks)
0145e89a 921 for ( Int_t i = 1; i <= AliMpConstants::TotalNofLocalBoards(); ++i )
de01cdf0 922 {
a0eca509 923 AliMUONVCalibParam* localBoard = new AliMUONCalibParamNI(1,8,i,0,0);
de01cdf0 924 for ( Int_t x = 0; x < 2; ++x )
925 {
926 for ( Int_t y = 0; y < 4; ++y )
927 {
928 Int_t index = x*4+y;
929 localBoard->SetValueAsInt(index,0,0xFFFF);
930 ++ngenerated;
931 }
932 }
a0eca509 933 localBoardMasks.Add(localBoard);
de01cdf0 934 }
935 return ngenerated;
936}
937
938//_____________________________________________________________________________
939Int_t
a99c3449 940AliMUONCDB::MakeRegionalTriggerConfigStore(AliMUONRegionalTriggerConfig& rtm)
de01cdf0 941{
92c23b09 942 /// Make a regional trigger config store. Mask is set to FFFF for each local board (Ch.F.)
de01cdf0 943
a99c3449 944 AliCodeTimerAutoGeneral("",0);
409de10f 945
5cc125b2 946 if ( ! rtm.ReadData(AliMpFiles::LocalTriggerBoardMapping()) ) {
a99c3449 947 AliErrorGeneral("AliMUONCDB", "Error when reading from mapping file");
5cc125b2 948 return 0;
949 }
950
951 return rtm.GetNofTriggerCrates();
de01cdf0 952}
953
92c23b09 954
de01cdf0 955//_____________________________________________________________________________
956Int_t
a99c3449 957AliMUONCDB::MakeGlobalTriggerConfigStore(AliMUONGlobalCrateConfig& gtm)
de01cdf0 958{
92c23b09 959 /// Make a global trigger config store. All masks (disable) set to 0x00 for each Darc board (Ch.F.)
de01cdf0 960
a99c3449 961 AliCodeTimerAutoGeneral("",0);
913f1b43 962
963 return gtm.ReadData(AliMpFiles::GlobalTriggerBoardMapping());
de01cdf0 964}
965
92c23b09 966
de01cdf0 967//_____________________________________________________________________________
968AliMUONTriggerLut*
a99c3449 969AliMUONCDB::MakeTriggerLUT(const char* file)
de01cdf0 970{
971 /// Make a triggerlut object, from a file.
972
a99c3449 973 AliCodeTimerAutoGeneral("",0);
409de10f 974
de01cdf0 975 AliMUONTriggerLut* lut = new AliMUONTriggerLut;
976 lut->ReadFromFile(file);
977 return lut;
978}
979
980//_____________________________________________________________________________
981AliMUONTriggerEfficiencyCells*
a99c3449 982AliMUONCDB::MakeTriggerEfficiency(const char* file)
de01cdf0 983{
984 /// Make a trigger efficiency object from a file.
985
a99c3449 986 AliCodeTimerAutoGeneral("",0);
409de10f 987
de01cdf0 988 return new AliMUONTriggerEfficiencyCells(file);
989}
990
25e1df3e 991//_____________________________________________________________________________
992void
993AliMUONCDB::WriteToCDB(const char* calibpath, TObject* object,
994 Int_t startRun, Int_t endRun,
995 const char* filename)
996{
997 /// Write a given object to OCDB
998
913f1b43 999 TString comment(gSystem->ExpandPathName(filename));
1000
1001 WriteToCDB(object, calibpath, startRun, endRun, comment.Data());
25e1df3e 1002}
1003
de01cdf0 1004//_____________________________________________________________________________
1005void
1006AliMUONCDB::WriteToCDB(const char* calibpath, TObject* object,
1007 Int_t startRun, Int_t endRun, Bool_t defaultValues)
1008{
1009 /// Write a given object to OCDB
1010
913f1b43 1011 TString comment;
1012 if ( defaultValues ) comment += "Test with default values";
1013 else comment += "Test with random values";
1014
1015 WriteToCDB(object, calibpath, startRun, endRun, comment.Data());
1016}
1017
1018//_____________________________________________________________________________
1019void
1020AliMUONCDB::WriteToCDB(TObject* object, const char* calibpath, Int_t startRun, Int_t endRun,
1021 const char* comment, const char* responsible)
1022{
1023 /// Write a given object to OCDB
1024
a99c3449 1025 if (!AliMUONCDB::CheckOCDB(kTRUE)) return;
1026
de01cdf0 1027 AliCDBId id(calibpath,startRun,endRun);
1028 AliCDBMetaData md;
1029 md.SetAliRootVersion(gROOT->GetVersion());
913f1b43 1030 md.SetComment(comment);
1031 md.SetResponsible(responsible);
a99c3449 1032 AliCDBManager::Instance()->Put(object,id,&md);
de01cdf0 1033}
1034
1035//_____________________________________________________________________________
1036Int_t
a0eca509 1037AliMUONCDB::MakeNeighbourStore(AliMUONVStore& neighbourStore)
de01cdf0 1038{
1039 /// Fill the neighbours store with, for each channel, a TObjArray of its
1040 /// neighbouring pads (including itself)
1041
a99c3449 1042 AliCodeTimerAutoGeneral("",0);
1043
1044 if (!AliMUONCDB::CheckMapping()) return 0;
de01cdf0 1045
a99c3449 1046 AliInfoGeneral("AliMUONCDB", "Generating NeighbourStore. This will take a while. Please be patient.");
de01cdf0 1047
1048 Int_t nchannels(0);
1049
1050 TObjArray tmp;
409de10f 1051
1052 Int_t detElemId;
1053 Int_t manuId;
de01cdf0 1054
409de10f 1055 AliMpManuIterator it;
1056
1057 while ( it.Next(detElemId,manuId) )
de01cdf0 1058 {
de01cdf0 1059 const AliMpVSegmentation* seg =
1060 AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId,manuId);
1061
a0eca509 1062 AliMUONVCalibParam* calibParam = static_cast<AliMUONVCalibParam*>(neighbourStore.FindObject(detElemId,manuId));
de01cdf0 1063 if (!calibParam)
1064 {
1065 Int_t dimension(11);
a0eca509 1066 Int_t size(AliMpConstants::ManuNofChannels());
de01cdf0 1067 Int_t defaultValue(-1);
a0eca509 1068 Int_t packingFactor(size);
de01cdf0 1069
a0eca509 1070 calibParam = new AliMUONCalibParamNI(dimension,size,detElemId,manuId,defaultValue,packingFactor);
1071 Bool_t ok = neighbourStore.Add(calibParam);
de01cdf0 1072 if (!ok)
1073 {
a99c3449 1074 AliErrorGeneral("AliMUONCDB", Form("Could not set DetElemId=%d manuId=%d",detElemId,manuId));
de01cdf0 1075 return -1;
1076 }
1077 }
1078
a0eca509 1079 for ( Int_t manuChannel = 0; manuChannel < AliMpConstants::ManuNofChannels(); ++manuChannel )
de01cdf0 1080 {
168e9c4d 1081 AliMpPad pad = seg->PadByLocation(manuId,manuChannel,kFALSE);
de01cdf0 1082
1083 if (pad.IsValid())
1084 {
1085 ++nchannels;
1086
1087 seg->GetNeighbours(pad,tmp,true,true);
1088 Int_t nofPadNeighbours = tmp.GetEntriesFast();
1089
1090 for ( Int_t i = 0; i < nofPadNeighbours; ++i )
1091 {
bf0d3528 1092 AliMpPad* p = static_cast<AliMpPad*>(tmp.UncheckedAt(i));
de01cdf0 1093 Int_t x;
409de10f 1094// Bool_t ok =
6e97fbb8 1095 calibParam->PackValues(p->GetManuId(),p->GetManuChannel(),x);
409de10f 1096// if (!ok)
1097// {
1098// AliError("Could not pack value. Something is seriously wrong. Please check");
1099// StdoutToAliError(pad->Print(););
1100// return -1;
1101// }
de01cdf0 1102 calibParam->SetValueAsInt(manuChannel,i,x);
1103 }
1104 }
1105 }
1106 }
1107
de01cdf0 1108 return nchannels;
1109}
1110
1111//_____________________________________________________________________________
1112void
1113AliMUONCDB::WriteLocalTriggerMasks(Int_t startRun, Int_t endRun)
1114{
1115 /// Write local trigger masks to OCDB
1116
630711ed 1117 AliMUONVStore* ltm = new AliMUON1DArray(AliMpConstants::TotalNofLocalBoards()+1);
de01cdf0 1118 Int_t ngenerated = MakeLocalTriggerMaskStore(*ltm);
a99c3449 1119 AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
de01cdf0 1120 if (ngenerated>0)
1121 {
1122 WriteToCDB("MUON/Calib/LocalTriggerBoardMasks",ltm,startRun,endRun,true);
1123 }
1124 delete ltm;
1125}
1126
1127//_____________________________________________________________________________
1128void
92c23b09 1129AliMUONCDB::WriteRegionalTriggerConfig(Int_t startRun, Int_t endRun)
de01cdf0 1130{
1131 /// Write regional trigger masks to OCDB
1132
92c23b09 1133 AliMUONRegionalTriggerConfig* rtm = new AliMUONRegionalTriggerConfig();
1134 Int_t ngenerated = MakeRegionalTriggerConfigStore(*rtm);
a99c3449 1135 AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
de01cdf0 1136 if (ngenerated>0)
1137 {
92c23b09 1138 WriteToCDB("MUON/Calib/RegionalTriggerConfig",rtm,startRun,endRun,true);
de01cdf0 1139 }
1140 delete rtm;
1141}
1142
92c23b09 1143
de01cdf0 1144//_____________________________________________________________________________
1145void
92c23b09 1146AliMUONCDB::WriteGlobalTriggerConfig(Int_t startRun, Int_t endRun)
de01cdf0 1147{
1148 /// Write global trigger masks to OCDB
1149
92c23b09 1150 AliMUONGlobalCrateConfig* gtm = new AliMUONGlobalCrateConfig();
de01cdf0 1151
92c23b09 1152 Int_t ngenerated = MakeGlobalTriggerConfigStore(*gtm);
a99c3449 1153 AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
de01cdf0 1154 if (ngenerated>0)
1155 {
92c23b09 1156 WriteToCDB("MUON/Calib/GlobalTriggerCrateConfig",gtm,startRun,endRun,true);
de01cdf0 1157 }
1158 delete gtm;
1159}
1160
92c23b09 1161
de01cdf0 1162//_____________________________________________________________________________
1163void
1164AliMUONCDB::WriteTriggerLut(Int_t startRun, Int_t endRun)
1165{
1166 /// Write trigger LUT to OCDB
1167
1168 AliMUONTriggerLut* lut = MakeTriggerLUT();
1169 if (lut)
1170 {
1171 WriteToCDB("MUON/Calib/TriggerLut",lut,startRun,endRun,true);
1172 }
1173 delete lut;
1174}
1175
1176//_____________________________________________________________________________
1177void
1178AliMUONCDB::WriteTriggerEfficiency(Int_t startRun, Int_t endRun)
1179{
1180 /// Write trigger efficiency to OCDB
1181
1182 AliMUONTriggerEfficiencyCells* eff = MakeTriggerEfficiency();
1183 if (eff)
1184 {
1185 WriteToCDB("MUON/Calib/TriggerEfficiency",eff,startRun,endRun,true);
1186 }
1187 delete eff;
1188}
1189
1190//_____________________________________________________________________________
1191void
1192AliMUONCDB::WriteNeighbours(Int_t startRun, Int_t endRun)
1193{
1194 /// Write neighbours to OCDB
1195
409de10f 1196 AliMUONVStore* neighbours = Create2DMap();
de01cdf0 1197 Int_t ngenerated = MakeNeighbourStore(*neighbours);
a99c3449 1198 AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
de01cdf0 1199 if (ngenerated>0)
1200 {
1201 WriteToCDB("MUON/Calib/Neighbours",neighbours,startRun,endRun,true);
1202 }
1203 delete neighbours;
1204}
1205
1206//_____________________________________________________________________________
1207void
1208AliMUONCDB::WriteHV(Bool_t defaultValues,
1209 Int_t startRun, Int_t endRun)
1210{
1211 /// generate HV values (either cste = 1500 V) if defaultValues=true or random
1212 /// if defaultValues=false, see makeHVStore) and
1213 /// store them into CDB located at cdbpath, with a validity period
1214 /// ranging from startRun to endRun
1215
1216 TMap* hvStore = new TMap;
1217 Int_t ngenerated = MakeHVStore(*hvStore,defaultValues);
a99c3449 1218 AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
de01cdf0 1219 if (ngenerated>0)
1220 {
1221 WriteToCDB("MUON/Calib/HV",hvStore,startRun,endRun,defaultValues);
1222 }
1223 delete hvStore;
1224}
1225
49e110ec 1226//_____________________________________________________________________________
1227void
1228AliMUONCDB::WriteTriggerDCS(Bool_t defaultValues,
1229 Int_t startRun, Int_t endRun)
1230{
1231 /// generate Trigger HV and current values (either const if defaultValues=true or random
1232 /// if defaultValues=false, see makeTriggerDCSStore) and
1233 /// store them into CDB located at cdbpath, with a validity period
1234 /// ranging from startRun to endRun
1235
1236 TMap* triggerDCSStore = new TMap;
1237 Int_t ngenerated = MakeTriggerDCSStore(*triggerDCSStore,defaultValues);
a99c3449 1238 AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
49e110ec 1239 if (ngenerated>0)
1240 {
1241 WriteToCDB("MUON/Calib/TriggerDCS",triggerDCSStore,startRun,endRun,defaultValues);
1242 }
1243 delete triggerDCSStore;
1244}
1245
de01cdf0 1246//_____________________________________________________________________________
1247void
1248AliMUONCDB::WritePedestals(Bool_t defaultValues,
1249 Int_t startRun, Int_t endRun)
1250{
1251 /// generate pedestal values (either 0 if defaultValues=true or random
1252 /// if defaultValues=false, see makePedestalStore) and
1253 /// store them into CDB located at cdbpath, with a validity period
1254 /// ranging from startRun to endRun
1255
409de10f 1256 AliMUONVStore* pedestalStore = Create2DMap();
de01cdf0 1257 Int_t ngenerated = MakePedestalStore(*pedestalStore,defaultValues);
a99c3449 1258 AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
de01cdf0 1259 WriteToCDB("MUON/Calib/Pedestals",pedestalStore,startRun,endRun,defaultValues);
1260 delete pedestalStore;
1261}
1262
2b8a1212 1263//_____________________________________________________________________________
1264void
7eafe398 1265AliMUONCDB::WriteOccupancyMap(Bool_t defaultValues,
1266 Int_t startRun, Int_t endRun)
2b8a1212 1267{
7eafe398 1268 /// generate occupancy map values (either empty one if defaultValues=true, or
1269 /// random one, see MakeOccupancyMapStore) and
2b8a1212 1270 /// store them into CDB located at cdbpath, with a validity period
1271 /// ranging from startRun to endRun
1272
7eafe398 1273 AliMUONVStore* occupancyMapStore = Create2DMap();
1274 Int_t ngenerated = MakeOccupancyMapStore(*occupancyMapStore,defaultValues);
a99c3449 1275 AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
7eafe398 1276 WriteToCDB("MUON/Calib/OccupancyMap",occupancyMapStore,startRun,endRun,defaultValues);
1277 delete occupancyMapStore;
2b8a1212 1278}
1279
0045b488 1280//_____________________________________________________________________________
1281void
1282AliMUONCDB::WriteRejectList(Bool_t defaultValues,
1283 Int_t startRun, Int_t endRun)
1284{
1285 /// generate reject list values (either empty one if defaultValues=true, or
1286 /// random one, see MakeRejectListStore) and
1287 /// store them into CDB located at cdbpath, with a validity period
1288 /// ranging from startRun to endRun
1289
1290 AliMUONRejectList* rl = MakeRejectListStore(defaultValues);
1291 WriteToCDB("MUON/Calib/RejectList",rl,startRun,endRun,defaultValues);
1292 delete rl;
1293}
1294
de01cdf0 1295
1296//_____________________________________________________________________________
1297void
1298AliMUONCDB::WriteGains(Bool_t defaultValues,
1299 Int_t startRun, Int_t endRun)
1300{
1301 /// generate gain values (either 1 if defaultValues=true or random
1302 /// if defaultValues=false, see makeGainStore) and
1303 /// store them into CDB located at cdbpath, with a validity period
1304 /// ranging from startRun to endRun
1305
409de10f 1306 AliMUONVStore* gainStore = Create2DMap();
de01cdf0 1307 Int_t ngenerated = MakeGainStore(*gainStore,defaultValues);
a99c3449 1308 AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
de01cdf0 1309 WriteToCDB("MUON/Calib/Gains",gainStore,startRun,endRun,defaultValues);
1310 delete gainStore;
1311}
1312
25e1df3e 1313//_____________________________________________________________________________
1314void
1315AliMUONCDB::WriteCapacitances(const char* filename,
1316 Int_t startRun, Int_t endRun)
1317{
1318 /// read manu capacitance and injection gain values from file
1319 /// and store them into CDB located at cdbpath, with a validity period
1320 /// ranging from startRun to endRun
1321
1322 AliMUONVStore* capaStore = new AliMUON1DMap(16828);
1323 Int_t ngenerated = MakeCapacitanceStore(*capaStore,filename);
a99c3449 1324 AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
25e1df3e 1325 if ( ngenerated > 0 )
1326 {
1327 WriteToCDB("MUON/Calib/Capacitances",capaStore,startRun,endRun,filename);
1328 }
1329 delete capaStore;
1330}
1331
de01cdf0 1332//_____________________________________________________________________________
1333void
1334AliMUONCDB::WriteCapacitances(Bool_t defaultValues,
1335 Int_t startRun, Int_t endRun)
1336{
1337 /// generate manu capacitance values (either 1 if defaultValues=true or random
1338 /// if defaultValues=false, see makeCapacitanceStore) and
1339 /// store them into CDB located at cdbpath, with a validity period
1340 /// ranging from startRun to endRun
1341
a0eca509 1342 AliMUONVStore* capaStore = new AliMUON1DMap(16828);
de01cdf0 1343 Int_t ngenerated = MakeCapacitanceStore(*capaStore,defaultValues);
a99c3449 1344 AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
de01cdf0 1345 WriteToCDB("MUON/Calib/Capacitances",capaStore,startRun,endRun,defaultValues);
1346 delete capaStore;
1347}
1348
1349//_____________________________________________________________________________
1350void
49e110ec 1351AliMUONCDB::WriteTrigger(Bool_t defaultValues, Int_t startRun, Int_t endRun)
de01cdf0 1352{
1353 /// Writes all Trigger related calibration to CDB
49e110ec 1354 WriteTriggerDCS(defaultValues,startRun,endRun);
de01cdf0 1355 WriteLocalTriggerMasks(startRun,endRun);
92c23b09 1356 WriteRegionalTriggerConfig(startRun,endRun);
1357 WriteGlobalTriggerConfig(startRun,endRun);
de01cdf0 1358 WriteTriggerLut(startRun,endRun);
1359 WriteTriggerEfficiency(startRun,endRun);
1360}
1361
1362//_____________________________________________________________________________
1363void
1364AliMUONCDB::WriteTracker(Bool_t defaultValues, Int_t startRun, Int_t endRun)
1365{
1366 /// Writes all Tracker related calibration to CDB
1367 WriteHV(defaultValues,startRun,endRun);
1368 WritePedestals(defaultValues,startRun,endRun);
1369 WriteGains(defaultValues,startRun,endRun);
1370 WriteCapacitances(defaultValues,startRun,endRun);
1371 WriteNeighbours(startRun,endRun);
7eafe398 1372 WriteOccupancyMap(startRun,endRun,defaultValues);
0045b488 1373 WriteRejectList(startRun,endRun,defaultValues);
de01cdf0 1374}
913f1b43 1375