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