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 "AliCDBMetaData.h"
40 class AliShuttleInterface;
44 const Double_t kFitFraction = 0.7; // Fraction of DCS sensor fits required
46 ClassImp(AliGRPPreprocessor)
48 //_______________________________________________________________
49 const char* AliGRPPreprocessor::fgkDCSDataPoints[12] = {"LHCState","LHCPeriod","LHCLuminosity","BeamIntensity","L3Current","L3Polarity","DipoleCurrent","DipolePolarity","CavernTemperature","CavernAtmosPressure","gva_cr5AtmosphericPressure","gva_meyrinAtmosphericPressure"};
51 //_______________________________________________________________
52 AliGRPPreprocessor::AliGRPPreprocessor():
53 AliPreprocessor("GRP",0), fPressure(0) {
54 // default constructor - Don't use this!
58 //_______________________________________________________________
59 AliGRPPreprocessor::AliGRPPreprocessor(AliShuttleInterface* shuttle):
60 AliPreprocessor("GRP",shuttle), fPressure(0) {
61 // constructor - shuttle must be instantiated!
65 //_______________________________________________________________
66 AliGRPPreprocessor::~AliGRPPreprocessor() {
71 //_______________________________________________________________
72 void AliGRPPreprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime) {
73 // Initialize preprocessor
75 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run, TTimeStamp(startTime).AsString(), TTimeStamp(endTime).AsString()));
78 fStartTime = startTime;
80 AliInfo("Initialization of the GRP preprocessor.");
82 TClonesArray * array = new TClonesArray("AliDCSSensor",2);
83 for(Int_t j = 0; j < 2; j++) {
84 AliDCSSensor * sens = new ((*array)[j])AliDCSSensor;
85 sens->SetStringID(fgkDCSDataPoints[j+10]);
87 AliInfo(Form("Pressure Entries: %d",array->GetEntries()));
89 fPressure = new AliDCSSensorArray(fStartTime, fEndTime, array);
92 //_______________________________________________________________
93 UInt_t AliGRPPreprocessor::Process(TMap* valueMap) {
94 // process data retrieved by the Shuttle
100 TList *daqlblist = ProcessDaqLB();
102 Log(Form("Problem with the DAQ logbook parameters!!!"));
105 TMap *m1 = (TMap *)daqlblist->At(0);
106 TObjString *s1 = (TObjString *)m1->GetValue("fAliceStartTime");
107 UInt_t iStartTime = atoi(s1->String().Data());
108 TMap *m2 = (TMap *)daqlblist->At(1);
109 TObjString *s2 = (TObjString *)m2->GetValue("fAliceStopTime");
110 UInt_t iStopTime = atoi(s2->String().Data());
112 //=================//
114 //=================//
115 UInt_t iDaqFxs = ProcessDaqFxs();
117 Log(Form("Raw data tags merged successfully!"));
119 Log(Form("Could not store run raw tag file!"));
124 //=================//
125 // DCS data points //
126 //=================//
127 TList *dcsdplist = ProcessDcsDPs(valueMap, iStartTime, iStopTime);
129 Log(Form("Problem with the DCS data points!!!"));
132 if(dcsdplist->GetEntries() != 10) {
133 Log(Form("Problem with the DCS data points!!!"));
136 //NEEDS TO BE REVISED - BREAKS!!!
137 // AliDCSSensorArray *dcsSensorArray = GetPressureMap(valueMap,fPressure);
138 // if(!dcsSensorArray) {
139 // Log(Form("Problem with the pressure sensor values!!!"));
143 TList * list = new TList();
144 list = GetGlobalList(daqlblist,dcsdplist);
146 AliInfo(Form("Final list entries: %d",list->GetEntries()));
149 md.SetResponsible("Panos Christakoglou");
150 md.SetComment("Output parameters from the GRP preprocessor.");
152 Bool_t result = Store("GRP", "Data", list, &md);
162 //_______________________________________________________________
163 TList *AliGRPPreprocessor::GetGlobalList(TList *l1, TList *l2) {
164 //Getting the global output TList
165 TList *list = new TList();
166 TMap *map = new TMap();
167 for(Int_t i = 0; i < l1->GetEntries(); i++)
168 list->AddLast(map = (TMap *)l1->At(i));
169 for(Int_t i = 0; i < l2->GetEntries(); i++)
170 list->AddLast(map = (TMap *)l2->At(i));
175 //_______________________________________________________________
176 TList *AliGRPPreprocessor::ProcessDaqLB() {
177 //Getting the DAQ lb informnation
178 const char* timeStart = GetRunParameter("time_start");
179 const char* timeEnd = GetRunParameter("time_end");
180 const char* beamEnergy = GetRunParameter("beamEnergy");
181 const char* beamType = GetRunParameter("beamType");
182 const char* numberOfDetectors = GetRunParameter("numberOfDetectors");
183 const char* detectorMask = GetRunParameter("detectorMask");
184 const char* lhcPeriod = GetRunParameter("LHCperiod");
187 Log(Form("Start time for run %d: %s",fRun, timeStart));
189 Log(Form("Start time not put in logbook!"));
191 TMap *mapDAQ1 = new TMap();
192 mapDAQ1->Add(new TObjString("fAliceStartTime"),new TObjString(timeStart));
195 Log(Form("End time for run %d: %s",fRun, timeEnd));
197 Log(Form("End time not put in logbook!"));
199 TMap *mapDAQ2 = new TMap();
200 mapDAQ2->Add(new TObjString("fAliceStopTime"),new TObjString(timeEnd));
203 Log(Form("Beam energy for run %d: %s",fRun, beamEnergy));
205 Log(Form("Beam energy not put in logbook!"));
207 TMap *mapDAQ3 = new TMap();
208 mapDAQ3->Add(new TObjString("fAliceBeamEnergy"),new TObjString(beamEnergy));
211 Log(Form("Beam type for run %d: %s",fRun, beamType));
213 Log(Form("Beam type not put in logbook!"));
215 TMap *mapDAQ4 = new TMap();
216 mapDAQ4->Add(new TObjString("fAliceBeamType"),new TObjString(beamType));
218 if (numberOfDetectors) {
219 Log(Form("Number of active detectors for run %d: %s",fRun, numberOfDetectors));
221 Log(Form("Number of active detectors not put in logbook!"));
223 TMap *mapDAQ5 = new TMap();
224 mapDAQ5->Add(new TObjString("fNumberOfDetectors"),new TObjString(numberOfDetectors));
227 Log(Form("Detector mask for run %d: %s",fRun, detectorMask));
229 Log(Form("Detector mask not put in logbook!"));
231 TMap *mapDAQ6 = new TMap();
232 mapDAQ6->Add(new TObjString("fDetectorMask"),new TObjString(detectorMask));
235 Log(Form("LHC period (DAQ) for run %d: %s",fRun, lhcPeriod));
237 Log(Form("LHCperiod not put in logbook!"));
239 TMap *mapDAQ7 = new TMap();
240 mapDAQ7->Add(new TObjString("fLHCPeriod"),new TObjString(lhcPeriod));
242 TList *list = new TList();
243 list->Add(mapDAQ1); list->Add(mapDAQ2);
244 list->Add(mapDAQ3); list->Add(mapDAQ4);
245 list->Add(mapDAQ5); list->Add(mapDAQ6);
251 //_______________________________________________________________
252 UInt_t AliGRPPreprocessor::ProcessDaqFxs() {
253 //======DAQ FXS======//
254 TChain *fRawTagChain = new TChain("T");
256 TList* list = GetFileSources(kDAQ);
258 Log("No raw data tag list found!!!");
261 TIterator* iter = list->MakeIterator();
263 while ((obj = iter->Next())) {
264 TObjString* objStr = dynamic_cast<TObjString*> (obj);
266 Log(Form("Found source %s", objStr->String().Data()));
267 TList* list2 = GetFileIDs(kDAQ, objStr->String());
269 Log("No list with ids from DAQ was found!!!");
272 Log(Form("Number of ids: %d",list2->GetEntries()));
273 for(Int_t i = 0; i < list2->GetEntries(); i++) {
274 TObjString *idStr = (TObjString *)list2->At(i);
275 //Log(Form("Filename1: %s",idStr->String().Data()));
276 TString fileName = GetFile(kDAQ,idStr->String().Data(),objStr->String().Data());
277 Log(Form("Adding file in the chain: %s",fileName.Data()));
278 fRawTagChain->Add(fileName.Data());
279 //fRawDataFileName = fileName(0,fileName.First("_"));
286 TString fRawDataFileName = "GRP_Merged.tag.root";
287 Log(Form("Merging raw data tags into file: %s",fRawDataFileName.Data()));
288 fRawTagChain->Merge(fRawDataFileName);
290 TString outputfile = Form("Run%d.Merged.RAW.tag.root", fRun);
291 Bool_t result = StoreRunMetadataFile(fRawDataFileName.Data(),outputfile.Data());
293 return (UInt_t) result;
296 //_______________________________________________________________
297 TList *AliGRPPreprocessor::ProcessDcsDPs(TMap* valueMap, UInt_t iStartTime, UInt_t iStopTime) {
298 //Getting the DCS dps
301 TList *list = new TList();
305 AliInfo(Form("==========LHCState==========="));
306 TObjArray *aliasLHCState = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[0]);
308 Log(Form("LHCState not found!!!"));
311 AliGRPDCS *dcs1 = new AliGRPDCS(aliasLHCState,iStartTime,iStopTime);
312 TString sLHCState = dcs1->ProcessDCS(3);
314 Log(Form("<LHCState> for run %d: %s",fRun, sLHCState.Data()));
316 Log(Form("LHCState not put in TMap!"));
318 TMap *mapDCS1 = new TMap();
319 mapDCS1->Add(new TObjString("fLHCState"),new TObjString(sLHCState));
322 AliInfo(Form("==========LHCPeriod==========="));
323 TObjArray *aliasLHCPeriod = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[1]);
324 if(!aliasLHCPeriod) {
325 Log(Form("LHCPeriod not found!!!"));
328 AliGRPDCS *dcs2 = new AliGRPDCS(aliasLHCPeriod,iStartTime,iStopTime);
329 TString sLHCPeriod = dcs2->ProcessDCS(3);
331 Log(Form("<LHCPeriod> for run %d: %s",fRun, sLHCPeriod.Data()));
333 Log(Form("LHCPeriod not put in TMap!"));
335 TMap *mapDCS2 = new TMap();
336 mapDCS2->Add(new TObjString("fLHCCondition"),new TObjString(sLHCPeriod));
339 AliInfo(Form("==========LHCLuminosity==========="));
340 TObjArray *aliasLHCLuminosity = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[2]);
341 if(!aliasLHCLuminosity) {
342 Log(Form("LHCLuminosity not found!!!"));
345 AliGRPDCS *dcs3 = new AliGRPDCS(aliasLHCLuminosity,iStartTime,iStopTime);
346 TString sMeanLHCLuminosity = dcs3->ProcessDCS(2);
347 if (sMeanLHCLuminosity) {
348 Log(Form("<LHCLuminosity> for run %d: %s",fRun, sMeanLHCLuminosity.Data()));
350 Log(Form("LHCLuminosity not put in TMap!"));
352 TMap *mapDCS3 = new TMap();
353 mapDCS3->Add(new TObjString("fLHCLuminosity"),new TObjString(sMeanLHCLuminosity));
356 AliInfo(Form("==========BeamIntensity==========="));
357 TObjArray *aliasBeamIntensity = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[3]);
358 if(!aliasBeamIntensity) {
359 Log(Form("BeamIntensity not found!!!"));
362 AliGRPDCS *dcs4 = new AliGRPDCS(aliasBeamIntensity,iStartTime,iStopTime);
363 TString sMeanBeamIntensity = dcs4->ProcessDCS(2);
364 if (sMeanBeamIntensity) {
365 Log(Form("<BeamIntensity> for run %d: %s",fRun, sMeanBeamIntensity.Data()));
367 Log(Form("BeamIntensity not put in TMap!"));
369 TMap *mapDCS4 = new TMap();
370 mapDCS4->Add(new TObjString("fBeamIntensity"),new TObjString(sMeanBeamIntensity));
373 AliInfo(Form("==========L3Current==========="));
374 TObjArray *aliasL3Current = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[4]);
375 if(!aliasL3Current) {
376 Log(Form("L3Current not found!!!"));
379 AliGRPDCS *dcs5 = new AliGRPDCS(aliasL3Current,iStartTime,iStopTime);
380 TString sMeanL3Current = dcs5->ProcessDCS(2);
381 if (sMeanL3Current) {
382 Log(Form("<L3Current> for run %d: %s",fRun, sMeanL3Current.Data()));
384 Log(Form("L3Current not put in TMap!"));
386 TMap *mapDCS5 = new TMap();
387 mapDCS5->Add(new TObjString("fL3Current"),new TObjString(sMeanL3Current));
390 AliInfo(Form("==========L3Polarity==========="));
391 TObjArray *aliasL3Polarity = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[5]);
392 if(!aliasL3Polarity) {
393 Log(Form("L3Polarity not found!!!"));
396 AliGRPDCS *dcs6 = new AliGRPDCS(aliasL3Polarity,iStartTime,iStopTime);
397 TString sL3Polarity = dcs6->ProcessDCS(4);
399 Log(Form("<L3Polarity> for run %d: %s",fRun, sL3Polarity.Data()));
401 Log(Form("L3Polarity not put in TMap!"));
403 TMap *mapDCS6 = new TMap();
404 mapDCS6->Add(new TObjString("fL3Polarity"),new TObjString(sL3Polarity));
407 AliInfo(Form("==========DipoleCurrent==========="));
408 TObjArray *aliasDipoleCurrent = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[6]);
409 if(!aliasDipoleCurrent) {
410 Log(Form("DipoleCurrent not found!!!"));
413 AliGRPDCS *dcs7 = new AliGRPDCS(aliasDipoleCurrent,iStartTime,iStopTime);
414 TString sMeanDipoleCurrent = dcs7->ProcessDCS(2);
415 if (sMeanDipoleCurrent) {
416 Log(Form("<DipoleCurrent> for run %d: %s",fRun, sMeanDipoleCurrent.Data()));
418 Log(Form("DipoleCurrent not put in TMap!"));
420 TMap *mapDCS7 = new TMap();
421 mapDCS7->Add(new TObjString("fDipoleCurrent"),new TObjString(sMeanDipoleCurrent));
424 AliInfo(Form("==========DipolePolarity==========="));
425 TObjArray *aliasDipolePolarity = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[7]);
426 if(!aliasDipolePolarity) {
427 Log(Form("DipolePolarity not found!!!"));
430 AliGRPDCS *dcs8 = new AliGRPDCS(aliasDipolePolarity,iStartTime,iStopTime);
431 TString sDipolePolarity = dcs8->ProcessDCS(4);
432 if (sDipolePolarity) {
433 Log(Form("<DipolePolarity> for run %d: %s",fRun, sDipolePolarity.Data()));
435 Log(Form("DipolePolarity not put in TMap!"));
437 TMap *mapDCS8 = new TMap();
438 mapDCS8->Add(new TObjString("fDipolePolarity"),new TObjString(sDipolePolarity));
441 AliInfo(Form("==========CavernTemperature==========="));
442 TObjArray *aliasCavernTemperature = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[8]);
443 if(!aliasCavernTemperature) {
444 Log(Form("CavernTemperature not found!!!"));
447 AliGRPDCS *dcs9 = new AliGRPDCS(aliasCavernTemperature,iStartTime,iStopTime);
448 TString sMeanCavernTemperature = dcs9->ProcessDCS(2);
449 if (sMeanCavernTemperature) {
450 Log(Form("<CavernTemperature> for run %d: %s",fRun, sMeanCavernTemperature.Data()));
452 Log(Form("CavernTemperature not put in TMap!"));
454 TMap *mapDCS9 = new TMap();
455 mapDCS9->Add(new TObjString("fCavernTemperature"),new TObjString(sMeanCavernTemperature));
458 AliInfo(Form("==========CavernPressure==========="));
459 TObjArray *aliasCavernPressure = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[9]);
460 if(!aliasCavernPressure) {
461 Log(Form("CavernPressure not found!!!"));
464 AliGRPDCS *dcs10 = new AliGRPDCS(aliasCavernPressure,iStartTime,iStopTime);
465 TString sMeanCavernPressure = dcs10->ProcessDCS(2);
466 if (sMeanCavernPressure) {
467 Log(Form("<CavernPressure> for run %d: %s",fRun, sMeanCavernPressure.Data()));
469 Log(Form("CavernPressure not put in TMap!"));
471 TMap *mapDCS10 = new TMap();
472 mapDCS10->Add(new TObjString("fCavernPressure"),new TObjString(sMeanCavernPressure));
478 //_______________________________________________________________
479 AliDCSSensorArray *AliGRPPreprocessor::GetPressureMap(TMap* dcsAliasMap, AliDCSSensorArray *fPressure) {
480 // extract DCS pressure maps. Perform fits to save space
482 TMap *map = fPressure->ExtractDCS(dcsAliasMap);
484 fPressure->MakeSplineFit(map);
485 Double_t fitFraction = fPressure->NumFits()/fPressure->NumSensors();
486 if (fitFraction > kFitFraction ) {
487 AliInfo(Form("Pressure values extracted, fits performed.\n"));
489 AliInfo("Too few pressure maps fitted. \n");
492 AliInfo("AliGRPDCS: no atmospheric pressure map extracted. \n");
499 //_______________________________________________________________
500 /*UInt_t AliGRPPreprocessor::MapPressure(TMap* dcsAliasMap) {
501 // extract DCS pressure maps. Perform fits to save space
504 TMap *map = fPressure->ExtractDCS(dcsAliasMap);
506 fPressure->MakeSplineFit(map);
507 Double_t fitFraction = fPressure->NumFits()/fPressure->NumSensors();
508 if (fitFraction > kFitFraction ) {
509 AliInfo(Form("Pressure values extracted, fits performed.\n"));
511 Log ("Too few pressure maps fitted. \n");
515 Log("AliTPCPreprocsessor: no atmospheric pressure map extracted. \n");
519 // Now store the final CDB file
522 AliCDBMetaData metaData;
523 metaData.SetBeamPeriod(0);
524 metaData.SetResponsible("Panos Christakoglou");
525 metaData.SetComment("Preprocessor AliGRP data base pressure entries.");
527 Bool_t storeOK = Store("Calib", "Pressure", fPressure, &metaData, 0, 0);
528 if ( !storeOK ) result=1;