]> git.uio.no Git - u/mrichter/AliRoot.git/blob - T0/AliT0Preprocessor.cxx
Getting rid of zero length arrays in the block structure declarations since this...
[u/mrichter/AliRoot.git] / T0 / AliT0Preprocessor.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 /*
17 $Log: AliT0Preprocessor.cxx,v $
18 Revision 1.8  2007/12/07 15:22:51  alla
19 bug fixed by Alberto
20  
21 Revision 1.7  2007/12/06 16:35:24  alla
22 new bugs fixed by Tomek
23
24 Revision 1.5  2007/11/23 19:28:52  alla
25 bug fixed
26
27 Version 2.1  2007/11/21 
28 Preprocessor storing data to OCDB (T.Malkiewicz)
29
30 Version 1.1  2006/10   
31 Preliminary test version (T.Malkiewicz)
32 */   
33 // T0 preprocessor:
34 // 1) takes data from DCS and passes it to the class AliTOFDataDCS 
35 // for processing and writes the result to the Reference DB.
36 // 2) takes data form DAQ (both from Laser Calibration and Physics runs), 
37 // processes it, and stores either to OCDB or to Reference DB.
38
39
40 #include "AliT0Preprocessor.h"
41 #include "AliT0DataDCS.h"
42 #include "AliT0CalibWalk.h"
43 #include "AliT0CalibTimeEq.h"
44
45 #include "AliCDBMetaData.h"
46 #include "AliDCSValue.h"
47 #include "AliLog.h"
48
49 #include <TTimeStamp.h>
50 #include <TFile.h>
51 #include <TObjString.h>
52 #include <TNamed.h>
53 #include "AliT0Dqclass.h"
54
55
56 ClassImp(AliT0Preprocessor)
57
58 //____________________________________________________
59 AliT0Preprocessor::AliT0Preprocessor(AliShuttleInterface* shuttle) : 
60   AliPreprocessor("T00", shuttle), 
61   fData(0)
62 {
63   //constructor
64   AddRunType("PHYSICS");
65   AddRunType("STANDALONE");
66 }
67 //____________________________________________________
68
69 AliT0Preprocessor::~AliT0Preprocessor()
70 {
71   //destructor
72   delete fData;
73   fData = 0;
74 }
75 //____________________________________________________
76
77 void AliT0Preprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
78 {
79   // Creates AliT0DataDCS object
80   AliPreprocessor::Initialize(run, startTime, endTime);
81   AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run, TTimeStamp(startTime).AsString(), TTimeStamp(endTime).AsString()));
82   fData = new AliT0DataDCS(fRun, fStartTime, fEndTime);
83 }
84 //____________________________________________________
85
86 Bool_t AliT0Preprocessor::ProcessDCS(){
87         // Check whether DCS should be processed or not...
88         TString runType = GetRunType();
89         Log(Form("ProcessDCS - RunType: %s",runType.Data()));
90
91         if((runType == "STANDALONE")||(runType == "PHYSICS")){
92                 return kFALSE;
93         }else{
94         return kFALSE;
95         }
96 }
97 //____________________________________________________
98
99 UInt_t AliT0Preprocessor::ProcessDCSDataPoints(TMap* dcsAliasMap){
100         // Fills data into AliT0DataDCS object
101         Log("Processing DCS DP");
102         Bool_t resultDCSMap=kFALSE;
103         Bool_t resultDCSStore=kFALSE;
104
105         if(!dcsAliasMap)
106         {
107           Log("No DCS input data");
108           return 1;
109         }
110         else
111         {
112           resultDCSMap=fData->ProcessData(*dcsAliasMap);
113           if(!resultDCSMap)
114           {
115             Log("Error when processing DCS data");
116             return 2;// return error Code for processed DCS data not stored
117           }
118           else
119           {
120             AliCDBMetaData metaDataDCS;
121             metaDataDCS.SetBeamPeriod(0);
122             metaDataDCS.SetResponsible("Tomasz Malkiewicz");
123             metaDataDCS.SetComment("This preprocessor fills an AliTODataDCS object.");
124             AliInfo("Storing DCS Data");
125             resultDCSStore = Store("Calib","DCSData",fData, &metaDataDCS);
126             if (!resultDCSStore)
127             {
128               Log("Some problems occurred while storing DCS data results in ReferenceDB");
129               return 2;// return error Code for processed DCS data not stored
130             }
131           }
132         }
133         return 0;
134 }
135 //____________________________________________________
136
137 UInt_t AliT0Preprocessor::ProcessLaser(){
138         // Processing data from DAQ Standalone run
139         Log("Processing Laser calibration - Walk Correction");
140         
141         Bool_t resultLaser=kFALSE;
142         //processing DAQ
143         TList* list = GetFileSources(kDAQ, "LASER");
144         if (list)
145         {
146             TIter iter(list);
147             TObjString *source;
148             while ((source = dynamic_cast<TObjString *> (iter.Next())))
149             {
150               const char *laserFile = GetFile(kDAQ, "LASER", source->GetName());
151               if (laserFile)
152               {
153                 Log(Form("File with Id LASER found in source %s!", source->GetName()));
154                 AliT0CalibWalk *laser = new AliT0CalibWalk();
155                 laser->MakeWalkCorrGraph(laserFile);
156                 AliCDBMetaData metaData;
157                 metaData.SetBeamPeriod(0);
158                 metaData.SetResponsible("Tomek&Michal");
159                 metaData.SetComment("Walk correction from laser runs.");
160                 resultLaser=Store("Calib","Slewing_Walk", laser, &metaData, 0, 1);
161                 delete laser;
162                 Log(Form("resultLaser = %d",resultLaser));
163               }
164               else
165               {
166                 Log(Form("Could not find file with Id LASER in source %s!", source->GetName()));
167                 return 1;
168               }
169             }
170             if (!resultLaser)
171             {
172               Log("No Laser Data stored");
173               return 3;//return error code for failure in storing Laser Data
174             }
175           } else {
176                 Log("No sources found for id LASER!");
177                 return 1;
178           }
179         return 0;
180 }
181 //____________________________________________________
182
183 UInt_t AliT0Preprocessor::ProcessPhysics(){
184         //Processing data from DAQ Physics run
185         Log("Processing Physics");
186
187         Bool_t resultOnline=kFALSE; 
188         //processing DAQ
189         TList* listPhys = GetFileSources(kDAQ, "PHYSICS");
190         if (listPhys)
191           {
192             TIter iter(listPhys);
193             TObjString *sourcePhys;
194             while ((sourcePhys = dynamic_cast<TObjString *> (iter.Next())))
195             {
196               const char *filePhys = GetFile(kDAQ, "PHYSICS", sourcePhys->GetName());
197               if (filePhys)
198               {
199                 AliT0CalibTimeEq *online = new AliT0CalibTimeEq();
200                 online->Reset();
201                 online->ComputeOnlineParams(filePhys);
202                 AliCDBMetaData metaData;
203                 metaData.SetBeamPeriod(0);
204                 metaData.SetResponsible("Tomek&Michal");
205                 metaData.SetComment("Time equalizing result.");
206                 resultOnline = Store("Calib","TimeDelay", online, &metaData, 0, 1);
207                 Log(Form("resultOnline = %d",resultOnline));
208                 delete online;
209               }
210                 else
211               {
212                 Log(Form("Could not find file with Id PHYSICS in source %s!", sourcePhys->GetName()));
213                 return 1;
214               }
215               
216             }
217             if (!resultOnline)
218             {
219               Log("No Data stored");
220               return 4;//return error code for failure in storing OCDB Data
221             }
222           } else {
223                 Log("No sources found for id PHYSICS!");
224                 return 1;
225           }
226         return 0;
227 }
228 //____________________________________________________
229
230 UInt_t AliT0Preprocessor::ProcessCosmic(){
231         //Processing data from DAQ Physics run
232         Log("Processing Laser Physics");
233
234         Bool_t resultLaserOnline=kFALSE; 
235         //processing DAQ
236         TList* listLaser = GetFileSources(kDAQ, "COSMIC");
237         if (listLaser)
238           {
239             TIter iter(listLaser);
240             TObjString *sourceLaser;
241             while ((sourceLaser = dynamic_cast<TObjString *> (iter.Next())))
242             {
243               const char *fileLaser = GetFile(kDAQ, "COSMIC", sourceLaser->GetName());
244               if (fileLaser)
245               {
246                 AliT0CalibTimeEq *onlineLaser = new AliT0CalibTimeEq();
247                 onlineLaser->Reset();
248                 onlineLaser->ComputeOnlineParams(fileLaser);
249                 AliCDBMetaData metaData;
250                 metaData.SetBeamPeriod(0);
251                 metaData.SetResponsible("Tomek&Michal");
252                 metaData.SetComment("Time equalizing result.");
253                 resultLaserOnline = Store("Calib","LaserTimeDelay", onlineLaser, &metaData, 0, 1);
254                 Log(Form("resultLaserOnline = %d",resultLaserOnline));
255                 delete onlineLaser;
256               }
257                 else
258               {
259                 Log(Form("Could not find file with Id COSMIC in source %s!", sourceLaser->GetName()));
260                 return 0;
261               }
262               
263             }
264             if (!resultLaserOnline)
265             {
266               Log("No Laser Data stored");
267               return 0;//return error code for failure in storing OCDB Data
268             }
269           } else {
270                 Log("No sources found for id COSMIC!");
271                 return 0;
272           }
273         return 0;
274 }
275 //____________________________________________________
276
277 UInt_t AliT0Preprocessor::Process(TMap* dcsAliasMap )
278 {
279   // T0 preprocessor return codes:
280   // return=0 : all ok
281   // return=1 : no DCS input data 
282   // return=2 : failed to store DCS data
283   // return=3 : no Laser data (Walk correction)
284   // return=4 : failed to store OCDB time equalized data
285   // return=5 : no DAQ input for OCDB
286   // return=6 : failed to retrieve DAQ data from OCDB
287   // return=7 : failed to store T0 OCDB data
288         Bool_t dcsDP = ProcessDCS();
289         Log(Form("dcsDP = %d",dcsDP));  
290         TString runType = GetRunType();
291         Log(Form("RunType: %s",runType.Data()));
292         //processing
293         if(runType == "STANDALONE"){
294                 Int_t iresultLaser = ProcessLaser();
295                         if(dcsDP==1){
296                         Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap);
297                         return iresultDCS;
298                 }
299                 Log(Form("iresultLaser = %d",iresultLaser));
300                 return iresultLaser;
301         }
302        else if(runType == "PHYSICS"){
303                 Int_t iresultPhysics = ProcessPhysics();
304                 Int_t iresultCosmic = ProcessCosmic();
305                 if(dcsDP==1){
306                         Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap);
307                         return iresultDCS;
308                 }
309                 Log(Form("iresultPhysics = %d",iresultPhysics));
310                 return iresultPhysics; 
311        }        
312
313   return 0;
314 }