]> git.uio.no Git - u/mrichter/AliRoot.git/blame - VZERO/AliVZEROPreprocessor.cxx
file Run0_999999999_v0_s1.root with TObjectArray of AliHMPIDRecoParamV1 class, for...
[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 fData->ProcessData(*dcsAliasMap);
d2b85094 101
d5deaaa5 102 // Writes VZERO PMs HV values into VZERO calibration object and Timing resolution parameters
103 calibData->FillDCSData(fData);
7495d2be 104
d2b85094 105 // *************** From DAQ ******************
96da3fe8 106
6472f844 107 TString sourcesId = "V00da_results";
96da3fe8 108
6472f844 109 TList* sourceList = GetFileSources(kDAQ, sourcesId.Data());
96da3fe8 110 if (!sourceList) {
6472f844 111 Log(Form("No sources found for id %s", sourcesId.Data()));
96da3fe8 112 return 1; }
6472f844 113 Log(Form("The following sources produced files with the id %s",sourcesId.Data()));
96da3fe8 114 sourceList->Print();
115
116 TIter iter(sourceList);
117 TObjString *source = 0;
118
119 while((source=dynamic_cast<TObjString*> (iter.Next()))){
6472f844 120 fileName = GetFile(kDAQ, sourcesId.Data(), source->GetName());
96da3fe8 121 if (fileName.Length() > 0)
d1c61c72 122 Log(Form("Got the file %s, now we can extract some values.", fileName.Data()));
96da3fe8 123 FILE *file;
124 if((file = fopen(fileName.Data(),"r")) == NULL){
d1c61c72 125 Log(Form("Cannot open file %s",fileName.Data()));
96da3fe8 126 return 1;}
6472f844 127 Float_t pedMean[128], pedSigma[128], adcMean[128], adcSigma[128] ;
982d0603 128 for(Int_t j=0; j<128; j++)fscanf(file,"%f %f %f %f",
6472f844 129 &pedMean[j], &pedSigma[j], &adcMean[j], &adcSigma[j]);
96da3fe8 130 fclose(file);
131
6472f844 132 calibData->SetPedestal(pedMean);
133 calibData->SetSigma(pedSigma);
134 calibData->SetGain(adcMean);
135 calibData->SetADCsigma(adcSigma);
982d0603 136 }
025eb721 137
96da3fe8 138 delete source;
d2b85094 139
140 // Check that everything was properly transmitted
141
982d0603 142// for(Int_t j=0; j<128; j++){printf("Pedestal[%d] -> %f \n",j,calibData->GetPedestal(j));}
6472f844 143// for(Int_t j=0; j<128; j++){printf("pedSigma[%d] -> %f \n",j,calibData->GetSigma(j));}
982d0603 144// for(Int_t j=0; j<128; j++){printf("Gain[%d] -> %f \n",j,calibData->GetGain(j));}
6472f844 145// for(Int_t j=0; j<128; j++){printf("adcSigma[%d] -> %f \n",j,calibData->GetADCsigma(j));}
d2b85094 146// for(Int_t j=0; j<64; j++){printf("MeanHV[%d] -> %f \n",j,calibData->GetMeanHV(j));}
147// for(Int_t j=0; j<64; j++){printf("WidthHV[%d] -> %f \n",j,calibData->GetWidthHV(j));}
96da3fe8 148
d1c61c72 149 // Now we store the VZERO Calibration Object into CalibrationDB
312388a6 150
151 Bool_t resECal=kTRUE;
152
153 Bool_t result = 0;
154// if(sourceList && sourceList->GetEntries()>0)
155// {
156 AliCDBMetaData metaData;
157 metaData.SetBeamPeriod(0);
158 metaData.SetResponsible("Brigitte Cheynis");
159 metaData.SetComment("This preprocessor fills an AliVZEROCalibData object");
160
161 resECal = Store("Calib", "Data", calibData, &metaData, 0, kTRUE);
162// }
163 if(resECal==kFALSE ) result = 1;
d2b85094 164
d2b85094 165
166 delete calibData;
025eb721 167 delete sourceList;
d2b85094 168
fad64858 169 // -----------------------------------------------------------------------
6472f844 170 // Retrieves Front End Electronics Parameters from DCS archive
fad64858 171 // -----------------------------------------------------------------------
172 AliVZEROTriggerData *triggerData = new AliVZEROTriggerData();
173
174 // The processing of the DCS input data is forwarded to AliVZERODataFEE
175 fFEEData->ProcessData(*dcsAliasMap);
176
177 // Writes VZERO FEE parameters values into VZERO Trigger parametrization object
178 triggerData->FillData(fFEEData);
179
6472f844 180 // Stores the VZERO Trigger Object into TriggerDB
fad64858 181
182 resECal=kTRUE;
183
184 result = 0;
185 metaData.SetBeamPeriod(0);
186 metaData.SetResponsible("Brigitte Cheynis");
187 metaData.SetComment("This preprocessor fills an AliVZEROTriggerData object");
188
189 resECal = Store("Trigger", "Data", triggerData, &metaData, 0, kTRUE);
190 if(resECal==kFALSE ) result = 1;
191
192
5fc81083 193 return result;
d2b85094 194}
195