]>
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 |
3dedb44a | 23 | //------------------------------------------------------------------------- |
24 | ||
836d8b4f | 25 | #include <TChain.h> |
7ca4655f | 26 | #include <TList.h> |
27 | #include <TMap.h> | |
28 | #include <TObjString.h> | |
29 | #include <TTimeStamp.h> | |
29cc8704 | 30 | #include <TSystem.h> |
31 | #include <TFile.h> | |
7ca4655f | 32 | |
3dedb44a | 33 | #include "AliGRPPreprocessor.h" |
34 | #include "AliGRPDCS.h" | |
17984b61 | 35 | #include "AliDCSSensorArray.h" |
3dedb44a | 36 | |
48b1b444 | 37 | #include "AliTriggerConfiguration.h" |
38 | #include "AliTriggerRunScalers.h" | |
39 | ||
3dedb44a | 40 | #include "AliCDBMetaData.h" |
41 | #include "AliLog.h" | |
42 | ||
3dedb44a | 43 | class AliDCSValue; |
44 | class AliShuttleInterface; | |
45 | ||
46 | #include <TH1.h> | |
47 | ||
1e27bb6b | 48 | // needed for ReceivePromptRecoParameters |
49 | #include <TSQLServer.h> | |
50 | #include <TSQLResult.h> | |
51 | #include <TSQLRow.h> | |
52 | #include <AliCDBManager.h> | |
53 | #include <AliCDBMetaData.h> | |
54 | #include <AliCDBId.h> | |
55 | #include <AliTriggerConfiguration.h> | |
56 | ||
17984b61 | 57 | const Double_t kFitFraction = 0.7; // Fraction of DCS sensor fits required |
58 | ||
3dedb44a | 59 | ClassImp(AliGRPPreprocessor) |
60 | ||
17984b61 | 61 | //_______________________________________________________________ |
e7a6790f | 62 | const Int_t AliGRPPreprocessor::fgknDAQLbPar = 8; // num parameters in the logbook |
63 | const Int_t AliGRPPreprocessor::fgknDCSDP = 11; // number of dcs dps | |
64 | const char* AliGRPPreprocessor::fgkDCSDataPoints[AliGRPPreprocessor::fgknDCSDP] = { | |
7e1a6c0b | 65 | "LHCState", |
e7a6790f | 66 | "L3Polarity", |
67 | "DipolePolarity", | |
7e1a6c0b | 68 | "LHCLuminosity", |
69 | "BeamIntensity", | |
e7a6790f | 70 | "L3Current", |
71 | "DipoleCurrent", | |
72 | "CavernTemperature", | |
73 | "CavernAtmosPressure", | |
7e1a6c0b | 74 | "gva_cr5AtmosphericPressure", |
75 | "gva_meyrinAtmosphericPressure" | |
e7a6790f | 76 | }; |
77 | ||
78 | const Short_t kSensors = 9; // start index position of sensor in DCS DPs | |
79 | ||
80 | const char* AliGRPPreprocessor::fgkLHCState[20] = { | |
81 | "P", "PREPARE", | |
82 | "J", "PREINJECTION", | |
83 | "I", "INJECTION", | |
84 | "F", "FILLING", | |
85 | "A", "ADJUST", | |
86 | "U", "UNSTABLE BEAMS", | |
87 | "S", "STABLE BEAMS", | |
88 | "D", "BEAM DUMP", | |
89 | "R", "RECOVER", | |
90 | "C", "PRECYCLE" | |
91 | }; | |
92 | ||
93 | const char* kppError[] = { | |
94 | "", | |
95 | "(DAQ logbook ERROR)", | |
96 | "(DAQ FXS ERROR)", | |
97 | "(DCS FXS ERROR)", | |
7e1a6c0b | 98 | "(DCS data points ERROR)", |
99 | "(Trigger Configuration ERROR)" | |
e7a6790f | 100 | }; |
17984b61 | 101 | |
3dedb44a | 102 | //_______________________________________________________________ |
103 | AliGRPPreprocessor::AliGRPPreprocessor(AliShuttleInterface* shuttle): | |
e7a6790f | 104 | AliPreprocessor("GRP",shuttle), fPressure(0) |
105 | { | |
3dedb44a | 106 | // constructor - shuttle must be instantiated! |
ad103e84 | 107 | |
108 | AddRunType("PHYSICS"); | |
3dedb44a | 109 | } |
110 | ||
111 | //_______________________________________________________________ | |
e7a6790f | 112 | AliGRPPreprocessor::~AliGRPPreprocessor() |
113 | { | |
3dedb44a | 114 | //destructor |
e7a6790f | 115 | |
17984b61 | 116 | delete fPressure; |
3dedb44a | 117 | } |
118 | ||
119 | //_______________________________________________________________ | |
e7a6790f | 120 | void AliGRPPreprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime) |
121 | { | |
3dedb44a | 122 | // Initialize preprocessor |
5a5052e5 | 123 | |
124 | AliPreprocessor::Initialize(run, startTime, endTime); | |
e7a6790f | 125 | |
17984b61 | 126 | AliInfo("Initialization of the GRP preprocessor."); |
127 | ||
128 | TClonesArray * array = new TClonesArray("AliDCSSensor",2); | |
129 | for(Int_t j = 0; j < 2; j++) { | |
130 | AliDCSSensor * sens = new ((*array)[j])AliDCSSensor; | |
e7a6790f | 131 | sens->SetStringID(fgkDCSDataPoints[j+kSensors]); |
17984b61 | 132 | } |
133 | AliInfo(Form("Pressure Entries: %d",array->GetEntries())); | |
134 | ||
135 | fPressure = new AliDCSSensorArray(fStartTime, fEndTime, array); | |
3dedb44a | 136 | } |
137 | ||
138 | //_______________________________________________________________ | |
e7a6790f | 139 | UInt_t AliGRPPreprocessor::Process(TMap* valueMap) |
140 | { | |
3dedb44a | 141 | // process data retrieved by the Shuttle |
17984b61 | 142 | |
143 | //=================// | |
144 | // DAQ logbook // | |
145 | //=================// | |
e7a6790f | 146 | UInt_t error = 0; |
29cc8704 | 147 | |
e7a6790f | 148 | TMap *grpmap = ProcessDaqLB(); |
149 | if( grpmap->GetEntries() == fgknDAQLbPar ) { | |
150 | Log(Form("DAQ logbook, successful!")); | |
151 | } else { | |
152 | Log(Form("DAQ logbook, missing parameters!!!")); | |
153 | error |= 1; | |
17984b61 | 154 | } |
17984b61 | 155 | //=================// |
156 | // DAQ FXS // | |
157 | //=================// | |
bba57327 | 158 | UInt_t iDaqFxs = ProcessDaqFxs(); |
e7a6790f | 159 | if( iDaqFxs == 0 ) { |
160 | Log(Form("DAQ FXS, successful!")); | |
b49acef7 | 161 | } else { |
e7a6790f | 162 | Log(Form("DAQ FXS, could not store run raw tag file!!!")); |
163 | error |= 2; | |
b49acef7 | 164 | } |
165 | ||
48b1b444 | 166 | //=================// |
167 | // DCS FXS // | |
168 | //=================// | |
169 | UInt_t iDcsFxs = ProcessDcsFxs(); | |
e7a6790f | 170 | if( iDcsFxs == 0 ) { |
171 | Log(Form("DCS FXS, successful!")); | |
48b1b444 | 172 | } else { |
e7a6790f | 173 | Log(Form("DCS FXS, Could not store CTP run configuration and scalers!!!")); |
174 | error |= 4; | |
48b1b444 | 175 | } |
b49acef7 | 176 | |
17984b61 | 177 | //=================// |
178 | // DCS data points // | |
179 | //=================// | |
e7a6790f | 180 | Int_t entries = ProcessDcsDPs( valueMap, grpmap ); |
7e1a6c0b | 181 | if( entries < fgknDCSDP-3 ) { // FIXME (!= ) LHState and pressure map are not working yet...??? |
17984b61 | 182 | Log(Form("Problem with the DCS data points!!!")); |
e7a6790f | 183 | error |= 8; |
184 | } else Log(Form("DCS data points, successful!")); | |
185 | ||
7e1a6c0b | 186 | //=======================// |
187 | // Trigger Configuration // | |
188 | //=======================// | |
189 | // either from DAQ logbook..... | |
190 | const char * triggerConf = GetTriggerConfiguration(); | |
191 | if (triggerConf!= NULL) { | |
192 | Log("Found trigger configuration in DAQ logbook"); | |
193 | AliTriggerConfiguration *runcfg = AliTriggerConfiguration::LoadConfigurationFromString(triggerConf); | |
194 | if (!runcfg) { | |
195 | Log("Bad CTP run configuration file from DAQ logbook! The corresponding CDB entry will not be filled!"); | |
196 | error |= 16; | |
197 | } | |
198 | else { | |
199 | AliCDBMetaData metaData; | |
200 | metaData.SetBeamPeriod(0); | |
201 | metaData.SetResponsible("Roman Lietava"); | |
202 | metaData.SetComment("CTP run configuration from DAQ logbook"); | |
203 | if (!Store("CTP","Config", runcfg, &metaData, 0, 0)) { | |
204 | Log("Unable to store the CTP run configuration object to OCDB!"); | |
205 | error |= 16; | |
206 | } | |
207 | } | |
208 | } | |
209 | // ...or from DCS FXS | |
210 | else{ | |
211 | Log("No trigger configuration found in the DAQ logbook!! Trying reading from DCS FXS..."); | |
212 | TString runcfgfile = GetFile(kDCS, "CTP_runconfig", ""); | |
213 | if (runcfgfile.IsNull()) { | |
214 | Log("No CTP runconfig files has been found in DCS FXS!"); | |
215 | error |= 16; | |
216 | } | |
217 | else { | |
218 | Log(Form("File with Id CTP_runconfig found! Copied to %s",runcfgfile.Data())); | |
219 | AliTriggerConfiguration *runcfg = AliTriggerConfiguration::LoadConfiguration(runcfgfile); | |
220 | if (!runcfg) { | |
221 | Log("Bad CTP run configuration file from DCS FXS! The corresponding CDB entry will not be filled!"); | |
222 | error |= 16;; | |
223 | } | |
224 | else { | |
225 | AliCDBMetaData metaData; | |
226 | metaData.SetBeamPeriod(0); | |
227 | metaData.SetResponsible("Roman Lietava"); | |
228 | metaData.SetComment("CTP run configuration from DCS FXS"); | |
229 | if (!Store("CTP","Config", runcfg, &metaData, 0, 0)) { | |
230 | Log("Unable to store the CTP run configuration object to OCDB!"); | |
231 | error |= 16; | |
232 | } | |
233 | } | |
234 | } | |
235 | } | |
236 | ||
e7a6790f | 237 | grpmap->SetOwner(1); |
238 | AliInfo(Form("Final list entries: %d",grpmap->GetEntries())); | |
17984b61 | 239 | |
240 | AliCDBMetaData md; | |
e7a6790f | 241 | md.SetResponsible("Ernesto Lopez Torres"); |
17984b61 | 242 | md.SetComment("Output parameters from the GRP preprocessor."); |
243 | ||
e7a6790f | 244 | Bool_t result = Store("GRP", "Data", grpmap, &md); |
17984b61 | 245 | |
e7a6790f | 246 | delete grpmap; |
17984b61 | 247 | |
e7a6790f | 248 | if (result && !error ) { |
249 | Log("GRP Preprocessor Success"); | |
17984b61 | 250 | return 0; |
e7a6790f | 251 | } else { |
7e1a6c0b | 252 | Log( Form("GRP Preprocessor FAILS!!! %s%s%s%s%s", |
e7a6790f | 253 | kppError[(error&1)?1:0], |
254 | kppError[(error&2)?2:0], | |
255 | kppError[(error&4)?3:0], | |
7e1a6c0b | 256 | kppError[(error&8)?4:0], |
257 | kppError[(error&16)?5:0] | |
e7a6790f | 258 | )); |
259 | return error; | |
260 | } | |
17984b61 | 261 | } |
262 | ||
17984b61 | 263 | //_______________________________________________________________ |
e7a6790f | 264 | TMap *AliGRPPreprocessor::ProcessDaqLB() |
265 | { | |
266 | //Getting the DAQ lb information | |
267 | ||
268 | const char* timeStart = GetRunParameter("time_start"); | |
269 | const char* timeEnd = GetRunParameter("time_end"); | |
270 | const char* beamEnergy = GetRunParameter("beamEnergy"); | |
271 | const char* beamType = GetRunParameter("beamType"); | |
125567f8 | 272 | const char* numberOfDetectors = GetRunParameter("numberOfDetectors"); |
e7a6790f | 273 | const char* detectorMask = GetRunParameter("detectorMask"); |
274 | const char* lhcPeriod = GetRunParameter("LHCperiod"); | |
275 | ||
276 | TMap *mapDAQ = new TMap(); | |
277 | ||
17984b61 | 278 | if (timeStart) { |
279 | Log(Form("Start time for run %d: %s",fRun, timeStart)); | |
280 | } else { | |
281 | Log(Form("Start time not put in logbook!")); | |
282 | } | |
e7a6790f | 283 | mapDAQ->Add(new TObjString("fAliceStartTime"), new TObjString(timeStart)); |
17984b61 | 284 | |
285 | if (timeEnd) { | |
286 | Log(Form("End time for run %d: %s",fRun, timeEnd)); | |
287 | } else { | |
288 | Log(Form("End time not put in logbook!")); | |
289 | } | |
e7a6790f | 290 | mapDAQ->Add(new TObjString("fAliceStopTime"), new TObjString(timeEnd)); |
17984b61 | 291 | |
292 | if (beamEnergy) { | |
293 | Log(Form("Beam energy for run %d: %s",fRun, beamEnergy)); | |
294 | } else { | |
295 | Log(Form("Beam energy not put in logbook!")); | |
296 | } | |
e7a6790f | 297 | mapDAQ->Add(new TObjString("fAliceBeamEnergy"), new TObjString(beamEnergy)); |
17984b61 | 298 | |
299 | if (beamType) { | |
300 | Log(Form("Beam type for run %d: %s",fRun, beamType)); | |
301 | } else { | |
302 | Log(Form("Beam type not put in logbook!")); | |
303 | } | |
e7a6790f | 304 | mapDAQ->Add(new TObjString("fAliceBeamType"), new TObjString(beamType)); |
17984b61 | 305 | |
306 | if (numberOfDetectors) { | |
307 | Log(Form("Number of active detectors for run %d: %s",fRun, numberOfDetectors)); | |
308 | } else { | |
309 | Log(Form("Number of active detectors not put in logbook!")); | |
310 | } | |
e7a6790f | 311 | mapDAQ->Add(new TObjString("fNumberOfDetectors"), new TObjString(numberOfDetectors)); |
17984b61 | 312 | |
313 | if (detectorMask) { | |
314 | Log(Form("Detector mask for run %d: %s",fRun, detectorMask)); | |
315 | } else { | |
316 | Log(Form("Detector mask not put in logbook!")); | |
317 | } | |
e7a6790f | 318 | mapDAQ->Add(new TObjString("fDetectorMask"), new TObjString(detectorMask)); |
17984b61 | 319 | |
320 | if (lhcPeriod) { | |
321 | Log(Form("LHC period (DAQ) for run %d: %s",fRun, lhcPeriod)); | |
322 | } else { | |
323 | Log(Form("LHCperiod not put in logbook!")); | |
324 | } | |
e7a6790f | 325 | mapDAQ->Add(new TObjString("fLHCPeriod"), new TObjString(lhcPeriod)); |
5a5052e5 | 326 | |
e7a6790f | 327 | mapDAQ->Add(new TObjString("fRunType"), new TObjString(GetRunType())); |
328 | Log( Form("Retrived %d parameters from logbook", mapDAQ->GetEntries() ) ); | |
17984b61 | 329 | |
e7a6790f | 330 | return mapDAQ; |
17984b61 | 331 | } |
332 | ||
333 | //_______________________________________________________________ | |
e7a6790f | 334 | UInt_t AliGRPPreprocessor::ProcessDaqFxs() |
335 | { | |
836d8b4f | 336 | //======DAQ FXS======// |
29cc8704 | 337 | |
c865efca | 338 | TList* list = GetFileSources(kDAQ); |
339 | if (!list) { | |
ff97356e | 340 | Log("No raw data tag list: connection problems with DAQ FXS logbook!"); |
341 | return 1; | |
342 | } | |
e7a6790f | 343 | |
344 | if (list->GetEntries() == 0) { | |
345 | Log("no raw data tags in this run: nothing to merge!"); | |
346 | delete list; list=0; | |
347 | return 0; | |
c865efca | 348 | } |
ff97356e | 349 | |
350 | TChain *fRawTagChain = new TChain("T"); | |
351 | Int_t nFiles=0; | |
4a33bdd9 | 352 | TIterator* iter = list->MakeIterator(); |
353 | TObject* obj = 0; | |
958ecabf | 354 | while ((obj = iter->Next())) { |
355 | TObjString* objStr = dynamic_cast<TObjString*> (obj); | |
356 | if (objStr) { | |
357 | Log(Form("Found source %s", objStr->String().Data())); | |
358 | TList* list2 = GetFileIDs(kDAQ, objStr->String()); | |
836d8b4f | 359 | if (!list2) { |
e7a6790f | 360 | Log("No list with ids from DAQ was found: connection problems with DAQ FXS logbook!"); |
361 | delete fRawTagChain; fRawTagChain=0; | |
362 | return 1; | |
836d8b4f | 363 | } |
364 | Log(Form("Number of ids: %d",list2->GetEntries())); | |
365 | for(Int_t i = 0; i < list2->GetEntries(); i++) { | |
e7a6790f | 366 | TObjString *idStr = (TObjString *)list2->At(i); |
367 | TString fileName = GetFile(kDAQ,idStr->String().Data(),objStr->String().Data()); | |
368 | if (fileName.Length() > 0) { | |
369 | Log(Form("Adding file in the chain: %s",fileName.Data())); | |
370 | fRawTagChain->Add(fileName.Data()); | |
371 | nFiles++; | |
372 | } else { | |
373 | Log(Form("Could not retrieve file with id %s from source %s: " | |
374 | "connection problems with DAQ FXS!", | |
375 | idStr->String().Data(), objStr->String().Data())); | |
376 | delete list; list=0; | |
377 | delete list2; list2=0; | |
378 | delete fRawTagChain; fRawTagChain=0; | |
379 | return 2; | |
380 | } | |
836d8b4f | 381 | } |
958ecabf | 382 | delete list2; |
383 | } | |
384 | } | |
ff97356e | 385 | |
29cc8704 | 386 | TString fRawDataFileName = "GRP_Merged.tag.root"; |
ff97356e | 387 | Log(Form("Merging %d raw data tags into file: %s", nFiles, fRawDataFileName.Data())); |
e7a6790f | 388 | if( fRawTagChain->Merge(fRawDataFileName) < 1 ) { |
389 | Log("Error merging raw data files!!!"); | |
390 | return 3; | |
391 | } | |
29cc8704 | 392 | |
b49acef7 | 393 | TString outputfile = Form("Run%d.Merged.RAW.tag.root", fRun); |
bba57327 | 394 | Bool_t result = StoreRunMetadataFile(fRawDataFileName.Data(),outputfile.Data()); |
ff97356e | 395 | |
e7a6790f | 396 | if (!result) { |
397 | Log("Problem storing raw data tags in local file!!!"); | |
8b5f35a9 | 398 | } else { |
e7a6790f | 399 | Log("Raw data tags merged successfully!!"); |
ff97356e | 400 | } |
401 | ||
402 | delete iter; | |
403 | delete list; | |
404 | delete fRawTagChain; fRawTagChain=0; | |
e7a6790f | 405 | |
406 | if (result == kFALSE) { | |
407 | return 4; | |
8b5f35a9 | 408 | } |
e7a6790f | 409 | |
073502c9 | 410 | return 0; |
e7a6790f | 411 | |
17984b61 | 412 | } |
413 | ||
48b1b444 | 414 | //_______________________________________________________________ |
e7a6790f | 415 | UInt_t AliGRPPreprocessor::ProcessDcsFxs() |
416 | { | |
48b1b444 | 417 | //======DCS FXS======// |
418 | // Get the CTP run configuration | |
419 | // and scalers from DCS FXS | |
420 | ||
7e1a6c0b | 421 | /* |
48b1b444 | 422 | { |
7e1a6c0b | 423 | |
48b1b444 | 424 | // Get the CTP run configuration |
425 | TList* list = GetFileSources(kDCS,"CTP_runconfig"); | |
426 | if (!list) { | |
cbdd8439 | 427 | Log("No CTP runconfig file: connection problems with DCS FXS logbook!"); |
48b1b444 | 428 | return 1; |
429 | } | |
430 | ||
431 | if (list->GetEntries() == 0) { | |
432 | Log("No CTP runconfig file to be processed!"); | |
e7a6790f | 433 | return 1; |
48b1b444 | 434 | } |
435 | else { | |
436 | TIter iter(list); | |
437 | TObjString *source; | |
438 | while ((source = dynamic_cast<TObjString *> (iter.Next()))) { | |
e7a6790f | 439 | TString runcfgfile = GetFile(kDCS, "CTP_runconfig", source->GetName()); |
440 | if (runcfgfile.IsNull()) { | |
441 | Log("No CTP runconfig files has been found: empty source!"); | |
442 | } | |
443 | else { | |
444 | Log(Form("File with Id CTP_runconfig found in source %s! Copied to %s",source->GetName(),runcfgfile.Data())); | |
445 | AliTriggerConfiguration *runcfg = AliTriggerConfiguration::LoadConfiguration(runcfgfile); | |
446 | if (!runcfg) { | |
447 | Log("Bad CTP run configuration file! The corresponding CDB entry will not be filled!"); | |
448 | return 1; | |
449 | } | |
450 | else { | |
451 | AliCDBMetaData metaData; | |
452 | metaData.SetBeamPeriod(0); | |
453 | metaData.SetResponsible("Roman Lietava"); | |
454 | metaData.SetComment("CTP run configuration"); | |
455 | if (!Store("CTP","Config", runcfg, &metaData, 0, 0)) { | |
456 | Log("Unable to store the CTP run configuration object to OCDB!"); | |
457 | } | |
458 | } | |
459 | } | |
48b1b444 | 460 | } |
461 | } | |
462 | delete list; | |
463 | } | |
7e1a6c0b | 464 | */ |
48b1b444 | 465 | { |
466 | // Get the CTP counters information | |
467 | TList* list = GetFileSources(kDCS,"CTP_xcounters"); | |
468 | if (!list) { | |
469 | Log("No CTP counters file: connection problems with DAQ FXS logbook!"); | |
470 | return 1; | |
471 | } | |
472 | ||
473 | if (list->GetEntries() == 0) { | |
474 | Log("No CTP counters file to be processed!"); | |
e7a6790f | 475 | return 1; |
48b1b444 | 476 | } |
477 | else { | |
478 | TIter iter(list); | |
479 | TObjString *source; | |
480 | while ((source = dynamic_cast<TObjString *> (iter.Next()))) { | |
e7a6790f | 481 | TString countersfile = GetFile(kDCS, "CTP_xcounters", source->GetName()); |
482 | if (countersfile.IsNull()) { | |
483 | Log("No CTP counters files has been found: empty source!"); | |
484 | } | |
485 | else { | |
486 | Log(Form("File with Id CTP_xcounters found in source %s! Copied to %s",source->GetName(),countersfile.Data())); | |
487 | AliTriggerRunScalers *scalers = AliTriggerRunScalers::ReadScalers(countersfile); | |
488 | if (!scalers) { | |
489 | Log("Bad CTP counters file! The corresponding CDB entry will not be filled!"); | |
490 | return 1; | |
491 | } | |
492 | else { | |
493 | AliCDBMetaData metaData; | |
494 | metaData.SetBeamPeriod(0); | |
495 | metaData.SetResponsible("Roman Lietava"); | |
496 | metaData.SetComment("CTP scalers"); | |
497 | if (!Store("CTP","Scalers", scalers, &metaData, 0, 0)) { | |
498 | Log("Unable to store the CTP scalers object to OCDB!"); | |
499 | } | |
500 | } | |
501 | } | |
48b1b444 | 502 | } |
503 | } | |
504 | delete list; | |
505 | } | |
506 | ||
507 | return 0; | |
508 | } | |
509 | ||
17984b61 | 510 | //_______________________________________________________________ |
e7a6790f | 511 | Int_t AliGRPPreprocessor::ProcessDcsDPs(TMap* valueMap, TMap* mapDCS) |
512 | { | |
17984b61 | 513 | //Getting the DCS dps |
e97cc90e | 514 | //===========// |
17984b61 | 515 | |
e97cc90e | 516 | //DCS data points |
517 | //===========// | |
e7a6790f | 518 | |
519 | Int_t entries = 0; | |
520 | ||
17984b61 | 521 | AliInfo(Form("==========LHCState===========")); |
522 | TObjArray *aliasLHCState = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[0]); | |
e97cc90e | 523 | if(!aliasLHCState) { |
524 | Log(Form("LHCState not found!!!")); | |
e7a6790f | 525 | } else { |
526 | AliGRPDCS *dcs1 = new AliGRPDCS(aliasLHCState,fStartTime,fEndTime); | |
527 | TString sLHCState = dcs1->ProcessDCS(2); | |
528 | if (sLHCState) { | |
529 | for( Int_t i=0; i<20; i+=2 ) { | |
530 | if( sLHCState.CompareTo(fgkLHCState[i]) == 0 ) { | |
531 | sLHCState = fgkLHCState[i+1]; | |
532 | break; | |
533 | } | |
534 | } | |
535 | Log(Form("<LHCState> for run %d: %s",fRun, sLHCState.Data())); | |
536 | } else { | |
537 | Log("LHCState not put in TMap!"); | |
538 | } | |
539 | mapDCS->Add(new TObjString("fLHCState"),new TObjString(sLHCState)); | |
540 | ++entries; | |
8ecdaed6 | 541 | } |
e7a6790f | 542 | |
543 | AliInfo(Form("==========L3Polarity===========")); | |
544 | TObjArray *aliasL3Polarity = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[1]); | |
545 | if(!aliasL3Polarity) { | |
546 | Log(Form("L3Polarity not found!!!")); | |
e97cc90e | 547 | } else { |
e7a6790f | 548 | AliGRPDCS *dcs6 = new AliGRPDCS(aliasL3Polarity,fStartTime,fEndTime); |
549 | TString sL3Polarity = dcs6->ProcessDCS(1); | |
550 | if (sL3Polarity) { | |
551 | Log(Form("<L3Polarity> for run %d: %s",fRun, sL3Polarity.Data())); | |
552 | } else { | |
553 | Log("L3Polarity not put in TMap!"); | |
554 | } | |
555 | mapDCS->Add(new TObjString("fL3Polarity"),new TObjString(sL3Polarity)); | |
556 | ++entries; | |
557 | } | |
558 | ||
559 | AliInfo(Form("==========DipolePolarity===========")); | |
560 | TObjArray *aliasDipolePolarity = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[2]); | |
561 | if(!aliasDipolePolarity) { | |
562 | Log(Form("DipolePolarity not found!!!")); | |
3dedb44a | 563 | } else { |
e7a6790f | 564 | AliGRPDCS *dcs8 = new AliGRPDCS(aliasDipolePolarity,fStartTime,fEndTime); |
565 | TString sDipolePolarity = dcs8->ProcessDCS(1); | |
566 | if (sDipolePolarity) { | |
567 | Log(Form("<DipolePolarity> for run %d: %s",fRun, sDipolePolarity.Data())); | |
568 | } else { | |
569 | Log("DipolePolarity not put in TMap!"); | |
570 | } | |
571 | mapDCS->Add(new TObjString("fDipolePolarity"),new TObjString(sDipolePolarity)); | |
572 | ++entries; | |
3dedb44a | 573 | } |
125567f8 | 574 | |
17984b61 | 575 | AliInfo(Form("==========LHCLuminosity===========")); |
e7a6790f | 576 | TObjArray *aliasLHCLuminosity = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[3]); |
e97cc90e | 577 | if(!aliasLHCLuminosity) { |
578 | Log(Form("LHCLuminosity not found!!!")); | |
e97cc90e | 579 | } else { |
e7a6790f | 580 | AliGRPDCS *dcs3 = new AliGRPDCS(aliasLHCLuminosity,fStartTime,fEndTime); |
581 | TString sMeanLHCLuminosity = dcs3->ProcessDCS(5); | |
582 | if (sMeanLHCLuminosity) { | |
583 | Log(Form("<LHCLuminosity> for run %d: %s",fRun, sMeanLHCLuminosity.Data())); | |
584 | } else { | |
585 | Log("LHCLuminosity not put in TMap!"); | |
586 | } | |
587 | mapDCS->Add(new TObjString("fLHCLuminosity"), new TObjString(sMeanLHCLuminosity)); | |
588 | ++entries; | |
e97cc90e | 589 | } |
590 | ||
17984b61 | 591 | AliInfo(Form("==========BeamIntensity===========")); |
e7a6790f | 592 | TObjArray *aliasBeamIntensity = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[4]); |
e97cc90e | 593 | if(!aliasBeamIntensity) { |
594 | Log(Form("BeamIntensity not found!!!")); | |
e97cc90e | 595 | } else { |
e7a6790f | 596 | AliGRPDCS *dcs4 = new AliGRPDCS(aliasBeamIntensity,fStartTime,fEndTime); |
597 | TString sMeanBeamIntensity = dcs4->ProcessDCS(5); | |
598 | if (sMeanBeamIntensity) { | |
599 | Log(Form("<BeamIntensity> for run %d: %s",fRun, sMeanBeamIntensity.Data())); | |
600 | } else { | |
601 | Log("BeamIntensity not put in TMap!"); | |
602 | } | |
603 | mapDCS->Add(new TObjString("fBeamIntensity"),new TObjString(sMeanBeamIntensity)); | |
604 | ++entries; | |
e97cc90e | 605 | } |
606 | ||
17984b61 | 607 | AliInfo(Form("==========L3Current===========")); |
e7a6790f | 608 | TObjArray *aliasL3Current = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[5]); |
e97cc90e | 609 | if(!aliasL3Current) { |
610 | Log(Form("L3Current not found!!!")); | |
e97cc90e | 611 | } else { |
e7a6790f | 612 | AliGRPDCS *dcs5 = new AliGRPDCS(aliasL3Current,fStartTime,fEndTime); |
613 | TString sMeanL3Current = dcs5->ProcessDCS(5); | |
614 | if (sMeanL3Current) { | |
615 | Log(Form("<L3Current> for run %d: %s",fRun, sMeanL3Current.Data())); | |
616 | } else { | |
617 | Log("L3Current not put in TMap!"); | |
618 | } | |
619 | mapDCS->Add(new TObjString("fL3Current"),new TObjString(sMeanL3Current)); | |
620 | ++entries; | |
e97cc90e | 621 | } |
622 | ||
e97cc90e | 623 | |
17984b61 | 624 | AliInfo(Form("==========DipoleCurrent===========")); |
625 | TObjArray *aliasDipoleCurrent = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[6]); | |
e97cc90e | 626 | if(!aliasDipoleCurrent) { |
627 | Log(Form("DipoleCurrent not found!!!")); | |
e7a6790f | 628 | } else { |
629 | AliGRPDCS *dcs7 = new AliGRPDCS(aliasDipoleCurrent,fStartTime,fEndTime); | |
630 | TString sMeanDipoleCurrent = dcs7->ProcessDCS(5); | |
631 | if (sMeanDipoleCurrent) { | |
632 | Log(Form("<DipoleCurrent> for run %d: %s",fRun, sMeanDipoleCurrent.Data())); | |
633 | } else { | |
634 | Log("DipoleCurrent not put in TMap!"); | |
635 | } | |
636 | mapDCS->Add(new TObjString("fDipoleCurrent"),new TObjString(sMeanDipoleCurrent)); | |
637 | ++entries; | |
e97cc90e | 638 | } |
639 | ||
17984b61 | 640 | AliInfo(Form("==========CavernTemperature===========")); |
e7a6790f | 641 | TObjArray *aliasCavernTemperature = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[7]); |
e97cc90e | 642 | if(!aliasCavernTemperature) { |
643 | Log(Form("CavernTemperature not found!!!")); | |
e7a6790f | 644 | } else { |
645 | AliGRPDCS *dcs9 = new AliGRPDCS(aliasCavernTemperature,fStartTime,fEndTime); | |
646 | TString sMeanCavernTemperature = dcs9->ProcessDCS(5); | |
647 | if (sMeanCavernTemperature) { | |
648 | Log(Form("<CavernTemperature> for run %d: %s",fRun, sMeanCavernTemperature.Data())); | |
649 | } else { | |
650 | Log("CavernTemperature not put in TMap!"); | |
651 | } | |
652 | mapDCS->Add(new TObjString("fCavernTemperature"),new TObjString(sMeanCavernTemperature)); | |
653 | ++entries; | |
e97cc90e | 654 | } |
655 | ||
17984b61 | 656 | AliInfo(Form("==========CavernPressure===========")); |
e7a6790f | 657 | TObjArray *aliasCavernPressure = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[8]); |
e97cc90e | 658 | if(!aliasCavernPressure) { |
e7a6790f | 659 | Log("CavernPressure not found!!!"); |
e97cc90e | 660 | } else { |
e7a6790f | 661 | AliGRPDCS *dcs10 = new AliGRPDCS(aliasCavernPressure,fStartTime,fEndTime); |
662 | TString sMeanCavernPressure = dcs10->ProcessDCS(5); | |
663 | if (sMeanCavernPressure) { | |
664 | Log(Form("<CavernPressure> for run %d: %s",fRun, sMeanCavernPressure.Data())); | |
665 | } else { | |
666 | Log("CavernPressure not put in TMap!"); | |
667 | } | |
668 | mapDCS->Add(new TObjString("fCavernPressure"),new TObjString(sMeanCavernPressure)); | |
669 | ++entries; | |
670 | } | |
671 | ||
672 | ||
673 | // NEEDS TO BE REVISED, CONFIRMED | |
674 | AliInfo(Form("==========GenevaPressureMaps===========")); | |
3ba92a38 | 675 | AliDCSSensorArray *dcsSensorArray = GetPressureMap(valueMap); |
e7a6790f | 676 | if( fPressure->NumFits()==0 ) { |
677 | Log("Problem with the pressure sensor values!!!"); | |
678 | } else { | |
679 | AliDCSSensor* sensorCr5 = dcsSensorArray->GetSensor(fgkDCSDataPoints[9]); | |
680 | if( sensorCr5->GetFit() ) { | |
681 | Log(Form("<GvaCr5Pressure> for run %d: Sensor Fit found",fRun)); | |
682 | mapDCS->Add( new TObjString("fCr5Pressure"), sensorCr5 ); | |
683 | ++entries; | |
684 | } else { | |
685 | Log(Form("ERROR Sensor Fit for %s not found: ", fgkDCSDataPoints[9] )); | |
686 | } | |
687 | ||
688 | AliDCSSensor* sensorMeyrin = dcsSensorArray->GetSensor(fgkDCSDataPoints[10]); | |
689 | if( sensorMeyrin->GetFit() ) { | |
690 | Log(Form("<MeyrinPressure> for run %d: Sensor Fit found",fRun)); | |
691 | mapDCS->Add( new TObjString("fMeyrinPressure"), sensorMeyrin ); | |
692 | ++entries; | |
693 | } else { | |
694 | Log(Form("ERROR Sensor Fit for %s not found: ", fgkDCSDataPoints[10] )); | |
695 | } | |
696 | ||
697 | } | |
e97cc90e | 698 | |
e7a6790f | 699 | return entries; |
17984b61 | 700 | } |
125567f8 | 701 | |
17984b61 | 702 | //_______________________________________________________________ |
3ba92a38 | 703 | AliDCSSensorArray *AliGRPPreprocessor::GetPressureMap(TMap* dcsAliasMap) |
e7a6790f | 704 | { |
17984b61 | 705 | // extract DCS pressure maps. Perform fits to save space |
3dedb44a | 706 | |
17984b61 | 707 | TMap *map = fPressure->ExtractDCS(dcsAliasMap); |
708 | if (map) { | |
709 | fPressure->MakeSplineFit(map); | |
710 | Double_t fitFraction = fPressure->NumFits()/fPressure->NumSensors(); | |
711 | if (fitFraction > kFitFraction ) { | |
e7a6790f | 712 | AliInfo(Form("Pressure values extracted, %d fits performed.", fPressure->NumFits())); |
17984b61 | 713 | } else { |
e7a6790f | 714 | AliInfo("Too few pressure maps fitted!!!"); |
17984b61 | 715 | } |
716 | } else { | |
e7a6790f | 717 | AliInfo("no atmospheric pressure map extracted!!!"); |
17984b61 | 718 | } |
719 | delete map; | |
720 | ||
721 | return fPressure; | |
722 | } | |
e97cc90e | 723 | |
17984b61 | 724 | //_______________________________________________________________ |
725 | /*UInt_t AliGRPPreprocessor::MapPressure(TMap* dcsAliasMap) { | |
726 | // extract DCS pressure maps. Perform fits to save space | |
3dedb44a | 727 | |
17984b61 | 728 | UInt_t result=0; |
729 | TMap *map = fPressure->ExtractDCS(dcsAliasMap); | |
730 | if (map) { | |
731 | fPressure->MakeSplineFit(map); | |
732 | Double_t fitFraction = fPressure->NumFits()/fPressure->NumSensors(); | |
733 | if (fitFraction > kFitFraction ) { | |
734 | AliInfo(Form("Pressure values extracted, fits performed.\n")); | |
735 | } else { | |
736 | Log ("Too few pressure maps fitted. \n"); | |
737 | result = 9; | |
738 | } | |
739 | } else { | |
740 | Log("AliTPCPreprocsessor: no atmospheric pressure map extracted. \n"); | |
741 | result=9; | |
742 | } | |
743 | delete map; | |
744 | // Now store the final CDB file | |
3dedb44a | 745 | |
17984b61 | 746 | if ( result == 0 ) { |
747 | AliCDBMetaData metaData; | |
748 | metaData.SetBeamPeriod(0); | |
749 | metaData.SetResponsible("Panos Christakoglou"); | |
750 | metaData.SetComment("Preprocessor AliGRP data base pressure entries."); | |
751 | ||
752 | Bool_t storeOK = Store("Calib", "Pressure", fPressure, &metaData, 0, 0); | |
753 | if ( !storeOK ) result=1; | |
754 | } | |
3dedb44a | 755 | |
17984b61 | 756 | return result; |
757 | }*/ | |
1e27bb6b | 758 | |
759 | ||
760 | //_______________________________________________________________ | |
3dfcd47d | 761 | 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) |
1e27bb6b | 762 | { |
e7a6790f | 763 | // |
764 | // Retrieves logbook and trigger information from the online logbook | |
765 | // This information is needed for prompt reconstruction | |
766 | // | |
767 | // Parameters are: | |
768 | // Run number | |
769 | // DAQ params: dbHost, dbPort, dbName, user, password, logbookTable, triggerTable | |
770 | // cdbRoot | |
771 | // | |
772 | // returns: | |
773 | // positive on success: the return code is the run number of last run processed of the same run type already processed by the SHUTTLE | |
774 | // 0 on success and no run was found | |
775 | // negative on error | |
776 | // | |
777 | // This function is NOT called during the preprocessor run in the Shuttle! | |
778 | // | |
779 | ||
780 | // defaults | |
781 | if (dbPort == 0) | |
782 | dbPort = 3306; | |
783 | ||
784 | // CDB connection | |
785 | AliCDBManager* cdb = AliCDBManager::Instance(); | |
786 | cdb->SetDefaultStorage(cdbRoot); | |
787 | ||
788 | // SQL connection | |
789 | TSQLServer* server = TSQLServer::Connect(Form("mysql://%s:%d/%s", dbHost, dbPort, dbName), user, password); | |
790 | ||
791 | if (!server) | |
792 | { | |
793 | Printf("ERROR: Could not connect to DAQ LB"); | |
794 | return -1; | |
795 | } | |
796 | ||
797 | // main logbook | |
798 | TString sqlQuery; | |
799 | sqlQuery.Form("SELECT DAQ_time_start, run_type, detectorMask FROM logbook WHERE run = %d", run); | |
800 | TSQLResult* result = server->Query(sqlQuery); | |
801 | if (!result) | |
802 | { | |
803 | Printf("ERROR: Can't execute query <%s>!", sqlQuery.Data()); | |
804 | return -2; | |
805 | } | |
806 | ||
807 | if (result->GetRowCount() == 0) | |
808 | { | |
809 | Printf("ERROR: Run %d not found", run); | |
810 | delete result; | |
811 | return -3; | |
812 | } | |
813 | ||
814 | TSQLRow* row = result->Next(); | |
815 | if (!row) | |
816 | { | |
817 | Printf("ERROR: Could not receive data from run %d", run); | |
818 | delete result; | |
819 | return -4; | |
820 | } | |
821 | ||
822 | TString runType(row->GetField(1)); | |
823 | ||
824 | TMap grpData; | |
825 | grpData.Add(new TObjString("DAQ_time_start"), new TObjString(row->GetField(0))); | |
826 | grpData.Add(new TObjString("run_type"), new TObjString(runType)); | |
827 | grpData.Add(new TObjString("detectorMask"), new TObjString(row->GetField(2))); | |
828 | ||
829 | delete row; | |
830 | row = 0; | |
831 | ||
832 | delete result; | |
833 | result = 0; | |
834 | ||
835 | Printf("Storing GRP/GRP/Data object with the following content"); | |
836 | grpData.Print(); | |
837 | ||
838 | AliCDBMetaData metadata; | |
839 | metadata.SetResponsible("Jan Fiete Grosse-Oetringhaus"); | |
840 | metadata.SetComment("GRP Output parameters received during online running"); | |
841 | ||
842 | AliCDBId id("GRP/GRP/Data", run, run); | |
843 | Bool_t success = cdb->Put(&grpData, id, &metadata); | |
844 | ||
845 | grpData.DeleteAll(); | |
846 | ||
847 | if (!success) | |
848 | { | |
849 | Printf("ERROR: Could not store GRP/GRP/Data into OCDB"); | |
850 | return -5; | |
851 | } | |
852 | ||
853 | // Receive trigger information | |
854 | sqlQuery.Form("SELECT configFile FROM logbook_trigger_config WHERE run = %d", run); | |
855 | result = server->Query(sqlQuery); | |
856 | if (!result) | |
857 | { | |
858 | Printf("ERROR: Can't execute query <%s>!", sqlQuery.Data()); | |
859 | return -11; | |
860 | } | |
861 | ||
862 | if (result->GetRowCount() == 0) | |
863 | { | |
864 | Printf("ERROR: Run %d not found in logbook_trigger_config", run); | |
865 | delete result; | |
866 | return -12; | |
867 | } | |
868 | ||
869 | row = result->Next(); | |
870 | if (!row) | |
871 | { | |
872 | Printf("ERROR: Could not receive logbook_trigger_config data from run %d", run); | |
873 | delete result; | |
874 | return -13; | |
875 | } | |
876 | ||
877 | TString triggerConfig(row->GetField(0)); | |
878 | ||
879 | delete row; | |
880 | row = 0; | |
881 | ||
882 | delete result; | |
883 | result = 0; | |
884 | ||
885 | Printf("Found trigger configuration: %s", triggerConfig.Data()); | |
886 | ||
887 | AliTriggerConfiguration *runcfg = AliTriggerConfiguration::LoadConfigurationFromString(triggerConfig); | |
888 | if (!runcfg) | |
889 | { | |
890 | Printf("ERROR: Could not create CTP configuration object"); | |
891 | return -14; | |
892 | } | |
893 | ||
894 | metadata.SetComment("CTP run configuration received during online running"); | |
895 | ||
896 | AliCDBId id2("GRP/CTP/Config", run, run); | |
897 | success = cdb->Put(runcfg, id2, &metadata); | |
898 | ||
899 | delete runcfg; | |
900 | runcfg = 0; | |
901 | ||
902 | if (!success) | |
903 | { | |
904 | Printf("ERROR: Could not store GRP/CTP/Config into OCDB"); | |
905 | return -15; | |
906 | } | |
907 | ||
908 | // get last run with same run type that was already processed by the SHUTTLE | |
909 | ||
910 | 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()); | |
911 | result = server->Query(sqlQuery); | |
912 | if (!result) | |
913 | { | |
914 | Printf("ERROR: Can't execute query <%s>!", sqlQuery.Data()); | |
915 | return -21; | |
916 | } | |
917 | ||
918 | if (result->GetRowCount() == 0) | |
919 | { | |
920 | Printf("ERROR: No result with query <%s>", sqlQuery.Data()); | |
921 | delete result; | |
922 | return -22; | |
923 | } | |
924 | ||
925 | row = result->Next(); | |
926 | if (!row) | |
927 | { | |
928 | Printf("ERROR: Could not receive data for query <%s>", sqlQuery.Data()); | |
929 | delete result; | |
930 | return -23; | |
931 | } | |
932 | ||
933 | TString lastRunStr(row->GetField(0)); | |
934 | Int_t lastRun = lastRunStr.Atoi(); | |
935 | ||
936 | Printf("Last run with same run type %s is %d", runType.Data(), lastRun); | |
937 | ||
938 | delete row; | |
939 | row = 0; | |
940 | ||
941 | delete result; | |
942 | result = 0; | |
943 | ||
944 | server->Close(); | |
945 | delete server; | |
946 | server = 0; | |
947 | ||
948 | return lastRun; | |
1e27bb6b | 949 | } |