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