3 * @file makeGRPObject.C
4 * @brief Creation of the GRP configuration object for HLT
7 * Usage: aliroot -b -q -l makeGRPObject.C'("arguments", "uri", \
11 * Usage: aliroot -b -q -l makeGRPObject.C'(l3Current, l3Polarity, \
12 * dipoleCurrent, dipolePolarity, \
13 * "uri", rangemin, rangemax)'
16 * Create the GRP OCDB object for the magnetic field settings.
17 * The magnetic field in AliRoot is controlled by the AliMagF class and
18 * the TGeoGlobalMagField container. AliMagF contains the field maps
19 * for both the L3 and dipole magnets.
21 * The following conventions for magnetic field polarity are known:
22 * 1) kConvMap2005: used for the field mapping in 2005
23 * positive L3 current -> negative Bz
24 * positive Dip current -> positive Bx
25 * 2) kConvMapDCS2008: defined by the microswitches/cabling of power
26 * converters as of 2008 - 1st half 2009
27 * positive L3 current -> positive Bz
28 * positive Dip current -> positive Bx
29 * 3) kConvLHC : defined by LHC
30 * positive L3 current -> positive Bz
31 * positive Dip current -> negative Bx
33 * For current data taking, only the last convention is relevant.
35 * Negative polarity corresponds to the value '1' in the GRP, while
39 * arguments off, default, l3=current, l3=off,
40 * dipole=current, dipole=off
41 * uri (opt) the OCDB URI, default $ALICE_ROOT/OCDB
42 * rangemin (opt) default 0
43 * rangemax (opt) default 999999999
45 * @author Matthias.Richter@ift.uib.no
46 * @ingroup alihlt_tutorial
48 void makeGRPObject(float l3Current,
52 const char* cdbUri=NULL,
57 AliCDBManager* man = AliCDBManager::Instance();
59 cerr << "can not get AliCDBManager" << end;
63 if (!man->IsDefaultStorageSet()) {
66 if (storage.Contains("://")==0) {
67 storage="local://"; storage+=cdbUri;
70 storage="local://$ALICE_ROOT/OCDB";
72 man->SetDefaultStorage(storage);
74 storage = man->GetDefaultStorage()->GetURI();
77 // generate GRP object
78 AliGRPObject* grpObj=new AliGRPObject;
79 float cmsEnergy=14000;
80 grpObj->SetBeamEnergy(cmsEnergy/0.120); // LHC convention
81 grpObj->SetBeamType("p-p");
82 grpObj->SetL3Current(l3Current,(AliGRPObject::Stats)0);
83 grpObj->SetDipoleCurrent(dipoleCurrent,(AliGRPObject::Stats)0);
84 grpObj->SetL3Polarity(l3Polarity);
85 grpObj->SetDipolePolarity(dipolePolarity);
86 grpObj->SetPolarityConventionLHC(); // LHC convention +/+ current -> -/- field main components
90 grpman.SetGRPEntry(grpObj);
94 // write object to OCDB
95 AliCDBPath cdbPath("GRP/GRP/Data");
96 AliCDBId cdbId(cdbPath, runmin, runmax);
97 AliCDBMetaData cdbMetaData;
98 cdbMetaData.SetResponsible("ALICE HLT");
99 cdbMetaData.SetComment("Automatically produced GRP entry (AliHLTSimulation) for the magnetic field initialization of HLT components");
100 man->Put(grpObj, cdbId, &cdbMetaData);
103 void makeGRPObject(const char* arguments="",
104 const char* cdbUri=NULL,
106 int runmax=999999999)
109 TString args=arguments;
110 bool bHelp=args.IsNull();
111 TObjArray* pTokens=args.Tokenize(" ");
114 float dipoleCurrent=0;
115 int dipolePolarity=0;
117 for (int i=0; i<pTokens->GetEntriesFast(); i++) {
118 TString arg=((TObjString*)pTokens->At(i))->GetString();
119 if (arg.CompareTo("off", TString::kIgnoreCase)==0) {
124 } else if (arg.CompareTo("default", TString::kIgnoreCase)==0) {
126 l3Polarity=0; // positive for positive field
128 dipolePolarity=1; // negative for positive field
129 } else if (arg.BeginsWith("l3=")) {
130 arg.ReplaceAll("l3=", "");
131 if (arg.CompareTo("off", TString::kIgnoreCase)==0) {
134 } else if (arg.IsFloat()) {
135 l3Current=arg.Atof();
136 l3Polarity=l3Current<0 ? 1:0;
137 l3Current=TMath::Abs(l3Current);
139 cerr << "Invalid parameter for key 'l3=', allowed is 'off' or current" << endl;
142 } else if (arg.BeginsWith("dipole=")) {
143 arg.ReplaceAll("dipole=", "");
144 if (arg.CompareTo("off", TString::kIgnoreCase)==0) {
147 } else if (arg.IsFloat()) {
148 dipoleCurrent=arg.Atof();
149 dipolePolarity=dipoleCurrent<0 ? 1:0;
150 dipoleCurrent=TMath::Abs(dipoleCurrent);
152 cerr << "Invalid parameter for key 'dipole=', allowed is 'off' or current" << endl;
155 if (arg.CompareTo("--help", TString::kIgnoreCase) &&
156 arg.CompareTo("-h", TString::kIgnoreCase)) {
157 cerr << "Unknown argument: " << arg << endl;
166 makeGRPObject(l3Current, l3Polarity, dipoleCurrent, dipolePolarity, cdbUri, runmin, runmax);
168 cout << "========================================================================" << endl;
169 cout << "usage: aliroot -b -q -l makeGRPObject.C'(\"arguments\", \"uri\", rangemin, rangemax)'" << endl << endl;
170 cout << " arguments off, default, l3=<current>, l3=off," << endl;
171 cout << " dipole=<current>, dipole=off" << endl;
172 cout << " uri (opt) the OCDB URI, default $ALICE_ROOT/OCDB " << endl;
173 cout << " rangemin (opt) default 0" << endl;
174 cout << " rangemax (opt) default 999999999" << endl << endl;
175 cout << "alternative usage: aliroot -b -q -l makeGRPObject.C'(l3Current, l3Polarity, \\" << endl;
176 cout << " dipoleCurrent, dipolePolarity, \\" << endl;
177 cout << " \"uri\", rangemin, rangemax)'" << endl << endl;
178 cout << "========================================================================" << endl;