]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliGRPPreprocessor.cxx
Two new classes added (Marian)
[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   //===========//
87   //DCS data points
88   //===========//
89   TObjArray *aliasLHCState = (TObjArray *)valueMap->GetValue("LHCState");
90   if(!aliasLHCState) {
91     Log(Form("LHCState not found!!!"));
92     return 0;
93   }
94   AliGRPDCS *dcs1 = new AliGRPDCS(aliasLHCState,iStartTime,iStopTime);
95   TString sLHCState = dcs1->ProcessDCS(3);  
96   if (sLHCState) {
97     Log(Form("<LHCState> for run %d: %s",fRun, sLHCState.Data()));
98   } else {
99     Log(Form("LHCState not put in TMap!"));
100   }
101
102   TObjArray *aliasLHCPeriod = (TObjArray *)valueMap->GetValue("LHCPeriod");
103   if(!aliasLHCPeriod) {
104     Log(Form("LHCPeriod not found!!!"));
105     return 0;
106   }
107   AliGRPDCS *dcs2 = new AliGRPDCS(aliasLHCPeriod,iStartTime,iStopTime);
108   TString sLHCPeriod = dcs2->ProcessDCS(3);  
109   if (sLHCPeriod) {
110     Log(Form("<LHCPeriod> for run %d: %s",fRun, sLHCPeriod.Data()));
111   } else {
112     Log(Form("LHCPeriod not put in TMap!"));
113   }
114
115   TObjArray *aliasLHCLuminosity = (TObjArray *)valueMap->GetValue("LHCLuminosity");
116   if(!aliasLHCLuminosity) {
117     Log(Form("LHCLuminosity not found!!!"));
118     return 0;
119   }
120   AliGRPDCS *dcs3 = new AliGRPDCS(aliasLHCLuminosity,iStartTime,iStopTime);
121   TString sMeanLHCLuminosity = dcs3->ProcessDCS(2);  
122   if (sMeanLHCLuminosity) {
123     Log(Form("<LHCLuminosity> for run %d: %s",fRun, sMeanLHCLuminosity.Data()));
124   } else {
125     Log(Form("LHCLuminosity not put in TMap!"));
126   }
127
128   TObjArray *aliasBeamIntensity = (TObjArray *)valueMap->GetValue("BeamIntensity");
129   if(!aliasBeamIntensity) {
130     Log(Form("BeamIntensity not found!!!"));
131     return 0;
132   }
133   AliGRPDCS *dcs4 = new AliGRPDCS(aliasBeamIntensity,iStartTime,iStopTime);
134   TString sMeanBeamIntensity = dcs4->ProcessDCS(2);  
135   if (sMeanBeamIntensity) {
136     Log(Form("<BeamIntensity> for run %d: %s",fRun, sMeanBeamIntensity.Data()));
137   } else {
138     Log(Form("BeamIntensity not put in TMap!"));
139   }
140
141   TObjArray *aliasL3Current = (TObjArray *)valueMap->GetValue("L3Current");
142   if(!aliasL3Current) {
143     Log(Form("L3Current not found!!!"));
144     return 0;
145   }
146   AliGRPDCS *dcs5 = new AliGRPDCS(aliasL3Current,iStartTime,iStopTime);
147   TString sMeanL3Current = dcs5->ProcessDCS(2);  
148   if (sMeanL3Current) {
149     Log(Form("<L3Current> for run %d: %s",fRun, sMeanL3Current.Data()));
150   } else {
151     Log(Form("L3Current not put in TMap!"));
152   }
153
154   TObjArray *aliasL3Polarity = (TObjArray *)valueMap->GetValue("L3Polarity");
155   if(!aliasL3Polarity) {
156     Log(Form("L3Polarity not found!!!"));
157     return 0;
158   }
159   AliGRPDCS *dcs6 = new AliGRPDCS(aliasL3Polarity,iStartTime,iStopTime);
160   TString sL3Polarity = dcs6->ProcessDCS(4);  
161   if (sL3Polarity) {
162     Log(Form("<L3Polarity> for run %d: %s",fRun, sL3Polarity.Data()));
163   } else {
164     Log(Form("L3Polarity not put in TMap!"));
165   }
166
167   TObjArray *aliasDipoleCurrent = (TObjArray *)valueMap->GetValue("DipoleCurrent");
168   if(!aliasDipoleCurrent) {
169     Log(Form("DipoleCurrent not found!!!"));
170     return 0;
171   }
172   AliGRPDCS *dcs7 = new AliGRPDCS(aliasDipoleCurrent,iStartTime,iStopTime);
173   TString sMeanDipoleCurrent = dcs7->ProcessDCS(2);  
174   if (sMeanDipoleCurrent) {
175     Log(Form("<DipoleCurrent> for run %d: %s",fRun, sMeanDipoleCurrent.Data()));
176   } else {
177     Log(Form("DipoleCurrent not put in TMap!"));
178   }
179
180   TObjArray *aliasDipolePolarity = (TObjArray *)valueMap->GetValue("DipolePolarity");
181   if(!aliasDipolePolarity) {
182     Log(Form("DipolePolarity not found!!!"));
183     return 0;
184   }
185   AliGRPDCS *dcs8 = new AliGRPDCS(aliasDipolePolarity,iStartTime,iStopTime);
186   TString sDipolePolarity = dcs8->ProcessDCS(4);  
187   if (sDipolePolarity) {
188     Log(Form("<DipolePolarity> for run %d: %s",fRun, sDipolePolarity.Data()));
189   } else {
190     Log(Form("DipolePolarity not put in TMap!"));
191   }
192
193   TObjArray *aliasCavernTemperature = (TObjArray *)valueMap->GetValue("CavernTemperature");
194   if(!aliasCavernTemperature) {
195     Log(Form("CavernTemperature not found!!!"));
196     return 0;
197   }
198   AliGRPDCS *dcs9 = new AliGRPDCS(aliasCavernTemperature,iStartTime,iStopTime);
199   TString sMeanCavernTemperature = dcs9->ProcessDCS(2);  
200   if (sMeanCavernTemperature) {
201     Log(Form("<CavernTemperature> for run %d: %s",fRun, sMeanCavernTemperature.Data()));
202   } else {
203     Log(Form("CavernTemperature not put in TMap!"));
204   }
205
206   TObjArray *aliasCavernPressure = (TObjArray *)valueMap->GetValue("CavernPressure");
207   if(!aliasCavernPressure) {
208     Log(Form("CavernPressure not found!!!"));
209     return 0;
210   }
211   AliGRPDCS *dcs10 = new AliGRPDCS(aliasCavernPressure,iStartTime,iStopTime);
212   TString sMeanCavernPressure = dcs10->ProcessDCS(2);  
213   if (sMeanCavernPressure) {
214     Log(Form("<CavernPressure> for run %d: %s",fRun, sMeanCavernPressure.Data()));
215   } else {
216     Log(Form("CavernPressure not put in TMap!"));
217   }
218
219   //===========//
220   //DAQ logbook
221   //===========//
222   if (timeStart) {
223     Log(Form("Start time for run %d: %s",fRun, timeStart));
224   } else {
225     Log(Form("Start time not put in logbook!"));
226   }
227   if (timeEnd) {
228     Log(Form("End time for run %d: %s",fRun, timeEnd));
229   } else {
230     Log(Form("End time not put in logbook!"));
231   }
232   if (beamEnergy) {
233     Log(Form("Beam energy for run %d: %s",fRun, beamEnergy));
234   } else {
235     Log(Form("Beam energy not put in logbook!"));
236   }
237   if (beamType) {
238     Log(Form("Beam type for run %d: %s",fRun, beamType));
239   } else {
240     Log(Form("Beam type not put in logbook!"));
241   }
242   if (numberOfDetectors) {
243     Log(Form("Number of active detectors for run %d: %s",fRun, numberOfDetectors));
244   } else {
245     Log(Form("Number of active detectors not put in logbook!"));
246   }
247   if (detectorMask) {
248     Log(Form("Detector mask for run %d: %s",fRun, detectorMask));
249   } else {
250     Log(Form("Detector mask not put in logbook!"));
251   }
252   if (lhcPeriod) {
253     Log(Form("LHC period (DAQ) for run %d: %s",fRun, lhcPeriod));
254   } else {
255     Log(Form("LHCperiod not put in logbook!"));
256   }
257
258   TList *values = new TList();
259   values->SetOwner(1);
260   
261   //DAQ logbook
262   TMap *mapDAQ1 = new TMap();
263   mapDAQ1->Add(new TObjString("fAliceStartTime"),new TObjString(timeStart));
264   values->Add(mapDAQ1);
265
266   TMap *mapDAQ2 = new TMap();
267   mapDAQ2->Add(new TObjString("fAliceStopTime"),new TObjString(timeEnd));
268   values->Add(mapDAQ2);
269
270   TMap *mapDAQ3 = new TMap();
271   mapDAQ3->Add(new TObjString("fAliceBeamEnergy"),new TObjString(beamEnergy));
272   values->Add(mapDAQ3);
273
274   TMap *mapDAQ4 = new TMap();
275   mapDAQ4->Add(new TObjString("fAliceBeamType"),new TObjString(beamType));
276   values->Add(mapDAQ4);
277
278   TMap *mapDAQ5 = new TMap();
279   mapDAQ5->Add(new TObjString("fNumberOfDetectors"),new TObjString(numberOfDetectors));
280   values->Add(mapDAQ5);
281
282   TMap *mapDAQ6 = new TMap();
283   mapDAQ6->Add(new TObjString("fDetectorMask"),new TObjString(detectorMask));
284   values->Add(mapDAQ6);
285
286   TMap *mapDAQ7 = new TMap();
287   mapDAQ7->Add(new TObjString("fLHCPeriod"),new TObjString(lhcPeriod));
288   values->Add(mapDAQ7);
289
290   //DCS dp
291   TMap *mapDCS1 = new TMap();
292   mapDCS1->Add(new TObjString("fLHCState"),new TObjString(sLHCState));
293   values->Add(mapDCS1);
294
295   TMap *mapDCS2 = new TMap();
296   mapDCS2->Add(new TObjString("fLHCCondition"),new TObjString(sLHCPeriod));
297   values->Add(mapDCS2);
298
299   TMap *mapDCS3 = new TMap();
300   mapDCS3->Add(new TObjString("fLHCLuminosity"),new TObjString(sMeanLHCLuminosity));
301   values->Add(mapDCS3);
302
303   TMap *mapDCS4 = new TMap();
304   mapDCS4->Add(new TObjString("fBeamIntensity"),new TObjString(sMeanBeamIntensity));
305   values->Add(mapDCS4);
306
307   TMap *mapDCS5 = new TMap();
308   mapDCS5->Add(new TObjString("fL3Current"),new TObjString(sMeanL3Current));
309   values->Add(mapDCS5);
310
311   TMap *mapDCS6 = new TMap();
312   mapDCS6->Add(new TObjString("fL3Polarity"),new TObjString(sL3Polarity));
313   values->Add(mapDCS6);
314
315   TMap *mapDCS7 = new TMap();
316   mapDCS7->Add(new TObjString("fDipoleCurrent"),new TObjString(sMeanDipoleCurrent));
317   values->Add(mapDCS7);
318
319   TMap *mapDCS8 = new TMap();
320   mapDCS8->Add(new TObjString("fDipolePolarity"),new TObjString(sDipolePolarity));
321   values->Add(mapDCS8);
322
323   TMap *mapDCS9 = new TMap();
324   mapDCS9->Add(new TObjString("fCavernTemperature"),new TObjString(sMeanCavernTemperature));
325   values->Add(mapDCS9);
326
327   TMap *mapDCS10 = new TMap();
328   mapDCS10->Add(new TObjString("fCavernPressure"),new TObjString(sMeanCavernPressure));
329   values->Add(mapDCS10);
330
331   AliCDBMetaData md;
332   md.SetResponsible("Panos");
333   
334   Int_t result=0;
335   result = Store("GRP", "Values", values, &md);
336   
337   delete values;
338   
339   return result;
340 }
341