+Bool_t AliMUONCDB::CheckOCDB(Bool_t pathOnly)
+{
+ /// 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)