X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=MUON%2FAliMUONCDB.cxx;h=54e97ca9a08586db3da717eac9e9df85c6df0b01;hb=da2d199e7a43dca38046efcbf1dae1a5648aa5a5;hp=e1ac639f93ffd441737059d2fccaa4dd5a0ff37e;hpb=a0eca50986ea6e10d419bf5c2af185e1a77093b7;p=u%2Fmrichter%2FAliRoot.git diff --git a/MUON/AliMUONCDB.cxx b/MUON/AliMUONCDB.cxx index e1ac639f93f..54e97ca9a08 100644 --- a/MUON/AliMUONCDB.cxx +++ b/MUON/AliMUONCDB.cxx @@ -15,45 +15,65 @@ /* $Id$ */ -/// \class AliMUONCDB +//----------------------------------------------------------------------------- +/// \namespace AliMUONCDB /// -/// Helper class to experience the OCDB -/// It allows to generate dummy (but complete) containers for all the +/// Helper functions to experience the OCDB +/// +/// They allow to read magnetic field, mapping and recoParam from OCDB +/// +/// And also to generate dummy (but complete) containers for all the /// calibration data types we have for tracker and trigger, and to write /// them into OCDB. /// -/// For more information, please see READMECDB +/// For more information, please see READMEcalib /// -// \author Laurent Aphecetche +/// \author Laurent Aphecetche +//----------------------------------------------------------------------------- #include "AliMUONCDB.h" -#include "AliCDBEntry.h" -#include "AliCDBManager.h" -#include "AliDCSValue.h" -#include "AliLog.h" #include "AliMUON1DArray.h" #include "AliMUON1DMap.h" #include "AliMUON2DMap.h" #include "AliMUON2DStoreValidator.h" +#include "AliMUONCalibParamND.h" #include "AliMUONCalibParamNF.h" #include "AliMUONCalibParamNI.h" #include "AliMUONConstants.h" -#include "AliMUONHVNamer.h" +#include "AliMUONRejectList.h" +#include "AliMUONTrackerIO.h" #include "AliMUONTriggerEfficiencyCells.h" #include "AliMUONTriggerLut.h" #include "AliMUONVStore.h" #include "AliMUONVCalibParam.h" #include "AliMUONVCalibParam.h" +#include "AliMUONGlobalCrateConfig.h" +#include "AliMUONRegionalTriggerConfig.h" +#include "AliMUONRecoParam.h" + +#include "AliMpCDB.h" #include "AliMpConstants.h" +#include "AliMpDEStore.h" #include "AliMpDDLStore.h" -#include "AliMpDEIterator.h" +#include "AliMpManuStore.h" #include "AliMpDEManager.h" #include "AliMpDetElement.h" -#include "AliMpManuList.h" +#include "AliMpFiles.h" +#include "AliMpDCSNamer.h" +#include "AliMpManuIterator.h" #include "AliMpSegmentation.h" #include "AliMpStationType.h" #include "AliMpVSegmentation.h" + +#include "AliCodeTimer.h" +#include "AliCDBEntry.h" +#include "AliCDBManager.h" +#include "AliGRPManager.h" +#include "AliDCSValue.h" +#include "AliLog.h" +#include "AliMpBusPatch.h" + #include #include #include @@ -65,22 +85,32 @@ #include #include #include - -/// \cond CLASSIMP -ClassImp(AliMUONCDB) -/// \endcond +#include +#include +#include +#include namespace { -//_____________________________________________________________________________ -void getBoundaries(const AliMUONVStore& store, - Float_t& x0min, Float_t& x0max, - Float_t& x1min, Float_t& x1max) + //_____________________________________________________________________________ +AliMUONVStore* Create2DMap() +{ + return new AliMUON2DMap(true); +} + + //_____________________________________________________________________________ +void getBoundaries(const AliMUONVStore& store, Int_t dim, + Float_t* xmin, Float_t* xmax) { - x0min=1E30; - x0max=-1E30; - x1min=1E30; - x1max=-1E30; + /// Assuming the store contains AliMUONVCalibParam objects, compute the + /// limits of the value contained in the VCalibParam, for each of its dimensions + /// xmin and xmax must be of dimension dim + + for ( Int_t i = 0; i < dim; ++i ) + { + xmin[i]=1E30; + xmax[i]=-1E30; + } TIter next(store.CreateIterator()); AliMUONVCalibParam* value; @@ -95,53 +125,210 @@ void getBoundaries(const AliMUONVStore& store, for ( Int_t manuChannel = 0; manuChannel < value->Size(); ++manuChannel ) { - AliMpPad pad = seg->PadByLocation(AliMpIntPair(manuId,manuChannel),kFALSE); + AliMpPad pad = seg->PadByLocation(manuId,manuChannel,kFALSE); if (!pad.IsValid()) continue; - Float_t x0 = value->ValueAsFloat(manuChannel,0); - - x0min = TMath::Min(x0min,x0); - x0max = TMath::Max(x0max,x0); - if ( value->Dimension()>1 ) + for ( Int_t i = 0; i < dim; ++i ) { - Float_t x1 = value->ValueAsFloat(manuChannel,1); - x1min = TMath::Min(x1min,x1); - x1max = TMath::Max(x1max,x1); + Float_t x0 = value->ValueAsFloat(manuChannel,i); + + xmin[i] = TMath::Min(xmin[i],x0); + xmax[i] = TMath::Max(xmax[i],x0); } } - } + } + + for ( Int_t i = 0; i < dim; ++i ) + { + if ( TMath::Abs(xmin[i]-xmax[i]) < 1E-3 ) + { + xmin[i] -= 1; + xmax[i] += 1; + } + } +} + +//_____________________________________________________________________________ +Double_t GetRandom(Double_t mean, Double_t sigma, Bool_t mustBePositive) +{ + Double_t x(-1); + if ( mustBePositive ) + { + while ( x < 0 ) + { + x = gRandom->Gaus(mean,sigma); + } + } + else + { + x = gRandom->Gaus(mean,sigma); + } + return x; } } //_____________________________________________________________________________ -AliMUONCDB::AliMUONCDB(const char* cdbpath) -: TObject(), - fCDBPath(cdbpath), - fManuList(0x0) +Bool_t AliMUONCDB::CheckOCDB(Bool_t pathOnly) { - /// ctor + /// Check that OCDB path and run number are properly set + + AliCDBManager* man = AliCDBManager::Instance(); + + // first OCDB path + if (!man->IsDefaultStorageSet()) { + AliErrorGeneral("AliMUONCDB", "OCDB path must be properly set"); + return kFALSE; + } + + // then run number if required + if (pathOnly) return kTRUE; + if (man->GetRun() < 0) { + AliErrorGeneral("AliMUONCDB", "Run number must be properly set"); + return kFALSE; + } + + return kTRUE; + } //_____________________________________________________________________________ -AliMUONCDB::~AliMUONCDB() +Bool_t AliMUONCDB::CheckMapping(Bool_t segmentationOnly) { - /// dtor - delete fManuList; + /// Check that the mapping has been loaded + + // first the segmentation + if (!AliMpSegmentation::Instance(false)) { + AliErrorGeneral("AliMUONCDB", "Mapping segmentation must be loaded first"); + return kFALSE; + } + + // then the others if required + if (segmentationOnly) return kTRUE; + if (!AliMpDDLStore::Instance(false) || !AliMpDEStore::Instance(false) || !AliMpManuStore::Instance(false)) { + AliErrorGeneral("AliMUONCDB", "Full mapping must be loaded first"); + return kFALSE; + } + + return kTRUE; + } //_____________________________________________________________________________ -TList* -AliMUONCDB::ManuList() +Bool_t AliMUONCDB::LoadField() { - /// return (and create if necessary) the list of (de,manu) pairs - if (!fManuList) - { - AliInfo("Generating ManuList..."); - fManuList = AliMpManuList::ManuList(); - AliInfo("Manu List generated."); + /// Load magnetic field (existing field will be deleted). + /// OCDB path and run number are supposed to be set. + + AliInfoGeneral("AliMUONCDB","Loading field map from GRP..."); + + if (!AliMUONCDB::CheckOCDB()) return kFALSE; + + AliGRPManager grpMan; + + // make sure the old field is deleted even if it is locked + if(TGeoGlobalMagField::Instance()->IsLocked()) delete TGeoGlobalMagField::Instance(); + + if (!grpMan.ReadGRPEntry() || !grpMan.SetMagField()) { + AliErrorGeneral("AliMUONCDB", "failed to load magnetic field from OCDB"); + return kFALSE; + } + + return kTRUE; + +} + +//_____________________________________________________________________________ +Bool_t AliMUONCDB::LoadMapping(Bool_t segmentationOnly) +{ + /// Load mapping (existing mapping will be unloaded). + /// OCDB path and run number are supposed to be set. + + AliInfoGeneral("AliMUONCDB", "Loading mapping from OCDB..."); + + if (!AliMUONCDB::CheckOCDB()) return kFALSE; + + // in case it has already been set + AliMpCDB::UnloadAll(); + + if (segmentationOnly) { + + if (!AliMpCDB::LoadMpSegmentation(kTRUE)){ + AliErrorGeneral("AliMUONCDB", "failed to load segmentation from OCDB"); + return kFALSE; + } + + } else { + + if (!AliMpCDB::LoadAll(kTRUE)) { + AliErrorGeneral("AliMUONCDB", "failed to load mapping from OCDB"); + return kFALSE; + } + + } + + return kTRUE; + +} + +//_____________________________________________________________________________ +AliMUONRecoParam* AliMUONCDB::LoadRecoParam() +{ + /// Load and return reconstruction parameters. + /// OCDB path is supposed to be set. + + AliInfoGeneral("AliMUONCDB", "Loading RecoParam from OCDB..."); + + if (!AliMUONCDB::CheckOCDB()) return kFALSE; + + AliMUONRecoParam* recoParam = 0x0; + AliCDBEntry* entry = AliCDBManager::Instance()->Get("MUON/Calib/RecoParam"); + + if(entry) { + + // load recoParam according OCDB content (single or array) + if (!(recoParam = dynamic_cast(entry->GetObject()))) { + + TObjArray* recoParamArray = static_cast(entry->GetObject()); + + for(Int_t i = 0; i < recoParamArray->GetEntriesFast(); i++) { + recoParam = static_cast(recoParamArray->UncheckedAt(i)); + if (recoParam->IsDefault()) break; + recoParam = 0x0; + } + + } + } - return fManuList; + + if (!recoParam) AliErrorGeneral("AliMUONCDB", "failed to load RecoParam from OCDB"); + + return recoParam; + +} + +//_____________________________________________________________________________ +TClonesArray* AliMUONCDB::LoadAlignmentData() +{ + /// Load and return the array of alignment objects. + + AliInfoGeneral("AliMUONCDB", "Loading Alignemnt from OCDB..."); + + if (!AliMUONCDB::CheckOCDB()) return kFALSE; + + TClonesArray* alignmentArray = 0x0; + AliCDBEntry* entry = AliCDBManager::Instance()->Get("MUON/Align/Data"); + + if (entry) { + // load alignement array + alignmentArray = dynamic_cast(entry->GetObject()); + } + + if (!alignmentArray) { + AliErrorGeneral("AliMUONCDB", "failed to load Alignemnt from OCDB"); + } + + return alignmentArray; } //_____________________________________________________________________________ @@ -152,14 +339,16 @@ AliMUONCDB::Diff(AliMUONVStore& store1, AliMUONVStore& store2, /// creates a store which contains store1-store2 /// if opt="abs" the difference is absolute one, /// if opt="rel" then what is stored is (store1-store2)/store1 + /// if opt="percent" then what is stored is rel*100 + /// /// WARNING Works only for stores which holds AliMUONVCalibParam objects TString sopt(opt); sopt.ToUpper(); - if ( !sopt.Contains("ABS") && !sopt.Contains("REL") ) + if ( !sopt.Contains("ABS") && !sopt.Contains("REL") && !sopt.Contains("PERCENT") ) { - AliErrorClass(Form("opt %s not supported. Only ABS or REL are",opt)); + AliErrorGeneral("AliMUONCDB", Form("opt %s not supported. Only ABS, REL, PERCENT are",opt)); return 0x0; } @@ -192,7 +381,7 @@ AliMUONCDB::Diff(AliMUONVStore& store1, AliMUONVStore& store2, { value = param->ValueAsFloat(i,j) - param2->ValueAsFloat(i,j); } - else if ( sopt.Contains("REL") ) + else if ( sopt.Contains("REL") || sopt.Contains("PERCENT") ) { if ( param->ValueAsFloat(i,j) ) { @@ -202,6 +391,7 @@ AliMUONCDB::Diff(AliMUONVStore& store1, AliMUONVStore& store2, { continue; } + if ( sopt.Contains("PERCENT") ) value *= 100.0; } param->SetValueAsFloat(i,j,value); } @@ -214,89 +404,69 @@ AliMUONCDB::Diff(AliMUONVStore& store1, AliMUONVStore& store2, void AliMUONCDB::Plot(const AliMUONVStore& store, const char* name, Int_t nbins) { - /// Make a plot of the first 1 or 2 dimensions of the AliMUONVCalibParam + /// Make histograms of each dimension of the AliMUONVCalibParam /// contained inside store. /// It produces histograms named name_0, name_1, etc... - Float_t x0min, x0max, x1min, x1max; - - getBoundaries(store,x0min,x0max,x1min,x1max); - - if ( x0min > x0max ) - { - cerr << Form("Something is wrong with boundaries : x0(min,max)=%e,%e", - x0min,x0max) << endl; - return; - } - - if ( TMath::Abs(x0min-x0max) < 1E-3 ) - { - x0min -= 1; - x0max += 1; - } - - TH1* h0 = new TH1F(Form("%s_0",name),Form("%s_0",name), - nbins,x0min,x0max); - - TH1* h1(0); + if (!AliMUONCDB::CheckMapping(kTRUE)) return; - if ( x1max > x1min ) - { - h1 = new TH1F(Form("%s_1",name),Form("%s_1",name), - nbins,x1min,x1max); - } - - TIter next(ManuList()); - AliMpIntPair* p; + TIter next(store.CreateIterator()); + AliMUONVCalibParam* param; Int_t n(0); - Int_t nPerStation[7]; + const Int_t kNStations = AliMpConstants::NofTrackingChambers()/2; + Int_t* nPerStation = new Int_t[kNStations]; + TH1** h(0x0); - for ( Int_t i = 0; i < 7; ++i ) nPerStation[i]=0; + for ( Int_t i = 0; i < kNStations; ++i ) nPerStation[i]=0; - while ( ( p = (AliMpIntPair*)next() ) ) + while ( ( param = static_cast(next()) ) ) { - Int_t detElemId = p->GetFirst(); - Int_t manuId = p->GetSecond(); - Int_t station = AliMpDEManager::GetChamberId(detElemId); + if (!h) + { + Int_t dim = param->Dimension(); + h = new TH1*[dim]; + Float_t* xmin = new Float_t[dim]; + Float_t* xmax = new Float_t[dim]; + getBoundaries(store,dim,xmin,xmax); + + for ( Int_t i = 0; i < dim; ++i ) + { + h[i] = new TH1F(Form("%s_%d",name,i),Form("%s_%d",name,i), + nbins,xmin[i],xmax[i]); + AliInfoGeneral("AliMUONCDB", Form("Created histogram %s",h[i]->GetName())); + } + } + + Int_t detElemId = param->ID0(); + Int_t manuId = param->ID1(); + Int_t station = AliMpDEManager::GetChamberId(detElemId)/2; const AliMpVSegmentation* seg = AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId,manuId); - AliMUONVCalibParam* value = - dynamic_cast(store.FindObject(detElemId,manuId)); - - if (value) + for ( Int_t manuChannel = 0; manuChannel < param->Size(); ++manuChannel ) { - for ( Int_t manuChannel = 0; manuChannel < value->Size(); ++manuChannel ) - { - AliMpPad pad = seg->PadByLocation(AliMpIntPair(manuId,manuChannel),kFALSE); - if (!pad.IsValid()) continue; + AliMpPad pad = seg->PadByLocation(manuId,manuChannel,kFALSE); + if (!pad.IsValid()) continue; - ++n; - ++nPerStation[station]; - Float_t x = value->ValueAsFloat(manuChannel,0); - if ( x>1E4 ) - { - AliInfo(Form("DE %d Manu %d Ch %d x=%e",detElemId,manuId,manuChannel,x)); - } - h0->Fill(x); - if (h1) - { - h1->Fill(value->ValueAsFloat(manuChannel,1)); - } + ++n; + ++nPerStation[station]; + + for ( Int_t dim = 0; dim < param->Dimension(); ++dim ) + { + h[dim]->Fill(param->ValueAsFloat(manuChannel,dim)); } } - else - { - AliWarning(Form("Got a null value for DE=%d manuId=%d",detElemId,manuId)); - } - } + } - AliInfo(Form("Number of channels = %d",n)); - for ( Int_t i = 0; i < 7; ++i ) + for ( Int_t i = 0; i < kNStations; ++i ) { - AliInfo(Form("Station %d %d ",(i+1),nPerStation[i])); + AliInfoGeneral("AliMUONCDB", Form("Station %d %d ",(i+1),nPerStation[i])); } + + AliInfoGeneral("AliMUONCDB", Form("Number of channels = %d",n)); + + delete[] nPerStation; } //_____________________________________________________________________________ @@ -305,7 +475,9 @@ AliMUONCDB::MakeHVStore(TMap& aliasMap, Bool_t defaultValues) { /// Create a HV store - AliMUONHVNamer hvNamer; + if (!AliMUONCDB::CheckMapping()) return 0; + + AliMpDCSNamer hvNamer("TRACKER"); TObjArray* aliases = hvNamer.GenerateAliases(); @@ -345,7 +517,7 @@ AliMUONCDB::MakeHVStore(TMap& aliasMap, Bool_t defaultValues) for ( UInt_t timeStamp = 0; timeStamp < 60*15; timeStamp += 120 ) { Float_t value = 1500; - if (!defaultValues) value = gRandom->Gaus(1750,62.5); + if (!defaultValues) value = GetRandom(1750,62.5,true); AliDCSValue* dcsValue = new AliDCSValue(value,timeStamp); valueSet->Add(dcsValue); } @@ -356,11 +528,61 @@ AliMUONCDB::MakeHVStore(TMap& aliasMap, Bool_t defaultValues) delete aliases; - AliInfo(Form("%d HV channels and %d switches",nChannels,nSwitch)); + AliInfoGeneral("AliMUONCDB", Form("%d HV channels and %d switches",nChannels,nSwitch)); return nChannels+nSwitch; } +//_____________________________________________________________________________ +Int_t +AliMUONCDB::MakeTriggerDCSStore(TMap& aliasMap, Bool_t defaultValues) +{ + /// Create a Trigger HV and Currents store + + if (!AliMUONCDB::CheckMapping()) return 0; + + AliMpDCSNamer triggerDCSNamer("TRIGGER"); + + TObjArray* aliases = triggerDCSNamer.GenerateAliases(); + + Int_t nChannels[2] = {0, 0}; + + for ( Int_t i = 0; i < aliases->GetEntries(); ++i ) + { + TObjString* alias = static_cast(aliases->At(i)); + TString& aliasName = alias->String(); + + TObjArray* valueSet = new TObjArray; + valueSet->SetOwner(kTRUE); + Int_t measureType = triggerDCSNamer.DCSvariableFromDCSAlias(aliasName.Data()); + for ( UInt_t timeStamp = 0; timeStamp < 60*15; timeStamp += 120 ) + { + Float_t value = + (measureType == AliMpDCSNamer::kDCSI) ? 2. : 8000.; + if (!defaultValues) { + switch (measureType){ + case AliMpDCSNamer::kDCSI: + value = GetRandom(2.,0.4,true); + break; + case AliMpDCSNamer::kDCSHV: + value = GetRandom(8000.,16.,true); + break; + } + } + AliDCSValue* dcsValue = new AliDCSValue(value,timeStamp); + valueSet->Add(dcsValue); + } + aliasMap.Add(new TObjString(*alias),valueSet); + ++nChannels[measureType]; + } + + delete aliases; + + AliInfoGeneral("AliMUONCDB", Form("Trigger channels I -> %i HV -> %i",nChannels[0], nChannels[1])); + + return nChannels[0] + nChannels[1]; +} + //_____________________________________________________________________________ Int_t AliMUONCDB::MakePedestalStore(AliMUONVStore& pedestalStore, Bool_t defaultValues) @@ -368,36 +590,50 @@ AliMUONCDB::MakePedestalStore(AliMUONVStore& pedestalStore, Bool_t defaultValues /// Create a pedestal store. if defaultValues=true, ped.mean=ped.sigma=1, /// otherwise mean and sigma are from a gaussian (with parameters /// defined below by the kPedestal* constants) + + AliCodeTimerAutoGeneral("",0); - TIter next(ManuList()); - - AliMpIntPair* p; + if (!AliMUONCDB::CheckMapping()) return 0; Int_t nchannels(0); Int_t nmanus(0); const Int_t kChannels(AliMpConstants::ManuNofChannels()); - const Float_t kPedestalMeanMean(200); - const Float_t kPedestalMeanSigma(10); - const Float_t kPedestalSigmaMean(1.0); - const Float_t kPedestalSigmaSigma(0.2); - while ( ( p = (AliMpIntPair*)next() ) ) - { - ++nmanus; + // bending + const Float_t kPedestalMeanMeanB(200.); + const Float_t kPedestalMeanSigmaB(10.); + const Float_t kPedestalSigmaMeanB(1.); + const Float_t kPedestalSigmaSigmaB(0.2); + + // non bending + const Float_t kPedestalMeanMeanNB(200.); + const Float_t kPedestalMeanSigmaNB(10.); + const Float_t kPedestalSigmaMeanNB(1.); + const Float_t kPedestalSigmaSigmaNB(0.2); + + const Float_t kFractionOfDeadManu(0.); // within [0.,1.] - Int_t detElemId = p->GetFirst(); - Int_t manuId = p->GetSecond(); + Int_t detElemId; + Int_t manuId; - AliMUONVCalibParam* ped = new AliMUONCalibParamNF(2,kChannels,detElemId,manuId,AliMUONVCalibParam::InvalidFloatValue()); + AliMpManuIterator it; + + while ( it.Next(detElemId,manuId) ) + { + // skip a given fraction of manus + if (kFractionOfDeadManu > 0. && gRandom->Uniform() < kFractionOfDeadManu) continue; - const AliMpVSegmentation* seg = - AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId,manuId); + ++nmanus; + + AliMUONVCalibParam* ped = + new AliMUONCalibParamNF(2,kChannels,detElemId,manuId,AliMUONVCalibParam::InvalidFloatValue()); + + AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId); for ( Int_t manuChannel = 0; manuChannel < kChannels; ++manuChannel ) { - AliMpPad pad = seg->PadByLocation(AliMpIntPair(manuId,manuChannel),kFALSE); - if (!pad.IsValid()) continue; + if ( ! de->IsConnectedChannel(manuId,manuChannel) ) continue; ++nchannels; @@ -411,17 +647,29 @@ AliMUONCDB::MakePedestalStore(AliMUONVStore& pedestalStore, Bool_t defaultValues } else { - meanPedestal = -1; - while ( meanPedestal < 0 ) - { - meanPedestal = gRandom->Gaus(kPedestalMeanMean,kPedestalMeanSigma); - } - sigmaPedestal = -1; - while ( sigmaPedestal < 0 ) - { - sigmaPedestal = gRandom->Gaus(kPedestalSigmaMean,kPedestalSigmaSigma); - } + Bool_t positive(kTRUE); + meanPedestal = 0.0; + + if ( manuId & AliMpConstants::ManuMask(AliMp::kNonBendingPlane) ) { // manu in non bending plane + + while ( meanPedestal == 0.0 ) // avoid strict zero + { + meanPedestal = GetRandom(kPedestalMeanMeanNB,kPedestalMeanSigmaNB,positive); + } + sigmaPedestal = GetRandom(kPedestalSigmaMeanNB,kPedestalSigmaSigmaNB,positive); + + } else { // manu in bending plane + + while ( meanPedestal == 0.0 ) // avoid strict zero + { + meanPedestal = GetRandom(kPedestalMeanMeanB,kPedestalMeanSigmaB,positive); + } + sigmaPedestal = GetRandom(kPedestalSigmaMeanB,kPedestalSigmaSigmaB,positive); + + } + } + ped->SetValueAsFloat(manuChannel,0,meanPedestal); ped->SetValueAsFloat(manuChannel,1,sigmaPedestal); @@ -429,13 +677,94 @@ AliMUONCDB::MakePedestalStore(AliMUONVStore& pedestalStore, Bool_t defaultValues Bool_t ok = pedestalStore.Add(ped); if (!ok) { - AliError(Form("Could not set DetElemId=%d manuId=%d",detElemId,manuId)); + AliErrorGeneral("AliMUONCDB", Form("Could not set DetElemId=%d manuId=%d",detElemId,manuId)); } } - AliInfo(Form("%d Manus and %d channels.",nmanus,nchannels)); + AliInfoGeneral("AliMUONCDB", Form("%d Manus and %d channels.",nmanus,nchannels)); return nchannels; +} + +//_____________________________________________________________________________ +AliMUONRejectList* +AliMUONCDB::MakeRejectListStore(Bool_t defaultValues) +{ + /// Create a reject list + + AliCodeTimerAutoGeneral("",0); + + AliMUONRejectList* rl = new AliMUONRejectList; + if (!defaultValues) + { + rl->SetDetectionElementProbability(510); + rl->SetDetectionElementProbability(508); + return rl; + } + + return rl; +} + +//_____________________________________________________________________________ +Int_t +AliMUONCDB::MakeOccupancyMapStore(AliMUONVStore& occupancyMapStore, Bool_t defaultValues) +{ + /// Create an occupancy map. + + AliCodeTimerAutoGeneral("",0); + + if (!AliMUONCDB::CheckMapping()) return 0; + + Int_t nmanus(0); + + Int_t detElemId; + Int_t manuId; + + AliMpManuIterator it; + + Int_t nevents(1000); + + while ( it.Next(detElemId,manuId) ) + { + ++nmanus; + + AliMUONVCalibParam* occupancy = new AliMUONCalibParamND(5,1,detElemId,manuId,0); + + Double_t occ = 0.0; + + AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId); + + Int_t numberOfChannelsInManu = de->NofChannelsInManu(manuId); + + if (!defaultValues) occ = gRandom->Rndm(1); + + Double_t sumn = occ*nevents; + + occupancy->SetValueAsFloat(0,0,sumn); + occupancy->SetValueAsFloat(0,1,sumn); + occupancy->SetValueAsFloat(0,2,sumn); + occupancy->SetValueAsInt(0,3,numberOfChannelsInManu); + occupancy->SetValueAsInt(0,4,nevents); + + Bool_t ok = occupancyMapStore.Add(occupancy); + if (!ok) + { + AliErrorGeneral("AliMUONCDB", Form("Could not set DetElemId=%d manuId=%d",detElemId,manuId)); + } + } + + return nmanus; +} + +//_____________________________________________________________________________ +Int_t +AliMUONCDB::MakeCapacitanceStore(AliMUONVStore& capaStore, const char* file) +{ + /// Read the capacitance values from file and append them to the capaStore + + if (!AliMUONCDB::CheckMapping()) return 0; + + return AliMUONTrackerIO::ReadCapacitances(file,capaStore); } //_____________________________________________________________________________ @@ -445,80 +774,80 @@ AliMUONCDB::MakeCapacitanceStore(AliMUONVStore& capaStore, Bool_t defaultValues) /// Create a capacitance store. if defaultValues=true, all capa are 1.0, /// otherwise they are from a gaussian with parameters defined in the /// kCapa* constants below. + + AliCodeTimerAutoGeneral("",0); - TIter next(ManuList()); - - AliMpIntPair* p; + if (!AliMUONCDB::CheckMapping()) return 0; Int_t nchannels(0); Int_t nmanus(0); Int_t nmanusOK(0); // manus for which we got the serial number - const Float_t kCapaMean(1.0); - const Float_t kCapaSigma(0.5); + const Float_t kCapaMean(0.3); + const Float_t kCapaSigma(0.1); + const Float_t kInjectionGainMean(3); + const Float_t kInjectionGainSigma(1); + + Int_t detElemId; + Int_t manuId; + + AliMpManuIterator it; - while ( ( p = (AliMpIntPair*)next() ) ) + while ( it.Next(detElemId,manuId) ) { ++nmanus; - Int_t detElemId = p->GetFirst(); - Int_t manuId = p->GetSecond(); - AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId); - Int_t serialNumber = de->GetManuSerialFromId(manuId); + Int_t serialNumber = AliMpManuStore::Instance()->GetManuSerial(detElemId, manuId); if ( serialNumber <= 0 ) continue; ++nmanusOK; - const AliMpVSegmentation* seg = - AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId,manuId); - AliMUONVCalibParam* capa = static_cast(capaStore.FindObject(serialNumber)); if (!capa) { - capa = new AliMUONCalibParamNF(1,AliMpConstants::ManuNofChannels(),serialNumber,0,1.0); + capa = new AliMUONCalibParamNF(2,AliMpConstants::ManuNofChannels(),serialNumber,0,1.0); Bool_t ok = capaStore.Add(capa); if (!ok) { - AliError(Form("Could not set serialNumber=%d manuId=%d",serialNumber,manuId)); + AliErrorGeneral("AliMUONCDB", Form("Could not set serialNumber=%d manuId=%d",serialNumber,manuId)); } } for ( Int_t manuChannel = 0; manuChannel < capa->Size(); ++manuChannel ) { - AliMpPad pad = seg->PadByLocation(AliMpIntPair(manuId,manuChannel),kFALSE); - if (!pad.IsValid()) continue; + if ( ! de->IsConnectedChannel(manuId,manuChannel) ) continue; ++nchannels; Float_t capaValue; + Float_t injectionGain; if ( defaultValues ) { capaValue = 1.0; + injectionGain = 1.0; } else { - capaValue = -1; - while ( capaValue < 0 ) - { - capaValue = gRandom->Gaus(kCapaMean,kCapaSigma); - } + capaValue = GetRandom(kCapaMean,kCapaSigma,kTRUE); + injectionGain = GetRandom(kInjectionGainMean,kInjectionGainSigma,kTRUE); } capa->SetValueAsFloat(manuChannel,0,capaValue); + capa->SetValueAsFloat(manuChannel,1,injectionGain); } } Float_t percent = 0; if ( nmanus ) percent = 100*nmanusOK/nmanus; - AliInfo(Form("%5d manus with serial number (out of %5d manus = %3.0f%%)", + AliInfoGeneral("AliMUONCDB", Form("%5d manus with serial number (out of %5d manus = %3.0f%%)", nmanusOK,nmanus,percent)); - AliInfo(Form("%5d channels",nchannels)); + AliInfoGeneral("AliMUONCDB", Form("%5d channels",nchannels)); if ( percent < 100 ) { - AliWarning("Did not get all serial numbers. capaStore is incomplete !!!!"); + AliWarningGeneral("AliMUONCDB", "Did not get all serial numbers. capaStore is incomplete !!!!"); } return nchannels; @@ -528,85 +857,94 @@ AliMUONCDB::MakeCapacitanceStore(AliMUONVStore& capaStore, Bool_t defaultValues) Int_t AliMUONCDB::MakeGainStore(AliMUONVStore& gainStore, Bool_t defaultValues) { - /// Create a gain store. if defaultValues=true, all gain are 1.0, - /// otherwise they are from a gaussian with parameters defined in the - /// kGain* constants below. + /// Create a gain store. if defaultValues=true, all gains set so that + /// charge = (adc-ped) + /// + /// otherwise parameters are taken from gaussians with parameters + /// defined in the k* constants below. - TIter next(ManuList()); + AliCodeTimerAutoGeneral("",0); - AliMpIntPair* p; + if (!AliMUONCDB::CheckMapping()) return 0; Int_t nchannels(0); Int_t nmanus(0); - const Double_t kSaturation(3000); - const Double_t kGainMean(1.0); - const Double_t kGainSigma(0.05); - - while ( ( p = (AliMpIntPair*)next() ) ) + const Int_t kSaturation(3000); + const Double_t kA0Mean(1.2); + const Double_t kA0Sigma(0.1); + const Double_t kA1Mean(1E-5); + const Double_t kA1Sigma(1E-6); + const Double_t kQualMean(0xFF); + const Double_t kQualSigma(0x10); + const Int_t kThresMean(1600); + const Int_t kThresSigma(100); + + Int_t detElemId; + Int_t manuId; + + AliMpManuIterator it; + + while ( it.Next(detElemId,manuId) ) { ++nmanus; - Int_t detElemId = p->GetFirst(); - Int_t manuId = p->GetSecond(); - AliMUONVCalibParam* gain = - new AliMUONCalibParamNF(2,AliMpConstants::ManuNofChannels(), + new AliMUONCalibParamNF(5,AliMpConstants::ManuNofChannels(), detElemId, manuId, AliMUONVCalibParam::InvalidFloatValue()); - - const AliMpVSegmentation* seg = - AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId,manuId); + AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId); for ( Int_t manuChannel = 0; manuChannel < gain->Size(); ++manuChannel ) { - AliMpPad pad = seg->PadByLocation(AliMpIntPair(manuId,manuChannel),kFALSE); - if (!pad.IsValid()) continue; + if ( ! de->IsConnectedChannel(manuId,manuChannel) ) continue; ++nchannels; - Float_t meanGain; - Float_t saturation(kSaturation); - if ( defaultValues ) { - meanGain = 1.0; + gain->SetValueAsFloat(manuChannel,0,1.0); + gain->SetValueAsFloat(manuChannel,1,0.0); + gain->SetValueAsInt(manuChannel,2,4095); + gain->SetValueAsInt(manuChannel,3,1); + gain->SetValueAsInt(manuChannel,4,kSaturation); } else { - meanGain = -1; - while ( meanGain < 0 ) - { - meanGain = gRandom->Gaus(kGainMean,kGainSigma); - } + Bool_t positive(kTRUE); + gain->SetValueAsFloat(manuChannel,0,GetRandom(kA0Mean,kA0Sigma,positive)); + gain->SetValueAsFloat(manuChannel,1,GetRandom(kA1Mean,kA1Sigma,!positive)); + gain->SetValueAsInt(manuChannel,2,(Int_t)TMath::Nint(GetRandom(kThresMean,kThresSigma,positive))); + gain->SetValueAsInt(manuChannel,3,(Int_t)TMath::Nint(GetRandom(kQualMean,kQualSigma,positive))); + gain->SetValueAsInt(manuChannel,4,kSaturation); } - gain->SetValueAsFloat(manuChannel,0,meanGain); - gain->SetValueAsFloat(manuChannel,1,saturation); } Bool_t ok = gainStore.Add(gain); if (!ok) { - AliError(Form("Could not set DetElemId=%d manuId=%d",detElemId,manuId)); + AliErrorGeneral("AliMUONCDB", Form("Could not set DetElemId=%d manuId=%d",detElemId,manuId)); } } - AliInfo(Form("%d Manus and %d channels.",nmanus,nchannels)); + AliInfoGeneral("AliMUONCDB", Form("%d Manus and %d channels.",nmanus,nchannels)); return nchannels; } //_____________________________________________________________________________ Int_t -AliMUONCDB::MakeLocalTriggerMaskStore(AliMUONVStore& localBoardMasks) const +AliMUONCDB::MakeLocalTriggerMaskStore(AliMUONVStore& localBoardMasks) { /// Generate local trigger masks store. All masks are set to FFFF + AliCodeTimerAutoGeneral("",0); + Int_t ngenerated(0); - // Generate fake mask values for 234 localboards and put that into + // Generate fake mask values for all localboards and put that into // one single container (localBoardMasks) - for ( Int_t i = 1; i <= 234; ++i ) + for ( Int_t i = 1; i <= AliMpConstants::TotalNofLocalBoards(); ++i ) { AliMUONVCalibParam* localBoard = new AliMUONCalibParamNI(1,8,i,0,0); for ( Int_t x = 0; x < 2; ++x ) @@ -625,47 +963,41 @@ AliMUONCDB::MakeLocalTriggerMaskStore(AliMUONVStore& localBoardMasks) const //_____________________________________________________________________________ Int_t -AliMUONCDB::MakeRegionalTriggerMaskStore(AliMUONVStore& rtm) const +AliMUONCDB::MakeRegionalTriggerConfigStore(AliMUONRegionalTriggerConfig& rtm) { - /// Make a regional trigger masks store. All masks are set to 3F + /// Make a regional trigger config store. Mask is set to FFFF for each local board (Ch.F.) - Int_t ngenerated(0); - for ( Int_t i = 0; i < 16; ++i ) - { - AliMUONVCalibParam* regionalBoard = new AliMUONCalibParamNI(1,16,i,0,0); - for ( Int_t j = 0; j < 16; ++j ) - { - regionalBoard->SetValueAsInt(j,0,0x3F); - ++ngenerated; - } - rtm.Add(regionalBoard); - } + AliCodeTimerAutoGeneral("",0); - return ngenerated; + if ( ! rtm.ReadData(AliMpFiles::LocalTriggerBoardMapping()) ) { + AliErrorGeneral("AliMUONCDB", "Error when reading from mapping file"); + return 0; + } + + return rtm.GetNofTriggerCrates(); } + //_____________________________________________________________________________ Int_t -AliMUONCDB::MakeGlobalTriggerMaskStore(AliMUONVCalibParam& gtm) const +AliMUONCDB::MakeGlobalTriggerConfigStore(AliMUONGlobalCrateConfig& gtm) { - /// Make a global trigger masks store. All masks set to FFF + /// Make a global trigger config store. All masks (disable) set to 0x00 for each Darc board (Ch.F.) - Int_t ngenerated(0); + AliCodeTimerAutoGeneral("",0); - for ( Int_t j = 0; j < 16; ++j ) - { - gtm.SetValueAsInt(j,0,0xFFF); - ++ngenerated; - } - return ngenerated; + return gtm.ReadData(AliMpFiles::GlobalTriggerBoardMapping()); } + //_____________________________________________________________________________ AliMUONTriggerLut* -AliMUONCDB::MakeTriggerLUT(const char* file) const +AliMUONCDB::MakeTriggerLUT(const char* file) { /// Make a triggerlut object, from a file. + AliCodeTimerAutoGeneral("",0); + AliMUONTriggerLut* lut = new AliMUONTriggerLut; lut->ReadFromFile(file); return lut; @@ -673,13 +1005,28 @@ AliMUONCDB::MakeTriggerLUT(const char* file) const //_____________________________________________________________________________ AliMUONTriggerEfficiencyCells* -AliMUONCDB::MakeTriggerEfficiency(const char* file) const +AliMUONCDB::MakeTriggerEfficiency(const char* file) { /// Make a trigger efficiency object from a file. + AliCodeTimerAutoGeneral("",0); + return new AliMUONTriggerEfficiencyCells(file); } +//_____________________________________________________________________________ +void +AliMUONCDB::WriteToCDB(const char* calibpath, TObject* object, + Int_t startRun, Int_t endRun, + const char* filename) +{ + /// Write a given object to OCDB + + TString comment(gSystem->ExpandPathName(filename)); + + WriteToCDB(object, calibpath, startRun, endRun, comment.Data()); +} + //_____________________________________________________________________________ void AliMUONCDB::WriteToCDB(const char* calibpath, TObject* object, @@ -687,22 +1034,28 @@ AliMUONCDB::WriteToCDB(const char* calibpath, TObject* object, { /// Write a given object to OCDB + TString comment; + if ( defaultValues ) comment += "Test with default values"; + else comment += "Test with random values"; + + WriteToCDB(object, calibpath, startRun, endRun, comment.Data()); +} + +//_____________________________________________________________________________ +void +AliMUONCDB::WriteToCDB(TObject* object, const char* calibpath, Int_t startRun, Int_t endRun, + const char* comment, const char* responsible) +{ + /// Write a given object to OCDB + + if (!AliMUONCDB::CheckOCDB(kTRUE)) return; + AliCDBId id(calibpath,startRun,endRun); AliCDBMetaData md; md.SetAliRootVersion(gROOT->GetVersion()); - if ( defaultValues ) - { - md.SetComment("Test with default values"); - } - else - { - md.SetComment("Test with random values"); - } - md.SetResponsible("AliMUONCDB tester class"); - - AliCDBManager* man = AliCDBManager::Instance(); - man->SetDefaultStorage(fCDBPath); - man->Put(object,id,&md); + md.SetComment(comment); + md.SetResponsible(responsible); + AliCDBManager::Instance()->Put(object,id,&md); } //_____________________________________________________________________________ @@ -712,25 +1065,23 @@ AliMUONCDB::MakeNeighbourStore(AliMUONVStore& neighbourStore) /// Fill the neighbours store with, for each channel, a TObjArray of its /// neighbouring pads (including itself) - AliInfo("Generating NeighbourStore. This will take a while. Please be patient."); + AliCodeTimerAutoGeneral("",0); - TStopwatch timer; + if (!AliMUONCDB::CheckMapping()) return 0; - timer.Start(kTRUE); - - TIter next(ManuList()); - - AliMpIntPair* p; + AliInfoGeneral("AliMUONCDB", "Generating NeighbourStore. This will take a while. Please be patient."); Int_t nchannels(0); TObjArray tmp; + + Int_t detElemId; + Int_t manuId; - while ( ( p = (AliMpIntPair*)next() ) ) + AliMpManuIterator it; + + while ( it.Next(detElemId,manuId) ) { - Int_t detElemId = p->GetFirst(); - Int_t manuId = p->GetSecond(); - const AliMpVSegmentation* seg = AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId,manuId); @@ -746,14 +1097,14 @@ AliMUONCDB::MakeNeighbourStore(AliMUONVStore& neighbourStore) Bool_t ok = neighbourStore.Add(calibParam); if (!ok) { - AliError(Form("Could not set DetElemId=%d manuId=%d",detElemId,manuId)); + AliErrorGeneral("AliMUONCDB", Form("Could not set DetElemId=%d manuId=%d",detElemId,manuId)); return -1; } } for ( Int_t manuChannel = 0; manuChannel < AliMpConstants::ManuNofChannels(); ++manuChannel ) { - AliMpPad pad = seg->PadByLocation(AliMpIntPair(manuId,manuChannel),kFALSE); + AliMpPad pad = seg->PadByLocation(manuId,manuChannel,kFALSE); if (pad.IsValid()) { @@ -764,23 +1115,22 @@ AliMUONCDB::MakeNeighbourStore(AliMUONVStore& neighbourStore) for ( Int_t i = 0; i < nofPadNeighbours; ++i ) { - AliMpPad* pad = static_cast(tmp.At(i)); + AliMpPad* p = static_cast(tmp.UncheckedAt(i)); Int_t x; - Bool_t ok = calibParam->PackValues(pad->GetLocation().GetFirst(),pad->GetLocation().GetSecond(),x); - if (!ok) - { - AliError("Could not pack value. Something is seriously wrong. Please check"); - StdoutToAliError(pad->Print();); - return -1; - } +// Bool_t ok = + calibParam->PackValues(p->GetManuId(),p->GetManuChannel(),x); +// if (!ok) +// { +// AliError("Could not pack value. Something is seriously wrong. Please check"); +// StdoutToAliError(pad->Print();); +// return -1; +// } calibParam->SetValueAsInt(manuChannel,i,x); } } } } - timer.Print(); - return nchannels; } @@ -790,9 +1140,9 @@ AliMUONCDB::WriteLocalTriggerMasks(Int_t startRun, Int_t endRun) { /// Write local trigger masks to OCDB - AliMUONVStore* ltm = new AliMUON1DArray(235); + AliMUONVStore* ltm = new AliMUON1DArray(AliMpConstants::TotalNofLocalBoards()+1); Int_t ngenerated = MakeLocalTriggerMaskStore(*ltm); - AliInfo(Form("Ngenerated = %d",ngenerated)); + AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated)); if (ngenerated>0) { WriteToCDB("MUON/Calib/LocalTriggerBoardMasks",ltm,startRun,endRun,true); @@ -802,37 +1152,39 @@ AliMUONCDB::WriteLocalTriggerMasks(Int_t startRun, Int_t endRun) //_____________________________________________________________________________ void -AliMUONCDB::WriteRegionalTriggerMasks(Int_t startRun, Int_t endRun) +AliMUONCDB::WriteRegionalTriggerConfig(Int_t startRun, Int_t endRun) { /// Write regional trigger masks to OCDB - AliMUONVStore* rtm = new AliMUON1DArray(16); - Int_t ngenerated = MakeRegionalTriggerMaskStore(*rtm); - AliInfo(Form("Ngenerated = %d",ngenerated)); + AliMUONRegionalTriggerConfig* rtm = new AliMUONRegionalTriggerConfig(); + Int_t ngenerated = MakeRegionalTriggerConfigStore(*rtm); + AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated)); if (ngenerated>0) { - WriteToCDB("MUON/Calib/RegionalTriggerBoardMasks",rtm,startRun,endRun,true); + WriteToCDB("MUON/Calib/RegionalTriggerConfig",rtm,startRun,endRun,true); } delete rtm; } + //_____________________________________________________________________________ void -AliMUONCDB::WriteGlobalTriggerMasks(Int_t startRun, Int_t endRun) +AliMUONCDB::WriteGlobalTriggerConfig(Int_t startRun, Int_t endRun) { /// Write global trigger masks to OCDB - AliMUONVCalibParam* gtm = new AliMUONCalibParamNI(1,16,1,0,0); + AliMUONGlobalCrateConfig* gtm = new AliMUONGlobalCrateConfig(); - Int_t ngenerated = MakeGlobalTriggerMaskStore(*gtm); - AliInfo(Form("Ngenerated = %d",ngenerated)); + Int_t ngenerated = MakeGlobalTriggerConfigStore(*gtm); + AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated)); if (ngenerated>0) { - WriteToCDB("MUON/Calib/GlobalTriggerBoardMasks",gtm,startRun,endRun,true); + WriteToCDB("MUON/Calib/GlobalTriggerCrateConfig",gtm,startRun,endRun,true); } delete gtm; } + //_____________________________________________________________________________ void AliMUONCDB::WriteTriggerLut(Int_t startRun, Int_t endRun) @@ -867,9 +1219,9 @@ AliMUONCDB::WriteNeighbours(Int_t startRun, Int_t endRun) { /// Write neighbours to OCDB - AliMUONVStore* neighbours = new AliMUON2DMap(kTRUE); + AliMUONVStore* neighbours = Create2DMap(); Int_t ngenerated = MakeNeighbourStore(*neighbours); - AliInfo(Form("Ngenerated = %d",ngenerated)); + AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated)); if (ngenerated>0) { WriteToCDB("MUON/Calib/Neighbours",neighbours,startRun,endRun,true); @@ -889,7 +1241,7 @@ AliMUONCDB::WriteHV(Bool_t defaultValues, TMap* hvStore = new TMap; Int_t ngenerated = MakeHVStore(*hvStore,defaultValues); - AliInfo(Form("Ngenerated = %d",ngenerated)); + AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated)); if (ngenerated>0) { WriteToCDB("MUON/Calib/HV",hvStore,startRun,endRun,defaultValues); @@ -897,6 +1249,26 @@ AliMUONCDB::WriteHV(Bool_t defaultValues, delete hvStore; } +//_____________________________________________________________________________ +void +AliMUONCDB::WriteTriggerDCS(Bool_t defaultValues, + Int_t startRun, Int_t endRun) +{ + /// generate Trigger HV and current values (either const if defaultValues=true or random + /// if defaultValues=false, see makeTriggerDCSStore) and + /// store them into CDB located at cdbpath, with a validity period + /// ranging from startRun to endRun + + TMap* triggerDCSStore = new TMap; + Int_t ngenerated = MakeTriggerDCSStore(*triggerDCSStore,defaultValues); + AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated)); + if (ngenerated>0) + { + WriteToCDB("MUON/Calib/TriggerDCS",triggerDCSStore,startRun,endRun,defaultValues); + } + delete triggerDCSStore; +} + //_____________________________________________________________________________ void AliMUONCDB::WritePedestals(Bool_t defaultValues, @@ -907,13 +1279,45 @@ AliMUONCDB::WritePedestals(Bool_t defaultValues, /// store them into CDB located at cdbpath, with a validity period /// ranging from startRun to endRun - AliMUONVStore* pedestalStore = new AliMUON2DMap(true); + AliMUONVStore* pedestalStore = Create2DMap(); Int_t ngenerated = MakePedestalStore(*pedestalStore,defaultValues); - AliInfo(Form("Ngenerated = %d",ngenerated)); + AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated)); WriteToCDB("MUON/Calib/Pedestals",pedestalStore,startRun,endRun,defaultValues); delete pedestalStore; } +//_____________________________________________________________________________ +void +AliMUONCDB::WriteOccupancyMap(Bool_t defaultValues, + Int_t startRun, Int_t endRun) +{ + /// generate occupancy map values (either empty one if defaultValues=true, or + /// random one, see MakeOccupancyMapStore) and + /// store them into CDB located at cdbpath, with a validity period + /// ranging from startRun to endRun + + AliMUONVStore* occupancyMapStore = Create2DMap(); + Int_t ngenerated = MakeOccupancyMapStore(*occupancyMapStore,defaultValues); + AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated)); + WriteToCDB("MUON/Calib/OccupancyMap",occupancyMapStore,startRun,endRun,defaultValues); + delete occupancyMapStore; +} + +//_____________________________________________________________________________ +void +AliMUONCDB::WriteRejectList(Bool_t defaultValues, + Int_t startRun, Int_t endRun) +{ + /// generate reject list values (either empty one if defaultValues=true, or + /// random one, see MakeRejectListStore) and + /// store them into CDB located at cdbpath, with a validity period + /// ranging from startRun to endRun + + AliMUONRejectList* rl = MakeRejectListStore(defaultValues); + WriteToCDB("MUON/Calib/RejectList",rl,startRun,endRun,defaultValues); + delete rl; +} + //_____________________________________________________________________________ void @@ -925,13 +1329,32 @@ AliMUONCDB::WriteGains(Bool_t defaultValues, /// store them into CDB located at cdbpath, with a validity period /// ranging from startRun to endRun - AliMUONVStore* gainStore = new AliMUON2DMap(true); + AliMUONVStore* gainStore = Create2DMap(); Int_t ngenerated = MakeGainStore(*gainStore,defaultValues); - AliInfo(Form("Ngenerated = %d",ngenerated)); + AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated)); WriteToCDB("MUON/Calib/Gains",gainStore,startRun,endRun,defaultValues); delete gainStore; } +//_____________________________________________________________________________ +void +AliMUONCDB::WriteCapacitances(const char* filename, + Int_t startRun, Int_t endRun) +{ + /// read manu capacitance and injection gain values from file + /// and store them into CDB located at cdbpath, with a validity period + /// ranging from startRun to endRun + + AliMUONVStore* capaStore = new AliMUON1DMap(16828); + Int_t ngenerated = MakeCapacitanceStore(*capaStore,filename); + AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated)); + if ( ngenerated > 0 ) + { + WriteToCDB("MUON/Calib/Capacitances",capaStore,startRun,endRun,filename); + } + delete capaStore; +} + //_____________________________________________________________________________ void AliMUONCDB::WriteCapacitances(Bool_t defaultValues, @@ -944,23 +1367,47 @@ AliMUONCDB::WriteCapacitances(Bool_t defaultValues, AliMUONVStore* capaStore = new AliMUON1DMap(16828); Int_t ngenerated = MakeCapacitanceStore(*capaStore,defaultValues); - AliInfo(Form("Ngenerated = %d",ngenerated)); + AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated)); WriteToCDB("MUON/Calib/Capacitances",capaStore,startRun,endRun,defaultValues); delete capaStore; } //_____________________________________________________________________________ void -AliMUONCDB::WriteTrigger(Int_t startRun, Int_t endRun) +AliMUONCDB::WriteTrigger(Bool_t defaultValues, Int_t startRun, Int_t endRun) { /// Writes all Trigger related calibration to CDB + WriteTriggerDCS(defaultValues,startRun,endRun); WriteLocalTriggerMasks(startRun,endRun); - WriteRegionalTriggerMasks(startRun,endRun); - WriteGlobalTriggerMasks(startRun,endRun); + WriteRegionalTriggerConfig(startRun,endRun); + WriteGlobalTriggerConfig(startRun,endRun); WriteTriggerLut(startRun,endRun); WriteTriggerEfficiency(startRun,endRun); } +//_____________________________________________________________________________ +void +AliMUONCDB::WriteConfig(Int_t startRun, Int_t endRun) +{ + /// Write complete tracker configuration to OCDB + ostringstream lines; + TIter next(AliMpDDLStore::Instance()->CreateBusPatchIterator()); + AliMpBusPatch* bp; + while ( ( bp = static_cast(next()) ) ) + { + for (Int_t imanu = 0; imanu < bp->GetNofManus(); ++imanu) + { + lines << bp->GetId() << " " << bp->GetManuId(imanu) << endl; + } + } + + AliMUON2DMap config(kTRUE); + + AliMUONTrackerIO::DecodeConfig(lines.str().c_str(),config); + + WriteToCDB("MUON/Calib/Config",&config,startRun,endRun,kTRUE); +} + //_____________________________________________________________________________ void AliMUONCDB::WriteTracker(Bool_t defaultValues, Int_t startRun, Int_t endRun) @@ -971,5 +1418,8 @@ AliMUONCDB::WriteTracker(Bool_t defaultValues, Int_t startRun, Int_t endRun) WriteGains(defaultValues,startRun,endRun); WriteCapacitances(defaultValues,startRun,endRun); WriteNeighbours(startRun,endRun); + WriteOccupancyMap(defaultValues,startRun,endRun); + WriteRejectList(defaultValues,startRun,endRun); + WriteConfig(startRun,endRun); }