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