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