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>
30 #include "AliGRPPreprocessor.h"
31 #include "AliGRPDCS.h"
32 #include "AliDCSSensorArray.h"
34 #include "AliCDBMetaData.h"
38 class AliShuttleInterface;
42 const Double_t kFitFraction = 0.7; // Fraction of DCS sensor fits required
44 ClassImp(AliGRPPreprocessor)
46 //_______________________________________________________________
47 const char* AliGRPPreprocessor::fgkDCSDataPoints[12] = {"LHCState","LHCPeriod","LHCLuminosity","BeamIntensity","L3Current","L3Polarity","DipoleCurrent","DipolePolarity","CavernTemperature","CavernAtmosPressure","gva_cr5AtmosphericPressure","gva_meyrinAtmosphericPressure"};
49 //_______________________________________________________________
50 AliGRPPreprocessor::AliGRPPreprocessor():
51 AliPreprocessor("GRP",0), fPressure(0) {
52 // default constructor - Don't use this!
56 //_______________________________________________________________
57 AliGRPPreprocessor::AliGRPPreprocessor(AliShuttleInterface* shuttle):
58 AliPreprocessor("GRP",shuttle), fPressure(0) {
59 // constructor - shuttle must be instantiated!
63 //_______________________________________________________________
64 AliGRPPreprocessor::~AliGRPPreprocessor() {
69 //_______________________________________________________________
70 void AliGRPPreprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime) {
71 // Initialize preprocessor
73 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run, TTimeStamp(startTime).AsString(), TTimeStamp(endTime).AsString()));
76 fStartTime = startTime;
78 AliInfo("Initialization of the GRP preprocessor.");
80 TClonesArray * array = new TClonesArray("AliDCSSensor",2);
81 for(Int_t j = 0; j < 2; j++) {
82 AliDCSSensor * sens = new ((*array)[j])AliDCSSensor;
83 sens->SetStringID(fgkDCSDataPoints[j+10]);
85 AliInfo(Form("Pressure Entries: %d",array->GetEntries()));
87 fPressure = new AliDCSSensorArray(fStartTime, fEndTime, array);
90 //_______________________________________________________________
91 UInt_t AliGRPPreprocessor::Process(TMap* valueMap) {
92 // process data retrieved by the Shuttle
97 TList *daqlblist = ProcessDaqLB();
99 Log(Form("Problem with the DAQ logbook parameters!!!"));
102 TMap *m1 = (TMap *)daqlblist->At(0);
103 TObjString *s1 = (TObjString *)m1->GetValue("fAliceStartTime");
104 UInt_t iStartTime = atoi(s1->String().Data());
105 TMap *m2 = (TMap *)daqlblist->At(1);
106 TObjString *s2 = (TObjString *)m2->GetValue("fAliceStopTime");
107 UInt_t iStopTime = atoi(s2->String().Data());
108 TMap *m3 = (TMap *)daqlblist->At(6);
109 TObjString *s3 = (TObjString *)m3->GetValue("fLHCPeriod");
110 TString productionYear = "";
112 //=================//
114 //=================//
115 UInt_t iDaqFxs = ProcessDaqFxs(s3->String(),productionYear);
116 if(iDaqFxs == 0) Log(Form("Raw data merged tags copied succesfully in AliEn!!!"));
118 //=================//
119 // DCS data points //
120 //=================//
121 TList *dcsdplist = ProcessDcsDPs(valueMap, iStartTime, iStopTime);
123 Log(Form("Problem with the DCS data points!!!"));
126 if(dcsdplist->GetEntries() != 10) {
127 Log(Form("Problem with the DCS data points!!!"));
130 //NEEDS TO BE REVISED - BREAKS!!!
131 // AliDCSSensorArray *dcsSensorArray = GetPressureMap(valueMap,fPressure);
132 // if(!dcsSensorArray) {
133 // Log(Form("Problem with the pressure sensor values!!!"));
137 TList * list = new TList();
138 list = GetGlobalList(daqlblist,dcsdplist);
140 AliInfo(Form("Final list entries: %d",list->GetEntries()));
143 md.SetResponsible("Panos Christakoglou");
144 md.SetComment("Output parameters from the GRP preprocessor.");
146 Bool_t result = Store("GRP", "Data", list, &md);
156 //_______________________________________________________________
157 TList *AliGRPPreprocessor::GetGlobalList(TList *l1, TList *l2) {
158 //Getting the global output TList
159 TList *list = new TList();
160 TMap *map = new TMap();
161 for(Int_t i = 0; i < l1->GetEntries(); i++)
162 list->AddLast(map = (TMap *)l1->At(i));
163 for(Int_t i = 0; i < l2->GetEntries(); i++)
164 list->AddLast(map = (TMap *)l2->At(i));
169 //_______________________________________________________________
170 TList *AliGRPPreprocessor::ProcessDaqLB() {
171 //Getting the DAQ lb informnation
172 const char* timeStart = GetRunParameter("time_start");
173 const char* timeEnd = GetRunParameter("time_end");
174 const char* beamEnergy = GetRunParameter("beamEnergy");
175 const char* beamType = GetRunParameter("beamType");
176 const char* numberOfDetectors = GetRunParameter("numberOfDetectors");
177 const char* detectorMask = GetRunParameter("detectorMask");
178 const char* lhcPeriod = GetRunParameter("LHCperiod");
181 Log(Form("Start time for run %d: %s",fRun, timeStart));
183 Log(Form("Start time not put in logbook!"));
185 TMap *mapDAQ1 = new TMap();
186 mapDAQ1->Add(new TObjString("fAliceStartTime"),new TObjString(timeStart));
189 Log(Form("End time for run %d: %s",fRun, timeEnd));
191 Log(Form("End time not put in logbook!"));
193 TMap *mapDAQ2 = new TMap();
194 mapDAQ2->Add(new TObjString("fAliceStopTime"),new TObjString(timeEnd));
197 Log(Form("Beam energy for run %d: %s",fRun, beamEnergy));
199 Log(Form("Beam energy not put in logbook!"));
201 TMap *mapDAQ3 = new TMap();
202 mapDAQ3->Add(new TObjString("fAliceBeamEnergy"),new TObjString(beamEnergy));
205 Log(Form("Beam type for run %d: %s",fRun, beamType));
207 Log(Form("Beam type not put in logbook!"));
209 TMap *mapDAQ4 = new TMap();
210 mapDAQ4->Add(new TObjString("fAliceBeamType"),new TObjString(beamType));
212 if (numberOfDetectors) {
213 Log(Form("Number of active detectors for run %d: %s",fRun, numberOfDetectors));
215 Log(Form("Number of active detectors not put in logbook!"));
217 TMap *mapDAQ5 = new TMap();
218 mapDAQ5->Add(new TObjString("fNumberOfDetectors"),new TObjString(numberOfDetectors));
221 Log(Form("Detector mask for run %d: %s",fRun, detectorMask));
223 Log(Form("Detector mask not put in logbook!"));
225 TMap *mapDAQ6 = new TMap();
226 mapDAQ6->Add(new TObjString("fDetectorMask"),new TObjString(detectorMask));
229 Log(Form("LHC period (DAQ) for run %d: %s",fRun, lhcPeriod));
231 Log(Form("LHCperiod not put in logbook!"));
233 TMap *mapDAQ7 = new TMap();
234 mapDAQ7->Add(new TObjString("fLHCPeriod"),new TObjString(lhcPeriod));
236 TList *list = new TList();
237 list->Add(mapDAQ1); list->Add(mapDAQ2);
238 list->Add(mapDAQ3); list->Add(mapDAQ4);
239 list->Add(mapDAQ5); list->Add(mapDAQ6);
245 //_______________________________________________________________
246 UInt_t AliGRPPreprocessor::ProcessDaqFxs(TString lhcperiod, TString productionYear) {
247 //======DAQ FXS======//
248 TChain *fRawTagChain = new TChain("T");
249 TString fRawDataFileName;
250 TList* list = GetFileSources(kDAQ);
252 Log("No raw data tag list found!!!");
255 TIterator* iter = list->MakeIterator();
257 while ((obj = iter->Next())) {
258 TObjString* objStr = dynamic_cast<TObjString*> (obj);
260 Log(Form("Found source %s", objStr->String().Data()));
261 TList* list2 = GetFileIDs(kDAQ, objStr->String());
263 Log("No list with ids from DAQ was found!!!");
266 Log(Form("Number of ids: %d",list2->GetEntries()));
267 for(Int_t i = 0; i < list2->GetEntries(); i++) {
268 TObjString *idStr = (TObjString *)list2->At(i);
269 //Log(Form("Filename1: %s",idStr->String().Data()));
270 TString fileName = GetFile(kDAQ,idStr->String().Data(),objStr->String().Data());
271 Log(Form("Adding file in the chain: %s",fileName.Data()));
272 fRawTagChain->Add(fileName.Data());
273 fRawDataFileName = fileName(0,fileName.First("_"));
280 fRawDataFileName += "_GRP_Merged.tag.root";
281 Log(Form("Merging raw data tags into file: %s",fRawDataFileName.Data()));
283 TString outputfile = "alien:///alice/data/";
284 outputfile += productionYear.Data(); outputfile += "/";
285 outputfile += lhcperiod.Data(); outputfile += "/";
286 outputfile += fRun; outputfile += "/raw/";
287 //StoreTagFiles(fRawDataFileName.Data(),outputfile.Data());
292 //_______________________________________________________________
293 TList *AliGRPPreprocessor::ProcessDcsDPs(TMap* valueMap, UInt_t iStartTime, UInt_t iStopTime) {
294 //Getting the DCS dps
297 TList *list = new TList();
301 AliInfo(Form("==========LHCState==========="));
302 TObjArray *aliasLHCState = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[0]);
304 Log(Form("LHCState not found!!!"));
307 AliGRPDCS *dcs1 = new AliGRPDCS(aliasLHCState,iStartTime,iStopTime);
308 TString sLHCState = dcs1->ProcessDCS(3);
310 Log(Form("<LHCState> for run %d: %s",fRun, sLHCState.Data()));
312 Log(Form("LHCState not put in TMap!"));
314 TMap *mapDCS1 = new TMap();
315 mapDCS1->Add(new TObjString("fLHCState"),new TObjString(sLHCState));
318 AliInfo(Form("==========LHCPeriod==========="));
319 TObjArray *aliasLHCPeriod = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[1]);
320 if(!aliasLHCPeriod) {
321 Log(Form("LHCPeriod not found!!!"));
324 AliGRPDCS *dcs2 = new AliGRPDCS(aliasLHCPeriod,iStartTime,iStopTime);
325 TString sLHCPeriod = dcs2->ProcessDCS(3);
327 Log(Form("<LHCPeriod> for run %d: %s",fRun, sLHCPeriod.Data()));
329 Log(Form("LHCPeriod not put in TMap!"));
331 TMap *mapDCS2 = new TMap();
332 mapDCS2->Add(new TObjString("fLHCCondition"),new TObjString(sLHCPeriod));
335 AliInfo(Form("==========LHCLuminosity==========="));
336 TObjArray *aliasLHCLuminosity = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[2]);
337 if(!aliasLHCLuminosity) {
338 Log(Form("LHCLuminosity not found!!!"));
341 AliGRPDCS *dcs3 = new AliGRPDCS(aliasLHCLuminosity,iStartTime,iStopTime);
342 TString sMeanLHCLuminosity = dcs3->ProcessDCS(2);
343 if (sMeanLHCLuminosity) {
344 Log(Form("<LHCLuminosity> for run %d: %s",fRun, sMeanLHCLuminosity.Data()));
346 Log(Form("LHCLuminosity not put in TMap!"));
348 TMap *mapDCS3 = new TMap();
349 mapDCS3->Add(new TObjString("fLHCLuminosity"),new TObjString(sMeanLHCLuminosity));
352 AliInfo(Form("==========BeamIntensity==========="));
353 TObjArray *aliasBeamIntensity = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[3]);
354 if(!aliasBeamIntensity) {
355 Log(Form("BeamIntensity not found!!!"));
358 AliGRPDCS *dcs4 = new AliGRPDCS(aliasBeamIntensity,iStartTime,iStopTime);
359 TString sMeanBeamIntensity = dcs4->ProcessDCS(2);
360 if (sMeanBeamIntensity) {
361 Log(Form("<BeamIntensity> for run %d: %s",fRun, sMeanBeamIntensity.Data()));
363 Log(Form("BeamIntensity not put in TMap!"));
365 TMap *mapDCS4 = new TMap();
366 mapDCS4->Add(new TObjString("fBeamIntensity"),new TObjString(sMeanBeamIntensity));
369 AliInfo(Form("==========L3Current==========="));
370 TObjArray *aliasL3Current = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[4]);
371 if(!aliasL3Current) {
372 Log(Form("L3Current not found!!!"));
375 AliGRPDCS *dcs5 = new AliGRPDCS(aliasL3Current,iStartTime,iStopTime);
376 TString sMeanL3Current = dcs5->ProcessDCS(2);
377 if (sMeanL3Current) {
378 Log(Form("<L3Current> for run %d: %s",fRun, sMeanL3Current.Data()));
380 Log(Form("L3Current not put in TMap!"));
382 TMap *mapDCS5 = new TMap();
383 mapDCS5->Add(new TObjString("fL3Current"),new TObjString(sMeanL3Current));
386 AliInfo(Form("==========L3Polarity==========="));
387 TObjArray *aliasL3Polarity = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[5]);
388 if(!aliasL3Polarity) {
389 Log(Form("L3Polarity not found!!!"));
392 AliGRPDCS *dcs6 = new AliGRPDCS(aliasL3Polarity,iStartTime,iStopTime);
393 TString sL3Polarity = dcs6->ProcessDCS(4);
395 Log(Form("<L3Polarity> for run %d: %s",fRun, sL3Polarity.Data()));
397 Log(Form("L3Polarity not put in TMap!"));
399 TMap *mapDCS6 = new TMap();
400 mapDCS6->Add(new TObjString("fL3Polarity"),new TObjString(sL3Polarity));
403 AliInfo(Form("==========DipoleCurrent==========="));
404 TObjArray *aliasDipoleCurrent = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[6]);
405 if(!aliasDipoleCurrent) {
406 Log(Form("DipoleCurrent not found!!!"));
409 AliGRPDCS *dcs7 = new AliGRPDCS(aliasDipoleCurrent,iStartTime,iStopTime);
410 TString sMeanDipoleCurrent = dcs7->ProcessDCS(2);
411 if (sMeanDipoleCurrent) {
412 Log(Form("<DipoleCurrent> for run %d: %s",fRun, sMeanDipoleCurrent.Data()));
414 Log(Form("DipoleCurrent not put in TMap!"));
416 TMap *mapDCS7 = new TMap();
417 mapDCS7->Add(new TObjString("fDipoleCurrent"),new TObjString(sMeanDipoleCurrent));
420 AliInfo(Form("==========DipolePolarity==========="));
421 TObjArray *aliasDipolePolarity = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[7]);
422 if(!aliasDipolePolarity) {
423 Log(Form("DipolePolarity not found!!!"));
426 AliGRPDCS *dcs8 = new AliGRPDCS(aliasDipolePolarity,iStartTime,iStopTime);
427 TString sDipolePolarity = dcs8->ProcessDCS(4);
428 if (sDipolePolarity) {
429 Log(Form("<DipolePolarity> for run %d: %s",fRun, sDipolePolarity.Data()));
431 Log(Form("DipolePolarity not put in TMap!"));
433 TMap *mapDCS8 = new TMap();
434 mapDCS8->Add(new TObjString("fDipolePolarity"),new TObjString(sDipolePolarity));
437 AliInfo(Form("==========CavernTemperature==========="));
438 TObjArray *aliasCavernTemperature = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[8]);
439 if(!aliasCavernTemperature) {
440 Log(Form("CavernTemperature not found!!!"));
443 AliGRPDCS *dcs9 = new AliGRPDCS(aliasCavernTemperature,iStartTime,iStopTime);
444 TString sMeanCavernTemperature = dcs9->ProcessDCS(2);
445 if (sMeanCavernTemperature) {
446 Log(Form("<CavernTemperature> for run %d: %s",fRun, sMeanCavernTemperature.Data()));
448 Log(Form("CavernTemperature not put in TMap!"));
450 TMap *mapDCS9 = new TMap();
451 mapDCS9->Add(new TObjString("fCavernTemperature"),new TObjString(sMeanCavernTemperature));
454 AliInfo(Form("==========CavernPressure==========="));
455 TObjArray *aliasCavernPressure = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[9]);
456 if(!aliasCavernPressure) {
457 Log(Form("CavernPressure not found!!!"));
460 AliGRPDCS *dcs10 = new AliGRPDCS(aliasCavernPressure,iStartTime,iStopTime);
461 TString sMeanCavernPressure = dcs10->ProcessDCS(2);
462 if (sMeanCavernPressure) {
463 Log(Form("<CavernPressure> for run %d: %s",fRun, sMeanCavernPressure.Data()));
465 Log(Form("CavernPressure not put in TMap!"));
467 TMap *mapDCS10 = new TMap();
468 mapDCS10->Add(new TObjString("fCavernPressure"),new TObjString(sMeanCavernPressure));
474 //_______________________________________________________________
475 AliDCSSensorArray *AliGRPPreprocessor::GetPressureMap(TMap* dcsAliasMap, AliDCSSensorArray *fPressure) {
476 // extract DCS pressure maps. Perform fits to save space
478 TMap *map = fPressure->ExtractDCS(dcsAliasMap);
480 fPressure->MakeSplineFit(map);
481 Double_t fitFraction = fPressure->NumFits()/fPressure->NumSensors();
482 if (fitFraction > kFitFraction ) {
483 AliInfo(Form("Pressure values extracted, fits performed.\n"));
485 AliInfo("Too few pressure maps fitted. \n");
488 AliInfo("AliGRPDCS: no atmospheric pressure map extracted. \n");
495 //_______________________________________________________________
496 /*UInt_t AliGRPPreprocessor::MapPressure(TMap* dcsAliasMap) {
497 // extract DCS pressure maps. Perform fits to save space
500 TMap *map = fPressure->ExtractDCS(dcsAliasMap);
502 fPressure->MakeSplineFit(map);
503 Double_t fitFraction = fPressure->NumFits()/fPressure->NumSensors();
504 if (fitFraction > kFitFraction ) {
505 AliInfo(Form("Pressure values extracted, fits performed.\n"));
507 Log ("Too few pressure maps fitted. \n");
511 Log("AliTPCPreprocsessor: no atmospheric pressure map extracted. \n");
515 // Now store the final CDB file
518 AliCDBMetaData metaData;
519 metaData.SetBeamPeriod(0);
520 metaData.SetResponsible("Panos Christakoglou");
521 metaData.SetComment("Preprocessor AliGRP data base pressure entries.");
523 Bool_t storeOK = Store("Calib", "Pressure", fPressure, &metaData, 0, 0);
524 if ( !storeOK ) result=1;