/* $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 "AliMUONVCalibParam.h"
#include "AliMUONGlobalCrateConfig.h"
#include "AliMUONRegionalTriggerConfig.h"
+#include "AliMUONRecoParam.h"
#include "AliMpCDB.h"
#include "AliMpConstants.h"
+#include "AliMpDEStore.h"
#include "AliMpDDLStore.h"
#include "AliMpManuStore.h"
#include "AliMpDEManager.h"
#include "AliCodeTimer.h"
#include "AliCDBEntry.h"
#include "AliCDBManager.h"
+#include "AliGRPManager.h"
#include "AliDCSValue.h"
#include "AliLog.h"
#include <TStopwatch.h>
#include <TSystem.h>
#include <TMath.h>
+#include <TGeoGlobalMagField.h>
+#include <TClonesArray.h>
-/// \cond CLASSIMP
-ClassImp(AliMUONCDB)
-/// \endcond
-
namespace
{
//_____________________________________________________________________________
}
//_____________________________________________________________________________
-AliMUONCDB::AliMUONCDB(const char* cdbpath)
-: TObject(),
- fCDBPath(cdbpath),
- fMaxNofChannelsToGenerate(-1)
+Bool_t AliMUONCDB::CheckOCDB(Bool_t pathOnly)
{
- /// ctor
- // Load mapping
- if ( ! AliMpCDB::LoadDDLStore() ) {
- AliFatal("Could not access mapping from OCDB !");
+ /// 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;
+
+}
+
+//_____________________________________________________________________________
+Bool_t AliMUONCDB::CheckMapping(Bool_t segmentationOnly)
+{
+ /// 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;
+
+}
+
+//_____________________________________________________________________________
+Bool_t AliMUONCDB::LoadField()
+{
+ /// 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;
+
+}
- if ( ! AliMpCDB::LoadManuStore() ) {
- AliFatal("Could not access run-dependent mapping from OCDB !");
+//_____________________________________________________________________________
+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<AliMUONRecoParam*>(entry->GetObject()))) {
+
+ TObjArray* recoParamArray = static_cast<TObjArray*>(entry->GetObject());
+
+ for(Int_t i = 0; i < recoParamArray->GetEntriesFast(); i++) {
+ recoParam = static_cast<AliMUONRecoParam*>(recoParamArray->UncheckedAt(i));
+ if (recoParam->IsDefault()) break;
+ recoParam = 0x0;
+ }
+
}
+
+ }
+
+ if (!recoParam) AliErrorGeneral("AliMUONCDB", "failed to load RecoParam from OCDB");
+
+ return recoParam;
+
}
//_____________________________________________________________________________
-AliMUONCDB::~AliMUONCDB()
+TClonesArray* AliMUONCDB::LoadAlignmentData()
{
- /// dtor
+ /// 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<TClonesArray*>(entry->GetObject());
+ }
+
+ if (!alignmentArray) {
+ AliErrorGeneral("AliMUONCDB", "failed to load Alignemnt from OCDB");
+ }
+
+ return alignmentArray;
}
//_____________________________________________________________________________
if ( !sopt.Contains("ABS") && !sopt.Contains("REL") && !sopt.Contains("PERCENT") )
{
- AliErrorClass(Form("opt %s not supported. Only ABS, REL, PERCENT are",opt));
+ AliErrorGeneral("AliMUONCDB", Form("opt %s not supported. Only ABS, REL, PERCENT are",opt));
return 0x0;
}
/// contained inside store.
/// It produces histograms named name_0, name_1, etc...
+ if (!AliMUONCDB::CheckMapping(kTRUE)) return;
+
TIter next(store.CreateIterator());
AliMUONVCalibParam* param;
Int_t n(0);
{
h[i] = new TH1F(Form("%s_%d",name,i),Form("%s_%d",name,i),
nbins,xmin[i],xmax[i]);
- AliInfo(Form("Created histogram %s",h[i]->GetName()));
+ AliInfoGeneral("AliMUONCDB", Form("Created histogram %s",h[i]->GetName()));
}
}
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]));
}
- AliInfo(Form("Number of channels = %d",n));
+ AliInfoGeneral("AliMUONCDB", Form("Number of channels = %d",n));
delete[] nPerStation;
}
{
/// Create a HV store
+ if (!AliMUONCDB::CheckMapping()) return 0;
+
AliMpDCSNamer hvNamer("TRACKER");
TObjArray* aliases = hvNamer.GenerateAliases();
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;
}
{
/// Create a Trigger HV and Currents store
+ if (!AliMUONCDB::CheckMapping()) return 0;
+
AliMpDCSNamer triggerDCSNamer("TRIGGER");
TObjArray* aliases = triggerDCSNamer.GenerateAliases();
delete aliases;
- AliInfo(Form("Trigger channels I -> %i HV -> %i",nChannels[0], nChannels[1]));
+ AliInfoGeneral("AliMUONCDB", Form("Trigger channels I -> %i HV -> %i",nChannels[0], nChannels[1]));
return nChannels[0] + nChannels[1];
}
/// otherwise mean and sigma are from a gaussian (with parameters
/// defined below by the kPedestal* constants)
- AliCodeTimerAuto("");
+ AliCodeTimerAutoGeneral("",0);
+
+ if (!AliMUONCDB::CheckMapping()) return 0;
Int_t nchannels(0);
Int_t nmanus(0);
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));
}
- if ( fMaxNofChannelsToGenerate > 0 && nchannels >= fMaxNofChannelsToGenerate ) break;
}
- AliInfo(Form("%d Manus and %d channels.",nmanus,nchannels));
+ AliInfoGeneral("AliMUONCDB", Form("%d Manus and %d channels.",nmanus,nchannels));
return nchannels;
}
{
/// Create a reject list
- AliCodeTimerAuto("");
+ AliCodeTimerAutoGeneral("",0);
AliMUONRejectList* rl = new AliMUONRejectList;
{
/// Create an occupancy map.
- AliCodeTimerAuto("");
+ AliCodeTimerAutoGeneral("",0);
+
+ if (!AliMUONCDB::CheckMapping()) return 0;
Int_t nmanus(0);
Int_t numberOfChannelsInManu = de->NofChannelsInManu(manuId);
- if (!defaultValues) occ = gRandom->Rndm(1.0);
+ if (!defaultValues) occ = gRandom->Rndm(1);
Double_t sumn = occ*nevents;
Bool_t ok = occupancyMapStore.Add(occupancy);
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));
}
}
{
/// Read the capacitance values from file and append them to the capaStore
+ if (!AliMUONCDB::CheckMapping()) return 0;
+
return AliMUONTrackerIO::ReadCapacitances(file,capaStore);
}
/// otherwise they are from a gaussian with parameters defined in the
/// kCapa* constants below.
- AliCodeTimerAuto("");
+ AliCodeTimerAutoGeneral("",0);
+
+ if (!AliMUONCDB::CheckMapping()) return 0;
Int_t nchannels(0);
Int_t nmanus(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));
}
}
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;
/// otherwise parameters are taken from gaussians with parameters
/// defined in the k* constants below.
- AliCodeTimerAuto("");
+ AliCodeTimerAutoGeneral("",0);
+
+ if (!AliMUONCDB::CheckMapping()) return 0;
Int_t nchannels(0);
Int_t nmanus(0);
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));
}
- if ( fMaxNofChannelsToGenerate > 0 && nchannels >= fMaxNofChannelsToGenerate ) break;
}
- 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
- AliCodeTimerAuto("");
+ AliCodeTimerAutoGeneral("",0);
Int_t ngenerated(0);
// Generate fake mask values for all localboards and put that into
//_____________________________________________________________________________
Int_t
-AliMUONCDB::MakeRegionalTriggerConfigStore(AliMUONRegionalTriggerConfig& rtm) const
+AliMUONCDB::MakeRegionalTriggerConfigStore(AliMUONRegionalTriggerConfig& rtm)
{
/// Make a regional trigger config store. Mask is set to FFFF for each local board (Ch.F.)
- AliCodeTimerAuto("");
+ AliCodeTimerAutoGeneral("",0);
if ( ! rtm.ReadData(AliMpFiles::LocalTriggerBoardMapping()) ) {
- AliErrorStream() << "Error when reading from mapping file" << endl;
+ AliErrorGeneral("AliMUONCDB", "Error when reading from mapping file");
return 0;
}
//_____________________________________________________________________________
Int_t
-AliMUONCDB::MakeGlobalTriggerConfigStore(AliMUONGlobalCrateConfig& gtm) const
+AliMUONCDB::MakeGlobalTriggerConfigStore(AliMUONGlobalCrateConfig& gtm)
{
/// Make a global trigger config store. All masks (disable) set to 0x00 for each Darc board (Ch.F.)
- AliCodeTimerAuto("");
+ AliCodeTimerAutoGeneral("",0);
return gtm.ReadData(AliMpFiles::GlobalTriggerBoardMapping());
}
//_____________________________________________________________________________
AliMUONTriggerLut*
-AliMUONCDB::MakeTriggerLUT(const char* file) const
+AliMUONCDB::MakeTriggerLUT(const char* file)
{
/// Make a triggerlut object, from a file.
- AliCodeTimerAuto("");
+ AliCodeTimerAutoGeneral("",0);
AliMUONTriggerLut* lut = new AliMUONTriggerLut;
lut->ReadFromFile(file);
//_____________________________________________________________________________
AliMUONTriggerEfficiencyCells*
-AliMUONCDB::MakeTriggerEfficiency(const char* file) const
+AliMUONCDB::MakeTriggerEfficiency(const char* file)
{
/// Make a trigger efficiency object from a file.
- AliCodeTimerAuto("");
+ AliCodeTimerAutoGeneral("",0);
return new AliMUONTriggerEfficiencyCells(file);
}
{
/// Write a given object to OCDB
+ if (!AliMUONCDB::CheckOCDB(kTRUE)) return;
+
AliCDBId id(calibpath,startRun,endRun);
AliCDBMetaData md;
md.SetAliRootVersion(gROOT->GetVersion());
md.SetComment(comment);
md.SetResponsible(responsible);
- AliCDBManager* man = AliCDBManager::Instance();
- if (!man->IsDefaultStorageSet()) man->SetDefaultStorage(fCDBPath);
- man->Put(object,id,&md);
+ AliCDBManager::Instance()->Put(object,id,&md);
}
//_____________________________________________________________________________
/// Fill the neighbours store with, for each channel, a TObjArray of its
/// neighbouring pads (including itself)
- AliCodeTimerAuto("");
+ AliCodeTimerAutoGeneral("",0);
+
+ if (!AliMUONCDB::CheckMapping()) return 0;
- AliInfo("Generating NeighbourStore. This will take a while. Please be patient.");
+ AliInfoGeneral("AliMUONCDB", "Generating NeighbourStore. This will take a while. Please be patient.");
Int_t nchannels(0);
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;
}
}
return nchannels;
}
-//_____________________________________________________________________________
-void
-AliMUONCDB::SetMaxNofChannelsToGenerate(Int_t n)
-{
- /// Set the maximum number of channels to generate (used for testing only)
- /// n < 0 means no limit
- fMaxNofChannelsToGenerate = n;
-}
-
//_____________________________________________________________________________
void
AliMUONCDB::WriteLocalTriggerMasks(Int_t startRun, Int_t endRun)
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);
AliMUONRegionalTriggerConfig* rtm = new AliMUONRegionalTriggerConfig();
Int_t ngenerated = MakeRegionalTriggerConfigStore(*rtm);
- AliInfo(Form("Ngenerated = %d",ngenerated));
+ AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
if (ngenerated>0)
{
WriteToCDB("MUON/Calib/RegionalTriggerConfig",rtm,startRun,endRun,true);
AliMUONGlobalCrateConfig* gtm = new AliMUONGlobalCrateConfig();
Int_t ngenerated = MakeGlobalTriggerConfigStore(*gtm);
- AliInfo(Form("Ngenerated = %d",ngenerated));
+ AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
if (ngenerated>0)
{
WriteToCDB("MUON/Calib/GlobalTriggerCrateConfig",gtm,startRun,endRun,true);
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);
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);
TMap* triggerDCSStore = new TMap;
Int_t ngenerated = MakeTriggerDCSStore(*triggerDCSStore,defaultValues);
- AliInfo(Form("Ngenerated = %d",ngenerated));
+ AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
if (ngenerated>0)
{
WriteToCDB("MUON/Calib/TriggerDCS",triggerDCSStore,startRun,endRun,defaultValues);
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;
}
AliMUONVStore* occupancyMapStore = Create2DMap();
Int_t ngenerated = MakeOccupancyMapStore(*occupancyMapStore,defaultValues);
- AliInfo(Form("Ngenerated = %d",ngenerated));
+ AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
WriteToCDB("MUON/Calib/OccupancyMap",occupancyMapStore,startRun,endRun,defaultValues);
delete occupancyMapStore;
}
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;
}
AliMUONVStore* capaStore = new AliMUON1DMap(16828);
Int_t ngenerated = MakeCapacitanceStore(*capaStore,filename);
- AliInfo(Form("Ngenerated = %d",ngenerated));
+ AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
if ( ngenerated > 0 )
{
WriteToCDB("MUON/Calib/Capacitances",capaStore,startRun,endRun,filename);
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;
}
WriteGains(defaultValues,startRun,endRun);
WriteCapacitances(defaultValues,startRun,endRun);
WriteNeighbours(startRun,endRun);
- WriteOccupancyMap(startRun,endRun,defaultValues);
- WriteRejectList(startRun,endRun,defaultValues);
+ WriteOccupancyMap(defaultValues,startRun,endRun);
+ WriteRejectList(defaultValues,startRun,endRun);
}