]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliGRPPreprocessor.cxx
commented logging message
[u/mrichter/AliRoot.git] / STEER / AliGRPPreprocessor.cxx
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 <TList.h>
25 #include <TMap.h>
26 #include <TObjString.h>
27 #include <TTimeStamp.h>
28
29 #include "AliGRPPreprocessor.h"
30 #include "AliGRPDCS.h"
31
32 #include "AliCDBMetaData.h"
33 #include "AliLog.h"
34
35 class AliDCSValue;
36 class AliShuttleInterface;
37
38 #include <TH1.h>
39
40 ClassImp(AliGRPPreprocessor)
41
42 //_______________________________________________________________
43 AliGRPPreprocessor::AliGRPPreprocessor():
44   AliPreprocessor("GRP",0) {
45   // default constructor - Don't use this!
46   
47 }
48
49 //_______________________________________________________________
50 AliGRPPreprocessor::AliGRPPreprocessor(AliShuttleInterface* shuttle):
51   AliPreprocessor("GRP",shuttle) {
52   // constructor - shuttle must be instantiated!
53   
54 }
55
56 //_______________________________________________________________
57 AliGRPPreprocessor::~AliGRPPreprocessor() {
58   //destructor
59 }
60
61 //_______________________________________________________________
62 void AliGRPPreprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime) {
63   // Initialize preprocessor
64   
65   AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run, TTimeStamp(startTime).AsString(), TTimeStamp(endTime).AsString()));
66   
67   fRun = run;
68   fStartTime = startTime;
69   fEndTime = endTime;
70   AliInfo("This preprocessor is to test the GetRunParameter function.");
71 }
72
73 //_______________________________________________________________
74 UInt_t AliGRPPreprocessor::Process(TMap* valueMap) {
75   // process data retrieved by the Shuttle
76   const char* timeStart = GetRunParameter("time_start");
77   UInt_t iStartTime = atoi(timeStart);
78   const char* timeEnd = GetRunParameter("time_end");
79   UInt_t iStopTime = atoi(timeEnd);
80   const char* beamEnergy = GetRunParameter("beamEnergy");
81   const char* beamType = GetRunParameter("beamType");
82   const char* numberOfDetectors = GetRunParameter("numberOfDetectors");
83   const char* detectorMask = GetRunParameter("detectorMask");
84   const char* lhcPeriod = GetRunParameter("LHCperiod");
85
86   TList* list = GetFileSources(kDAQ);
87   TIterator* iter = list->MakeIterator();
88   TObject* obj = 0;
89   while ((obj = iter->Next()))
90   {
91         TObjString* objStr = dynamic_cast<TObjString*> (obj);
92         if (objStr)
93         {
94                 Log(Form("Found source %s", objStr->String().Data()));
95                 TList* list2 = GetFileIDs(kDAQ, objStr->String());
96                 list2->Print();
97                 delete list2;
98         }
99    }
100    delete iter;
101    delete list;  
102   
103   //===========//
104   //DCS data points
105   //===========//
106   TObjArray *aliasLHCState = (TObjArray *)valueMap->GetValue("LHCState");
107   if(!aliasLHCState) {
108     Log(Form("LHCState not found!!!"));
109     return 1;
110   }
111   AliGRPDCS *dcs1 = new AliGRPDCS(aliasLHCState,iStartTime,iStopTime);
112   TString sLHCState = dcs1->ProcessDCS(3);  
113   if (sLHCState) {
114     Log(Form("<LHCState> for run %d: %s",fRun, sLHCState.Data()));
115   } else {
116     Log(Form("LHCState not put in TMap!"));
117   }
118
119   TObjArray *aliasLHCPeriod = (TObjArray *)valueMap->GetValue("LHCPeriod");
120   if(!aliasLHCPeriod) {
121     Log(Form("LHCPeriod not found!!!"));
122     return 1;
123   }
124   AliGRPDCS *dcs2 = new AliGRPDCS(aliasLHCPeriod,iStartTime,iStopTime);
125   TString sLHCPeriod = dcs2->ProcessDCS(3);  
126   if (sLHCPeriod) {
127     Log(Form("<LHCPeriod> for run %d: %s",fRun, sLHCPeriod.Data()));
128   } else {
129     Log(Form("LHCPeriod not put in TMap!"));
130   }
131
132   TObjArray *aliasLHCLuminosity = (TObjArray *)valueMap->GetValue("LHCLuminosity");
133   if(!aliasLHCLuminosity) {
134     Log(Form("LHCLuminosity not found!!!"));
135     return 1;
136   }
137   AliGRPDCS *dcs3 = new AliGRPDCS(aliasLHCLuminosity,iStartTime,iStopTime);
138   TString sMeanLHCLuminosity = dcs3->ProcessDCS(2);  
139   if (sMeanLHCLuminosity) {
140     Log(Form("<LHCLuminosity> for run %d: %s",fRun, sMeanLHCLuminosity.Data()));
141   } else {
142     Log(Form("LHCLuminosity not put in TMap!"));
143   }
144
145   TObjArray *aliasBeamIntensity = (TObjArray *)valueMap->GetValue("BeamIntensity");
146   if(!aliasBeamIntensity) {
147     Log(Form("BeamIntensity not found!!!"));
148     return 1;
149   }
150   AliGRPDCS *dcs4 = new AliGRPDCS(aliasBeamIntensity,iStartTime,iStopTime);
151   TString sMeanBeamIntensity = dcs4->ProcessDCS(2);  
152   if (sMeanBeamIntensity) {
153     Log(Form("<BeamIntensity> for run %d: %s",fRun, sMeanBeamIntensity.Data()));
154   } else {
155     Log(Form("BeamIntensity not put in TMap!"));
156   }
157
158   TObjArray *aliasL3Current = (TObjArray *)valueMap->GetValue("L3Current");
159   if(!aliasL3Current) {
160     Log(Form("L3Current not found!!!"));
161     return 1;
162   }
163   AliGRPDCS *dcs5 = new AliGRPDCS(aliasL3Current,iStartTime,iStopTime);
164   TString sMeanL3Current = dcs5->ProcessDCS(2);  
165   if (sMeanL3Current) {
166     Log(Form("<L3Current> for run %d: %s",fRun, sMeanL3Current.Data()));
167   } else {
168     Log(Form("L3Current not put in TMap!"));
169   }
170
171   TObjArray *aliasL3Polarity = (TObjArray *)valueMap->GetValue("L3Polarity");
172   if(!aliasL3Polarity) {
173     Log(Form("L3Polarity not found!!!"));
174     return 1;
175   }
176   AliGRPDCS *dcs6 = new AliGRPDCS(aliasL3Polarity,iStartTime,iStopTime);
177   TString sL3Polarity = dcs6->ProcessDCS(4);  
178   if (sL3Polarity) {
179     Log(Form("<L3Polarity> for run %d: %s",fRun, sL3Polarity.Data()));
180   } else {
181     Log(Form("L3Polarity not put in TMap!"));
182   }
183
184   TObjArray *aliasDipoleCurrent = (TObjArray *)valueMap->GetValue("DipoleCurrent");
185   if(!aliasDipoleCurrent) {
186     Log(Form("DipoleCurrent not found!!!"));
187     return 1;
188   }
189   AliGRPDCS *dcs7 = new AliGRPDCS(aliasDipoleCurrent,iStartTime,iStopTime);
190   TString sMeanDipoleCurrent = dcs7->ProcessDCS(2);  
191   if (sMeanDipoleCurrent) {
192     Log(Form("<DipoleCurrent> for run %d: %s",fRun, sMeanDipoleCurrent.Data()));
193   } else {
194     Log(Form("DipoleCurrent not put in TMap!"));
195   }
196
197   TObjArray *aliasDipolePolarity = (TObjArray *)valueMap->GetValue("DipolePolarity");
198   if(!aliasDipolePolarity) {
199     Log(Form("DipolePolarity not found!!!"));
200     return 1;
201   }
202   AliGRPDCS *dcs8 = new AliGRPDCS(aliasDipolePolarity,iStartTime,iStopTime);
203   TString sDipolePolarity = dcs8->ProcessDCS(4);  
204   if (sDipolePolarity) {
205     Log(Form("<DipolePolarity> for run %d: %s",fRun, sDipolePolarity.Data()));
206   } else {
207     Log(Form("DipolePolarity not put in TMap!"));
208   }
209
210   TObjArray *aliasCavernTemperature = (TObjArray *)valueMap->GetValue("CavernTemperature");
211   if(!aliasCavernTemperature) {
212     Log(Form("CavernTemperature not found!!!"));
213     return 1;
214   }
215   AliGRPDCS *dcs9 = new AliGRPDCS(aliasCavernTemperature,iStartTime,iStopTime);
216   TString sMeanCavernTemperature = dcs9->ProcessDCS(2);  
217   if (sMeanCavernTemperature) {
218     Log(Form("<CavernTemperature> for run %d: %s",fRun, sMeanCavernTemperature.Data()));
219   } else {
220     Log(Form("CavernTemperature not put in TMap!"));
221   }
222
223   TObjArray *aliasCavernPressure = (TObjArray *)valueMap->GetValue("CavernPressure");
224   if(!aliasCavernPressure) {
225     Log(Form("CavernPressure not found!!!"));
226     return 1;
227   }
228   AliGRPDCS *dcs10 = new AliGRPDCS(aliasCavernPressure,iStartTime,iStopTime);
229   TString sMeanCavernPressure = dcs10->ProcessDCS(2);  
230   if (sMeanCavernPressure) {
231     Log(Form("<CavernPressure> for run %d: %s",fRun, sMeanCavernPressure.Data()));
232   } else {
233     Log(Form("CavernPressure not put in TMap!"));
234   }
235
236   //===========//
237   //DAQ logbook
238   //===========//
239   if (timeStart) {
240     Log(Form("Start time for run %d: %s",fRun, timeStart));
241   } else {
242     Log(Form("Start time not put in logbook!"));
243   }
244   if (timeEnd) {
245     Log(Form("End time for run %d: %s",fRun, timeEnd));
246   } else {
247     Log(Form("End time not put in logbook!"));
248   }
249   if (beamEnergy) {
250     Log(Form("Beam energy for run %d: %s",fRun, beamEnergy));
251   } else {
252     Log(Form("Beam energy not put in logbook!"));
253   }
254   if (beamType) {
255     Log(Form("Beam type for run %d: %s",fRun, beamType));
256   } else {
257     Log(Form("Beam type not put in logbook!"));
258   }
259   if (numberOfDetectors) {
260     Log(Form("Number of active detectors for run %d: %s",fRun, numberOfDetectors));
261   } else {
262     Log(Form("Number of active detectors not put in logbook!"));
263   }
264   if (detectorMask) {
265     Log(Form("Detector mask for run %d: %s",fRun, detectorMask));
266   } else {
267     Log(Form("Detector mask not put in logbook!"));
268   }
269   if (lhcPeriod) {
270     Log(Form("LHC period (DAQ) for run %d: %s",fRun, lhcPeriod));
271   } else {
272     Log(Form("LHCperiod not put in logbook!"));
273   }
274
275   TList *values = new TList();
276   values->SetOwner(1);
277   
278   //DAQ logbook
279   TMap *mapDAQ1 = new TMap();
280   mapDAQ1->Add(new TObjString("fAliceStartTime"),new TObjString(timeStart));
281   values->Add(mapDAQ1);
282
283   TMap *mapDAQ2 = new TMap();
284   mapDAQ2->Add(new TObjString("fAliceStopTime"),new TObjString(timeEnd));
285   values->Add(mapDAQ2);
286
287   TMap *mapDAQ3 = new TMap();
288   mapDAQ3->Add(new TObjString("fAliceBeamEnergy"),new TObjString(beamEnergy));
289   values->Add(mapDAQ3);
290
291   TMap *mapDAQ4 = new TMap();
292   mapDAQ4->Add(new TObjString("fAliceBeamType"),new TObjString(beamType));
293   values->Add(mapDAQ4);
294
295   TMap *mapDAQ5 = new TMap();
296   mapDAQ5->Add(new TObjString("fNumberOfDetectors"),new TObjString(numberOfDetectors));
297   values->Add(mapDAQ5);
298
299   TMap *mapDAQ6 = new TMap();
300   mapDAQ6->Add(new TObjString("fDetectorMask"),new TObjString(detectorMask));
301   values->Add(mapDAQ6);
302
303   TMap *mapDAQ7 = new TMap();
304   mapDAQ7->Add(new TObjString("fLHCPeriod"),new TObjString(lhcPeriod));
305   values->Add(mapDAQ7);
306
307   //DCS dp
308   TMap *mapDCS1 = new TMap();
309   mapDCS1->Add(new TObjString("fLHCState"),new TObjString(sLHCState));
310   values->Add(mapDCS1);
311
312   TMap *mapDCS2 = new TMap();
313   mapDCS2->Add(new TObjString("fLHCCondition"),new TObjString(sLHCPeriod));
314   values->Add(mapDCS2);
315
316   TMap *mapDCS3 = new TMap();
317   mapDCS3->Add(new TObjString("fLHCLuminosity"),new TObjString(sMeanLHCLuminosity));
318   values->Add(mapDCS3);
319
320   TMap *mapDCS4 = new TMap();
321   mapDCS4->Add(new TObjString("fBeamIntensity"),new TObjString(sMeanBeamIntensity));
322   values->Add(mapDCS4);
323
324   TMap *mapDCS5 = new TMap();
325   mapDCS5->Add(new TObjString("fL3Current"),new TObjString(sMeanL3Current));
326   values->Add(mapDCS5);
327
328   TMap *mapDCS6 = new TMap();
329   mapDCS6->Add(new TObjString("fL3Polarity"),new TObjString(sL3Polarity));
330   values->Add(mapDCS6);
331
332   TMap *mapDCS7 = new TMap();
333   mapDCS7->Add(new TObjString("fDipoleCurrent"),new TObjString(sMeanDipoleCurrent));
334   values->Add(mapDCS7);
335
336   TMap *mapDCS8 = new TMap();
337   mapDCS8->Add(new TObjString("fDipolePolarity"),new TObjString(sDipolePolarity));
338   values->Add(mapDCS8);
339
340   TMap *mapDCS9 = new TMap();
341   mapDCS9->Add(new TObjString("fCavernTemperature"),new TObjString(sMeanCavernTemperature));
342   values->Add(mapDCS9);
343
344   TMap *mapDCS10 = new TMap();
345   mapDCS10->Add(new TObjString("fCavernPressure"),new TObjString(sMeanCavernPressure));
346   values->Add(mapDCS10);
347
348   AliCDBMetaData md;
349   md.SetResponsible("Panos");
350   
351   Bool_t result = Store("GRP", "Values", values, &md);
352   
353   delete values;
354   
355   if (result)
356     return 0;
357   else
358     return 1;
359 }
360