]> git.uio.no Git - u/mrichter/AliRoot.git/blob - T0/AliT0Preprocessor.cxx
Clean-up compile-time warnings
[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
34 #include "AliT0Preprocessor.h"
35 #include "AliT0DataDCS.h"
36 #include "AliT0CalibWalk.h"
37 #include "AliT0CalibTimeEq.h"
38
39 #include "AliCDBMetaData.h"
40 #include "AliDCSValue.h"
41 #include "AliLog.h"
42
43 #include <TTimeStamp.h>
44 #include <TFile.h>
45 #include <TObjString.h>
46 #include <TNamed.h>
47 #include "AliT0Dqclass.h"
48
49 // T0 preprocessor:
50 // 1) takes data from DCS and passes it to the class AliTOFDataDCS 
51 // for processing and writes the result to the Reference DB.
52 // 2) takes data form DAQ (both from Laser Calibration and Physics runs), 
53 // processes it, and stores either to OCDB or to Reference DB.
54
55
56 ClassImp(AliT0Preprocessor)
57
58 //____________________________________________________
59 AliT0Preprocessor::AliT0Preprocessor(AliShuttleInterface* shuttle) : AliPreprocessor("T00", shuttle), fData(0)
60 {
61   //constructor
62 }
63 //____________________________________________________
64
65 AliT0Preprocessor::~AliT0Preprocessor()
66 {
67   //destructor
68   delete fData;
69   fData = 0;
70 }
71 //____________________________________________________
72
73 void AliT0Preprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
74 {
75   // Creates AliT0DataDCS object
76   AliPreprocessor::Initialize(run, startTime, endTime);
77   AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run, TTimeStamp(startTime).AsString(), TTimeStamp(endTime).AsString()));
78   fData = new AliT0DataDCS(fRun, fStartTime, fEndTime);
79 }
80 //____________________________________________________
81
82 UInt_t AliT0Preprocessor::Process(TMap* dcsAliasMap )
83 {
84   // T0 preprocessor return codes:
85   // return=0 : all ok
86   // return=1 : no DCS input data 
87   // return=2 : failed to store DCS data
88   // return=3 : no Laser data (Walk correction)
89   // return=4 : failed to store OCDB time equalized data
90   // return=5 : no DAQ input for OCDB
91   // return=6 : failed to retrieve DAQ data from OCDB
92   // return=7 : failed to store T0 OCDB data
93
94         Bool_t resultDCSMap=kFALSE;
95         Bool_t resultDCSStore=kFALSE;
96         Bool_t resultLaser=kFALSE;
97         Bool_t resultOnline=kFALSE;  
98      
99         if(!dcsAliasMap)
100         {
101           Log("No DCS input data");
102           return 1;
103         }
104         else
105         {
106           
107           resultDCSMap=fData->ProcessData(*dcsAliasMap);
108           if(!resultDCSMap)
109           {
110             Log("Error when processing DCS data");
111             return 2;// return error Code for processed DCS data not stored
112           }
113           else
114           {
115             AliCDBMetaData metaDataDCS;
116             metaDataDCS.SetBeamPeriod(0);
117             metaDataDCS.SetResponsible("Tomasz Malkiewicz");
118             metaDataDCS.SetComment("This preprocessor fills an AliTODataDCS object.");
119             AliInfo("Storing DCS Data");
120             resultDCSStore = StoreReferenceData("Calib","DCSData", fData, &metaDataDCS);
121             if (!resultDCSStore)
122             {
123               Log("Some problems occurred while storing DCS data results in ReferenceDB");
124               //return 2;// return error Code for processed DCS data not stored
125             }
126
127           }
128         }
129
130         // processing DAQ
131
132         TString runType = GetRunType();
133
134         if(runType == "T0_STANDALONE_LASER")
135         {
136           TList* list = GetFileSources(kDAQ, "LASER");
137           if (list)
138           {
139             TIter iter(list);
140             TObjString *source;
141             while ((source = dynamic_cast<TObjString *> (iter.Next())))
142             {
143               const char *laserFile = GetFile(kDAQ, "LASER", source->GetName());
144               if (laserFile)
145               {
146                 Log(Form("File with Id LASER found in source %s!", source->GetName()));
147                 AliT0CalibWalk *laser = new AliT0CalibWalk();
148                 laser->MakeWalkCorrGraph(laserFile);
149                 AliCDBMetaData metaData;
150                 metaData.SetBeamPeriod(0);
151                 metaData.SetResponsible("Tomek&Michal");
152                 metaData.SetComment("Walk correction from laser runs.");
153                 //TObjArray* arrLaser = laser->GetfWalk();
154                 resultLaser=Store("Calib","Slewing_Walk", laser, &metaData, 0, 1);
155                 delete laser;
156               }
157               else
158               {
159                 Log(Form("Could not find file with Id LASER in source %s!", source->GetName()));
160                 return 1;
161               }
162             }
163             if (!resultLaser)
164             {
165               Log("No Laser Data stored");
166               return 3;//return error code for failure in storing Laser Data
167             }
168           } else {
169                 Log("No sources found for id LASER!");
170                 return 1;
171           }
172         }
173         else if(runType == "PHYSICS")
174         {
175           TList* listPhys = GetFileSources(kDAQ, "PHYSICS");
176           if (listPhys)
177           {
178             TIter iter(listPhys);
179             TObjString *sourcePhys;
180             while ((sourcePhys = dynamic_cast<TObjString *> (iter.Next())))
181             {
182               const char *filePhys = GetFile(kDAQ, "PHYSICS", sourcePhys->GetName());
183               if (filePhys)
184               {
185                 AliT0CalibTimeEq *online = new AliT0CalibTimeEq();
186                 online->Reset();
187                 online->ComputeOnlineParams("CFD", 20, 4., filePhys);
188                 AliCDBMetaData metaData;
189                 metaData.SetBeamPeriod(0);
190                 metaData.SetResponsible("Tomek&Michal");
191                 metaData.SetComment("Time equalizing result.");
192                 resultOnline = Store("Calib","TimeDelay", online, &metaData, 0, 1);
193                 delete online;
194               }
195               else
196               {
197                 Log(Form("Could not find file with Id PHYSICS in source %s!", sourcePhys->GetName()));
198                 return 1;
199               }
200             }
201             if (!resultOnline)
202             {
203               Log("No Laser Data stored");
204               return 4;//return error code for failure in storing OCDB Data
205             }
206           } else {
207                 Log("No sources found for id PHYSICS!");
208                 return 1;
209           }
210         }
211
212   return 0;
213 }