]>
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> |
6a150f83 | 33 | #include <TFile.h> |
7ca4655f | 34 | |
fe726709 | 35 | #include <float.h> |
36 | ||
3dedb44a | 37 | #include "AliGRPPreprocessor.h" |
44e45fac | 38 | #include "AliGRPObject.h" |
39 | #include "AliDCSSensor.h" | |
40 | #include "AliSplineFit.h" | |
17984b61 | 41 | #include "AliDCSSensorArray.h" |
ea4a87ee | 42 | #include "AliRawEventHeaderVersions.h" |
3dedb44a | 43 | |
48b1b444 | 44 | #include "AliTriggerConfiguration.h" |
45 | #include "AliTriggerRunScalers.h" | |
6ecb073a | 46 | #include "AliTriggerInput.h" |
48b1b444 | 47 | |
3dedb44a | 48 | #include "AliCDBMetaData.h" |
6a150f83 | 49 | #include "AliESDVertex.h" |
0254e751 | 50 | #include "AliLHCReader.h" |
51 | #include "AliLHCData.h" | |
52 | #include "AliDCSArray.h" | |
6ecb073a | 53 | #include "AliDAQ.h" |
54 | #include "AliLTUConfig.h" | |
3dedb44a | 55 | |
ac152fdd | 56 | class AliLog; |
3dedb44a | 57 | class AliDCSValue; |
58 | class AliShuttleInterface; | |
59 | ||
1e27bb6b | 60 | // needed for ReceivePromptRecoParameters |
39e3007b | 61 | |
1e27bb6b | 62 | #include <TSQLServer.h> |
63 | #include <TSQLResult.h> | |
64 | #include <TSQLRow.h> | |
65 | #include <AliCDBManager.h> | |
66 | #include <AliCDBMetaData.h> | |
67 | #include <AliCDBId.h> | |
68 | #include <AliTriggerConfiguration.h> | |
6614fa48 | 69 | #include <AliCTPTimeParams.h> |
8c1f1006 | 70 | #include <AliLHCClockPhase.h> |
1e27bb6b | 71 | |
d7edf69d | 72 | const Double_t kFitFraction = -1.; // Fraction of DCS sensor fits required |
17984b61 | 73 | |
3dedb44a | 74 | ClassImp(AliGRPPreprocessor) |
75 | ||
17984b61 | 76 | //_______________________________________________________________ |
44e45fac | 77 | |
e3a2ac48 | 78 | const Int_t AliGRPPreprocessor::fgknDAQLbPar = 6; // num parameters in the logbook used to fill the GRP object |
0254e751 | 79 | const Int_t AliGRPPreprocessor::fgknDCSDP = 48; // number of dcs dps |
39e3007b | 80 | const Int_t AliGRPPreprocessor::fgknDCSDPHallProbes = 40; // number of dcs dps |
da0e365e | 81 | const Int_t AliGRPPreprocessor::fgknLHCDP = 6; // number of dcs dps from LHC data |
4bb7c769 | 82 | const Int_t AliGRPPreprocessor::fgkDCSDPHallTopShift = 4; // shift from the top to get tp the Hall Probes names in the list of DCS DPs |
9fae6417 | 83 | const Int_t AliGRPPreprocessor::fgkDCSDPNonWorking = 5; // number of non working DCS DPs |
e7a6790f | 84 | const char* AliGRPPreprocessor::fgkDCSDataPoints[AliGRPPreprocessor::fgknDCSDP] = { |
e7a6790f | 85 | "L3Polarity", |
86 | "DipolePolarity", | |
e7a6790f | 87 | "L3Current", |
88 | "DipoleCurrent", | |
44e45fac | 89 | "L3_BSF17_H1", |
90 | "L3_BSF17_H2", | |
91 | "L3_BSF17_H3", | |
92 | "L3_BSF17_Temperature", | |
93 | "L3_BSF4_H1", | |
94 | "L3_BSF4_H2", | |
95 | "L3_BSF4_H3", | |
96 | "L3_BSF4_Temperature", | |
97 | "L3_BKF17_H1", | |
98 | "L3_BKF17_H2", | |
99 | "L3_BKF17_H3", | |
100 | "L3_BKF17_Temperature", | |
101 | "L3_BKF4_H1", | |
102 | "L3_BKF4_H2", | |
103 | "L3_BKF4_H3", | |
104 | "L3_BKF4_Temperature", | |
105 | "L3_BSF13_H1", | |
106 | "L3_BSF13_H2", | |
107 | "L3_BSF13_H3", | |
108 | "L3_BSF13_Temperature", | |
109 | "L3_BSF8_H1", | |
110 | "L3_BSF8_H2", | |
111 | "L3_BSF8_H3", | |
112 | "L3_BSF8_Temperature", | |
113 | "L3_BKF13_H1", | |
114 | "L3_BKF13_H2", | |
115 | "L3_BKF13_H3", | |
116 | "L3_BKF13_Temperature", | |
117 | "L3_BKF8_H1", | |
118 | "L3_BKF8_H2", | |
119 | "L3_BKF8_H3", | |
120 | "L3_BKF8_Temperature", | |
121 | "Dipole_Inside_H1", | |
122 | "Dipole_Inside_H2", | |
123 | "Dipole_Inside_H3", | |
124 | "Dipole_Inside_Temperature", | |
125 | "Dipole_Outside_H1", | |
126 | "Dipole_Outside_H2", | |
127 | "Dipole_Outside_H3", | |
128 | "Dipole_Outside_Temperature", | |
e7a6790f | 129 | "CavernTemperature", |
130 | "CavernAtmosPressure", | |
ce996d13 | 131 | "SurfaceAtmosPressure", |
3343d11b | 132 | "CavernAtmosPressure2" |
e7a6790f | 133 | }; |
44e45fac | 134 | |
39e3007b | 135 | const char* AliGRPPreprocessor::fgkDCSDataPointsHallProbes[AliGRPPreprocessor::fgknDCSDPHallProbes] = { |
44e45fac | 136 | "L3_BSF17_H1", |
137 | "L3_BSF17_H2", | |
138 | "L3_BSF17_H3", | |
139 | "L3_BSF17_Temperature", | |
140 | "L3_BSF4_H1", | |
141 | "L3_BSF4_H2", | |
142 | "L3_BSF4_H3", | |
143 | "L3_BSF4_Temperature", | |
144 | "L3_BKF17_H1", | |
145 | "L3_BKF17_H2", | |
146 | "L3_BKF17_H3", | |
147 | "L3_BKF17_Temperature", | |
148 | "L3_BKF4_H1", | |
149 | "L3_BKF4_H2", | |
150 | "L3_BKF4_H3", | |
151 | "L3_BKF4_Temperature", | |
152 | "L3_BSF13_H1", | |
153 | "L3_BSF13_H2", | |
154 | "L3_BSF13_H3", | |
155 | "L3_BSF13_Temperature", | |
156 | "L3_BSF8_H1", | |
157 | "L3_BSF8_H2", | |
158 | "L3_BSF8_H3", | |
159 | "L3_BSF8_Temperature", | |
160 | "L3_BKF13_H1", | |
161 | "L3_BKF13_H2", | |
162 | "L3_BKF13_H3", | |
163 | "L3_BKF13_Temperature", | |
164 | "L3_BKF8_H1", | |
165 | "L3_BKF8_H2", | |
166 | "L3_BKF8_H3", | |
167 | "L3_BKF8_Temperature", | |
168 | "Dipole_Inside_H1", | |
169 | "Dipole_Inside_H2", | |
170 | "Dipole_Inside_H3", | |
171 | "Dipole_Inside_Temperature", | |
172 | "Dipole_Outside_H1", | |
173 | "Dipole_Outside_H2", | |
174 | "Dipole_Outside_H3", | |
3343d11b | 175 | "Dipole_Outside_Temperature" |
44e45fac | 176 | }; |
e7a6790f | 177 | |
0254e751 | 178 | const Short_t kSensors = 45; // start index position of sensor in DCS DPs |
ce996d13 | 179 | const Short_t kNumSensors = 3; // Number of sensors in DCS DPs (CavernAtmosPressure, SurfaceAtmosPressure, CavernAtmosPressure2) |
180 | ||
e7a6790f | 181 | |
0254e751 | 182 | const char* AliGRPPreprocessor::fgkLHCDataPoints[AliGRPPreprocessor::fgknLHCDP] = { |
5fb8d1a1 | 183 | "LHC_Beam_Energy", |
184 | "LHC_MachineMode", | |
185 | "LHC_BeamMode", | |
da0e365e | 186 | "LHC_Beams_Particle_Type", |
187 | "BPTX_Phase_Shift_B1", | |
188 | "BPTX_Phase_Shift_B2" | |
0254e751 | 189 | }; |
e07d2728 | 190 | |
e7a6790f | 191 | const char* kppError[] = { |
192 | "", | |
193 | "(DAQ logbook ERROR)", | |
194 | "(DAQ FXS ERROR)", | |
161a4dc3 | 195 | "(Trigger Scalers not found in DCS FXS - ERROR)", |
7e1a6c0b | 196 | "(DCS data points ERROR)", |
e75e6e01 | 197 | "(Trigger Configuration ERROR)", |
6614fa48 | 198 | "(DAQ logbook ERROR determining partition of the run)", |
6a150f83 | 199 | "(CTP timing ERROR)", |
0254e751 | 200 | "(SPD Mean Vertex ERROR)", |
201 | "(DCS FXS Error for LHC Data)", | |
da0e365e | 202 | "(LHC Data Error)", |
6ecb073a | 203 | "(LHC Clock Phase Error (from LHC Data))", |
204 | "(LTU Configuration Error)" | |
e7a6790f | 205 | }; |
17984b61 | 206 | |
3dedb44a | 207 | //_______________________________________________________________ |
44e45fac | 208 | |
3dedb44a | 209 | AliGRPPreprocessor::AliGRPPreprocessor(AliShuttleInterface* shuttle): |
c5340e82 | 210 | 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 | 211 | { |
44e45fac | 212 | // constructor - shuttle must be instantiated! |
ad103e84 | 213 | |
7eaa854b | 214 | AddRunType("COSMIC"); |
215 | AddRunType("LASER"); | |
44e45fac | 216 | AddRunType("PHYSICS"); |
c2ad5069 | 217 | AddRunType("CALIBRATION_BC"); |
218 | AddRunType("CALIBRATION_CENTRAL"); | |
219 | AddRunType("CALIBRATION_EMD"); | |
220 | AddRunType("CALIBRATION_MB"); | |
221 | AddRunType("CALIBRATION_SEMICENTRAL"); | |
69bf9b19 | 222 | AddRunType("CALIBRATION"); |
223 | AddRunType("PEDESTAL"); | |
7be24dea | 224 | AddRunType("STANDALONE"); |
225 | AddRunType("GAIN"); | |
3242245e | 226 | AddRunType("NOISE"); |
227 | AddRunType("PULSER"); | |
b7a928fe | 228 | AddRunType("STANDALONE_PULSER"); |
52439816 | 229 | AddRunType("STANDALONE_BC"); |
fe726709 | 230 | |
231 | fmaxFloat = FLT_MAX; | |
232 | fminFloat = -FLT_MAX; | |
233 | fmaxDouble = DBL_MAX; | |
234 | fminDouble = -DBL_MAX; | |
235 | fmaxInt = kMaxInt; | |
236 | fminInt = kMinInt; | |
237 | fmaxUInt = kMaxUInt; | |
238 | fminUInt = 0; | |
239 | ||
240 | AliInfo(Form("Max allowed float = %6.5e",fmaxFloat)); | |
241 | AliInfo(Form("Min allowed float = %6.5e",fminFloat)); | |
242 | AliInfo(Form("Max allowed double = %6.5e",fmaxDouble)); | |
243 | AliInfo(Form("Min allowed double = %6.5e",fminDouble)); | |
244 | AliInfo(Form("Max allowed integer = %d",fmaxInt)); | |
245 | AliInfo(Form("Min allowed integer = %d",fminInt)); | |
246 | AliInfo(Form("Max allowed unsigned integer = %u",(Int_t)fmaxUInt)); | |
247 | AliInfo(Form("Min allowed unsigned integer = %u",(Int_t)fminUInt)); | |
248 | ||
c5340e82 | 249 | ffailedDPs->SetOwner(kTRUE); |
3dedb44a | 250 | } |
251 | ||
252 | //_______________________________________________________________ | |
44e45fac | 253 | |
e7a6790f | 254 | AliGRPPreprocessor::~AliGRPPreprocessor() |
255 | { | |
44e45fac | 256 | //destructor |
257 | ||
258 | delete fPressure; | |
c5340e82 | 259 | delete ffailedDPs; |
260 | ||
3dedb44a | 261 | } |
262 | ||
263 | //_______________________________________________________________ | |
44e45fac | 264 | |
e7a6790f | 265 | void AliGRPPreprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime) |
266 | { | |
ce996d13 | 267 | // Initialize preprocessor |
17984b61 | 268 | |
ce996d13 | 269 | AliPreprocessor::Initialize(run, startTime, endTime); |
270 | ||
271 | AliInfo("Initialization of the GRP preprocessor."); | |
272 | AliInfo(Form("Start Time DCS = %d",GetStartTimeDCSQuery())); | |
273 | AliInfo(Form("End Time DCS = %d",GetEndTimeDCSQuery())); | |
274 | TClonesArray * array = new TClonesArray("AliDCSSensor",kNumSensors); | |
275 | for(Int_t j = 0; j < kNumSensors; j++) { | |
276 | AliDCSSensor * sens = new ((*array)[j])AliDCSSensor; | |
277 | sens->SetStringID(fgkDCSDataPoints[j+kSensors]); | |
278 | } | |
279 | AliInfo(Form("Pressure Entries: %d",array->GetEntries())); | |
280 | ||
281 | fPressure = new AliDCSSensorArray(GetStartTimeDCSQuery(), GetEndTimeDCSQuery(), array); | |
c5340e82 | 282 | |
283 | for (Int_t iDP=0; iDP < fgknDCSDP; iDP++){ | |
284 | TObjString* dp = new TObjString(fgkDCSDataPoints[iDP]); | |
285 | ffailedDPs->AddAt(dp,iDP); | |
286 | } | |
287 | ||
3dedb44a | 288 | } |
289 | ||
290 | //_______________________________________________________________ | |
44e45fac | 291 | |
e7a6790f | 292 | UInt_t AliGRPPreprocessor::Process(TMap* valueMap) |
293 | { | |
44e45fac | 294 | // process data retrieved by the Shuttle |
295 | ||
e75e6e01 | 296 | // retrieving "partition" and "detector" fields from DAQ logbook to |
297 | // determine the partition in which the run was taken | |
298 | // the partition is used to decide how to react in case of errors for CTP | |
299 | ||
300 | TString partition = (TString)GetRunParameter("partition"); | |
301 | TString detector = (TString)GetRunParameter("detector"); | |
302 | ||
44e45fac | 303 | AliGRPObject *grpobj = new AliGRPObject(); // object to store data |
5cf76849 | 304 | grpobj->SetBeamEnergyIsSqrtSHalfGeV(); // new format |
0254e751 | 305 | |
44e45fac | 306 | //=================// |
307 | // DAQ logbook // | |
308 | //=================// | |
e3a2ac48 | 309 | |
310 | Log("*************** Processing DAQ logbook"); | |
311 | ||
44e45fac | 312 | UInt_t error = 0; |
313 | ||
e75e6e01 | 314 | Int_t iDaqLB = ProcessDaqLB(grpobj); |
315 | TString runType = (TString)GetRunType(); | |
316 | TString beamType = (TString)GetRunParameter("beamType"); | |
e3a2ac48 | 317 | if(iDaqLB == fgknDAQLbPar) { |
318 | Log(Form("DAQ Logbook, successful! Retrieved %d/%d entries",iDaqLB,fgknDAQLbPar)); | |
e75e6e01 | 319 | } else { |
e3a2ac48 | 320 | Log(Form("DAQ Logbook, could not get all expected entries!!! Retrieved only %d/%d entries",iDaqLB,fgknDAQLbPar)); |
e75e6e01 | 321 | error |= 1; |
322 | } | |
44e45fac | 323 | |
324 | //=================// | |
325 | // DAQ FXS // | |
326 | //=================// | |
e3a2ac48 | 327 | |
328 | Log("*************** Processing DAQ FXS"); | |
329 | ||
44e45fac | 330 | UInt_t iDaqFxs = ProcessDaqFxs(); |
331 | if( iDaqFxs == 0 ) { | |
332 | Log(Form("DAQ FXS, successful!")); | |
333 | } else { | |
334 | Log(Form("DAQ FXS, could not store run raw tag file!!!")); | |
335 | error |= 2; | |
336 | } | |
337 | ||
338 | //=================// | |
339 | // DCS FXS // | |
340 | //=================// | |
e3a2ac48 | 341 | |
342 | Log("*************** Processing DCS FXS"); | |
343 | ||
e75e6e01 | 344 | UInt_t iDcsFxs = ProcessDcsFxs(partition, detector); |
44e45fac | 345 | if( iDcsFxs == 0 ) { |
346 | Log(Form("DCS FXS, successful!")); | |
e75e6e01 | 347 | } else if (iDcsFxs ==1) { |
76820ec2 | 348 | Log(Form("DCS FXS, Could not store CTP scalers!!!")); |
44e45fac | 349 | error |= 4; |
e75e6e01 | 350 | } else{ |
351 | Log(Form("Incorrect field in DAQ logbook for partition = %s and detector = %s, going into error without CTP scalers...",partition.Data(),detector.Data())); | |
352 | error |= 32; | |
44e45fac | 353 | } |
354 | ||
355 | //=================// | |
356 | // DCS data points // | |
357 | //=================// | |
e3a2ac48 | 358 | |
359 | Log("*************** Processing DCS DPs"); | |
360 | ||
7e6f5523 | 361 | Log(Form("Starting DCS Query at %d and finishing at %d",GetStartTimeDCSQuery(),GetEndTimeDCSQuery())); |
44e45fac | 362 | Int_t entries = ProcessDcsDPs( valueMap, grpobj ); |
9fae6417 | 363 | Log(Form("entries found = %d (should be %d)",entries, fgknDCSDP-fgkDCSDPNonWorking)); |
5fbf7677 | 364 | if (fdaqStartEndTimeOk){ |
9fae6417 | 365 | if( entries < fgknDCSDP - fgkDCSDPNonWorking ) { // L3_BSF4_H3, L3_BSF17_H1, L3_BSF17_H2, L3_BSF17_H3, L3_BSF17_Temperature are not working yet... |
366 | Log(Form("Possible problem with the DCS data points!!! Only %d/%d entries found - Please read further for more details",entries,fgknDCSDP-fgkDCSDPNonWorking)); | |
c5340e82 | 367 | Log(Form("The DPs giving problems were:")); |
368 | for (Int_t iDP = 0; iDP < fgknDCSDP; iDP++){ | |
369 | TObjString *dpString = (TObjString*)ffailedDPs->At(iDP); | |
370 | if (dpString){ | |
371 | TString name = dpString->String(); | |
9fae6417 | 372 | if (name != "L3_BSF4_H3" && name != "L3_BSF17_H1" && name != "L3_BSF17_H2" && name != "L3_BSF17_H3" && name != "L3_BSF17_Temperature" ){ |
c5340e82 | 373 | Log(Form("******** %s ******** not present, but foreseen --> causing an ERROR",name.Data())); |
374 | } | |
375 | else { | |
376 | 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())); | |
377 | } | |
378 | } | |
379 | } | |
5fbf7677 | 380 | error |= 8; |
381 | } | |
382 | else Log(Form("DCS data points, successful!")); | |
383 | } | |
384 | 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 | 385 | |
386 | //=======================// | |
387 | // Trigger Configuration // | |
388 | //=======================// | |
e75e6e01 | 389 | |
e3a2ac48 | 390 | Log("*************** Processing Trigger Configuration"); |
391 | ||
44e45fac | 392 | const char * triggerConf = GetTriggerConfiguration(); |
e75e6e01 | 393 | |
394 | if (partition.IsNull() && !detector.IsNull()){ // standalone partition | |
395 | Log("STANDALONE partition for current run, using Trigger Configuration dummy value"); | |
396 | AliCDBEntry *cdbEntry = GetFromOCDB("CTP","DummyConfig"); | |
397 | if (!cdbEntry) { | |
398 | Log(Form("No dummy CTP configuration entry found, going into error...")); | |
44e45fac | 399 | error |= 16; |
400 | } | |
e75e6e01 | 401 | else{ |
402 | AliTriggerConfiguration *runcfg = (AliTriggerConfiguration*)cdbEntry->GetObject(); | |
403 | if (!runcfg){ | |
404 | Log(Form("dummy CTP config not found in OCDB entry, going into error...")); | |
44e45fac | 405 | error |= 16; |
406 | } | |
e75e6e01 | 407 | else { |
408 | TString titleCTPcfg = Form("CTP cfg for run %i from Dummy entry in OCDB",fRun); | |
409 | runcfg->SetTitle(titleCTPcfg); | |
410 | AliCDBMetaData metaData; | |
411 | metaData.SetResponsible("Roman Lietava"); | |
412 | metaData.SetComment("CTP run configuration from dummy entry in OCDB"); | |
413 | if (!Store("CTP","Config", runcfg, &metaData, 0, 0)) { | |
414 | Log("Unable to store the dummy CTP run configuration object to OCDB!"); | |
415 | error |= 16; | |
416 | } | |
417 | } | |
44e45fac | 418 | } |
419 | } | |
a453acbf | 420 | |
e75e6e01 | 421 | else if (!partition.IsNull() && detector.IsNull()){ // global partition |
422 | Log("GLOBAL partition for current run, using Trigger Configuration from DAQ Logbook"); | |
423 | if (triggerConf!= NULL) { | |
424 | Log("Found trigger configuration in DAQ logbook"); | |
425 | AliTriggerConfiguration *runcfg = AliTriggerConfiguration::LoadConfigurationFromString(triggerConf); | |
44e45fac | 426 | if (!runcfg) { |
e75e6e01 | 427 | Log("Bad CTP run configuration file from DAQ logbook! The corresponding CDB entry will not be filled!"); |
428 | error |= 16; | |
44e45fac | 429 | } |
430 | else { | |
e75e6e01 | 431 | TString titleCTPcfg = Form("CTP cfg for run %i from DAQ",fRun); |
44e45fac | 432 | runcfg->SetTitle(titleCTPcfg); |
433 | AliCDBMetaData metaData; | |
434 | metaData.SetBeamPeriod(0); | |
435 | metaData.SetResponsible("Roman Lietava"); | |
e75e6e01 | 436 | metaData.SetComment("CTP run configuration from DAQ logbook"); |
44e45fac | 437 | if (!Store("CTP","Config", runcfg, &metaData, 0, 0)) { |
438 | Log("Unable to store the CTP run configuration object to OCDB!"); | |
439 | error |= 16; | |
440 | } | |
441 | } | |
442 | } | |
e75e6e01 | 443 | |
444 | else { | |
445 | Log("Trigger configuration NULL in DAQ logbook"); | |
446 | error |= 16; | |
447 | } | |
448 | } | |
449 | ||
450 | else { | |
451 | Log(Form("Incorrect field in DAQ logbook for partition = %s and detector = %s, going into error without trigger configuration...",partition.Data(),detector.Data())); | |
452 | error |= 32; | |
44e45fac | 453 | } |
e75e6e01 | 454 | |
6614fa48 | 455 | //===========================// |
456 | // Trigger Timing Parameters // | |
457 | //===========================// | |
458 | ||
e3a2ac48 | 459 | Log("*************** Processing Trigger Time Params"); |
6614fa48 | 460 | |
461 | const char * triggerCTPtiming = GetCTPTimeParams(); | |
462 | ||
463 | if (partition.IsNull() && !detector.IsNull()){ // standalone partition | |
464 | Log("STANDALONE partition for current run, using CTP timing params dummy value"); | |
465 | AliCDBEntry *cdbEntry = GetFromOCDB("CTP","DummyCTPtime"); | |
466 | if (!cdbEntry) { | |
467 | Log(Form("No dummy CTP timing parameters entry found, going into error...")); | |
468 | error |= 64; | |
469 | } | |
470 | else{ | |
471 | AliCTPTimeParams *runCTPtiming = (AliCTPTimeParams*)cdbEntry->GetObject(); | |
472 | if (!runCTPtiming){ | |
473 | Log(Form("dummy CTP timing parameters not found in OCDB entry, going into error...")); | |
474 | error |= 64; | |
475 | } | |
476 | else { | |
477 | TString titleCTPtiming = Form("CTP timing params for run %i from Dummy entry in OCDB",fRun); | |
478 | runCTPtiming->SetTitle(titleCTPtiming); | |
479 | AliCDBMetaData metadata; | |
480 | metadata.SetResponsible("Roman Lietava"); | |
481 | metadata.SetComment("CTP run timing parameters from dummy entry in OCDB"); | |
482 | if (!Store("CTP","CTPtiming", runCTPtiming, &metadata, 0, 0)) { | |
483 | Log("Unable to store the dummy CTP timing params object to OCDB!"); | |
484 | error |= 64; | |
485 | } | |
486 | } | |
487 | } | |
488 | } | |
489 | ||
490 | else if (!partition.IsNull() && detector.IsNull()){ // global partition | |
491 | Log("GLOBAL partition for current run, using Trigger Timing Parameters from DAQ Logbook"); | |
492 | if (triggerCTPtiming!= NULL) { | |
493 | Log("Found trigger timing params in DAQ logbook"); | |
494 | AliDebug(2,Form("%s",triggerCTPtiming)); | |
dd5ac86b | 495 | AliCTPTimeParams *runCTPtiming = AliCTPTimeParams::LoadCTPTimeParamsFromString(triggerCTPtiming); |
6614fa48 | 496 | if (!runCTPtiming) { |
497 | Log("Bad CTP trigger timing params file from DAQ logbook! The corresponding CDB entry will not be filled!"); | |
498 | error |= 64; | |
499 | } | |
500 | else { | |
501 | TString titleCTPtiming = Form("CTP timing params for run %i from DAQ",fRun); | |
502 | runCTPtiming->SetTitle(titleCTPtiming); | |
503 | AliCDBMetaData metadata; | |
504 | metadata.SetBeamPeriod(0); | |
505 | metadata.SetResponsible("Roman Lietava"); | |
506 | metadata.SetComment("CTP timing params from DAQ logbook"); | |
507 | if (!Store("CTP","CTPtiming", runCTPtiming, &metadata, 0, 0)) { | |
508 | Log("Unable to store the CTP timing params object to OCDB!"); | |
509 | error |= 64; | |
510 | } | |
511 | } | |
512 | } | |
513 | ||
514 | else { | |
515 | Log("Trigger timing params NULL in DAQ logbook"); | |
516 | error |= 64; | |
517 | } | |
518 | } | |
519 | ||
520 | else { | |
521 | Log(Form("Incorrect field in DAQ logbook for partition = %s and detector = %s, going into error without trigger timing parameters...",partition.Data(),detector.Data())); | |
522 | error |= 32; | |
523 | } | |
e75e6e01 | 524 | |
6ecb073a | 525 | //===========================// |
526 | // LTU Configuration // | |
527 | //===========================// | |
528 | ||
529 | Log("*************** Processing LTU Configuration"); | |
530 | ||
531 | if (partition.IsNull() && !detector.IsNull()){ // standalone partition | |
532 | Log("STANDALONE partition for current run, not retrieving LTU configuration"); | |
533 | /* | |
534 | Log("STANDALONE partition for current run, using LTU configuration dummy value"); | |
535 | AliCDBEntry *cdbEntry = GetFromOCDB("CTP","DummyLTUConfig"); | |
536 | if (!cdbEntry) { | |
537 | Log(Form("No dummy LTU Config entry found, going into error...")); | |
538 | error |= 2048; | |
539 | } | |
540 | else{ | |
541 | TObjArray *ltuConfig = (TObjArray*)cdbEntry->GetObject(); | |
542 | if (!ltuConfig){ | |
543 | Log(Form("dummy LTU Config not found in OCDB entry, going into error...")); | |
544 | error |= 2048; | |
545 | } | |
546 | else { | |
547 | AliCDBMetaData metadata; | |
548 | metadata.SetResponsible("Roman Lietava"); | |
549 | metadata.SetComment("LTU Config from dummy entry in OCDB"); | |
550 | if (!Store("CTP","LTUConfig", ltuConfig, &metadata, 0, 0)) { | |
551 | Log("Unable to store the dummy LTU Config object to OCDB!"); | |
552 | error |= 2048; | |
553 | } | |
554 | } | |
555 | } | |
556 | */ | |
557 | } | |
558 | ||
559 | else if (!partition.IsNull() && detector.IsNull()){ // global partition | |
560 | ||
561 | Log("GLOBAL partition for current run, getting LTU Config from DAQ Logbook (logbook_detectors table)"); | |
562 | UInt_t detectorMask = (UInt_t)(((TString)GetRunParameter("detectorMask")).Atoi()); | |
563 | Printf ("detectormask = %d",detectorMask); | |
564 | TObjArray * ltuarray = new TObjArray(); | |
565 | ltuarray->SetOwner(1); | |
566 | Bool_t isLTUok = kTRUE; | |
567 | for(Int_t i = 0; i<AliDAQ::kNDetectors-2; i++){ | |
568 | if ((detectorMask >> i) & 0x1) { | |
569 | TString det = AliDAQ::OfflineModuleName(i); | |
570 | TString detCTPName = AliTriggerInput::fgkCTPDetectorName[i]; | |
571 | if (detCTPName == "CTP") detCTPName="TRG"; // converting according to what is found in DAQ logbook_detectors | |
572 | Printf("Processing detector %s (CTP Detector name %s)",det.Data(),detCTPName.Data()); | |
573 | TString* ltu = GetLTUConfig(detCTPName.Data()); | |
574 | if (!ltu){ | |
575 | Log(Form("No LTU Configuration from DAQ logbook for detector %s (BUT it was expected)! The corresponding CDB entry will not be filled!",detCTPName.Data())); | |
576 | error |= 2048; | |
577 | isLTUok = kFALSE; | |
578 | break; | |
579 | } | |
580 | else{ | |
581 | Float_t ltuFineDelay1 = ltu[0].Atof(); | |
582 | Float_t ltuFineDelay2 = ltu[1].Atof(); | |
583 | Float_t ltuBCDelayAdd = ltu[2].Atof(); | |
584 | const char* name = AliDAQ::DetectorName(i); | |
585 | AliLTUConfig* ltuConfig = new AliLTUConfig((UChar_t)AliDAQ::DetectorID(name),ltuFineDelay1,ltuFineDelay2,ltuBCDelayAdd); | |
586 | ltuarray->AddAtAndExpand(ltuConfig,i); | |
587 | } | |
588 | } | |
589 | } | |
590 | if (isLTUok){ | |
591 | AliCDBMetaData metadata; | |
592 | metadata.SetBeamPeriod(0); | |
593 | metadata.SetResponsible("Roman Lietava"); | |
594 | metadata.SetComment("LTU Configuration for current run"); | |
595 | if (!Store("CTP","LTUConfig", ltuarray, &metadata, 0, 0)) { | |
596 | Log("Unable to store the LTU Config object to OCDB!"); | |
597 | error |= 2048; | |
598 | } | |
599 | } | |
600 | if (ltuarray) delete ltuarray; | |
601 | } | |
602 | ||
603 | else { | |
604 | Log(Form("Incorrect field in DAQ logbook for partition = %s and detector = %s, going into error without trigger timing parameters...",partition.Data(),detector.Data())); | |
605 | error |= 32; | |
606 | } | |
607 | ||
0254e751 | 608 | |
609 | //=================// | |
610 | // LHC Data // | |
611 | //=================// | |
612 | ||
e07d2728 | 613 | if (runType == "PHYSICS"){ // processing the LHC file only in PHYSICS runs |
614 | Log("*************** Processing LHC Data"); | |
615 | ||
616 | UInt_t iLHCData = ProcessLHCData(grpobj); | |
617 | ||
618 | if( iLHCData == 0 ) { | |
619 | Log(Form("LHC Data from DCS FXS, successful!")); | |
620 | } else if (iLHCData == 1) { | |
621 | Log(Form("LHC Data, problems with DCS FXS!")); | |
622 | error |= 256; | |
da0e365e | 623 | } else if (iLHCData == 2) { |
624 | Log(Form("LHC Data, problems with DAQ_time_start/DAQ_time_end!")); | |
625 | error |= 512; | |
e07d2728 | 626 | } else if (iLHCData ==3){ |
da0e365e | 627 | Log(Form("Problems in storing LHC Phase - going into Error")); |
628 | error |= 1024; | |
e07d2728 | 629 | } else if (iLHCData ==4){ |
da0e365e | 630 | Log(Form("Problems with LHC Phase - going into Error")); |
631 | error |= 1024; | |
e07d2728 | 632 | } else{ |
633 | Log(Form("LHC Data problems")); | |
634 | error |= 512; | |
635 | } | |
44e45fac | 636 | |
e07d2728 | 637 | } |
638 | ||
6a150f83 | 639 | //==================// |
640 | // SPD Mean Vertex // | |
641 | //==================// | |
e3a2ac48 | 642 | |
643 | Log("*************** Processing SPD Mean Vertex"); | |
644 | ||
62d2c16a | 645 | if (runType == "PHYSICS"){ |
646 | UInt_t iSPDMeanVertex = ProcessSPDMeanVertex(); | |
647 | if( iSPDMeanVertex == 1 ) { | |
648 | Log(Form("SPD Mean Vertex, successful!")); | |
649 | } else { | |
650 | Log(Form("SPD Mean Vertex failed!!!")); | |
651 | error |= 128; | |
652 | } | |
6a150f83 | 653 | } |
62d2c16a | 654 | else { |
655 | Log("SPD Mean Vertex not processed since runType != PHYSICS"); | |
656 | } | |
657 | ||
0254e751 | 658 | // storing AliGRPObject in OCDB |
659 | ||
660 | AliCDBMetaData md; | |
661 | md.SetResponsible("Chiara Zampolli"); | |
662 | md.SetComment("Output parameters from the GRP preprocessor."); | |
663 | ||
664 | Bool_t result = kTRUE; | |
665 | result = Store("GRP", "Data", grpobj, &md); | |
666 | delete grpobj; | |
667 | ||
44e45fac | 668 | if (result && !error ) { |
669 | Log("GRP Preprocessor Success"); | |
670 | return 0; | |
671 | } else { | |
6ecb073a | 672 | Log( Form("GRP Preprocessor FAILS!!! %s%s%s%s%s%s%s%s%s%s%s%s", |
44e45fac | 673 | kppError[(error&1)?1:0], |
674 | kppError[(error&2)?2:0], | |
675 | kppError[(error&4)?3:0], | |
676 | kppError[(error&8)?4:0], | |
e75e6e01 | 677 | kppError[(error&16)?5:0], |
6614fa48 | 678 | kppError[(error&32)?6:0], |
6a150f83 | 679 | kppError[(error&64)?7:0], |
0254e751 | 680 | kppError[(error&128)?8:0], |
681 | kppError[(error&256)?9:0], | |
da0e365e | 682 | kppError[(error&512)?10:0], |
6ecb073a | 683 | kppError[(error&1024)?11:0], |
684 | kppError[(error&2048)?12:0] | |
44e45fac | 685 | )); |
686 | return error; | |
687 | } | |
0254e751 | 688 | |
689 | ||
690 | } | |
691 | ||
692 | //_______________________________________________________________ | |
693 | ||
694 | UInt_t AliGRPPreprocessor::ProcessLHCData(AliGRPObject *grpobj) | |
695 | { | |
696 | // | |
697 | //Getting the LHC Data from DCS FXS | |
698 | // | |
699 | ||
700 | TString timeStartString = (TString)GetRunParameter("DAQ_time_start"); | |
701 | TString timeEndString = (TString)GetRunParameter("DAQ_time_end"); | |
e541e2aa | 702 | if (timeStartString.IsNull() || timeEndString.IsNull()){ |
0254e751 | 703 | if (timeStartString.IsNull()){ |
704 | AliError("DAQ_time_start not set in logbook! Setting statistical values for current DP to invalid"); | |
705 | } | |
e541e2aa | 706 | else if (timeEndString.IsNull()){ |
0254e751 | 707 | AliError("DAQ_time_end not set in logbook! Setting statistical values for current DP to invalid"); |
708 | } | |
709 | return 2; | |
710 | } | |
711 | ||
712 | Double_t timeStart = timeStartString.Atof(); | |
713 | Double_t timeEnd = timeEndString.Atof(); | |
714 | ||
0254e751 | 715 | TString fileName = GetFile(kDCS, "LHCData",""); |
716 | if (fileName.Length()>0){ | |
717 | AliInfo("Got The LHC Data file"); | |
e541e2aa | 718 | AliLHCReader lhcReader; |
49822138 | 719 | |
720 | // Processing data to be put in AliGRPObject | |
721 | ||
722 | // Energy | |
79350b54 | 723 | Log("*************Energy "); |
49822138 | 724 | TObjArray* energyArray = lhcReader.ReadSingleLHCDP(fileName.Data(),fgkLHCDataPoints[0]); |
725 | if (energyArray){ | |
4cbf81c1 | 726 | Float_t energy = ProcessEnergy(energyArray,timeStart); |
ac152fdd | 727 | if (energy != -1.) { |
49822138 | 728 | grpobj->SetBeamEnergy(energy); |
729 | grpobj->SetBeamEnergyIsSqrtSHalfGeV(kTRUE); | |
0254e751 | 730 | } |
49822138 | 731 | delete energyArray; |
732 | } | |
733 | else { | |
734 | AliError("Energy not found in LHC Data file!!!"); | |
735 | } | |
736 | ||
4cbf81c1 | 737 | Double_t timeBeamModeEnd = timeEnd; // max validity for Beam Mode |
738 | Double_t timeMachineModeEnd = timeEnd; // max validity for Machine Mode | |
739 | Double_t timeBeamEnd = timeEnd; // max validity for Beam Type | |
740 | Double_t timeBeamModeStart = -1; // min validity for Beam Mode | |
741 | Double_t timeMachineModeStart = -1; // min validity for Machine Mode | |
742 | Double_t timeBeamStart = -1; // min validity for Beam Type | |
743 | Int_t indexBeamMode = -1; // index of measurement used to set Beam Mode | |
744 | Int_t indexMachineMode = -1; // index of measurement used to set Beam Mode | |
745 | Int_t indexBeam = -1; // index of measurement used to set Beam Mode | |
746 | Bool_t foundBeamModeStart = kFALSE; // flag to be set in case an entry for the Beam Mode is found before (or at) SOR | |
747 | Bool_t foundMachineModeStart = kFALSE; // flag to be set in case an entry for the Beam Mode is found before (or at) SOR | |
748 | Bool_t foundBeamStart = kFALSE; // flag to be set in case an entry for the Beam Mode is found before (or at) SOR | |
749 | Bool_t flagBeamMode = kFALSE; //flag set true if a changed occurred in BeamMode | |
750 | Bool_t flagMachineMode = kFALSE; //flag set true if a changed occurred in MachineMode | |
751 | Bool_t flagBeam = kFALSE; //flag set true if a changed occurred in BeamType | |
49822138 | 752 | |
753 | // BeamMode | |
79350b54 | 754 | Log("*************BeamMode (LHCState) "); |
49822138 | 755 | TObjArray* beamModeArray = lhcReader.ReadSingleLHCDP(fileName.Data(),fgkLHCDataPoints[2]); |
756 | Int_t nBeamMode = -1; | |
757 | if (beamModeArray){ | |
758 | nBeamMode = beamModeArray->GetEntries(); | |
759 | if (nBeamMode==0){ | |
79350b54 | 760 | AliInfo("Found zero entries for the Beam Mode, leaving it empty"); |
49822138 | 761 | } |
762 | else{ | |
4cbf81c1 | 763 | for (Int_t iBeamMode = 0; iBeamMode<nBeamMode; iBeamMode++){ |
764 | AliDCSArray* beamMode = (AliDCSArray*)beamModeArray->At(iBeamMode); | |
765 | if (beamMode){ | |
766 | if (beamMode->GetTimeStamp()<=timeStart && beamMode->GetTimeStamp()>=timeBeamModeStart){// taking always the very last entry: of two measurements have the same timestamp, the last one is taken | |
767 | timeBeamModeStart = beamMode->GetTimeStamp(); | |
768 | indexBeamMode = iBeamMode; | |
769 | foundBeamModeStart = kTRUE; | |
79350b54 | 770 | } |
4cbf81c1 | 771 | else { |
772 | break; | |
773 | ||
79350b54 | 774 | } |
49822138 | 775 | } |
4cbf81c1 | 776 | } |
777 | if (!foundBeamModeStart){ | |
778 | AliInfo("No value for the Beam Mode found before start of run, the Beam Mode will remain empty"); | |
40e422c8 | 779 | } |
49822138 | 780 | else { |
4cbf81c1 | 781 | AliDCSArray* beamMode = (AliDCSArray*)beamModeArray->At(indexBeamMode); |
782 | TObjString* beamModeString = beamMode->GetStringArray(0); | |
783 | AliInfo(Form("LHC State (corresponding to BeamMode) = %s (set at %f)",(beamModeString->String()).Data(),beamMode->GetTimeStamp())); | |
784 | grpobj->SetLHCState(beamModeString->String()); | |
785 | if (indexBeamMode < nBeamMode-1){ | |
786 | AliDCSArray* beamMode1 = (AliDCSArray*)beamModeArray->At(indexBeamMode+1); | |
787 | if (beamMode1){ | |
788 | if (beamMode1->GetTimeStamp()<=timeStart){ | |
789 | AliError("you did not choose the correct value! there is still something before (or at) SOR, but later than this!"); | |
790 | } | |
791 | else if (beamMode1->GetTimeStamp()>timeStart && beamMode1->GetTimeStamp()<=timeEnd){ | |
792 | timeBeamModeEnd = beamMode1->GetTimeStamp(); | |
793 | TObjString* beamModeString1 = beamMode1->GetStringArray(0); | |
794 | TString bmString0 = beamModeString->String(); | |
795 | TString bmString1 = beamModeString1->String(); | |
796 | if (bmString0.CompareTo(bmString1.Data(),TString::kIgnoreCase) == -1){ | |
6720fa1f | 797 | AliWarning(Form("The beam mode changed from %s to %s during the run at timestamp %f! Setting it to %s and keeping track of the time of the change to set MaxTimeLHCValidity afterward",bmString0.Data(), bmString1.Data(), timeBeamModeEnd, bmString0.Data())); |
4cbf81c1 | 798 | flagBeamMode = kTRUE; |
79350b54 | 799 | } |
49822138 | 800 | } |
79350b54 | 801 | } |
802 | else { | |
4cbf81c1 | 803 | AliInfo("Invalid pointer for the first entry for Beam Mode after the first valid one, not considering anything after what has already been found"); |
5fb8d1a1 | 804 | } |
805 | } | |
40e422c8 | 806 | } |
0d361338 | 807 | } |
49822138 | 808 | delete beamModeArray; |
809 | } | |
810 | else{ | |
811 | AliError("Beam mode array not found in LHC Data file!!!"); | |
812 | } | |
813 | ||
814 | // MachineMode | |
79350b54 | 815 | Log("*************MachineMode "); |
49822138 | 816 | TObjArray* machineModeArray = lhcReader.ReadSingleLHCDP(fileName.Data(),fgkLHCDataPoints[1]); |
817 | Int_t nMachineMode = -1; | |
818 | if (machineModeArray){ | |
819 | nMachineMode = machineModeArray->GetEntries(); | |
820 | if (nMachineMode==0){ | |
821 | AliInfo("No Machine Mode found, leaving it empty"); | |
0254e751 | 822 | } |
49822138 | 823 | else{ |
4cbf81c1 | 824 | for (Int_t iMachineMode = 0; iMachineMode<nMachineMode; iMachineMode++){ |
825 | AliDCSArray* machineMode = (AliDCSArray*)machineModeArray->At(iMachineMode); | |
79350b54 | 826 | if (machineMode){ |
4cbf81c1 | 827 | if (machineMode->GetTimeStamp()<=timeStart && machineMode->GetTimeStamp()>=timeMachineModeStart){// taking always the very last entry: of two measurements have the same timestamp, the last one is taken |
828 | timeMachineModeStart = machineMode->GetTimeStamp(); | |
829 | indexMachineMode = iMachineMode; | |
830 | foundMachineModeStart = kTRUE; | |
79350b54 | 831 | } |
832 | else{ | |
4cbf81c1 | 833 | break; |
79350b54 | 834 | } |
49822138 | 835 | } |
4cbf81c1 | 836 | } |
837 | if (!foundMachineModeStart){ | |
838 | AliInfo("No value for the Machine Mode found before start of run, the Machine Mode will remain empty"); | |
40e422c8 | 839 | } |
49822138 | 840 | else { |
4cbf81c1 | 841 | AliDCSArray* machineMode = (AliDCSArray*)machineModeArray->At(indexMachineMode); |
842 | TObjString* machineModeString = machineMode->GetStringArray(0); | |
843 | AliInfo(Form("MachineMode = %s (set at %f)",(machineModeString->String()).Data(),machineMode->GetTimeStamp())); | |
844 | grpobj->SetMachineMode(machineModeString->String()); | |
845 | if (indexMachineMode < nMachineMode-1){ | |
846 | AliDCSArray* machineMode1 = (AliDCSArray*)machineModeArray->At(indexMachineMode+1); | |
847 | if (machineMode1){ | |
848 | if (machineMode1->GetTimeStamp()>timeStart && machineMode1->GetTimeStamp()<=timeEnd){ | |
849 | timeMachineModeEnd = machineMode1->GetTimeStamp(); | |
850 | TObjString* machineModeString1 = machineMode1->GetStringArray(0); | |
851 | TString mmString0 = machineModeString->String(); | |
852 | TString mmString1 = machineModeString1->String(); | |
853 | if (mmString0.CompareTo(mmString1.Data(),TString::kIgnoreCase) == -1){ | |
6720fa1f | 854 | AliWarning(Form("The machine mode changed from %s to %s during the run at timestamp %f! Setting it to %s and keeping track of the time of the change to set MaxTimeLHCValidity afterward",mmString0.Data(),mmString1.Data(),timeMachineModeEnd,mmString0.Data())); |
4cbf81c1 | 855 | flagMachineMode = kTRUE; |
79350b54 | 856 | } |
49822138 | 857 | } |
79350b54 | 858 | } |
4cbf81c1 | 859 | else { |
860 | AliInfo("Invalid pointer for the first entry for Machine Mode after the first valid one, not considering anything after what has already been found"); | |
49822138 | 861 | } |
862 | } | |
49822138 | 863 | } |
864 | } | |
865 | delete machineModeArray; | |
866 | } | |
4cbf81c1 | 867 | else{ |
49822138 | 868 | AliError("Machine mode array not found in LHC Data file!!!"); |
4cbf81c1 | 869 | } |
49822138 | 870 | |
871 | // BeamType1 and BeamType2 - both put in the same string | |
79350b54 | 872 | Log("*************BeamType "); |
49822138 | 873 | TObjArray* beamArray = lhcReader.ReadSingleLHCDP(fileName.Data(),fgkLHCDataPoints[3]); |
874 | if (beamArray){ | |
875 | Int_t nBeam = beamArray->GetEntries(); | |
876 | if (nBeam==0){ | |
877 | AliInfo("No Beam Type found, leaving it empty"); | |
878 | } | |
879 | else{ | |
4cbf81c1 | 880 | for (Int_t iBeam = 0; iBeam<nBeam; iBeam++){ |
881 | AliDCSArray* beam = (AliDCSArray*)beamArray->At(iBeam); | |
79350b54 | 882 | if (beam){ |
4cbf81c1 | 883 | if (beam->GetTimeStamp()<=timeStart && beam->GetTimeStamp()>=timeBeamStart){// taking always the very last entry: of two measurements have the same timestamp, the last one is taken |
884 | timeBeamStart = beam->GetTimeStamp(); | |
885 | indexBeam = iBeam; | |
886 | foundBeamStart = kTRUE; | |
79350b54 | 887 | } |
4cbf81c1 | 888 | else{ |
889 | break; | |
79350b54 | 890 | } |
891 | } | |
4cbf81c1 | 892 | } |
893 | if (!foundBeamStart){ | |
5755755a | 894 | AliInfo("No value for the Beam Type found before start of run, the Machine Mode will remain empty"); |
4cbf81c1 | 895 | } |
896 | else { | |
897 | AliDCSArray* beam = (AliDCSArray*)beamArray->At(indexBeam); | |
898 | TObjString* beamString = beam->GetStringArray(0); | |
899 | TString beamType = beamString->String(); | |
900 | AliInfo(Form("Beam Type = %s",beamType.Data())); | |
901 | if (beamType.CompareTo("PROTON",TString::kIgnoreCase) == 0){ | |
902 | AliInfo("Setting beam type to p-p"); | |
903 | grpobj->SetBeamType("p-p"); | |
904 | } | |
5755755a | 905 | else { // if there is no PROTON beam, we suppose it is Pb, and we put A-A |
906 | AliInfo("Setting beam type to A-A"); | |
907 | grpobj->SetBeamType("A-A"); | |
908 | } | |
909 | /* | |
910 | else if (beamType.CompareTo("LEAD82",TString::kIgnoreCase) == 0){ | |
4cbf81c1 | 911 | AliInfo("Setting beam type to Pb-Pb"); |
912 | grpobj->SetBeamType("Pb-Pb"); | |
913 | } | |
79350b54 | 914 | else{ |
4cbf81c1 | 915 | AliError("Beam Type not known, leaving it empty"); |
79350b54 | 916 | } |
5755755a | 917 | */ |
4cbf81c1 | 918 | if (indexBeam < nBeam-1){ |
919 | AliDCSArray* beam1 = (AliDCSArray*)beamArray->At(indexBeam+1); | |
920 | if (beam1){ | |
921 | if (beam1->GetTimeStamp()>timeStart && beam1->GetTimeStamp()<=timeEnd){ | |
922 | timeBeamEnd = beam1->GetTimeStamp(); | |
923 | TObjString* beamString1 = beam1->GetStringArray(0); | |
924 | TString beamType1 = beamString1->String(); | |
925 | if (beamType.CompareTo(beamType1.Data(),TString::kIgnoreCase) == -1){ | |
6720fa1f | 926 | AliWarning(Form("The Beam Type changed from %s to %s during the run at timestamp %f! Setting it to %s and keeping track of the time of the change to set MaxTimeLHCValidity afterward",beamType.Data(),(beamString1->String()).Data(),timeBeamEnd,beamType.Data())); |
4cbf81c1 | 927 | flagBeam = kTRUE; |
79350b54 | 928 | } |
79350b54 | 929 | } |
930 | } | |
4cbf81c1 | 931 | else { |
932 | AliInfo("Invalid pointer for the first entry for Beam Type after the first valid one, not considering anything after what has already been found"); | |
e07d2728 | 933 | } |
934 | } | |
e07d2728 | 935 | } |
936 | } | |
49822138 | 937 | delete beamArray; |
938 | } | |
939 | else{ | |
4cbf81c1 | 940 | AliError("Beam Type array not found in LHC Data file!!!"); |
941 | } | |
49822138 | 942 | |
943 | // Setting minTimeLHCValidity | |
4cbf81c1 | 944 | if (timeBeamModeEnd!=0 || timeMachineModeEnd!=0 || timeBeamEnd !=0){ |
49822138 | 945 | Double_t minTimeLHCValidity; |
4cbf81c1 | 946 | if (flagBeamMode == kFALSE && flagMachineMode == kFALSE && flagBeam == kTRUE){ // flagBeam only true |
947 | minTimeLHCValidity = timeBeamEnd; | |
49822138 | 948 | } |
4cbf81c1 | 949 | else if (flagBeamMode == kFALSE && flagMachineMode == kTRUE && flagBeam == kFALSE){ // flagMachineMode only true |
950 | minTimeLHCValidity = timeMachineModeEnd; | |
49822138 | 951 | } |
4cbf81c1 | 952 | else if (flagBeamMode == kTRUE && flagMachineMode == kFALSE && flagBeam == kFALSE){ // flagBeamMode only true |
953 | minTimeLHCValidity = timeBeamModeEnd; | |
49822138 | 954 | } |
4cbf81c1 | 955 | else if (flagBeamMode == kFALSE && flagMachineMode == kTRUE && flagBeam == kTRUE){ // flagBeam and flagMachineMode only true |
956 | minTimeLHCValidity= TMath::Min(timeBeamEnd,timeMachineModeEnd); | |
49822138 | 957 | } |
4cbf81c1 | 958 | else if (flagBeamMode == kTRUE && flagMachineMode == kFALSE && flagBeam == kTRUE){ // flagBeam and flagBeamMode only true |
959 | minTimeLHCValidity= TMath::Min(timeBeamEnd,timeBeamModeEnd); | |
49822138 | 960 | } |
4cbf81c1 | 961 | else if (flagBeamMode == kTRUE && flagMachineMode == kTRUE && flagBeam == kFALSE){ // flagMachineMode and flagBeamMode only true |
962 | minTimeLHCValidity= TMath::Min(timeMachineModeEnd,timeBeamModeEnd); | |
0254e751 | 963 | } |
49822138 | 964 | else { |
4cbf81c1 | 965 | Double_t arrayTimes[3] = {timeBeamModeEnd,timeMachineModeEnd,timeBeamEnd};// flagMachineMode and flagBeamMode and flagBeam |
49822138 | 966 | minTimeLHCValidity= TMath::MinElement(3,arrayTimes); |
967 | } | |
968 | AliWarning(Form("Setting MaxTimeLHCValidity to %f",minTimeLHCValidity)); | |
969 | grpobj->SetMaxTimeLHCValidity(minTimeLHCValidity); | |
970 | } | |
971 | ||
972 | // Processing data to go to AliLHCData object | |
63bd40f4 | 973 | AliLHCData* dt = new AliLHCData(fileName.Data(),timeStart,timeEnd); |
974 | // storing AliLHCData in OCDB | |
975 | if (dt){ | |
976 | AliInfo(Form("Filled %d records to AliLHCData object",dt->GetData().GetEntriesFast())); | |
977 | AliCDBMetaData md; | |
978 | md.SetResponsible("Ruben Shahoyan"); | |
979 | md.SetComment("LHC data from the GRP preprocessor."); | |
980 | Bool_t result = kTRUE; | |
981 | result = Store("GRP", "LHCData", dt, &md); | |
982 | delete dt; | |
da0e365e | 983 | if (!result){ |
984 | Log(Form("Problems in storing LHC Data - but not going into Error")); | |
985 | } | |
986 | } | |
987 | ||
988 | // processing LHC Phase | |
989 | ||
990 | TObjArray *beam1phase = lhcReader.ReadSingleLHCDP(fileName.Data(),fgkLHCDataPoints[4]); | |
991 | TObjArray *beam2phase = lhcReader.ReadSingleLHCDP(fileName.Data(),fgkLHCDataPoints[5]); | |
992 | if (beam1phase == 0x0 || beam2phase == 0x0){ | |
993 | Log(Form("Problems in retrieving LHC Clock data from LHC file")); | |
994 | return 4; | |
995 | } | |
17fd2848 | 996 | AliLHCClockPhase *phaseObj = ProcessLHCClockPhase(beam1phase,beam2phase,timeEnd); |
da0e365e | 997 | if (phaseObj){ |
998 | AliInfo(Form("LHC Phase found")); | |
999 | AliCDBMetaData mdPhase; | |
1000 | mdPhase.SetResponsible("Cvetan Cheshkov"); | |
1001 | mdPhase.SetComment("LHC Clock Phase"); | |
1002 | Bool_t result = kTRUE; | |
1003 | result = Store("Calib", "LHCClockPhase", phaseObj, &mdPhase); | |
1004 | delete phaseObj; | |
1005 | if (!result) return 3; | |
0254e751 | 1006 | } |
da0e365e | 1007 | else return 4; |
0254e751 | 1008 | } |
49822138 | 1009 | |
0254e751 | 1010 | else { |
1011 | AliError("No LHCData file found in DCS FXS"); | |
1012 | return 1; | |
1013 | } | |
79350b54 | 1014 | |
1015 | return 0; | |
17984b61 | 1016 | } |
1017 | ||
6a150f83 | 1018 | //_______________________________________________________________ |
1019 | ||
1020 | UInt_t AliGRPPreprocessor::ProcessSPDMeanVertex() | |
1021 | { | |
0254e751 | 1022 | // |
6a150f83 | 1023 | //Getting the SPD Mean Vertex |
0254e751 | 1024 | // |
1025 | ||
6a150f83 | 1026 | TList* list = GetForeignFileSources("SPD", kDAQ, "VertexDiamond"); |
1027 | Bool_t storeResult = kTRUE; | |
1028 | if (list !=0x0 && list->GetEntries()!=0) | |
1029 | { | |
1030 | AliInfo("The following sources produced files with the id VertexDiamond from SPD"); | |
1031 | list->Print(); | |
1032 | for (Int_t jj=0;jj<list->GetEntries();jj++){ | |
1033 | TObjString * str = dynamic_cast<TObjString*> (list->At(jj)); | |
1034 | AliInfo(Form("found source %s", str->String().Data())); | |
1035 | TString fileNameRun = GetForeignFile("SPD", kDAQ, "VertexDiamond", str->GetName()); | |
1036 | if (fileNameRun.Length()>0){ | |
1037 | AliInfo(Form("Got the file %s", fileNameRun.Data())); | |
1038 | TFile daqFile(fileNameRun.Data(),"READ"); | |
1039 | if (daqFile.IsOpen()) { | |
1040 | AliESDVertex* meanVtx = dynamic_cast<AliESDVertex*>(daqFile.Get("MeanVertexPos")); | |
1041 | if (meanVtx){ | |
1042 | meanVtx->Print(); | |
1043 | // storing in the OCDB | |
1044 | AliCDBMetaData md; | |
1045 | md.SetResponsible("Cvetan Cheshkov"); | |
1046 | md.SetComment("SPD Mean Vertex"); | |
295c54b0 | 1047 | storeResult = Store("Calib", "MeanVertexSPD", meanVtx, &md, 0, kTRUE); |
6a150f83 | 1048 | } |
1049 | else{ | |
1050 | AliWarning("No SPD Mean Vertex object found in file"); | |
1051 | } | |
1052 | } | |
1053 | else { | |
1054 | AliError("Can't open file"); | |
1055 | storeResult = kFALSE; | |
1056 | } | |
1057 | } | |
1058 | else{ | |
1059 | AliWarning("No file found for current source for SPD Mean Vertex"); | |
1060 | } | |
1061 | } | |
1062 | } | |
1063 | else { | |
1064 | AliWarning("No list found for SPD Mean Vertex"); | |
1065 | } | |
1066 | ||
1067 | if (list) delete list; | |
1068 | ||
1069 | return storeResult; | |
1070 | } | |
1071 | ||
1072 | ||
17984b61 | 1073 | //_______________________________________________________________ |
17984b61 | 1074 | |
e75e6e01 | 1075 | Int_t AliGRPPreprocessor::ProcessDaqLB(AliGRPObject* grpObj) |
44e45fac | 1076 | { |
1077 | //Getting the DAQ lb information | |
1078 | ||
e75e6e01 | 1079 | time_t timeStart = (time_t)(((TString)GetRunParameter("DAQ_time_start")).Atoi()); |
1080 | time_t timeEnd = (time_t)(((TString)GetRunParameter("DAQ_time_end")).Atoi()); | |
1081 | Float_t beamEnergy = (Float_t)(((TString)GetRunParameter("beamEnergy")).Atof()); | |
44e45fac | 1082 | TString beamType = (TString)GetRunParameter("beamType"); |
1083 | Char_t numberOfDetectors = (Char_t)(((TString)GetRunParameter("numberOfDetectors")).Atoi()); | |
e75e6e01 | 1084 | UInt_t detectorMask = (UInt_t)(((TString)GetRunParameter("detectorMask")).Atoi()); |
44e45fac | 1085 | TString lhcPeriod = (TString)GetRunParameter("LHCperiod"); |
1086 | TString runType = (TString)GetRunType(); | |
1087 | ||
e75e6e01 | 1088 | UInt_t nparameter = 0; |
44e45fac | 1089 | if (timeStart != 0){ |
1090 | grpObj->SetTimeStart(timeStart); | |
1091 | Log(Form("Start time for run %d: %d",fRun, (Int_t)timeStart)); | |
e75e6e01 | 1092 | nparameter++; |
44e45fac | 1093 | } |
1094 | else { | |
e3a2ac48 | 1095 | Log(Form("Start time not put in logbook, setting to invalid in GRP entry, and causing an error!")); |
44e45fac | 1096 | } |
1097 | ||
1098 | if (timeEnd != 0){ | |
1099 | grpObj->SetTimeEnd(timeEnd); | |
1100 | Log(Form("End time for run %d: %i",fRun, (Int_t)timeEnd)); | |
e75e6e01 | 1101 | nparameter++; |
44e45fac | 1102 | } |
1103 | else { | |
e3a2ac48 | 1104 | Log(Form("End time not put in logbook, setting to invalid in GRP entry, and causing an error!")); |
44e45fac | 1105 | } |
1106 | ||
1107 | if (beamEnergy != 0){ | |
e3a2ac48 | 1108 | Log(Form("Beam Energy for run %d: %f (NOT USING IT TO FILL THE GRP OBJECT, taking it from the LHC file)",fRun, beamEnergy)); |
44e45fac | 1109 | } |
1110 | else { | |
e3a2ac48 | 1111 | Log(Form("Beam Energy not put in logbook, but not using it anyway for the GRP object (taking it from the LHC file)")); |
44e45fac | 1112 | } |
1113 | ||
44e45fac | 1114 | |
1115 | if (beamType.Length() != 0){ | |
e3a2ac48 | 1116 | Log(Form("Beam Type for run %d: %s (NOT USING IT TO FILL THE GRP OBJECT, taking it from the LHC file)",fRun, beamType.Data())); |
44e45fac | 1117 | } |
1118 | else { | |
e3a2ac48 | 1119 | Log(Form("Beam Type not put in logbook, but not using it anyway for the GRP entry (taking it from the LHC file)")); |
44e45fac | 1120 | } |
1121 | ||
1122 | if (numberOfDetectors != 0){ | |
1123 | grpObj->SetNumberOfDetectors(numberOfDetectors); | |
1124 | Log(Form("Number Of Detectors for run %d: %d",fRun, (Int_t)numberOfDetectors)); | |
e75e6e01 | 1125 | nparameter++; |
44e45fac | 1126 | } |
1127 | else { | |
e3a2ac48 | 1128 | Log(Form("Number Of Detectors not put in logbook, setting to invalid in GRP entry, and causing an error!")); |
44e45fac | 1129 | } |
1130 | ||
1131 | if (detectorMask != 0){ | |
1132 | grpObj->SetDetectorMask(detectorMask); | |
1133 | Log(Form("Detector Mask for run %d: %d",fRun, detectorMask)); | |
e75e6e01 | 1134 | nparameter++; |
44e45fac | 1135 | } |
1136 | else { | |
e3a2ac48 | 1137 | Log(Form("Detector Mask not put in logbook, setting to invalid in GRP entry, and causing an error!")); |
44e45fac | 1138 | } |
1139 | ||
1140 | if (lhcPeriod.Length() != 0) { | |
1141 | grpObj->SetLHCPeriod(lhcPeriod); | |
1142 | Log(Form("LHC period (DAQ) for run %d: %s",fRun, lhcPeriod.Data())); | |
e75e6e01 | 1143 | nparameter++; |
1144 | } | |
1145 | else { | |
e3a2ac48 | 1146 | Log(Form("LHCperiod not put in logbook, setting to invalid in GRP entry, and causing an error!")); |
44e45fac | 1147 | } |
1148 | if (runType.Length() != 0) { | |
1149 | grpObj->SetRunType(runType); | |
1150 | Log(Form("Run Type (DAQ) for run %d: %s",fRun, runType.Data())); | |
e75e6e01 | 1151 | nparameter++; |
1152 | } | |
1153 | else { | |
e3a2ac48 | 1154 | Log(Form("Run Type not put in logbook, setting to invalid in GRP entry, and causing an error!")); |
44e45fac | 1155 | } |
1156 | ||
e75e6e01 | 1157 | return nparameter; |
44e45fac | 1158 | } |
17984b61 | 1159 | |
44e45fac | 1160 | //_______________________________________________________________ |
17984b61 | 1161 | |
44e45fac | 1162 | UInt_t AliGRPPreprocessor::ProcessDaqFxs() |
1163 | { | |
1164 | //======DAQ FXS======// | |
1165 | ||
ea4a87ee | 1166 | AliRawEventHeaderV3_9::Class()->IgnoreTObjectStreamer(); // to avoid trying reading TObject store in AliRawEventHeaderV3_9 - temporary fix |
44e45fac | 1167 | TList* list = GetFileSources(kDAQ); |
1168 | if (!list) { | |
1169 | Log("No raw data tag list: connection problems with DAQ FXS logbook!"); | |
1170 | return 1; | |
1171 | } | |
1172 | ||
1173 | if (list->GetEntries() == 0) { | |
1174 | Log("no raw data tags in this run: nothing to merge!"); | |
1175 | delete list; list=0; | |
1176 | return 0; | |
1177 | } | |
1178 | ||
1179 | TChain *fRawTagChain = new TChain("T"); | |
1180 | Int_t nFiles=0; | |
1181 | TIterator* iter = list->MakeIterator(); | |
1182 | TObject* obj = 0; | |
1183 | while ((obj = iter->Next())) { | |
1184 | TObjString* objStr = dynamic_cast<TObjString*> (obj); | |
1185 | if (objStr) { | |
1186 | Log(Form("Found source %s", objStr->String().Data())); | |
1187 | TList* list2 = GetFileIDs(kDAQ, objStr->String()); | |
1188 | if (!list2) { | |
1189 | Log("No list with ids from DAQ was found: connection problems with DAQ FXS logbook!"); | |
1190 | delete fRawTagChain; fRawTagChain=0; | |
1191 | return 1; | |
1192 | } | |
1193 | Log(Form("Number of ids: %d",list2->GetEntries())); | |
1194 | for(Int_t i = 0; i < list2->GetEntries(); i++) { | |
1195 | TObjString *idStr = (TObjString *)list2->At(i); | |
1196 | TString fileName = GetFile(kDAQ,idStr->String().Data(),objStr->String().Data()); | |
1197 | if (fileName.Length() > 0) { | |
1198 | Log(Form("Adding file in the chain: %s",fileName.Data())); | |
1199 | fRawTagChain->Add(fileName.Data()); | |
1200 | nFiles++; | |
1201 | } else { | |
1202 | Log(Form("Could not retrieve file with id %s from source %s: " | |
1203 | "connection problems with DAQ FXS!", | |
1204 | idStr->String().Data(), objStr->String().Data())); | |
1205 | delete list; list=0; | |
1206 | delete list2; list2=0; | |
1207 | delete fRawTagChain; fRawTagChain=0; | |
1208 | return 2; | |
1209 | } | |
1210 | } | |
1211 | delete list2; | |
1212 | } | |
1213 | } | |
1214 | ||
1215 | TString fRawDataFileName = "GRP_Merged.tag.root"; | |
1216 | Log(Form("Merging %d raw data tags into file: %s", nFiles, fRawDataFileName.Data())); | |
7e6f5523 | 1217 | |
44e45fac | 1218 | if( fRawTagChain->Merge(fRawDataFileName) < 1 ) { |
1219 | Log("Error merging raw data files!!!"); | |
1220 | return 3; | |
1221 | } | |
7e6f5523 | 1222 | |
44e45fac | 1223 | TString outputfile = Form("Run%d.Merged.RAW.tag.root", fRun); |
1224 | Bool_t result = StoreRunMetadataFile(fRawDataFileName.Data(),outputfile.Data()); | |
1225 | ||
1226 | if (!result) { | |
1227 | Log("Problem storing raw data tags in local file!!!"); | |
1228 | } else { | |
1229 | Log("Raw data tags merged successfully!!"); | |
1230 | } | |
1231 | ||
1232 | delete iter; | |
1233 | delete list; | |
1234 | delete fRawTagChain; fRawTagChain=0; | |
1235 | ||
1236 | if (result == kFALSE) { | |
1237 | return 4; | |
1238 | } | |
1239 | ||
1240 | return 0; | |
1241 | ||
1242 | } | |
17984b61 | 1243 | |
44e45fac | 1244 | //_______________________________________________________________ |
e75e6e01 | 1245 | UInt_t AliGRPPreprocessor::ProcessDcsFxs(TString partition, TString detector) |
44e45fac | 1246 | { |
39e3007b | 1247 | |
1248 | // processing the info | |
1249 | // stored in the DCS FXS | |
1250 | // coming from the trigger | |
1251 | ||
e75e6e01 | 1252 | // Get the CTP counters information |
1253 | ||
1254 | if (partition.IsNull() && !detector.IsNull()){ // standalone partition | |
161a4dc3 | 1255 | Log("STANDALONE partition for current run, using Trigger Scalers dummy value"); |
e75e6e01 | 1256 | AliCDBEntry *cdbEntry = GetFromOCDB("CTP","DummyScalers"); |
1257 | if (!cdbEntry) { | |
1258 | Log(Form("No dummy CTP scalers entry found, going into error...")); | |
44e45fac | 1259 | return 1; |
1260 | } | |
e75e6e01 | 1261 | else{ |
1262 | AliTriggerRunScalers *scalers = (AliTriggerRunScalers*)cdbEntry->GetObject(); | |
1263 | if (!scalers){ | |
1264 | Log(Form("CTP dummy scalers not found in OCDB entry, going into error...")); | |
1265 | return 1; | |
1266 | } | |
1267 | else { | |
1268 | AliCDBMetaData metaData; | |
1269 | metaData.SetResponsible("Roman Lietava"); | |
1270 | metaData.SetComment("CTP scalers from dummy entry in OCDB"); | |
1271 | if (!Store("CTP","Scalers", scalers, &metaData, 0, 0)) { | |
1272 | Log("Unable to store the dummy CTP scalers object to OCDB!"); | |
1273 | return 1; | |
1274 | } | |
1275 | } | |
1276 | } | |
1277 | } | |
1278 | ||
1279 | else if (!partition.IsNull() && detector.IsNull()){ // global partition | |
1280 | Log("GLOBAL partition for current run, using CTP scalers from DCS FXS"); | |
1281 | TString countersfile = GetFile(kDCS, "CTP_xcounters",""); | |
1282 | if (countersfile.IsNull()) { | |
1283 | Log("No CTP counters files has been found: empty source!"); | |
44e45fac | 1284 | return 1; |
1285 | } | |
1286 | else { | |
e75e6e01 | 1287 | Log(Form("File with Id CTP_xcounters found in DCS FXS! Copied to %s",countersfile.Data())); |
1288 | AliTriggerRunScalers *scalers = AliTriggerRunScalers::ReadScalers(countersfile); | |
1289 | if (!scalers) { | |
1290 | Log("Bad CTP counters file! The corresponding CDB entry will not be filled!"); | |
1291 | return 1; | |
1292 | } | |
1293 | else { | |
1294 | AliCDBMetaData metaData; | |
1295 | metaData.SetBeamPeriod(0); | |
1296 | metaData.SetResponsible("Roman Lietava"); | |
1297 | metaData.SetComment("CTP scalers"); | |
1298 | if (!Store("CTP","Scalers", scalers, &metaData, 0, 0)) { | |
1299 | Log("Unable to store the CTP scalers object to OCDB!"); | |
e541e2aa | 1300 | delete scalers; |
e75e6e01 | 1301 | return 1; |
44e45fac | 1302 | } |
1303 | } | |
e541e2aa | 1304 | delete scalers; |
44e45fac | 1305 | } |
44e45fac | 1306 | } |
1307 | ||
e75e6e01 | 1308 | |
1309 | else{ | |
1310 | Log(Form("Incorrect field in DAQ logbook for partition = %s and detector = %s, going into error...",partition.Data(),detector.Data())); | |
1311 | return 2; | |
1312 | } | |
1313 | ||
44e45fac | 1314 | return 0; |
e75e6e01 | 1315 | |
44e45fac | 1316 | } |
1317 | //_______________________________________________________________ | |
17984b61 | 1318 | |
44e45fac | 1319 | Int_t AliGRPPreprocessor::ProcessDcsDPs(TMap* valueMap, AliGRPObject* grpObj) |
1320 | { | |
17984b61 | 1321 | |
44e45fac | 1322 | // |
1323 | // processing DCS DPs | |
1324 | // | |
1325 | ||
26c1dff2 | 1326 | Int_t entries = 0; // counting the entries that are in the DCS DB, not taking care whether they have values or not |
44e45fac | 1327 | Int_t nL3Entries = 0; |
1328 | Int_t nDipoleEntries = 0; | |
1329 | Int_t nEnvEntries = 0; | |
1330 | Int_t nHallProbesEntries = 0; | |
44e45fac | 1331 | nL3Entries = ProcessL3DPs(valueMap, grpObj); |
1332 | nDipoleEntries = ProcessDipoleDPs(valueMap, grpObj); | |
1333 | nEnvEntries = ProcessEnvDPs(valueMap, grpObj); | |
1334 | nHallProbesEntries = ProcessHPDPs(valueMap, grpObj); | |
fab61587 | 1335 | grpObj->SetPolarityConventionLHC(); // after the dipole cables swap we comply with LHC convention |
0254e751 | 1336 | Log(Form("L3Entries = %d, nDipoleEntries =%d, nEnvEntries = %d, nHallProbesEntries = %d", nL3Entries, nDipoleEntries, nEnvEntries, nHallProbesEntries)); |
1337 | entries = nL3Entries + nDipoleEntries + nEnvEntries + nHallProbesEntries; | |
44e45fac | 1338 | return entries; |
17984b61 | 1339 | |
17984b61 | 1340 | } |
1341 | ||
1342 | //_______________________________________________________________ | |
29cc8704 | 1343 | |
39e3007b | 1344 | Int_t AliGRPPreprocessor::ProcessL3DPs(const TMap* valueMap, AliGRPObject* grpObj) |
44e45fac | 1345 | { |
39e3007b | 1346 | |
1347 | // processing DPs | |
1348 | // related to | |
1349 | // L3 info | |
1350 | ||
44e45fac | 1351 | Int_t nL3Entries = 0; |
c5340e82 | 1352 | |
44e45fac | 1353 | TObjArray *array = 0x0; |
1354 | Int_t indexDP = -1; | |
fe726709 | 1355 | Bool_t isZero = kTRUE; // flag to monitor L3Current. If set to true, the magnet is OFF, and the polarity can change |
44e45fac | 1356 | |
fe726709 | 1357 | AliInfo(Form("==========L3Current===========")); |
1358 | Bool_t outOfRange = kFALSE; // flag to monitor if any value collected by DCS is out of range | |
1359 | indexDP = kL3Current; | |
44e45fac | 1360 | array = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[indexDP]); |
1361 | if(!array) { | |
1362 | Log(Form("%s not found in the map!!!",fgkDCSDataPoints[indexDP])); | |
1363 | } | |
1364 | else { | |
26c1dff2 | 1365 | if (array->GetEntries() == 0){ |
fe726709 | 1366 | AliError(Form("No entries found in array! setting %s to invalid...",fgkDCSDataPoints[indexDP])); |
26c1dff2 | 1367 | } |
1368 | else { | |
fe726709 | 1369 | Float_t *floatDCS = ProcessFloatAllMagnet(array, indexDP, isZero); |
1370 | if (floatDCS != NULL){ | |
1371 | grpObj->SetL3Current(floatDCS); | |
1372 | } | |
1373 | else{ | |
1374 | outOfRange = kTRUE; | |
1375 | } | |
03672227 | 1376 | if (floatDCS){ |
1377 | delete[] floatDCS; | |
1378 | floatDCS = 0x0; | |
1379 | } | |
26c1dff2 | 1380 | } |
c5340e82 | 1381 | if (!outOfRange) { |
1382 | nL3Entries++; | |
1383 | ffailedDPs->RemoveAt(indexDP); | |
1384 | } | |
44e45fac | 1385 | } |
1386 | ||
1387 | if (array) array = 0x0; | |
1388 | ||
fe726709 | 1389 | AliInfo(Form("==========L3Polarity===========")); |
1390 | indexDP = kL3Polarity; | |
44e45fac | 1391 | array = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[indexDP]); |
1392 | if(!array) { | |
1393 | Log(Form("%s not found in the map!!!",fgkDCSDataPoints[indexDP])); | |
1394 | } | |
1395 | else { | |
26c1dff2 | 1396 | if (array->GetEntries() == 0){ |
fe726709 | 1397 | AliError(Form("No entries found in array! setting %s Polarity to invalid...",fgkDCSDataPoints[indexDP])); |
26c1dff2 | 1398 | } |
1399 | else { | |
fe726709 | 1400 | Bool_t change = kFALSE; |
1401 | Char_t charDCS = ProcessBool(array,change); | |
01920f0c | 1402 | if (change == kFALSE){ |
fe726709 | 1403 | grpObj->SetL3Polarity(charDCS); |
1404 | AliInfo(Form("%s set to %d",fgkDCSDataPoints[indexDP],(Int_t)(grpObj->GetL3Polarity()))); | |
c5340e82 | 1405 | ffailedDPs->RemoveAt(indexDP); |
fe726709 | 1406 | nL3Entries++; |
1407 | } | |
1408 | else if (isZero){ | |
ac833e7a | 1409 | AliInfo(Form("%s set to invalid, but magnet was OFF (according to the current), DP not considered wrong",fgkDCSDataPoints[indexDP])); |
c5340e82 | 1410 | ffailedDPs->RemoveAt(indexDP); |
fe726709 | 1411 | nL3Entries++; |
1412 | } | |
1413 | else { | |
ac833e7a | 1414 | 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 | 1415 | } |
26c1dff2 | 1416 | } |
44e45fac | 1417 | } |
1418 | ||
1419 | return nL3Entries; | |
e7a6790f | 1420 | |
44e45fac | 1421 | } |
1422 | //_______________________________________________________________ | |
ff97356e | 1423 | |
39e3007b | 1424 | Int_t AliGRPPreprocessor::ProcessDipoleDPs(const TMap* valueMap, AliGRPObject* grpObj) |
44e45fac | 1425 | { |
39e3007b | 1426 | // processing DPs |
1427 | // related to | |
1428 | // the Dipole info | |
1429 | ||
44e45fac | 1430 | Int_t nDipoleEntries = 0; |
1431 | TObjArray *array = 0x0; | |
1432 | Int_t indexDP = -1; | |
fe726709 | 1433 | Bool_t isZero = kTRUE; // flag to monitor L3Current. If set to true, the magnet is OFF, and the polarity can change |
44e45fac | 1434 | |
fe726709 | 1435 | AliInfo(Form("==========DipoleCurrent===========")); |
1436 | Bool_t outOfRange = kFALSE; // flag to monitor if any value collected by DCS is out of range | |
1437 | indexDP = kDipoleCurrent; | |
44e45fac | 1438 | array = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[indexDP]); |
44e45fac | 1439 | if(!array) { |
1440 | Log(Form("%s not found in the map!!!",fgkDCSDataPoints[indexDP])); | |
1441 | } | |
1442 | else { | |
26c1dff2 | 1443 | if (array->GetEntries() == 0){ |
1444 | AliError(Form("No entries found in array! setting %s to invalid...",fgkDCSDataPoints[indexDP])); | |
1445 | } | |
1446 | else { | |
fe726709 | 1447 | Float_t *floatDCS = ProcessFloatAllMagnet(array, indexDP, isZero); |
1448 | if (floatDCS != NULL){ | |
1449 | grpObj->SetDipoleCurrent(floatDCS); | |
1450 | } | |
1451 | else{ | |
1452 | outOfRange=kTRUE; | |
1453 | } | |
03672227 | 1454 | if (floatDCS){ |
1455 | delete[] floatDCS; | |
1456 | floatDCS = 0x0; | |
1457 | } | |
26c1dff2 | 1458 | } |
c5340e82 | 1459 | if (!outOfRange) { |
1460 | nDipoleEntries++; | |
1461 | ffailedDPs->RemoveAt(indexDP); | |
1462 | } | |
44e45fac | 1463 | } |
1464 | ||
1465 | if (array) array = 0x0; | |
1466 | ||
fe726709 | 1467 | AliInfo(Form("==========DipolePolarity===========")); |
1468 | indexDP = kDipolePolarity; | |
44e45fac | 1469 | array = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[indexDP]); |
1470 | if(!array) { | |
1471 | Log(Form("%s not found in the map!!!",fgkDCSDataPoints[indexDP])); | |
1472 | } | |
1473 | else { | |
26c1dff2 | 1474 | if (array->GetEntries() == 0){ |
1475 | AliError(Form("No entries found in array! setting %s to invalid...",fgkDCSDataPoints[indexDP])); | |
1476 | } | |
1477 | else { | |
fe726709 | 1478 | Bool_t change = kFALSE; |
1479 | Char_t charDCS = ProcessBool(array,change); | |
1480 | if (!change){ | |
1481 | grpObj->SetDipolePolarity(charDCS); | |
1482 | AliInfo(Form("%s set to %d",fgkDCSDataPoints[indexDP],(Int_t)(grpObj->GetDipolePolarity()))); | |
c5340e82 | 1483 | ffailedDPs->RemoveAt(indexDP); |
fe726709 | 1484 | nDipoleEntries++; |
1485 | } | |
1486 | else if (isZero){ | |
ac833e7a | 1487 | AliInfo(Form("%s set to invalid, but magnet was OFF (according to the current), DP not considered wrong",fgkDCSDataPoints[indexDP])); |
c5340e82 | 1488 | ffailedDPs->RemoveAt(indexDP); |
fe726709 | 1489 | nDipoleEntries++; |
1490 | } | |
1491 | else{ | |
ac833e7a | 1492 | 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 | 1493 | } |
26c1dff2 | 1494 | } |
44e45fac | 1495 | } |
1496 | ||
1497 | return nDipoleEntries; | |
e7a6790f | 1498 | |
44e45fac | 1499 | } |
1500 | //_______________________________________________________________ | |
e7a6790f | 1501 | |
44e45fac | 1502 | Int_t AliGRPPreprocessor::ProcessEnvDPs(TMap* valueMap, AliGRPObject* grpObj) |
1503 | { | |
39e3007b | 1504 | // processing DPs |
1505 | // related to | |
1506 | // evironment conditions (temperature, pressure) info | |
1507 | ||
44e45fac | 1508 | Int_t nEnvEntries = 0; |
1509 | TObjArray *array = 0x0; | |
1510 | Int_t indexDP = -1; | |
1511 | ||
1512 | AliInfo(Form("==========CavernTemperature===========")); | |
fe726709 | 1513 | Bool_t outOfRange = kFALSE; // flag to monitor if any value collected by DCS is out of range |
44e45fac | 1514 | indexDP = kCavernTemperature; |
1515 | array = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[indexDP]); | |
1516 | if(!array) { | |
1517 | Log(Form("%s not found in the map!!!",fgkDCSDataPoints[indexDP])); | |
1518 | } | |
1519 | else { | |
26c1dff2 | 1520 | if (array->GetEntries() == 0){ |
1521 | AliError(Form("No entries found in array! setting %s to invalid...",fgkDCSDataPoints[indexDP])); | |
1522 | } | |
1523 | else { | |
1524 | Float_t *floatDCS = ProcessFloatAll(array); | |
fe726709 | 1525 | if (floatDCS != NULL){ |
1526 | grpObj->SetCavernTemperature(floatDCS); | |
1527 | } | |
1528 | else{ | |
1529 | outOfRange = kTRUE; | |
1530 | } | |
03672227 | 1531 | if (floatDCS){ |
1532 | delete[] floatDCS; | |
1533 | floatDCS = 0x0; | |
1534 | } | |
26c1dff2 | 1535 | } |
c5340e82 | 1536 | if (!outOfRange) { |
1537 | ffailedDPs->RemoveAt(indexDP); | |
1538 | nEnvEntries++; | |
1539 | } | |
44e45fac | 1540 | } |
1541 | ||
1542 | if (array) array = 0x0; | |
1543 | ||
ce996d13 | 1544 | AliInfo(Form("========== AtmosPressures (Cavern + Surface + Cavern2) ===========")); |
44e45fac | 1545 | AliDCSSensorArray *dcsSensorArray = GetPressureMap(valueMap); |
ce996d13 | 1546 | //dcsSensorArray->Print(); |
1547 | if( fPressure->NumFits()<kNumSensors ) { | |
d7edf69d | 1548 | Log(Form("Check the pressure sensor values! Not all the %d pressure sensors have been fit",kNumSensors)); |
44e45fac | 1549 | } |
d7edf69d | 1550 | Log(Form("Number of fits performed = %d",fPressure->NumFits())); |
1551 | ||
1552 | AliInfo(Form("==========CavernAtmosPressure===========")); | |
1553 | indexDP = kCavernAtmosPressure; | |
1554 | AliDCSSensor* sensorCavernP2 = dcsSensorArray->GetSensor(fgkDCSDataPoints[indexDP]); | |
1555 | TGraph* graph = sensorCavernP2->GetGraph(); | |
3343d11b | 1556 | AliDebug(3,Form("index = %d",indexDP)); |
1557 | AliDebug(3,Form("name = %s",fgkDCSDataPoints[indexDP])); | |
d7edf69d | 1558 | AliDebug(2,Form("graph = %p",graph)); |
1559 | AliDebug(3,Form("sensorCavernP2 = %p", sensorCavernP2)); | |
2a0b175e | 1560 | if(sensorCavernP2->GetFit() || graph) { |
d7edf69d | 1561 | if (sensorCavernP2->GetFit()){ |
2a0b175e | 1562 | Log(Form("Fit for sensor %s found",fgkDCSDataPoints[indexDP])); |
d7edf69d | 1563 | } |
44e45fac | 1564 | else { |
2a0b175e | 1565 | Log(Form("Fit for sensor %s not found, but the graph is there - NOT going into error",fgkDCSDataPoints[indexDP])); |
d7edf69d | 1566 | } |
1567 | grpObj->SetCavernAtmosPressure(sensorCavernP2); | |
c5340e82 | 1568 | ffailedDPs->RemoveAt(indexDP); |
d7edf69d | 1569 | nEnvEntries++; |
1570 | } | |
1571 | //if (sensorP2) delete sensorP2; | |
1572 | else { | |
2a0b175e | 1573 | 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 | 1574 | } |
2a0b175e | 1575 | |
d7edf69d | 1576 | AliInfo(Form("==========SurfaceAtmosPressure===========")); |
1577 | indexDP = kSurfaceAtmosPressure; | |
1578 | AliDCSSensor* sensorP2 = dcsSensorArray->GetSensor(fgkDCSDataPoints[indexDP]); | |
1579 | graph = sensorP2->GetGraph(); | |
3343d11b | 1580 | AliDebug(3,Form("index = %d",indexDP)); |
1581 | AliDebug(3,Form("name = %s",fgkDCSDataPoints[indexDP])); | |
d7edf69d | 1582 | AliDebug(2,Form("graph = %p",graph)); |
1583 | AliDebug(3,Form("sensorP2 = %p", sensorP2)); | |
2a0b175e | 1584 | if(sensorP2->GetFit() || graph) { |
d7edf69d | 1585 | if (sensorP2->GetFit()){ |
2a0b175e | 1586 | Log(Form("Fit for sensor %s found",fgkDCSDataPoints[indexDP])); |
d7edf69d | 1587 | } |
44e45fac | 1588 | else { |
2a0b175e | 1589 | Log(Form("Fit for sensor %s not found, but the graph is there - NOT going into error",fgkDCSDataPoints[indexDP])); |
d7edf69d | 1590 | } |
1591 | grpObj->SetSurfaceAtmosPressure(sensorP2); | |
c5340e82 | 1592 | ffailedDPs->RemoveAt(indexDP); |
d7edf69d | 1593 | nEnvEntries++; |
1594 | } | |
1595 | //if (sensorP2) delete sensorP2; | |
1596 | else { | |
2a0b175e | 1597 | 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 | 1598 | } |
1599 | ||
d7edf69d | 1600 | AliInfo(Form("==========CavernAtmosPressure2===========")); |
1601 | indexDP = kCavernAtmosPressure2; | |
1602 | AliDCSSensor* sensorCavernP22 = dcsSensorArray->GetSensor(fgkDCSDataPoints[indexDP]); | |
8976336c | 1603 | graph = sensorCavernP22->GetGraph(); |
3343d11b | 1604 | AliDebug(3,Form("index = %d",indexDP)); |
1605 | AliDebug(3,Form("name = %s",fgkDCSDataPoints[indexDP])); | |
d7edf69d | 1606 | AliDebug(2,Form("graph = %p",graph)); |
1607 | AliDebug(3,Form("sensorCavernP2_2 = %p", sensorCavernP22)); | |
2a0b175e | 1608 | if(sensorCavernP22->GetFit() || graph) { |
d7edf69d | 1609 | if (sensorCavernP22->GetFit()){ |
2a0b175e | 1610 | Log(Form("Fit for sensor %s found",fgkDCSDataPoints[indexDP])); |
d7edf69d | 1611 | } |
1612 | else { | |
2a0b175e | 1613 | Log(Form("Fit for sensor %s not found, but the graph is there - NOT going into error",fgkDCSDataPoints[indexDP])); |
d7edf69d | 1614 | } |
1615 | grpObj->SetCavernAtmosPressure2(sensorCavernP22); | |
c5340e82 | 1616 | ffailedDPs->RemoveAt(indexDP); |
d7edf69d | 1617 | nEnvEntries++; |
1618 | } | |
1619 | //if (sensorP2) delete sensorP2; | |
1620 | else { | |
2a0b175e | 1621 | 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 | 1622 | } |
1623 | ||
1624 | ||
44e45fac | 1625 | return nEnvEntries; |
1626 | } | |
1627 | //_______________________________________________________________ | |
e7a6790f | 1628 | |
39e3007b | 1629 | Int_t AliGRPPreprocessor::ProcessHPDPs(const TMap* valueMap, AliGRPObject* grpObj) |
44e45fac | 1630 | { |
39e3007b | 1631 | // processing DPs |
1632 | // related to | |
1633 | // Hall Probes info | |
1634 | ||
44e45fac | 1635 | Int_t nHPEntries = 0; |
1636 | TObjArray *array = 0x0; | |
1637 | Int_t indexDP = -1; | |
fe726709 | 1638 | Bool_t outOfRange; // flag to monitor if any value collected by DCS is out of range |
44e45fac | 1639 | |
39e3007b | 1640 | if (fgknDCSDPHallProbes != AliGRPObject::GetNumberOfHP()){ |
1641 | 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 | 1642 | } |
1643 | for (indexDP = 0; indexDP < AliGRPObject::GetNumberOfHP(); indexDP++){ | |
fe726709 | 1644 | outOfRange = kFALSE; // resetting outOfRange flag at each HP |
44e45fac | 1645 | AliInfo(Form("==========%s===========",AliGRPObject::GetHPDP(indexDP))); |
1646 | array = (TObjArray *)valueMap->GetValue(AliGRPObject::GetHPDP(indexDP)); | |
1647 | if(!array) { | |
1648 | Log(Form("%s not found in the map!!!",AliGRPObject::GetHPDP(indexDP))); | |
1649 | } | |
1650 | else { | |
26c1dff2 | 1651 | if (array->GetEntries() == 0){ |
1652 | AliError(Form("No entries found in array! setting %s to invalid...",AliGRPObject::GetHPDP(indexDP))); | |
1653 | } | |
1654 | else { | |
1655 | Float_t *floatDCS = ProcessFloatAll(array); | |
fe726709 | 1656 | if (floatDCS != NULL){ |
1657 | 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])); | |
1658 | grpObj->SetHallProbes((AliGRPObject::DP_HallProbes)indexDP,floatDCS); | |
1659 | for (Int_t kk = 0 ; kk< 5; kk++){ | |
1660 | AliDebug(2,Form("HallProbe[%d][%d]=%f",indexDP,kk,grpObj->GetHallProbes((AliGRPObject::DP_HallProbes)indexDP,(AliGRPObject::Stats)kk))); | |
1661 | } | |
1662 | } | |
1663 | else{ | |
1664 | outOfRange = kTRUE; | |
26c1dff2 | 1665 | } |
03672227 | 1666 | if (floatDCS){ |
1667 | delete[] floatDCS; | |
1668 | floatDCS = 0x0; | |
1669 | } | |
44e45fac | 1670 | } |
c5340e82 | 1671 | if (!outOfRange) { |
4bb7c769 | 1672 | ffailedDPs->RemoveAt(indexDP + fgkDCSDPHallTopShift); // 7 = shift in the complete list of DPs to get to the Hall Probes |
c5340e82 | 1673 | nHPEntries++; |
1674 | } | |
44e45fac | 1675 | } |
1676 | } | |
1677 | ||
7e6f5523 | 1678 | Log(Form("Hall Probes = %d ", nHPEntries)); |
1679 | return nHPEntries; | |
17984b61 | 1680 | } |
1681 | ||
44e45fac | 1682 | //_________________________________________________________________________ |
1683 | ||
39e3007b | 1684 | AliSplineFit* AliGRPPreprocessor::GetSplineFit(const TObjArray *array, const TString& stringID){ |
1685 | ||
1686 | ||
1687 | // | |
1688 | // returning Spline Fit | |
1689 | // | |
44e45fac | 1690 | |
1691 | Int_t entriesarray = array->GetEntries(); | |
1692 | Float_t* value = new Float_t[entriesarray]; | |
1693 | Float_t* time = new Float_t[entriesarray]; | |
1694 | AliDCSValue* v = 0x0; | |
1695 | for (Int_t iarray = 0; iarray < entriesarray; iarray++){ | |
1696 | v = (AliDCSValue*)array->At(iarray); | |
1697 | value[iarray] = v->GetFloat(); | |
1698 | time[iarray] = v->GetTimeStamp(); | |
e75e6e01 | 1699 | AliDebug(2,Form("iarray = %d, value = %f, time = %f",iarray,value[iarray],time[iarray])); |
44e45fac | 1700 | } |
1701 | TGraph* gr = new TGraph(entriesarray,value,time); | |
1702 | if (!gr ) { | |
1703 | AliWarning(Form("%s: no input graph to compute SplineFit",stringID.Data())); | |
1704 | return NULL; | |
1705 | } | |
1706 | AliSplineFit *fit = new AliSplineFit(); | |
1707 | fit->SetMinPoints(10); | |
1708 | fit->InitKnots(gr,10,10,0.0); | |
1709 | fit->SplineFit(2); | |
1710 | fit->Cleanup(); | |
1711 | if (!fit) { | |
1712 | AliWarning(Form("%s: no fit performed",stringID.Data())); | |
1713 | return NULL; | |
1714 | } | |
1715 | return fit; | |
48b1b444 | 1716 | } |
1717 | ||
44e45fac | 1718 | //_________________________________________________________________________ |
1719 | ||
39e3007b | 1720 | TString AliGRPPreprocessor::ProcessChar(const TObjArray *array) |
e7a6790f | 1721 | { |
17984b61 | 1722 | |
44e45fac | 1723 | // |
1724 | // processing char | |
1725 | // | |
1726 | ||
1727 | TString aDCSString=""; | |
1728 | ||
1729 | AliDCSValue *v = 0x0; | |
1730 | for(Int_t iCount = 0; iCount < array->GetEntries(); iCount++) { | |
1731 | v = (AliDCSValue *)array->At(iCount); | |
26c1dff2 | 1732 | if (((Int_t)(v->GetTimeStamp()) < (Int_t)GetStartTimeDCSQuery()) || ((Int_t)(v->GetTimeStamp()) > (Int_t)GetEndTimeDCSQuery())) { |
44e45fac | 1733 | AliError(Form("DCS values for the parameter outside the queried interval")); |
1734 | continue; | |
1735 | } | |
1736 | if (iCount > 0) { | |
7e6f5523 | 1737 | if (aDCSString != v->GetChar()) |
44e45fac | 1738 | AliError(Form("DCS values for the parameter changed from %s to %c within the queried interval", aDCSString.Data(), (Char_t)v->GetChar())); |
1739 | } | |
1740 | aDCSString = (TString)v->GetChar(); // keeping always last value in the array | |
1741 | } | |
1742 | return aDCSString; | |
1743 | } | |
e7a6790f | 1744 | |
44e45fac | 1745 | //__________________________________________________________________________________________________________________ |
e7a6790f | 1746 | |
39e3007b | 1747 | Float_t* AliGRPPreprocessor::ProcessFloatAll(const TObjArray* array) |
44e45fac | 1748 | { |
1749 | // | |
1750 | // processing Float values using Mean, Median, Standard Deviation wrt Mean, Standar Deviation wrt Median | |
1751 | // | |
1752 | // parameters[0] = mean | |
1753 | // parameters[1] = truncated mean (calculated excluding points outside +/- 3RMS from mean | |
1754 | // parameters[2] = median | |
1755 | // parameters[3] = standard deviation wrt mean | |
1756 | // parameters[4] = standard deviation wrt median | |
1757 | // | |
1758 | ||
28131b57 | 1759 | TString timeStartString = (TString)GetRunParameter("DAQ_time_start"); |
1760 | TString timeEndString = (TString)GetRunParameter("DAQ_time_end"); | |
1761 | if (timeStartString.IsNull() || timeStartString.IsNull()){ | |
1762 | if (timeStartString.IsNull()){ | |
1763 | AliError("DAQ_time_start not set in logbook! Setting statistical values for current DP to invalid"); | |
1764 | } | |
1765 | else if (timeStartString.IsNull()){ | |
1766 | AliError("DAQ_time_end not set in logbook! Setting statistical values for current DP to invalid"); | |
1767 | } | |
5fbf7677 | 1768 | fdaqStartEndTimeOk = kFALSE; |
28131b57 | 1769 | return 0; |
1770 | } | |
1771 | ||
1772 | Int_t timeStart = (Int_t)(timeStartString.Atoi()); | |
1773 | Int_t timeEnd = (Int_t)(timeEndString.Atoi()); | |
5138cd05 | 1774 | Float_t* parameters = new Float_t[5]; |
44e45fac | 1775 | Int_t iCounts = 0; |
28131b57 | 1776 | Int_t iCountsRun = 0; |
44e45fac | 1777 | Int_t nCounts = array->GetEntries(); |
28131b57 | 1778 | Float_t valueBeforeSOR = 0; |
1779 | Float_t valueAfterEOR = 0; | |
1780 | Int_t timestampBeforeSOR = -1; | |
1781 | Int_t timestampAfterEOR = -1; | |
1782 | Int_t ientrySOR = -1; | |
1783 | Int_t ientryEOR = -1; | |
1784 | Float_t* arrayValues = 0x0; | |
1785 | Double_t* arrayWeights = 0x0; | |
1786 | Bool_t truncMeanFlag = kTRUE; // flag to indicate whether Truncated Mean should be calculated or not | |
5fbf7677 | 1787 | Bool_t sdFlag = kTRUE; // flag to indicate whether SD (wrt Mean/Median) should be calculated or not |
1788 | ||
44e45fac | 1789 | for(Int_t i = 0; i < nCounts; i++) { |
1790 | AliDCSValue *v = (AliDCSValue *)array->At(i); | |
fe726709 | 1791 | if ((v->GetFloat() <= fminFloat) || (v->GetFloat() >= fmaxFloat)) { |
1792 | AliError(Form("Error! Float value found in DCS map at %d-th entry is OUT OF RANGE: value = %6.5e",i,v->GetFloat())); | |
1793 | if (v->GetFloat() < fminFloat) AliInfo(Form("The value is smaller than %6.5e",fminFloat)); | |
1794 | if (v->GetFloat() > fmaxFloat) AliInfo(Form("The value is greater than %6.5e",fmaxFloat)); | |
1795 | return NULL; | |
1796 | } | |
1797 | if(((Int_t)(v->GetTimeStamp()) >= (Int_t)GetStartTimeDCSQuery()) &&((Int_t)(v->GetTimeStamp()) <= (Int_t)GetEndTimeDCSQuery())) { | |
28131b57 | 1798 | AliDebug(2,Form("%d-th entry = %f at timestamp %i",i,v->GetFloat(),v->GetTimeStamp())); |
fe726709 | 1799 | iCounts += 1; |
28131b57 | 1800 | // look for the last value before SOR and the first value before EOR |
1801 | if (((Int_t)(v->GetTimeStamp()) >= (Int_t)GetStartTimeDCSQuery()) && (Int_t)(v->GetTimeStamp()) < timeStart) { | |
1802 | timestampBeforeSOR = (Int_t)(v->GetTimeStamp()); | |
1803 | AliDebug(2,Form("timestamp of last value before SOR = %d, with DAQ_time_start = %d",timestampBeforeSOR,timeStart)); | |
1804 | valueBeforeSOR = v->GetFloat(); | |
1805 | } | |
1806 | else if ((Int_t)(v->GetTimeStamp()) <= (Int_t)GetEndTimeDCSQuery() && (Int_t)(v->GetTimeStamp()) > timeEnd && timestampAfterEOR == -1){ | |
1807 | timestampAfterEOR = (Int_t)(v->GetTimeStamp()); | |
1808 | valueAfterEOR = v->GetFloat(); | |
1809 | AliDebug(2,Form("timestamp of first value after EOR = %d, with DAQ_time_end = %d",timestampAfterEOR,timeEnd)); | |
1810 | } | |
1811 | // check if there are DPs between DAQ_time_start and DAQ_time_end | |
1812 | if(((Int_t)(v->GetTimeStamp()) >= timeStart) &&((Int_t)(v->GetTimeStamp()) <= timeEnd)) { | |
1813 | if (ientrySOR == -1) ientrySOR = i; // first entry after SOR | |
1814 | if (ientryEOR < i) ientryEOR = i; // last entry before EOR | |
1815 | AliDebug(2,Form("entry between SOR and EOR")); | |
1816 | iCountsRun += 1; | |
1817 | } | |
fe726709 | 1818 | } |
1819 | else { | |
28131b57 | 1820 | AliError(Form("DCS values for the parameter outside the queried interval: timestamp = %d",v->GetTimeStamp())); |
fe726709 | 1821 | } |
1822 | } | |
1823 | ||
28131b57 | 1824 | if (timestampBeforeSOR == -1){ |
df1faeb3 | 1825 | AliWarning("No value found before SOR"); |
28131b57 | 1826 | } |
1827 | if (timestampAfterEOR == -1){ | |
df1faeb3 | 1828 | AliWarning("No value found after EOR"); |
28131b57 | 1829 | } |
1830 | ||
1831 | AliDebug(2,Form("Number of valid entries (within DCS query interval) = %i, from a total amount of %i entries",iCounts,nCounts)); | |
1832 | AliDebug(2,Form("Last value before DAQ_time_start (SOR) = %f at timestamp = %d",valueBeforeSOR,timestampBeforeSOR)); | |
1833 | AliDebug(2,Form("First value after DAQ_time_end (EOR) = %f at timestamp = %d",valueAfterEOR,timestampAfterEOR)); | |
1834 | AliInfo(Form("Found %d entries between DAQ_time_start (SOR) and DAQ_time_end (EOR)",iCountsRun)); | |
1835 | AliDebug(2,Form("Index of first entry after DAQ_time_start (SOR) = %d ",ientrySOR)); | |
1836 | AliDebug(2,Form("Index of first entry before DAQ_time_end (EOR) = %d ",ientryEOR)); | |
1837 | ||
1838 | Int_t nentriesUsed = 0; | |
1839 | if (iCountsRun > 1){ | |
1840 | AliInfo("Using entries between DAQ_time_start (SOR) and DAQ_time_end (EOR)"); | |
1841 | AliDebug(2,"Calculating (weighted) Mean and Median"); | |
1842 | arrayValues = new Float_t[iCountsRun]; | |
1843 | arrayWeights = new Double_t[iCountsRun]; | |
1844 | nentriesUsed = iCountsRun; | |
1845 | for (Int_t i = ientrySOR; i <= ientryEOR; i++){ | |
fe726709 | 1846 | AliDCSValue *v = (AliDCSValue *)array->At(i); |
28131b57 | 1847 | Int_t timestamp2 = 0; |
1848 | if (i < ientryEOR){ | |
1849 | AliDCSValue *v1 = (AliDCSValue *)array->At(i+1); | |
1850 | timestamp2 = (Int_t)v1->GetTimeStamp(); | |
fe726709 | 1851 | } |
28131b57 | 1852 | else { |
1853 | timestamp2 = timeEnd+1; | |
1854 | } | |
1855 | arrayWeights[i-ientrySOR] = (Double_t)(timestamp2 - (Int_t)v->GetTimeStamp()); | |
1856 | arrayValues[i-ientrySOR] = v->GetFloat(); | |
fe726709 | 1857 | } |
28131b57 | 1858 | parameters[0] = TMath::Mean(iCountsRun,arrayValues,arrayWeights); |
1859 | parameters[2] = TMath::Median(iCountsRun,arrayValues,arrayWeights); | |
1860 | } | |
1861 | else if (iCountsRun == 1){ | |
1862 | AliDCSValue* v = (AliDCSValue *)array->At(ientrySOR); | |
1863 | nentriesUsed = 2; | |
1864 | if (timestampBeforeSOR != -1 && timestampBeforeSOR != (Int_t)v->GetTimeStamp()){ | |
1865 | 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."); | |
1866 | arrayValues = new Float_t[2]; | |
1867 | arrayWeights = new Double_t[2]; | |
1868 | arrayValues[0] = valueBeforeSOR; | |
1869 | arrayWeights[0] = (Double_t)((Int_t)v->GetTimeStamp()-timestampBeforeSOR); | |
1870 | arrayValues[1] = v->GetFloat(); | |
1871 | arrayWeights[1] = (Double_t)(timeEnd+1-(Int_t)v->GetTimeStamp()); | |
1872 | AliDebug(2, Form("value0 = %f, with weight = %f",arrayValues[0],arrayWeights[0])); | |
1873 | AliDebug(2, Form("value1 = %f, with weight = %f",arrayValues[1],arrayWeights[1])); | |
1874 | parameters[0] = TMath::Mean(2,arrayValues,arrayWeights); | |
1875 | parameters[2] = TMath::Median(2,arrayValues,arrayWeights); | |
1876 | truncMeanFlag = kFALSE; | |
fe726709 | 1877 | } |
1878 | else{ | |
28131b57 | 1879 | 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"); |
1880 | parameters[0] = AliGRPObject::GetInvalidFloat(); | |
1881 | parameters[1] = AliGRPObject::GetInvalidFloat(); | |
1882 | parameters[2] = AliGRPObject::GetInvalidFloat(); | |
1883 | parameters[3] = AliGRPObject::GetInvalidFloat(); | |
1884 | parameters[4] = AliGRPObject::GetInvalidFloat(); | |
1885 | return parameters; | |
fe726709 | 1886 | } |
1887 | } | |
5fbf7677 | 1888 | else { // iCountsRun == 0, using only the point immediately before SOR |
1889 | if (timestampBeforeSOR == -1){ | |
1890 | 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 | 1891 | parameters[0] = AliGRPObject::GetInvalidFloat(); |
1892 | parameters[1] = AliGRPObject::GetInvalidFloat(); | |
1893 | parameters[2] = AliGRPObject::GetInvalidFloat(); | |
1894 | parameters[3] = AliGRPObject::GetInvalidFloat(); | |
1895 | parameters[4] = AliGRPObject::GetInvalidFloat(); | |
1896 | return parameters; | |
1897 | } | |
1898 | else { | |
5fbf7677 | 1899 | AliWarning("Using only last entry before SOR. Truncated mean and Standard deviations (wrt mean/median) won't be calculated."); |
1900 | AliDebug(2,Form("value = %f",valueBeforeSOR)); | |
1901 | parameters[0] = valueBeforeSOR; | |
1902 | parameters[2] = valueBeforeSOR; | |
28131b57 | 1903 | truncMeanFlag = kFALSE; |
5fbf7677 | 1904 | sdFlag = kFALSE; |
28131b57 | 1905 | } |
1906 | } | |
1907 | ||
1908 | Float_t temp = 0; | |
1909 | Float_t temp1 = 0; | |
1910 | Float_t sumweights = 0; | |
1911 | Int_t entriesTruncMean = 0; | |
1912 | Float_t* arrayValuesTruncMean = new Float_t[nentriesUsed]; | |
1913 | Double_t* arrayWeightsTruncMean = new Double_t[nentriesUsed]; | |
1914 | ||
1915 | // calculating SD wrt Mean and Median | |
1916 | AliDebug(2,"Calculating SD wrt Mean and SD wrt Median"); | |
5fbf7677 | 1917 | if (sdFlag){ |
1918 | for (Int_t i =0; i< nentriesUsed; i++){ | |
df1faeb3 | 1919 | AliDebug(2,Form("Entry %d: value = %f, weight = %f",i,arrayValues[i],arrayWeights[i])); |
5fbf7677 | 1920 | temp += (arrayValues[i]-parameters[2])*(arrayValues[i]-parameters[2]); |
1921 | temp1 += arrayWeights[i]*(arrayValues[i]-parameters[0])*(arrayValues[i]-parameters[0]); | |
1922 | sumweights += arrayWeights[i]; | |
1923 | } | |
1924 | // setting SD wrt Mean | |
1925 | if (sumweights != 0 ){ | |
1926 | parameters[3] = TMath::Sqrt(temp1/sumweights); | |
1927 | } | |
1928 | else { | |
1929 | AliError("Sum of weights to calculate Standard Deviation (wrt mean) <= 0, setting the SD to invalid"); | |
1930 | parameters[3] = AliGRPObject::GetInvalidFloat(); | |
1931 | } | |
1932 | // setting SD wrt Median | |
1933 | if (nentriesUsed != 0){ | |
1934 | parameters[4] = TMath::Sqrt(temp/nentriesUsed); | |
1935 | } | |
1936 | else{ | |
1937 | AliError("Number of entries used to calculate Standard Deviation (wrt median) <= 0, setting the SD to invalid"); | |
1938 | parameters[4] = AliGRPObject::GetInvalidFloat(); | |
1939 | } | |
28131b57 | 1940 | } |
fe726709 | 1941 | else { |
28131b57 | 1942 | parameters[3] = AliGRPObject::GetInvalidFloat(); |
28131b57 | 1943 | parameters[4] = AliGRPObject::GetInvalidFloat(); |
5fbf7677 | 1944 | } |
fe726709 | 1945 | |
28131b57 | 1946 | // calculating truncated mean (this comes afterwards since you need the SD wrt Mean) |
1947 | if (truncMeanFlag){ | |
1948 | AliDebug(2,"Calculating Truncated Mean"); | |
1949 | for (Int_t i =0; i< nentriesUsed; i++){ | |
df1faeb3 | 1950 | AliDebug(2,Form("Entry %d: value = %f, weight = %f",i,arrayValues[i],arrayWeights[i])); |
28131b57 | 1951 | if ((arrayValues[i]<=parameters[0]+3*parameters[3]) && (arrayValues[i]>=parameters[0]-3*parameters[3])){ |
df1faeb3 | 1952 | arrayValuesTruncMean[entriesTruncMean]=arrayValues[i]; |
1953 | arrayWeightsTruncMean[entriesTruncMean]=arrayWeights[i]; | |
1954 | AliDebug(2,Form("For Truncated Mean: Entry %d: value = %f, weight = %f",entriesTruncMean,arrayValuesTruncMean[entriesTruncMean],arrayWeightsTruncMean[entriesTruncMean])); | |
28131b57 | 1955 | entriesTruncMean++; |
df1faeb3 | 1956 | } |
1957 | else{ | |
1958 | AliDebug(2,"Discarding entry"); | |
28131b57 | 1959 | } |
1960 | } | |
1961 | // setting truncated mean | |
1962 | if (entriesTruncMean >1){ | |
1963 | AliDebug(2,Form("%d entries used for truncated mean",entriesTruncMean)); | |
1964 | parameters[1] = TMath::Mean(entriesTruncMean,arrayValuesTruncMean,arrayWeightsTruncMean); | |
1965 | } | |
1966 | else{ | |
1967 | AliDebug(2,Form("Too few entries (%d) to calculate truncated mean",entriesTruncMean)); | |
1968 | parameters[1] = AliGRPObject::GetInvalidFloat(); | |
1969 | } | |
1970 | } | |
1971 | else{ | |
1972 | parameters[1] = AliGRPObject::GetInvalidFloat(); | |
1973 | } | |
fe726709 | 1974 | |
28131b57 | 1975 | AliInfo(Form("(weighted) mean = %f ",parameters[0])); |
1976 | AliInfo(Form("(weighted) truncated mean = %f ",parameters[1])); | |
1a3ac627 | 1977 | AliInfo(Form("median = %f ",parameters[2])); |
28131b57 | 1978 | AliInfo(Form("(weighted) standard deviation with (weighted) mean = %f ",parameters[3])); |
1979 | AliInfo(Form("standard deviation with median = %f ",parameters[4])); | |
1980 | ||
fe726709 | 1981 | return parameters; |
1982 | } | |
1983 | ||
fe726709 | 1984 | //__________________________________________________________________________________________________________________ |
1985 | ||
1986 | Float_t* AliGRPPreprocessor::ProcessFloatAllMagnet(const TObjArray* array, Int_t indexDP, Bool_t &isZero) | |
1987 | { | |
1988 | // | |
1989 | // processing Float values using Mean, Median, Standard Deviation wrt Mean, Standar Deviation wrt Median | |
1990 | // used for L3 and Dipole magnets, using isZero flag to decide whther the magnet was OFF/ON | |
ac833e7a | 1991 | // the flag is set according to the L3/Dipole current value |
1992 | // current threshold for L3 = 350 A (value provided by DCS) | |
1993 | // current threshold for Dipole = 450 A (value provided by DCS) | |
fe726709 | 1994 | // |
1995 | // parameters[0] = mean | |
1996 | // parameters[1] = truncated mean (calculated excluding points outside +/- 3RMS from mean | |
1997 | // parameters[2] = median | |
1998 | // parameters[3] = standard deviation wrt mean | |
1999 | // parameters[4] = standard deviation wrt median | |
2000 | // | |
2001 | ||
2002 | AliInfo(Form("indexDP = %d",indexDP)); | |
28131b57 | 2003 | |
fe726709 | 2004 | Int_t nCounts = array->GetEntries(); |
fe726709 | 2005 | for(Int_t i = 0; i < nCounts; i++) { |
2006 | AliDCSValue *v = (AliDCSValue *)array->At(i); | |
2007 | if ((v->GetFloat() <= fminFloat) || (v->GetFloat() >= fmaxFloat)) { | |
2008 | AliError(Form("Error! Float value found in DCS map at %d-th entry is OUT OF RANGE: value = %6.5e",i,v->GetFloat())); | |
535c05eb | 2009 | if (v->GetFloat() < fminFloat) AliInfo(Form("The value is smaller than %6.5e",fminFloat)); |
2010 | if (v->GetFloat() > fmaxFloat) AliInfo(Form("The value is greater than %6.5e",fmaxFloat)); | |
fe726709 | 2011 | return NULL; |
2012 | } | |
26c1dff2 | 2013 | if(((Int_t)(v->GetTimeStamp()) >= (Int_t)GetStartTimeDCSQuery()) &&((Int_t)(v->GetTimeStamp()) <= (Int_t)GetEndTimeDCSQuery())) { |
28131b57 | 2014 | AliDebug(2,Form("%d-th entry = %f",i,v->GetFloat())); |
ac833e7a | 2015 | if (indexDP == kL3Current && v->GetFloat() > 350 && isZero == kTRUE) isZero=kFALSE; |
2016 | if (indexDP == kDipoleCurrent && v->GetFloat() > 450 && isZero == kTRUE) isZero=kFALSE; | |
fe726709 | 2017 | } |
2018 | else { | |
2019 | AliError(Form("DCS values for the parameter outside the queried interval")); | |
44e45fac | 2020 | } |
2021 | } | |
2022 | ||
28131b57 | 2023 | return ProcessFloatAll(array); |
44e45fac | 2024 | } |
125567f8 | 2025 | |
e97cc90e | 2026 | |
44e45fac | 2027 | //_______________________________________________________________ |
e97cc90e | 2028 | |
fe726709 | 2029 | Char_t AliGRPPreprocessor::ProcessBool(const TObjArray* array, Bool_t &change) |
44e45fac | 2030 | { |
2031 | // | |
2032 | // processing Boolean values | |
2033 | // | |
2034 | ||
2035 | Bool_t aDCSBool = kTRUE; | |
2036 | ||
2037 | AliDCSValue *v = 0x0; | |
26c1dff2 | 2038 | |
44e45fac | 2039 | for(Int_t iCount = 0; iCount < array->GetEntries(); iCount++) { |
2040 | v = (AliDCSValue *)array->At(iCount); | |
26c1dff2 | 2041 | if (((Int_t)(v->GetTimeStamp()) < (Int_t)GetStartTimeDCSQuery()) || ((Int_t)(v->GetTimeStamp()) > (Int_t)GetEndTimeDCSQuery())) { |
44e45fac | 2042 | AliError(Form("DCS values for the parameter outside the queried interval")); |
2043 | continue; | |
2044 | } | |
2045 | if (iCount > 0) { | |
01920f0c | 2046 | if (aDCSBool != v->GetBool()) { |
2047 | AliError(Form("DCS values for the parameter changed from %d to %d within the queried interval", (UInt_t)aDCSBool, (UInt_t)v->GetBool())); | |
2048 | change = kTRUE; | |
2049 | } | |
44e45fac | 2050 | } |
2051 | aDCSBool = v->GetBool(); // always keeping last value | |
26c1dff2 | 2052 | AliDebug(2,Form("Bool = %d",(Int_t)aDCSBool)); |
44e45fac | 2053 | } |
2054 | ||
26c1dff2 | 2055 | Char_t caDCSBool = (Char_t) aDCSBool; |
44e45fac | 2056 | return caDCSBool; |
2057 | ||
2058 | } | |
e97cc90e | 2059 | |
44e45fac | 2060 | //_______________________________________________________________ |
e97cc90e | 2061 | |
39e3007b | 2062 | Float_t AliGRPPreprocessor::ProcessInt(const TObjArray* array) |
44e45fac | 2063 | { |
2064 | // | |
2065 | // processing Int values, returning mean | |
fe726709 | 2066 | // AliGRPObject::GetInvalidFloat() is returned if any of the DCS values |
2067 | // are outside the queried time interval or their value is out of range | |
44e45fac | 2068 | // |
2069 | ||
28131b57 | 2070 | TString timeStartString = (TString)GetRunParameter("DAQ_time_start"); |
2071 | TString timeEndString = (TString)GetRunParameter("DAQ_time_end"); | |
2072 | if (timeStartString.IsNull() || timeStartString.IsNull()){ | |
2073 | if (timeStartString.IsNull()){ | |
2074 | AliError("DAQ_time_start not set in logbook! Setting statistical values for current DP to invalid"); | |
2075 | } | |
2076 | else if (timeStartString.IsNull()){ | |
2077 | AliError("DAQ_time_end not set in logbook! Setting statistical values for current DP to invalid"); | |
2078 | } | |
2079 | return 0; | |
2080 | } | |
2081 | ||
2082 | Int_t timeStart = (Int_t)(timeStartString.Atoi()); | |
2083 | Int_t timeEnd = (Int_t)(timeEndString.Atoi()); | |
44e45fac | 2084 | Float_t aDCSArrayMean = 0.0; |
2085 | Int_t iCounts = 0; | |
28131b57 | 2086 | Float_t valueBeforeSOR = 0; |
2087 | Float_t valueAfterEOR = 0; | |
2088 | Int_t timestampBeforeSOR = -1; | |
2089 | Int_t timestampAfterEOR = -1; | |
2090 | Int_t ientrySOR = -1; | |
2091 | Int_t ientryEOR = -1; | |
2092 | Float_t* arrayValues = 0x0; | |
2093 | Double_t* arrayWeights = 0x0; | |
2094 | Int_t iCountsRun = 0; | |
2095 | Int_t nCounts = array->GetEntries(); | |
44e45fac | 2096 | |
28131b57 | 2097 | for(Int_t i = 0; i < nCounts; i++) { |
dd5ac86b | 2098 | AliDCSValue* v = (AliDCSValue *)array->At(i); |
fe726709 | 2099 | if ((v->GetInt() < fminInt) || (v->GetInt() > fmaxInt)) { |
28131b57 | 2100 | AliError(Form("Error! Int value found in DCS map at %d-th entry is OUT OF RANGE: value = %d",i, v->GetInt())); |
fe726709 | 2101 | return AliGRPObject::GetInvalidFloat(); |
2102 | } | |
26c1dff2 | 2103 | if(((Int_t)(v->GetTimeStamp()) >= (Int_t)GetStartTimeDCSQuery()) &&((Int_t)(v->GetTimeStamp()) <= (Int_t)GetEndTimeDCSQuery())) { |
28131b57 | 2104 | AliDebug(2,Form("%d-th entry = %d at timestamp %i",i,v->GetInt(),v->GetTimeStamp())); |
44e45fac | 2105 | iCounts += 1; |
28131b57 | 2106 | // look for the last value before SOR and the first value before EOR |
2107 | if (((Int_t)(v->GetTimeStamp()) >= (Int_t)GetStartTimeDCSQuery()) && (Int_t)(v->GetTimeStamp()) < timeStart) { | |
2108 | timestampBeforeSOR = (Int_t)(v->GetTimeStamp()); | |
2109 | AliDebug(2,Form("timestamp of last entry before SOR = %d, with DAQ_time_start = %d",timestampBeforeSOR,timeStart)); | |
2110 | valueBeforeSOR = (Float_t) v->GetInt(); | |
2111 | } | |
2112 | else if ((Int_t)(v->GetTimeStamp()) <= (Int_t)GetEndTimeDCSQuery() && (Int_t)(v->GetTimeStamp()) > timeEnd && timestampAfterEOR == -1){ | |
2113 | timestampAfterEOR = (Int_t)(v->GetTimeStamp()); | |
2114 | valueAfterEOR = (Float_t) v->GetInt(); | |
2115 | AliDebug(2,Form("timestamp of first entry after EOR = %d, with DAQ_time_end = %d",timestampAfterEOR,timeEnd)); | |
2116 | } | |
2117 | // check if there are DPs between DAQ_time_start and DAQ_time_end | |
2118 | if(((Int_t)(v->GetTimeStamp()) >= timeStart) &&((Int_t)(v->GetTimeStamp()) <= timeEnd)) { | |
2119 | if (ientrySOR == -1) ientrySOR = i; // first entry after SOR | |
2120 | if (ientryEOR < i) ientryEOR = i; // last entry before EOR | |
2121 | AliDebug(2,Form("entry between SOR and EOR")); | |
2122 | iCountsRun += 1; | |
2123 | } | |
2124 | } | |
2125 | else { | |
2126 | AliError(Form("DCS values for the parameter outside the queried interval: timestamp = %d",v->GetTimeStamp())); | |
44e45fac | 2127 | } |
2128 | } | |
2129 | ||
28131b57 | 2130 | if (timestampBeforeSOR == -1){ |
2131 | AliWarning("No value found before SOR!"); | |
2132 | } | |
2133 | if (timestampAfterEOR == -1){ | |
2134 | AliWarning("No value found after EOR!"); | |
2135 | } | |
2136 | ||
2137 | AliDebug(2,Form("Number of valid entries (within query interval) = %i, starting from %i entries",iCounts,nCounts)); | |
2138 | AliDebug(2,Form("Last value before DAQ_time_start (SOR) = %f at timestamp = %d",valueBeforeSOR,timestampBeforeSOR)); | |
2139 | AliDebug(2,Form("First value after DAQ_time_end (EOR) = %f at timestamp = %d",valueAfterEOR,timestampAfterEOR)); | |
2140 | AliInfo(Form("Found %d entries between DAQ_time_start (SOR) and DAQ_time_end (EOR)",iCountsRun)); | |
2141 | AliDebug(2,Form("Index of first entry after DAQ_time_start (SOR) = %d ",ientrySOR)); | |
2142 | AliDebug(2,Form("Index of first entry before DAQ_time_end (EOR) = %d ",ientryEOR)); | |
2143 | ||
2144 | Int_t nentriesUsed = 0; | |
2145 | if (iCountsRun > 1){ | |
2146 | AliInfo("Using entries between DAQ_time_start (SOR) and DAQ_time_end (EOR)"); | |
2147 | AliDebug(2,"Calculating (weighted) Mean"); | |
2148 | arrayValues = new Float_t[iCountsRun]; | |
2149 | arrayWeights = new Double_t[iCountsRun]; | |
2150 | nentriesUsed = iCountsRun; | |
2151 | for (Int_t i = ientrySOR; i <= ientryEOR; i++){ | |
2152 | AliDCSValue *v = (AliDCSValue *)array->At(i); | |
2153 | Int_t timestamp2 = 0; | |
2154 | if (i < ientryEOR){ | |
2155 | AliDCSValue *v1 = (AliDCSValue *)array->At(i+1); | |
2156 | timestamp2 = (Int_t)v1->GetTimeStamp(); | |
2157 | } | |
2158 | else { | |
2159 | timestamp2 = timeEnd+1; | |
2160 | } | |
2161 | arrayWeights[i-ientrySOR] = (Double_t)(timestamp2 - (Int_t)v->GetTimeStamp()); | |
2162 | arrayValues[i-ientrySOR] = (Float_t)v->GetInt(); | |
2163 | } | |
2164 | aDCSArrayMean = TMath::Mean(iCountsRun,arrayValues,arrayWeights); | |
2165 | } | |
2166 | else if (iCountsRun == 1){ | |
2167 | AliDCSValue* v = (AliDCSValue *)array->At(ientrySOR); | |
2168 | nentriesUsed = 2; | |
2169 | if (timestampBeforeSOR != -1 && timestampBeforeSOR != (Int_t)v->GetTimeStamp()){ | |
2170 | AliWarning("Using single entry between DAQ_time_start (SOR) and DAQ_time_end (EOR) and last entry before SOR."); | |
2171 | arrayValues = new Float_t[2]; | |
2172 | arrayWeights = new Double_t[2]; | |
2173 | arrayValues[0] = valueBeforeSOR; | |
2174 | arrayWeights[0] = (Double_t)((Int_t)v->GetTimeStamp()-timestampBeforeSOR); | |
2175 | arrayValues[1] = (Float_t)v->GetInt(); | |
2176 | arrayWeights[1] = (Double_t)(timeEnd+1-(Int_t)v->GetTimeStamp()); | |
2177 | AliDebug(2,Form("value0 = %f, with weight = %f",arrayValues[0],arrayWeights[0])); | |
2178 | AliDebug(2,Form("value1 = %f, with weight = %f",arrayValues[1],arrayWeights[1])); | |
2179 | aDCSArrayMean = TMath::Mean(2,arrayValues,arrayWeights); | |
2180 | } | |
2181 | else{ | |
2182 | AliError("Cannot calculate mean - only one value collected during the run, but no value before with which to calculate the statistical quantities"); | |
2183 | return AliGRPObject::GetInvalidFloat(); | |
2184 | } | |
2185 | } | |
2186 | else { // iCountsRun == 0, using the point immediately before SOR and the one immediately after EOR | |
2187 | if (timestampBeforeSOR == -1 || timestampAfterEOR == -1){ | |
2188 | if (timestampBeforeSOR == -1){ | |
2189 | AliError("Cannot calculate mean - no points during the run collected, and point before SOR missing"); | |
2190 | } | |
2191 | if (timestampAfterEOR == -1){ | |
2192 | AliError("Cannot calculate maen - no points during the run collected, and point after EOR missing"); | |
2193 | } | |
2194 | return AliGRPObject::GetInvalidFloat(); | |
2195 | } | |
2196 | else { | |
2197 | AliWarning("Using last entry before SOR and first entry after EOR."); | |
2198 | nentriesUsed = 2; | |
2199 | arrayValues = new Float_t[2]; | |
2200 | arrayWeights = new Double_t[2]; | |
2201 | arrayValues[0] = valueBeforeSOR; | |
2202 | arrayWeights[0] = (Double_t)(timestampAfterEOR - timestampBeforeSOR); | |
2203 | arrayValues[1] = valueAfterEOR; | |
2204 | arrayWeights[1] = 1.; | |
2205 | AliDebug(2,Form("value0 = %f, with weight = %f",arrayValues[0],arrayWeights[0])); | |
2206 | AliDebug(2,Form("value1 = %f, with weight = %f",arrayValues[1],arrayWeights[1])); | |
2207 | aDCSArrayMean = TMath::Mean(1,arrayValues,arrayWeights); | |
2208 | } | |
2209 | } | |
2210 | ||
2211 | AliInfo(Form("mean = %f ", aDCSArrayMean)); | |
44e45fac | 2212 | return aDCSArrayMean; |
e97cc90e | 2213 | |
44e45fac | 2214 | } |
2215 | //_______________________________________________________________ | |
e7a6790f | 2216 | |
39e3007b | 2217 | Float_t AliGRPPreprocessor::ProcessUInt(const TObjArray* array) |
44e45fac | 2218 | { |
2219 | // | |
fe726709 | 2220 | // processing Int values, returning mean |
2221 | // AliGRPObject::GetInvalidFloat() is returned if any of the DCS values | |
2222 | // are outside the queried time interval or their value is out of range | |
44e45fac | 2223 | // |
2224 | ||
28131b57 | 2225 | TString timeStartString = (TString)GetRunParameter("DAQ_time_start"); |
2226 | TString timeEndString = (TString)GetRunParameter("DAQ_time_end"); | |
2227 | if (timeStartString.IsNull() || timeStartString.IsNull()){ | |
2228 | if (timeStartString.IsNull()){ | |
2229 | AliError("DAQ_time_start not set in logbook! Setting statistical values for current DP to invalid"); | |
2230 | } | |
2231 | else if (timeStartString.IsNull()){ | |
2232 | AliError("DAQ_time_end not set in logbook! Setting statistical values for current DP to invalid"); | |
2233 | } | |
2234 | return 0; | |
2235 | } | |
2236 | ||
2237 | Int_t timeStart = (Int_t)(timeStartString.Atoi()); | |
2238 | Int_t timeEnd = (Int_t)(timeEndString.Atoi()); | |
44e45fac | 2239 | Float_t aDCSArrayMean = 0.0; |
2240 | Int_t iCounts = 0; | |
28131b57 | 2241 | Float_t valueBeforeSOR = 0; |
2242 | Float_t valueAfterEOR = 0; | |
2243 | Int_t timestampBeforeSOR = -1; | |
2244 | Int_t timestampAfterEOR = -1; | |
2245 | Int_t ientrySOR = -1; | |
2246 | Int_t ientryEOR = -1; | |
2247 | Float_t* arrayValues = 0x0; | |
2248 | Double_t* arrayWeights = 0x0; | |
2249 | Int_t iCountsRun = 0; | |
2250 | Int_t nCounts = array->GetEntries(); | |
44e45fac | 2251 | |
28131b57 | 2252 | for(Int_t i = 0; i < nCounts; i++) { |
dd5ac86b | 2253 | AliDCSValue* v = (AliDCSValue *)array->At(i); |
fe726709 | 2254 | if ((v->GetUInt() < fminUInt) || (v->GetUInt() > fmaxUInt)) { |
28131b57 | 2255 | AliError(Form("Error! UInt value found in DCS map at %d-th entry is OUT OF RANGE: value = %u",i,v->GetUInt())); |
fe726709 | 2256 | return AliGRPObject::GetInvalidFloat(); |
2257 | } | |
26c1dff2 | 2258 | if(((Int_t)(v->GetTimeStamp()) >= (Int_t)GetStartTimeDCSQuery()) &&((Int_t)(v->GetTimeStamp()) <= (Int_t)GetEndTimeDCSQuery())) { |
28131b57 | 2259 | AliDebug(2,Form("%d-th entry = %d at timestamp %i",i,v->GetUInt(),v->GetTimeStamp())); |
44e45fac | 2260 | iCounts += 1; |
28131b57 | 2261 | // look for the last value before SOR and the first value before EOR |
2262 | if (((Int_t)(v->GetTimeStamp()) >= (Int_t)GetStartTimeDCSQuery()) && (Int_t)(v->GetTimeStamp()) < timeStart) { | |
2263 | timestampBeforeSOR = (Int_t)(v->GetTimeStamp()); | |
2264 | AliDebug(2,Form("timestamp of last entry before SOR = %d, with DAQ_time_start = %d",timestampBeforeSOR,timeStart)); | |
2265 | valueBeforeSOR = (Float_t)v->GetUInt(); | |
2266 | } | |
2267 | else if ((Int_t)(v->GetTimeStamp()) <= (Int_t)GetEndTimeDCSQuery() && (Int_t)(v->GetTimeStamp()) > timeEnd && timestampAfterEOR == -1){ | |
2268 | timestampAfterEOR = (Int_t)(v->GetTimeStamp()); | |
2269 | valueAfterEOR = (Float_t)v->GetUInt(); | |
2270 | AliDebug(2,Form("timestamp of first entry after EOR = %d, with DAQ_time_end = %d",timestampAfterEOR,timeEnd)); | |
2271 | } | |
2272 | // check if there are DPs between DAQ_time_start and DAQ_time_end | |
2273 | if(((Int_t)(v->GetTimeStamp()) >= timeStart) &&((Int_t)(v->GetTimeStamp()) <= timeEnd)) { | |
2274 | if (ientrySOR == -1) ientrySOR = i; // first entry after SOR | |
2275 | if (ientryEOR < i) ientryEOR = i; // last entry before EOR | |
2276 | AliDebug(2,Form("entry between SOR and EOR")); | |
2277 | iCountsRun += 1; | |
2278 | } | |
2279 | } | |
2280 | else { | |
2281 | AliError(Form("DCS values for the parameter outside the queried interval: timestamp = %d",v->GetTimeStamp())); | |
44e45fac | 2282 | } |
2283 | } | |
2284 | ||
28131b57 | 2285 | if (timestampBeforeSOR == -1){ |
2286 | AliWarning("No value found before SOR!"); | |
2287 | } | |
2288 | if (timestampAfterEOR == -1){ | |
2289 | AliWarning("No value found after EOR!"); | |
2290 | } | |
2291 | ||
2292 | AliDebug(2,Form("Number of valid entries (within query interval) = %i, starting from %i entries",iCounts,nCounts)); | |
2293 | AliDebug(2,Form("Last value before DAQ_time_start (SOR) = %f at timestamp = %d",valueBeforeSOR,timestampBeforeSOR)); | |
2294 | AliDebug(2,Form("First value after DAQ_time_end (EOR) = %f at timestamp = %d",valueAfterEOR,timestampAfterEOR)); | |
2295 | AliInfo(Form("Found %d entries between DAQ_time_start (SOR) and DAQ_time_end (EOR)",iCountsRun)); | |
2296 | AliDebug(2,Form("Index of first entry after DAQ_time_start (SOR) = %d ",ientrySOR)); | |
2297 | AliDebug(2,Form("Index of first entry before DAQ_time_end (EOR) = %d ",ientryEOR)); | |
2298 | ||
2299 | Int_t nentriesUsed = 0; | |
2300 | if (iCountsRun > 1){ | |
2301 | AliInfo("Using entries between DAQ_time_start (SOR) and DAQ_time_end (EOR)"); | |
2302 | AliDebug(2,"Calculating (weighted) Mean"); | |
2303 | arrayValues = new Float_t[iCountsRun]; | |
2304 | arrayWeights = new Double_t[iCountsRun]; | |
2305 | nentriesUsed = iCountsRun; | |
2306 | for (Int_t i = ientrySOR; i <= ientryEOR; i++){ | |
2307 | AliDCSValue *v = (AliDCSValue *)array->At(i); | |
2308 | Int_t timestamp2 = 0; | |
2309 | if (i < ientryEOR){ | |
2310 | AliDCSValue *v1 = (AliDCSValue *)array->At(i+1); | |
2311 | timestamp2 = (Int_t)v1->GetTimeStamp(); | |
2312 | } | |
2313 | else { | |
2314 | timestamp2 = timeEnd+1; | |
2315 | } | |
2316 | arrayWeights[i-ientrySOR] = (Double_t)(timestamp2 - (Int_t)v->GetTimeStamp()); | |
2317 | arrayValues[i-ientrySOR] = (Float_t)v->GetUInt(); | |
2318 | } | |
2319 | aDCSArrayMean = TMath::Mean(iCountsRun,arrayValues,arrayWeights); | |
2320 | } | |
2321 | else if (iCountsRun == 1){ | |
2322 | AliDCSValue* v = (AliDCSValue *)array->At(ientrySOR); | |
2323 | nentriesUsed = 2; | |
2324 | if (timestampBeforeSOR != -1 && timestampBeforeSOR != (Int_t)v->GetTimeStamp()){ | |
2325 | AliWarning("Using single entry between DAQ_time_start (SOR) and DAQ_time_end (EOR) and last entry before SOR."); | |
2326 | arrayValues = new Float_t[2]; | |
2327 | arrayWeights = new Double_t[2]; | |
2328 | arrayValues[0] = valueBeforeSOR; | |
2329 | arrayWeights[0] = (Double_t)((Int_t)v->GetTimeStamp()-timestampBeforeSOR); | |
2330 | arrayValues[1] = (Float_t)v->GetUInt(); | |
2331 | arrayWeights[1] = (Double_t)(timeEnd+1-(Int_t)v->GetTimeStamp()); | |
2332 | AliDebug(2,Form("value0 = %f, with weight = %f",arrayValues[0],arrayWeights[0])); | |
2333 | AliDebug(2,Form("value1 = %f, with weight = %f",arrayValues[1],arrayWeights[1])); | |
2334 | aDCSArrayMean = TMath::Mean(2,arrayValues,arrayWeights); | |
2335 | } | |
2336 | else{ | |
2337 | AliError("Cannot calculate mean - only one value collected during the run, but no value before with which to calculate the statistical quantities"); | |
2338 | return AliGRPObject::GetInvalidFloat(); | |
2339 | } | |
2340 | } | |
2341 | else { // iCountsRun == 0, using the point immediately before SOR and the one immediately after EOR | |
2342 | if (timestampBeforeSOR == -1 || timestampAfterEOR == -1){ | |
2343 | if (timestampBeforeSOR == -1){ | |
2344 | AliError("Cannot calculate mean - no points during the run collected, and point before SOR missing"); | |
2345 | } | |
2346 | if (timestampAfterEOR == -1){ | |
2347 | AliError("Cannot calculate maen - no points during the run collected, and point after EOR missing"); | |
2348 | } | |
2349 | return AliGRPObject::GetInvalidFloat(); | |
2350 | } | |
2351 | else { | |
2352 | AliWarning("Using last entry before SOR and first entry after EOR."); | |
2353 | nentriesUsed = 2; | |
2354 | arrayValues = new Float_t[2]; | |
2355 | arrayWeights = new Double_t[2]; | |
2356 | arrayValues[0] = valueBeforeSOR; | |
2357 | arrayWeights[0] = (Double_t)(timestampAfterEOR - timestampBeforeSOR); | |
2358 | arrayValues[1] = valueAfterEOR; | |
2359 | arrayWeights[1] = 1.; | |
2360 | AliDebug(2,Form("value0 = %f, with weight = %f",arrayValues[0],arrayWeights[0])); | |
2361 | AliDebug(2,Form("value1 = %f, with weight = %f",arrayValues[1],arrayWeights[1])); | |
2362 | aDCSArrayMean = TMath::Mean(1,arrayValues,arrayWeights); | |
2363 | } | |
2364 | } | |
2365 | ||
2366 | AliInfo(Form("mean = %f ",aDCSArrayMean)); | |
44e45fac | 2367 | return aDCSArrayMean; |
e7a6790f | 2368 | |
17984b61 | 2369 | } |
125567f8 | 2370 | |
44e45fac | 2371 | |
17984b61 | 2372 | //_______________________________________________________________ |
44e45fac | 2373 | |
3ba92a38 | 2374 | AliDCSSensorArray *AliGRPPreprocessor::GetPressureMap(TMap* dcsAliasMap) |
e7a6790f | 2375 | { |
44e45fac | 2376 | // extract DCS pressure maps. Perform fits to save space |
2377 | ||
44e45fac | 2378 | TMap *map = fPressure->ExtractDCS(dcsAliasMap); |
2379 | if (map) { | |
d7edf69d | 2380 | AliDebug(2,Form("Map has %d entries",map->GetEntries())); |
44e45fac | 2381 | fPressure->MakeSplineFit(map); |
2382 | Double_t fitFraction = fPressure->NumFits()/fPressure->NumSensors(); | |
2383 | if (fitFraction > kFitFraction ) { | |
ce996d13 | 2384 | AliInfo(Form("Pressure values extracted, %d fits performed for %d sensors.", fPressure->NumFits(),fPressure->NumSensors())); |
44e45fac | 2385 | } else { |
2386 | AliInfo("Too few pressure maps fitted!!!"); | |
2387 | } | |
2388 | } else { | |
2389 | AliInfo("no atmospheric pressure map extracted!!!"); | |
2390 | } | |
2391 | delete map; | |
2392 | ||
2393 | return fPressure; | |
17984b61 | 2394 | } |
e97cc90e | 2395 | |
1e27bb6b | 2396 | |
2397 | ||
2398 | //_______________________________________________________________ | |
03e5ee4f | 2399 | 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 | 2400 | { |
44e45fac | 2401 | // |
2402 | // Retrieves logbook and trigger information from the online logbook | |
2403 | // This information is needed for prompt reconstruction | |
2404 | // | |
2405 | // Parameters are: | |
2406 | // Run number | |
2407 | // DAQ params: dbHost, dbPort, dbName, user, password, logbookTable, triggerTable | |
2408 | // cdbRoot | |
2409 | // | |
2410 | // returns: | |
2411 | // positive on success: the return code is the run number of last run processed of the same run type already processed by the SHUTTLE | |
2412 | // 0 on success and no run was found | |
2413 | // negative on error | |
2414 | // | |
2415 | // This function is NOT called during the preprocessor run in the Shuttle! | |
2416 | // | |
2417 | ||
2418 | // defaults | |
2419 | if (dbPort == 0) | |
2420 | dbPort = 3306; | |
2421 | ||
2422 | // CDB connection | |
2423 | AliCDBManager* cdb = AliCDBManager::Instance(); | |
2424 | cdb->SetDefaultStorage(cdbRoot); | |
2425 | ||
2426 | // SQL connection | |
2427 | TSQLServer* server = TSQLServer::Connect(Form("mysql://%s:%d/%s", dbHost, dbPort, dbName), user, password); | |
2428 | ||
2429 | if (!server) | |
2430 | { | |
2431 | Printf("ERROR: Could not connect to DAQ LB"); | |
2432 | return -1; | |
2433 | } | |
2434 | ||
2435 | // main logbook | |
2436 | TString sqlQuery; | |
5d43966f | 2437 | sqlQuery.Form("SELECT DAQ_time_start, run_type, detectorMask, L3_magnetCurrent, Dipole_magnetCurrent,beamType FROM logbook WHERE run = %d", run); |
44e45fac | 2438 | TSQLResult* result = server->Query(sqlQuery); |
2439 | if (!result) | |
2440 | { | |
2441 | Printf("ERROR: Can't execute query <%s>!", sqlQuery.Data()); | |
2442 | return -2; | |
2443 | } | |
2444 | ||
2445 | if (result->GetRowCount() == 0) | |
2446 | { | |
2447 | Printf("ERROR: Run %d not found", run); | |
2448 | delete result; | |
2449 | return -3; | |
2450 | } | |
2451 | ||
2452 | TSQLRow* row = result->Next(); | |
2453 | if (!row) | |
2454 | { | |
2455 | Printf("ERROR: Could not receive data from run %d", run); | |
2456 | delete result; | |
2457 | return -4; | |
2458 | } | |
2459 | ||
26c1dff2 | 2460 | TString timeStartString(row->GetField(0)); |
44e45fac | 2461 | TString runType(row->GetField(1)); |
26c1dff2 | 2462 | TString detectorMaskString(row->GetField(2)); |
2463 | TString l3CurrentString(row->GetField(3)); | |
2464 | TString dipoleCurrentString(row->GetField(4)); | |
5d43966f | 2465 | TString beamTypeString(row->GetField(5)); |
26c1dff2 | 2466 | time_t timeStart = (time_t)(timeStartString.Atoi()); |
2467 | UInt_t detectorMask = (UInt_t)(detectorMaskString.Atoi()); | |
2468 | Float_t l3Current = (Float_t)(TMath::Abs(l3CurrentString.Atof())); | |
2469 | Float_t dipoleCurrent = (Float_t)(TMath::Abs(dipoleCurrentString.Atof())); | |
03e5ee4f | 2470 | Char_t l3Polarity = (l3CurrentString.Atof() < 0) ? 1 : 0; |
2471 | Char_t dipolePolarity = (dipoleCurrentString.Atof() < 0) ? 1 : 0; | |
9f08228b | 2472 | if (beamTypeString.CompareTo("Pb-Pb",TString::kIgnoreCase) == 0){ |
2473 | beamTypeString="A-A"; | |
2474 | } | |
44e45fac | 2475 | |
26c1dff2 | 2476 | AliGRPObject * grpObj = new AliGRPObject(); |
2477 | grpObj->SetTimeStart(timeStart); | |
2478 | grpObj->SetRunType((TString)(row->GetField(1))); | |
2479 | grpObj->SetDetectorMask(detectorMask); | |
2480 | grpObj->SetL3Current(l3Current,(AliGRPObject::Stats)0); | |
2481 | grpObj->SetDipoleCurrent(dipoleCurrent,(AliGRPObject::Stats)0); | |
03e5ee4f | 2482 | grpObj->SetL3Polarity(l3Polarity); |
2483 | grpObj->SetDipolePolarity(dipolePolarity); | |
48fcacdc | 2484 | grpObj->SetPolarityConventionLHC(); // after the dipole cables swap we comply with LHC convention |
9f08228b | 2485 | grpObj->SetBeamType(beamTypeString); |
26c1dff2 | 2486 | |
44e45fac | 2487 | delete row; |
2488 | row = 0; | |
2489 | ||
2490 | delete result; | |
2491 | result = 0; | |
2492 | ||
2493 | Printf("Storing GRP/GRP/Data object with the following content"); | |
26c1dff2 | 2494 | grpObj->Dump(); |
44e45fac | 2495 | |
2496 | AliCDBMetaData metadata; | |
26c1dff2 | 2497 | metadata.SetResponsible("Jan Fiete Grosse-Oetringhaus & Chiara Zampolli"); |
44e45fac | 2498 | metadata.SetComment("GRP Output parameters received during online running"); |
2499 | ||
2500 | AliCDBId id("GRP/GRP/Data", run, run); | |
26c1dff2 | 2501 | Bool_t success = cdb->Put(grpObj, id, &metadata); |
44e45fac | 2502 | |
26c1dff2 | 2503 | delete grpObj; |
44e45fac | 2504 | |
2505 | if (!success) | |
2506 | { | |
2507 | Printf("ERROR: Could not store GRP/GRP/Data into OCDB"); | |
2508 | return -5; | |
2509 | } | |
2510 | ||
2511 | // Receive trigger information | |
2512 | sqlQuery.Form("SELECT configFile FROM logbook_trigger_config WHERE run = %d", run); | |
2513 | result = server->Query(sqlQuery); | |
2514 | if (!result) | |
2515 | { | |
2516 | Printf("ERROR: Can't execute query <%s>!", sqlQuery.Data()); | |
2517 | return -11; | |
2518 | } | |
2519 | ||
2520 | if (result->GetRowCount() == 0) | |
2521 | { | |
2522 | Printf("ERROR: Run %d not found in logbook_trigger_config", run); | |
2523 | delete result; | |
2524 | return -12; | |
2525 | } | |
2526 | ||
2527 | row = result->Next(); | |
2528 | if (!row) | |
2529 | { | |
2530 | Printf("ERROR: Could not receive logbook_trigger_config data from run %d", run); | |
2531 | delete result; | |
2532 | return -13; | |
2533 | } | |
2534 | ||
2535 | TString triggerConfig(row->GetField(0)); | |
2536 | ||
2537 | delete row; | |
2538 | row = 0; | |
2539 | ||
2540 | delete result; | |
2541 | result = 0; | |
2542 | ||
2543 | Printf("Found trigger configuration: %s", triggerConfig.Data()); | |
2544 | ||
2545 | AliTriggerConfiguration *runcfg = AliTriggerConfiguration::LoadConfigurationFromString(triggerConfig); | |
2546 | if (!runcfg) | |
2547 | { | |
2548 | Printf("ERROR: Could not create CTP configuration object"); | |
2549 | return -14; | |
2550 | } | |
2551 | ||
2552 | metadata.SetComment("CTP run configuration received during online running"); | |
2553 | ||
2554 | AliCDBId id2("GRP/CTP/Config", run, run); | |
2555 | success = cdb->Put(runcfg, id2, &metadata); | |
2556 | ||
2557 | delete runcfg; | |
2558 | runcfg = 0; | |
2559 | ||
2560 | if (!success) | |
2561 | { | |
2562 | Printf("ERROR: Could not store GRP/CTP/Config into OCDB"); | |
2563 | return -15; | |
2564 | } | |
2565 | ||
03e5ee4f | 2566 | |
2567 | // Receive list of GDCs for this run | |
2568 | sqlQuery.Form("SELECT GDC FROM logbook_stats_GDC WHERE run = %d", run); | |
2569 | result = server->Query(sqlQuery); | |
2570 | if (!result) | |
2571 | { | |
2572 | Printf("ERROR: Can't execute query <%s>!", sqlQuery.Data()); | |
2573 | return -24; | |
2574 | } | |
2575 | ||
2576 | if (result->GetRowCount() == 0) | |
2577 | { | |
2578 | Printf("ERROR: Run %d not found in logbook_stats_GDC", run); | |
2579 | delete result; | |
2580 | return -25; | |
2581 | } | |
2b81b7d0 | 2582 | |
2583 | gdc = ""; | |
2584 | for (Int_t iGDC = 0; iGDC < result->GetRowCount(); iGDC++) { | |
2585 | row = result->Next(); | |
2586 | if (!row) | |
2587 | { | |
2588 | Printf("ERROR: Could not receive logbook_stats_GDC data from run %d", run); | |
2589 | delete result; | |
2590 | return -26; | |
2591 | } | |
2592 | gdc += row->GetField(0); | |
2593 | gdc += " "; | |
2594 | } | |
2595 | ||
03e5ee4f | 2596 | delete row; |
2597 | row = 0; | |
2598 | ||
2599 | delete result; | |
2600 | result = 0; | |
2601 | ||
2602 | Printf("Found GDC: %s", gdc.Data()); | |
2603 | ||
44e45fac | 2604 | // get last run with same run type that was already processed by the SHUTTLE |
2605 | ||
2606 | 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()); | |
2607 | result = server->Query(sqlQuery); | |
2608 | if (!result) | |
2609 | { | |
2610 | Printf("ERROR: Can't execute query <%s>!", sqlQuery.Data()); | |
2611 | return -21; | |
2612 | } | |
2613 | ||
2614 | if (result->GetRowCount() == 0) | |
2615 | { | |
2616 | Printf("ERROR: No result with query <%s>", sqlQuery.Data()); | |
2617 | delete result; | |
2618 | return -22; | |
2619 | } | |
2620 | ||
2621 | row = result->Next(); | |
2622 | if (!row) | |
2623 | { | |
2624 | Printf("ERROR: Could not receive data for query <%s>", sqlQuery.Data()); | |
2625 | delete result; | |
2626 | return -23; | |
2627 | } | |
2628 | ||
2629 | TString lastRunStr(row->GetField(0)); | |
2630 | Int_t lastRun = lastRunStr.Atoi(); | |
2631 | ||
2632 | Printf("Last run with same run type %s is %d", runType.Data(), lastRun); | |
2633 | ||
2634 | delete row; | |
2635 | row = 0; | |
2636 | ||
2637 | delete result; | |
2638 | result = 0; | |
2639 | ||
2640 | server->Close(); | |
2641 | delete server; | |
2642 | server = 0; | |
2643 | ||
2644 | return lastRun; | |
1e27bb6b | 2645 | } |
0254e751 | 2646 | //----------------------------------------------------------------- |
ac152fdd | 2647 | Double_t AliGRPPreprocessor::CalculateMean(TObjArray* const array){ |
0254e751 | 2648 | |
2649 | // | |
2650 | // Calculating mean over TObjArray from LHC Data | |
2651 | // | |
2652 | ||
2653 | TString timeStartString = (TString)GetRunParameter("DAQ_time_start"); | |
2654 | TString timeEndString = (TString)GetRunParameter("DAQ_time_end"); | |
2655 | if (timeStartString.IsNull() || timeStartString.IsNull()){ | |
2656 | if (timeStartString.IsNull()){ | |
2657 | AliError("DAQ_time_start not set in logbook! Setting statistical values for current DP to invalid"); | |
2658 | } | |
2659 | else if (timeStartString.IsNull()){ | |
2660 | AliError("DAQ_time_end not set in logbook! Setting statistical values for current DP to invalid"); | |
2661 | } | |
2662 | return 0; | |
2663 | } | |
2664 | ||
2665 | Int_t timeStart = (Int_t)(timeStartString.Atoi()); | |
2666 | Int_t timeEnd = (Int_t)(timeEndString.Atoi()); | |
2667 | timeStart = 1260646960; | |
2668 | timeEnd = 1260652740; | |
2669 | Double_t* parameters = new Double_t[5]; | |
2670 | parameters[0] = -1.; | |
2671 | parameters[1] = -1.; | |
2672 | parameters[2] = -1.; | |
2673 | parameters[3] = -1.; | |
2674 | parameters[4] = -1.; | |
2675 | Int_t iCounts = 0; | |
2676 | Int_t iCountsRun = 0; | |
2677 | Int_t nCounts = array->GetEntries(); | |
2678 | printf("ncounts = %d\n",nCounts); | |
2679 | Double_t valueBeforeSOR = 0; | |
2680 | Double_t valueAfterEOR = 0; | |
2681 | Double_t timestampBeforeSOR = -1.; | |
2682 | Double_t timestampAfterEOR = -1.; | |
2683 | Int_t ientrySOR = -1; | |
2684 | Int_t ientryEOR = -1; | |
2685 | Double_t* arrayValues = 0x0; | |
2686 | Double_t* arrayWeights = 0x0; | |
2687 | Bool_t truncMeanFlag = kTRUE; // flag to indicate whether Truncated Mean should be calculated or not | |
2688 | Bool_t sdFlag = kTRUE; // flag to indicate whether SD (wrt Mean/Median) should be calculated or not | |
2689 | ||
2690 | for(Int_t i = 0; i < nCounts; i++) { | |
2691 | AliDCSArray *dcs = (AliDCSArray*)array->At(i); | |
2692 | if((dcs->GetTimeStamp() >= timeStart) &&(dcs->GetTimeStamp() <= timeEnd)) { | |
2693 | AliDebug(2,Form("%d-th entry = %f at timestamp %f\n",i,(Double_t)(dcs->GetInt(0)),dcs->GetTimeStamp())); | |
2694 | iCounts += 1; | |
2695 | // look for the last value before SOR and the first value before EOR | |
2696 | if ((dcs->GetTimeStamp() >= timeStart) && (dcs->GetTimeStamp() < timeStart)) { | |
2697 | timestampBeforeSOR = dcs->GetTimeStamp(); | |
2698 | AliDebug(2,Form("timestamp of last value before SOR = %f, with DAQ_time_start = %d\n",timestampBeforeSOR,timeStart)); | |
2699 | valueBeforeSOR = (Double_t)(dcs->GetInt(0)); | |
2700 | } | |
2701 | else if ((dcs->GetTimeStamp() <= timeEnd) && (dcs->GetTimeStamp() > timeEnd) && timestampAfterEOR == -1){ | |
2702 | timestampAfterEOR = dcs->GetTimeStamp(); | |
2703 | valueAfterEOR = (Double_t)(dcs->GetInt(0)); | |
2704 | AliDebug(2,Form("timestamp of first value after EOR = %f, with DAQ_time_end = %d\n",timestampAfterEOR,timeEnd)); | |
2705 | } | |
2706 | // check if there are DPs between DAQ_time_start and DAQ_time_end | |
2707 | if((dcs->GetTimeStamp() >= timeStart) &&(dcs->GetTimeStamp() <= timeEnd)) { | |
2708 | if (ientrySOR == -1) ientrySOR = i; // first entry after SOR | |
2709 | if (ientryEOR < i) ientryEOR = i; // last entry before EOR | |
2710 | AliDebug(2,Form("entry between SOR and EOR\n")); | |
2711 | iCountsRun += 1; | |
2712 | } | |
2713 | } | |
2714 | else { | |
2715 | printf("DCS values for the parameter outside the queried interval: timestamp = %f\n",dcs->GetTimeStamp()); | |
2716 | } | |
2717 | } | |
2718 | ||
2719 | if (timestampBeforeSOR == -1.){ | |
2720 | printf("No value found before SOR\n"); | |
2721 | } | |
2722 | if (timestampAfterEOR == -1.){ | |
2723 | printf("No value found after EOR\n"); | |
2724 | } | |
2725 | ||
2726 | printf("Number of valid entries (within DCS query interval) = %i, from a total amount of %i entries\n",iCounts,nCounts); | |
2727 | printf("Last value before DAQ_time_start (SOR) = %f at timestamp = %f\n",valueBeforeSOR,timestampBeforeSOR); | |
2728 | printf("First value after DAQ_time_end (EOR) = %f at timestamp = %f\n",valueAfterEOR,timestampAfterEOR); | |
2729 | printf("Found %d entries between DAQ_time_start (SOR) and DAQ_time_end (EOR)\n",iCountsRun); | |
2730 | printf("Index of first entry after DAQ_time_start (SOR) = %d\n ",ientrySOR); | |
2731 | printf("Index of first entry before DAQ_time_end (EOR) = %d\n ",ientryEOR); | |
2732 | ||
2733 | Int_t nentriesUsed = 0; | |
2734 | if (iCountsRun > 1){ | |
2735 | printf("Using entries between DAQ_time_start (SOR) and DAQ_time_end (EOR)\n"); | |
2736 | printf("Calculating (weighted) Mean and Median\n" ); | |
2737 | arrayValues = new Double_t[iCountsRun]; | |
2738 | arrayWeights = new Double_t[iCountsRun]; | |
2739 | nentriesUsed = iCountsRun; | |
2740 | for (Int_t i = ientrySOR; i <= ientryEOR; i++){ | |
2741 | AliDCSArray *dcs = (AliDCSArray *)array->At(i); | |
2742 | Double_t timestamp2 = 0; | |
2743 | if (i < ientryEOR){ | |
2744 | AliDCSArray *dcs1 = (AliDCSArray *)array->At(i+1); | |
2745 | timestamp2 = dcs1->GetTimeStamp(); | |
2746 | } | |
2747 | else { | |
2748 | timestamp2 = (Double_t)timeEnd+1; | |
2749 | } | |
2750 | arrayWeights[i-ientrySOR] = (Double_t)((Double_t)timestamp2 - dcs->GetTimeStamp()); | |
2751 | arrayValues[i-ientrySOR] = (Double_t)(dcs->GetInt(0)); | |
2752 | printf("Entry %d: value = %f, weight = %f\n",i-ientrySOR,arrayValues[i-ientrySOR],arrayWeights[i-ientrySOR]); | |
2753 | } | |
2754 | parameters[0] = TMath::Mean(iCountsRun,arrayValues,arrayWeights); | |
2755 | parameters[2] = TMath::Median(iCountsRun,arrayValues,arrayWeights); | |
2756 | } | |
2757 | else if (iCountsRun == 1){ | |
2758 | AliDCSArray* dcs = (AliDCSArray *)array->At(ientrySOR); | |
2759 | nentriesUsed = 2; | |
2760 | if (timestampBeforeSOR != -1 && timestampBeforeSOR != (Int_t)dcs->GetTimeStamp()){ | |
2761 | printf("Using single entry between DAQ_time_start (SOR) and DAQ_time_end (EOR) and last entry before SOR. Truncated mean won't be calculated.\n"); | |
2762 | arrayValues = new Double_t[2]; | |
2763 | arrayWeights = new Double_t[2]; | |
2764 | arrayValues[0] = valueBeforeSOR; | |
2765 | arrayWeights[0] = (Double_t)(dcs->GetTimeStamp()-(Double_t)timestampBeforeSOR); | |
2766 | arrayValues[1] = (Double_t)(dcs->GetInt(0)); | |
2767 | arrayWeights[1] = (Double_t)((Double_t)timeEnd+1-dcs->GetTimeStamp()); | |
2768 | printf("value0 = %f, with weight = %f\n",arrayValues[0],arrayWeights[0]); | |
2769 | printf("value1 = %f, with weight = %f\n",arrayValues[1],arrayWeights[1]); | |
2770 | parameters[0] = TMath::Mean(2,arrayValues,arrayWeights); | |
2771 | parameters[2] = TMath::Median(2,arrayValues,arrayWeights); | |
2772 | truncMeanFlag = kFALSE; | |
2773 | } | |
2774 | else{ | |
2775 | printf("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\n"); | |
2776 | parameters[0] = -1; | |
2777 | parameters[1] = -1; | |
2778 | parameters[2] = -1; | |
2779 | parameters[3] = -1; | |
2780 | parameters[4] = -1; | |
2781 | return parameters[0]; | |
2782 | } | |
2783 | } | |
2784 | else { // iCountsRun == 0, using only the point immediately before SOR | |
2785 | if (timestampBeforeSOR == -1.){ | |
2786 | printf("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\n"); | |
2787 | parameters[0] = -1; | |
2788 | parameters[1] = -1; | |
2789 | parameters[2] = -1; | |
2790 | parameters[3] = -1; | |
2791 | parameters[4] = -1; | |
2792 | return parameters[0]; | |
2793 | } | |
2794 | else { | |
2795 | printf("Using only last entry before SOR. Truncated mean and Standard deviations (wrt mean/median) won't be calculated.\n"); | |
2796 | printf("value = %f\n",valueBeforeSOR); | |
2797 | parameters[0] = valueBeforeSOR; | |
2798 | parameters[2] = valueBeforeSOR; | |
2799 | truncMeanFlag = kFALSE; | |
2800 | sdFlag = kFALSE; | |
2801 | } | |
2802 | } | |
2803 | ||
2804 | Double_t temp = 0; | |
2805 | Double_t temp1 = 0; | |
2806 | Double_t sumweights = 0; | |
2807 | Int_t entriesTruncMean = 0; | |
2808 | Double_t* arrayValuesTruncMean = new Double_t[nentriesUsed]; | |
2809 | Double_t* arrayWeightsTruncMean = new Double_t[nentriesUsed]; | |
2810 | ||
2811 | // calculating SD wrt Mean and Median | |
2812 | printf("Calculating SD wrt Mean and SD wrt Median\n"); | |
2813 | if (sdFlag){ | |
2814 | for (Int_t i =0; i< nentriesUsed; i++){ | |
2815 | //printf("Entry %d: value = %f, weight = %f\n",i,arrayValues[i],arrayWeights[i]); | |
2816 | temp += (arrayValues[i]-parameters[2])*(arrayValues[i]-parameters[2]); | |
2817 | temp1 += arrayWeights[i]*(arrayValues[i]-parameters[0])*(arrayValues[i]-parameters[0]); | |
2818 | sumweights += arrayWeights[i]; | |
2819 | } | |
2820 | // setting SD wrt Mean | |
2821 | if (sumweights != 0 ){ | |
2822 | parameters[3] = TMath::Sqrt(temp1/sumweights); | |
2823 | } | |
2824 | else { | |
2825 | printf("Sum of weights to calculate Standard Deviation (wrt mean) <= 0, setting the SD to invalid\n"); | |
2826 | parameters[3] = -1; | |
2827 | } | |
2828 | // setting SD wrt Median | |
2829 | if (nentriesUsed != 0){ | |
2830 | parameters[4] = TMath::Sqrt(temp/nentriesUsed); | |
2831 | } | |
2832 | else{ | |
2833 | printf("Number of entries used to calculate Standard Deviation (wrt median) <= 0, setting the SD to invalid\n"); | |
2834 | parameters[4] = -1; | |
2835 | } | |
2836 | } | |
2837 | else { | |
2838 | parameters[3] = -1; | |
2839 | parameters[4] = -1; | |
2840 | } | |
2841 | ||
2842 | // calculating truncated mean (this comes afterwards since you need the SD wrt Mean) | |
2843 | if (truncMeanFlag){ | |
2844 | printf("Calculating Truncated Mean\n"); | |
2845 | for (Int_t i =0; i< nentriesUsed; i++){ | |
2846 | //printf("Entry %d: value = %f, weight = %f\n",i,arrayValues[i],arrayWeights[i]); | |
2847 | if ((arrayValues[i]<=parameters[0]+3*parameters[3]) && (arrayValues[i]>=parameters[0]-3*parameters[3])){ | |
2848 | arrayValuesTruncMean[entriesTruncMean]=arrayValues[i]; | |
2849 | arrayWeightsTruncMean[entriesTruncMean]=arrayWeights[i]; | |
2850 | printf("For Truncated Mean: Entry %d: value = %f, weight = %f\n",entriesTruncMean,arrayValuesTruncMean[entriesTruncMean],arrayWeightsTruncMean[entriesTruncMean]); | |
2851 | entriesTruncMean++; | |
2852 | } | |
2853 | else{ | |
2854 | printf("Discarding entry\n"); | |
2855 | } | |
2856 | } | |
2857 | // setting truncated mean | |
2858 | if (entriesTruncMean >1){ | |
2859 | printf("%d entries used for truncated mean\n",entriesTruncMean); | |
2860 | parameters[1] = TMath::Mean(entriesTruncMean,arrayValuesTruncMean,arrayWeightsTruncMean); | |
2861 | } | |
2862 | else{ | |
2863 | printf("Too few entries (%d) to calculate truncated mean\n",entriesTruncMean); | |
2864 | parameters[1] = -1; | |
2865 | } | |
2866 | } | |
2867 | else{ | |
2868 | parameters[1] = -1; | |
2869 | } | |
2870 | ||
2871 | printf("(weighted) mean = %f \n",parameters[0]); | |
2872 | printf("(weighted) truncated mean = %f \n",parameters[1]); | |
2873 | printf("median = %f \n",parameters[2]); | |
2874 | printf("(weighted) standard deviation with (weighted) mean = %f \n",parameters[3]); | |
2875 | printf("standard deviation with median = %f \n",parameters[4]); | |
2876 | ||
2877 | return (parameters[0]); | |
2878 | } | |
2879 | //------------------------------------------------------------------------------------------------------ | |
4cbf81c1 | 2880 | Float_t AliGRPPreprocessor::ProcessEnergy(TObjArray* const array, Double_t timeStart){ |
0254e751 | 2881 | |
2882 | // | |
2883 | // Method to processo LHC Energy information | |
2884 | // Only the first value is returned, provided that it is withing DAQ_time_start and DAQ_time_end | |
2885 | // | |
2886 | ||
2887 | Int_t nCounts = array->GetEntries(); | |
2888 | Float_t energy = -1; | |
4cbf81c1 | 2889 | Double_t timeEnergy = -1; |
2890 | Int_t indexEnergy = -1; | |
2891 | Bool_t foundEnergy = kFALSE; | |
2892 | ||
0254e751 | 2893 | AliDebug(2,Form("Energy measurements = %d\n",nCounts)); |
0d361338 | 2894 | if (nCounts ==0){ |
2895 | AliWarning("No Energy values found! Beam Energy remaining invalid!"); | |
2896 | } | |
2897 | else{ | |
4cbf81c1 | 2898 | for (Int_t i = 0; i < nCounts; i++){ |
0d361338 | 2899 | AliDCSArray *dcs = (AliDCSArray*)array->At(i); |
4cbf81c1 | 2900 | if (dcs){ |
2901 | if (dcs->GetTimeStamp()<=timeStart && dcs->GetTimeStamp()>=timeEnergy){// taking always the very last entry: of two measurements have the same timestamp, the last one is taken | |
2902 | timeEnergy = dcs->GetTimeStamp(); | |
2903 | indexEnergy = i; | |
2904 | foundEnergy = kTRUE; | |
2905 | } | |
2906 | else{ | |
2907 | break; | |
2908 | } | |
0d361338 | 2909 | } |
0254e751 | 2910 | } |
4cbf81c1 | 2911 | if (!foundEnergy){ |
2912 | AliInfo("No value for the Energy found before start of run, the Energy will remain invalid"); | |
2913 | } | |
2914 | else { | |
2915 | AliDCSArray* dcs = (AliDCSArray*)array->At(indexEnergy); | |
2916 | energy = (Float_t)(TMath::Nint(((Double_t)(dcs->GetInt(0)))*120/1000)); // sqrt(s)/2 energy in GeV | |
2917 | AliInfo(Form("Energy value found = %d (at %f), converting --> sqrt(s)/2 = %f (GeV)", dcs->GetInt(0),dcs->GetTimeStamp(),energy)); | |
e541e2aa | 2918 | } |
0254e751 | 2919 | } |
2920 | ||
2921 | return energy; | |
2922 | } | |
8c1f1006 | 2923 | //------------------------------------------------------------------------------------------------------ |
17fd2848 | 2924 | AliLHCClockPhase* AliGRPPreprocessor::ProcessLHCClockPhase(TObjArray *beam1phase,TObjArray *beam2phase, Double_t timeEnd) |
8c1f1006 | 2925 | { |
2926 | // | |
2927 | // Method to process LHC-Clock Phase data | |
2928 | // Only the values between DAQ_time_start and DAQ_time_end are kept | |
2929 | // | |
2930 | AliLHCClockPhase *phaseObj = new AliLHCClockPhase; | |
2931 | ||
2932 | Bool_t foundBeam1Phase = kFALSE, foundBeam2Phase = kFALSE; | |
0c191635 | 2933 | const Float_t threshold = 0.050; // we store the measurement only in case they differ with more 50ps from the previous one |
8c1f1006 | 2934 | |
17fd2848 | 2935 | TString timeCreatedStr = GetRunParameter("time_created"); |
2936 | Double_t timeCreated = timeCreatedStr.Atof(); | |
2937 | ||
8c1f1006 | 2938 | Int_t nCounts = beam1phase->GetEntries(); |
2939 | AliDebug(2,Form("Beam1 phase measurements = %d\n",nCounts)); | |
2940 | if (nCounts ==0){ | |
2941 | AliWarning("No beam1 LHC clock phase values found!"); | |
2942 | delete phaseObj; | |
2943 | return NULL; | |
2944 | } | |
2945 | else{ | |
0c191635 | 2946 | Double_t prevPhase = 0; |
8c1f1006 | 2947 | for (Int_t i = 0; i < nCounts; i++){ |
2948 | AliDCSArray *dcs = (AliDCSArray*)beam1phase->At(i); | |
2949 | if (dcs){ | |
f1226569 | 2950 | //if (dcs->GetTimeStamp()>=timeStart && dcs->GetTimeStamp()<=timeEnd) { |
2951 | if (dcs->GetTimeStamp()>=timeCreated && dcs->GetTimeStamp()<=timeEnd) { | |
0c191635 | 2952 | if ((i == 0) || (i == (nCounts-1)) || |
2953 | !foundBeam1Phase || | |
2954 | (TMath::Abs(dcs->GetDouble(0)-prevPhase) > threshold)) { | |
2955 | prevPhase = dcs->GetDouble(0); | |
2956 | foundBeam1Phase = kTRUE; | |
2957 | AliInfo(Form("B1 Clk Phase = %f at TS = %f", | |
2958 | (Float_t)dcs->GetDouble(0),dcs->GetTimeStamp())); | |
2959 | phaseObj->AddPhaseB1DP((UInt_t)dcs->GetTimeStamp(),(Float_t)dcs->GetDouble(0)); | |
2960 | } | |
8c1f1006 | 2961 | } |
2962 | } | |
2963 | } | |
2964 | if (!foundBeam1Phase){ | |
2965 | AliError("No beam1 LHC clock phase values found within the run!"); | |
2966 | delete phaseObj; | |
2967 | return NULL; | |
2968 | } | |
2969 | } | |
2970 | ||
2971 | nCounts = beam2phase->GetEntries(); | |
2972 | AliDebug(2,Form("Beam2 phase measurements = %d\n",nCounts)); | |
2973 | if (nCounts ==0){ | |
2974 | AliWarning("No beam2 LHC clock phase values found!"); | |
2975 | delete phaseObj; | |
2976 | return NULL; | |
2977 | } | |
2978 | else{ | |
0c191635 | 2979 | Double_t prevPhase = 0; |
8c1f1006 | 2980 | for (Int_t i = 0; i < nCounts; i++){ |
2981 | AliDCSArray *dcs = (AliDCSArray*)beam2phase->At(i); | |
2982 | if (dcs){ | |
17fd2848 | 2983 | if (dcs->GetTimeStamp()>=timeCreated && dcs->GetTimeStamp()<=timeEnd) { |
0c191635 | 2984 | if ((i == 0) || (i == (nCounts-1)) || |
2985 | !foundBeam2Phase || | |
2986 | (TMath::Abs(dcs->GetDouble(0)-prevPhase) > threshold)) { | |
2987 | prevPhase = dcs->GetDouble(0); | |
2988 | foundBeam2Phase = kTRUE; | |
2989 | AliInfo(Form("B2 Clk Phase = %f at TS = %f", | |
2990 | (Float_t)dcs->GetDouble(0),dcs->GetTimeStamp())); | |
2991 | phaseObj->AddPhaseB2DP((UInt_t)dcs->GetTimeStamp(),(Float_t)dcs->GetDouble(0)); | |
2992 | } | |
8c1f1006 | 2993 | } |
2994 | } | |
2995 | } | |
2996 | if (!foundBeam2Phase){ | |
2997 | AliError("No beam2 LHC clock phase values found within the run!"); | |
2998 | delete phaseObj; | |
2999 | return NULL; | |
3000 | } | |
3001 | } | |
3002 | ||
3003 | return phaseObj; | |
3004 | } |