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