1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //-----------------------------------------------------------------------------
21 /// Helper class to experience the OCDB
22 /// It allows to generate dummy (but complete) containers for all the
23 /// calibration data types we have for tracker and trigger, and to write
26 /// For more information, please see READMECDB
28 // \author Laurent Aphecetche
29 //-----------------------------------------------------------------------------
31 #include "AliMUONCDB.h"
33 #include "AliMUON1DArray.h"
34 #include "AliMUON1DMap.h"
35 #include "AliMUON2DMap.h"
36 #include "AliMUON2DStoreValidator.h"
37 #include "AliMUONCalibParamNF.h"
38 #include "AliMUONCalibParamNI.h"
39 #include "AliMUONConstants.h"
40 #include "AliMUONTrackerIO.h"
41 #include "AliMUONTriggerEfficiencyCells.h"
42 #include "AliMUONTriggerLut.h"
43 #include "AliMUONVStore.h"
44 #include "AliMUONVCalibParam.h"
45 #include "AliMUONVCalibParam.h"
46 #include "AliMUONGlobalCrateConfig.h"
47 #include "AliMUONRegionalTriggerConfig.h"
50 #include "AliMpConstants.h"
51 #include "AliMpDDLStore.h"
52 #include "AliMpManuStore.h"
53 #include "AliMpDEManager.h"
54 #include "AliMpDetElement.h"
55 #include "AliMpFiles.h"
56 #include "AliMpDCSNamer.h"
57 #include "AliMpManuIterator.h"
58 #include "AliMpSegmentation.h"
59 #include "AliMpStationType.h"
60 #include "AliMpVSegmentation.h"
62 #include "AliCodeTimer.h"
63 #include "AliCDBEntry.h"
64 #include "AliCDBManager.h"
65 #include "AliDCSValue.h"
68 #include <Riostream.h>
74 #include <TObjString.h>
77 #include <TStopwatch.h>
88 //_____________________________________________________________________________
89 AliMUONVStore* Create2DMap()
91 return new AliMUON2DMap(true);
94 //_____________________________________________________________________________
95 void getBoundaries(const AliMUONVStore& store, Int_t dim,
96 Float_t* xmin, Float_t* xmax)
98 /// Assuming the store contains AliMUONVCalibParam objects, compute the
99 /// limits of the value contained in the VCalibParam, for each of its dimensions
100 /// xmin and xmax must be of dimension dim
102 for ( Int_t i = 0; i < dim; ++i )
108 TIter next(store.CreateIterator());
109 AliMUONVCalibParam* value;
111 while ( ( value = dynamic_cast<AliMUONVCalibParam*>(next() ) ) )
113 Int_t detElemId = value->ID0();
114 Int_t manuId = value->ID1();
116 const AliMpVSegmentation* seg =
117 AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId,manuId);
119 for ( Int_t manuChannel = 0; manuChannel < value->Size(); ++manuChannel )
121 AliMpPad pad = seg->PadByLocation(AliMpIntPair(manuId,manuChannel),kFALSE);
122 if (!pad.IsValid()) continue;
124 for ( Int_t i = 0; i < dim; ++i )
126 Float_t x0 = value->ValueAsFloat(manuChannel,i);
128 xmin[i] = TMath::Min(xmin[i],x0);
129 xmax[i] = TMath::Max(xmax[i],x0);
134 for ( Int_t i = 0; i < dim; ++i )
136 if ( TMath::Abs(xmin[i]-xmax[i]) < 1E-3 )
144 //_____________________________________________________________________________
145 Double_t GetRandom(Double_t mean, Double_t sigma, Bool_t mustBePositive)
148 if ( mustBePositive )
152 x = gRandom->Gaus(mean,sigma);
157 x = gRandom->Gaus(mean,sigma);
164 //_____________________________________________________________________________
165 AliMUONCDB::AliMUONCDB(const char* cdbpath)
168 fMaxNofChannelsToGenerate(-1)
172 if ( ! AliMpCDB::LoadDDLStore() ) {
173 AliFatal("Could not access mapping from OCDB !");
176 if ( ! AliMpCDB::LoadManuStore() ) {
177 AliFatal("Could not access run-dependent mapping from OCDB !");
181 //_____________________________________________________________________________
182 AliMUONCDB::~AliMUONCDB()
187 //_____________________________________________________________________________
189 AliMUONCDB::Diff(AliMUONVStore& store1, AliMUONVStore& store2,
192 /// creates a store which contains store1-store2
193 /// if opt="abs" the difference is absolute one,
194 /// if opt="rel" then what is stored is (store1-store2)/store1
195 /// if opt="percent" then what is stored is rel*100
197 /// WARNING Works only for stores which holds AliMUONVCalibParam objects
202 if ( !sopt.Contains("ABS") && !sopt.Contains("REL") && !sopt.Contains("PERCENT") )
204 AliErrorClass(Form("opt %s not supported. Only ABS, REL, PERCENT are",opt));
208 AliMUONVStore* d = static_cast<AliMUONVStore*>(store1.Clone());
210 TIter next(d->CreateIterator());
212 AliMUONVCalibParam* param;
214 while ( ( param = dynamic_cast<AliMUONVCalibParam*>(next() ) ) )
216 Int_t detElemId = param->ID0();
217 Int_t manuId = param->ID1();
219 AliMUONVCalibParam* param2 = dynamic_cast<AliMUONVCalibParam*>(store2.FindObject(detElemId,manuId));
220 //FIXME: this might happen. Handle it.
223 cerr << "param2 is null : FIXME : this might happen !" << endl;
228 for ( Int_t i = 0; i < param->Size(); ++i )
230 for ( Int_t j = 0; j < param->Dimension(); ++j )
233 if ( sopt.Contains("ABS") )
235 value = param->ValueAsFloat(i,j) - param2->ValueAsFloat(i,j);
237 else if ( sopt.Contains("REL") || sopt.Contains("PERCENT") )
239 if ( param->ValueAsFloat(i,j) )
241 value = (param->ValueAsFloat(i,j) - param2->ValueAsFloat(i,j))/param->ValueAsFloat(i,j);
247 if ( sopt.Contains("PERCENT") ) value *= 100.0;
249 param->SetValueAsFloat(i,j,value);
256 //_____________________________________________________________________________
258 AliMUONCDB::Plot(const AliMUONVStore& store, const char* name, Int_t nbins)
260 /// Make histograms of each dimension of the AliMUONVCalibParam
261 /// contained inside store.
262 /// It produces histograms named name_0, name_1, etc...
264 TIter next(store.CreateIterator());
265 AliMUONVCalibParam* param;
267 const Int_t kNStations = AliMpConstants::NofTrackingChambers()/2;
268 Int_t* nPerStation = new Int_t[kNStations];
271 for ( Int_t i = 0; i < kNStations; ++i ) nPerStation[i]=0;
273 while ( ( param = static_cast<AliMUONVCalibParam*>(next()) ) )
277 Int_t dim = param->Dimension();
279 Float_t* xmin = new Float_t[dim];
280 Float_t* xmax = new Float_t[dim];
281 getBoundaries(store,dim,xmin,xmax);
283 for ( Int_t i = 0; i < dim; ++i )
285 h[i] = new TH1F(Form("%s_%d",name,i),Form("%s_%d",name,i),
286 nbins,xmin[i],xmax[i]);
287 AliInfo(Form("Created histogram %s",h[i]->GetName()));
291 Int_t detElemId = param->ID0();
292 Int_t manuId = param->ID1();
293 Int_t station = AliMpDEManager::GetChamberId(detElemId)/2;
295 const AliMpVSegmentation* seg =
296 AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId,manuId);
298 for ( Int_t manuChannel = 0; manuChannel < param->Size(); ++manuChannel )
300 AliMpPad pad = seg->PadByLocation(AliMpIntPair(manuId,manuChannel),kFALSE);
301 if (!pad.IsValid()) continue;
304 ++nPerStation[station];
306 for ( Int_t dim = 0; dim < param->Dimension(); ++dim )
308 h[dim]->Fill(param->ValueAsFloat(manuChannel,dim));
313 for ( Int_t i = 0; i < kNStations; ++i )
315 AliInfo(Form("Station %d %d ",(i+1),nPerStation[i]));
318 AliInfo(Form("Number of channels = %d",n));
320 delete[] nPerStation;
323 //_____________________________________________________________________________
325 AliMUONCDB::MakeHVStore(TMap& aliasMap, Bool_t defaultValues)
327 /// Create a HV store
329 AliMpDCSNamer hvNamer("TRACKER");
331 TObjArray* aliases = hvNamer.GenerateAliases();
336 for ( Int_t i = 0; i < aliases->GetEntries(); ++i )
338 TObjString* alias = static_cast<TObjString*>(aliases->At(i));
339 TString& aliasName = alias->String();
340 if ( aliasName.Contains("sw") )
342 // HV Switch (St345 only)
343 TObjArray* valueSet = new TObjArray;
344 valueSet->SetOwner(kTRUE);
346 Bool_t value = kTRUE;
350 Float_t r = gRandom->Uniform();
351 if ( r < 0.007 ) value = kFALSE;
354 for ( UInt_t timeStamp = 0; timeStamp < 60*3; timeStamp += 60 )
356 AliDCSValue* dcsValue = new AliDCSValue(value,timeStamp);
357 valueSet->Add(dcsValue);
359 aliasMap.Add(new TObjString(*alias),valueSet);
364 TObjArray* valueSet = new TObjArray;
365 valueSet->SetOwner(kTRUE);
366 for ( UInt_t timeStamp = 0; timeStamp < 60*15; timeStamp += 120 )
368 Float_t value = 1500;
369 if (!defaultValues) value = GetRandom(1750,62.5,true);
370 AliDCSValue* dcsValue = new AliDCSValue(value,timeStamp);
371 valueSet->Add(dcsValue);
373 aliasMap.Add(new TObjString(*alias),valueSet);
380 AliInfo(Form("%d HV channels and %d switches",nChannels,nSwitch));
382 return nChannels+nSwitch;
385 //_____________________________________________________________________________
387 AliMUONCDB::MakeTriggerDCSStore(TMap& aliasMap, Bool_t defaultValues)
389 /// Create a Trigger HV and Currents store
391 AliMpDCSNamer triggerDCSNamer("TRIGGER");
393 TObjArray* aliases = triggerDCSNamer.GenerateAliases();
395 Int_t nChannels[2] = {0, 0};
397 for ( Int_t i = 0; i < aliases->GetEntries(); ++i )
399 TObjString* alias = static_cast<TObjString*>(aliases->At(i));
400 TString& aliasName = alias->String();
402 TObjArray* valueSet = new TObjArray;
403 valueSet->SetOwner(kTRUE);
404 Int_t measureType = triggerDCSNamer.DCSvariableFromDCSAlias(aliasName.Data());
405 for ( UInt_t timeStamp = 0; timeStamp < 60*15; timeStamp += 120 )
408 (measureType == AliMpDCSNamer::kDCSI) ? 2. : 8000.;
409 if (!defaultValues) {
410 switch (measureType){
411 case AliMpDCSNamer::kDCSI:
412 value = GetRandom(2.,0.4,true);
414 case AliMpDCSNamer::kDCSHV:
415 value = GetRandom(8000.,16.,true);
419 AliDCSValue* dcsValue = new AliDCSValue(value,timeStamp);
420 valueSet->Add(dcsValue);
422 aliasMap.Add(new TObjString(*alias),valueSet);
423 ++nChannels[measureType];
428 AliInfo(Form("Trigger channels I -> %i HV -> %i",nChannels[0], nChannels[1]));
430 return nChannels[0] + nChannels[1];
433 //_____________________________________________________________________________
435 AliMUONCDB::MakePedestalStore(AliMUONVStore& pedestalStore, Bool_t defaultValues)
437 /// Create a pedestal store. if defaultValues=true, ped.mean=ped.sigma=1,
438 /// otherwise mean and sigma are from a gaussian (with parameters
439 /// defined below by the kPedestal* constants)
441 AliCodeTimerAuto("");
446 const Int_t kChannels(AliMpConstants::ManuNofChannels());
447 const Float_t kPedestalMeanMean(200);
448 const Float_t kPedestalMeanSigma(10);
449 const Float_t kPedestalSigmaMean(1.0);
450 const Float_t kPedestalSigmaSigma(0.2);
455 AliMpManuIterator it;
457 while ( it.Next(detElemId,manuId) )
461 AliMUONVCalibParam* ped =
462 new AliMUONCalibParamNF(2,kChannels,detElemId,manuId,AliMUONVCalibParam::InvalidFloatValue());
464 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
466 for ( Int_t manuChannel = 0; manuChannel < kChannels; ++manuChannel )
468 if ( ! de->IsConnectedChannel(manuId,manuChannel) ) continue;
472 Float_t meanPedestal;
473 Float_t sigmaPedestal;
482 Bool_t positive(kTRUE);
484 while ( meanPedestal == 0.0 ) // avoid strict zero
486 meanPedestal = GetRandom(kPedestalMeanMean,kPedestalMeanSigma,positive);
488 sigmaPedestal = GetRandom(kPedestalSigmaMean,kPedestalSigmaSigma,positive);
490 ped->SetValueAsFloat(manuChannel,0,meanPedestal);
491 ped->SetValueAsFloat(manuChannel,1,sigmaPedestal);
494 Bool_t ok = pedestalStore.Add(ped);
497 AliError(Form("Could not set DetElemId=%d manuId=%d",detElemId,manuId));
499 if ( fMaxNofChannelsToGenerate > 0 && nchannels >= fMaxNofChannelsToGenerate ) break;
502 AliInfo(Form("%d Manus and %d channels.",nmanus,nchannels));
506 //_____________________________________________________________________________
508 AliMUONCDB::MakeCapacitanceStore(AliMUONVStore& capaStore, const char* file)
510 /// Read the capacitance values from file and append them to the capaStore
512 return AliMUONTrackerIO::ReadCapacitances(file,capaStore);
515 //_____________________________________________________________________________
517 AliMUONCDB::MakeCapacitanceStore(AliMUONVStore& capaStore, Bool_t defaultValues)
519 /// Create a capacitance store. if defaultValues=true, all capa are 1.0,
520 /// otherwise they are from a gaussian with parameters defined in the
521 /// kCapa* constants below.
523 AliCodeTimerAuto("");
527 Int_t nmanusOK(0); // manus for which we got the serial number
529 const Float_t kCapaMean(0.3);
530 const Float_t kCapaSigma(0.1);
531 const Float_t kInjectionGainMean(3);
532 const Float_t kInjectionGainSigma(1);
537 AliMpManuIterator it;
539 while ( it.Next(detElemId,manuId) )
543 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
544 Int_t serialNumber = AliMpManuStore::Instance()->GetManuSerial(detElemId, manuId);
546 if ( serialNumber <= 0 ) continue;
550 AliMUONVCalibParam* capa = static_cast<AliMUONVCalibParam*>(capaStore.FindObject(serialNumber));
554 capa = new AliMUONCalibParamNF(2,AliMpConstants::ManuNofChannels(),serialNumber,0,1.0);
555 Bool_t ok = capaStore.Add(capa);
558 AliError(Form("Could not set serialNumber=%d manuId=%d",serialNumber,manuId));
562 for ( Int_t manuChannel = 0; manuChannel < capa->Size(); ++manuChannel )
564 if ( ! de->IsConnectedChannel(manuId,manuChannel) ) continue;
569 Float_t injectionGain;
578 capaValue = GetRandom(kCapaMean,kCapaSigma,kTRUE);
579 injectionGain = GetRandom(kInjectionGainMean,kInjectionGainSigma,kTRUE);
581 capa->SetValueAsFloat(manuChannel,0,capaValue);
582 capa->SetValueAsFloat(manuChannel,1,injectionGain);
587 if ( nmanus ) percent = 100*nmanusOK/nmanus;
588 AliInfo(Form("%5d manus with serial number (out of %5d manus = %3.0f%%)",
589 nmanusOK,nmanus,percent));
590 AliInfo(Form("%5d channels",nchannels));
593 AliWarning("Did not get all serial numbers. capaStore is incomplete !!!!");
599 //_____________________________________________________________________________
601 AliMUONCDB::MakeGainStore(AliMUONVStore& gainStore, Bool_t defaultValues)
603 /// Create a gain store. if defaultValues=true, all gains set so that
604 /// charge = (adc-ped)
606 /// otherwise parameters are taken from gaussians with parameters
607 /// defined in the k* constants below.
609 AliCodeTimerAuto("");
614 const Int_t kSaturation(3000);
615 const Double_t kA0Mean(1.2);
616 const Double_t kA0Sigma(0.1);
617 const Double_t kA1Mean(1E-5);
618 const Double_t kA1Sigma(1E-6);
619 const Double_t kQualMean(0xFF);
620 const Double_t kQualSigma(0x10);
621 const Int_t kThresMean(1600);
622 const Int_t kThresSigma(100);
627 AliMpManuIterator it;
629 while ( it.Next(detElemId,manuId) )
633 AliMUONVCalibParam* gain =
634 new AliMUONCalibParamNF(5,AliMpConstants::ManuNofChannels(),
637 AliMUONVCalibParam::InvalidFloatValue());
639 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
641 for ( Int_t manuChannel = 0; manuChannel < gain->Size(); ++manuChannel )
643 if ( ! de->IsConnectedChannel(manuId,manuChannel) ) continue;
649 gain->SetValueAsFloat(manuChannel,0,1.0);
650 gain->SetValueAsFloat(manuChannel,1,0.0);
651 gain->SetValueAsInt(manuChannel,2,4095);
652 gain->SetValueAsInt(manuChannel,3,1);
653 gain->SetValueAsInt(manuChannel,4,kSaturation);
657 Bool_t positive(kTRUE);
658 gain->SetValueAsFloat(manuChannel,0,GetRandom(kA0Mean,kA0Sigma,positive));
659 gain->SetValueAsFloat(manuChannel,1,GetRandom(kA1Mean,kA1Sigma,!positive));
660 gain->SetValueAsInt(manuChannel,2,(Int_t)TMath::Nint(GetRandom(kThresMean,kThresSigma,positive)));
661 gain->SetValueAsInt(manuChannel,3,(Int_t)TMath::Nint(GetRandom(kQualMean,kQualSigma,positive)));
662 gain->SetValueAsInt(manuChannel,4,kSaturation);
666 Bool_t ok = gainStore.Add(gain);
669 AliError(Form("Could not set DetElemId=%d manuId=%d",detElemId,manuId));
671 if ( fMaxNofChannelsToGenerate > 0 && nchannels >= fMaxNofChannelsToGenerate ) break;
674 AliInfo(Form("%d Manus and %d channels.",nmanus,nchannels));
678 //_____________________________________________________________________________
680 AliMUONCDB::MakeLocalTriggerMaskStore(AliMUONVStore& localBoardMasks) const
682 /// Generate local trigger masks store. All masks are set to FFFF
684 AliCodeTimerAuto("");
687 // Generate fake mask values for all localboards and put that into
688 // one single container (localBoardMasks)
689 for ( Int_t i = 1; i <= AliMpConstants::TotalNofLocalBoards(); ++i )
691 AliMUONVCalibParam* localBoard = new AliMUONCalibParamNI(1,8,i,0,0);
692 for ( Int_t x = 0; x < 2; ++x )
694 for ( Int_t y = 0; y < 4; ++y )
697 localBoard->SetValueAsInt(index,0,0xFFFF);
701 localBoardMasks.Add(localBoard);
706 //_____________________________________________________________________________
708 AliMUONCDB::MakeRegionalTriggerConfigStore(AliMUONRegionalTriggerConfig& rtm) const
710 /// Make a regional trigger config store. Mask is set to FFFF for each local board (Ch.F.)
712 AliCodeTimerAuto("");
714 if ( ! rtm.ReadData(AliMpFiles::LocalTriggerBoardMapping()) ) {
715 AliErrorStream() << "Error when reading from mapping file" << endl;
719 return rtm.GetNofTriggerCrates();
723 //_____________________________________________________________________________
725 AliMUONCDB::MakeGlobalTriggerConfigStore(AliMUONGlobalCrateConfig& gtm) const
727 /// Make a global trigger config store. All masks (disable) set to 0x00 for each Darc board (Ch.F.)
729 AliCodeTimerAuto("");
731 return gtm.ReadData(AliMpFiles::GlobalTriggerBoardMapping());
735 //_____________________________________________________________________________
737 AliMUONCDB::MakeTriggerLUT(const char* file) const
739 /// Make a triggerlut object, from a file.
741 AliCodeTimerAuto("");
743 AliMUONTriggerLut* lut = new AliMUONTriggerLut;
744 lut->ReadFromFile(file);
748 //_____________________________________________________________________________
749 AliMUONTriggerEfficiencyCells*
750 AliMUONCDB::MakeTriggerEfficiency(const char* file) const
752 /// Make a trigger efficiency object from a file.
754 AliCodeTimerAuto("");
756 return new AliMUONTriggerEfficiencyCells(file);
759 //_____________________________________________________________________________
761 AliMUONCDB::WriteToCDB(const char* calibpath, TObject* object,
762 Int_t startRun, Int_t endRun,
763 const char* filename)
765 /// Write a given object to OCDB
767 TString comment(gSystem->ExpandPathName(filename));
769 WriteToCDB(object, calibpath, startRun, endRun, comment.Data());
772 //_____________________________________________________________________________
774 AliMUONCDB::WriteToCDB(const char* calibpath, TObject* object,
775 Int_t startRun, Int_t endRun, Bool_t defaultValues)
777 /// Write a given object to OCDB
780 if ( defaultValues ) comment += "Test with default values";
781 else comment += "Test with random values";
783 WriteToCDB(object, calibpath, startRun, endRun, comment.Data());
786 //_____________________________________________________________________________
788 AliMUONCDB::WriteToCDB(TObject* object, const char* calibpath, Int_t startRun, Int_t endRun,
789 const char* comment, const char* responsible)
791 /// Write a given object to OCDB
793 AliCDBId id(calibpath,startRun,endRun);
795 md.SetAliRootVersion(gROOT->GetVersion());
796 md.SetComment(comment);
797 md.SetResponsible(responsible);
798 AliCDBManager* man = AliCDBManager::Instance();
799 if (!man->IsDefaultStorageSet()) man->SetDefaultStorage(fCDBPath);
800 man->Put(object,id,&md);
803 //_____________________________________________________________________________
805 AliMUONCDB::MakeNeighbourStore(AliMUONVStore& neighbourStore)
807 /// Fill the neighbours store with, for each channel, a TObjArray of its
808 /// neighbouring pads (including itself)
810 AliCodeTimerAuto("");
812 AliInfo("Generating NeighbourStore. This will take a while. Please be patient.");
821 AliMpManuIterator it;
823 while ( it.Next(detElemId,manuId) )
825 const AliMpVSegmentation* seg =
826 AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId,manuId);
828 AliMUONVCalibParam* calibParam = static_cast<AliMUONVCalibParam*>(neighbourStore.FindObject(detElemId,manuId));
832 Int_t size(AliMpConstants::ManuNofChannels());
833 Int_t defaultValue(-1);
834 Int_t packingFactor(size);
836 calibParam = new AliMUONCalibParamNI(dimension,size,detElemId,manuId,defaultValue,packingFactor);
837 Bool_t ok = neighbourStore.Add(calibParam);
840 AliError(Form("Could not set DetElemId=%d manuId=%d",detElemId,manuId));
845 for ( Int_t manuChannel = 0; manuChannel < AliMpConstants::ManuNofChannels(); ++manuChannel )
847 AliMpPad pad = seg->PadByLocation(AliMpIntPair(manuId,manuChannel),kFALSE);
853 seg->GetNeighbours(pad,tmp,true,true);
854 Int_t nofPadNeighbours = tmp.GetEntriesFast();
856 for ( Int_t i = 0; i < nofPadNeighbours; ++i )
858 AliMpPad* p = static_cast<AliMpPad*>(tmp.UncheckedAt(i));
861 calibParam->PackValues(p->GetLocation().GetFirst(),p->GetLocation().GetSecond(),x);
864 // AliError("Could not pack value. Something is seriously wrong. Please check");
865 // StdoutToAliError(pad->Print(););
868 calibParam->SetValueAsInt(manuChannel,i,x);
877 //_____________________________________________________________________________
879 AliMUONCDB::SetMaxNofChannelsToGenerate(Int_t n)
881 /// Set the maximum number of channels to generate (used for testing only)
882 /// n < 0 means no limit
883 fMaxNofChannelsToGenerate = n;
886 //_____________________________________________________________________________
888 AliMUONCDB::WriteLocalTriggerMasks(Int_t startRun, Int_t endRun)
890 /// Write local trigger masks to OCDB
892 AliMUONVStore* ltm = new AliMUON1DArray(AliMpConstants::TotalNofLocalBoards()+1);
893 Int_t ngenerated = MakeLocalTriggerMaskStore(*ltm);
894 AliInfo(Form("Ngenerated = %d",ngenerated));
897 WriteToCDB("MUON/Calib/LocalTriggerBoardMasks",ltm,startRun,endRun,true);
902 //_____________________________________________________________________________
904 AliMUONCDB::WriteRegionalTriggerConfig(Int_t startRun, Int_t endRun)
906 /// Write regional trigger masks to OCDB
908 AliMUONRegionalTriggerConfig* rtm = new AliMUONRegionalTriggerConfig();
909 Int_t ngenerated = MakeRegionalTriggerConfigStore(*rtm);
910 AliInfo(Form("Ngenerated = %d",ngenerated));
913 WriteToCDB("MUON/Calib/RegionalTriggerConfig",rtm,startRun,endRun,true);
919 //_____________________________________________________________________________
921 AliMUONCDB::WriteGlobalTriggerConfig(Int_t startRun, Int_t endRun)
923 /// Write global trigger masks to OCDB
925 AliMUONGlobalCrateConfig* gtm = new AliMUONGlobalCrateConfig();
927 Int_t ngenerated = MakeGlobalTriggerConfigStore(*gtm);
928 AliInfo(Form("Ngenerated = %d",ngenerated));
931 WriteToCDB("MUON/Calib/GlobalTriggerCrateConfig",gtm,startRun,endRun,true);
937 //_____________________________________________________________________________
939 AliMUONCDB::WriteTriggerLut(Int_t startRun, Int_t endRun)
941 /// Write trigger LUT to OCDB
943 AliMUONTriggerLut* lut = MakeTriggerLUT();
946 WriteToCDB("MUON/Calib/TriggerLut",lut,startRun,endRun,true);
951 //_____________________________________________________________________________
953 AliMUONCDB::WriteTriggerEfficiency(Int_t startRun, Int_t endRun)
955 /// Write trigger efficiency to OCDB
957 AliMUONTriggerEfficiencyCells* eff = MakeTriggerEfficiency();
960 WriteToCDB("MUON/Calib/TriggerEfficiency",eff,startRun,endRun,true);
965 //_____________________________________________________________________________
967 AliMUONCDB::WriteNeighbours(Int_t startRun, Int_t endRun)
969 /// Write neighbours to OCDB
971 AliMUONVStore* neighbours = Create2DMap();
972 Int_t ngenerated = MakeNeighbourStore(*neighbours);
973 AliInfo(Form("Ngenerated = %d",ngenerated));
976 WriteToCDB("MUON/Calib/Neighbours",neighbours,startRun,endRun,true);
981 //_____________________________________________________________________________
983 AliMUONCDB::WriteHV(Bool_t defaultValues,
984 Int_t startRun, Int_t endRun)
986 /// generate HV values (either cste = 1500 V) if defaultValues=true or random
987 /// if defaultValues=false, see makeHVStore) and
988 /// store them into CDB located at cdbpath, with a validity period
989 /// ranging from startRun to endRun
991 TMap* hvStore = new TMap;
992 Int_t ngenerated = MakeHVStore(*hvStore,defaultValues);
993 AliInfo(Form("Ngenerated = %d",ngenerated));
996 WriteToCDB("MUON/Calib/HV",hvStore,startRun,endRun,defaultValues);
1001 //_____________________________________________________________________________
1003 AliMUONCDB::WriteTriggerDCS(Bool_t defaultValues,
1004 Int_t startRun, Int_t endRun)
1006 /// generate Trigger HV and current values (either const if defaultValues=true or random
1007 /// if defaultValues=false, see makeTriggerDCSStore) and
1008 /// store them into CDB located at cdbpath, with a validity period
1009 /// ranging from startRun to endRun
1011 TMap* triggerDCSStore = new TMap;
1012 Int_t ngenerated = MakeTriggerDCSStore(*triggerDCSStore,defaultValues);
1013 AliInfo(Form("Ngenerated = %d",ngenerated));
1016 WriteToCDB("MUON/Calib/TriggerDCS",triggerDCSStore,startRun,endRun,defaultValues);
1018 delete triggerDCSStore;
1021 //_____________________________________________________________________________
1023 AliMUONCDB::WritePedestals(Bool_t defaultValues,
1024 Int_t startRun, Int_t endRun)
1026 /// generate pedestal values (either 0 if defaultValues=true or random
1027 /// if defaultValues=false, see makePedestalStore) and
1028 /// store them into CDB located at cdbpath, with a validity period
1029 /// ranging from startRun to endRun
1031 AliMUONVStore* pedestalStore = Create2DMap();
1032 Int_t ngenerated = MakePedestalStore(*pedestalStore,defaultValues);
1033 AliInfo(Form("Ngenerated = %d",ngenerated));
1034 WriteToCDB("MUON/Calib/Pedestals",pedestalStore,startRun,endRun,defaultValues);
1035 delete pedestalStore;
1039 //_____________________________________________________________________________
1041 AliMUONCDB::WriteGains(Bool_t defaultValues,
1042 Int_t startRun, Int_t endRun)
1044 /// generate gain values (either 1 if defaultValues=true or random
1045 /// if defaultValues=false, see makeGainStore) and
1046 /// store them into CDB located at cdbpath, with a validity period
1047 /// ranging from startRun to endRun
1049 AliMUONVStore* gainStore = Create2DMap();
1050 Int_t ngenerated = MakeGainStore(*gainStore,defaultValues);
1051 AliInfo(Form("Ngenerated = %d",ngenerated));
1052 WriteToCDB("MUON/Calib/Gains",gainStore,startRun,endRun,defaultValues);
1056 //_____________________________________________________________________________
1058 AliMUONCDB::WriteCapacitances(const char* filename,
1059 Int_t startRun, Int_t endRun)
1061 /// read manu capacitance and injection gain values from file
1062 /// and store them into CDB located at cdbpath, with a validity period
1063 /// ranging from startRun to endRun
1065 AliMUONVStore* capaStore = new AliMUON1DMap(16828);
1066 Int_t ngenerated = MakeCapacitanceStore(*capaStore,filename);
1067 AliInfo(Form("Ngenerated = %d",ngenerated));
1068 if ( ngenerated > 0 )
1070 WriteToCDB("MUON/Calib/Capacitances",capaStore,startRun,endRun,filename);
1075 //_____________________________________________________________________________
1077 AliMUONCDB::WriteCapacitances(Bool_t defaultValues,
1078 Int_t startRun, Int_t endRun)
1080 /// generate manu capacitance values (either 1 if defaultValues=true or random
1081 /// if defaultValues=false, see makeCapacitanceStore) and
1082 /// store them into CDB located at cdbpath, with a validity period
1083 /// ranging from startRun to endRun
1085 AliMUONVStore* capaStore = new AliMUON1DMap(16828);
1086 Int_t ngenerated = MakeCapacitanceStore(*capaStore,defaultValues);
1087 AliInfo(Form("Ngenerated = %d",ngenerated));
1088 WriteToCDB("MUON/Calib/Capacitances",capaStore,startRun,endRun,defaultValues);
1092 //_____________________________________________________________________________
1094 AliMUONCDB::WriteTrigger(Bool_t defaultValues, Int_t startRun, Int_t endRun)
1096 /// Writes all Trigger related calibration to CDB
1097 WriteTriggerDCS(defaultValues,startRun,endRun);
1098 WriteLocalTriggerMasks(startRun,endRun);
1099 WriteRegionalTriggerConfig(startRun,endRun);
1100 WriteGlobalTriggerConfig(startRun,endRun);
1101 WriteTriggerLut(startRun,endRun);
1102 WriteTriggerEfficiency(startRun,endRun);
1105 //_____________________________________________________________________________
1107 AliMUONCDB::WriteTracker(Bool_t defaultValues, Int_t startRun, Int_t endRun)
1109 /// Writes all Tracker related calibration to CDB
1110 WriteHV(defaultValues,startRun,endRun);
1111 WritePedestals(defaultValues,startRun,endRun);
1112 WriteGains(defaultValues,startRun,endRun);
1113 WriteCapacitances(defaultValues,startRun,endRun);
1114 WriteNeighbours(startRun,endRun);