]>
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 |
e75e6e01 | 23 | // Modified: Chiara.Zampolli@cern.ch CERN |
3dedb44a | 24 | //------------------------------------------------------------------------- |
25 | ||
836d8b4f | 26 | #include <TChain.h> |
7ca4655f | 27 | #include <TList.h> |
28 | #include <TMap.h> | |
29 | #include <TObjString.h> | |
44e45fac | 30 | #include <TGraph.h> |
7ca4655f | 31 | |
fe726709 | 32 | #include <float.h> |
33 | ||
3dedb44a | 34 | #include "AliGRPPreprocessor.h" |
44e45fac | 35 | #include "AliGRPObject.h" |
36 | #include "AliDCSSensor.h" | |
37 | #include "AliSplineFit.h" | |
17984b61 | 38 | #include "AliDCSSensorArray.h" |
ea4a87ee | 39 | #include "AliRawEventHeaderVersions.h" |
3dedb44a | 40 | |
48b1b444 | 41 | #include "AliTriggerConfiguration.h" |
42 | #include "AliTriggerRunScalers.h" | |
43 | ||
3dedb44a | 44 | #include "AliCDBMetaData.h" |
45 | #include "AliLog.h" | |
46 | ||
3dedb44a | 47 | class AliDCSValue; |
48 | class AliShuttleInterface; | |
49 | ||
1e27bb6b | 50 | // needed for ReceivePromptRecoParameters |
39e3007b | 51 | |
1e27bb6b | 52 | #include <TSQLServer.h> |
53 | #include <TSQLResult.h> | |
54 | #include <TSQLRow.h> | |
55 | #include <AliCDBManager.h> | |
56 | #include <AliCDBMetaData.h> | |
57 | #include <AliCDBId.h> | |
58 | #include <AliTriggerConfiguration.h> | |
59 | ||
17984b61 | 60 | const Double_t kFitFraction = 0.7; // Fraction of DCS sensor fits required |
61 | ||
3dedb44a | 62 | ClassImp(AliGRPPreprocessor) |
63 | ||
17984b61 | 64 | //_______________________________________________________________ |
44e45fac | 65 | |
c3ca811b | 66 | const Int_t AliGRPPreprocessor::fgknDAQLbPar = 8; // num parameters in the logbook for PHYSICS runs, when beamType from DAQ logbook != Cosmics |
e75e6e01 | 67 | const Int_t AliGRPPreprocessor::fgknDAQLbParReduced = 7; // num parameters in the logbook for the other cases |
44e45fac | 68 | const Int_t AliGRPPreprocessor::fgknDCSDP = 50; // number of dcs dps |
39e3007b | 69 | const Int_t AliGRPPreprocessor::fgknDCSDPHallProbes = 40; // number of dcs dps |
e7a6790f | 70 | const char* AliGRPPreprocessor::fgkDCSDataPoints[AliGRPPreprocessor::fgknDCSDP] = { |
1676baf1 | 71 | "LHCState", // missing in DCS |
e7a6790f | 72 | "L3Polarity", |
73 | "DipolePolarity", | |
1676baf1 | 74 | "LHCLuminosity", // missing in DCS |
75 | "BeamIntensity", // missing in DCS | |
e7a6790f | 76 | "L3Current", |
77 | "DipoleCurrent", | |
44e45fac | 78 | "L3_BSF17_H1", |
79 | "L3_BSF17_H2", | |
80 | "L3_BSF17_H3", | |
81 | "L3_BSF17_Temperature", | |
82 | "L3_BSF4_H1", | |
83 | "L3_BSF4_H2", | |
84 | "L3_BSF4_H3", | |
85 | "L3_BSF4_Temperature", | |
86 | "L3_BKF17_H1", | |
87 | "L3_BKF17_H2", | |
88 | "L3_BKF17_H3", | |
89 | "L3_BKF17_Temperature", | |
90 | "L3_BKF4_H1", | |
91 | "L3_BKF4_H2", | |
92 | "L3_BKF4_H3", | |
93 | "L3_BKF4_Temperature", | |
94 | "L3_BSF13_H1", | |
95 | "L3_BSF13_H2", | |
96 | "L3_BSF13_H3", | |
97 | "L3_BSF13_Temperature", | |
98 | "L3_BSF8_H1", | |
99 | "L3_BSF8_H2", | |
100 | "L3_BSF8_H3", | |
101 | "L3_BSF8_Temperature", | |
102 | "L3_BKF13_H1", | |
103 | "L3_BKF13_H2", | |
104 | "L3_BKF13_H3", | |
105 | "L3_BKF13_Temperature", | |
106 | "L3_BKF8_H1", | |
107 | "L3_BKF8_H2", | |
108 | "L3_BKF8_H3", | |
109 | "L3_BKF8_Temperature", | |
110 | "Dipole_Inside_H1", | |
111 | "Dipole_Inside_H2", | |
112 | "Dipole_Inside_H3", | |
113 | "Dipole_Inside_Temperature", | |
114 | "Dipole_Outside_H1", | |
115 | "Dipole_Outside_H2", | |
116 | "Dipole_Outside_H3", | |
117 | "Dipole_Outside_Temperature", | |
e7a6790f | 118 | "CavernTemperature", |
119 | "CavernAtmosPressure", | |
6240e6a4 | 120 | "SurfaceAtmosPressure" |
e7a6790f | 121 | }; |
44e45fac | 122 | |
39e3007b | 123 | const char* AliGRPPreprocessor::fgkDCSDataPointsHallProbes[AliGRPPreprocessor::fgknDCSDPHallProbes] = { |
44e45fac | 124 | "L3_BSF17_H1", |
125 | "L3_BSF17_H2", | |
126 | "L3_BSF17_H3", | |
127 | "L3_BSF17_Temperature", | |
128 | "L3_BSF4_H1", | |
129 | "L3_BSF4_H2", | |
130 | "L3_BSF4_H3", | |
131 | "L3_BSF4_Temperature", | |
132 | "L3_BKF17_H1", | |
133 | "L3_BKF17_H2", | |
134 | "L3_BKF17_H3", | |
135 | "L3_BKF17_Temperature", | |
136 | "L3_BKF4_H1", | |
137 | "L3_BKF4_H2", | |
138 | "L3_BKF4_H3", | |
139 | "L3_BKF4_Temperature", | |
140 | "L3_BSF13_H1", | |
141 | "L3_BSF13_H2", | |
142 | "L3_BSF13_H3", | |
143 | "L3_BSF13_Temperature", | |
144 | "L3_BSF8_H1", | |
145 | "L3_BSF8_H2", | |
146 | "L3_BSF8_H3", | |
147 | "L3_BSF8_Temperature", | |
148 | "L3_BKF13_H1", | |
149 | "L3_BKF13_H2", | |
150 | "L3_BKF13_H3", | |
151 | "L3_BKF13_Temperature", | |
152 | "L3_BKF8_H1", | |
153 | "L3_BKF8_H2", | |
154 | "L3_BKF8_H3", | |
155 | "L3_BKF8_Temperature", | |
156 | "Dipole_Inside_H1", | |
157 | "Dipole_Inside_H2", | |
158 | "Dipole_Inside_H3", | |
159 | "Dipole_Inside_Temperature", | |
160 | "Dipole_Outside_H1", | |
161 | "Dipole_Outside_H2", | |
162 | "Dipole_Outside_H3", | |
163 | "Dipole_Outside_Temperature", | |
164 | }; | |
e7a6790f | 165 | |
44e45fac | 166 | const Short_t kSensors = 48; // start index position of sensor in DCS DPs |
167 | const Short_t kNumSensors = 2; // Number of sensors in DCS DPs | |
e7a6790f | 168 | |
169 | const char* AliGRPPreprocessor::fgkLHCState[20] = { | |
170 | "P", "PREPARE", | |
171 | "J", "PREINJECTION", | |
172 | "I", "INJECTION", | |
173 | "F", "FILLING", | |
174 | "A", "ADJUST", | |
175 | "U", "UNSTABLE BEAMS", | |
176 | "S", "STABLE BEAMS", | |
177 | "D", "BEAM DUMP", | |
178 | "R", "RECOVER", | |
179 | "C", "PRECYCLE" | |
180 | }; | |
181 | ||
182 | const char* kppError[] = { | |
183 | "", | |
184 | "(DAQ logbook ERROR)", | |
185 | "(DAQ FXS ERROR)", | |
161a4dc3 | 186 | "(Trigger Scalers not found in DCS FXS - ERROR)", |
7e1a6c0b | 187 | "(DCS data points ERROR)", |
e75e6e01 | 188 | "(Trigger Configuration ERROR)", |
189 | "(DAQ logbook ERROR determining partition of the run)" | |
e7a6790f | 190 | }; |
17984b61 | 191 | |
3dedb44a | 192 | //_______________________________________________________________ |
44e45fac | 193 | |
3dedb44a | 194 | AliGRPPreprocessor::AliGRPPreprocessor(AliShuttleInterface* shuttle): |
fe726709 | 195 | AliPreprocessor("GRP",shuttle), fPressure(0), fmaxFloat(0), fminFloat(0),fmaxDouble(0), fminDouble(0), fmaxInt(0), fminInt(0), fmaxUInt(0), fminUInt(0) |
e7a6790f | 196 | { |
44e45fac | 197 | // constructor - shuttle must be instantiated! |
ad103e84 | 198 | |
7eaa854b | 199 | AddRunType("COSMIC"); |
200 | AddRunType("LASER"); | |
44e45fac | 201 | AddRunType("PHYSICS"); |
c2ad5069 | 202 | AddRunType("CALIBRATION_BC"); |
203 | AddRunType("CALIBRATION_CENTRAL"); | |
204 | AddRunType("CALIBRATION_EMD"); | |
205 | AddRunType("CALIBRATION_MB"); | |
206 | AddRunType("CALIBRATION_SEMICENTRAL"); | |
69bf9b19 | 207 | AddRunType("CALIBRATION"); |
208 | AddRunType("PEDESTAL"); | |
7be24dea | 209 | AddRunType("STANDALONE"); |
210 | AddRunType("GAIN"); | |
3242245e | 211 | AddRunType("NOISE"); |
212 | AddRunType("PULSER"); | |
b7a928fe | 213 | AddRunType("STANDALONE_PULSER"); |
fe726709 | 214 | |
215 | fmaxFloat = FLT_MAX; | |
216 | fminFloat = -FLT_MAX; | |
217 | fmaxDouble = DBL_MAX; | |
218 | fminDouble = -DBL_MAX; | |
219 | fmaxInt = kMaxInt; | |
220 | fminInt = kMinInt; | |
221 | fmaxUInt = kMaxUInt; | |
222 | fminUInt = 0; | |
223 | ||
224 | AliInfo(Form("Max allowed float = %6.5e",fmaxFloat)); | |
225 | AliInfo(Form("Min allowed float = %6.5e",fminFloat)); | |
226 | AliInfo(Form("Max allowed double = %6.5e",fmaxDouble)); | |
227 | AliInfo(Form("Min allowed double = %6.5e",fminDouble)); | |
228 | AliInfo(Form("Max allowed integer = %d",fmaxInt)); | |
229 | AliInfo(Form("Min allowed integer = %d",fminInt)); | |
230 | AliInfo(Form("Max allowed unsigned integer = %u",(Int_t)fmaxUInt)); | |
231 | AliInfo(Form("Min allowed unsigned integer = %u",(Int_t)fminUInt)); | |
232 | ||
3dedb44a | 233 | } |
234 | ||
235 | //_______________________________________________________________ | |
44e45fac | 236 | |
e7a6790f | 237 | AliGRPPreprocessor::~AliGRPPreprocessor() |
238 | { | |
44e45fac | 239 | //destructor |
240 | ||
241 | delete fPressure; | |
3dedb44a | 242 | } |
243 | ||
244 | //_______________________________________________________________ | |
44e45fac | 245 | |
e7a6790f | 246 | void AliGRPPreprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime) |
247 | { | |
3dedb44a | 248 | // Initialize preprocessor |
5a5052e5 | 249 | |
250 | AliPreprocessor::Initialize(run, startTime, endTime); | |
e7a6790f | 251 | |
17984b61 | 252 | AliInfo("Initialization of the GRP preprocessor."); |
fe726709 | 253 | AliInfo(Form("Start Time DCS = %d",GetStartTimeDCSQuery())); |
254 | AliInfo(Form("End Time DCS = %d",GetEndTimeDCSQuery())); | |
6240e6a4 | 255 | TClonesArray * array = new TClonesArray("AliDCSSensor",kNumSensors); |
256 | for(Int_t j = 0; j < kNumSensors; j++) { | |
17984b61 | 257 | AliDCSSensor * sens = new ((*array)[j])AliDCSSensor; |
e7a6790f | 258 | sens->SetStringID(fgkDCSDataPoints[j+kSensors]); |
17984b61 | 259 | } |
260 | AliInfo(Form("Pressure Entries: %d",array->GetEntries())); | |
261 | ||
563f2a84 | 262 | fPressure = new AliDCSSensorArray(GetStartTimeDCSQuery(), GetEndTimeDCSQuery(), array); |
3dedb44a | 263 | } |
264 | ||
265 | //_______________________________________________________________ | |
44e45fac | 266 | |
e7a6790f | 267 | UInt_t AliGRPPreprocessor::Process(TMap* valueMap) |
268 | { | |
44e45fac | 269 | // process data retrieved by the Shuttle |
270 | ||
e75e6e01 | 271 | // retrieving "partition" and "detector" fields from DAQ logbook to |
272 | // determine the partition in which the run was taken | |
273 | // the partition is used to decide how to react in case of errors for CTP | |
274 | ||
275 | TString partition = (TString)GetRunParameter("partition"); | |
276 | TString detector = (TString)GetRunParameter("detector"); | |
277 | ||
44e45fac | 278 | AliGRPObject *grpobj = new AliGRPObject(); // object to store data |
279 | ||
280 | //=================// | |
281 | // DAQ logbook // | |
282 | //=================// | |
283 | UInt_t error = 0; | |
284 | ||
e75e6e01 | 285 | Int_t iDaqLB = ProcessDaqLB(grpobj); |
286 | TString runType = (TString)GetRunType(); | |
287 | TString beamType = (TString)GetRunParameter("beamType"); | |
c3ca811b | 288 | if((runType == "PHYSICS" && iDaqLB == fgknDAQLbPar && beamType!="Cosmics") || (runType == "PHYSICS" && iDaqLB == fgknDAQLbParReduced && beamType=="Cosmics") || (runType != "PHYSICS" && iDaqLB == fgknDAQLbParReduced)) { |
e75e6e01 | 289 | Log(Form("DAQ Logbook, successful!")); |
290 | } else { | |
291 | Log(Form("DAQ Logbook, could not get all expected entries!!!")); | |
292 | error |= 1; | |
293 | } | |
44e45fac | 294 | |
295 | //=================// | |
296 | // DAQ FXS // | |
297 | //=================// | |
298 | UInt_t iDaqFxs = ProcessDaqFxs(); | |
299 | if( iDaqFxs == 0 ) { | |
300 | Log(Form("DAQ FXS, successful!")); | |
301 | } else { | |
302 | Log(Form("DAQ FXS, could not store run raw tag file!!!")); | |
303 | error |= 2; | |
304 | } | |
305 | ||
306 | //=================// | |
307 | // DCS FXS // | |
308 | //=================// | |
e75e6e01 | 309 | UInt_t iDcsFxs = ProcessDcsFxs(partition, detector); |
44e45fac | 310 | if( iDcsFxs == 0 ) { |
311 | Log(Form("DCS FXS, successful!")); | |
e75e6e01 | 312 | } else if (iDcsFxs ==1) { |
76820ec2 | 313 | Log(Form("DCS FXS, Could not store CTP scalers!!!")); |
44e45fac | 314 | error |= 4; |
e75e6e01 | 315 | } else{ |
316 | Log(Form("Incorrect field in DAQ logbook for partition = %s and detector = %s, going into error without CTP scalers...",partition.Data(),detector.Data())); | |
317 | error |= 32; | |
44e45fac | 318 | } |
319 | ||
320 | //=================// | |
321 | // DCS data points // | |
322 | //=================// | |
7e6f5523 | 323 | Log(Form("Starting DCS Query at %d and finishing at %d",GetStartTimeDCSQuery(),GetEndTimeDCSQuery())); |
44e45fac | 324 | Int_t entries = ProcessDcsDPs( valueMap, grpobj ); |
fe726709 | 325 | Log(Form("entries found = %d (should be %d)",entries, fgknDCSDP-4)); |
24c16c5d | 326 | if( entries < fgknDCSDP-4 ) { // FIXME (!= ) LHState, LHCLuminosity, BeamIntensity, LH3_BSF4_H3 are not working yet... |
fe726709 | 327 | Log(Form("Problem with the DCS data points!!! Only %d/%d entries found",entries,fgknDCSDP-4)); |
44e45fac | 328 | error |= 8; |
329 | } else Log(Form("DCS data points, successful!")); | |
330 | ||
331 | //=======================// | |
332 | // Trigger Configuration // | |
333 | //=======================// | |
e75e6e01 | 334 | |
44e45fac | 335 | const char * triggerConf = GetTriggerConfiguration(); |
e75e6e01 | 336 | |
337 | if (partition.IsNull() && !detector.IsNull()){ // standalone partition | |
338 | Log("STANDALONE partition for current run, using Trigger Configuration dummy value"); | |
339 | AliCDBEntry *cdbEntry = GetFromOCDB("CTP","DummyConfig"); | |
340 | if (!cdbEntry) { | |
341 | Log(Form("No dummy CTP configuration entry found, going into error...")); | |
44e45fac | 342 | error |= 16; |
343 | } | |
e75e6e01 | 344 | else{ |
345 | AliTriggerConfiguration *runcfg = (AliTriggerConfiguration*)cdbEntry->GetObject(); | |
346 | if (!runcfg){ | |
347 | Log(Form("dummy CTP config not found in OCDB entry, going into error...")); | |
44e45fac | 348 | error |= 16; |
349 | } | |
e75e6e01 | 350 | else { |
351 | TString titleCTPcfg = Form("CTP cfg for run %i from Dummy entry in OCDB",fRun); | |
352 | runcfg->SetTitle(titleCTPcfg); | |
353 | AliCDBMetaData metaData; | |
354 | metaData.SetResponsible("Roman Lietava"); | |
355 | metaData.SetComment("CTP run configuration from dummy entry in OCDB"); | |
356 | if (!Store("CTP","Config", runcfg, &metaData, 0, 0)) { | |
357 | Log("Unable to store the dummy CTP run configuration object to OCDB!"); | |
358 | error |= 16; | |
359 | } | |
360 | } | |
44e45fac | 361 | } |
362 | } | |
a453acbf | 363 | |
e75e6e01 | 364 | else if (!partition.IsNull() && detector.IsNull()){ // global partition |
365 | Log("GLOBAL partition for current run, using Trigger Configuration from DAQ Logbook"); | |
366 | if (triggerConf!= NULL) { | |
367 | Log("Found trigger configuration in DAQ logbook"); | |
368 | AliTriggerConfiguration *runcfg = AliTriggerConfiguration::LoadConfigurationFromString(triggerConf); | |
44e45fac | 369 | if (!runcfg) { |
e75e6e01 | 370 | Log("Bad CTP run configuration file from DAQ logbook! The corresponding CDB entry will not be filled!"); |
371 | error |= 16; | |
44e45fac | 372 | } |
373 | else { | |
e75e6e01 | 374 | TString titleCTPcfg = Form("CTP cfg for run %i from DAQ",fRun); |
44e45fac | 375 | runcfg->SetTitle(titleCTPcfg); |
376 | AliCDBMetaData metaData; | |
377 | metaData.SetBeamPeriod(0); | |
378 | metaData.SetResponsible("Roman Lietava"); | |
e75e6e01 | 379 | metaData.SetComment("CTP run configuration from DAQ logbook"); |
44e45fac | 380 | if (!Store("CTP","Config", runcfg, &metaData, 0, 0)) { |
381 | Log("Unable to store the CTP run configuration object to OCDB!"); | |
382 | error |= 16; | |
383 | } | |
384 | } | |
385 | } | |
e75e6e01 | 386 | |
387 | else { | |
388 | Log("Trigger configuration NULL in DAQ logbook"); | |
389 | error |= 16; | |
390 | } | |
391 | } | |
392 | ||
393 | else { | |
394 | Log(Form("Incorrect field in DAQ logbook for partition = %s and detector = %s, going into error without trigger configuration...",partition.Data(),detector.Data())); | |
395 | error |= 32; | |
44e45fac | 396 | } |
e75e6e01 | 397 | |
398 | // storing AliGRPObject in OCDB | |
399 | ||
44e45fac | 400 | AliCDBMetaData md; |
15a700f5 | 401 | md.SetResponsible("Chiara Zampolli"); |
44e45fac | 402 | md.SetComment("Output parameters from the GRP preprocessor."); |
403 | ||
404 | Bool_t result = kTRUE; | |
44e45fac | 405 | result = Store("GRP", "Data", grpobj, &md); |
406 | delete grpobj; | |
407 | ||
408 | if (result && !error ) { | |
409 | Log("GRP Preprocessor Success"); | |
410 | return 0; | |
411 | } else { | |
e75e6e01 | 412 | Log( Form("GRP Preprocessor FAILS!!! %s%s%s%s%s%s", |
44e45fac | 413 | kppError[(error&1)?1:0], |
414 | kppError[(error&2)?2:0], | |
415 | kppError[(error&4)?3:0], | |
416 | kppError[(error&8)?4:0], | |
e75e6e01 | 417 | kppError[(error&16)?5:0], |
418 | kppError[(error&32)?6:0] | |
44e45fac | 419 | )); |
420 | return error; | |
421 | } | |
17984b61 | 422 | } |
423 | ||
17984b61 | 424 | //_______________________________________________________________ |
17984b61 | 425 | |
e75e6e01 | 426 | Int_t AliGRPPreprocessor::ProcessDaqLB(AliGRPObject* grpObj) |
44e45fac | 427 | { |
428 | //Getting the DAQ lb information | |
429 | ||
e75e6e01 | 430 | time_t timeStart = (time_t)(((TString)GetRunParameter("DAQ_time_start")).Atoi()); |
431 | time_t timeEnd = (time_t)(((TString)GetRunParameter("DAQ_time_end")).Atoi()); | |
432 | Float_t beamEnergy = (Float_t)(((TString)GetRunParameter("beamEnergy")).Atof()); | |
44e45fac | 433 | TString beamType = (TString)GetRunParameter("beamType"); |
434 | Char_t numberOfDetectors = (Char_t)(((TString)GetRunParameter("numberOfDetectors")).Atoi()); | |
e75e6e01 | 435 | UInt_t detectorMask = (UInt_t)(((TString)GetRunParameter("detectorMask")).Atoi()); |
44e45fac | 436 | TString lhcPeriod = (TString)GetRunParameter("LHCperiod"); |
437 | TString runType = (TString)GetRunType(); | |
438 | ||
e75e6e01 | 439 | UInt_t nparameter = 0; |
44e45fac | 440 | if (timeStart != 0){ |
441 | grpObj->SetTimeStart(timeStart); | |
442 | Log(Form("Start time for run %d: %d",fRun, (Int_t)timeStart)); | |
e75e6e01 | 443 | nparameter++; |
44e45fac | 444 | } |
445 | else { | |
446 | Log(Form("Start time not put in logbook, setting to invalid in GRP entry!")); | |
447 | } | |
448 | ||
449 | if (timeEnd != 0){ | |
450 | grpObj->SetTimeEnd(timeEnd); | |
451 | Log(Form("End time for run %d: %i",fRun, (Int_t)timeEnd)); | |
e75e6e01 | 452 | nparameter++; |
44e45fac | 453 | } |
454 | else { | |
455 | Log(Form("End time not put in logbook, setting to invalid in GRP entry!")); | |
456 | } | |
457 | ||
458 | if (beamEnergy != 0){ | |
459 | grpObj->SetBeamEnergy(beamEnergy); | |
460 | Log(Form("Beam Energy for run %d: %f",fRun, beamEnergy)); | |
c3ca811b | 461 | if ((runType == "PHYSICS" && beamType!="Cosmics")){ |
462 | nparameter++; // increasing nparameters only in case we're in PHYSICS runs with beamType != Cosmics | |
e75e6e01 | 463 | } |
44e45fac | 464 | } |
465 | else { | |
c3ca811b | 466 | if ((runType == "PHYSICS" && beamType!="Cosmics")){ |
e75e6e01 | 467 | Log(Form("Beam Energy not put in logbook, setting to invalid in GRP entry, and producing an error (beamType = %s, runType = %s)",beamType.Data(), runType.Data())); |
468 | } | |
469 | else{ | |
470 | Log(Form("Beam Energy not put in logbook, setting to invalid in GRP entry, but not producing any error (beamType = %s, runType = %s)",beamType.Data(), runType.Data())); | |
471 | } | |
44e45fac | 472 | } |
473 | ||
44e45fac | 474 | |
475 | if (beamType.Length() != 0){ | |
476 | grpObj->SetBeamType(beamType); | |
477 | Log(Form("Beam Type for run %d: %s",fRun, beamType.Data())); | |
e75e6e01 | 478 | nparameter++; |
44e45fac | 479 | } |
480 | else { | |
481 | Log(Form("Beam Type not put in logbook, setting to invalid in GRP entry!")); | |
482 | } | |
483 | ||
484 | if (numberOfDetectors != 0){ | |
485 | grpObj->SetNumberOfDetectors(numberOfDetectors); | |
486 | Log(Form("Number Of Detectors for run %d: %d",fRun, (Int_t)numberOfDetectors)); | |
e75e6e01 | 487 | nparameter++; |
44e45fac | 488 | } |
489 | else { | |
490 | Log(Form("Number Of Detectors not put in logbook, setting to invalid in GRP entry!")); | |
491 | } | |
492 | ||
493 | if (detectorMask != 0){ | |
494 | grpObj->SetDetectorMask(detectorMask); | |
495 | Log(Form("Detector Mask for run %d: %d",fRun, detectorMask)); | |
e75e6e01 | 496 | nparameter++; |
44e45fac | 497 | } |
498 | else { | |
499 | Log(Form("Detector Mask not put in logbook, setting to invalid in GRP entry!")); | |
500 | } | |
501 | ||
502 | if (lhcPeriod.Length() != 0) { | |
503 | grpObj->SetLHCPeriod(lhcPeriod); | |
504 | Log(Form("LHC period (DAQ) for run %d: %s",fRun, lhcPeriod.Data())); | |
e75e6e01 | 505 | nparameter++; |
506 | } | |
507 | else { | |
44e45fac | 508 | Log(Form("LHCperiod not put in logbook, setting to invalid in GRP entry!")); |
509 | } | |
510 | if (runType.Length() != 0) { | |
511 | grpObj->SetRunType(runType); | |
512 | Log(Form("Run Type (DAQ) for run %d: %s",fRun, runType.Data())); | |
e75e6e01 | 513 | nparameter++; |
514 | } | |
515 | else { | |
44e45fac | 516 | Log(Form("Run Type not put in logbook, setting to invalid in GRP entry!")); |
517 | } | |
518 | ||
e75e6e01 | 519 | return nparameter; |
44e45fac | 520 | } |
17984b61 | 521 | |
44e45fac | 522 | //_______________________________________________________________ |
17984b61 | 523 | |
44e45fac | 524 | UInt_t AliGRPPreprocessor::ProcessDaqFxs() |
525 | { | |
526 | //======DAQ FXS======// | |
527 | ||
ea4a87ee | 528 | AliRawEventHeaderV3_9::Class()->IgnoreTObjectStreamer(); // to avoid trying reading TObject store in AliRawEventHeaderV3_9 - temporary fix |
44e45fac | 529 | TList* list = GetFileSources(kDAQ); |
530 | if (!list) { | |
531 | Log("No raw data tag list: connection problems with DAQ FXS logbook!"); | |
532 | return 1; | |
533 | } | |
534 | ||
535 | if (list->GetEntries() == 0) { | |
536 | Log("no raw data tags in this run: nothing to merge!"); | |
537 | delete list; list=0; | |
538 | return 0; | |
539 | } | |
540 | ||
541 | TChain *fRawTagChain = new TChain("T"); | |
542 | Int_t nFiles=0; | |
543 | TIterator* iter = list->MakeIterator(); | |
544 | TObject* obj = 0; | |
545 | while ((obj = iter->Next())) { | |
546 | TObjString* objStr = dynamic_cast<TObjString*> (obj); | |
547 | if (objStr) { | |
548 | Log(Form("Found source %s", objStr->String().Data())); | |
549 | TList* list2 = GetFileIDs(kDAQ, objStr->String()); | |
550 | if (!list2) { | |
551 | Log("No list with ids from DAQ was found: connection problems with DAQ FXS logbook!"); | |
552 | delete fRawTagChain; fRawTagChain=0; | |
553 | return 1; | |
554 | } | |
555 | Log(Form("Number of ids: %d",list2->GetEntries())); | |
556 | for(Int_t i = 0; i < list2->GetEntries(); i++) { | |
557 | TObjString *idStr = (TObjString *)list2->At(i); | |
558 | TString fileName = GetFile(kDAQ,idStr->String().Data(),objStr->String().Data()); | |
559 | if (fileName.Length() > 0) { | |
560 | Log(Form("Adding file in the chain: %s",fileName.Data())); | |
561 | fRawTagChain->Add(fileName.Data()); | |
562 | nFiles++; | |
563 | } else { | |
564 | Log(Form("Could not retrieve file with id %s from source %s: " | |
565 | "connection problems with DAQ FXS!", | |
566 | idStr->String().Data(), objStr->String().Data())); | |
567 | delete list; list=0; | |
568 | delete list2; list2=0; | |
569 | delete fRawTagChain; fRawTagChain=0; | |
570 | return 2; | |
571 | } | |
572 | } | |
573 | delete list2; | |
574 | } | |
575 | } | |
576 | ||
577 | TString fRawDataFileName = "GRP_Merged.tag.root"; | |
578 | Log(Form("Merging %d raw data tags into file: %s", nFiles, fRawDataFileName.Data())); | |
7e6f5523 | 579 | |
44e45fac | 580 | if( fRawTagChain->Merge(fRawDataFileName) < 1 ) { |
581 | Log("Error merging raw data files!!!"); | |
582 | return 3; | |
583 | } | |
7e6f5523 | 584 | |
44e45fac | 585 | TString outputfile = Form("Run%d.Merged.RAW.tag.root", fRun); |
586 | Bool_t result = StoreRunMetadataFile(fRawDataFileName.Data(),outputfile.Data()); | |
587 | ||
588 | if (!result) { | |
589 | Log("Problem storing raw data tags in local file!!!"); | |
590 | } else { | |
591 | Log("Raw data tags merged successfully!!"); | |
592 | } | |
593 | ||
594 | delete iter; | |
595 | delete list; | |
596 | delete fRawTagChain; fRawTagChain=0; | |
597 | ||
598 | if (result == kFALSE) { | |
599 | return 4; | |
600 | } | |
601 | ||
602 | return 0; | |
603 | ||
604 | } | |
17984b61 | 605 | |
44e45fac | 606 | //_______________________________________________________________ |
e75e6e01 | 607 | UInt_t AliGRPPreprocessor::ProcessDcsFxs(TString partition, TString detector) |
44e45fac | 608 | { |
39e3007b | 609 | |
610 | // processing the info | |
611 | // stored in the DCS FXS | |
612 | // coming from the trigger | |
613 | ||
e75e6e01 | 614 | // Get the CTP counters information |
615 | ||
616 | if (partition.IsNull() && !detector.IsNull()){ // standalone partition | |
161a4dc3 | 617 | Log("STANDALONE partition for current run, using Trigger Scalers dummy value"); |
e75e6e01 | 618 | AliCDBEntry *cdbEntry = GetFromOCDB("CTP","DummyScalers"); |
619 | if (!cdbEntry) { | |
620 | Log(Form("No dummy CTP scalers entry found, going into error...")); | |
44e45fac | 621 | return 1; |
622 | } | |
e75e6e01 | 623 | else{ |
624 | AliTriggerRunScalers *scalers = (AliTriggerRunScalers*)cdbEntry->GetObject(); | |
625 | if (!scalers){ | |
626 | Log(Form("CTP dummy scalers not found in OCDB entry, going into error...")); | |
627 | return 1; | |
628 | } | |
629 | else { | |
630 | AliCDBMetaData metaData; | |
631 | metaData.SetResponsible("Roman Lietava"); | |
632 | metaData.SetComment("CTP scalers from dummy entry in OCDB"); | |
633 | if (!Store("CTP","Scalers", scalers, &metaData, 0, 0)) { | |
634 | Log("Unable to store the dummy CTP scalers object to OCDB!"); | |
635 | return 1; | |
636 | } | |
637 | } | |
638 | } | |
639 | } | |
640 | ||
641 | else if (!partition.IsNull() && detector.IsNull()){ // global partition | |
642 | Log("GLOBAL partition for current run, using CTP scalers from DCS FXS"); | |
643 | TString countersfile = GetFile(kDCS, "CTP_xcounters",""); | |
644 | if (countersfile.IsNull()) { | |
645 | Log("No CTP counters files has been found: empty source!"); | |
44e45fac | 646 | return 1; |
647 | } | |
648 | else { | |
e75e6e01 | 649 | Log(Form("File with Id CTP_xcounters found in DCS FXS! Copied to %s",countersfile.Data())); |
650 | AliTriggerRunScalers *scalers = AliTriggerRunScalers::ReadScalers(countersfile); | |
651 | if (!scalers) { | |
652 | Log("Bad CTP counters file! The corresponding CDB entry will not be filled!"); | |
653 | return 1; | |
654 | } | |
655 | else { | |
656 | AliCDBMetaData metaData; | |
657 | metaData.SetBeamPeriod(0); | |
658 | metaData.SetResponsible("Roman Lietava"); | |
659 | metaData.SetComment("CTP scalers"); | |
660 | if (!Store("CTP","Scalers", scalers, &metaData, 0, 0)) { | |
661 | Log("Unable to store the CTP scalers object to OCDB!"); | |
662 | return 1; | |
44e45fac | 663 | } |
664 | } | |
665 | } | |
44e45fac | 666 | } |
667 | ||
e75e6e01 | 668 | |
669 | else{ | |
670 | Log(Form("Incorrect field in DAQ logbook for partition = %s and detector = %s, going into error...",partition.Data(),detector.Data())); | |
671 | return 2; | |
672 | } | |
673 | ||
44e45fac | 674 | return 0; |
e75e6e01 | 675 | |
44e45fac | 676 | } |
677 | //_______________________________________________________________ | |
17984b61 | 678 | |
44e45fac | 679 | Int_t AliGRPPreprocessor::ProcessDcsDPs(TMap* valueMap, AliGRPObject* grpObj) |
680 | { | |
17984b61 | 681 | |
44e45fac | 682 | // |
683 | // processing DCS DPs | |
684 | // | |
685 | ||
26c1dff2 | 686 | Int_t entries = 0; // counting the entries that are in the DCS DB, not taking care whether they have values or not |
44e45fac | 687 | Int_t nLHCEntries = 0; |
688 | Int_t nL3Entries = 0; | |
689 | Int_t nDipoleEntries = 0; | |
690 | Int_t nEnvEntries = 0; | |
691 | Int_t nHallProbesEntries = 0; | |
692 | nLHCEntries = ProcessLHCDPs(valueMap, grpObj); | |
693 | nL3Entries = ProcessL3DPs(valueMap, grpObj); | |
694 | nDipoleEntries = ProcessDipoleDPs(valueMap, grpObj); | |
695 | nEnvEntries = ProcessEnvDPs(valueMap, grpObj); | |
696 | nHallProbesEntries = ProcessHPDPs(valueMap, grpObj); | |
697 | ||
698 | entries = nLHCEntries + nL3Entries + nDipoleEntries + nEnvEntries + nHallProbesEntries; | |
699 | return entries; | |
17984b61 | 700 | |
17984b61 | 701 | } |
702 | ||
703 | //_______________________________________________________________ | |
29cc8704 | 704 | |
39e3007b | 705 | Int_t AliGRPPreprocessor::ProcessL3DPs(const TMap* valueMap, AliGRPObject* grpObj) |
44e45fac | 706 | { |
39e3007b | 707 | |
708 | // processing DPs | |
709 | // related to | |
710 | // L3 info | |
711 | ||
44e45fac | 712 | Int_t nL3Entries = 0; |
713 | TObjArray *array = 0x0; | |
714 | Int_t indexDP = -1; | |
fe726709 | 715 | Bool_t isZero = kTRUE; // flag to monitor L3Current. If set to true, the magnet is OFF, and the polarity can change |
44e45fac | 716 | |
fe726709 | 717 | AliInfo(Form("==========L3Current===========")); |
718 | Bool_t outOfRange = kFALSE; // flag to monitor if any value collected by DCS is out of range | |
719 | indexDP = kL3Current; | |
44e45fac | 720 | array = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[indexDP]); |
721 | if(!array) { | |
722 | Log(Form("%s not found in the map!!!",fgkDCSDataPoints[indexDP])); | |
723 | } | |
724 | else { | |
26c1dff2 | 725 | if (array->GetEntries() == 0){ |
fe726709 | 726 | AliError(Form("No entries found in array! setting %s to invalid...",fgkDCSDataPoints[indexDP])); |
26c1dff2 | 727 | } |
728 | else { | |
fe726709 | 729 | Float_t *floatDCS = ProcessFloatAllMagnet(array, indexDP, isZero); |
730 | if (floatDCS != NULL){ | |
731 | grpObj->SetL3Current(floatDCS); | |
732 | } | |
733 | else{ | |
734 | outOfRange = kTRUE; | |
735 | } | |
03672227 | 736 | if (floatDCS){ |
737 | delete[] floatDCS; | |
738 | floatDCS = 0x0; | |
739 | } | |
26c1dff2 | 740 | } |
fe726709 | 741 | if (!outOfRange) nL3Entries++; |
44e45fac | 742 | } |
743 | ||
744 | if (array) array = 0x0; | |
745 | ||
fe726709 | 746 | AliInfo(Form("==========L3Polarity===========")); |
747 | indexDP = kL3Polarity; | |
44e45fac | 748 | array = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[indexDP]); |
749 | if(!array) { | |
750 | Log(Form("%s not found in the map!!!",fgkDCSDataPoints[indexDP])); | |
751 | } | |
752 | else { | |
26c1dff2 | 753 | if (array->GetEntries() == 0){ |
fe726709 | 754 | AliError(Form("No entries found in array! setting %s Polarity to invalid...",fgkDCSDataPoints[indexDP])); |
26c1dff2 | 755 | } |
756 | else { | |
fe726709 | 757 | Bool_t change = kFALSE; |
758 | Char_t charDCS = ProcessBool(array,change); | |
01920f0c | 759 | if (change == kFALSE){ |
fe726709 | 760 | grpObj->SetL3Polarity(charDCS); |
761 | AliInfo(Form("%s set to %d",fgkDCSDataPoints[indexDP],(Int_t)(grpObj->GetL3Polarity()))); | |
762 | nL3Entries++; | |
763 | } | |
764 | else if (isZero){ | |
ac833e7a | 765 | AliInfo(Form("%s set to invalid, but magnet was OFF (according to the current), DP not considered wrong",fgkDCSDataPoints[indexDP])); |
fe726709 | 766 | nL3Entries++; |
767 | } | |
768 | else { | |
ac833e7a | 769 | AliError(Form("%s value changed within the run, while the magnet was ON (according to the current), setting it to invalid and considering the DP as wrong",fgkDCSDataPoints[indexDP])); |
fe726709 | 770 | } |
26c1dff2 | 771 | } |
44e45fac | 772 | } |
773 | ||
774 | return nL3Entries; | |
e7a6790f | 775 | |
44e45fac | 776 | } |
777 | //_______________________________________________________________ | |
ff97356e | 778 | |
39e3007b | 779 | Int_t AliGRPPreprocessor::ProcessDipoleDPs(const TMap* valueMap, AliGRPObject* grpObj) |
44e45fac | 780 | { |
39e3007b | 781 | // processing DPs |
782 | // related to | |
783 | // the Dipole info | |
784 | ||
44e45fac | 785 | Int_t nDipoleEntries = 0; |
786 | TObjArray *array = 0x0; | |
787 | Int_t indexDP = -1; | |
fe726709 | 788 | Bool_t isZero = kTRUE; // flag to monitor L3Current. If set to true, the magnet is OFF, and the polarity can change |
44e45fac | 789 | |
fe726709 | 790 | AliInfo(Form("==========DipoleCurrent===========")); |
791 | Bool_t outOfRange = kFALSE; // flag to monitor if any value collected by DCS is out of range | |
792 | indexDP = kDipoleCurrent; | |
44e45fac | 793 | array = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[indexDP]); |
44e45fac | 794 | if(!array) { |
795 | Log(Form("%s not found in the map!!!",fgkDCSDataPoints[indexDP])); | |
796 | } | |
797 | else { | |
26c1dff2 | 798 | if (array->GetEntries() == 0){ |
799 | AliError(Form("No entries found in array! setting %s to invalid...",fgkDCSDataPoints[indexDP])); | |
800 | } | |
801 | else { | |
fe726709 | 802 | Float_t *floatDCS = ProcessFloatAllMagnet(array, indexDP, isZero); |
803 | if (floatDCS != NULL){ | |
804 | grpObj->SetDipoleCurrent(floatDCS); | |
805 | } | |
806 | else{ | |
807 | outOfRange=kTRUE; | |
808 | } | |
03672227 | 809 | if (floatDCS){ |
810 | delete[] floatDCS; | |
811 | floatDCS = 0x0; | |
812 | } | |
26c1dff2 | 813 | } |
fe726709 | 814 | if (!outOfRange) nDipoleEntries++; |
44e45fac | 815 | } |
816 | ||
817 | if (array) array = 0x0; | |
818 | ||
fe726709 | 819 | AliInfo(Form("==========DipolePolarity===========")); |
820 | indexDP = kDipolePolarity; | |
44e45fac | 821 | array = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[indexDP]); |
822 | if(!array) { | |
823 | Log(Form("%s not found in the map!!!",fgkDCSDataPoints[indexDP])); | |
824 | } | |
825 | else { | |
26c1dff2 | 826 | if (array->GetEntries() == 0){ |
827 | AliError(Form("No entries found in array! setting %s to invalid...",fgkDCSDataPoints[indexDP])); | |
828 | } | |
829 | else { | |
fe726709 | 830 | Bool_t change = kFALSE; |
831 | Char_t charDCS = ProcessBool(array,change); | |
832 | if (!change){ | |
833 | grpObj->SetDipolePolarity(charDCS); | |
834 | AliInfo(Form("%s set to %d",fgkDCSDataPoints[indexDP],(Int_t)(grpObj->GetDipolePolarity()))); | |
835 | nDipoleEntries++; | |
836 | } | |
837 | else if (isZero){ | |
ac833e7a | 838 | AliInfo(Form("%s set to invalid, but magnet was OFF (according to the current), DP not considered wrong",fgkDCSDataPoints[indexDP])); |
fe726709 | 839 | nDipoleEntries++; |
840 | } | |
841 | else{ | |
ac833e7a | 842 | AliError(Form("%s value changed within the run while the magnet was ON (according to the current), setting it to invalid and considering the DP as wrong", fgkDCSDataPoints[indexDP])); |
fe726709 | 843 | } |
26c1dff2 | 844 | } |
44e45fac | 845 | } |
846 | ||
847 | return nDipoleEntries; | |
e7a6790f | 848 | |
44e45fac | 849 | } |
850 | //_______________________________________________________________ | |
e7a6790f | 851 | |
44e45fac | 852 | Int_t AliGRPPreprocessor::ProcessEnvDPs(TMap* valueMap, AliGRPObject* grpObj) |
853 | { | |
39e3007b | 854 | // processing DPs |
855 | // related to | |
856 | // evironment conditions (temperature, pressure) info | |
857 | ||
44e45fac | 858 | Int_t nEnvEntries = 0; |
859 | TObjArray *array = 0x0; | |
860 | Int_t indexDP = -1; | |
861 | ||
862 | AliInfo(Form("==========CavernTemperature===========")); | |
fe726709 | 863 | Bool_t outOfRange = kFALSE; // flag to monitor if any value collected by DCS is out of range |
44e45fac | 864 | indexDP = kCavernTemperature; |
865 | array = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[indexDP]); | |
866 | if(!array) { | |
867 | Log(Form("%s not found in the map!!!",fgkDCSDataPoints[indexDP])); | |
868 | } | |
869 | else { | |
26c1dff2 | 870 | if (array->GetEntries() == 0){ |
871 | AliError(Form("No entries found in array! setting %s to invalid...",fgkDCSDataPoints[indexDP])); | |
872 | } | |
873 | else { | |
874 | Float_t *floatDCS = ProcessFloatAll(array); | |
fe726709 | 875 | if (floatDCS != NULL){ |
876 | grpObj->SetCavernTemperature(floatDCS); | |
877 | } | |
878 | else{ | |
879 | outOfRange = kTRUE; | |
880 | } | |
03672227 | 881 | if (floatDCS){ |
882 | delete[] floatDCS; | |
883 | floatDCS = 0x0; | |
884 | } | |
26c1dff2 | 885 | } |
fe726709 | 886 | if (!outOfRange) nEnvEntries++; |
44e45fac | 887 | } |
888 | ||
889 | if (array) array = 0x0; | |
890 | ||
891 | AliInfo(Form("==========AtmosPressures (Cavern + Surface)===========")); | |
892 | AliDCSSensorArray *dcsSensorArray = GetPressureMap(valueMap); | |
893 | dcsSensorArray->Print(); | |
44e45fac | 894 | if( fPressure->NumFits()==0 ) { |
895 | Log("Problem with the pressure sensor values!!!"); | |
896 | } | |
897 | else { | |
898 | AliInfo(Form("==========CavernAtmosPressure===========")); | |
899 | indexDP = kCavernAtmosPressure; | |
900 | AliDCSSensor* sensorCavernP2 = dcsSensorArray->GetSensor(fgkDCSDataPoints[indexDP]); | |
901 | AliDebug(2,Form("sensorCavernP2 = %p", sensorCavernP2)); | |
902 | if( sensorCavernP2->GetFit() ) { | |
903 | Log(Form("<%s> for run %d: Sensor Fit found",fgkDCSDataPoints[indexDP], fRun)); | |
904 | grpObj->SetCavernAtmosPressure(sensorCavernP2); | |
905 | nEnvEntries++; | |
906 | } | |
907 | //if (sensorP2) delete sensorP2; | |
908 | else { | |
ac833e7a | 909 | Log(Form("ERROR Sensor Fit for %s not found ", fgkDCSDataPoints[indexDP] )); |
44e45fac | 910 | } |
911 | AliInfo(Form("==========SurfaceAtmosPressure===========")); | |
912 | indexDP = kSurfaceAtmosPressure; | |
913 | AliDCSSensor* sensorP2 = dcsSensorArray->GetSensor(fgkDCSDataPoints[indexDP]); | |
914 | AliDebug(2,Form("sensorP2 = %p", sensorP2)); | |
915 | if( sensorP2->GetFit() ) { | |
916 | Log(Form("<%s> for run %d: Sensor Fit found",fgkDCSDataPoints[indexDP], fRun)); | |
917 | grpObj->SetSurfaceAtmosPressure(sensorP2); | |
918 | nEnvEntries++; | |
919 | } | |
920 | //if (sensorP2) delete sensorP2; | |
921 | else { | |
ac833e7a | 922 | Log(Form("ERROR Sensor Fit for %s not found ", fgkDCSDataPoints[indexDP] )); |
44e45fac | 923 | } |
924 | ||
925 | } | |
926 | ||
44e45fac | 927 | return nEnvEntries; |
928 | } | |
929 | //_______________________________________________________________ | |
e7a6790f | 930 | |
39e3007b | 931 | Int_t AliGRPPreprocessor::ProcessHPDPs(const TMap* valueMap, AliGRPObject* grpObj) |
44e45fac | 932 | { |
39e3007b | 933 | // processing DPs |
934 | // related to | |
935 | // Hall Probes info | |
936 | ||
44e45fac | 937 | Int_t nHPEntries = 0; |
938 | TObjArray *array = 0x0; | |
939 | Int_t indexDP = -1; | |
fe726709 | 940 | Bool_t outOfRange; // flag to monitor if any value collected by DCS is out of range |
44e45fac | 941 | |
39e3007b | 942 | if (fgknDCSDPHallProbes != AliGRPObject::GetNumberOfHP()){ |
943 | 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 | 944 | } |
945 | for (indexDP = 0; indexDP < AliGRPObject::GetNumberOfHP(); indexDP++){ | |
fe726709 | 946 | outOfRange = kFALSE; // resetting outOfRange flag at each HP |
44e45fac | 947 | AliInfo(Form("==========%s===========",AliGRPObject::GetHPDP(indexDP))); |
948 | array = (TObjArray *)valueMap->GetValue(AliGRPObject::GetHPDP(indexDP)); | |
949 | if(!array) { | |
950 | Log(Form("%s not found in the map!!!",AliGRPObject::GetHPDP(indexDP))); | |
951 | } | |
952 | else { | |
26c1dff2 | 953 | if (array->GetEntries() == 0){ |
954 | AliError(Form("No entries found in array! setting %s to invalid...",AliGRPObject::GetHPDP(indexDP))); | |
955 | } | |
956 | else { | |
957 | Float_t *floatDCS = ProcessFloatAll(array); | |
fe726709 | 958 | if (floatDCS != NULL){ |
959 | 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])); | |
960 | grpObj->SetHallProbes((AliGRPObject::DP_HallProbes)indexDP,floatDCS); | |
961 | for (Int_t kk = 0 ; kk< 5; kk++){ | |
962 | AliDebug(2,Form("HallProbe[%d][%d]=%f",indexDP,kk,grpObj->GetHallProbes((AliGRPObject::DP_HallProbes)indexDP,(AliGRPObject::Stats)kk))); | |
963 | } | |
964 | } | |
965 | else{ | |
966 | outOfRange = kTRUE; | |
26c1dff2 | 967 | } |
03672227 | 968 | if (floatDCS){ |
969 | delete[] floatDCS; | |
970 | floatDCS = 0x0; | |
971 | } | |
44e45fac | 972 | } |
fe726709 | 973 | if (!outOfRange) nHPEntries++; |
44e45fac | 974 | } |
975 | } | |
976 | ||
7e6f5523 | 977 | Log(Form("Hall Probes = %d ", nHPEntries)); |
978 | return nHPEntries; | |
17984b61 | 979 | } |
980 | ||
48b1b444 | 981 | //_______________________________________________________________ |
44e45fac | 982 | |
39e3007b | 983 | Int_t AliGRPPreprocessor::ProcessLHCDPs(const TMap* valueMap, AliGRPObject* grpObj) |
e7a6790f | 984 | { |
48b1b444 | 985 | |
44e45fac | 986 | // |
987 | // processing of LHC related DCS DPs, i.e.: | |
988 | // LHCState | |
989 | // LHCLuminosity | |
990 | // BeamIntensity | |
991 | // | |
992 | ||
993 | Int_t nLHCEntries = 0; | |
994 | TObjArray *array = 0x0; | |
995 | Int_t indexDP = -1; | |
996 | ||
997 | AliInfo(Form("==========LHCState===========")); | |
998 | indexDP = kLHCState; | |
999 | array = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[indexDP]); | |
1000 | if(!array) { | |
1001 | Log(Form("%s not found in the map!!!",fgkDCSDataPoints[indexDP])); | |
1002 | } | |
1003 | else { | |
26c1dff2 | 1004 | if (array->GetEntries() == 0){ |
1005 | AliError(Form("No entries found in array! setting %s to invalid...",fgkDCSDataPoints[indexDP])); | |
1006 | } | |
1007 | else { | |
1008 | TString stringDCS = ProcessChar(array); | |
1009 | if (stringDCS.Length()!=0) { | |
1010 | Bool_t found = kFALSE; | |
1011 | for( Int_t i=0; i<20; i+=2 ) { | |
1012 | if( stringDCS.CompareTo(fgkLHCState[i]) == 0 ) { | |
1013 | stringDCS = fgkLHCState[i+1]; | |
1014 | found = kTRUE; | |
1015 | break; | |
1016 | } | |
44e45fac | 1017 | } |
26c1dff2 | 1018 | if (found){ |
1019 | Log(Form("<%s> for run %d: %s",fgkDCSDataPoints[indexDP],fRun, stringDCS.Data())); | |
1020 | grpObj->SetLHCState(stringDCS); | |
1021 | } | |
1022 | else{ | |
1023 | Log(Form("%s values found not valid!",fgkDCSDataPoints[indexDP])); | |
1024 | grpObj->SetLHCState(AliGRPObject::GetInvalidString()); | |
1025 | } | |
44e45fac | 1026 | } |
26c1dff2 | 1027 | else { |
1028 | Log(Form("%s not valid (null length), string set as invalid!",fgkDCSDataPoints[indexDP])); | |
44e45fac | 1029 | grpObj->SetLHCState(AliGRPObject::GetInvalidString()); |
26c1dff2 | 1030 | } |
44e45fac | 1031 | } |
44e45fac | 1032 | nLHCEntries++; |
1033 | } | |
1034 | ||
1035 | if (array) array = 0x0; | |
1036 | ||
1037 | AliInfo(Form("==========LHCLuminosity===========")); | |
fe726709 | 1038 | Bool_t outOfRange = kFALSE; // flag to monitor if any value collected by DCS is out of range |
44e45fac | 1039 | indexDP = kLHCLuminosity; |
1040 | array = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[indexDP]); | |
1041 | if(!array) { | |
1042 | Log(Form("%s not found in the map!!!",fgkDCSDataPoints[indexDP])); | |
1043 | } | |
1044 | else { | |
26c1dff2 | 1045 | if (array->GetEntries() == 0){ |
1046 | AliError(Form("No entries found in array! setting %s and its Spline Fit to invalid...",fgkDCSDataPoints[indexDP])); | |
1047 | } | |
1048 | else { | |
1049 | Float_t *floatDCS = ProcessFloatAll(array); | |
fe726709 | 1050 | if (floatDCS != NULL){ |
1051 | grpObj->SetLHCLuminosity(floatDCS); | |
1052 | AliSplineFit* splfit = GetSplineFit(array,fgkDCSDataPoints[indexDP]); | |
1053 | grpObj->SetLHCLuminositySplineFit(splfit); | |
26c1dff2 | 1054 | // delete splfit; |
fe726709 | 1055 | } |
1056 | else { | |
1057 | outOfRange = kTRUE; | |
1058 | } | |
03672227 | 1059 | if (floatDCS){ |
1060 | delete[] floatDCS; | |
1061 | floatDCS = 0x0; | |
1062 | } | |
26c1dff2 | 1063 | } |
fe726709 | 1064 | if (!outOfRange) nLHCEntries++; |
44e45fac | 1065 | } |
1066 | ||
1067 | if (array) array = 0x0; | |
1068 | ||
1069 | AliInfo(Form("==========BeamIntensity===========")); | |
fe726709 | 1070 | if (outOfRange) outOfRange = kFALSE; // resetting outOfRange if needed |
44e45fac | 1071 | indexDP = kBeamIntensity; |
1072 | array = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[indexDP]); | |
1073 | if(!array) { | |
1074 | Log(Form("%s not found in the map!!!",fgkDCSDataPoints[indexDP])); | |
1075 | } | |
1076 | else { | |
26c1dff2 | 1077 | if (array->GetEntries() == 0){ |
1078 | AliError(Form("No entries found in array! setting %s and its Spline Fit to invalid...",fgkDCSDataPoints[indexDP])); | |
1079 | } | |
1080 | else { | |
1081 | Float_t *floatDCS = ProcessFloatAll(array); | |
fe726709 | 1082 | if (floatDCS != NULL){ |
1083 | grpObj->SetBeamIntensity(floatDCS); | |
1084 | AliSplineFit* splfit1 = GetSplineFit(array,fgkDCSDataPoints[indexDP]); | |
1085 | grpObj->SetBeamIntensitySplineFit(splfit1); | |
1086 | //delete splfit; | |
1087 | } | |
1088 | else{ | |
1089 | outOfRange = kTRUE; | |
1090 | } | |
03672227 | 1091 | if (floatDCS){ |
1092 | delete[] floatDCS; | |
1093 | floatDCS = 0x0; | |
1094 | } | |
26c1dff2 | 1095 | } |
fe726709 | 1096 | if (!outOfRange) nLHCEntries++; |
44e45fac | 1097 | } |
1098 | ||
1099 | return nLHCEntries; | |
1100 | } | |
1101 | //_________________________________________________________________________ | |
1102 | ||
39e3007b | 1103 | AliSplineFit* AliGRPPreprocessor::GetSplineFit(const TObjArray *array, const TString& stringID){ |
1104 | ||
1105 | ||
1106 | // | |
1107 | // returning Spline Fit | |
1108 | // | |
44e45fac | 1109 | |
1110 | Int_t entriesarray = array->GetEntries(); | |
1111 | Float_t* value = new Float_t[entriesarray]; | |
1112 | Float_t* time = new Float_t[entriesarray]; | |
1113 | AliDCSValue* v = 0x0; | |
1114 | for (Int_t iarray = 0; iarray < entriesarray; iarray++){ | |
1115 | v = (AliDCSValue*)array->At(iarray); | |
1116 | value[iarray] = v->GetFloat(); | |
1117 | time[iarray] = v->GetTimeStamp(); | |
e75e6e01 | 1118 | AliDebug(2,Form("iarray = %d, value = %f, time = %f",iarray,value[iarray],time[iarray])); |
44e45fac | 1119 | } |
1120 | TGraph* gr = new TGraph(entriesarray,value,time); | |
1121 | if (!gr ) { | |
1122 | AliWarning(Form("%s: no input graph to compute SplineFit",stringID.Data())); | |
1123 | return NULL; | |
1124 | } | |
1125 | AliSplineFit *fit = new AliSplineFit(); | |
1126 | fit->SetMinPoints(10); | |
1127 | fit->InitKnots(gr,10,10,0.0); | |
1128 | fit->SplineFit(2); | |
1129 | fit->Cleanup(); | |
1130 | if (!fit) { | |
1131 | AliWarning(Form("%s: no fit performed",stringID.Data())); | |
1132 | return NULL; | |
1133 | } | |
1134 | return fit; | |
48b1b444 | 1135 | } |
1136 | ||
44e45fac | 1137 | //_________________________________________________________________________ |
1138 | ||
39e3007b | 1139 | TString AliGRPPreprocessor::ProcessChar(const TObjArray *array) |
e7a6790f | 1140 | { |
17984b61 | 1141 | |
44e45fac | 1142 | // |
1143 | // processing char | |
1144 | // | |
1145 | ||
1146 | TString aDCSString=""; | |
1147 | ||
1148 | AliDCSValue *v = 0x0; | |
1149 | for(Int_t iCount = 0; iCount < array->GetEntries(); iCount++) { | |
1150 | v = (AliDCSValue *)array->At(iCount); | |
26c1dff2 | 1151 | if (((Int_t)(v->GetTimeStamp()) < (Int_t)GetStartTimeDCSQuery()) || ((Int_t)(v->GetTimeStamp()) > (Int_t)GetEndTimeDCSQuery())) { |
44e45fac | 1152 | AliError(Form("DCS values for the parameter outside the queried interval")); |
1153 | continue; | |
1154 | } | |
1155 | if (iCount > 0) { | |
7e6f5523 | 1156 | if (aDCSString != v->GetChar()) |
44e45fac | 1157 | AliError(Form("DCS values for the parameter changed from %s to %c within the queried interval", aDCSString.Data(), (Char_t)v->GetChar())); |
1158 | } | |
1159 | aDCSString = (TString)v->GetChar(); // keeping always last value in the array | |
1160 | } | |
1161 | return aDCSString; | |
1162 | } | |
e7a6790f | 1163 | |
44e45fac | 1164 | //__________________________________________________________________________________________________________________ |
e7a6790f | 1165 | |
39e3007b | 1166 | Float_t* AliGRPPreprocessor::ProcessFloatAll(const TObjArray* array) |
44e45fac | 1167 | { |
1168 | // | |
1169 | // processing Float values using Mean, Median, Standard Deviation wrt Mean, Standar Deviation wrt Median | |
1170 | // | |
1171 | // parameters[0] = mean | |
1172 | // parameters[1] = truncated mean (calculated excluding points outside +/- 3RMS from mean | |
1173 | // parameters[2] = median | |
1174 | // parameters[3] = standard deviation wrt mean | |
1175 | // parameters[4] = standard deviation wrt median | |
1176 | // | |
1177 | ||
5138cd05 | 1178 | Float_t* parameters = new Float_t[5]; |
44e45fac | 1179 | Double_t aDCSArrayMean = 0; // Mean |
1180 | Double_t aDCSArrayTruncMean = 0;// Truncated Mean | |
1181 | Double_t aDCSArrayMedian = 0; // Median | |
1182 | Double_t aDCSArraySDMean = 0; // Standard Deviation wrt Mean | |
1183 | Double_t aDCSArraySDMedian = 0; // Standard Deviation wrt Median | |
1184 | Float_t aDCSArraySum = 0.0; | |
1185 | Int_t iCounts = 0; | |
1186 | Int_t iCounts1 = 0; | |
1187 | Float_t temp = 0; | |
1188 | Float_t temp1 = 0; | |
1189 | Int_t nCounts = array->GetEntries(); | |
1190 | Float_t *tempArray = new Float_t[nCounts]; | |
1191 | for(Int_t i = 0; i < nCounts; i++) { | |
1192 | AliDCSValue *v = (AliDCSValue *)array->At(i); | |
fe726709 | 1193 | if ((v->GetFloat() <= fminFloat) || (v->GetFloat() >= fmaxFloat)) { |
1194 | AliError(Form("Error! Float value found in DCS map at %d-th entry is OUT OF RANGE: value = %6.5e",i,v->GetFloat())); | |
1195 | if (v->GetFloat() < fminFloat) AliInfo(Form("The value is smaller than %6.5e",fminFloat)); | |
1196 | if (v->GetFloat() > fmaxFloat) AliInfo(Form("The value is greater than %6.5e",fmaxFloat)); | |
1197 | return NULL; | |
1198 | } | |
1199 | if(((Int_t)(v->GetTimeStamp()) >= (Int_t)GetStartTimeDCSQuery()) &&((Int_t)(v->GetTimeStamp()) <= (Int_t)GetEndTimeDCSQuery())) { | |
1200 | aDCSArraySum += v->GetFloat(); | |
1201 | tempArray[i] = v->GetFloat(); | |
1202 | AliDebug(2,Form("%d-th entry = %f",i,tempArray[i])); | |
1203 | iCounts += 1; | |
1204 | } | |
1205 | else { | |
1206 | AliError(Form("DCS values for the parameter outside the queried interval")); | |
1207 | } | |
1208 | } | |
1209 | ||
1210 | AliDebug(2,Form("Using %i entries, starting from %i entries",iCounts,nCounts)); | |
1211 | if(iCounts != 0) { | |
1212 | aDCSArrayMean = TMath::Mean(iCounts,tempArray); | |
1213 | aDCSArrayMedian = TMath::Median(iCounts,tempArray); | |
1214 | aDCSArraySDMean = TMath::RMS(iCounts,tempArray); | |
1215 | AliDebug(2,Form("SD = %f",aDCSArraySDMean)); | |
1216 | // computing standard deviation wrt median | |
1217 | AliDebug(2,Form("maximum = %f, minimum = %f", aDCSArrayMean+3*aDCSArraySDMean, aDCSArrayMean-3*aDCSArraySDMean)); | |
1218 | for (Int_t i = 0; i < iCounts; i++){ | |
1219 | AliDCSValue *v = (AliDCSValue *)array->At(i); | |
1220 | AliDebug(3,Form("maximum = %f, minimum = %f", aDCSArrayMean+3*aDCSArraySDMean, aDCSArrayMean-3*aDCSArraySDMean)); | |
1221 | AliDebug(3,Form("%i-th entry = %f",i, v->GetFloat())); | |
1222 | if ((v->GetFloat()<=aDCSArrayMean+3*aDCSArraySDMean) && (v->GetFloat()>=aDCSArrayMean-3*aDCSArraySDMean)){ | |
1223 | temp1+=v->GetFloat(); | |
1224 | iCounts1++; | |
1225 | AliDebug(3,Form("temp1 = %f, iCounts1 = %i",temp1,iCounts1)); | |
1226 | } | |
1227 | temp += (v->GetFloat()-aDCSArrayMedian)*(v->GetFloat()-aDCSArrayMedian); | |
1228 | } | |
1229 | AliDebug(3,Form("temp before the ratio = %f, with %d counts", temp, iCounts)); | |
1230 | temp/=iCounts; | |
1231 | AliDebug(3,Form("temp after the ratio = %f", temp)); | |
1232 | if (temp>0) { | |
1233 | aDCSArraySDMedian = TMath::Sqrt(temp); | |
1234 | } | |
1235 | else if (temp==0) { | |
1236 | AliInfo(Form("Radical = 0 in computing standard deviation wrt median! Setting it to zero....")); | |
1237 | aDCSArraySDMedian = 0; | |
1238 | } | |
1239 | else{ | |
1240 | AliError(Form("Radical < 0 in computing standard deviation! Setting it to invalid....")); | |
1241 | aDCSArraySDMedian = AliGRPObject::GetInvalidFloat(); | |
1242 | } | |
1243 | } | |
1244 | else { | |
1245 | aDCSArrayMean = AliGRPObject::GetInvalidFloat(); | |
1246 | aDCSArrayMedian = AliGRPObject::GetInvalidFloat(); | |
1247 | aDCSArraySDMean = AliGRPObject::GetInvalidFloat(); | |
1248 | } | |
1249 | AliDebug(3,Form("iCounts1 = %d and temp1 = %f",iCounts1, temp1)); | |
1250 | if (iCounts1 > 0) { | |
1251 | aDCSArrayTruncMean = temp1/iCounts1; | |
1252 | } | |
1253 | else{ | |
1254 | aDCSArrayTruncMean = AliGRPObject::GetInvalidFloat(); | |
1255 | } | |
1256 | ||
1257 | ||
1258 | ||
1259 | AliDebug(2,Form("mean within %d counts = %f ",iCounts,aDCSArrayMean)); | |
1260 | AliDebug(2,Form("truncated mean within %d counts = %f (%i values used)",iCounts,aDCSArrayTruncMean,iCounts1)); | |
1261 | AliDebug(2,Form("median within %d counts = %f ",iCounts,aDCSArrayMedian)); | |
1262 | AliDebug(2,Form("standard deviation with mean within %d counts = %f ",iCounts,aDCSArraySDMean)); | |
1263 | AliDebug(2,Form("standard deviation with median within %d counts = %f ",iCounts,aDCSArraySDMedian)); | |
1264 | ||
1265 | parameters[0] = aDCSArrayMean; | |
1266 | parameters[1] = aDCSArrayTruncMean; | |
1267 | parameters[2] = aDCSArrayMedian; | |
1268 | parameters[3] = aDCSArraySDMean; | |
1269 | parameters[4] = aDCSArraySDMedian; | |
1270 | ||
1271 | 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])); | |
1272 | //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])); | |
1273 | ||
1274 | return parameters; | |
1275 | } | |
1276 | ||
1277 | ||
1278 | ||
1279 | //__________________________________________________________________________________________________________________ | |
1280 | ||
1281 | Float_t* AliGRPPreprocessor::ProcessFloatAllMagnet(const TObjArray* array, Int_t indexDP, Bool_t &isZero) | |
1282 | { | |
1283 | // | |
1284 | // processing Float values using Mean, Median, Standard Deviation wrt Mean, Standar Deviation wrt Median | |
1285 | // used for L3 and Dipole magnets, using isZero flag to decide whther the magnet was OFF/ON | |
ac833e7a | 1286 | // the flag is set according to the L3/Dipole current value |
1287 | // current threshold for L3 = 350 A (value provided by DCS) | |
1288 | // current threshold for Dipole = 450 A (value provided by DCS) | |
fe726709 | 1289 | // |
1290 | // parameters[0] = mean | |
1291 | // parameters[1] = truncated mean (calculated excluding points outside +/- 3RMS from mean | |
1292 | // parameters[2] = median | |
1293 | // parameters[3] = standard deviation wrt mean | |
1294 | // parameters[4] = standard deviation wrt median | |
1295 | // | |
1296 | ||
1297 | AliInfo(Form("indexDP = %d",indexDP)); | |
1298 | Float_t* parameters = new Float_t[5]; | |
1299 | Double_t aDCSArrayMean = 0; // Mean | |
1300 | Double_t aDCSArrayTruncMean = 0;// Truncated Mean | |
1301 | Double_t aDCSArrayMedian = 0; // Median | |
1302 | Double_t aDCSArraySDMean = 0; // Standard Deviation wrt Mean | |
1303 | Double_t aDCSArraySDMedian = 0; // Standard Deviation wrt Median | |
1304 | Float_t aDCSArraySum = 0.0; | |
1305 | Int_t iCounts = 0; | |
1306 | Int_t iCounts1 = 0; | |
1307 | Float_t temp = 0; | |
1308 | Float_t temp1 = 0; | |
1309 | Int_t nCounts = array->GetEntries(); | |
1310 | Float_t *tempArray = new Float_t[nCounts]; | |
1311 | for(Int_t i = 0; i < nCounts; i++) { | |
1312 | AliDCSValue *v = (AliDCSValue *)array->At(i); | |
1313 | if ((v->GetFloat() <= fminFloat) || (v->GetFloat() >= fmaxFloat)) { | |
1314 | AliError(Form("Error! Float value found in DCS map at %d-th entry is OUT OF RANGE: value = %6.5e",i,v->GetFloat())); | |
535c05eb | 1315 | if (v->GetFloat() < fminFloat) AliInfo(Form("The value is smaller than %6.5e",fminFloat)); |
1316 | if (v->GetFloat() > fmaxFloat) AliInfo(Form("The value is greater than %6.5e",fmaxFloat)); | |
fe726709 | 1317 | return NULL; |
1318 | } | |
26c1dff2 | 1319 | if(((Int_t)(v->GetTimeStamp()) >= (Int_t)GetStartTimeDCSQuery()) &&((Int_t)(v->GetTimeStamp()) <= (Int_t)GetEndTimeDCSQuery())) { |
44e45fac | 1320 | aDCSArraySum += v->GetFloat(); |
1321 | tempArray[i] = v->GetFloat(); | |
1322 | AliDebug(2,Form("%d-th entry = %f",i,tempArray[i])); | |
1323 | iCounts += 1; | |
ac833e7a | 1324 | if (indexDP == kL3Current && v->GetFloat() > 350 && isZero == kTRUE) isZero=kFALSE; |
1325 | if (indexDP == kDipoleCurrent && v->GetFloat() > 450 && isZero == kTRUE) isZero=kFALSE; | |
fe726709 | 1326 | } |
1327 | else { | |
1328 | AliError(Form("DCS values for the parameter outside the queried interval")); | |
44e45fac | 1329 | } |
1330 | } | |
1331 | ||
26c1dff2 | 1332 | AliDebug(2,Form("Using %i entries, starting from %i entries",iCounts,nCounts)); |
44e45fac | 1333 | if(iCounts != 0) { |
26c1dff2 | 1334 | aDCSArrayMean = TMath::Mean(iCounts,tempArray); |
1335 | aDCSArrayMedian = TMath::Median(iCounts,tempArray); | |
1336 | aDCSArraySDMean = TMath::RMS(iCounts,tempArray); | |
1337 | AliDebug(2,Form("SD = %f",aDCSArraySDMean)); | |
44e45fac | 1338 | // computing standard deviation wrt median |
1339 | AliDebug(2,Form("maximum = %f, minimum = %f", aDCSArrayMean+3*aDCSArraySDMean, aDCSArrayMean-3*aDCSArraySDMean)); | |
1340 | for (Int_t i = 0; i < iCounts; i++){ | |
1341 | AliDCSValue *v = (AliDCSValue *)array->At(i); | |
fe726709 | 1342 | AliDebug(3,Form("maximum = %f, minimum = %f", aDCSArrayMean+3*aDCSArraySDMean, aDCSArrayMean-3*aDCSArraySDMean)); |
1343 | AliDebug(3,Form("%i-th entry = %f",i, v->GetFloat())); | |
c135d475 | 1344 | if ((v->GetFloat()<=aDCSArrayMean+3*aDCSArraySDMean) && (v->GetFloat()>=aDCSArrayMean-3*aDCSArraySDMean)){ |
44e45fac | 1345 | temp1+=v->GetFloat(); |
1346 | iCounts1++; | |
fe726709 | 1347 | AliDebug(3,Form("temp1 = %f, iCounts1 = %i",temp1,iCounts1)); |
44e45fac | 1348 | } |
1349 | temp += (v->GetFloat()-aDCSArrayMedian)*(v->GetFloat()-aDCSArrayMedian); | |
1350 | } | |
c135d475 | 1351 | AliDebug(3,Form("temp before the ratio = %f, with %d counts", temp, iCounts)); |
44e45fac | 1352 | temp/=iCounts; |
c135d475 | 1353 | AliDebug(3,Form("temp after the ratio = %f", temp)); |
44e45fac | 1354 | if (temp>0) { |
1355 | aDCSArraySDMedian = TMath::Sqrt(temp); | |
1356 | } | |
c135d475 | 1357 | else if (temp==0) { |
1358 | AliInfo(Form("Radical = 0 in computing standard deviation wrt median! Setting it to zero....")); | |
1359 | aDCSArraySDMedian = 0; | |
1360 | } | |
44e45fac | 1361 | else{ |
c135d475 | 1362 | AliError(Form("Radical < 0 in computing standard deviation! Setting it to invalid....")); |
44e45fac | 1363 | aDCSArraySDMedian = AliGRPObject::GetInvalidFloat(); |
1364 | } | |
1365 | } | |
1366 | else { | |
1367 | aDCSArrayMean = AliGRPObject::GetInvalidFloat(); | |
1368 | aDCSArrayMedian = AliGRPObject::GetInvalidFloat(); | |
1369 | aDCSArraySDMean = AliGRPObject::GetInvalidFloat(); | |
1370 | } | |
fe726709 | 1371 | AliDebug(3,Form("iCounts1 = %d and temp1 = %f",iCounts1, temp1)); |
44e45fac | 1372 | if (iCounts1 > 0) { |
1373 | aDCSArrayTruncMean = temp1/iCounts1; | |
1374 | } | |
1375 | else{ | |
1376 | aDCSArrayTruncMean = AliGRPObject::GetInvalidFloat(); | |
1377 | } | |
1378 | ||
1379 | ||
1380 | ||
26c1dff2 | 1381 | AliDebug(2,Form("mean within %d counts = %f ",iCounts,aDCSArrayMean)); |
1382 | AliDebug(2,Form("truncated mean within %d counts = %f (%i values used)",iCounts,aDCSArrayTruncMean,iCounts1)); | |
1383 | AliDebug(2,Form("median within %d counts = %f ",iCounts,aDCSArrayMedian)); | |
1384 | AliDebug(2,Form("standard deviation with mean within %d counts = %f ",iCounts,aDCSArraySDMean)); | |
1385 | AliDebug(2,Form("standard deviation with median within %d counts = %f ",iCounts,aDCSArraySDMedian)); | |
44e45fac | 1386 | |
1387 | parameters[0] = aDCSArrayMean; | |
1388 | parameters[1] = aDCSArrayTruncMean; | |
1389 | parameters[2] = aDCSArrayMedian; | |
1390 | parameters[3] = aDCSArraySDMean; | |
1391 | parameters[4] = aDCSArraySDMedian; | |
1392 | ||
e75e6e01 | 1393 | 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])); |
1394 | //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 | 1395 | |
1396 | return parameters; | |
1397 | } | |
125567f8 | 1398 | |
e97cc90e | 1399 | |
44e45fac | 1400 | //_______________________________________________________________ |
e97cc90e | 1401 | |
fe726709 | 1402 | Char_t AliGRPPreprocessor::ProcessBool(const TObjArray* array, Bool_t &change) |
44e45fac | 1403 | { |
1404 | // | |
1405 | // processing Boolean values | |
1406 | // | |
1407 | ||
1408 | Bool_t aDCSBool = kTRUE; | |
1409 | ||
1410 | AliDCSValue *v = 0x0; | |
26c1dff2 | 1411 | |
44e45fac | 1412 | for(Int_t iCount = 0; iCount < array->GetEntries(); iCount++) { |
1413 | v = (AliDCSValue *)array->At(iCount); | |
26c1dff2 | 1414 | if (((Int_t)(v->GetTimeStamp()) < (Int_t)GetStartTimeDCSQuery()) || ((Int_t)(v->GetTimeStamp()) > (Int_t)GetEndTimeDCSQuery())) { |
44e45fac | 1415 | AliError(Form("DCS values for the parameter outside the queried interval")); |
1416 | continue; | |
1417 | } | |
1418 | if (iCount > 0) { | |
01920f0c | 1419 | if (aDCSBool != v->GetBool()) { |
1420 | AliError(Form("DCS values for the parameter changed from %d to %d within the queried interval", (UInt_t)aDCSBool, (UInt_t)v->GetBool())); | |
1421 | change = kTRUE; | |
1422 | } | |
44e45fac | 1423 | } |
1424 | aDCSBool = v->GetBool(); // always keeping last value | |
26c1dff2 | 1425 | AliDebug(2,Form("Bool = %d",(Int_t)aDCSBool)); |
44e45fac | 1426 | } |
1427 | ||
26c1dff2 | 1428 | Char_t caDCSBool = (Char_t) aDCSBool; |
44e45fac | 1429 | return caDCSBool; |
1430 | ||
1431 | } | |
e97cc90e | 1432 | |
44e45fac | 1433 | //_______________________________________________________________ |
e97cc90e | 1434 | |
39e3007b | 1435 | Float_t AliGRPPreprocessor::ProcessInt(const TObjArray* array) |
44e45fac | 1436 | { |
1437 | // | |
1438 | // processing Int values, returning mean | |
fe726709 | 1439 | // AliGRPObject::GetInvalidFloat() is returned if any of the DCS values |
1440 | // are outside the queried time interval or their value is out of range | |
44e45fac | 1441 | // |
1442 | ||
1443 | Float_t aDCSArraySum = 0.0; | |
1444 | Float_t aDCSArrayMean = 0.0; | |
1445 | Int_t iCounts = 0; | |
1446 | AliDCSValue* v = 0x0; | |
1447 | ||
1448 | for(Int_t iCount = 0; iCount < array->GetEntries(); iCount++) { | |
1449 | v = (AliDCSValue *)array->At(iCount); | |
fe726709 | 1450 | if ((v->GetInt() < fminInt) || (v->GetInt() > fmaxInt)) { |
1451 | AliError(Form("Error! Int value found in DCS map at %d-th entry is OUT OF RANGE: value = %d",iCount, v->GetInt())); | |
1452 | return AliGRPObject::GetInvalidFloat(); | |
1453 | } | |
26c1dff2 | 1454 | if(((Int_t)(v->GetTimeStamp()) >= (Int_t)GetStartTimeDCSQuery()) &&((Int_t)(v->GetTimeStamp()) <= (Int_t)GetEndTimeDCSQuery())) { |
44e45fac | 1455 | aDCSArraySum += v->GetInt(); |
1456 | iCounts += 1; | |
1457 | } | |
1458 | } | |
1459 | ||
1460 | if(iCounts != 0) aDCSArrayMean = aDCSArraySum/iCounts; | |
1461 | else aDCSArrayMean = AliGRPObject::GetInvalidFloat(); | |
1462 | ||
1463 | return aDCSArrayMean; | |
e97cc90e | 1464 | |
44e45fac | 1465 | } |
1466 | //_______________________________________________________________ | |
e7a6790f | 1467 | |
39e3007b | 1468 | Float_t AliGRPPreprocessor::ProcessUInt(const TObjArray* array) |
44e45fac | 1469 | { |
1470 | // | |
fe726709 | 1471 | // processing Int values, returning mean |
1472 | // AliGRPObject::GetInvalidFloat() is returned if any of the DCS values | |
1473 | // are outside the queried time interval or their value is out of range | |
44e45fac | 1474 | // |
1475 | ||
1476 | Float_t aDCSArraySum = 0.0; | |
1477 | Float_t aDCSArrayMean = 0.0; | |
1478 | Int_t iCounts = 0; | |
1479 | AliDCSValue* v = 0x0; | |
1480 | ||
1481 | for(Int_t iCount = 0; iCount < array->GetEntries(); iCount++) { | |
1482 | v = (AliDCSValue *)array->At(iCount); | |
fe726709 | 1483 | if ((v->GetUInt() < fminUInt) || (v->GetUInt() > fmaxUInt)) { |
1484 | AliError(Form("Error! UInt value found in DCS map at %d-th entry is OUT OF RANGE: value = %u",iCount,v->GetUInt())); | |
1485 | return AliGRPObject::GetInvalidFloat(); | |
1486 | } | |
26c1dff2 | 1487 | if(((Int_t)(v->GetTimeStamp()) >= (Int_t)GetStartTimeDCSQuery()) &&((Int_t)(v->GetTimeStamp()) <= (Int_t)GetEndTimeDCSQuery())) { |
44e45fac | 1488 | aDCSArraySum += v->GetUInt(); |
1489 | iCounts += 1; | |
1490 | } | |
1491 | } | |
1492 | ||
1493 | if(iCounts != 0) aDCSArrayMean = aDCSArraySum/iCounts; | |
1494 | else aDCSArrayMean = AliGRPObject::GetInvalidFloat(); | |
1495 | ||
1496 | return aDCSArrayMean; | |
e7a6790f | 1497 | |
17984b61 | 1498 | } |
125567f8 | 1499 | |
44e45fac | 1500 | |
17984b61 | 1501 | //_______________________________________________________________ |
44e45fac | 1502 | |
3ba92a38 | 1503 | AliDCSSensorArray *AliGRPPreprocessor::GetPressureMap(TMap* dcsAliasMap) |
e7a6790f | 1504 | { |
44e45fac | 1505 | // extract DCS pressure maps. Perform fits to save space |
1506 | ||
44e45fac | 1507 | TMap *map = fPressure->ExtractDCS(dcsAliasMap); |
1508 | if (map) { | |
1509 | fPressure->MakeSplineFit(map); | |
1510 | Double_t fitFraction = fPressure->NumFits()/fPressure->NumSensors(); | |
1511 | if (fitFraction > kFitFraction ) { | |
1512 | AliInfo(Form("Pressure values extracted, %d fits performed.", fPressure->NumFits())); | |
1513 | } else { | |
1514 | AliInfo("Too few pressure maps fitted!!!"); | |
1515 | } | |
1516 | } else { | |
1517 | AliInfo("no atmospheric pressure map extracted!!!"); | |
1518 | } | |
1519 | delete map; | |
1520 | ||
1521 | return fPressure; | |
17984b61 | 1522 | } |
e97cc90e | 1523 | |
1e27bb6b | 1524 | |
1525 | ||
1526 | //_______________________________________________________________ | |
03e5ee4f | 1527 | 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, TString &gdc) |
1e27bb6b | 1528 | { |
44e45fac | 1529 | // |
1530 | // Retrieves logbook and trigger information from the online logbook | |
1531 | // This information is needed for prompt reconstruction | |
1532 | // | |
1533 | // Parameters are: | |
1534 | // Run number | |
1535 | // DAQ params: dbHost, dbPort, dbName, user, password, logbookTable, triggerTable | |
1536 | // cdbRoot | |
1537 | // | |
1538 | // returns: | |
1539 | // positive on success: the return code is the run number of last run processed of the same run type already processed by the SHUTTLE | |
1540 | // 0 on success and no run was found | |
1541 | // negative on error | |
1542 | // | |
1543 | // This function is NOT called during the preprocessor run in the Shuttle! | |
1544 | // | |
1545 | ||
1546 | // defaults | |
1547 | if (dbPort == 0) | |
1548 | dbPort = 3306; | |
1549 | ||
1550 | // CDB connection | |
1551 | AliCDBManager* cdb = AliCDBManager::Instance(); | |
1552 | cdb->SetDefaultStorage(cdbRoot); | |
1553 | ||
1554 | // SQL connection | |
1555 | TSQLServer* server = TSQLServer::Connect(Form("mysql://%s:%d/%s", dbHost, dbPort, dbName), user, password); | |
1556 | ||
1557 | if (!server) | |
1558 | { | |
1559 | Printf("ERROR: Could not connect to DAQ LB"); | |
1560 | return -1; | |
1561 | } | |
1562 | ||
1563 | // main logbook | |
1564 | TString sqlQuery; | |
26c1dff2 | 1565 | sqlQuery.Form("SELECT DAQ_time_start, run_type, detectorMask, L3_magnetCurrent, Dipole_magnetCurrent FROM logbook WHERE run = %d", run); |
44e45fac | 1566 | TSQLResult* result = server->Query(sqlQuery); |
1567 | if (!result) | |
1568 | { | |
1569 | Printf("ERROR: Can't execute query <%s>!", sqlQuery.Data()); | |
1570 | return -2; | |
1571 | } | |
1572 | ||
1573 | if (result->GetRowCount() == 0) | |
1574 | { | |
1575 | Printf("ERROR: Run %d not found", run); | |
1576 | delete result; | |
1577 | return -3; | |
1578 | } | |
1579 | ||
1580 | TSQLRow* row = result->Next(); | |
1581 | if (!row) | |
1582 | { | |
1583 | Printf("ERROR: Could not receive data from run %d", run); | |
1584 | delete result; | |
1585 | return -4; | |
1586 | } | |
1587 | ||
26c1dff2 | 1588 | TString timeStartString(row->GetField(0)); |
44e45fac | 1589 | TString runType(row->GetField(1)); |
26c1dff2 | 1590 | TString detectorMaskString(row->GetField(2)); |
1591 | TString l3CurrentString(row->GetField(3)); | |
1592 | TString dipoleCurrentString(row->GetField(4)); | |
1593 | time_t timeStart = (time_t)(timeStartString.Atoi()); | |
1594 | UInt_t detectorMask = (UInt_t)(detectorMaskString.Atoi()); | |
1595 | Float_t l3Current = (Float_t)(TMath::Abs(l3CurrentString.Atof())); | |
1596 | Float_t dipoleCurrent = (Float_t)(TMath::Abs(dipoleCurrentString.Atof())); | |
03e5ee4f | 1597 | Char_t l3Polarity = (l3CurrentString.Atof() < 0) ? 1 : 0; |
1598 | Char_t dipolePolarity = (dipoleCurrentString.Atof() < 0) ? 1 : 0; | |
44e45fac | 1599 | |
26c1dff2 | 1600 | AliGRPObject * grpObj = new AliGRPObject(); |
1601 | grpObj->SetTimeStart(timeStart); | |
1602 | grpObj->SetRunType((TString)(row->GetField(1))); | |
1603 | grpObj->SetDetectorMask(detectorMask); | |
1604 | grpObj->SetL3Current(l3Current,(AliGRPObject::Stats)0); | |
1605 | grpObj->SetDipoleCurrent(dipoleCurrent,(AliGRPObject::Stats)0); | |
03e5ee4f | 1606 | grpObj->SetL3Polarity(l3Polarity); |
1607 | grpObj->SetDipolePolarity(dipolePolarity); | |
26c1dff2 | 1608 | |
44e45fac | 1609 | delete row; |
1610 | row = 0; | |
1611 | ||
1612 | delete result; | |
1613 | result = 0; | |
1614 | ||
1615 | Printf("Storing GRP/GRP/Data object with the following content"); | |
26c1dff2 | 1616 | grpObj->Dump(); |
44e45fac | 1617 | |
1618 | AliCDBMetaData metadata; | |
26c1dff2 | 1619 | metadata.SetResponsible("Jan Fiete Grosse-Oetringhaus & Chiara Zampolli"); |
44e45fac | 1620 | metadata.SetComment("GRP Output parameters received during online running"); |
1621 | ||
1622 | AliCDBId id("GRP/GRP/Data", run, run); | |
26c1dff2 | 1623 | Bool_t success = cdb->Put(grpObj, id, &metadata); |
44e45fac | 1624 | |
26c1dff2 | 1625 | delete grpObj; |
44e45fac | 1626 | |
1627 | if (!success) | |
1628 | { | |
1629 | Printf("ERROR: Could not store GRP/GRP/Data into OCDB"); | |
1630 | return -5; | |
1631 | } | |
1632 | ||
1633 | // Receive trigger information | |
1634 | sqlQuery.Form("SELECT configFile FROM logbook_trigger_config WHERE run = %d", run); | |
1635 | result = server->Query(sqlQuery); | |
1636 | if (!result) | |
1637 | { | |
1638 | Printf("ERROR: Can't execute query <%s>!", sqlQuery.Data()); | |
1639 | return -11; | |
1640 | } | |
1641 | ||
1642 | if (result->GetRowCount() == 0) | |
1643 | { | |
1644 | Printf("ERROR: Run %d not found in logbook_trigger_config", run); | |
1645 | delete result; | |
1646 | return -12; | |
1647 | } | |
1648 | ||
1649 | row = result->Next(); | |
1650 | if (!row) | |
1651 | { | |
1652 | Printf("ERROR: Could not receive logbook_trigger_config data from run %d", run); | |
1653 | delete result; | |
1654 | return -13; | |
1655 | } | |
1656 | ||
1657 | TString triggerConfig(row->GetField(0)); | |
1658 | ||
1659 | delete row; | |
1660 | row = 0; | |
1661 | ||
1662 | delete result; | |
1663 | result = 0; | |
1664 | ||
1665 | Printf("Found trigger configuration: %s", triggerConfig.Data()); | |
1666 | ||
1667 | AliTriggerConfiguration *runcfg = AliTriggerConfiguration::LoadConfigurationFromString(triggerConfig); | |
1668 | if (!runcfg) | |
1669 | { | |
1670 | Printf("ERROR: Could not create CTP configuration object"); | |
1671 | return -14; | |
1672 | } | |
1673 | ||
1674 | metadata.SetComment("CTP run configuration received during online running"); | |
1675 | ||
1676 | AliCDBId id2("GRP/CTP/Config", run, run); | |
1677 | success = cdb->Put(runcfg, id2, &metadata); | |
1678 | ||
1679 | delete runcfg; | |
1680 | runcfg = 0; | |
1681 | ||
1682 | if (!success) | |
1683 | { | |
1684 | Printf("ERROR: Could not store GRP/CTP/Config into OCDB"); | |
1685 | return -15; | |
1686 | } | |
1687 | ||
03e5ee4f | 1688 | |
1689 | // Receive list of GDCs for this run | |
1690 | sqlQuery.Form("SELECT GDC FROM logbook_stats_GDC WHERE run = %d", run); | |
1691 | result = server->Query(sqlQuery); | |
1692 | if (!result) | |
1693 | { | |
1694 | Printf("ERROR: Can't execute query <%s>!", sqlQuery.Data()); | |
1695 | return -24; | |
1696 | } | |
1697 | ||
1698 | if (result->GetRowCount() == 0) | |
1699 | { | |
1700 | Printf("ERROR: Run %d not found in logbook_stats_GDC", run); | |
1701 | delete result; | |
1702 | return -25; | |
1703 | } | |
2b81b7d0 | 1704 | |
1705 | gdc = ""; | |
1706 | for (Int_t iGDC = 0; iGDC < result->GetRowCount(); iGDC++) { | |
1707 | row = result->Next(); | |
1708 | if (!row) | |
1709 | { | |
1710 | Printf("ERROR: Could not receive logbook_stats_GDC data from run %d", run); | |
1711 | delete result; | |
1712 | return -26; | |
1713 | } | |
1714 | gdc += row->GetField(0); | |
1715 | gdc += " "; | |
1716 | } | |
1717 | ||
03e5ee4f | 1718 | delete row; |
1719 | row = 0; | |
1720 | ||
1721 | delete result; | |
1722 | result = 0; | |
1723 | ||
1724 | Printf("Found GDC: %s", gdc.Data()); | |
1725 | ||
44e45fac | 1726 | // get last run with same run type that was already processed by the SHUTTLE |
1727 | ||
1728 | 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()); | |
1729 | result = server->Query(sqlQuery); | |
1730 | if (!result) | |
1731 | { | |
1732 | Printf("ERROR: Can't execute query <%s>!", sqlQuery.Data()); | |
1733 | return -21; | |
1734 | } | |
1735 | ||
1736 | if (result->GetRowCount() == 0) | |
1737 | { | |
1738 | Printf("ERROR: No result with query <%s>", sqlQuery.Data()); | |
1739 | delete result; | |
1740 | return -22; | |
1741 | } | |
1742 | ||
1743 | row = result->Next(); | |
1744 | if (!row) | |
1745 | { | |
1746 | Printf("ERROR: Could not receive data for query <%s>", sqlQuery.Data()); | |
1747 | delete result; | |
1748 | return -23; | |
1749 | } | |
1750 | ||
1751 | TString lastRunStr(row->GetField(0)); | |
1752 | Int_t lastRun = lastRunStr.Atoi(); | |
1753 | ||
1754 | Printf("Last run with same run type %s is %d", runType.Data(), lastRun); | |
1755 | ||
1756 | delete row; | |
1757 | row = 0; | |
1758 | ||
1759 | delete result; | |
1760 | result = 0; | |
1761 | ||
1762 | server->Close(); | |
1763 | delete server; | |
1764 | server = 0; | |
1765 | ||
1766 | return lastRun; | |
1e27bb6b | 1767 | } |