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