]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/trigger/macros/makeTriggerConfigurationObject.C
Updated macros for PHOS alignment calculation
[u/mrichter/AliRoot.git] / HLT / trigger / macros / makeTriggerConfigurationObject.C
CommitLineData
d8e991b3 1//-*- Mode: C++ -*-
2// $Id: makeTriggerConfigurationObject.C $
3/**
4 * @file makeTriggerConfigurationObject.C
5 * @brief Creation of HLT component configuration objects in OCDB
6 *
7 * <pre>
8 * Usage: aliroot -b -q makeTriggerConfigurationObject.C'("triggerName", "cdbUri", runMin, runMax)'
9 * </pre>
10 *
11 * Create an CDB entry for a certain trigger.
12 *
13 * According to <Trigger-Identifier>, <Minor Version> and <Major Versions>,
14 * CDB objects are created and saved in the CDB. This objects can be any TObject
15 * and have to implemented according to the trigger needs.
16 *
17 * Note : <br>
18 * In the path in the CDB '-' is replaced by '_._'
19 *
20 * Parameters: <br>
21 * - triggerName Trigger Name following the standard
22 * H-<Trigger-Identifier>-VXXXX.YYY
23 - VXXXX being the major version number, specifying the settings
24 - YYY being the minor version number, specifying the alogrithm version
25 * - cdbUri (opt) the CDB URI, default $ALICE_ROOT
26 * - runMin (opt) default 0
27 * - runMax (opt) default 999999999
28 *
29 * Implemented Trigger : <br>
30 * - Barrel_pT_Single -> AliHLTESDTrackCuts object
31 *
32 * Usage Example : <br>
33 * aliroot -b -l -q makeTriggerConfigurationObject.C'("H-Barrel_pT_Single-V0001.001")'
34 *
35 * @author Jochen Thaeder <jochen@thaeder.de>
36 * @ingroup alihlt_trigger
37 */
38
39// #################################################################################
40void makeTriggerConfigurationObject(const Char_t* triggerName, const Char_t* cdbUri=NULL,
41 Int_t runMin=0, Int_t runMax=AliCDBRunRange::Infinity() ) {
42
4070f709 43 gSystem->Load("libANALYSIS");
44 gSystem->Load("libANALYSISalice");
45 gSystem->Load("libHLTbase");
46 gSystem->Load("libAliHLTUtil");
d8e991b3 47
48 // --------------------------------------
49 // -- Parse Trigger Name
50 // --------------------------------------
51
52 TString name(triggerName);
53 if ( !name.BeginsWith("H-") ) {
54 cerr << "Error : " << name.Data() << " is not a valid trigger name!" << endl;
55 return;
56 }
57
58 TObjArray* entries = name.Tokenize("-");
59 if (entries->GetEntriesFast() != 3 ) {
60 cerr << "Error : " << name.Data() << " is not a valid trigger name!" << endl;
61 return;
62 }
63
64 TString id = (static_cast<TObjString*>(entries->UncheckedAt(1)))->GetString();
65
66 TObjArray* version = (static_cast<TObjString*>(entries->UncheckedAt(2)))->GetString().Tokenize(".");
67 if (version->GetEntriesFast() != 2 ) {
68 cerr << "Error : " << name.Data() << " is not a valid trigger name!" << endl;
69 return;
70 }
71
72 // -- Major version ID = Settings
73 TString major = (static_cast<TObjString*>(version->UncheckedAt(0)))->GetString();
74
75 // -- Minor version ID = Algorithm
76 TString minor = (static_cast<TObjString*>(version->UncheckedAt(1)))->GetString();
77
78
79 // -------------------------------------------------------------------------------------
80
81 printf ("Trigger Setup for : %s \n", triggerName);
82
83 // --------------------------------------
84 // -- Create Configuration Object
85 // --------------------------------------
86
87 TObject* configObj = NULL;
88
89 if ( !id.CompareTo("Barrel_pT_Single") ) { // ----------------------------------------
90
91 AliHLTESDTrackCuts* esdTrackCuts = NULL;
92 TString description;
93
94 if ( !minor.CompareTo("001") ) {
95 printf (" - Trigger Setup for 2010 pp data.\n");
96
97 esdTrackCuts = AliHLTESDTrackCuts::GetStandardTrackCuts2010pp();
98 description += esdTrackCuts->GetTitle();
99
100 // -- pt cut 1 GeV - minClusters 80
101 if ( !major.CompareTo("V0001") ) {
102 esdTrackCuts->SetPtRange(1.);
103 esdTrackCuts->SetMinNClustersTPC(80);
104 description += " && p_t > 1 GeV/c && clustersTPC > 80";
105 }
106 // -- pt cut 2 GeV - minClusters 80
107 else if ( !major.CompareTo("V0002") ) {
108 esdTrackCuts->SetPtRange(2.);
109 esdTrackCuts->SetMinNClustersTPC(80);
110 description += " && p_t > 2 GeV/c && clustersTPC > 80";
111 }
112 // -- pt cut 3 GeV - minClusters 100
113 else if ( !major.CompareTo("V0003") ) {
114 esdTrackCuts->SetPtRange(3.);
115 esdTrackCuts->SetMinNClustersTPC(100);
116 description += " && p_t > 3 GeV/c && clustersTPC > 100";
117 }
118 else {
119 cerr << "Error : Major version " << major.Data() << " is not implemented!" << endl;
120 return;
121 }
122 }
123 else {
124 cerr << "Error : Minor version " << minor.Data() << " is not implemented!" << endl;
125 return;
126 }
127
128 if ( !esdTrackCuts ) {
129 cerr << "Error : No AliHLTESDTrackCuts object created" << endl;
130 return;
131 }
132
133 esdTrackCuts->SetTitle(description);
134 configObj = static_cast<TObject*>(esdTrackCuts);
135 }
136 else { // ------------------------------------------------------------------------------
137 cerr << "Error : Trigger name " << id.Data() << " is not implemented!" << endl;
138 return;
139 }
140
141 // -------------------------------------------------------------------------------------
142 printf(" - TrackCuts : %s\n", esdTrackCuts->GetTitle());
143
144 // --------------------------------------
145 // -- Setup CDB
146 // --------------------------------------
147
148 AliCDBManager* man = AliCDBManager::Instance();
149 if (!man) {
150 cerr << "Error : Can not get AliCDBManager" << endl;
151 return;
152 }
153
154 TString storage;
155 if ( !man->IsDefaultStorageSet() ) {
156 if ( cdbUri ) {
157 storage = cdbUri;
158 if ( storage.Contains("://") == 0 ) {
159 storage = "local://";
160 storage += cdbUri;
161 }
162 }
163 else {
164 storage = "local://$ALICE_ROOT/OCDB";
165 }
166 man->SetDefaultStorage(storage);
167 }
168 else {
169 storage = man->GetDefaultStorage()->GetURI();
170 }
171
172 TString path("HLT/ConfigHLT/");
173 path += name.ReplaceAll("-",1,"_._",3);
174
175 // --------------------------------------
176 // -- Fill Object
177 // --------------------------------------
178
179 if ( !configObj ) {
180 cerr << "Error : No configuration object created" << endl;
181 return;
182 }
183
184 AliCDBPath cdbPath(path);
185 AliCDBId cdbId(cdbPath, runMin, runMax);
186 AliCDBMetaData cdbMetaData;
187 man->Put(configObj, cdbId, &cdbMetaData);
188
189 printf("Adding %s type OCDB object to %s [%d,%d] in %s \n",
190 configObj->ClassName(),
191 path.Data(),
192 runMin, runMax, storage.Data());
193
194 // --------------------------------------
195 // -- Clean up
196 // --------------------------------------
197 if (version)
198 delete version;
199 version = NULL;
200
201 if (entries)
202 delete entries;
203 entries = NULL;
204
205 if (esdTrackCuts)
206 delete esdTrackCuts;
207 esdTrackCuts = NULL;
208}
209// #################################################################################
210void makeTriggerConfigurationObject() {
211
212 cout << "===============================================================" << endl;
213 cout << "usage: aliroot -b -q -l makeComponentConfigurationObject.C'(\"triggerName\", \"cdbUri\", rangeMin, rangeMax)'" << endl << endl;
214 cout << " triggerName Trigger Name following the standard" << endl;
215 cout << " H-<Trigger-Identifier>-VXXXX.YYY" << endl;
216 cout << " - VXXXX being the major version number, specifying the settings" << endl;
217 cout << " - YYY being the minor version number, specifying the alogrithm version" << endl;
218 cout << " cdbUri (opt) the OCDB URI, default $ALICE_ROOT/OCDB " << endl;
219 cout << " rangeMin (opt) default 0" << endl;
220 cout << " rangeMax (opt) default 999999999" << endl << endl;
221 cout << "example: aliroot -b -l -q makeTriggerConfigurationObject.C'(\"H-Barrel_pT_Single-V0001.001\")'" << endl;
222 cout << "===============================================================" << endl;
223}