]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - VZERO/AliVZEROPreprocessor.cxx
Correction of additional compilation errors from the first compilation trial.
[u/mrichter/AliRoot.git] / VZERO / AliVZEROPreprocessor.cxx
... / ...
CommitLineData
1#include "AliVZEROPreprocessor.h"
2#include "AliVZEROCalibData.h"
3#include "AliVZEROTriggerData.h"
4#include "AliCDBMetaData.h"
5#include "AliCDBEntry.h"
6#include "AliDCSValue.h"
7#include "AliLog.h"
8#include "AliShuttleInterface.h"
9#include "AliVZERODataFEE.h"
10#include "AliVZERODataDCS.h"
11
12#include <TFile.h>
13#include <TTimeStamp.h>
14#include <TObjString.h>
15#include <TSystem.h>
16
17
18class Tlist;
19
20//
21// This class is a simple preprocessor for VZERO detector.
22//
23// It gets High Voltage values for a given run from DCS and Pedestal values from DAQ
24// and writes them as Calibration MetaData into OCDB/VZERO/Calib/Data
25// It also retrieves FEE parameters from DCS archive
26// and writes them as Trigger MetaData into OCDB/VZERO/Trigger/Data
27// (to be used for trigger simulation)
28//
29
30ClassImp(AliVZEROPreprocessor)
31
32//______________________________________________________________________________________________
33AliVZEROPreprocessor::AliVZEROPreprocessor(AliShuttleInterface* shuttle) :
34 AliPreprocessor("V00", shuttle),
35 fData(0),
36 fFEEData(0)
37
38{
39 // constructor
40
41 AddRunType("STANDALONE_PULSER");
42 AddRunType("STANDALONE_BC");
43 AddRunType("PHYSICS");
44
45}
46
47//______________________________________________________________________________________________
48AliVZEROPreprocessor::~AliVZEROPreprocessor()
49{
50 // destructor
51 delete fFEEData;
52 delete fData;
53
54}
55
56//______________________________________________________________________________________________
57void AliVZEROPreprocessor::Initialize(Int_t run, UInt_t startTime,
58 UInt_t endTime)
59{
60 // Creates AliVZERODataDCS object
61
62 AliPreprocessor::Initialize(run, startTime, endTime);
63
64 Log(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
65 TTimeStamp(startTime).AsString(),
66 TTimeStamp(endTime).AsString()));
67
68 fRun = run;
69 // fStartTime = startTime;
70 // fEndTime = endTime;
71 fStartTime = GetStartTimeDCSQuery ();
72 fEndTime = GetEndTimeDCSQuery ();
73 time_t daqStart = (time_t) (((TString)GetRunParameter("DAQ_time_start")).Atoi());
74 time_t daqEnd = (time_t) (((TString)GetRunParameter("DAQ_time_end")).Atoi());
75
76 fData = new AliVZERODataDCS(fRun, fStartTime, fEndTime,(UInt_t)daqStart, (UInt_t)daqEnd);
77 fFEEData = new AliVZERODataFEE(fRun, fStartTime, fEndTime);
78
79}
80
81//______________________________________________________________________________________________
82UInt_t AliVZEROPreprocessor::Process(TMap* dcsAliasMap)
83{
84 // Fills data retrieved from DCS and DAQ into a AliVZEROCalibData object and
85 // stores it into CalibrationDB
86
87
88 // *** GET RUN TYPE ***
89 TString runType = GetRunType();
90
91
92 // *** REFERENCE DATA ***
93
94 TString fileName;
95 AliVZEROCalibData *calibData = new AliVZEROCalibData();
96
97 // *************** HV From DCS ******************
98 // Fills data into a AliVZERODataDCS object
99 if(!dcsAliasMap) return 1;
100
101 // The Processing of the DCS input data is forwarded to AliVZERODataDCS
102 if (!fData->ProcessData(*dcsAliasMap)) return 1;
103
104 // Writes VZERO PMs HV values into VZERO calibration object and Timing resolution parameters
105 calibData->FillDCSData(fData);
106
107 // *************** From DAQ ******************
108
109 TString sourcesId = "V00da_results";
110
111 TList* sourceList = GetFileSources(kDAQ, sourcesId.Data());
112 if (!sourceList) {
113 Log(Form("No sources found for id %s", sourcesId.Data()));
114 return 1; }
115 Log(Form("The following sources produced files with the id %s",sourcesId.Data()));
116 sourceList->Print();
117
118 TIter iter(sourceList);
119 TObjString *source;
120
121 while((source=dynamic_cast<TObjString*> (iter.Next()))){
122 fileName = GetFile(kDAQ, sourcesId.Data(), source->GetName());
123 if (fileName.Length() > 0)
124 Log(Form("Got the file %s, now we can extract some values.", fileName.Data()));
125 FILE *file;
126 if((file = fopen(fileName.Data(),"r")) == NULL){
127 Log(Form("Cannot open file %s",fileName.Data()));
128 return 1;}
129 Float_t pedMean[128], pedSigma[128], adcMean[128], adcSigma[128] ;
130 for(Int_t j=0; j<128; j++)fscanf(file,"%f %f %f %f",
131 &pedMean[j], &pedSigma[j], &adcMean[j], &adcSigma[j]);
132 fclose(file);
133
134 calibData->SetPedestal(pedMean);
135 calibData->SetSigma(pedSigma);
136 calibData->SetADCsigma(adcSigma);
137 }
138
139 delete source;
140
141 // Check that everything was properly transmitted
142
143// for(Int_t j=0; j<128; j++){printf("Pedestal[%d] -> %f \n",j,calibData->GetPedestal(j));}
144// for(Int_t j=0; j<128; j++){printf("pedSigma[%d] -> %f \n",j,calibData->GetSigma(j));}
145// for(Int_t j=0; j<128; j++){printf("Gain[%d] -> %f \n",j,calibData->GetGain(j));}
146// for(Int_t j=0; j<128; j++){printf("adcSigma[%d] -> %f \n",j,calibData->GetADCsigma(j));}
147// for(Int_t j=0; j<64; j++){printf("MeanHV[%d] -> %f \n",j,calibData->GetMeanHV(j));}
148// for(Int_t j=0; j<64; j++){printf("WidthHV[%d] -> %f \n",j,calibData->GetWidthHV(j));}
149
150 // Now we store the VZERO Calibration Object into CalibrationDB
151
152 Bool_t resECal=kTRUE;
153
154 Bool_t result = 0;
155// if(sourceList && sourceList->GetEntries()>0)
156// {
157 AliCDBMetaData metaData;
158 metaData.SetBeamPeriod(0);
159 metaData.SetResponsible("Brigitte Cheynis");
160 metaData.SetComment("This preprocessor fills an AliVZEROCalibData object");
161
162 resECal = Store("Calib", "Data", calibData, &metaData, 0, kTRUE);
163// }
164 if(resECal==kFALSE ) result = 1;
165
166
167 delete calibData;
168 delete sourceList;
169
170 // -----------------------------------------------------------------------
171 // Retrieves Front End Electronics Parameters from DCS archive
172 // -----------------------------------------------------------------------
173 AliVZEROTriggerData *triggerData = new AliVZEROTriggerData();
174
175 // The processing of the DCS input data is forwarded to AliVZERODataFEE
176 fFEEData->ProcessData(*dcsAliasMap);
177
178 // Writes VZERO FEE parameters values into VZERO Trigger parametrization object
179 triggerData->FillData(fFEEData);
180
181 // Stores the VZERO Trigger Object into TriggerDB
182
183 resECal=kTRUE;
184
185 result = 0;
186 metaData.SetBeamPeriod(0);
187 metaData.SetResponsible("Brigitte Cheynis");
188 metaData.SetComment("This preprocessor fills an AliVZEROTriggerData object");
189
190 resECal = Store("Trigger", "Data", triggerData, &metaData, 0, kTRUE);
191 if(resECal==kFALSE ) result = 1;
192
193
194 return result;
195}
196