1 #if !defined (__CINT__) || defined (__MAKECINT__)
3 #include "AliCDBManager.h"
4 #include "AliCDBPath.h"
5 #include "AliCDBEntry.h"
6 #include "AliGRPObject.h"
8 #include "TGeoGlobalMagField.h"
11 Bool_t InitGRP(TString OCDBpath, TString GRPpath="") {
12 //------------------------------------
13 // Initialization of the GRP entry
14 //------------------------------------
16 AliCDBManager::Instance()->SetDefaultStorage(OCDBpath.Data());
17 AliCDBManager::Instance()->SetSpecificStorage("GRP/GRP/Data", Form("local://%s",GRPpath.Data()));
18 AliCDBManager::Instance()->SetRun(0);
20 AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/GRP/Data");
21 AliGRPObject* GRPData;
25 TMap* m = dynamic_cast<TMap*>(entry->GetObject()); // old GRP entry
28 printf("Found a TMap in GRP/GRP/Data, converting it into an AliGRPObject");
30 GRPData = new AliGRPObject();
31 GRPData->ReadValuesFromMap(m);
35 printf("Found an AliGRPObject in GRP/GRP/Data, reading it");
36 GRPData = dynamic_cast<AliGRPObject*>(entry->GetObject()); // new GRP entry
40 // FIX ME: The unloading of GRP entry is temporarily disabled
41 // because ZDC and VZERO are using it in order to initialize
42 // their reconstructor objects. In the future one has to think
43 // of propagating AliRunInfo to the reconstructors.
44 // AliCDBManager::Instance()->UnloadFromCache("GRP/GRP/Data");
48 printf("No GRP entry found in OCDB!");
52 TString lhcState = GRPData->GetLHCState();
53 if (lhcState==AliGRPObject::GetInvalidString()) {
54 printf("GRP/GRP/Data entry: missing value for the LHC state ! Using UNKNOWN");
58 TString beamType = GRPData->GetBeamType();
59 if (beamType==AliGRPObject::GetInvalidString()) {
60 printf("GRP/GRP/Data entry: missing value for the beam type ! Using UNKNOWN");
64 Float_t beamEnergy = GRPData->GetBeamEnergy();
65 if (beamEnergy==AliGRPObject::GetInvalidFloat()) {
66 printf("GRP/GRP/Data entry: missing value for the beam energy ! Using 0");
69 // LHC: "multiply by 120 to get the energy in MeV"
72 TString runType = GRPData->GetRunType();
73 if (runType==AliGRPObject::GetInvalidString()) {
74 printf("GRP/GRP/Data entry: missing value for the run type ! Using UNKNOWN");
78 Int_t activeDetectors = GRPData->GetDetectorMask();
79 if (activeDetectors==AliGRPObject::GetInvalidUInt()) {
80 printf("GRP/GRP/Data entry: missing value for the detector mask ! Using 1074790399");
81 activeDetectors = 1074790399;
84 //*** Dealing with the magnetic field map
85 if ( TGeoGlobalMagField::Instance()->IsLocked() ) {
86 if (TGeoGlobalMagField::Instance()->GetField()->TestBit(AliMagF::kOverrideGRP)) {
87 printf("ExpertMode!!! GRP information will be ignored !");
88 printf("ExpertMode!!! Running with the externally locked B field !");
91 printf("Destroying existing B field instance!");
92 delete TGeoGlobalMagField::Instance();
95 if ( !TGeoGlobalMagField::Instance()->IsLocked() ) {
96 // Construct the field map out of the information retrieved from GRP.
99 Float_t l3Current = GRPData->GetL3Current((AliGRPObject::Stats)0);
100 if (l3Current == AliGRPObject::GetInvalidFloat()) {
101 printf("GRP/GRP/Data entry: missing value for the L3 current !");
105 Char_t l3Polarity = GRPData->GetL3Polarity();
106 if (l3Polarity == AliGRPObject::GetInvalidChar()) {
107 printf("GRP/GRP/Data entry: missing value for the L3 polarity !");
112 Float_t diCurrent = GRPData->GetDipoleCurrent((AliGRPObject::Stats)0);
113 if (diCurrent == AliGRPObject::GetInvalidFloat()) {
114 printf("GRP/GRP/Data entry: missing value for the dipole current !");
118 Char_t diPolarity = GRPData->GetDipolePolarity();
119 if (diPolarity == AliGRPObject::GetInvalidChar()) {
120 printf("GRP/GRP/Data entry: missing value for the dipole polarity !");
124 // read special bits for the polarity convention and map type
125 Int_t polConvention = GRPData->IsPolarityConventionLHC() ? AliMagF::kConvLHC : AliMagF::kConvDCS2008;
126 Bool_t uniformB = GRPData->IsUniformBMap();
129 AliMagF* fld = AliMagF::CreateFieldMap(TMath::Abs(l3Current) * (l3Polarity ? -1:1),
130 TMath::Abs(diCurrent) * (diPolarity ? -1:1),
131 polConvention,uniformB,beamEnergy, beamType.Data());
133 TGeoGlobalMagField::Instance()->SetField( fld );
134 TGeoGlobalMagField::Instance()->Lock();
135 printf("Running with the B field constructed out of GRP !");
137 else printf("Failed to create a B field map !");
139 else printf("B field is neither set nor constructed from GRP ! Exitig...");
142 //*** Get the diamond profiles from OCDB
143 // entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertexSPD");
145 // fDiamondProfileSPD = dynamic_cast<AliESDVertex*> (entry->GetObject());
147 // printf("No SPD diamond profile found in OCDB!");
150 // entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertex");
152 // fDiamondProfile = dynamic_cast<AliESDVertex*> (entry->GetObject());
154 // printf("No diamond profile found in OCDB!");
157 // entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertexTPC");
159 // fDiamondProfileTPC = dynamic_cast<AliESDVertex*> (entry->GetObject());
161 // printf("No TPC diamond profile found in OCDB!");
164 // entry = AliCDBManager::Instance()->Get("GRP/Calib/CosmicTriggers");
166 // fListOfCosmicTriggers = dynamic_cast<THashTable*>(entry->GetObject());
167 // entry->SetOwner(0);
168 // AliCDBManager::Instance()->UnloadFromCache("GRP/Calib/CosmicTriggers");
171 // if (!fListOfCosmicTriggers) {
172 // AliWarning("Can not get list of cosmic triggers from OCDB! Cosmic event specie will be effectively disabled!");