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