X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=MUON%2FAliMUONCDB.cxx;h=7ccf9f7ffb6a7a55085a7d5324b6c873464c8f2e;hb=57acd2d2f484e474d764cf49c17bf8a0af5bdd5e;hp=1386e4a0baedc8ddd19a2bd63c9f34e57aae0aa7;hpb=6687de6d5e6bd4b6b1f33fb5e9f8051645f52e07;p=u%2Fmrichter%2FAliRoot.git diff --git a/MUON/AliMUONCDB.cxx b/MUON/AliMUONCDB.cxx index 1386e4a0bae..7ccf9f7ffb6 100644 --- a/MUON/AliMUONCDB.cxx +++ b/MUON/AliMUONCDB.cxx @@ -30,10 +30,6 @@ #include "AliMUONCDB.h" -#include "AliCDBEntry.h" -#include "AliCDBManager.h" -#include "AliDCSValue.h" -#include "AliLog.h" #include "AliMUON1DArray.h" #include "AliMUON1DMap.h" #include "AliMUON2DMap.h" @@ -41,22 +37,34 @@ #include "AliMUONCalibParamNF.h" #include "AliMUONCalibParamNI.h" #include "AliMUONConstants.h" -#include "AliMUONHVNamer.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 "AliMpCDB.h" #include "AliMpConstants.h" #include "AliMpDDLStore.h" -#include "AliMpDEIterator.h" +#include "AliMpManuStore.h" #include "AliMpDEManager.h" #include "AliMpDetElement.h" -#include "AliMpManuList.h" +#include "AliMpFiles.h" +#include "AliMpHVNamer.h" +#include "AliMpManuIterator.h" #include "AliMpSegmentation.h" #include "AliMpStationType.h" #include "AliMpVSegmentation.h" + +#include "AliCodeTimer.h" +#include "AliCDBEntry.h" +#include "AliCDBManager.h" +#include "AliDCSValue.h" +#include "AliLog.h" + #include #include #include @@ -70,13 +78,20 @@ #include #include + /// \cond CLASSIMP ClassImp(AliMUONCDB) /// \endcond namespace { -//_____________________________________________________________________________ + //_____________________________________________________________________________ +AliMUONVStore* Create2DMap() +{ + return new AliMUON2DMap(true); +} + + //_____________________________________________________________________________ void getBoundaries(const AliMUONVStore& store, Int_t dim, Float_t* xmin, Float_t* xmax) { @@ -150,34 +165,23 @@ Double_t GetRandom(Double_t mean, Double_t sigma, Bool_t mustBePositive) AliMUONCDB::AliMUONCDB(const char* cdbpath) : TObject(), fCDBPath(cdbpath), - fManuList(0x0), fMaxNofChannelsToGenerate(-1) { - /// ctor + /// ctor + // Load mapping + if ( ! AliMpCDB::LoadDDLStore() ) { + AliFatal("Could not access mapping from OCDB !"); + } + + if ( ! AliMpCDB::LoadManuStore() ) { + AliFatal("Could not access run-dependent mapping from OCDB !"); + } } //_____________________________________________________________________________ AliMUONCDB::~AliMUONCDB() { /// dtor - delete fManuList; -} - -//_____________________________________________________________________________ -TList* -AliMUONCDB::ManuList() -{ - /// return (and create if necessary) the list of (de,manu) pairs - if (!fManuList) - { - AliInfo("Generating ManuList..."); - AliCDBManager::Instance()->SetDefaultStorage(fCDBPath); - AliMpCDB::LoadMpSegmentation(); - AliMpCDB::LoadDDLStore(); - fManuList = AliMpManuList::ManuList(); - AliInfo("Manu List generated."); - } - return fManuList; } //_____________________________________________________________________________ @@ -322,7 +326,7 @@ AliMUONCDB::MakeHVStore(TMap& aliasMap, Bool_t defaultValues) { /// Create a HV store - AliMUONHVNamer hvNamer; + AliMpHVNamer hvNamer; TObjArray* aliases = hvNamer.GenerateAliases(); @@ -385,10 +389,8 @@ 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) - - TIter next(ManuList()); - - AliMpIntPair* p; + + AliCodeTimerAuto(""); Int_t nchannels(0); Int_t nmanus(0); @@ -398,24 +400,24 @@ AliMUONCDB::MakePedestalStore(AliMUONVStore& pedestalStore, Bool_t defaultValues const Float_t kPedestalMeanSigma(10); const Float_t kPedestalSigmaMean(1.0); const Float_t kPedestalSigmaSigma(0.2); + + 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(); - AliMUONVCalibParam* ped = new AliMUONCalibParamNF(2,kChannels,detElemId,manuId,AliMUONVCalibParam::InvalidFloatValue()); - - const AliMpVSegmentation* seg = - AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId,manuId); + + 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; @@ -451,7 +453,6 @@ AliMUONCDB::MakePedestalStore(AliMUONVStore& pedestalStore, Bool_t defaultValues AliInfo(Form("%d Manus and %d channels.",nmanus,nchannels)); return nchannels; - } //_____________________________________________________________________________ @@ -460,50 +461,7 @@ AliMUONCDB::MakeCapacitanceStore(AliMUONVStore& capaStore, const char* file) { /// Read the capacitance values from file and append them to the capaStore - ifstream in(gSystem->ExpandPathName(file)); - if (in.bad()) return 0; - - Int_t ngenerated(0); - - char line[1024]; - Int_t serialNumber(-1); - AliMUONVCalibParam* param(0x0); - - while ( in.getline(line,1024,'\n') ) - { - if ( isdigit(line[0]) ) - { - serialNumber = atoi(line); - param = static_cast(capaStore.FindObject(serialNumber)); - if (param) - { - AliError(Form("serialNumber %d appears several times !",serialNumber)); - capaStore.Clear(); - break; - } - param = new AliMUONCalibParamNF(2,AliMpConstants::ManuNofChannels(),serialNumber,0,1.0); - Bool_t ok = capaStore.Add(param); - if (!ok) - { - AliError(Form("Could not set serialNumber=%d",serialNumber)); - continue; - } - continue; - } - Int_t channel; - Float_t capaValue; - Float_t injectionGain; - sscanf(line,"%d %f %f",&channel,&capaValue,&injectionGain); - AliDebug(1,Form("SerialNumber %10d Channel %3d Capa %f injectionGain %f", - serialNumber,channel,capaValue,injectionGain)); - param->SetValueAsFloat(channel,0,capaValue); - param->SetValueAsFloat(channel,1,injectionGain); - ++ngenerated; - } - - in.close(); - - return ngenerated; + return AliMUONTrackerIO::ReadCapacitances(file,capaStore); } //_____________________________________________________________________________ @@ -513,10 +471,8 @@ 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. - - TIter next(ManuList()); - - AliMpIntPair* p; + + AliCodeTimerAuto(""); Int_t nchannels(0); Int_t nmanus(0); @@ -526,24 +482,23 @@ AliMUONCDB::MakeCapacitanceStore(AliMUONVStore& capaStore, Bool_t defaultValues) const Float_t kCapaSigma(0.1); const Float_t kInjectionGainMean(3); const Float_t kInjectionGainSigma(1); + + Int_t detElemId; + Int_t manuId; - while ( ( p = (AliMpIntPair*)next() ) ) + AliMpManuIterator it; + + 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) @@ -558,8 +513,7 @@ AliMUONCDB::MakeCapacitanceStore(AliMUONVStore& capaStore, Bool_t defaultValues) 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; @@ -604,44 +558,41 @@ AliMUONCDB::MakeGainStore(AliMUONVStore& gainStore, Bool_t defaultValues) /// otherwise parameters are taken from gaussians with parameters /// defined in the k* constants below. - TIter next(ManuList()); - - AliMpIntPair* p; + AliCodeTimerAuto(""); Int_t nchannels(0); Int_t nmanus(0); 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 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); + const Int_t kThresSigma(100); + + Int_t detElemId; + Int_t manuId; - while ( ( p = (AliMpIntPair*)next() ) ) + AliMpManuIterator it; + + while ( it.Next(detElemId,manuId) ) { ++nmanus; - Int_t detElemId = p->GetFirst(); - Int_t manuId = p->GetSecond(); - AliMUONVCalibParam* gain = 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; @@ -682,10 +633,12 @@ AliMUONCDB::MakeLocalTriggerMaskStore(AliMUONVStore& localBoardMasks) const { /// Generate local trigger masks store. All masks are set to FFFF + AliCodeTimerAuto(""); + 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 ) @@ -704,47 +657,41 @@ AliMUONCDB::MakeLocalTriggerMaskStore(AliMUONVStore& localBoardMasks) const //_____________________________________________________________________________ Int_t -AliMUONCDB::MakeRegionalTriggerMaskStore(AliMUONVStore& rtm) const +AliMUONCDB::MakeRegionalTriggerConfigStore(AliMUONRegionalTriggerConfig& rtm) const { - /// 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); - } + AliCodeTimerAuto(""); - return ngenerated; + if ( ! rtm.ReadData(AliMpFiles::LocalTriggerBoardMapping()) ) { + AliErrorStream() << "Error when reading from mapping file" << endl; + return 0; + } + + return rtm.GetNofTriggerCrates(); } + //_____________________________________________________________________________ Int_t -AliMUONCDB::MakeGlobalTriggerMaskStore(AliMUONVCalibParam& gtm) const +AliMUONCDB::MakeGlobalTriggerConfigStore(AliMUONGlobalCrateConfig& gtm) const { - /// 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); + AliCodeTimerAuto(""); - 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 { /// Make a triggerlut object, from a file. + AliCodeTimerAuto(""); + AliMUONTriggerLut* lut = new AliMUONTriggerLut; lut->ReadFromFile(file); return lut; @@ -756,6 +703,8 @@ AliMUONCDB::MakeTriggerEfficiency(const char* file) const { /// Make a trigger efficiency object from a file. + AliCodeTimerAuto(""); + return new AliMUONTriggerEfficiencyCells(file); } @@ -767,14 +716,9 @@ AliMUONCDB::WriteToCDB(const char* calibpath, TObject* object, { /// Write a given object to OCDB - AliCDBId id(calibpath,startRun,endRun); - AliCDBMetaData md; - md.SetAliRootVersion(gROOT->GetVersion()); - md.SetComment(gSystem->ExpandPathName(filename)); - md.SetResponsible("Uploaded using AliMUONCDB class"); - AliCDBManager* man = AliCDBManager::Instance(); - man->SetDefaultStorage(fCDBPath); - man->Put(object,id,&md); + TString comment(gSystem->ExpandPathName(filename)); + + WriteToCDB(object, calibpath, startRun, endRun, comment.Data()); } //_____________________________________________________________________________ @@ -784,21 +728,27 @@ 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 + 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"); - + md.SetComment(comment); + md.SetResponsible(responsible); AliCDBManager* man = AliCDBManager::Instance(); - man->SetDefaultStorage(fCDBPath); + if (!man->IsDefaultStorageSet()) man->SetDefaultStorage(fCDBPath); man->Put(object,id,&md); } @@ -809,25 +759,21 @@ 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."); - - TStopwatch timer; - - timer.Start(kTRUE); + AliCodeTimerAuto(""); - TIter next(ManuList()); - - AliMpIntPair* p; + AliInfo("Generating NeighbourStore. This will take a while. Please be patient."); Int_t nchannels(0); TObjArray tmp; + + Int_t detElemId; + Int_t manuId; + + AliMpManuIterator it; - while ( ( p = (AliMpIntPair*)next() ) ) + while ( it.Next(detElemId,manuId) ) { - Int_t detElemId = p->GetFirst(); - Int_t manuId = p->GetSecond(); - const AliMpVSegmentation* seg = AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId,manuId); @@ -861,23 +807,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->GetLocation().GetFirst(),p->GetLocation().GetSecond(),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; } @@ -896,7 +841,7 @@ 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)); if (ngenerated>0) @@ -908,37 +853,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); + AliMUONRegionalTriggerConfig* rtm = new AliMUONRegionalTriggerConfig(); + Int_t ngenerated = MakeRegionalTriggerConfigStore(*rtm); AliInfo(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); + Int_t ngenerated = MakeGlobalTriggerConfigStore(*gtm); AliInfo(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) @@ -973,7 +920,7 @@ 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)); if (ngenerated>0) @@ -1013,7 +960,7 @@ 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)); WriteToCDB("MUON/Calib/Pedestals",pedestalStore,startRun,endRun,defaultValues); @@ -1031,7 +978,7 @@ 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)); WriteToCDB("MUON/Calib/Gains",gainStore,startRun,endRun,defaultValues); @@ -1080,8 +1027,8 @@ AliMUONCDB::WriteTrigger(Int_t startRun, Int_t endRun) { /// Writes all Trigger related calibration to CDB WriteLocalTriggerMasks(startRun,endRun); - WriteRegionalTriggerMasks(startRun,endRun); - WriteGlobalTriggerMasks(startRun,endRun); + WriteRegionalTriggerConfig(startRun,endRun); + WriteGlobalTriggerConfig(startRun,endRun); WriteTriggerLut(startRun,endRun); WriteTriggerEfficiency(startRun,endRun); } @@ -1097,3 +1044,4 @@ AliMUONCDB::WriteTracker(Bool_t defaultValues, Int_t startRun, Int_t endRun) WriteCapacitances(defaultValues,startRun,endRun); WriteNeighbours(startRun,endRun); } +