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