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