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():
56 AliPreprocessor("GRP",0), fPressure(0) {
57 // default constructor - Don't use this!
61 //_______________________________________________________________
62 AliGRPPreprocessor::AliGRPPreprocessor(AliShuttleInterface* shuttle):
63 AliPreprocessor("GRP",shuttle), fPressure(0) {
64 // constructor - shuttle must be instantiated!
68 //_______________________________________________________________
69 AliGRPPreprocessor::~AliGRPPreprocessor() {
74 //_______________________________________________________________
75 void AliGRPPreprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime) {
76 // Initialize preprocessor
78 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run, TTimeStamp(startTime).AsString(), TTimeStamp(endTime).AsString()));
81 fStartTime = startTime;
83 AliInfo("Initialization of the GRP preprocessor.");
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]);
90 AliInfo(Form("Pressure Entries: %d",array->GetEntries()));
92 fPressure = new AliDCSSensorArray(fStartTime, fEndTime, array);
95 //_______________________________________________________________
96 UInt_t AliGRPPreprocessor::Process(TMap* valueMap) {
97 // process data retrieved by the Shuttle
101 //=================//
103 TList *daqlblist = ProcessDaqLB();
105 Log(Form("Problem with the DAQ logbook parameters!!!"));
108 TMap *m1 = (TMap *)daqlblist->At(0);
109 TObjString *s1 = (TObjString *)m1->GetValue("fAliceStartTime");
110 UInt_t iStartTime = atoi(s1->String().Data());
111 TMap *m2 = (TMap *)daqlblist->At(1);
112 TObjString *s2 = (TObjString *)m2->GetValue("fAliceStopTime");
113 UInt_t iStopTime = atoi(s2->String().Data());
115 //=================//
117 //=================//
118 UInt_t iDaqFxs = ProcessDaqFxs();
120 Log(Form("ProcessDaqFxs successful!"));
122 Log(Form("Could not store run raw tag file!"));
126 //=================//
128 //=================//
129 UInt_t iDcsFxs = ProcessDcsFxs();
131 Log(Form("ProcessDcsFxs successful!"));
133 Log(Form("Could not store CTP run configuration and scalers!"));
137 //=================//
138 // DCS data points //
139 //=================//
140 TList *dcsdplist = ProcessDcsDPs(valueMap, iStartTime, iStopTime);
142 Log(Form("Problem with the DCS data points!!!"));
145 if(dcsdplist->GetEntries() != 10) {
146 Log(Form("Problem with the DCS data points!!!"));
147 // return 1; // TODO:COMMENTED FOR TESTING PURPOSES!
149 //NEEDS TO BE REVISED - BREAKS!!!
150 // AliDCSSensorArray *dcsSensorArray = GetPressureMap(valueMap,fPressure);
151 // if(!dcsSensorArray) {
152 // Log(Form("Problem with the pressure sensor values!!!"));
156 TList * list = new TList();
157 list = GetGlobalList(daqlblist,dcsdplist);
159 AliInfo(Form("Final list entries: %d",list->GetEntries()));
162 md.SetResponsible("Panos Christakoglou");
163 md.SetComment("Output parameters from the GRP preprocessor.");
165 Bool_t result = Store("GRP", "Data", list, &md);
175 //_______________________________________________________________
176 TList *AliGRPPreprocessor::GetGlobalList(TList *l1, TList *l2) {
177 //Getting the global output TList
178 TList *list = new TList();
179 TMap *map = new TMap();
180 for(Int_t i = 0; i < l1->GetEntries(); i++)
181 list->AddLast(map = (TMap *)l1->At(i));
182 for(Int_t i = 0; i < l2->GetEntries(); i++)
183 list->AddLast(map = (TMap *)l2->At(i));
188 //_______________________________________________________________
189 TList *AliGRPPreprocessor::ProcessDaqLB() {
190 //Getting the DAQ lb informnation
191 const char* timeStart = GetRunParameter("time_start");
192 const char* timeEnd = GetRunParameter("time_end");
193 const char* beamEnergy = GetRunParameter("beamEnergy");
194 const char* beamType = GetRunParameter("beamType");
195 const char* numberOfDetectors = GetRunParameter("numberOfDetectors");
196 const char* detectorMask = GetRunParameter("detectorMask");
197 const char* lhcPeriod = GetRunParameter("LHCperiod");
200 Log(Form("Start time for run %d: %s",fRun, timeStart));
202 Log(Form("Start time not put in logbook!"));
204 TMap *mapDAQ1 = new TMap();
205 mapDAQ1->Add(new TObjString("fAliceStartTime"),new TObjString(timeStart));
208 Log(Form("End time for run %d: %s",fRun, timeEnd));
210 Log(Form("End time not put in logbook!"));
212 TMap *mapDAQ2 = new TMap();
213 mapDAQ2->Add(new TObjString("fAliceStopTime"),new TObjString(timeEnd));
216 Log(Form("Beam energy for run %d: %s",fRun, beamEnergy));
218 Log(Form("Beam energy not put in logbook!"));
220 TMap *mapDAQ3 = new TMap();
221 mapDAQ3->Add(new TObjString("fAliceBeamEnergy"),new TObjString(beamEnergy));
224 Log(Form("Beam type for run %d: %s",fRun, beamType));
226 Log(Form("Beam type not put in logbook!"));
228 TMap *mapDAQ4 = new TMap();
229 mapDAQ4->Add(new TObjString("fAliceBeamType"),new TObjString(beamType));
231 if (numberOfDetectors) {
232 Log(Form("Number of active detectors for run %d: %s",fRun, numberOfDetectors));
234 Log(Form("Number of active detectors not put in logbook!"));
236 TMap *mapDAQ5 = new TMap();
237 mapDAQ5->Add(new TObjString("fNumberOfDetectors"),new TObjString(numberOfDetectors));
240 Log(Form("Detector mask for run %d: %s",fRun, detectorMask));
242 Log(Form("Detector mask not put in logbook!"));
244 TMap *mapDAQ6 = new TMap();
245 mapDAQ6->Add(new TObjString("fDetectorMask"),new TObjString(detectorMask));
248 Log(Form("LHC period (DAQ) for run %d: %s",fRun, lhcPeriod));
250 Log(Form("LHCperiod not put in logbook!"));
252 TMap *mapDAQ7 = new TMap();
253 mapDAQ7->Add(new TObjString("fLHCPeriod"),new TObjString(lhcPeriod));
255 TList *list = new TList();
256 list->Add(mapDAQ1); list->Add(mapDAQ2);
257 list->Add(mapDAQ3); list->Add(mapDAQ4);
258 list->Add(mapDAQ5); list->Add(mapDAQ6);
264 //_______________________________________________________________
265 UInt_t AliGRPPreprocessor::ProcessDaqFxs() {
266 //======DAQ FXS======//
268 TList* list = GetFileSources(kDAQ);
270 Log("No raw data tag list: connection problems with DAQ FXS logbook!");
274 if (list->GetEntries() == 0)
276 Log("no raw data tags in this run: nothing to merge!");
281 TChain *fRawTagChain = new TChain("T");
283 TIterator* iter = list->MakeIterator();
285 while ((obj = iter->Next())) {
286 TObjString* objStr = dynamic_cast<TObjString*> (obj);
288 Log(Form("Found source %s", objStr->String().Data()));
289 TList* list2 = GetFileIDs(kDAQ, objStr->String());
291 Log("No list with ids from DAQ was found: connection problems with DAQ FXS logbook!");
292 delete fRawTagChain; fRawTagChain=0;
295 Log(Form("Number of ids: %d",list2->GetEntries()));
296 for(Int_t i = 0; i < list2->GetEntries(); i++) {
297 TObjString *idStr = (TObjString *)list2->At(i);
298 TString fileName = GetFile(kDAQ,idStr->String().Data(),objStr->String().Data());
299 if (fileName.Length() > 0)
301 Log(Form("Adding file in the chain: %s",fileName.Data()));
302 fRawTagChain->Add(fileName.Data());
305 Log(Form("Could not retrieve file with id %s from source %s: "
306 "connection problems with DAQ FXS!",
307 idStr->String().Data(),objStr->String().Data()));
309 delete list2; list2=0;
310 delete fRawTagChain; fRawTagChain=0;
318 TString fRawDataFileName = "GRP_Merged.tag.root";
319 Log(Form("Merging %d raw data tags into file: %s", nFiles, fRawDataFileName.Data()));
320 fRawTagChain->Merge(fRawDataFileName);
322 TString outputfile = Form("Run%d.Merged.RAW.tag.root", fRun);
323 Bool_t result = StoreRunMetadataFile(fRawDataFileName.Data(),outputfile.Data());
327 Log("Problem storing raw data tags in local file!!");
329 Log("Raw data tags merged successfully!!");
334 delete fRawTagChain; fRawTagChain=0;
336 if (result == kFALSE)
345 //_______________________________________________________________
346 UInt_t AliGRPPreprocessor::ProcessDcsFxs() {
347 //======DCS FXS======//
348 // Get the CTP run configuration
349 // and scalers from DCS FXS
352 // Get the CTP run configuration
353 TList* list = GetFileSources(kDCS,"CTP_runconfig");
355 Log("No CTP runconfig file: connection problems with DCS FXS logbook!");
359 if (list->GetEntries() == 0) {
360 Log("No CTP runconfig file to be processed!");
365 while ((source = dynamic_cast<TObjString *> (iter.Next()))) {
366 TString runcfgfile = GetFile(kDCS, "CTP_runconfig", source->GetName());
367 if (runcfgfile.IsNull()) {
368 Log("No CTP runconfig files has been found: empty source!");
371 Log(Form("File with Id CTP_runconfig found in source %s! Copied to %s",source->GetName(),runcfgfile.Data()));
372 AliTriggerConfiguration *runcfg = AliTriggerConfiguration::LoadConfiguration(runcfgfile);
374 Log("Bad CTP run configuration file! The corresponding CDB entry will not be filled!");
377 AliCDBMetaData metaData;
378 metaData.SetBeamPeriod(0);
379 metaData.SetResponsible("Roman Lietava");
380 metaData.SetComment("CTP run configuration");
381 if (!Store("CTP","Config", runcfg, &metaData, 0, 0)) {
382 Log("Unable to store the CTP run configuration object to OCDB!");
392 // Get the CTP counters information
393 TList* list = GetFileSources(kDCS,"CTP_xcounters");
395 Log("No CTP counters file: connection problems with DAQ FXS logbook!");
399 if (list->GetEntries() == 0) {
400 Log("No CTP counters file to be processed!");
405 while ((source = dynamic_cast<TObjString *> (iter.Next()))) {
406 TString countersfile = GetFile(kDCS, "CTP_xcounters", source->GetName());
407 if (countersfile.IsNull()) {
408 Log("No CTP counters files has been found: empty source!");
411 Log(Form("File with Id CTP_xcounters found in source %s! Copied to %s",source->GetName(),countersfile.Data()));
412 AliTriggerRunScalers *scalers = AliTriggerRunScalers::ReadScalers(countersfile);
414 Log("Bad CTP counters file! The corresponding CDB entry will not be filled!");
417 AliCDBMetaData metaData;
418 metaData.SetBeamPeriod(0);
419 metaData.SetResponsible("Roman Lietava");
420 metaData.SetComment("CTP scalers");
421 if (!Store("CTP","Scalers", scalers, &metaData, 0, 0)) {
422 Log("Unable to store the CTP scalers object to OCDB!");
434 //_______________________________________________________________
435 TList *AliGRPPreprocessor::ProcessDcsDPs(TMap* valueMap, UInt_t iStartTime, UInt_t iStopTime) {
436 //Getting the DCS dps
439 TList *list = new TList();
443 AliInfo(Form("==========LHCState==========="));
444 TObjArray *aliasLHCState = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[0]);
446 Log(Form("LHCState not found!!!"));
449 AliGRPDCS *dcs1 = new AliGRPDCS(aliasLHCState,iStartTime,iStopTime);
450 TString sLHCState = dcs1->ProcessDCS(3);
452 Log(Form("<LHCState> for run %d: %s",fRun, sLHCState.Data()));
454 Log(Form("LHCState not put in TMap!"));
456 TMap *mapDCS1 = new TMap();
457 mapDCS1->Add(new TObjString("fLHCState"),new TObjString(sLHCState));
460 AliInfo(Form("==========LHCPeriod==========="));
461 TObjArray *aliasLHCPeriod = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[1]);
462 if(!aliasLHCPeriod) {
463 Log(Form("LHCPeriod not found!!!"));
466 AliGRPDCS *dcs2 = new AliGRPDCS(aliasLHCPeriod,iStartTime,iStopTime);
467 TString sLHCPeriod = dcs2->ProcessDCS(3);
469 Log(Form("<LHCPeriod> for run %d: %s",fRun, sLHCPeriod.Data()));
471 Log(Form("LHCPeriod not put in TMap!"));
473 TMap *mapDCS2 = new TMap();
474 mapDCS2->Add(new TObjString("fLHCCondition"),new TObjString(sLHCPeriod));
477 AliInfo(Form("==========LHCLuminosity==========="));
478 TObjArray *aliasLHCLuminosity = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[2]);
479 if(!aliasLHCLuminosity) {
480 Log(Form("LHCLuminosity not found!!!"));
483 AliGRPDCS *dcs3 = new AliGRPDCS(aliasLHCLuminosity,iStartTime,iStopTime);
484 TString sMeanLHCLuminosity = dcs3->ProcessDCS(2);
485 if (sMeanLHCLuminosity) {
486 Log(Form("<LHCLuminosity> for run %d: %s",fRun, sMeanLHCLuminosity.Data()));
488 Log(Form("LHCLuminosity not put in TMap!"));
490 TMap *mapDCS3 = new TMap();
491 mapDCS3->Add(new TObjString("fLHCLuminosity"),new TObjString(sMeanLHCLuminosity));
494 AliInfo(Form("==========BeamIntensity==========="));
495 TObjArray *aliasBeamIntensity = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[3]);
496 if(!aliasBeamIntensity) {
497 Log(Form("BeamIntensity not found!!!"));
500 AliGRPDCS *dcs4 = new AliGRPDCS(aliasBeamIntensity,iStartTime,iStopTime);
501 TString sMeanBeamIntensity = dcs4->ProcessDCS(2);
502 if (sMeanBeamIntensity) {
503 Log(Form("<BeamIntensity> for run %d: %s",fRun, sMeanBeamIntensity.Data()));
505 Log(Form("BeamIntensity not put in TMap!"));
507 TMap *mapDCS4 = new TMap();
508 mapDCS4->Add(new TObjString("fBeamIntensity"),new TObjString(sMeanBeamIntensity));
511 AliInfo(Form("==========L3Current==========="));
512 TObjArray *aliasL3Current = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[4]);
513 if(!aliasL3Current) {
514 Log(Form("L3Current not found!!!"));
517 AliGRPDCS *dcs5 = new AliGRPDCS(aliasL3Current,iStartTime,iStopTime);
518 TString sMeanL3Current = dcs5->ProcessDCS(2);
519 if (sMeanL3Current) {
520 Log(Form("<L3Current> for run %d: %s",fRun, sMeanL3Current.Data()));
522 Log(Form("L3Current not put in TMap!"));
524 TMap *mapDCS5 = new TMap();
525 mapDCS5->Add(new TObjString("fL3Current"),new TObjString(sMeanL3Current));
528 AliInfo(Form("==========L3Polarity==========="));
529 TObjArray *aliasL3Polarity = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[5]);
530 if(!aliasL3Polarity) {
531 Log(Form("L3Polarity not found!!!"));
534 AliGRPDCS *dcs6 = new AliGRPDCS(aliasL3Polarity,iStartTime,iStopTime);
535 TString sL3Polarity = dcs6->ProcessDCS(4);
537 Log(Form("<L3Polarity> for run %d: %s",fRun, sL3Polarity.Data()));
539 Log(Form("L3Polarity not put in TMap!"));
541 TMap *mapDCS6 = new TMap();
542 mapDCS6->Add(new TObjString("fL3Polarity"),new TObjString(sL3Polarity));
545 AliInfo(Form("==========DipoleCurrent==========="));
546 TObjArray *aliasDipoleCurrent = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[6]);
547 if(!aliasDipoleCurrent) {
548 Log(Form("DipoleCurrent not found!!!"));
551 AliGRPDCS *dcs7 = new AliGRPDCS(aliasDipoleCurrent,iStartTime,iStopTime);
552 TString sMeanDipoleCurrent = dcs7->ProcessDCS(2);
553 if (sMeanDipoleCurrent) {
554 Log(Form("<DipoleCurrent> for run %d: %s",fRun, sMeanDipoleCurrent.Data()));
556 Log(Form("DipoleCurrent not put in TMap!"));
558 TMap *mapDCS7 = new TMap();
559 mapDCS7->Add(new TObjString("fDipoleCurrent"),new TObjString(sMeanDipoleCurrent));
562 AliInfo(Form("==========DipolePolarity==========="));
563 TObjArray *aliasDipolePolarity = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[7]);
564 if(!aliasDipolePolarity) {
565 Log(Form("DipolePolarity not found!!!"));
568 AliGRPDCS *dcs8 = new AliGRPDCS(aliasDipolePolarity,iStartTime,iStopTime);
569 TString sDipolePolarity = dcs8->ProcessDCS(4);
570 if (sDipolePolarity) {
571 Log(Form("<DipolePolarity> for run %d: %s",fRun, sDipolePolarity.Data()));
573 Log(Form("DipolePolarity not put in TMap!"));
575 TMap *mapDCS8 = new TMap();
576 mapDCS8->Add(new TObjString("fDipolePolarity"),new TObjString(sDipolePolarity));
579 AliInfo(Form("==========CavernTemperature==========="));
580 TObjArray *aliasCavernTemperature = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[8]);
581 if(!aliasCavernTemperature) {
582 Log(Form("CavernTemperature not found!!!"));
585 AliGRPDCS *dcs9 = new AliGRPDCS(aliasCavernTemperature,iStartTime,iStopTime);
586 TString sMeanCavernTemperature = dcs9->ProcessDCS(2);
587 if (sMeanCavernTemperature) {
588 Log(Form("<CavernTemperature> for run %d: %s",fRun, sMeanCavernTemperature.Data()));
590 Log(Form("CavernTemperature not put in TMap!"));
592 TMap *mapDCS9 = new TMap();
593 mapDCS9->Add(new TObjString("fCavernTemperature"),new TObjString(sMeanCavernTemperature));
596 AliInfo(Form("==========CavernPressure==========="));
597 TObjArray *aliasCavernPressure = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[9]);
598 if(!aliasCavernPressure) {
599 Log(Form("CavernPressure not found!!!"));
602 AliGRPDCS *dcs10 = new AliGRPDCS(aliasCavernPressure,iStartTime,iStopTime);
603 TString sMeanCavernPressure = dcs10->ProcessDCS(2);
604 if (sMeanCavernPressure) {
605 Log(Form("<CavernPressure> for run %d: %s",fRun, sMeanCavernPressure.Data()));
607 Log(Form("CavernPressure not put in TMap!"));
609 TMap *mapDCS10 = new TMap();
610 mapDCS10->Add(new TObjString("fCavernPressure"),new TObjString(sMeanCavernPressure));
616 //_______________________________________________________________
617 AliDCSSensorArray *AliGRPPreprocessor::GetPressureMap(TMap* dcsAliasMap, AliDCSSensorArray *fPressure) {
618 // extract DCS pressure maps. Perform fits to save space
620 TMap *map = fPressure->ExtractDCS(dcsAliasMap);
622 fPressure->MakeSplineFit(map);
623 Double_t fitFraction = fPressure->NumFits()/fPressure->NumSensors();
624 if (fitFraction > kFitFraction ) {
625 AliInfo(Form("Pressure values extracted, fits performed.\n"));
627 AliInfo("Too few pressure maps fitted. \n");
630 AliInfo("AliGRPDCS: no atmospheric pressure map extracted. \n");
637 //_______________________________________________________________
638 /*UInt_t AliGRPPreprocessor::MapPressure(TMap* dcsAliasMap) {
639 // extract DCS pressure maps. Perform fits to save space
642 TMap *map = fPressure->ExtractDCS(dcsAliasMap);
644 fPressure->MakeSplineFit(map);
645 Double_t fitFraction = fPressure->NumFits()/fPressure->NumSensors();
646 if (fitFraction > kFitFraction ) {
647 AliInfo(Form("Pressure values extracted, fits performed.\n"));
649 Log ("Too few pressure maps fitted. \n");
653 Log("AliTPCPreprocsessor: no atmospheric pressure map extracted. \n");
657 // Now store the final CDB file
660 AliCDBMetaData metaData;
661 metaData.SetBeamPeriod(0);
662 metaData.SetResponsible("Panos Christakoglou");
663 metaData.SetComment("Preprocessor AliGRP data base pressure entries.");
665 Bool_t storeOK = Store("Calib", "Pressure", fPressure, &metaData, 0, 0);
666 if ( !storeOK ) result=1;