]>
Commit | Line | Data |
---|---|---|
92e5c8ed | 1 | |
2 | // This macro runs the GRP test preprocessor | |
3 | // It uses AliTestShuttle to simulate a full Shuttle process | |
4 | ||
5 | // The input data is created in the functions | |
6 | // CreateDCSAliasMap() creates input that would in the same way come from DCS | |
7 | // ReadDCSAliasMap() reads from a file | |
8 | // CreateInputFilesMap() creates a list of local files, that can be accessed by the shuttle | |
9 | ||
e75e6e01 | 10 | // Taking as input runtype and errorLevel |
11 | // errorLevel used to simulate errors: | |
12 | // 0 --> no error | |
13 | // 1 --> DAQ logbook error | |
14 | // 2 --> DAQ FXS error | |
15 | // 3 --> DAQ logbook_trigger_config erro | |
16 | // 4 --> DCS FXS error | |
17 | // 5 --> DCS DPs error | |
18 | // 6 --> Missing beamEnergy | |
19 | // 7 --> null buffer for Trigger Config | |
20 | ||
21 | // Need to include dummy files in TestShuttle/TestCDB for CTP Configuration and Scalers | |
22 | // (see macro $ALICE_ROOT/GRP/MakeCTPDummyEntries.C) | |
23 | ||
24 | // Modified by C. Zampolli | |
25 | ||
26 | ||
e3efae04 | 27 | #include <iostream> |
28 | #include <fstream> | |
29 | using namespace std; | |
92e5c8ed | 30 | |
e75e6e01 | 31 | void TestGRPPreprocessor(const char* runtype="PHYSICS", TString partition="ALICE", TString detector="", TString beamType = "p-p", Int_t errorLevel=0) |
92e5c8ed | 32 | { |
92e5c8ed | 33 | gSystem->Load("$ALICE_ROOT/SHUTTLE/TestShuttle/libTestShuttle.so"); |
34 | ||
7f32679b | 35 | AliLog::SetClassDebugLevel("AliGRPPreprocessor",3); |
92e5c8ed | 36 | Int_t kRun = 7; |
37 | AliTestShuttle* shuttle = new AliTestShuttle(kRun, 1, 10); | |
38 | ||
e75e6e01 | 39 | AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB"); |
40 | AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestReference"); | |
92e5c8ed | 41 | |
42 | printf("Test OCDB storage Uri: %s\n", AliShuttleInterface::GetMainCDB().Data()); | |
43 | printf("Test Reference storage Uri: %s\n", AliShuttleInterface::GetMainRefStorage().Data()); | |
44 | ||
e75e6e01 | 45 | // setting runtype |
46 | shuttle->SetInputRunType(runtype); | |
92e5c8ed | 47 | |
e75e6e01 | 48 | // simulating DCS DPs |
49 | TMap* dcsAliasMap = CreateDCSAliasMap(errorLevel); | |
92e5c8ed | 50 | shuttle->SetDCSInput(dcsAliasMap); |
51 | ||
e75e6e01 | 52 | // simulating input from DAQ FXS |
53 | if (errorLevel != 2){ | |
7f32679b | 54 | // $ALICE_ROT to be expanded manually by the user for this test macro |
55 | shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "Period_LHC09c_TPC.Seq_0.tag.root", "GDC35", "$ALICE_ROOT/GRP/ShuttleInput/run000080740_GRP_gdc-aldaqpc035_Period_LHC09c.Seq_0.tag.root"); | |
56 | shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "Period_LHC09c_TPC.Seq_0.tag.root", "GDC36", "$ALICE_ROOT/GRP/ShuttleInput/run000080740_GRP_gdc-aldaqpc036_Period_LHC09c.Seq_0.tag.root"); | |
57 | shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "Period_LHC09c_TPC.Seq_0.tag.root", "GDC44", "$ALICE_ROOT/GRP/ShuttleInput/run000080740_GRP_gdc-aldaqpc044_Period_LHC09c.Seq_0.tag.root"); | |
58 | shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "Period_LHC09c_TPC.Seq_0.tag.root", "GDC45", "$ALICE_ROOT/GRP/ShuttleInput/run000080740_GRP_gdc-aldaqpc045_Period_LHC09c.Seq_0.tag.root"); | |
e75e6e01 | 59 | |
60 | } | |
61 | ||
62 | // simulating input from DCS FXS | |
63 | if (errorLevel != 4 && !partition.IsNull() && detector.IsNull()){ | |
64 | shuttle->AddInputFile(AliShuttleInterface::kDCS, "GRP", "CTP_xcounters", "", gSystem->ExpandPathName("$ALICE_ROOT/GRP/CTP/xcounters.txt")); | |
65 | } | |
66 | ||
e3efae04 | 67 | Char_t * filename = gSystem->ExpandPathName("$ALICE_ROOT/GRP/CTP/p-p.cfg"); |
68 | ifstream is; | |
69 | is.open(filename); | |
70 | is.seekg(0,ios::end); | |
71 | int length = is.tellg(); | |
72 | const char *buffer = new char[length]; | |
73 | is.seekg(0,ios::beg); | |
74 | is.read(buffer,length); | |
75 | is.close(); | |
e75e6e01 | 76 | const char *emptybuffer = NULL; |
92e5c8ed | 77 | |
e75e6e01 | 78 | // simulating input from DAQ logbook_trigger_config |
7f32679b | 79 | if (errorLevel != 3 && errorLevel != 7 && !partition.IsNull() && detector.IsNull()) { |
80 | cout << " adding trigger config " << endl; | |
81 | shuttle->SetInputTriggerConfiguration(buffer); | |
e75e6e01 | 82 | } |
83 | else if (errorLevel == 7) { | |
84 | shuttle->SetInputTriggerConfiguration(emptybuffer); | |
85 | } | |
e3efae04 | 86 | |
e75e6e01 | 87 | // simulating input from DAQ logbook |
88 | if (errorLevel != 1){ | |
89 | shuttle->AddInputRunParameter("DAQ_time_start", "1233213.22"); | |
90 | } | |
91 | if (errorLevel != 6){ | |
92 | shuttle->AddInputRunParameter("beamEnergy", "1400."); | |
93 | } | |
94 | ||
95 | shuttle->AddInputRunParameter("DAQ_time_end", "1345645.22"); | |
96 | shuttle->AddInputRunParameter("beamType", beamType); | |
92e5c8ed | 97 | shuttle->AddInputRunParameter("numberOfDetectors", "5"); |
98 | shuttle->AddInputRunParameter("detectorMask", "34555"); | |
99 | shuttle->AddInputRunParameter("LHCperiod", "LHC08b"); | |
e75e6e01 | 100 | shuttle->AddInputRunParameter("partition",partition); |
101 | shuttle->AddInputRunParameter("detector",detector); | |
92e5c8ed | 102 | |
e75e6e01 | 103 | // simulating HLT |
92e5c8ed | 104 | Bool_t hltStatus = kTRUE; |
105 | shuttle->SetInputHLTStatus(hltStatus); | |
106 | ||
92e5c8ed | 107 | // Create the preprocessor that should be tested, it registers itself automatically to the shuttle |
108 | AliPreprocessor* test = new AliGRPPreprocessor(shuttle); | |
109 | ||
110 | // Test the preprocessor | |
111 | shuttle->Process(); | |
112 | ||
113 | printf("\n\n"); | |
114 | ||
92e5c8ed | 115 | // Check the file which should have been created |
116 | AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB()) | |
117 | ->Get("GRP/GRP/Data", kRun); | |
118 | if (!chkEntry) { | |
119 | printf("The file is not there. Something went wrong.\n"); | |
120 | return; | |
121 | } | |
122 | chkEntry->PrintId(); | |
123 | chkEntry->GetObject()->Print(); | |
124 | printf("\n\n"); | |
125 | ||
92e5c8ed | 126 | } |
127 | ||
e75e6e01 | 128 | TMap* CreateDCSAliasMap(Int_t errorLevel) |
92e5c8ed | 129 | { |
130 | // Creates a DCS structure | |
131 | // The structure is the following: | |
e75e6e01 | 132 | // TMap (key --> value) |
133 | // <DCSAlias> --> <valueList> | |
134 | // <DCSAlias> is a string | |
135 | // <valueList> is a TObjArray of AliDCSValue | |
136 | // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue | |
92e5c8ed | 137 | |
e75e6e01 | 138 | const Int_t fgknDCSDP = 50; |
92e5c8ed | 139 | const char* fgkDCSDataPoints[AliGRPPreprocessor::fgknDCSDP] = { |
e75e6e01 | 140 | "LHCState", // missing in DCS |
92e5c8ed | 141 | "L3Polarity", |
142 | "DipolePolarity", | |
e75e6e01 | 143 | "LHCLuminosity", // missing in DCS |
144 | "BeamIntensity", // missing in DCS | |
92e5c8ed | 145 | "L3Current", |
146 | "DipoleCurrent", | |
e75e6e01 | 147 | "L3_BSF17_H1", |
148 | "L3_BSF17_H2", | |
149 | "L3_BSF17_H3", | |
150 | "L3_BSF17_Temperature", | |
151 | "L3_BSF4_H1", | |
152 | "L3_BSF4_H2", | |
153 | "L3_BSF4_H3", | |
154 | "L3_BSF4_Temperature", | |
155 | "L3_BKF17_H1", | |
156 | "L3_BKF17_H2", | |
157 | "L3_BKF17_H3", | |
158 | "L3_BKF17_Temperature", | |
159 | "L3_BKF4_H1", | |
160 | "L3_BKF4_H2", | |
161 | "L3_BKF4_H3", | |
162 | "L3_BKF4_Temperature", | |
163 | "L3_BSF13_H1", | |
164 | "L3_BSF13_H2", | |
165 | "L3_BSF13_H3", | |
166 | "L3_BSF13_Temperature", | |
167 | "L3_BSF8_H1", | |
168 | "L3_BSF8_H2", | |
169 | "L3_BSF8_H3", | |
170 | "L3_BSF8_Temperature", | |
171 | "L3_BKF13_H1", | |
172 | "L3_BKF13_H2", | |
173 | "L3_BKF13_H3", | |
174 | "L3_BKF13_Temperature", | |
175 | "L3_BKF8_H1", | |
176 | "L3_BKF8_H2", | |
177 | "L3_BKF8_H3", | |
178 | "L3_BKF8_Temperature", | |
179 | "Dipole_Inside_H1", | |
180 | "Dipole_Inside_H2", | |
181 | "Dipole_Inside_H3", | |
182 | "Dipole_Inside_Temperature", | |
183 | "Dipole_Outside_H1", | |
184 | "Dipole_Outside_H2", | |
185 | "Dipole_Outside_H3", | |
186 | "Dipole_Outside_Temperature", | |
92e5c8ed | 187 | "CavernTemperature", |
188 | "CavernAtmosPressure", | |
649b8dcf | 189 | "SurfaceAtmosPressure" |
92e5c8ed | 190 | }; |
191 | ||
192 | TMap* aliasMap; | |
193 | TObjArray* valueSet; | |
194 | AliDCSValue* dcsVal; | |
195 | ||
196 | aliasMap = new TMap; | |
197 | aliasMap->SetOwner(1); | |
198 | ||
199 | // LHCState | |
200 | valueSet = new TObjArray; | |
201 | valueSet->SetOwner(1); | |
e75e6e01 | 202 | dcsVal = new AliDCSValue( 'F', 2 ); |
92e5c8ed | 203 | valueSet->Add(dcsVal); |
e75e6e01 | 204 | aliasMap->Add( new TObjString(fgkDCSDataPoints[0]), valueSet ); |
92e5c8ed | 205 | |
206 | // L3Polarity | |
207 | valueSet = new TObjArray; | |
208 | valueSet->SetOwner(1); | |
e75e6e01 | 209 | dcsVal = new AliDCSValue( kTRUE, 2 ); |
92e5c8ed | 210 | valueSet->Add(dcsVal); |
dba333ae | 211 | // add the following two lines to test errors for changing polarity |
212 | // dcsVal = new AliDCSValue( kFALSE, 2 ); | |
213 | // valueSet->Add(dcsVal); | |
92e5c8ed | 214 | aliasMap->Add( new TObjString(fgkDCSDataPoints[1]), valueSet ); |
215 | ||
216 | // DipolePolarity | |
217 | valueSet = new TObjArray; | |
218 | valueSet->SetOwner(1); | |
e75e6e01 | 219 | dcsVal = new AliDCSValue( kTRUE, 2 ); |
92e5c8ed | 220 | valueSet->Add(dcsVal); |
221 | aliasMap->Add( new TObjString(fgkDCSDataPoints[2]), valueSet ); | |
222 | ||
223 | TRandom random; | |
224 | ||
e75e6e01 | 225 | Int_t maxDPindex = 0; |
226 | if (errorLevel != 5) { | |
227 | maxDPindex = fgknDCSDP; | |
228 | } | |
229 | else { | |
230 | maxDPindex = 3; // simulating only a few DP in case errorLevel=5 | |
231 | } | |
232 | ||
233 | for( int nAlias=3; nAlias<maxDPindex; nAlias++) { | |
234 | if (nAlias>=7 && nAlias < 47) continue; | |
92e5c8ed | 235 | valueSet = new TObjArray; |
236 | valueSet->SetOwner(1); | |
237 | ||
e75e6e01 | 238 | for (int timeStamp=0; timeStamp<10; timeStamp++) { |
239 | dcsVal = new AliDCSValue((Float_t) (timeStamp+1+10*nAlias), timeStamp+1); | |
92e5c8ed | 240 | valueSet->Add(dcsVal); |
241 | } | |
242 | aliasMap->Add( new TObjString( fgkDCSDataPoints[nAlias]), valueSet ); | |
243 | } | |
244 | ||
e75e6e01 | 245 | // Hall Probes |
246 | TString probe1[3] = {"L3_BSF","L3_BKF","Dipole_"}; | |
247 | TString probe2[6] = {"17_","4_","13_","8_","Inside_","Outside_"}; | |
248 | TString probe3[4] = {"H1","H2","H3","Temperature"}; | |
249 | Int_t hp = 0; | |
250 | ||
251 | for (Int_t i=0;i<3;i++){ | |
252 | for (Int_t j=0;j<6;j++){ | |
253 | for (Int_t k=0;k<4;k++){ | |
254 | TString dpAlias = probe1[i]+probe2[j]+probe3[k]; | |
255 | valueSet = new TObjArray; | |
256 | valueSet->SetOwner(1); | |
257 | for (int timeStamp=0; timeStamp<10; timeStamp++) { | |
258 | dcsVal = new AliDCSValue((Float_t) (timeStamp+1+10*hp), timeStamp+1); | |
259 | valueSet->Add(dcsVal); | |
260 | //cout << " hall probe = " << dpAlias << " with value = " << dcsVal->GetFloat() << endl; | |
261 | } | |
262 | aliasMap->Add( new TObjString(dpAlias), valueSet ); | |
263 | hp++; | |
264 | } | |
265 | } | |
266 | } | |
267 | ||
92e5c8ed | 268 | return aliasMap; |
269 | } | |
270 | ||
271 | /* | |
272 | TMap* ReadDCSAliasMap() | |
273 | { | |
274 | // Open a file that contains DCS input data | |
275 | // The CDB framework is used to open the file, this means the file is located | |
276 | // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data | |
277 | // The file contains an AliCDBEntry that contains a TMap with the DCS structure. | |
278 | // An explanation of the structure can be found in CreateDCSAliasMap() | |
279 | ||
280 | AliCDBEntry *entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB()) | |
281 | ->Get("DET/DCS/Data", 0); | |
282 | return dynamic_cast<TMap*> (entry->GetObject()); | |
283 | } | |
284 | */ | |
285 | ||
286 | ||
287 | void WriteDCSAliasMap() | |
288 | { | |
289 | // This writes the output from CreateDCSAliasMap to a CDB file | |
290 | ||
e75e6e01 | 291 | TMap* dcsAliasMap = CreateDCSAliasMap(Int_t errorLevel); |
92e5c8ed | 292 | |
293 | AliCDBMetaData metaData; | |
294 | metaData.SetBeamPeriod(0); | |
295 | metaData.SetResponsible("Ernesto Lopez Torres"); | |
296 | metaData.SetComment("Test object for TestGRPPreprocessor.C"); | |
297 | ||
298 | AliCDBId id("GRP/Data", 0, 0); | |
299 | ||
300 | // look into AliTestShuttle's CDB main folder | |
301 | ||
302 | AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB()) | |
303 | ->Put(dcsAliasMap, id, &metaData); | |
304 | } |