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