]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - STEER/AliGRPPreprocessor.cxx
Removal of printf and cout messages (Per Thomas)
[u/mrichter/AliRoot.git] / STEER / AliGRPPreprocessor.cxx
... / ...
CommitLineData
1/**************************************************************************
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
16/* $Id$ */
17
18//-------------------------------------------------------------------------
19// Class AliGRPPreprocessor
20// Global Run Parameters (GRP) preprocessor
21// Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch
22//-------------------------------------------------------------------------
23
24#include <TChain.h>
25#include <TList.h>
26#include <TMap.h>
27#include <TObjString.h>
28#include <TTimeStamp.h>
29#include <TSystem.h>
30#include <TFile.h>
31
32#include "AliGRPPreprocessor.h"
33#include "AliGRPDCS.h"
34#include "AliDCSSensorArray.h"
35
36#include "AliTriggerConfiguration.h"
37#include "AliTriggerRunScalers.h"
38
39#include "AliCDBMetaData.h"
40#include "AliLog.h"
41
42class AliDCSValue;
43class AliShuttleInterface;
44
45#include <TH1.h>
46
47// needed for ReceivePromptRecoParameters
48#include <TSQLServer.h>
49#include <TSQLResult.h>
50#include <TSQLRow.h>
51#include <AliCDBManager.h>
52#include <AliCDBMetaData.h>
53#include <AliCDBId.h>
54#include <AliTriggerConfiguration.h>
55
56const Double_t kFitFraction = 0.7; // Fraction of DCS sensor fits required
57
58ClassImp(AliGRPPreprocessor)
59
60//_______________________________________________________________
61 const char* AliGRPPreprocessor::fgkDCSDataPoints[12] = {"LHCState","LHCPeriod","LHCLuminosity","BeamIntensity","L3Current","L3Polarity","DipoleCurrent","DipolePolarity","CavernTemperature","CavernAtmosPressure","gva_cr5AtmosphericPressure","gva_meyrinAtmosphericPressure"};
62
63//_______________________________________________________________
64AliGRPPreprocessor::AliGRPPreprocessor(AliShuttleInterface* shuttle):
65 AliPreprocessor("GRP",shuttle), fPressure(0) {
66 // constructor - shuttle must be instantiated!
67
68 AddRunType("PHYSICS");
69}
70
71//_______________________________________________________________
72AliGRPPreprocessor::~AliGRPPreprocessor() {
73 //destructor
74 delete fPressure;
75}
76
77//_______________________________________________________________
78void AliGRPPreprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime) {
79 // Initialize preprocessor
80
81 AliPreprocessor::Initialize(run, startTime, endTime);
82
83 AliInfo("Initialization of the GRP preprocessor.");
84
85 TClonesArray * array = new TClonesArray("AliDCSSensor",2);
86 for(Int_t j = 0; j < 2; j++) {
87 AliDCSSensor * sens = new ((*array)[j])AliDCSSensor;
88 sens->SetStringID(fgkDCSDataPoints[j+10]);
89 }
90 AliInfo(Form("Pressure Entries: %d",array->GetEntries()));
91
92 fPressure = new AliDCSSensorArray(fStartTime, fEndTime, array);
93}
94
95//_______________________________________________________________
96UInt_t AliGRPPreprocessor::Process(TMap* valueMap) {
97 // process data retrieved by the Shuttle
98
99 //=================//
100 // DAQ logbook //
101 //=================//
102
103 TList *daqlblist = ProcessDaqLB();
104 if(!daqlblist) {
105 Log(Form("Problem with the DAQ logbook parameters!!!"));
106 return 1;
107 }
108
109 //=================//
110 // DAQ FXS //
111 //=================//
112 UInt_t iDaqFxs = ProcessDaqFxs();
113 if(iDaqFxs == 0) {
114 Log(Form("ProcessDaqFxs successful!"));
115 } else {
116 Log(Form("Could not store run raw tag file!"));
117 return 1;
118 }
119
120 //=================//
121 // DCS FXS //
122 //=================//
123 UInt_t iDcsFxs = ProcessDcsFxs();
124 if(iDcsFxs == 0) {
125 Log(Form("ProcessDcsFxs successful!"));
126 } else {
127 Log(Form("Could not store CTP run configuration and scalers!"));
128 return 1;
129 }
130
131 //=================//
132 // DCS data points //
133 //=================//
134 TList *dcsdplist = ProcessDcsDPs(valueMap);
135 if(!dcsdplist) {
136 Log(Form("Problem with the DCS data points!!!"));
137 return 1;
138 }
139 if(dcsdplist->GetEntries() != 10) {
140 Log(Form("Problem with the DCS data points!!!"));
141 // return 1; // TODO:COMMENTED FOR TESTING PURPOSES!
142 }
143 //NEEDS TO BE REVISED - BREAKS!!!
144// AliDCSSensorArray *dcsSensorArray = GetPressureMap(valueMap,fPressure);
145// if(!dcsSensorArray) {
146// Log(Form("Problem with the pressure sensor values!!!"));
147// return 0;
148// }
149
150 daqlblist->AddAll(dcsdplist);
151 daqlblist->SetOwner(1);
152 AliInfo(Form("Final list entries: %d",daqlblist->GetEntries()));
153
154 AliCDBMetaData md;
155 md.SetResponsible("Panos Christakoglou");
156 md.SetComment("Output parameters from the GRP preprocessor.");
157
158 Bool_t result = Store("GRP", "Data", daqlblist, &md);
159
160 delete daqlblist;
161
162 if (result)
163 return 0;
164 else
165 return 1;
166}
167
168//_______________________________________________________________
169TList *AliGRPPreprocessor::ProcessDaqLB() {
170 //Getting the DAQ lb informnation
171 const char* timeStart = GetRunParameter("time_start");
172 const char* timeEnd = GetRunParameter("time_end");
173 const char* beamEnergy = GetRunParameter("beamEnergy");
174 const char* beamType = GetRunParameter("beamType");
175 const char* numberOfDetectors = GetRunParameter("numberOfDetectors");
176 const char* detectorMask = GetRunParameter("detectorMask");
177 const char* lhcPeriod = GetRunParameter("LHCperiod");
178
179 if (timeStart) {
180 Log(Form("Start time for run %d: %s",fRun, timeStart));
181 } else {
182 Log(Form("Start time not put in logbook!"));
183 }
184 TMap *mapDAQ1 = new TMap();
185 mapDAQ1->Add(new TObjString("fAliceStartTime"),new TObjString(timeStart));
186
187 if (timeEnd) {
188 Log(Form("End time for run %d: %s",fRun, timeEnd));
189 } else {
190 Log(Form("End time not put in logbook!"));
191 }
192 TMap *mapDAQ2 = new TMap();
193 mapDAQ2->Add(new TObjString("fAliceStopTime"),new TObjString(timeEnd));
194
195 if (beamEnergy) {
196 Log(Form("Beam energy for run %d: %s",fRun, beamEnergy));
197 } else {
198 Log(Form("Beam energy not put in logbook!"));
199 }
200 TMap *mapDAQ3 = new TMap();
201 mapDAQ3->Add(new TObjString("fAliceBeamEnergy"),new TObjString(beamEnergy));
202
203 if (beamType) {
204 Log(Form("Beam type for run %d: %s",fRun, beamType));
205 } else {
206 Log(Form("Beam type not put in logbook!"));
207 }
208 TMap *mapDAQ4 = new TMap();
209 mapDAQ4->Add(new TObjString("fAliceBeamType"),new TObjString(beamType));
210
211 if (numberOfDetectors) {
212 Log(Form("Number of active detectors for run %d: %s",fRun, numberOfDetectors));
213 } else {
214 Log(Form("Number of active detectors not put in logbook!"));
215 }
216 TMap *mapDAQ5 = new TMap();
217 mapDAQ5->Add(new TObjString("fNumberOfDetectors"),new TObjString(numberOfDetectors));
218
219 if (detectorMask) {
220 Log(Form("Detector mask for run %d: %s",fRun, detectorMask));
221 } else {
222 Log(Form("Detector mask not put in logbook!"));
223 }
224 TMap *mapDAQ6 = new TMap();
225 mapDAQ6->Add(new TObjString("fDetectorMask"),new TObjString(detectorMask));
226
227 if (lhcPeriod) {
228 Log(Form("LHC period (DAQ) for run %d: %s",fRun, lhcPeriod));
229 } else {
230 Log(Form("LHCperiod not put in logbook!"));
231 }
232 TMap *mapDAQ7 = new TMap();
233 mapDAQ7->Add(new TObjString("fLHCPeriod"),new TObjString(lhcPeriod));
234
235 TList *list = new TList();
236 list->Add(mapDAQ1); list->Add(mapDAQ2);
237 list->Add(mapDAQ3); list->Add(mapDAQ4);
238 list->Add(mapDAQ5); list->Add(mapDAQ6);
239 list->Add(mapDAQ7);
240
241 TMap* mapDAQ8 = new TMap;
242 mapDAQ8->Add(new TObjString("fRunType"), new TObjString(GetRunType()));
243 list->Add(mapDAQ8);
244
245 return list;
246}
247
248//_______________________________________________________________
249UInt_t AliGRPPreprocessor::ProcessDaqFxs() {
250 //======DAQ FXS======//
251
252 TList* list = GetFileSources(kDAQ);
253 if (!list) {
254 Log("No raw data tag list: connection problems with DAQ FXS logbook!");
255 return 1;
256 }
257
258 if (list->GetEntries() == 0)
259 {
260 Log("no raw data tags in this run: nothing to merge!");
261 delete list; list=0;
262 return 0;
263 }
264
265 TChain *fRawTagChain = new TChain("T");
266 Int_t nFiles=0;
267 TIterator* iter = list->MakeIterator();
268 TObject* obj = 0;
269 while ((obj = iter->Next())) {
270 TObjString* objStr = dynamic_cast<TObjString*> (obj);
271 if (objStr) {
272 Log(Form("Found source %s", objStr->String().Data()));
273 TList* list2 = GetFileIDs(kDAQ, objStr->String());
274 if (!list2) {
275 Log("No list with ids from DAQ was found: connection problems with DAQ FXS logbook!");
276 delete fRawTagChain; fRawTagChain=0;
277 return 1;
278 }
279 Log(Form("Number of ids: %d",list2->GetEntries()));
280 for(Int_t i = 0; i < list2->GetEntries(); i++) {
281 TObjString *idStr = (TObjString *)list2->At(i);
282 TString fileName = GetFile(kDAQ,idStr->String().Data(),objStr->String().Data());
283 if (fileName.Length() > 0)
284 {
285 Log(Form("Adding file in the chain: %s",fileName.Data()));
286 fRawTagChain->Add(fileName.Data());
287 nFiles++;
288 } else {
289 Log(Form("Could not retrieve file with id %s from source %s: "
290 "connection problems with DAQ FXS!",
291 idStr->String().Data(),objStr->String().Data()));
292 delete list; list=0;
293 delete list2; list2=0;
294 delete fRawTagChain; fRawTagChain=0;
295 return 2;
296 }
297 }
298 delete list2;
299 }
300 }
301
302 TString fRawDataFileName = "GRP_Merged.tag.root";
303 Log(Form("Merging %d raw data tags into file: %s", nFiles, fRawDataFileName.Data()));
304 fRawTagChain->Merge(fRawDataFileName);
305
306 TString outputfile = Form("Run%d.Merged.RAW.tag.root", fRun);
307 Bool_t result = StoreRunMetadataFile(fRawDataFileName.Data(),outputfile.Data());
308
309 if (!result)
310 {
311 Log("Problem storing raw data tags in local file!!");
312 } else {
313 Log("Raw data tags merged successfully!!");
314 }
315
316 delete iter;
317 delete list;
318 delete fRawTagChain; fRawTagChain=0;
319
320 if (result == kFALSE)
321 {
322 return 3;
323 }
324
325 return 0;
326
327}
328
329//_______________________________________________________________
330UInt_t AliGRPPreprocessor::ProcessDcsFxs() {
331 //======DCS FXS======//
332 // Get the CTP run configuration
333 // and scalers from DCS FXS
334
335 {
336 // Get the CTP run configuration
337 TList* list = GetFileSources(kDCS,"CTP_runconfig");
338 if (!list) {
339 Log("No CTP runconfig file: connection problems with DCS FXS logbook!");
340 return 1;
341 }
342
343 if (list->GetEntries() == 0) {
344 Log("No CTP runconfig file to be processed!");
345 }
346 else {
347 TIter iter(list);
348 TObjString *source;
349 while ((source = dynamic_cast<TObjString *> (iter.Next()))) {
350 TString runcfgfile = GetFile(kDCS, "CTP_runconfig", source->GetName());
351 if (runcfgfile.IsNull()) {
352 Log("No CTP runconfig files has been found: empty source!");
353 }
354 else {
355 Log(Form("File with Id CTP_runconfig found in source %s! Copied to %s",source->GetName(),runcfgfile.Data()));
356 AliTriggerConfiguration *runcfg = AliTriggerConfiguration::LoadConfiguration(runcfgfile);
357 if (!runcfg) {
358 Log("Bad CTP run configuration file! The corresponding CDB entry will not be filled!");
359 }
360 else {
361 AliCDBMetaData metaData;
362 metaData.SetBeamPeriod(0);
363 metaData.SetResponsible("Roman Lietava");
364 metaData.SetComment("CTP run configuration");
365 if (!Store("CTP","Config", runcfg, &metaData, 0, 0)) {
366 Log("Unable to store the CTP run configuration object to OCDB!");
367 }
368 }
369 }
370 }
371 }
372 delete list;
373 }
374
375 {
376 // Get the CTP counters information
377 TList* list = GetFileSources(kDCS,"CTP_xcounters");
378 if (!list) {
379 Log("No CTP counters file: connection problems with DAQ FXS logbook!");
380 return 1;
381 }
382
383 if (list->GetEntries() == 0) {
384 Log("No CTP counters file to be processed!");
385 }
386 else {
387 TIter iter(list);
388 TObjString *source;
389 while ((source = dynamic_cast<TObjString *> (iter.Next()))) {
390 TString countersfile = GetFile(kDCS, "CTP_xcounters", source->GetName());
391 if (countersfile.IsNull()) {
392 Log("No CTP counters files has been found: empty source!");
393 }
394 else {
395 Log(Form("File with Id CTP_xcounters found in source %s! Copied to %s",source->GetName(),countersfile.Data()));
396 AliTriggerRunScalers *scalers = AliTriggerRunScalers::ReadScalers(countersfile);
397 if (!scalers) {
398 Log("Bad CTP counters file! The corresponding CDB entry will not be filled!");
399 }
400 else {
401 AliCDBMetaData metaData;
402 metaData.SetBeamPeriod(0);
403 metaData.SetResponsible("Roman Lietava");
404 metaData.SetComment("CTP scalers");
405 if (!Store("CTP","Scalers", scalers, &metaData, 0, 0)) {
406 Log("Unable to store the CTP scalers object to OCDB!");
407 }
408 }
409 }
410 }
411 }
412 delete list;
413 }
414
415 return 0;
416}
417
418//_______________________________________________________________
419TList *AliGRPPreprocessor::ProcessDcsDPs(TMap* valueMap) {
420 //Getting the DCS dps
421 //===========//
422
423 TList *list = new TList();
424
425 //DCS data points
426 //===========//
427 AliInfo(Form("==========LHCState==========="));
428 TObjArray *aliasLHCState = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[0]);
429 if(!aliasLHCState) {
430 Log(Form("LHCState not found!!!"));
431 return list;
432 }
433 AliGRPDCS *dcs1 = new AliGRPDCS(aliasLHCState,fStartTime,fEndTime);
434 TString sLHCState = dcs1->ProcessDCS(3);
435 if (sLHCState) {
436 Log(Form("<LHCState> for run %d: %s",fRun, sLHCState.Data()));
437 } else {
438 Log(Form("LHCState not put in TMap!"));
439 }
440 TMap *mapDCS1 = new TMap();
441 mapDCS1->Add(new TObjString("fLHCState"),new TObjString(sLHCState));
442 list->Add(mapDCS1);
443
444 AliInfo(Form("==========LHCPeriod==========="));
445 TObjArray *aliasLHCPeriod = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[1]);
446 if(!aliasLHCPeriod) {
447 Log(Form("LHCPeriod not found!!!"));
448 return list;
449 }
450 AliGRPDCS *dcs2 = new AliGRPDCS(aliasLHCPeriod,fStartTime,fEndTime);
451 TString sLHCPeriod = dcs2->ProcessDCS(3);
452 if (sLHCPeriod) {
453 Log(Form("<LHCPeriod> for run %d: %s",fRun, sLHCPeriod.Data()));
454 } else {
455 Log(Form("LHCPeriod not put in TMap!"));
456 }
457 TMap *mapDCS2 = new TMap();
458 mapDCS2->Add(new TObjString("fLHCCondition"),new TObjString(sLHCPeriod));
459 list->Add(mapDCS2);
460
461 AliInfo(Form("==========LHCLuminosity==========="));
462 TObjArray *aliasLHCLuminosity = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[2]);
463 if(!aliasLHCLuminosity) {
464 Log(Form("LHCLuminosity not found!!!"));
465 return list;
466 }
467 AliGRPDCS *dcs3 = new AliGRPDCS(aliasLHCLuminosity,fStartTime,fEndTime);
468 TString sMeanLHCLuminosity = dcs3->ProcessDCS(2);
469 if (sMeanLHCLuminosity) {
470 Log(Form("<LHCLuminosity> for run %d: %s",fRun, sMeanLHCLuminosity.Data()));
471 } else {
472 Log(Form("LHCLuminosity not put in TMap!"));
473 }
474 TMap *mapDCS3 = new TMap();
475 mapDCS3->Add(new TObjString("fLHCLuminosity"),new TObjString(sMeanLHCLuminosity));
476 list->Add(mapDCS3);
477
478 AliInfo(Form("==========BeamIntensity==========="));
479 TObjArray *aliasBeamIntensity = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[3]);
480 if(!aliasBeamIntensity) {
481 Log(Form("BeamIntensity not found!!!"));
482 return list;
483 }
484 AliGRPDCS *dcs4 = new AliGRPDCS(aliasBeamIntensity,fStartTime,fEndTime);
485 TString sMeanBeamIntensity = dcs4->ProcessDCS(2);
486 if (sMeanBeamIntensity) {
487 Log(Form("<BeamIntensity> for run %d: %s",fRun, sMeanBeamIntensity.Data()));
488 } else {
489 Log(Form("BeamIntensity not put in TMap!"));
490 }
491 TMap *mapDCS4 = new TMap();
492 mapDCS4->Add(new TObjString("fBeamIntensity"),new TObjString(sMeanBeamIntensity));
493 list->Add(mapDCS4);
494
495 AliInfo(Form("==========L3Current==========="));
496 TObjArray *aliasL3Current = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[4]);
497 if(!aliasL3Current) {
498 Log(Form("L3Current not found!!!"));
499 return list;
500 }
501 AliGRPDCS *dcs5 = new AliGRPDCS(aliasL3Current,fStartTime,fEndTime);
502 TString sMeanL3Current = dcs5->ProcessDCS(2);
503 if (sMeanL3Current) {
504 Log(Form("<L3Current> for run %d: %s",fRun, sMeanL3Current.Data()));
505 } else {
506 Log(Form("L3Current not put in TMap!"));
507 }
508 TMap *mapDCS5 = new TMap();
509 mapDCS5->Add(new TObjString("fL3Current"),new TObjString(sMeanL3Current));
510 list->Add(mapDCS5);
511
512 AliInfo(Form("==========L3Polarity==========="));
513 TObjArray *aliasL3Polarity = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[5]);
514 if(!aliasL3Polarity) {
515 Log(Form("L3Polarity not found!!!"));
516 return list;
517 }
518 AliGRPDCS *dcs6 = new AliGRPDCS(aliasL3Polarity,fStartTime,fEndTime);
519 TString sL3Polarity = dcs6->ProcessDCS(4);
520 if (sL3Polarity) {
521 Log(Form("<L3Polarity> for run %d: %s",fRun, sL3Polarity.Data()));
522 } else {
523 Log(Form("L3Polarity not put in TMap!"));
524 }
525 TMap *mapDCS6 = new TMap();
526 mapDCS6->Add(new TObjString("fL3Polarity"),new TObjString(sL3Polarity));
527 list->Add(mapDCS6);
528
529 AliInfo(Form("==========DipoleCurrent==========="));
530 TObjArray *aliasDipoleCurrent = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[6]);
531 if(!aliasDipoleCurrent) {
532 Log(Form("DipoleCurrent not found!!!"));
533 return list;
534 }
535 AliGRPDCS *dcs7 = new AliGRPDCS(aliasDipoleCurrent,fStartTime,fEndTime);
536 TString sMeanDipoleCurrent = dcs7->ProcessDCS(2);
537 if (sMeanDipoleCurrent) {
538 Log(Form("<DipoleCurrent> for run %d: %s",fRun, sMeanDipoleCurrent.Data()));
539 } else {
540 Log(Form("DipoleCurrent not put in TMap!"));
541 }
542 TMap *mapDCS7 = new TMap();
543 mapDCS7->Add(new TObjString("fDipoleCurrent"),new TObjString(sMeanDipoleCurrent));
544 list->Add(mapDCS7);
545
546 AliInfo(Form("==========DipolePolarity==========="));
547 TObjArray *aliasDipolePolarity = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[7]);
548 if(!aliasDipolePolarity) {
549 Log(Form("DipolePolarity not found!!!"));
550 return list;
551 }
552 AliGRPDCS *dcs8 = new AliGRPDCS(aliasDipolePolarity,fStartTime,fEndTime);
553 TString sDipolePolarity = dcs8->ProcessDCS(4);
554 if (sDipolePolarity) {
555 Log(Form("<DipolePolarity> for run %d: %s",fRun, sDipolePolarity.Data()));
556 } else {
557 Log(Form("DipolePolarity not put in TMap!"));
558 }
559 TMap *mapDCS8 = new TMap();
560 mapDCS8->Add(new TObjString("fDipolePolarity"),new TObjString(sDipolePolarity));
561 list->Add(mapDCS8);
562
563 AliInfo(Form("==========CavernTemperature==========="));
564 TObjArray *aliasCavernTemperature = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[8]);
565 if(!aliasCavernTemperature) {
566 Log(Form("CavernTemperature not found!!!"));
567 return list;
568 }
569 AliGRPDCS *dcs9 = new AliGRPDCS(aliasCavernTemperature,fStartTime,fEndTime);
570 TString sMeanCavernTemperature = dcs9->ProcessDCS(2);
571 if (sMeanCavernTemperature) {
572 Log(Form("<CavernTemperature> for run %d: %s",fRun, sMeanCavernTemperature.Data()));
573 } else {
574 Log(Form("CavernTemperature not put in TMap!"));
575 }
576 TMap *mapDCS9 = new TMap();
577 mapDCS9->Add(new TObjString("fCavernTemperature"),new TObjString(sMeanCavernTemperature));
578 list->Add(mapDCS9);
579
580 AliInfo(Form("==========CavernPressure==========="));
581 TObjArray *aliasCavernPressure = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[9]);
582 if(!aliasCavernPressure) {
583 Log(Form("CavernPressure not found!!!"));
584 return list;
585 }
586 AliGRPDCS *dcs10 = new AliGRPDCS(aliasCavernPressure,fStartTime,fEndTime);
587 TString sMeanCavernPressure = dcs10->ProcessDCS(2);
588 if (sMeanCavernPressure) {
589 Log(Form("<CavernPressure> for run %d: %s",fRun, sMeanCavernPressure.Data()));
590 } else {
591 Log(Form("CavernPressure not put in TMap!"));
592 }
593 TMap *mapDCS10 = new TMap();
594 mapDCS10->Add(new TObjString("fCavernPressure"),new TObjString(sMeanCavernPressure));
595 list->Add(mapDCS10);
596
597 return list;
598}
599
600//_______________________________________________________________
601AliDCSSensorArray *AliGRPPreprocessor::GetPressureMap(TMap* dcsAliasMap, AliDCSSensorArray *fPressure) {
602 // extract DCS pressure maps. Perform fits to save space
603
604 TMap *map = fPressure->ExtractDCS(dcsAliasMap);
605 if (map) {
606 fPressure->MakeSplineFit(map);
607 Double_t fitFraction = fPressure->NumFits()/fPressure->NumSensors();
608 if (fitFraction > kFitFraction ) {
609 AliInfo(Form("Pressure values extracted, fits performed.\n"));
610 } else {
611 AliInfo("Too few pressure maps fitted. \n");
612 }
613 } else {
614 AliInfo("AliGRPDCS: no atmospheric pressure map extracted. \n");
615 }
616 delete map;
617
618 return fPressure;
619}
620
621//_______________________________________________________________
622/*UInt_t AliGRPPreprocessor::MapPressure(TMap* dcsAliasMap) {
623 // extract DCS pressure maps. Perform fits to save space
624
625 UInt_t result=0;
626 TMap *map = fPressure->ExtractDCS(dcsAliasMap);
627 if (map) {
628 fPressure->MakeSplineFit(map);
629 Double_t fitFraction = fPressure->NumFits()/fPressure->NumSensors();
630 if (fitFraction > kFitFraction ) {
631 AliInfo(Form("Pressure values extracted, fits performed.\n"));
632 } else {
633 Log ("Too few pressure maps fitted. \n");
634 result = 9;
635 }
636 } else {
637 Log("AliTPCPreprocsessor: no atmospheric pressure map extracted. \n");
638 result=9;
639 }
640 delete map;
641 // Now store the final CDB file
642
643 if ( result == 0 ) {
644 AliCDBMetaData metaData;
645 metaData.SetBeamPeriod(0);
646 metaData.SetResponsible("Panos Christakoglou");
647 metaData.SetComment("Preprocessor AliGRP data base pressure entries.");
648
649 Bool_t storeOK = Store("Calib", "Pressure", fPressure, &metaData, 0, 0);
650 if ( !storeOK ) result=1;
651 }
652
653 return result;
654 }*/
655
656
657//_______________________________________________________________
658Int_t AliGRPPreprocessor::ReceivePromptRecoParameters(UInt_t run, const char* dbHost, Int_t dbPort, const char* dbName, const char* user, const char* password, const char* logbookTable, const char* triggerTable, const char *cdbRoot)
659{
660 //
661 // Retrieves logbook and trigger information from the online logbook
662 // This information is needed for prompt reconstruction
663 //
664 // Parameters are:
665 // Run number
666 // DAQ params: dbHost, dbPort, dbName, user, password, logbookTable, triggerTable
667 // cdbRoot
668 //
669 // returns 0 on success
670 // negative on error
671 //
672 // This function is NOT called during the preprocessor run in the Shuttle!
673 //
674
675 // CDB connection
676 AliCDBManager* cdb = AliCDBManager::Instance();
677 cdb->SetDefaultStorage(cdbRoot);
678
679 // SQL connection
680 TSQLServer* server = TSQLServer::Connect(Form("mysql://%s:%d/%s", dbHost, dbPort, dbName), user, password);
681
682 if (!server)
683 {
684 Printf("ERROR: Could not connect to DAQ LB");
685 return -1;
686 }
687
688 // main logbook
689 TString sqlQuery;
690 sqlQuery.Form("SELECT time_start, run_type, detectorMask FROM %s WHERE run = %d", logbookTable, run);
691 TSQLResult* result = server->Query(sqlQuery);
692 if (!result)
693 {
694 Printf("ERROR: Can't execute query <%s>!", sqlQuery.Data());
695 return -2;
696 }
697
698 if (result->GetRowCount() == 0)
699 {
700 Printf("ERROR: Run %d not found", run);
701 delete result;
702 return -3;
703 }
704
705 TSQLRow* row = result->Next();
706 if (!row)
707 {
708 Printf("ERROR: Could not receive data from run %d", run);
709 delete result;
710 return -4;
711 }
712
713 TMap grpData;
714 grpData.Add(new TObjString("time_start"), new TObjString(row->GetField(0)));
715 grpData.Add(new TObjString("run_type"), new TObjString(row->GetField(1)));
716 grpData.Add(new TObjString("detectorMask"), new TObjString(row->GetField(2)));
717
718 delete row;
719 row = 0;
720
721 delete result;
722 result = 0;
723
724 Printf("Storing GRP/GRP/Data object with the following content");
725 grpData.Print();
726
727 AliCDBMetaData metadata;
728 metadata.SetResponsible("Jan Fiete Grosse-Oetringhaus");
729 metadata.SetComment("GRP Output parameters received during online running");
730
731 AliCDBId id("GRP/GRP/Data", run, run);
732 Bool_t success = cdb->Put(&grpData, id, &metadata);
733
734 grpData.DeleteAll();
735
736 if (!success)
737 {
738 Printf("ERROR: Could not store GRP/GRP/Data into OCDB");
739 return -5;
740 }
741
742 sqlQuery.Form("SELECT configFile FROM %s WHERE run = %d", triggerTable, run);
743 result = server->Query(sqlQuery);
744 if (!result)
745 {
746 Printf("ERROR: Can't execute query <%s>!", sqlQuery.Data());
747 return -11;
748 }
749
750 if (result->GetRowCount() == 0)
751 {
752 Printf("ERROR: Run %d not found in logbook_trigger_config", run);
753 delete result;
754 return -12;
755 }
756
757 row = result->Next();
758 if (!row)
759 {
760 Printf("ERROR: Could not receive logbook_trigger_config data from run %d", run);
761 delete result;
762 return -13;
763 }
764
765 TString triggerConfig(row->GetField(0));
766
767 delete row;
768 row = 0;
769
770 delete result;
771 result = 0;
772
773 Printf("Found trigger configuration: %s", triggerConfig.Data());
774
775 // add a function that takes the configuration from a string...
776 AliTriggerConfiguration *runcfg = AliTriggerConfiguration::LoadConfigurationFromString(triggerConfig);
777 if (!runcfg)
778 {
779 Printf("ERROR: Could not create CTP configuration object");
780 return -14;
781 }
782
783 metadata.SetComment("CTP run configuration received during online running");
784
785 AliCDBId id2("GRP/CTP/Config", run, run);
786 success = cdb->Put(runcfg, id2, &metadata);
787
788 delete runcfg;
789 runcfg = 0;
790
791 if (!success)
792 {
793 Printf("ERROR: Could not store GRP/CTP/Config into OCDB");
794 return -15;
795 }
796
797 server->Close();
798 delete server;
799 server = 0;
800
801 return 0;
802}