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