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