]>
Commit | Line | Data |
---|---|---|
ad18e2fb | 1 | // $Id$ |
2 | /** | |
3 | * @file makeGRPObject.C | |
4 | * @brief Creation of the GRP configuration object for HLT | |
5 | * | |
6 | * <pre> | |
7 | * Usage: aliroot -b -q -l makeGRPObject.C'("arguments", "uri", \ | |
8 | * rangemin, rangemax)' | |
9 | * | |
10 | * | |
11 | * Usage: aliroot -b -q -l makeGRPObject.C'(l3Current, l3Polarity, \ | |
12 | * dipoleCurrent, dipolePolarity, \ | |
13 | * "uri", rangemin, rangemax)' | |
14 | * </pre> | |
15 | * | |
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. | |
20 | * | |
e23c99f3 | 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 | |
32 | * | |
33 | * For current data taking, only the last convention is relevant. | |
34 | * | |
35 | * Negative polarity corresponds to the value '1' in the GRP, while | |
36 | * positive to '0'. | |
ad18e2fb | 37 | * |
38 | * Parameters: <br> | |
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 | |
44 | * | |
45 | * @author Matthias.Richter@ift.uib.no | |
46 | * @ingroup alihlt_tutorial | |
47 | */ | |
48 | void makeGRPObject(float l3Current, | |
49 | int l3Polarity, | |
50 | float dipoleCurrent, | |
51 | int dipolePolarity, | |
52 | const char* cdbUri=NULL, | |
53 | int runmin=0, | |
54 | int runmax=999999999, | |
55 | bool bVerbose=true) | |
56 | { | |
57 | AliCDBManager* man = AliCDBManager::Instance(); | |
58 | if (!man) { | |
59 | cerr << "can not get AliCDBManager" << end; | |
60 | exit; | |
61 | } | |
62 | TString storage; | |
63 | if (!man->IsDefaultStorageSet()) { | |
64 | if (cdbUri) { | |
65 | storage=cdbUri; | |
66 | if (storage.Contains("://")==0) { | |
67 | storage="local://"; storage+=cdbUri; | |
68 | } | |
69 | } else { | |
70 | storage="local://$ALICE_ROOT/OCDB"; | |
71 | } | |
72 | man->SetDefaultStorage(storage); | |
73 | } else { | |
74 | storage = man->GetDefaultStorage()->GetURI(); | |
75 | } | |
76 | ||
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"); | |
ad18e2fb | 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 | |
87 | ||
88 | if (bVerbose) { | |
e23c99f3 | 89 | AliGRPManager grpman; |
90 | grpman.SetGRPEntry(grpObj); | |
91 | grpman.SetMagField(); | |
ad18e2fb | 92 | } |
93 | ||
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); | |
101 | } | |
102 | ||
103 | void makeGRPObject(const char* arguments="", | |
104 | const char* cdbUri=NULL, | |
105 | int runmin=0, | |
106 | int runmax=999999999) | |
107 | ||
108 | { | |
109 | TString args=arguments; | |
110 | bool bHelp=args.IsNull(); | |
111 | TObjArray* pTokens=args.Tokenize(" "); | |
112 | float l3Current=0; | |
113 | int l3Polarity=0; | |
114 | float dipoleCurrent=0; | |
115 | int dipolePolarity=0; | |
116 | if (pTokens) { | |
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) { | |
120 | l3Current=0; | |
121 | l3Polarity=0; | |
122 | dipoleCurrent=0; | |
123 | dipolePolarity=0; | |
124 | } else if (arg.CompareTo("default", TString::kIgnoreCase)==0) { | |
125 | l3Current=30000; | |
e23c99f3 | 126 | l3Polarity=0; // positive for positive field |
ad18e2fb | 127 | dipoleCurrent=6000; |
e23c99f3 | 128 | dipolePolarity=1; // negative for positive field |
ad18e2fb | 129 | } else if (arg.BeginsWith("l3=")) { |
130 | arg.ReplaceAll("l3=", ""); | |
131 | if (arg.CompareTo("off", TString::kIgnoreCase)==0) { | |
132 | l3Current=0; | |
133 | l3Polarity=0; | |
cf8ae367 | 134 | } else if (arg.IsFloat()) { |
ad18e2fb | 135 | l3Current=arg.Atof(); |
cf8ae367 | 136 | l3Polarity=l3Current<0 ? 1:0; |
ad18e2fb | 137 | l3Current=TMath::Abs(l3Current); |
138 | } else { | |
139 | cerr << "Invalid parameter for key 'l3=', allowed is 'off' or current" << endl; | |
140 | } | |
141 | ||
142 | } else if (arg.BeginsWith("dipole=")) { | |
143 | arg.ReplaceAll("dipole=", ""); | |
144 | if (arg.CompareTo("off", TString::kIgnoreCase)==0) { | |
145 | dipoleCurrent=0; | |
146 | dipolePolarity=0; | |
cf8ae367 | 147 | } else if (arg.IsFloat()) { |
ad18e2fb | 148 | dipoleCurrent=arg.Atof(); |
cf8ae367 | 149 | dipolePolarity=dipoleCurrent<0 ? 1:0; |
ad18e2fb | 150 | dipoleCurrent=TMath::Abs(dipoleCurrent); |
151 | } else { | |
152 | cerr << "Invalid parameter for key 'dipole=', allowed is 'off' or current" << endl; | |
153 | } | |
154 | } else { | |
155 | if (arg.CompareTo("--help", TString::kIgnoreCase) && | |
156 | arg.CompareTo("-h", TString::kIgnoreCase)) { | |
157 | cerr << "Unknown argument: " << arg << endl; | |
158 | } | |
159 | bHelp=true; | |
160 | } | |
161 | } | |
162 | delete pTokens; | |
163 | } | |
164 | ||
165 | if (!bHelp) { | |
166 | makeGRPObject(l3Current, l3Polarity, dipoleCurrent, dipolePolarity, cdbUri, runmin, runmax); | |
167 | } else { | |
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; | |
179 | } | |
180 | } |