1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //-------------------------------------------------------------------------
19 // Class AliGRPPreprocessor
20 // Global Run Parameters (GRP) preprocessor
21 // Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch
22 //-------------------------------------------------------------------------
27 #include <TObjString.h>
28 #include <TTimeStamp.h>
32 #include "AliGRPPreprocessor.h"
33 #include "AliGRPDCS.h"
34 #include "AliDCSSensorArray.h"
36 #include "AliTriggerConfiguration.h"
37 #include "AliTriggerRunScalers.h"
39 #include "AliCDBMetaData.h"
43 class AliShuttleInterface;
47 const Double_t kFitFraction = 0.7; // Fraction of DCS sensor fits required
49 ClassImp(AliGRPPreprocessor)
51 //_______________________________________________________________
52 const char* AliGRPPreprocessor::fgkDCSDataPoints[12] = {"LHCState","LHCPeriod","LHCLuminosity","BeamIntensity","L3Current","L3Polarity","DipoleCurrent","DipolePolarity","CavernTemperature","CavernAtmosPressure","gva_cr5AtmosphericPressure","gva_meyrinAtmosphericPressure"};
54 //_______________________________________________________________
55 AliGRPPreprocessor::AliGRPPreprocessor(AliShuttleInterface* shuttle):
56 AliPreprocessor("GRP",shuttle), fPressure(0) {
57 // constructor - shuttle must be instantiated!
59 AddRunType("PHYSICS");
62 //_______________________________________________________________
63 AliGRPPreprocessor::~AliGRPPreprocessor() {
68 //_______________________________________________________________
69 void AliGRPPreprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime) {
70 // Initialize preprocessor
72 AliPreprocessor::Initialize(run, startTime, endTime);
74 AliInfo("Initialization of the GRP preprocessor.");
76 TClonesArray * array = new TClonesArray("AliDCSSensor",2);
77 for(Int_t j = 0; j < 2; j++) {
78 AliDCSSensor * sens = new ((*array)[j])AliDCSSensor;
79 sens->SetStringID(fgkDCSDataPoints[j+10]);
81 AliInfo(Form("Pressure Entries: %d",array->GetEntries()));
83 fPressure = new AliDCSSensorArray(fStartTime, fEndTime, array);
86 //_______________________________________________________________
87 UInt_t AliGRPPreprocessor::Process(TMap* valueMap) {
88 // process data retrieved by the Shuttle
94 TList *daqlblist = ProcessDaqLB();
96 Log(Form("Problem with the DAQ logbook parameters!!!"));
100 //=================//
102 //=================//
103 UInt_t iDaqFxs = ProcessDaqFxs();
105 Log(Form("ProcessDaqFxs successful!"));
107 Log(Form("Could not store run raw tag file!"));
111 //=================//
113 //=================//
114 UInt_t iDcsFxs = ProcessDcsFxs();
116 Log(Form("ProcessDcsFxs successful!"));
118 Log(Form("Could not store CTP run configuration and scalers!"));
122 //=================//
123 // DCS data points //
124 //=================//
125 TList *dcsdplist = ProcessDcsDPs(valueMap);
127 Log(Form("Problem with the DCS data points!!!"));
130 if(dcsdplist->GetEntries() != 10) {
131 Log(Form("Problem with the DCS data points!!!"));
132 // return 1; // TODO:COMMENTED FOR TESTING PURPOSES!
134 //NEEDS TO BE REVISED - BREAKS!!!
135 // AliDCSSensorArray *dcsSensorArray = GetPressureMap(valueMap,fPressure);
136 // if(!dcsSensorArray) {
137 // Log(Form("Problem with the pressure sensor values!!!"));
141 daqlblist->AddAll(dcsdplist);
142 daqlblist->SetOwner(1);
143 AliInfo(Form("Final list entries: %d",daqlblist->GetEntries()));
146 md.SetResponsible("Panos Christakoglou");
147 md.SetComment("Output parameters from the GRP preprocessor.");
149 Bool_t result = Store("GRP", "Data", daqlblist, &md);
159 //_______________________________________________________________
160 TList *AliGRPPreprocessor::ProcessDaqLB() {
161 //Getting the DAQ lb informnation
162 const char* timeStart = GetRunParameter("time_start");
163 const char* timeEnd = GetRunParameter("time_end");
164 const char* beamEnergy = GetRunParameter("beamEnergy");
165 const char* beamType = GetRunParameter("beamType");
166 const char* numberOfDetectors = GetRunParameter("numberOfDetectors");
167 const char* detectorMask = GetRunParameter("detectorMask");
168 const char* lhcPeriod = GetRunParameter("LHCperiod");
171 Log(Form("Start time for run %d: %s",fRun, timeStart));
173 Log(Form("Start time not put in logbook!"));
175 TMap *mapDAQ1 = new TMap();
176 mapDAQ1->Add(new TObjString("fAliceStartTime"),new TObjString(timeStart));
179 Log(Form("End time for run %d: %s",fRun, timeEnd));
181 Log(Form("End time not put in logbook!"));
183 TMap *mapDAQ2 = new TMap();
184 mapDAQ2->Add(new TObjString("fAliceStopTime"),new TObjString(timeEnd));
187 Log(Form("Beam energy for run %d: %s",fRun, beamEnergy));
189 Log(Form("Beam energy not put in logbook!"));
191 TMap *mapDAQ3 = new TMap();
192 mapDAQ3->Add(new TObjString("fAliceBeamEnergy"),new TObjString(beamEnergy));
195 Log(Form("Beam type for run %d: %s",fRun, beamType));
197 Log(Form("Beam type not put in logbook!"));
199 TMap *mapDAQ4 = new TMap();
200 mapDAQ4->Add(new TObjString("fAliceBeamType"),new TObjString(beamType));
202 if (numberOfDetectors) {
203 Log(Form("Number of active detectors for run %d: %s",fRun, numberOfDetectors));
205 Log(Form("Number of active detectors not put in logbook!"));
207 TMap *mapDAQ5 = new TMap();
208 mapDAQ5->Add(new TObjString("fNumberOfDetectors"),new TObjString(numberOfDetectors));
211 Log(Form("Detector mask for run %d: %s",fRun, detectorMask));
213 Log(Form("Detector mask not put in logbook!"));
215 TMap *mapDAQ6 = new TMap();
216 mapDAQ6->Add(new TObjString("fDetectorMask"),new TObjString(detectorMask));
219 Log(Form("LHC period (DAQ) for run %d: %s",fRun, lhcPeriod));
221 Log(Form("LHCperiod not put in logbook!"));
223 TMap *mapDAQ7 = new TMap();
224 mapDAQ7->Add(new TObjString("fLHCPeriod"),new TObjString(lhcPeriod));
226 TList *list = new TList();
227 list->Add(mapDAQ1); list->Add(mapDAQ2);
228 list->Add(mapDAQ3); list->Add(mapDAQ4);
229 list->Add(mapDAQ5); list->Add(mapDAQ6);
232 TMap* mapDAQ8 = new TMap;
233 mapDAQ8->Add(new TObjString("fRunType"), new TObjString(GetRunType()));
239 //_______________________________________________________________
240 UInt_t AliGRPPreprocessor::ProcessDaqFxs() {
241 //======DAQ FXS======//
243 TList* list = GetFileSources(kDAQ);
245 Log("No raw data tag list: connection problems with DAQ FXS logbook!");
249 if (list->GetEntries() == 0)
251 Log("no raw data tags in this run: nothing to merge!");
256 TChain *fRawTagChain = new TChain("T");
258 TIterator* iter = list->MakeIterator();
260 while ((obj = iter->Next())) {
261 TObjString* objStr = dynamic_cast<TObjString*> (obj);
263 Log(Form("Found source %s", objStr->String().Data()));
264 TList* list2 = GetFileIDs(kDAQ, objStr->String());
266 Log("No list with ids from DAQ was found: connection problems with DAQ FXS logbook!");
267 delete fRawTagChain; fRawTagChain=0;
270 Log(Form("Number of ids: %d",list2->GetEntries()));
271 for(Int_t i = 0; i < list2->GetEntries(); i++) {
272 TObjString *idStr = (TObjString *)list2->At(i);
273 TString fileName = GetFile(kDAQ,idStr->String().Data(),objStr->String().Data());
274 if (fileName.Length() > 0)
276 Log(Form("Adding file in the chain: %s",fileName.Data()));
277 fRawTagChain->Add(fileName.Data());
280 Log(Form("Could not retrieve file with id %s from source %s: "
281 "connection problems with DAQ FXS!",
282 idStr->String().Data(),objStr->String().Data()));
284 delete list2; list2=0;
285 delete fRawTagChain; fRawTagChain=0;
293 TString fRawDataFileName = "GRP_Merged.tag.root";
294 Log(Form("Merging %d raw data tags into file: %s", nFiles, fRawDataFileName.Data()));
295 fRawTagChain->Merge(fRawDataFileName);
297 TString outputfile = Form("Run%d.Merged.RAW.tag.root", fRun);
298 Bool_t result = StoreRunMetadataFile(fRawDataFileName.Data(),outputfile.Data());
302 Log("Problem storing raw data tags in local file!!");
304 Log("Raw data tags merged successfully!!");
309 delete fRawTagChain; fRawTagChain=0;
311 if (result == kFALSE)
320 //_______________________________________________________________
321 UInt_t AliGRPPreprocessor::ProcessDcsFxs() {
322 //======DCS FXS======//
323 // Get the CTP run configuration
324 // and scalers from DCS FXS
327 // Get the CTP run configuration
328 TList* list = GetFileSources(kDCS,"CTP_runconfig");
330 Log("No CTP runconfig file: connection problems with DCS FXS logbook!");
334 if (list->GetEntries() == 0) {
335 Log("No CTP runconfig file to be processed!");
340 while ((source = dynamic_cast<TObjString *> (iter.Next()))) {
341 TString runcfgfile = GetFile(kDCS, "CTP_runconfig", source->GetName());
342 if (runcfgfile.IsNull()) {
343 Log("No CTP runconfig files has been found: empty source!");
346 Log(Form("File with Id CTP_runconfig found in source %s! Copied to %s",source->GetName(),runcfgfile.Data()));
347 AliTriggerConfiguration *runcfg = AliTriggerConfiguration::LoadConfiguration(runcfgfile);
349 Log("Bad CTP run configuration file! The corresponding CDB entry will not be filled!");
352 AliCDBMetaData metaData;
353 metaData.SetBeamPeriod(0);
354 metaData.SetResponsible("Roman Lietava");
355 metaData.SetComment("CTP run configuration");
356 if (!Store("CTP","Config", runcfg, &metaData, 0, 0)) {
357 Log("Unable to store the CTP run configuration object to OCDB!");
367 // Get the CTP counters information
368 TList* list = GetFileSources(kDCS,"CTP_xcounters");
370 Log("No CTP counters file: connection problems with DAQ FXS logbook!");
374 if (list->GetEntries() == 0) {
375 Log("No CTP counters file to be processed!");
380 while ((source = dynamic_cast<TObjString *> (iter.Next()))) {
381 TString countersfile = GetFile(kDCS, "CTP_xcounters", source->GetName());
382 if (countersfile.IsNull()) {
383 Log("No CTP counters files has been found: empty source!");
386 Log(Form("File with Id CTP_xcounters found in source %s! Copied to %s",source->GetName(),countersfile.Data()));
387 AliTriggerRunScalers *scalers = AliTriggerRunScalers::ReadScalers(countersfile);
389 Log("Bad CTP counters file! The corresponding CDB entry will not be filled!");
392 AliCDBMetaData metaData;
393 metaData.SetBeamPeriod(0);
394 metaData.SetResponsible("Roman Lietava");
395 metaData.SetComment("CTP scalers");
396 if (!Store("CTP","Scalers", scalers, &metaData, 0, 0)) {
397 Log("Unable to store the CTP scalers object to OCDB!");
409 //_______________________________________________________________
410 TList *AliGRPPreprocessor::ProcessDcsDPs(TMap* valueMap) {
411 //Getting the DCS dps
414 TList *list = new TList();
418 AliInfo(Form("==========LHCState==========="));
419 TObjArray *aliasLHCState = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[0]);
421 Log(Form("LHCState not found!!!"));
424 AliGRPDCS *dcs1 = new AliGRPDCS(aliasLHCState,fStartTime,fEndTime);
425 TString sLHCState = dcs1->ProcessDCS(3);
427 Log(Form("<LHCState> for run %d: %s",fRun, sLHCState.Data()));
429 Log(Form("LHCState not put in TMap!"));
431 TMap *mapDCS1 = new TMap();
432 mapDCS1->Add(new TObjString("fLHCState"),new TObjString(sLHCState));
435 AliInfo(Form("==========LHCPeriod==========="));
436 TObjArray *aliasLHCPeriod = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[1]);
437 if(!aliasLHCPeriod) {
438 Log(Form("LHCPeriod not found!!!"));
441 AliGRPDCS *dcs2 = new AliGRPDCS(aliasLHCPeriod,fStartTime,fEndTime);
442 TString sLHCPeriod = dcs2->ProcessDCS(3);
444 Log(Form("<LHCPeriod> for run %d: %s",fRun, sLHCPeriod.Data()));
446 Log(Form("LHCPeriod not put in TMap!"));
448 TMap *mapDCS2 = new TMap();
449 mapDCS2->Add(new TObjString("fLHCCondition"),new TObjString(sLHCPeriod));
452 AliInfo(Form("==========LHCLuminosity==========="));
453 TObjArray *aliasLHCLuminosity = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[2]);
454 if(!aliasLHCLuminosity) {
455 Log(Form("LHCLuminosity not found!!!"));
458 AliGRPDCS *dcs3 = new AliGRPDCS(aliasLHCLuminosity,fStartTime,fEndTime);
459 TString sMeanLHCLuminosity = dcs3->ProcessDCS(2);
460 if (sMeanLHCLuminosity) {
461 Log(Form("<LHCLuminosity> for run %d: %s",fRun, sMeanLHCLuminosity.Data()));
463 Log(Form("LHCLuminosity not put in TMap!"));
465 TMap *mapDCS3 = new TMap();
466 mapDCS3->Add(new TObjString("fLHCLuminosity"),new TObjString(sMeanLHCLuminosity));
469 AliInfo(Form("==========BeamIntensity==========="));
470 TObjArray *aliasBeamIntensity = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[3]);
471 if(!aliasBeamIntensity) {
472 Log(Form("BeamIntensity not found!!!"));
475 AliGRPDCS *dcs4 = new AliGRPDCS(aliasBeamIntensity,fStartTime,fEndTime);
476 TString sMeanBeamIntensity = dcs4->ProcessDCS(2);
477 if (sMeanBeamIntensity) {
478 Log(Form("<BeamIntensity> for run %d: %s",fRun, sMeanBeamIntensity.Data()));
480 Log(Form("BeamIntensity not put in TMap!"));
482 TMap *mapDCS4 = new TMap();
483 mapDCS4->Add(new TObjString("fBeamIntensity"),new TObjString(sMeanBeamIntensity));
486 AliInfo(Form("==========L3Current==========="));
487 TObjArray *aliasL3Current = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[4]);
488 if(!aliasL3Current) {
489 Log(Form("L3Current not found!!!"));
492 AliGRPDCS *dcs5 = new AliGRPDCS(aliasL3Current,fStartTime,fEndTime);
493 TString sMeanL3Current = dcs5->ProcessDCS(2);
494 if (sMeanL3Current) {
495 Log(Form("<L3Current> for run %d: %s",fRun, sMeanL3Current.Data()));
497 Log(Form("L3Current not put in TMap!"));
499 TMap *mapDCS5 = new TMap();
500 mapDCS5->Add(new TObjString("fL3Current"),new TObjString(sMeanL3Current));
503 AliInfo(Form("==========L3Polarity==========="));
504 TObjArray *aliasL3Polarity = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[5]);
505 if(!aliasL3Polarity) {
506 Log(Form("L3Polarity not found!!!"));
509 AliGRPDCS *dcs6 = new AliGRPDCS(aliasL3Polarity,fStartTime,fEndTime);
510 TString sL3Polarity = dcs6->ProcessDCS(4);
512 Log(Form("<L3Polarity> for run %d: %s",fRun, sL3Polarity.Data()));
514 Log(Form("L3Polarity not put in TMap!"));
516 TMap *mapDCS6 = new TMap();
517 mapDCS6->Add(new TObjString("fL3Polarity"),new TObjString(sL3Polarity));
520 AliInfo(Form("==========DipoleCurrent==========="));
521 TObjArray *aliasDipoleCurrent = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[6]);
522 if(!aliasDipoleCurrent) {
523 Log(Form("DipoleCurrent not found!!!"));
526 AliGRPDCS *dcs7 = new AliGRPDCS(aliasDipoleCurrent,fStartTime,fEndTime);
527 TString sMeanDipoleCurrent = dcs7->ProcessDCS(2);
528 if (sMeanDipoleCurrent) {
529 Log(Form("<DipoleCurrent> for run %d: %s",fRun, sMeanDipoleCurrent.Data()));
531 Log(Form("DipoleCurrent not put in TMap!"));
533 TMap *mapDCS7 = new TMap();
534 mapDCS7->Add(new TObjString("fDipoleCurrent"),new TObjString(sMeanDipoleCurrent));
537 AliInfo(Form("==========DipolePolarity==========="));
538 TObjArray *aliasDipolePolarity = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[7]);
539 if(!aliasDipolePolarity) {
540 Log(Form("DipolePolarity not found!!!"));
543 AliGRPDCS *dcs8 = new AliGRPDCS(aliasDipolePolarity,fStartTime,fEndTime);
544 TString sDipolePolarity = dcs8->ProcessDCS(4);
545 if (sDipolePolarity) {
546 Log(Form("<DipolePolarity> for run %d: %s",fRun, sDipolePolarity.Data()));
548 Log(Form("DipolePolarity not put in TMap!"));
550 TMap *mapDCS8 = new TMap();
551 mapDCS8->Add(new TObjString("fDipolePolarity"),new TObjString(sDipolePolarity));
554 AliInfo(Form("==========CavernTemperature==========="));
555 TObjArray *aliasCavernTemperature = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[8]);
556 if(!aliasCavernTemperature) {
557 Log(Form("CavernTemperature not found!!!"));
560 AliGRPDCS *dcs9 = new AliGRPDCS(aliasCavernTemperature,fStartTime,fEndTime);
561 TString sMeanCavernTemperature = dcs9->ProcessDCS(2);
562 if (sMeanCavernTemperature) {
563 Log(Form("<CavernTemperature> for run %d: %s",fRun, sMeanCavernTemperature.Data()));
565 Log(Form("CavernTemperature not put in TMap!"));
567 TMap *mapDCS9 = new TMap();
568 mapDCS9->Add(new TObjString("fCavernTemperature"),new TObjString(sMeanCavernTemperature));
571 AliInfo(Form("==========CavernPressure==========="));
572 TObjArray *aliasCavernPressure = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[9]);
573 if(!aliasCavernPressure) {
574 Log(Form("CavernPressure not found!!!"));
577 AliGRPDCS *dcs10 = new AliGRPDCS(aliasCavernPressure,fStartTime,fEndTime);
578 TString sMeanCavernPressure = dcs10->ProcessDCS(2);
579 if (sMeanCavernPressure) {
580 Log(Form("<CavernPressure> for run %d: %s",fRun, sMeanCavernPressure.Data()));
582 Log(Form("CavernPressure not put in TMap!"));
584 TMap *mapDCS10 = new TMap();
585 mapDCS10->Add(new TObjString("fCavernPressure"),new TObjString(sMeanCavernPressure));
591 //_______________________________________________________________
592 AliDCSSensorArray *AliGRPPreprocessor::GetPressureMap(TMap* dcsAliasMap, AliDCSSensorArray *fPressure) {
593 // extract DCS pressure maps. Perform fits to save space
595 TMap *map = fPressure->ExtractDCS(dcsAliasMap);
597 fPressure->MakeSplineFit(map);
598 Double_t fitFraction = fPressure->NumFits()/fPressure->NumSensors();
599 if (fitFraction > kFitFraction ) {
600 AliInfo(Form("Pressure values extracted, fits performed.\n"));
602 AliInfo("Too few pressure maps fitted. \n");
605 AliInfo("AliGRPDCS: no atmospheric pressure map extracted. \n");
612 //_______________________________________________________________
613 /*UInt_t AliGRPPreprocessor::MapPressure(TMap* dcsAliasMap) {
614 // extract DCS pressure maps. Perform fits to save space
617 TMap *map = fPressure->ExtractDCS(dcsAliasMap);
619 fPressure->MakeSplineFit(map);
620 Double_t fitFraction = fPressure->NumFits()/fPressure->NumSensors();
621 if (fitFraction > kFitFraction ) {
622 AliInfo(Form("Pressure values extracted, fits performed.\n"));
624 Log ("Too few pressure maps fitted. \n");
628 Log("AliTPCPreprocsessor: no atmospheric pressure map extracted. \n");
632 // Now store the final CDB file
635 AliCDBMetaData metaData;
636 metaData.SetBeamPeriod(0);
637 metaData.SetResponsible("Panos Christakoglou");
638 metaData.SetComment("Preprocessor AliGRP data base pressure entries.");
640 Bool_t storeOK = Store("Calib", "Pressure", fPressure, &metaData, 0, 0);
641 if ( !storeOK ) result=1;