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