]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/exa/makeGRPObject.C
New task for filtering of AODs with Jpsi candidates (Carmelo)
[u/mrichter/AliRoot.git] / HLT / exa / makeGRPObject.C
CommitLineData
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 */
48void 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");
82 grpObj->SetLHCLuminosity(0,(AliGRPObject::Stats)0);
83 grpObj->SetBeamIntensity(0,(AliGRPObject::Stats)0);
84 grpObj->SetL3Current(l3Current,(AliGRPObject::Stats)0);
85 grpObj->SetDipoleCurrent(dipoleCurrent,(AliGRPObject::Stats)0);
86 grpObj->SetL3Polarity(l3Polarity);
87 grpObj->SetDipolePolarity(dipolePolarity);
88 grpObj->SetPolarityConventionLHC(); // LHC convention +/+ current -> -/- field main components
89
90 if (bVerbose) {
e23c99f3 91 AliGRPManager grpman;
92 grpman.SetGRPEntry(grpObj);
93 grpman.SetMagField();
ad18e2fb 94 }
95
96 // write object to OCDB
97 AliCDBPath cdbPath("GRP/GRP/Data");
98 AliCDBId cdbId(cdbPath, runmin, runmax);
99 AliCDBMetaData cdbMetaData;
100 cdbMetaData.SetResponsible("ALICE HLT");
101 cdbMetaData.SetComment("Automatically produced GRP entry (AliHLTSimulation) for the magnetic field initialization of HLT components");
102 man->Put(grpObj, cdbId, &cdbMetaData);
103}
104
105void makeGRPObject(const char* arguments="",
106 const char* cdbUri=NULL,
107 int runmin=0,
108 int runmax=999999999)
109
110{
111 TString args=arguments;
112 bool bHelp=args.IsNull();
113 TObjArray* pTokens=args.Tokenize(" ");
114 float l3Current=0;
115 int l3Polarity=0;
116 float dipoleCurrent=0;
117 int dipolePolarity=0;
118 if (pTokens) {
119 for (int i=0; i<pTokens->GetEntriesFast(); i++) {
120 TString arg=((TObjString*)pTokens->At(i))->GetString();
121 if (arg.CompareTo("off", TString::kIgnoreCase)==0) {
122 l3Current=0;
123 l3Polarity=0;
124 dipoleCurrent=0;
125 dipolePolarity=0;
126 } else if (arg.CompareTo("default", TString::kIgnoreCase)==0) {
127 l3Current=30000;
e23c99f3 128 l3Polarity=0; // positive for positive field
ad18e2fb 129 dipoleCurrent=6000;
e23c99f3 130 dipolePolarity=1; // negative for positive field
ad18e2fb 131 } else if (arg.BeginsWith("l3=")) {
132 arg.ReplaceAll("l3=", "");
133 if (arg.CompareTo("off", TString::kIgnoreCase)==0) {
134 l3Current=0;
135 l3Polarity=0;
136 } else if (arg.IsDigit()) {
137 l3Current=arg.Atof();
138 l3Polarity=l3Current<0 ? 0:1;
139 l3Current=TMath::Abs(l3Current);
140 } else {
141 cerr << "Invalid parameter for key 'l3=', allowed is 'off' or current" << endl;
142 }
143
144 } else if (arg.BeginsWith("dipole=")) {
145 arg.ReplaceAll("dipole=", "");
146 if (arg.CompareTo("off", TString::kIgnoreCase)==0) {
147 dipoleCurrent=0;
148 dipolePolarity=0;
149 } else if (arg.IsDigit()) {
150 dipoleCurrent=arg.Atof();
151 dipolePolarity=dipoleCurrent<0 ? 0:1;
152 dipoleCurrent=TMath::Abs(dipoleCurrent);
153 } else {
154 cerr << "Invalid parameter for key 'dipole=', allowed is 'off' or current" << endl;
155 }
156 } else {
157 if (arg.CompareTo("--help", TString::kIgnoreCase) &&
158 arg.CompareTo("-h", TString::kIgnoreCase)) {
159 cerr << "Unknown argument: " << arg << endl;
160 }
161 bHelp=true;
162 }
163 }
164 delete pTokens;
165 }
166
167 if (!bHelp) {
168 makeGRPObject(l3Current, l3Polarity, dipoleCurrent, dipolePolarity, cdbUri, runmin, runmax);
169 } else {
170 cout << "========================================================================" << endl;
171 cout << "usage: aliroot -b -q -l makeGRPObject.C'(\"arguments\", \"uri\", rangemin, rangemax)'" << endl << endl;
172 cout << " arguments off, default, l3=<current>, l3=off," << endl;
173 cout << " dipole=<current>, dipole=off" << endl;
174 cout << " uri (opt) the OCDB URI, default $ALICE_ROOT/OCDB " << endl;
175 cout << " rangemin (opt) default 0" << endl;
176 cout << " rangemax (opt) default 999999999" << endl << endl;
177 cout << "alternative usage: aliroot -b -q -l makeGRPObject.C'(l3Current, l3Polarity, \\" << endl;
178 cout << " dipoleCurrent, dipolePolarity, \\" << endl;
179 cout << " \"uri\", rangemin, rangemax)'" << endl << endl;
180 cout << "========================================================================" << endl;
181 }
182}