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