]>
Commit | Line | Data |
---|---|---|
33c82fbf | 1 | /************************************************************************** |
3dedb44a | 2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
7ca4655f | 16 | /* $Id$ */ |
17 | ||
3dedb44a | 18 | //------------------------------------------------------------------------- |
19 | // Class AliGRPPreprocessor | |
20 | // Global Run Parameters (GRP) preprocessor | |
21 | // Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch | |
e7a6790f | 22 | // Modified: Ernesto.Lopez.Torres@cern.ch CEADEN-CERN |
3dedb44a | 23 | //------------------------------------------------------------------------- |
24 | ||
836d8b4f | 25 | #include <TChain.h> |
7ca4655f | 26 | #include <TList.h> |
27 | #include <TMap.h> | |
28 | #include <TObjString.h> | |
44e45fac | 29 | #include <TGraph.h> |
7ca4655f | 30 | |
3dedb44a | 31 | #include "AliGRPPreprocessor.h" |
44e45fac | 32 | #include "AliGRPObject.h" |
33 | #include "AliDCSSensor.h" | |
34 | #include "AliSplineFit.h" | |
17984b61 | 35 | #include "AliDCSSensorArray.h" |
3dedb44a | 36 | |
48b1b444 | 37 | #include "AliTriggerConfiguration.h" |
38 | #include "AliTriggerRunScalers.h" | |
39 | ||
3dedb44a | 40 | #include "AliCDBMetaData.h" |
41 | #include "AliLog.h" | |
42 | ||
3dedb44a | 43 | class AliDCSValue; |
44 | class AliShuttleInterface; | |
45 | ||
1e27bb6b | 46 | // needed for ReceivePromptRecoParameters |
39e3007b | 47 | |
1e27bb6b | 48 | #include <TSQLServer.h> |
49 | #include <TSQLResult.h> | |
50 | #include <TSQLRow.h> | |
51 | #include <AliCDBManager.h> | |
52 | #include <AliCDBMetaData.h> | |
53 | #include <AliCDBId.h> | |
54 | #include <AliTriggerConfiguration.h> | |
55 | ||
17984b61 | 56 | const Double_t kFitFraction = 0.7; // Fraction of DCS sensor fits required |
57 | ||
3dedb44a | 58 | ClassImp(AliGRPPreprocessor) |
59 | ||
17984b61 | 60 | //_______________________________________________________________ |
44e45fac | 61 | |
e7a6790f | 62 | const Int_t AliGRPPreprocessor::fgknDAQLbPar = 8; // num parameters in the logbook |
44e45fac | 63 | const Int_t AliGRPPreprocessor::fgknDCSDP = 50; // number of dcs dps |
39e3007b | 64 | const Int_t AliGRPPreprocessor::fgknDCSDPHallProbes = 40; // number of dcs dps |
e7a6790f | 65 | const char* AliGRPPreprocessor::fgkDCSDataPoints[AliGRPPreprocessor::fgknDCSDP] = { |
1676baf1 | 66 | "LHCState", // missing in DCS |
e7a6790f | 67 | "L3Polarity", |
68 | "DipolePolarity", | |
1676baf1 | 69 | "LHCLuminosity", // missing in DCS |
70 | "BeamIntensity", // missing in DCS | |
e7a6790f | 71 | "L3Current", |
72 | "DipoleCurrent", | |
44e45fac | 73 | "L3_BSF17_H1", |
74 | "L3_BSF17_H2", | |
75 | "L3_BSF17_H3", | |
76 | "L3_BSF17_Temperature", | |
77 | "L3_BSF4_H1", | |
78 | "L3_BSF4_H2", | |
79 | "L3_BSF4_H3", | |
80 | "L3_BSF4_Temperature", | |
81 | "L3_BKF17_H1", | |
82 | "L3_BKF17_H2", | |
83 | "L3_BKF17_H3", | |
84 | "L3_BKF17_Temperature", | |
85 | "L3_BKF4_H1", | |
86 | "L3_BKF4_H2", | |
87 | "L3_BKF4_H3", | |
88 | "L3_BKF4_Temperature", | |
89 | "L3_BSF13_H1", | |
90 | "L3_BSF13_H2", | |
91 | "L3_BSF13_H3", | |
92 | "L3_BSF13_Temperature", | |
93 | "L3_BSF8_H1", | |
94 | "L3_BSF8_H2", | |
95 | "L3_BSF8_H3", | |
96 | "L3_BSF8_Temperature", | |
97 | "L3_BKF13_H1", | |
98 | "L3_BKF13_H2", | |
99 | "L3_BKF13_H3", | |
100 | "L3_BKF13_Temperature", | |
101 | "L3_BKF8_H1", | |
102 | "L3_BKF8_H2", | |
103 | "L3_BKF8_H3", | |
104 | "L3_BKF8_Temperature", | |
105 | "Dipole_Inside_H1", | |
106 | "Dipole_Inside_H2", | |
107 | "Dipole_Inside_H3", | |
108 | "Dipole_Inside_Temperature", | |
109 | "Dipole_Outside_H1", | |
110 | "Dipole_Outside_H2", | |
111 | "Dipole_Outside_H3", | |
112 | "Dipole_Outside_Temperature", | |
e7a6790f | 113 | "CavernTemperature", |
114 | "CavernAtmosPressure", | |
6240e6a4 | 115 | "SurfaceAtmosPressure" |
e7a6790f | 116 | }; |
44e45fac | 117 | |
39e3007b | 118 | const char* AliGRPPreprocessor::fgkDCSDataPointsHallProbes[AliGRPPreprocessor::fgknDCSDPHallProbes] = { |
44e45fac | 119 | "L3_BSF17_H1", |
120 | "L3_BSF17_H2", | |
121 | "L3_BSF17_H3", | |
122 | "L3_BSF17_Temperature", | |
123 | "L3_BSF4_H1", | |
124 | "L3_BSF4_H2", | |
125 | "L3_BSF4_H3", | |
126 | "L3_BSF4_Temperature", | |
127 | "L3_BKF17_H1", | |
128 | "L3_BKF17_H2", | |
129 | "L3_BKF17_H3", | |
130 | "L3_BKF17_Temperature", | |
131 | "L3_BKF4_H1", | |
132 | "L3_BKF4_H2", | |
133 | "L3_BKF4_H3", | |
134 | "L3_BKF4_Temperature", | |
135 | "L3_BSF13_H1", | |
136 | "L3_BSF13_H2", | |
137 | "L3_BSF13_H3", | |
138 | "L3_BSF13_Temperature", | |
139 | "L3_BSF8_H1", | |
140 | "L3_BSF8_H2", | |
141 | "L3_BSF8_H3", | |
142 | "L3_BSF8_Temperature", | |
143 | "L3_BKF13_H1", | |
144 | "L3_BKF13_H2", | |
145 | "L3_BKF13_H3", | |
146 | "L3_BKF13_Temperature", | |
147 | "L3_BKF8_H1", | |
148 | "L3_BKF8_H2", | |
149 | "L3_BKF8_H3", | |
150 | "L3_BKF8_Temperature", | |
151 | "Dipole_Inside_H1", | |
152 | "Dipole_Inside_H2", | |
153 | "Dipole_Inside_H3", | |
154 | "Dipole_Inside_Temperature", | |
155 | "Dipole_Outside_H1", | |
156 | "Dipole_Outside_H2", | |
157 | "Dipole_Outside_H3", | |
158 | "Dipole_Outside_Temperature", | |
159 | }; | |
e7a6790f | 160 | |
44e45fac | 161 | const Short_t kSensors = 48; // start index position of sensor in DCS DPs |
162 | const Short_t kNumSensors = 2; // Number of sensors in DCS DPs | |
e7a6790f | 163 | |
164 | const char* AliGRPPreprocessor::fgkLHCState[20] = { | |
165 | "P", "PREPARE", | |
166 | "J", "PREINJECTION", | |
167 | "I", "INJECTION", | |
168 | "F", "FILLING", | |
169 | "A", "ADJUST", | |
170 | "U", "UNSTABLE BEAMS", | |
171 | "S", "STABLE BEAMS", | |
172 | "D", "BEAM DUMP", | |
173 | "R", "RECOVER", | |
174 | "C", "PRECYCLE" | |
175 | }; | |
176 | ||
177 | const char* kppError[] = { | |
178 | "", | |
179 | "(DAQ logbook ERROR)", | |
180 | "(DAQ FXS ERROR)", | |
181 | "(DCS FXS ERROR)", | |
7e1a6c0b | 182 | "(DCS data points ERROR)", |
183 | "(Trigger Configuration ERROR)" | |
e7a6790f | 184 | }; |
17984b61 | 185 | |
3dedb44a | 186 | //_______________________________________________________________ |
44e45fac | 187 | |
3dedb44a | 188 | AliGRPPreprocessor::AliGRPPreprocessor(AliShuttleInterface* shuttle): |
08a446c2 | 189 | AliPreprocessor("GRP",shuttle), fPressure(0) |
e7a6790f | 190 | { |
44e45fac | 191 | // constructor - shuttle must be instantiated! |
ad103e84 | 192 | |
44e45fac | 193 | AddRunType("PHYSICS"); |
3dedb44a | 194 | } |
195 | ||
196 | //_______________________________________________________________ | |
44e45fac | 197 | |
e7a6790f | 198 | AliGRPPreprocessor::~AliGRPPreprocessor() |
199 | { | |
44e45fac | 200 | //destructor |
201 | ||
202 | delete fPressure; | |
3dedb44a | 203 | } |
204 | ||
205 | //_______________________________________________________________ | |
44e45fac | 206 | |
e7a6790f | 207 | void AliGRPPreprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime) |
208 | { | |
3dedb44a | 209 | // Initialize preprocessor |
5a5052e5 | 210 | |
211 | AliPreprocessor::Initialize(run, startTime, endTime); | |
e7a6790f | 212 | |
17984b61 | 213 | AliInfo("Initialization of the GRP preprocessor."); |
6240e6a4 | 214 | TClonesArray * array = new TClonesArray("AliDCSSensor",kNumSensors); |
215 | for(Int_t j = 0; j < kNumSensors; j++) { | |
17984b61 | 216 | AliDCSSensor * sens = new ((*array)[j])AliDCSSensor; |
e7a6790f | 217 | sens->SetStringID(fgkDCSDataPoints[j+kSensors]); |
17984b61 | 218 | } |
219 | AliInfo(Form("Pressure Entries: %d",array->GetEntries())); | |
220 | ||
563f2a84 | 221 | // fPressure = new AliDCSSensorArray(fStartTime, fEndTime, array); |
222 | fPressure = new AliDCSSensorArray(GetStartTimeDCSQuery(), GetEndTimeDCSQuery(), array); | |
3dedb44a | 223 | } |
224 | ||
225 | //_______________________________________________________________ | |
44e45fac | 226 | |
e7a6790f | 227 | UInt_t AliGRPPreprocessor::Process(TMap* valueMap) |
228 | { | |
44e45fac | 229 | // process data retrieved by the Shuttle |
230 | ||
231 | AliGRPObject *grpobj = new AliGRPObject(); // object to store data | |
232 | ||
233 | //=================// | |
234 | // DAQ logbook // | |
235 | //=================// | |
236 | UInt_t error = 0; | |
237 | ||
238 | grpobj = ProcessDaqLB(); | |
239 | ||
240 | //=================// | |
241 | // DAQ FXS // | |
242 | //=================// | |
243 | UInt_t iDaqFxs = ProcessDaqFxs(); | |
244 | if( iDaqFxs == 0 ) { | |
245 | Log(Form("DAQ FXS, successful!")); | |
246 | } else { | |
247 | Log(Form("DAQ FXS, could not store run raw tag file!!!")); | |
248 | error |= 2; | |
249 | } | |
250 | ||
251 | //=================// | |
252 | // DCS FXS // | |
253 | //=================// | |
254 | UInt_t iDcsFxs = ProcessDcsFxs(); | |
255 | if( iDcsFxs == 0 ) { | |
256 | Log(Form("DCS FXS, successful!")); | |
257 | } else { | |
258 | Log(Form("DCS FXS, Could not store CTP run configuration and scalers!!!")); | |
259 | error |= 4; | |
260 | } | |
261 | ||
262 | //=================// | |
263 | // DCS data points // | |
264 | //=================// | |
7e6f5523 | 265 | Log(Form("Starting DCS Query at %d and finishing at %d",GetStartTimeDCSQuery(),GetEndTimeDCSQuery())); |
44e45fac | 266 | Int_t entries = ProcessDcsDPs( valueMap, grpobj ); |
7e6f5523 | 267 | Log(Form("entries found = %d",entries)); |
268 | if( entries < fgknDCSDP-7 ) { // FIXME (!= ) LHState and pressure map are not working yet... and removing the 4 values for the missing HP | |
44e45fac | 269 | Log(Form("Problem with the DCS data points!!!")); |
270 | error |= 8; | |
271 | } else Log(Form("DCS data points, successful!")); | |
272 | ||
273 | //=======================// | |
274 | // Trigger Configuration // | |
275 | //=======================// | |
276 | // either from DAQ logbook..... | |
277 | const char * triggerConf = GetTriggerConfiguration(); | |
278 | if (triggerConf!= NULL) { | |
279 | Log("Found trigger configuration in DAQ logbook"); | |
280 | AliTriggerConfiguration *runcfg = AliTriggerConfiguration::LoadConfigurationFromString(triggerConf); | |
281 | if (!runcfg) { | |
282 | Log("Bad CTP run configuration file from DAQ logbook! The corresponding CDB entry will not be filled!"); | |
283 | error |= 16; | |
284 | } | |
285 | else { | |
286 | TString titleCTPcfg = Form("CTP cfg for run %i from DAQ",fRun); | |
287 | runcfg->SetTitle(titleCTPcfg); | |
288 | AliCDBMetaData metaData; | |
289 | metaData.SetBeamPeriod(0); | |
290 | metaData.SetResponsible("Roman Lietava"); | |
291 | metaData.SetComment("CTP run configuration from DAQ logbook"); | |
292 | if (!Store("CTP","Config", runcfg, &metaData, 0, 0)) { | |
293 | Log("Unable to store the CTP run configuration object to OCDB!"); | |
294 | error |= 16; | |
295 | } | |
296 | } | |
297 | } | |
298 | /* the DCS should not been used any more to access this stuff!!! | |
299 | // ...or from DCS FXS | |
300 | else{ | |
301 | Log("No trigger configuration found in the DAQ logbook!! Trying reading from DCS FXS..."); | |
302 | TString runcfgfile = GetFile(kDCS, "CTP_runconfig", ""); | |
303 | if (runcfgfile.IsNull()) { | |
304 | Log("No CTP runconfig files has been found in DCS FXS!"); | |
305 | error |= 16; | |
306 | } | |
307 | else { | |
308 | Log(Form("File with Id CTP_runconfig found! Copied to %s",runcfgfile.Data())); | |
309 | AliTriggerConfiguration *runcfg = AliTriggerConfiguration::LoadConfiguration(runcfgfile); | |
310 | if (!runcfg) { | |
311 | Log("Bad CTP run configuration file from DCS FXS! The corresponding CDB entry will not be filled!"); | |
312 | error |= 16;; | |
313 | } | |
314 | else { | |
315 | TString titleCTPcfg = Form("CTP cfg for run %i from DCS",fRun); | |
316 | runcfg->SetTitle(titleCTPcfg); | |
317 | AliCDBMetaData metaData; | |
318 | metaData.SetBeamPeriod(0); | |
319 | metaData.SetResponsible("Roman Lietava"); | |
320 | metaData.SetComment("CTP run configuration from DCS FXS"); | |
321 | if (!Store("CTP","Config", runcfg, &metaData, 0, 0)) { | |
322 | Log("Unable to store the CTP run configuration object to OCDB!"); | |
323 | error |= 16; | |
324 | } | |
325 | } | |
326 | } | |
327 | } | |
328 | */ | |
329 | AliCDBMetaData md; | |
330 | md.SetResponsible("Ernesto Lopez Torres"); | |
331 | md.SetComment("Output parameters from the GRP preprocessor."); | |
332 | ||
333 | Bool_t result = kTRUE; | |
334 | Log("Before storing"); | |
335 | result = Store("GRP", "Data", grpobj, &md); | |
336 | delete grpobj; | |
337 | ||
338 | if (result && !error ) { | |
339 | Log("GRP Preprocessor Success"); | |
340 | return 0; | |
341 | } else { | |
342 | Log( Form("GRP Preprocessor FAILS!!! %s%s%s%s%s", | |
343 | kppError[(error&1)?1:0], | |
344 | kppError[(error&2)?2:0], | |
345 | kppError[(error&4)?3:0], | |
346 | kppError[(error&8)?4:0], | |
347 | kppError[(error&16)?5:0] | |
348 | )); | |
349 | return error; | |
350 | } | |
17984b61 | 351 | } |
352 | ||
17984b61 | 353 | //_______________________________________________________________ |
17984b61 | 354 | |
44e45fac | 355 | AliGRPObject* AliGRPPreprocessor::ProcessDaqLB() |
356 | { | |
357 | //Getting the DAQ lb information | |
358 | ||
359 | time_t timeStart = (time_t)(((TString)GetRunParameter("DAQ_time_start")).Atoi()); | |
360 | time_t timeEnd = (time_t)(((TString)GetRunParameter("DAQ_time_end")).Atoi()); | |
361 | Float_t beamEnergy = (Float_t)(((TString)GetRunParameter("beamEnergy")).Atof()); | |
362 | TString beamType = (TString)GetRunParameter("beamType"); | |
363 | Char_t numberOfDetectors = (Char_t)(((TString)GetRunParameter("numberOfDetectors")).Atoi()); | |
364 | UInt_t detectorMask= (UInt_t)(((TString)GetRunParameter("detectorMask")).Atoi()); | |
365 | TString lhcPeriod = (TString)GetRunParameter("LHCperiod"); | |
366 | TString runType = (TString)GetRunType(); | |
367 | ||
368 | AliGRPObject* grpObj = new AliGRPObject(); | |
369 | ||
370 | if (timeStart != 0){ | |
371 | grpObj->SetTimeStart(timeStart); | |
372 | Log(Form("Start time for run %d: %d",fRun, (Int_t)timeStart)); | |
373 | } | |
374 | else { | |
375 | Log(Form("Start time not put in logbook, setting to invalid in GRP entry!")); | |
376 | } | |
377 | ||
378 | if (timeEnd != 0){ | |
379 | grpObj->SetTimeEnd(timeEnd); | |
380 | Log(Form("End time for run %d: %i",fRun, (Int_t)timeEnd)); | |
381 | } | |
382 | else { | |
383 | Log(Form("End time not put in logbook, setting to invalid in GRP entry!")); | |
384 | } | |
385 | ||
386 | if (beamEnergy != 0){ | |
387 | grpObj->SetBeamEnergy(beamEnergy); | |
388 | Log(Form("Beam Energy for run %d: %f",fRun, beamEnergy)); | |
389 | } | |
390 | else { | |
391 | Log(Form("Beam Energy not put in logbook, setting to invalid in GRP entry!")); | |
392 | } | |
393 | ||
394 | Log(Form("Beam Type for run %d: %s",fRun, beamType.Data())); | |
395 | ||
396 | if (beamType.Length() != 0){ | |
397 | grpObj->SetBeamType(beamType); | |
398 | Log(Form("Beam Type for run %d: %s",fRun, beamType.Data())); | |
399 | } | |
400 | else { | |
401 | Log(Form("Beam Type not put in logbook, setting to invalid in GRP entry!")); | |
402 | } | |
403 | ||
404 | if (numberOfDetectors != 0){ | |
405 | grpObj->SetNumberOfDetectors(numberOfDetectors); | |
406 | Log(Form("Number Of Detectors for run %d: %d",fRun, (Int_t)numberOfDetectors)); | |
407 | } | |
408 | else { | |
409 | Log(Form("Number Of Detectors not put in logbook, setting to invalid in GRP entry!")); | |
410 | } | |
411 | ||
412 | if (detectorMask != 0){ | |
413 | grpObj->SetDetectorMask(detectorMask); | |
414 | Log(Form("Detector Mask for run %d: %d",fRun, detectorMask)); | |
415 | } | |
416 | else { | |
417 | Log(Form("Detector Mask not put in logbook, setting to invalid in GRP entry!")); | |
418 | } | |
419 | ||
420 | if (lhcPeriod.Length() != 0) { | |
421 | grpObj->SetLHCPeriod(lhcPeriod); | |
422 | Log(Form("LHC period (DAQ) for run %d: %s",fRun, lhcPeriod.Data())); | |
423 | } else { | |
424 | Log(Form("LHCperiod not put in logbook, setting to invalid in GRP entry!")); | |
425 | } | |
426 | if (runType.Length() != 0) { | |
427 | grpObj->SetRunType(runType); | |
428 | Log(Form("Run Type (DAQ) for run %d: %s",fRun, runType.Data())); | |
429 | } else { | |
430 | Log(Form("Run Type not put in logbook, setting to invalid in GRP entry!")); | |
431 | } | |
432 | ||
433 | return grpObj; | |
434 | } | |
17984b61 | 435 | |
44e45fac | 436 | //_______________________________________________________________ |
17984b61 | 437 | |
44e45fac | 438 | UInt_t AliGRPPreprocessor::ProcessDaqFxs() |
439 | { | |
440 | //======DAQ FXS======// | |
441 | ||
442 | TList* list = GetFileSources(kDAQ); | |
443 | if (!list) { | |
444 | Log("No raw data tag list: connection problems with DAQ FXS logbook!"); | |
445 | return 1; | |
446 | } | |
447 | ||
448 | if (list->GetEntries() == 0) { | |
449 | Log("no raw data tags in this run: nothing to merge!"); | |
450 | delete list; list=0; | |
451 | return 0; | |
452 | } | |
453 | ||
454 | TChain *fRawTagChain = new TChain("T"); | |
455 | Int_t nFiles=0; | |
456 | TIterator* iter = list->MakeIterator(); | |
457 | TObject* obj = 0; | |
458 | while ((obj = iter->Next())) { | |
459 | TObjString* objStr = dynamic_cast<TObjString*> (obj); | |
460 | if (objStr) { | |
461 | Log(Form("Found source %s", objStr->String().Data())); | |
462 | TList* list2 = GetFileIDs(kDAQ, objStr->String()); | |
463 | if (!list2) { | |
464 | Log("No list with ids from DAQ was found: connection problems with DAQ FXS logbook!"); | |
465 | delete fRawTagChain; fRawTagChain=0; | |
466 | return 1; | |
467 | } | |
468 | Log(Form("Number of ids: %d",list2->GetEntries())); | |
469 | for(Int_t i = 0; i < list2->GetEntries(); i++) { | |
470 | TObjString *idStr = (TObjString *)list2->At(i); | |
471 | TString fileName = GetFile(kDAQ,idStr->String().Data(),objStr->String().Data()); | |
472 | if (fileName.Length() > 0) { | |
473 | Log(Form("Adding file in the chain: %s",fileName.Data())); | |
474 | fRawTagChain->Add(fileName.Data()); | |
475 | nFiles++; | |
476 | } else { | |
477 | Log(Form("Could not retrieve file with id %s from source %s: " | |
478 | "connection problems with DAQ FXS!", | |
479 | idStr->String().Data(), objStr->String().Data())); | |
480 | delete list; list=0; | |
481 | delete list2; list2=0; | |
482 | delete fRawTagChain; fRawTagChain=0; | |
483 | return 2; | |
484 | } | |
485 | } | |
486 | delete list2; | |
487 | } | |
488 | } | |
489 | ||
490 | TString fRawDataFileName = "GRP_Merged.tag.root"; | |
491 | Log(Form("Merging %d raw data tags into file: %s", nFiles, fRawDataFileName.Data())); | |
7e6f5523 | 492 | |
44e45fac | 493 | if( fRawTagChain->Merge(fRawDataFileName) < 1 ) { |
494 | Log("Error merging raw data files!!!"); | |
495 | return 3; | |
496 | } | |
7e6f5523 | 497 | |
44e45fac | 498 | TString outputfile = Form("Run%d.Merged.RAW.tag.root", fRun); |
499 | Bool_t result = StoreRunMetadataFile(fRawDataFileName.Data(),outputfile.Data()); | |
500 | ||
501 | if (!result) { | |
502 | Log("Problem storing raw data tags in local file!!!"); | |
503 | } else { | |
504 | Log("Raw data tags merged successfully!!"); | |
505 | } | |
506 | ||
507 | delete iter; | |
508 | delete list; | |
509 | delete fRawTagChain; fRawTagChain=0; | |
510 | ||
511 | if (result == kFALSE) { | |
512 | return 4; | |
513 | } | |
514 | ||
515 | return 0; | |
516 | ||
517 | } | |
17984b61 | 518 | |
44e45fac | 519 | //_______________________________________________________________ |
520 | UInt_t AliGRPPreprocessor::ProcessDcsFxs() | |
521 | { | |
39e3007b | 522 | |
523 | // processing the info | |
524 | // stored in the DCS FXS | |
525 | // coming from the trigger | |
526 | ||
44e45fac | 527 | { |
528 | // Get the CTP counters information | |
529 | TList* list = GetFileSources(kDCS,"CTP_xcounters"); | |
530 | if (!list) { | |
531 | Log("No CTP counters file: connection problems with DAQ FXS logbook!"); | |
532 | return 1; | |
533 | } | |
534 | ||
535 | if (list->GetEntries() == 0) { | |
536 | Log("No CTP counters file to be processed!"); | |
537 | return 1; | |
538 | } | |
539 | else { | |
540 | TIter iter(list); | |
541 | TObjString *source; | |
542 | while ((source = dynamic_cast<TObjString *> (iter.Next()))) { | |
543 | TString countersfile = GetFile(kDCS, "CTP_xcounters", source->GetName()); | |
544 | if (countersfile.IsNull()) { | |
545 | Log("No CTP counters files has been found: empty source!"); | |
546 | } | |
547 | else { | |
548 | Log(Form("File with Id CTP_xcounters found in source %s! Copied to %s",source->GetName(),countersfile.Data())); | |
549 | AliTriggerRunScalers *scalers = AliTriggerRunScalers::ReadScalers(countersfile); | |
550 | if (!scalers) { | |
551 | Log("Bad CTP counters file! The corresponding CDB entry will not be filled!"); | |
552 | return 1; | |
553 | } | |
554 | else { | |
555 | AliCDBMetaData metaData; | |
556 | metaData.SetBeamPeriod(0); | |
557 | metaData.SetResponsible("Roman Lietava"); | |
558 | metaData.SetComment("CTP scalers"); | |
559 | if (!Store("CTP","Scalers", scalers, &metaData, 0, 0)) { | |
560 | Log("Unable to store the CTP scalers object to OCDB!"); | |
561 | } | |
562 | } | |
563 | } | |
564 | } | |
565 | } | |
566 | delete list; | |
567 | } | |
568 | ||
569 | return 0; | |
570 | } | |
571 | //_______________________________________________________________ | |
17984b61 | 572 | |
44e45fac | 573 | Int_t AliGRPPreprocessor::ProcessDcsDPs(TMap* valueMap, AliGRPObject* grpObj) |
574 | { | |
17984b61 | 575 | |
44e45fac | 576 | // |
577 | // processing DCS DPs | |
578 | // | |
579 | ||
26c1dff2 | 580 | Int_t entries = 0; // counting the entries that are in the DCS DB, not taking care whether they have values or not |
44e45fac | 581 | Int_t nLHCEntries = 0; |
582 | Int_t nL3Entries = 0; | |
583 | Int_t nDipoleEntries = 0; | |
584 | Int_t nEnvEntries = 0; | |
585 | Int_t nHallProbesEntries = 0; | |
586 | nLHCEntries = ProcessLHCDPs(valueMap, grpObj); | |
587 | nL3Entries = ProcessL3DPs(valueMap, grpObj); | |
588 | nDipoleEntries = ProcessDipoleDPs(valueMap, grpObj); | |
589 | nEnvEntries = ProcessEnvDPs(valueMap, grpObj); | |
590 | nHallProbesEntries = ProcessHPDPs(valueMap, grpObj); | |
591 | ||
592 | entries = nLHCEntries + nL3Entries + nDipoleEntries + nEnvEntries + nHallProbesEntries; | |
593 | return entries; | |
17984b61 | 594 | |
17984b61 | 595 | } |
596 | ||
597 | //_______________________________________________________________ | |
29cc8704 | 598 | |
39e3007b | 599 | Int_t AliGRPPreprocessor::ProcessL3DPs(const TMap* valueMap, AliGRPObject* grpObj) |
44e45fac | 600 | { |
39e3007b | 601 | |
602 | // processing DPs | |
603 | // related to | |
604 | // L3 info | |
605 | ||
44e45fac | 606 | Int_t nL3Entries = 0; |
607 | TObjArray *array = 0x0; | |
608 | Int_t indexDP = -1; | |
609 | ||
610 | AliInfo(Form("==========L3Polarity===========")); | |
611 | indexDP = kL3Polarity; | |
612 | array = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[indexDP]); | |
613 | if(!array) { | |
614 | Log(Form("%s not found in the map!!!",fgkDCSDataPoints[indexDP])); | |
615 | } | |
616 | else { | |
26c1dff2 | 617 | if (array->GetEntries() == 0){ |
618 | AliError(Form("No entries found in array! setting %s Polarity to invalid...",fgkDCSDataPoints[indexDP])); | |
619 | } | |
620 | else { | |
621 | Char_t charDCS = ProcessBool(array); | |
622 | grpObj->SetL3Polarity(charDCS); | |
623 | AliInfo(Form("%s set to %d",fgkDCSDataPoints[indexDP],(Int_t)(grpObj->GetL3Polarity()))); | |
624 | } | |
44e45fac | 625 | nL3Entries++; |
626 | } | |
627 | ||
628 | if (array) array = 0x0; | |
629 | ||
630 | AliInfo(Form("==========L3Current===========")); | |
631 | indexDP = kL3Current; | |
632 | array = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[indexDP]); | |
633 | if(!array) { | |
634 | Log(Form("%s not found in the map!!!",fgkDCSDataPoints[indexDP])); | |
635 | } | |
636 | else { | |
26c1dff2 | 637 | if (array->GetEntries() == 0){ |
638 | AliError(Form("No entries found in array! setting %s to invalid...",fgkDCSDataPoints[indexDP])); | |
639 | } | |
640 | else { | |
641 | Float_t *floatDCS = ProcessFloatAll(array); | |
642 | grpObj->SetL3Current(floatDCS); | |
643 | delete floatDCS; | |
644 | } | |
44e45fac | 645 | nL3Entries++; |
646 | } | |
647 | ||
648 | return nL3Entries; | |
e7a6790f | 649 | |
44e45fac | 650 | } |
651 | //_______________________________________________________________ | |
ff97356e | 652 | |
39e3007b | 653 | Int_t AliGRPPreprocessor::ProcessDipoleDPs(const TMap* valueMap, AliGRPObject* grpObj) |
44e45fac | 654 | { |
39e3007b | 655 | // processing DPs |
656 | // related to | |
657 | // the Dipole info | |
658 | ||
44e45fac | 659 | Int_t nDipoleEntries = 0; |
660 | TObjArray *array = 0x0; | |
661 | Int_t indexDP = -1; | |
662 | ||
663 | AliInfo(Form("==========DipolePolarity===========")); | |
664 | indexDP = kDipolePolarity; | |
44e45fac | 665 | array = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[indexDP]); |
44e45fac | 666 | if(!array) { |
667 | Log(Form("%s not found in the map!!!",fgkDCSDataPoints[indexDP])); | |
668 | } | |
669 | else { | |
26c1dff2 | 670 | if (array->GetEntries() == 0){ |
671 | AliError(Form("No entries found in array! setting %s to invalid...",fgkDCSDataPoints[indexDP])); | |
672 | } | |
673 | else { | |
674 | Char_t charDCS = ProcessBool(array); | |
675 | grpObj->SetDipolePolarity(charDCS); | |
676 | AliInfo(Form("%s set to %d",fgkDCSDataPoints[indexDP],(Int_t)(grpObj->GetDipolePolarity()))); | |
677 | } | |
44e45fac | 678 | nDipoleEntries++; |
679 | } | |
680 | ||
681 | if (array) array = 0x0; | |
682 | ||
683 | AliInfo(Form("==========DipoleCurrent===========")); | |
684 | indexDP = kDipoleCurrent; | |
685 | array = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[indexDP]); | |
686 | if(!array) { | |
687 | Log(Form("%s not found in the map!!!",fgkDCSDataPoints[indexDP])); | |
688 | } | |
689 | else { | |
26c1dff2 | 690 | if (array->GetEntries() == 0){ |
691 | AliError(Form("No entries found in array! setting %s to invalid...",fgkDCSDataPoints[indexDP])); | |
692 | } | |
693 | else { | |
694 | Float_t *floatDCS = ProcessFloatAll(array); | |
695 | grpObj->SetDipoleCurrent(floatDCS); | |
696 | delete floatDCS; | |
697 | } | |
44e45fac | 698 | nDipoleEntries++; |
699 | } | |
700 | ||
701 | return nDipoleEntries; | |
e7a6790f | 702 | |
44e45fac | 703 | } |
704 | //_______________________________________________________________ | |
e7a6790f | 705 | |
44e45fac | 706 | Int_t AliGRPPreprocessor::ProcessEnvDPs(TMap* valueMap, AliGRPObject* grpObj) |
707 | { | |
39e3007b | 708 | // processing DPs |
709 | // related to | |
710 | // evironment conditions (temperature, pressure) info | |
711 | ||
44e45fac | 712 | Int_t nEnvEntries = 0; |
713 | TObjArray *array = 0x0; | |
714 | Int_t indexDP = -1; | |
715 | ||
716 | AliInfo(Form("==========CavernTemperature===========")); | |
717 | indexDP = kCavernTemperature; | |
718 | array = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[indexDP]); | |
719 | if(!array) { | |
720 | Log(Form("%s not found in the map!!!",fgkDCSDataPoints[indexDP])); | |
721 | } | |
722 | else { | |
26c1dff2 | 723 | if (array->GetEntries() == 0){ |
724 | AliError(Form("No entries found in array! setting %s to invalid...",fgkDCSDataPoints[indexDP])); | |
725 | } | |
726 | else { | |
727 | Float_t *floatDCS = ProcessFloatAll(array); | |
728 | grpObj->SetCavernTemperature(floatDCS); | |
729 | delete floatDCS; | |
730 | } | |
44e45fac | 731 | nEnvEntries++; |
732 | } | |
733 | ||
734 | if (array) array = 0x0; | |
735 | ||
736 | AliInfo(Form("==========AtmosPressures (Cavern + Surface)===========")); | |
737 | AliDCSSensorArray *dcsSensorArray = GetPressureMap(valueMap); | |
738 | dcsSensorArray->Print(); | |
44e45fac | 739 | if( fPressure->NumFits()==0 ) { |
740 | Log("Problem with the pressure sensor values!!!"); | |
741 | } | |
742 | else { | |
743 | AliInfo(Form("==========CavernAtmosPressure===========")); | |
744 | indexDP = kCavernAtmosPressure; | |
745 | AliDCSSensor* sensorCavernP2 = dcsSensorArray->GetSensor(fgkDCSDataPoints[indexDP]); | |
746 | AliDebug(2,Form("sensorCavernP2 = %p", sensorCavernP2)); | |
747 | if( sensorCavernP2->GetFit() ) { | |
748 | Log(Form("<%s> for run %d: Sensor Fit found",fgkDCSDataPoints[indexDP], fRun)); | |
749 | grpObj->SetCavernAtmosPressure(sensorCavernP2); | |
750 | nEnvEntries++; | |
751 | } | |
752 | //if (sensorP2) delete sensorP2; | |
753 | else { | |
754 | Log(Form("ERROR Sensor Fit for %s not found: ", fgkDCSDataPoints[indexDP] )); | |
755 | } | |
756 | AliInfo(Form("==========SurfaceAtmosPressure===========")); | |
757 | indexDP = kSurfaceAtmosPressure; | |
758 | AliDCSSensor* sensorP2 = dcsSensorArray->GetSensor(fgkDCSDataPoints[indexDP]); | |
759 | AliDebug(2,Form("sensorP2 = %p", sensorP2)); | |
760 | if( sensorP2->GetFit() ) { | |
761 | Log(Form("<%s> for run %d: Sensor Fit found",fgkDCSDataPoints[indexDP], fRun)); | |
762 | grpObj->SetSurfaceAtmosPressure(sensorP2); | |
763 | nEnvEntries++; | |
764 | } | |
765 | //if (sensorP2) delete sensorP2; | |
766 | else { | |
767 | Log(Form("ERROR Sensor Fit for %s not found: ", fgkDCSDataPoints[indexDP] )); | |
768 | } | |
769 | ||
770 | } | |
771 | ||
772 | /* indexDP = kCavernAtmosPressure; | |
773 | array = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[indexDP]); | |
774 | if(!array) { | |
775 | Log(Form("%s not found in the map!!!",fgkDCSDataPoints[indexDP])); | |
776 | } | |
777 | else { | |
778 | Float_t *floatDCS = ProcessFloatAll(array); | |
779 | grpObj->SetCavernAtmosPressure(floatDCS); | |
780 | delete floatDCS; | |
781 | nEnvEntries++; | |
782 | } | |
783 | ||
784 | ||
785 | if (array) array = 0x0; | |
786 | ||
787 | AliInfo(Form("==========SurfaceAtmosPressure===========")); | |
788 | indexDP = kSurfaceAtmosPressure; | |
789 | AliDCSSensorArray *dcsSensorArray = GetPressureMap(valueMap); | |
790 | dcsSensorArray->Print(); | |
791 | AliInfo(Form("fPressure = %p",fPressure)); | |
792 | AliInfo(Form("dcsSensorArray = %p",dcsSensorArray)); | |
793 | if( fPressure->NumFits()==0 ) { | |
794 | Log("Problem with the pressure sensor values!!!"); | |
795 | } | |
796 | else { | |
797 | AliDCSSensor* sensorP2 = dcsSensorArray->GetSensor(fgkDCSDataPoints[indexDP]); | |
798 | AliDebug(2,Form("sensorP2 = %p", sensorP2)); | |
799 | if( sensorP2->GetFit() ) { | |
800 | Log(Form("<%s> for run %d: Sensor Fit found",fgkDCSDataPoints[indexDP], fRun)); | |
801 | grpObj->SetSurfaceAtmosPressure(sensorP2); | |
802 | nEnvEntries++; | |
803 | } | |
804 | //if (sensorP2) delete sensorP2; | |
805 | else { | |
806 | Log(Form("ERROR Sensor Fit for %s not found: ", fgkDCSDataPoints[indexDP] )); | |
807 | } | |
808 | ||
809 | } | |
810 | */ | |
811 | ||
812 | return nEnvEntries; | |
813 | } | |
814 | //_______________________________________________________________ | |
e7a6790f | 815 | |
39e3007b | 816 | Int_t AliGRPPreprocessor::ProcessHPDPs(const TMap* valueMap, AliGRPObject* grpObj) |
44e45fac | 817 | { |
39e3007b | 818 | // processing DPs |
819 | // related to | |
820 | // Hall Probes info | |
821 | ||
44e45fac | 822 | Int_t nHPEntries = 0; |
823 | TObjArray *array = 0x0; | |
824 | Int_t indexDP = -1; | |
825 | ||
39e3007b | 826 | if (fgknDCSDPHallProbes != AliGRPObject::GetNumberOfHP()){ |
827 | AliError(Form("Number of Hall probes expected in GRP Preprocessor (i.e. %d) different from number of Hall Probes foreseen in GRP object (i.e. %d). Looping on entries from GRP object anyway.", fgknDCSDPHallProbes, AliGRPObject::GetNumberOfHP())); | |
44e45fac | 828 | } |
829 | for (indexDP = 0; indexDP < AliGRPObject::GetNumberOfHP(); indexDP++){ | |
830 | AliInfo(Form("==========%s===========",AliGRPObject::GetHPDP(indexDP))); | |
831 | array = (TObjArray *)valueMap->GetValue(AliGRPObject::GetHPDP(indexDP)); | |
832 | if(!array) { | |
833 | Log(Form("%s not found in the map!!!",AliGRPObject::GetHPDP(indexDP))); | |
834 | } | |
835 | else { | |
26c1dff2 | 836 | if (array->GetEntries() == 0){ |
837 | AliError(Form("No entries found in array! setting %s to invalid...",AliGRPObject::GetHPDP(indexDP))); | |
838 | } | |
839 | else { | |
840 | Float_t *floatDCS = ProcessFloatAll(array); | |
841 | AliDebug(2,Form("value[0] = %f, value[1] = %f, value[2] = %f, value[3] = %f, value[4] = %f",floatDCS[0],floatDCS[1],floatDCS[2],floatDCS[3],floatDCS[4])); | |
842 | grpObj->SetHallProbes((AliGRPObject::DP_HallProbes)indexDP,floatDCS); | |
843 | for (Int_t kk = 0 ; kk< 5; kk++){ | |
844 | AliDebug(2,Form("HallProbe[%d][%d]=%f",indexDP,kk,grpObj->GetHallProbes((AliGRPObject::DP_HallProbes)indexDP,(AliGRPObject::Stats)kk))); | |
845 | } | |
846 | delete floatDCS; | |
44e45fac | 847 | } |
44e45fac | 848 | nHPEntries++; |
849 | } | |
850 | } | |
851 | ||
7e6f5523 | 852 | Log(Form("Hall Probes = %d ", nHPEntries)); |
853 | return nHPEntries; | |
17984b61 | 854 | } |
855 | ||
48b1b444 | 856 | //_______________________________________________________________ |
44e45fac | 857 | |
39e3007b | 858 | Int_t AliGRPPreprocessor::ProcessLHCDPs(const TMap* valueMap, AliGRPObject* grpObj) |
e7a6790f | 859 | { |
48b1b444 | 860 | |
44e45fac | 861 | // |
862 | // processing of LHC related DCS DPs, i.e.: | |
863 | // LHCState | |
864 | // LHCLuminosity | |
865 | // BeamIntensity | |
866 | // | |
867 | ||
868 | Int_t nLHCEntries = 0; | |
869 | TObjArray *array = 0x0; | |
870 | Int_t indexDP = -1; | |
871 | ||
872 | AliInfo(Form("==========LHCState===========")); | |
873 | indexDP = kLHCState; | |
874 | array = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[indexDP]); | |
875 | if(!array) { | |
876 | Log(Form("%s not found in the map!!!",fgkDCSDataPoints[indexDP])); | |
877 | } | |
878 | else { | |
26c1dff2 | 879 | if (array->GetEntries() == 0){ |
880 | AliError(Form("No entries found in array! setting %s to invalid...",fgkDCSDataPoints[indexDP])); | |
881 | } | |
882 | else { | |
883 | TString stringDCS = ProcessChar(array); | |
884 | if (stringDCS.Length()!=0) { | |
885 | Bool_t found = kFALSE; | |
886 | for( Int_t i=0; i<20; i+=2 ) { | |
887 | if( stringDCS.CompareTo(fgkLHCState[i]) == 0 ) { | |
888 | stringDCS = fgkLHCState[i+1]; | |
889 | found = kTRUE; | |
890 | break; | |
891 | } | |
44e45fac | 892 | } |
26c1dff2 | 893 | if (found){ |
894 | Log(Form("<%s> for run %d: %s",fgkDCSDataPoints[indexDP],fRun, stringDCS.Data())); | |
895 | grpObj->SetLHCState(stringDCS); | |
896 | } | |
897 | else{ | |
898 | Log(Form("%s values found not valid!",fgkDCSDataPoints[indexDP])); | |
899 | grpObj->SetLHCState(AliGRPObject::GetInvalidString()); | |
900 | } | |
44e45fac | 901 | } |
26c1dff2 | 902 | else { |
903 | Log(Form("%s not valid (null length), string set as invalid!",fgkDCSDataPoints[indexDP])); | |
44e45fac | 904 | grpObj->SetLHCState(AliGRPObject::GetInvalidString()); |
26c1dff2 | 905 | } |
44e45fac | 906 | } |
44e45fac | 907 | nLHCEntries++; |
908 | } | |
909 | ||
910 | if (array) array = 0x0; | |
911 | ||
912 | AliInfo(Form("==========LHCLuminosity===========")); | |
913 | indexDP = kLHCLuminosity; | |
914 | array = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[indexDP]); | |
915 | if(!array) { | |
916 | Log(Form("%s not found in the map!!!",fgkDCSDataPoints[indexDP])); | |
917 | } | |
918 | else { | |
26c1dff2 | 919 | if (array->GetEntries() == 0){ |
920 | AliError(Form("No entries found in array! setting %s and its Spline Fit to invalid...",fgkDCSDataPoints[indexDP])); | |
921 | } | |
922 | else { | |
923 | Float_t *floatDCS = ProcessFloatAll(array); | |
924 | grpObj->SetLHCLuminosity(floatDCS); | |
925 | delete floatDCS; | |
926 | AliSplineFit* splfit = GetSplineFit(array,fgkDCSDataPoints[indexDP]); | |
927 | grpObj->SetLHCLuminositySplineFit(splfit); | |
928 | // delete splfit; | |
929 | } | |
44e45fac | 930 | nLHCEntries++; |
931 | } | |
932 | ||
933 | if (array) array = 0x0; | |
934 | ||
935 | AliInfo(Form("==========BeamIntensity===========")); | |
936 | indexDP = kBeamIntensity; | |
937 | array = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[indexDP]); | |
938 | if(!array) { | |
939 | Log(Form("%s not found in the map!!!",fgkDCSDataPoints[indexDP])); | |
940 | } | |
941 | else { | |
26c1dff2 | 942 | if (array->GetEntries() == 0){ |
943 | AliError(Form("No entries found in array! setting %s and its Spline Fit to invalid...",fgkDCSDataPoints[indexDP])); | |
944 | } | |
945 | else { | |
946 | Float_t *floatDCS = ProcessFloatAll(array); | |
947 | grpObj->SetBeamIntensity(floatDCS); | |
948 | delete floatDCS; | |
949 | AliSplineFit* splfit1 = GetSplineFit(array,fgkDCSDataPoints[indexDP]); | |
950 | grpObj->SetBeamIntensitySplineFit(splfit1); | |
951 | //delete splfit; | |
952 | } | |
44e45fac | 953 | nLHCEntries++; |
954 | } | |
955 | ||
956 | return nLHCEntries; | |
957 | } | |
958 | //_________________________________________________________________________ | |
959 | ||
39e3007b | 960 | AliSplineFit* AliGRPPreprocessor::GetSplineFit(const TObjArray *array, const TString& stringID){ |
961 | ||
962 | ||
963 | // | |
964 | // returning Spline Fit | |
965 | // | |
44e45fac | 966 | |
967 | Int_t entriesarray = array->GetEntries(); | |
968 | Float_t* value = new Float_t[entriesarray]; | |
969 | Float_t* time = new Float_t[entriesarray]; | |
970 | AliDCSValue* v = 0x0; | |
971 | for (Int_t iarray = 0; iarray < entriesarray; iarray++){ | |
972 | v = (AliDCSValue*)array->At(iarray); | |
973 | value[iarray] = v->GetFloat(); | |
974 | time[iarray] = v->GetTimeStamp(); | |
975 | AliInfo(Form("iarray = %d, value = %f, time = %f",iarray,value[iarray],time[iarray])); | |
976 | } | |
977 | TGraph* gr = new TGraph(entriesarray,value,time); | |
978 | if (!gr ) { | |
979 | AliWarning(Form("%s: no input graph to compute SplineFit",stringID.Data())); | |
980 | return NULL; | |
981 | } | |
982 | AliSplineFit *fit = new AliSplineFit(); | |
983 | fit->SetMinPoints(10); | |
984 | fit->InitKnots(gr,10,10,0.0); | |
985 | fit->SplineFit(2); | |
986 | fit->Cleanup(); | |
987 | if (!fit) { | |
988 | AliWarning(Form("%s: no fit performed",stringID.Data())); | |
989 | return NULL; | |
990 | } | |
991 | return fit; | |
48b1b444 | 992 | } |
993 | ||
44e45fac | 994 | //_________________________________________________________________________ |
995 | ||
39e3007b | 996 | TString AliGRPPreprocessor::ProcessChar(const TObjArray *array) |
e7a6790f | 997 | { |
17984b61 | 998 | |
44e45fac | 999 | // |
1000 | // processing char | |
1001 | // | |
1002 | ||
1003 | TString aDCSString=""; | |
1004 | ||
1005 | AliDCSValue *v = 0x0; | |
1006 | for(Int_t iCount = 0; iCount < array->GetEntries(); iCount++) { | |
1007 | v = (AliDCSValue *)array->At(iCount); | |
26c1dff2 | 1008 | if (((Int_t)(v->GetTimeStamp()) < (Int_t)GetStartTimeDCSQuery()) || ((Int_t)(v->GetTimeStamp()) > (Int_t)GetEndTimeDCSQuery())) { |
44e45fac | 1009 | AliError(Form("DCS values for the parameter outside the queried interval")); |
1010 | continue; | |
1011 | } | |
1012 | if (iCount > 0) { | |
7e6f5523 | 1013 | if (aDCSString != v->GetChar()) |
44e45fac | 1014 | AliError(Form("DCS values for the parameter changed from %s to %c within the queried interval", aDCSString.Data(), (Char_t)v->GetChar())); |
1015 | } | |
1016 | aDCSString = (TString)v->GetChar(); // keeping always last value in the array | |
1017 | } | |
1018 | return aDCSString; | |
1019 | } | |
e7a6790f | 1020 | |
44e45fac | 1021 | //__________________________________________________________________________________________________________________ |
e7a6790f | 1022 | |
39e3007b | 1023 | Float_t* AliGRPPreprocessor::ProcessFloatAll(const TObjArray* array) |
44e45fac | 1024 | { |
1025 | // | |
1026 | // processing Float values using Mean, Median, Standard Deviation wrt Mean, Standar Deviation wrt Median | |
1027 | // | |
1028 | // parameters[0] = mean | |
1029 | // parameters[1] = truncated mean (calculated excluding points outside +/- 3RMS from mean | |
1030 | // parameters[2] = median | |
1031 | // parameters[3] = standard deviation wrt mean | |
1032 | // parameters[4] = standard deviation wrt median | |
1033 | // | |
1034 | ||
5138cd05 | 1035 | Float_t* parameters = new Float_t[5]; |
44e45fac | 1036 | Double_t aDCSArrayMean = 0; // Mean |
1037 | Double_t aDCSArrayTruncMean = 0;// Truncated Mean | |
1038 | Double_t aDCSArrayMedian = 0; // Median | |
1039 | Double_t aDCSArraySDMean = 0; // Standard Deviation wrt Mean | |
1040 | Double_t aDCSArraySDMedian = 0; // Standard Deviation wrt Median | |
1041 | Float_t aDCSArraySum = 0.0; | |
1042 | Int_t iCounts = 0; | |
1043 | Int_t iCounts1 = 0; | |
1044 | Float_t temp = 0; | |
1045 | Float_t temp1 = 0; | |
1046 | Int_t nCounts = array->GetEntries(); | |
1047 | Float_t *tempArray = new Float_t[nCounts]; | |
1048 | for(Int_t i = 0; i < nCounts; i++) { | |
1049 | AliDCSValue *v = (AliDCSValue *)array->At(i); | |
26c1dff2 | 1050 | if(((Int_t)(v->GetTimeStamp()) >= (Int_t)GetStartTimeDCSQuery()) &&((Int_t)(v->GetTimeStamp()) <= (Int_t)GetEndTimeDCSQuery())) { |
44e45fac | 1051 | aDCSArraySum += v->GetFloat(); |
1052 | tempArray[i] = v->GetFloat(); | |
1053 | AliDebug(2,Form("%d-th entry = %f",i,tempArray[i])); | |
1054 | iCounts += 1; | |
1055 | } | |
1056 | } | |
1057 | ||
26c1dff2 | 1058 | AliDebug(2,Form("Using %i entries, starting from %i entries",iCounts,nCounts)); |
44e45fac | 1059 | if(iCounts != 0) { |
26c1dff2 | 1060 | aDCSArrayMean = TMath::Mean(iCounts,tempArray); |
1061 | aDCSArrayMedian = TMath::Median(iCounts,tempArray); | |
1062 | aDCSArraySDMean = TMath::RMS(iCounts,tempArray); | |
1063 | AliDebug(2,Form("SD = %f",aDCSArraySDMean)); | |
44e45fac | 1064 | // computing standard deviation wrt median |
1065 | AliDebug(2,Form("maximum = %f, minimum = %f", aDCSArrayMean+3*aDCSArraySDMean, aDCSArrayMean-3*aDCSArraySDMean)); | |
1066 | for (Int_t i = 0; i < iCounts; i++){ | |
1067 | AliDCSValue *v = (AliDCSValue *)array->At(i); | |
1068 | AliDebug(2,Form("maximum = %f, minimum = %f", aDCSArrayMean+3*aDCSArraySDMean, aDCSArrayMean-3*aDCSArraySDMean)); | |
1069 | AliDebug(2,Form("%i-th entry = %f",i, v->GetFloat())); | |
c135d475 | 1070 | if ((v->GetFloat()<=aDCSArrayMean+3*aDCSArraySDMean) && (v->GetFloat()>=aDCSArrayMean-3*aDCSArraySDMean)){ |
44e45fac | 1071 | temp1+=v->GetFloat(); |
1072 | iCounts1++; | |
c135d475 | 1073 | AliDebug(2,Form("temp1 = %f, iCounts1 = %i",temp1,iCounts1)); |
44e45fac | 1074 | } |
1075 | temp += (v->GetFloat()-aDCSArrayMedian)*(v->GetFloat()-aDCSArrayMedian); | |
1076 | } | |
c135d475 | 1077 | AliDebug(3,Form("temp before the ratio = %f, with %d counts", temp, iCounts)); |
44e45fac | 1078 | temp/=iCounts; |
c135d475 | 1079 | AliDebug(3,Form("temp after the ratio = %f", temp)); |
44e45fac | 1080 | if (temp>0) { |
1081 | aDCSArraySDMedian = TMath::Sqrt(temp); | |
1082 | } | |
c135d475 | 1083 | else if (temp==0) { |
1084 | AliInfo(Form("Radical = 0 in computing standard deviation wrt median! Setting it to zero....")); | |
1085 | aDCSArraySDMedian = 0; | |
1086 | } | |
44e45fac | 1087 | else{ |
c135d475 | 1088 | AliError(Form("Radical < 0 in computing standard deviation! Setting it to invalid....")); |
44e45fac | 1089 | aDCSArraySDMedian = AliGRPObject::GetInvalidFloat(); |
1090 | } | |
1091 | } | |
1092 | else { | |
1093 | aDCSArrayMean = AliGRPObject::GetInvalidFloat(); | |
1094 | aDCSArrayMedian = AliGRPObject::GetInvalidFloat(); | |
1095 | aDCSArraySDMean = AliGRPObject::GetInvalidFloat(); | |
1096 | } | |
c135d475 | 1097 | AliDebug(2,Form("iCounts1 = %d and temp1 = %f",iCounts1, temp1)); |
44e45fac | 1098 | if (iCounts1 > 0) { |
1099 | aDCSArrayTruncMean = temp1/iCounts1; | |
1100 | } | |
1101 | else{ | |
1102 | aDCSArrayTruncMean = AliGRPObject::GetInvalidFloat(); | |
1103 | } | |
1104 | ||
1105 | ||
1106 | ||
26c1dff2 | 1107 | AliDebug(2,Form("mean within %d counts = %f ",iCounts,aDCSArrayMean)); |
1108 | AliDebug(2,Form("truncated mean within %d counts = %f (%i values used)",iCounts,aDCSArrayTruncMean,iCounts1)); | |
1109 | AliDebug(2,Form("median within %d counts = %f ",iCounts,aDCSArrayMedian)); | |
1110 | AliDebug(2,Form("standard deviation with mean within %d counts = %f ",iCounts,aDCSArraySDMean)); | |
1111 | AliDebug(2,Form("standard deviation with median within %d counts = %f ",iCounts,aDCSArraySDMedian)); | |
44e45fac | 1112 | |
1113 | parameters[0] = aDCSArrayMean; | |
1114 | parameters[1] = aDCSArrayTruncMean; | |
1115 | parameters[2] = aDCSArrayMedian; | |
1116 | parameters[3] = aDCSArraySDMean; | |
1117 | parameters[4] = aDCSArraySDMedian; | |
1118 | ||
c135d475 | 1119 | // AliDebug(2,Form("mean = %f, truncated mean = %f, median = %f, SD wrt mean = %f, SD wrt median = %f ",parameters[0],parameters[1],parameters[2],parameters[3],parameters[4])); |
1120 | AliInfo(Form("mean = %f, truncated mean = %f, median = %f, SD wrt mean = %f, SD wrt median = %f ",parameters[0],parameters[1],parameters[2],parameters[3],parameters[4])); | |
44e45fac | 1121 | |
1122 | return parameters; | |
1123 | } | |
125567f8 | 1124 | |
e97cc90e | 1125 | |
44e45fac | 1126 | //_______________________________________________________________ |
e97cc90e | 1127 | |
39e3007b | 1128 | Char_t AliGRPPreprocessor::ProcessBool(const TObjArray* array) |
44e45fac | 1129 | { |
1130 | // | |
1131 | // processing Boolean values | |
1132 | // | |
1133 | ||
1134 | Bool_t aDCSBool = kTRUE; | |
1135 | ||
1136 | AliDCSValue *v = 0x0; | |
26c1dff2 | 1137 | |
44e45fac | 1138 | for(Int_t iCount = 0; iCount < array->GetEntries(); iCount++) { |
1139 | v = (AliDCSValue *)array->At(iCount); | |
26c1dff2 | 1140 | if (((Int_t)(v->GetTimeStamp()) < (Int_t)GetStartTimeDCSQuery()) || ((Int_t)(v->GetTimeStamp()) > (Int_t)GetEndTimeDCSQuery())) { |
44e45fac | 1141 | AliError(Form("DCS values for the parameter outside the queried interval")); |
1142 | continue; | |
1143 | } | |
1144 | if (iCount > 0) { | |
7e6f5523 | 1145 | if (aDCSBool != v->GetBool()) |
44e45fac | 1146 | AliError(Form("DCS values for the parameter changed from %d to %d within the queried interval", (UInt_t)aDCSBool, (UInt_t)v->GetBool())); |
1147 | } | |
1148 | aDCSBool = v->GetBool(); // always keeping last value | |
26c1dff2 | 1149 | AliDebug(2,Form("Bool = %d",(Int_t)aDCSBool)); |
44e45fac | 1150 | } |
1151 | ||
26c1dff2 | 1152 | Char_t caDCSBool = (Char_t) aDCSBool; |
44e45fac | 1153 | return caDCSBool; |
1154 | ||
1155 | } | |
e97cc90e | 1156 | |
44e45fac | 1157 | //_______________________________________________________________ |
e97cc90e | 1158 | |
39e3007b | 1159 | Float_t AliGRPPreprocessor::ProcessInt(const TObjArray* array) |
44e45fac | 1160 | { |
1161 | // | |
1162 | // processing Int values, returning mean | |
1163 | // | |
1164 | ||
1165 | Float_t aDCSArraySum = 0.0; | |
1166 | Float_t aDCSArrayMean = 0.0; | |
1167 | Int_t iCounts = 0; | |
1168 | AliDCSValue* v = 0x0; | |
1169 | ||
1170 | for(Int_t iCount = 0; iCount < array->GetEntries(); iCount++) { | |
1171 | v = (AliDCSValue *)array->At(iCount); | |
26c1dff2 | 1172 | if(((Int_t)(v->GetTimeStamp()) >= (Int_t)GetStartTimeDCSQuery()) &&((Int_t)(v->GetTimeStamp()) <= (Int_t)GetEndTimeDCSQuery())) { |
44e45fac | 1173 | aDCSArraySum += v->GetInt(); |
1174 | iCounts += 1; | |
1175 | } | |
1176 | } | |
1177 | ||
1178 | if(iCounts != 0) aDCSArrayMean = aDCSArraySum/iCounts; | |
1179 | else aDCSArrayMean = AliGRPObject::GetInvalidFloat(); | |
1180 | ||
1181 | return aDCSArrayMean; | |
e97cc90e | 1182 | |
44e45fac | 1183 | } |
1184 | //_______________________________________________________________ | |
e7a6790f | 1185 | |
39e3007b | 1186 | Float_t AliGRPPreprocessor::ProcessUInt(const TObjArray* array) |
44e45fac | 1187 | { |
1188 | // | |
1189 | // processing Int values, returning mean | |
1190 | // | |
1191 | ||
1192 | Float_t aDCSArraySum = 0.0; | |
1193 | Float_t aDCSArrayMean = 0.0; | |
1194 | Int_t iCounts = 0; | |
1195 | AliDCSValue* v = 0x0; | |
1196 | ||
1197 | for(Int_t iCount = 0; iCount < array->GetEntries(); iCount++) { | |
1198 | v = (AliDCSValue *)array->At(iCount); | |
26c1dff2 | 1199 | if(((Int_t)(v->GetTimeStamp()) >= (Int_t)GetStartTimeDCSQuery()) &&((Int_t)(v->GetTimeStamp()) <= (Int_t)GetEndTimeDCSQuery())) { |
44e45fac | 1200 | aDCSArraySum += v->GetUInt(); |
1201 | iCounts += 1; | |
1202 | } | |
1203 | } | |
1204 | ||
1205 | if(iCounts != 0) aDCSArrayMean = aDCSArraySum/iCounts; | |
1206 | else aDCSArrayMean = AliGRPObject::GetInvalidFloat(); | |
1207 | ||
1208 | return aDCSArrayMean; | |
e7a6790f | 1209 | |
17984b61 | 1210 | } |
125567f8 | 1211 | |
44e45fac | 1212 | |
17984b61 | 1213 | //_______________________________________________________________ |
44e45fac | 1214 | |
3ba92a38 | 1215 | AliDCSSensorArray *AliGRPPreprocessor::GetPressureMap(TMap* dcsAliasMap) |
e7a6790f | 1216 | { |
44e45fac | 1217 | // extract DCS pressure maps. Perform fits to save space |
1218 | ||
44e45fac | 1219 | TMap *map = fPressure->ExtractDCS(dcsAliasMap); |
1220 | if (map) { | |
1221 | fPressure->MakeSplineFit(map); | |
1222 | Double_t fitFraction = fPressure->NumFits()/fPressure->NumSensors(); | |
1223 | if (fitFraction > kFitFraction ) { | |
1224 | AliInfo(Form("Pressure values extracted, %d fits performed.", fPressure->NumFits())); | |
1225 | } else { | |
1226 | AliInfo("Too few pressure maps fitted!!!"); | |
1227 | } | |
1228 | } else { | |
1229 | AliInfo("no atmospheric pressure map extracted!!!"); | |
1230 | } | |
1231 | delete map; | |
1232 | ||
1233 | return fPressure; | |
17984b61 | 1234 | } |
e97cc90e | 1235 | |
1e27bb6b | 1236 | |
1237 | ||
1238 | //_______________________________________________________________ | |
3dfcd47d | 1239 | Int_t AliGRPPreprocessor::ReceivePromptRecoParameters(UInt_t run, const char* dbHost, Int_t dbPort, const char* dbName, const char* user, const char* password, const char *cdbRoot) |
1e27bb6b | 1240 | { |
44e45fac | 1241 | // |
1242 | // Retrieves logbook and trigger information from the online logbook | |
1243 | // This information is needed for prompt reconstruction | |
1244 | // | |
1245 | // Parameters are: | |
1246 | // Run number | |
1247 | // DAQ params: dbHost, dbPort, dbName, user, password, logbookTable, triggerTable | |
1248 | // cdbRoot | |
1249 | // | |
1250 | // returns: | |
1251 | // positive on success: the return code is the run number of last run processed of the same run type already processed by the SHUTTLE | |
1252 | // 0 on success and no run was found | |
1253 | // negative on error | |
1254 | // | |
1255 | // This function is NOT called during the preprocessor run in the Shuttle! | |
1256 | // | |
1257 | ||
1258 | // defaults | |
1259 | if (dbPort == 0) | |
1260 | dbPort = 3306; | |
1261 | ||
1262 | // CDB connection | |
1263 | AliCDBManager* cdb = AliCDBManager::Instance(); | |
1264 | cdb->SetDefaultStorage(cdbRoot); | |
1265 | ||
1266 | // SQL connection | |
1267 | TSQLServer* server = TSQLServer::Connect(Form("mysql://%s:%d/%s", dbHost, dbPort, dbName), user, password); | |
1268 | ||
1269 | if (!server) | |
1270 | { | |
1271 | Printf("ERROR: Could not connect to DAQ LB"); | |
1272 | return -1; | |
1273 | } | |
1274 | ||
1275 | // main logbook | |
1276 | TString sqlQuery; | |
26c1dff2 | 1277 | sqlQuery.Form("SELECT DAQ_time_start, run_type, detectorMask, L3_magnetCurrent, Dipole_magnetCurrent FROM logbook WHERE run = %d", run); |
44e45fac | 1278 | TSQLResult* result = server->Query(sqlQuery); |
1279 | if (!result) | |
1280 | { | |
1281 | Printf("ERROR: Can't execute query <%s>!", sqlQuery.Data()); | |
1282 | return -2; | |
1283 | } | |
1284 | ||
1285 | if (result->GetRowCount() == 0) | |
1286 | { | |
1287 | Printf("ERROR: Run %d not found", run); | |
1288 | delete result; | |
1289 | return -3; | |
1290 | } | |
1291 | ||
1292 | TSQLRow* row = result->Next(); | |
1293 | if (!row) | |
1294 | { | |
1295 | Printf("ERROR: Could not receive data from run %d", run); | |
1296 | delete result; | |
1297 | return -4; | |
1298 | } | |
1299 | ||
26c1dff2 | 1300 | TString timeStartString(row->GetField(0)); |
44e45fac | 1301 | TString runType(row->GetField(1)); |
26c1dff2 | 1302 | TString detectorMaskString(row->GetField(2)); |
1303 | TString l3CurrentString(row->GetField(3)); | |
1304 | TString dipoleCurrentString(row->GetField(4)); | |
1305 | time_t timeStart = (time_t)(timeStartString.Atoi()); | |
1306 | UInt_t detectorMask = (UInt_t)(detectorMaskString.Atoi()); | |
1307 | Float_t l3Current = (Float_t)(TMath::Abs(l3CurrentString.Atof())); | |
1308 | Float_t dipoleCurrent = (Float_t)(TMath::Abs(dipoleCurrentString.Atof())); | |
44e45fac | 1309 | |
26c1dff2 | 1310 | AliGRPObject * grpObj = new AliGRPObject(); |
1311 | grpObj->SetTimeStart(timeStart); | |
1312 | grpObj->SetRunType((TString)(row->GetField(1))); | |
1313 | grpObj->SetDetectorMask(detectorMask); | |
1314 | grpObj->SetL3Current(l3Current,(AliGRPObject::Stats)0); | |
1315 | grpObj->SetDipoleCurrent(dipoleCurrent,(AliGRPObject::Stats)0); | |
1316 | ||
44e45fac | 1317 | delete row; |
1318 | row = 0; | |
1319 | ||
1320 | delete result; | |
1321 | result = 0; | |
1322 | ||
1323 | Printf("Storing GRP/GRP/Data object with the following content"); | |
26c1dff2 | 1324 | grpObj->Dump(); |
44e45fac | 1325 | |
1326 | AliCDBMetaData metadata; | |
26c1dff2 | 1327 | metadata.SetResponsible("Jan Fiete Grosse-Oetringhaus & Chiara Zampolli"); |
44e45fac | 1328 | metadata.SetComment("GRP Output parameters received during online running"); |
1329 | ||
1330 | AliCDBId id("GRP/GRP/Data", run, run); | |
26c1dff2 | 1331 | Bool_t success = cdb->Put(grpObj, id, &metadata); |
44e45fac | 1332 | |
26c1dff2 | 1333 | delete grpObj; |
44e45fac | 1334 | |
1335 | if (!success) | |
1336 | { | |
1337 | Printf("ERROR: Could not store GRP/GRP/Data into OCDB"); | |
1338 | return -5; | |
1339 | } | |
1340 | ||
1341 | // Receive trigger information | |
1342 | sqlQuery.Form("SELECT configFile FROM logbook_trigger_config WHERE run = %d", run); | |
1343 | result = server->Query(sqlQuery); | |
1344 | if (!result) | |
1345 | { | |
1346 | Printf("ERROR: Can't execute query <%s>!", sqlQuery.Data()); | |
1347 | return -11; | |
1348 | } | |
1349 | ||
1350 | if (result->GetRowCount() == 0) | |
1351 | { | |
1352 | Printf("ERROR: Run %d not found in logbook_trigger_config", run); | |
1353 | delete result; | |
1354 | return -12; | |
1355 | } | |
1356 | ||
1357 | row = result->Next(); | |
1358 | if (!row) | |
1359 | { | |
1360 | Printf("ERROR: Could not receive logbook_trigger_config data from run %d", run); | |
1361 | delete result; | |
1362 | return -13; | |
1363 | } | |
1364 | ||
1365 | TString triggerConfig(row->GetField(0)); | |
1366 | ||
1367 | delete row; | |
1368 | row = 0; | |
1369 | ||
1370 | delete result; | |
1371 | result = 0; | |
1372 | ||
1373 | Printf("Found trigger configuration: %s", triggerConfig.Data()); | |
1374 | ||
1375 | AliTriggerConfiguration *runcfg = AliTriggerConfiguration::LoadConfigurationFromString(triggerConfig); | |
1376 | if (!runcfg) | |
1377 | { | |
1378 | Printf("ERROR: Could not create CTP configuration object"); | |
1379 | return -14; | |
1380 | } | |
1381 | ||
1382 | metadata.SetComment("CTP run configuration received during online running"); | |
1383 | ||
1384 | AliCDBId id2("GRP/CTP/Config", run, run); | |
1385 | success = cdb->Put(runcfg, id2, &metadata); | |
1386 | ||
1387 | delete runcfg; | |
1388 | runcfg = 0; | |
1389 | ||
1390 | if (!success) | |
1391 | { | |
1392 | Printf("ERROR: Could not store GRP/CTP/Config into OCDB"); | |
1393 | return -15; | |
1394 | } | |
1395 | ||
1396 | // get last run with same run type that was already processed by the SHUTTLE | |
1397 | ||
1398 | sqlQuery.Form("SELECT max(logbook.run) FROM logbook LEFT JOIN logbook_shuttle ON logbook_shuttle.run = logbook.run WHERE run_type = '%s' AND shuttle_done = 1", runType.Data()); | |
1399 | result = server->Query(sqlQuery); | |
1400 | if (!result) | |
1401 | { | |
1402 | Printf("ERROR: Can't execute query <%s>!", sqlQuery.Data()); | |
1403 | return -21; | |
1404 | } | |
1405 | ||
1406 | if (result->GetRowCount() == 0) | |
1407 | { | |
1408 | Printf("ERROR: No result with query <%s>", sqlQuery.Data()); | |
1409 | delete result; | |
1410 | return -22; | |
1411 | } | |
1412 | ||
1413 | row = result->Next(); | |
1414 | if (!row) | |
1415 | { | |
1416 | Printf("ERROR: Could not receive data for query <%s>", sqlQuery.Data()); | |
1417 | delete result; | |
1418 | return -23; | |
1419 | } | |
1420 | ||
1421 | TString lastRunStr(row->GetField(0)); | |
1422 | Int_t lastRun = lastRunStr.Atoi(); | |
1423 | ||
1424 | Printf("Last run with same run type %s is %d", runType.Data(), lastRun); | |
1425 | ||
1426 | delete row; | |
1427 | row = 0; | |
1428 | ||
1429 | delete result; | |
1430 | result = 0; | |
1431 | ||
1432 | server->Close(); | |
1433 | delete server; | |
1434 | server = 0; | |
1435 | ||
1436 | return lastRun; | |
1e27bb6b | 1437 | } |