pointer to AliVZERODataDCS object deleted in destructor
[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{
25 // constructor
26}
27
28//______________________________________________________________________________________________
29AliVZEROPreprocessor::~AliVZEROPreprocessor()
30{
31 // destructor
7009762e 32
33 delete fData;
d2b85094 34}
35
36//______________________________________________________________________________________________
37void AliVZEROPreprocessor::Initialize(Int_t run, UInt_t startTime,
38 UInt_t endTime)
39{
40 // Creates AliZDCDataDCS object
41
d1c61c72 42 AliPreprocessor::Initialize(run, startTime, endTime);
43
44 Log(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
d2b85094 45 TTimeStamp(startTime).AsString(),
46 TTimeStamp(endTime).AsString()));
47
d1c61c72 48 fRun = run;
49 fStartTime = startTime;
50 fEndTime = endTime;
d2b85094 51
d1c61c72 52 fData = new AliVZERODataDCS(fRun, fStartTime, fEndTime);
53
d2b85094 54}
55
d2b85094 56//______________________________________________________________________________________________
57UInt_t AliVZEROPreprocessor::Process(TMap* dcsAliasMap)
58{
59 // Fills data retrieved from DCS and DAQ into a AliVZEROCalibData object and
60 // stores it into CalibrationDB
61
62
63 // *** GET RUN TYPE ***
64 TString runType = GetRunType();
65
66
67 // *** REFERENCE DATA ***
68
69 TString fileName;
70 AliVZEROCalibData *calibData = new AliVZEROCalibData();
71
72 // *************** From DCS ******************
73 // Fills data into a AliVZERODataDCS object
74 if(!dcsAliasMap) return 1;
75
76 // The processing of the DCS input data is forwarded to AliVZERODataDCS
77
78 fData->ProcessData(*dcsAliasMap);
96da3fe8 79 //fData->Draw(""); // Draws the HV values as a function of time
80 //dcsAliasMap->Print(""); // Prints out the HV values
d2b85094 81
96da3fe8 82 // Writes VZERO PMs HV values into VZERO calibration object
d2b85094 83 calibData->SetMeanHV(fData->GetMeanHV());
84 calibData->SetWidthHV(fData->GetWidthHV());
96da3fe8 85
d2b85094 86 // *************** From DAQ ******************
96da3fe8 87
88 TString SourcesId = "CALIB";
89
90 TList* sourceList = GetFileSources(kDAQ, SourcesId.Data());
91 if (!sourceList) {
d1c61c72 92 Log(Form("No sources found for id %s", SourcesId.Data()));
96da3fe8 93 return 1; }
d1c61c72 94 Log(Form("The following sources produced files with the id %s",SourcesId.Data()));
96da3fe8 95 sourceList->Print();
96
97 TIter iter(sourceList);
98 TObjString *source = 0;
99
100 while((source=dynamic_cast<TObjString*> (iter.Next()))){
101 fileName = GetFile(kDAQ, SourcesId.Data(), source->GetName());
102 if (fileName.Length() > 0)
d1c61c72 103 Log(Form("Got the file %s, now we can extract some values.", fileName.Data()));
96da3fe8 104 FILE *file;
105 if((file = fopen(fileName.Data(),"r")) == NULL){
d1c61c72 106 Log(Form("Cannot open file %s",fileName.Data()));
96da3fe8 107 return 1;}
108 Float_t Pedestals[128], Sigmas[128], Gains[128];
109 for(Int_t j=0; j<128; j++)fscanf(file,"%f %f %f ",
110 &Pedestals[j], &Sigmas[j], &Gains[j]);
111 fclose(file);
112
113 calibData->SetPedestal(Pedestals);
114 calibData->SetSigma(Sigmas);
115 calibData->SetGain(Gains); }
d2b85094 116
96da3fe8 117 delete sourceList;
118 delete source;
d2b85094 119
120 // Check that everything was properly transmitted
121
122// for(Int_t j=0; j<128; j++){printf("ADCPedestal[%d] -> %f \n",j,calibData->GetPedestal(j));}
123// for(Int_t j=0; j<128; j++){printf("ADCGain[%d] -> %f \n",j,calibData->GetGain(j));}
124// for(Int_t j=0; j<128; j++){printf("ADCSigma[%d] -> %f \n",j,calibData->GetSigma(j));}
125// for(Int_t j=0; j<64; j++){printf("MeanHV[%d] -> %f \n",j,calibData->GetMeanHV(j));}
126// for(Int_t j=0; j<64; j++){printf("WidthHV[%d] -> %f \n",j,calibData->GetWidthHV(j));}
96da3fe8 127
d1c61c72 128 // Now we store the VZERO Calibration Object into CalibrationDB
d2b85094 129
130 AliCDBMetaData metaData;
131 metaData.SetBeamPeriod(0);
132 metaData.SetResponsible("Brigitte Cheynis");
133 metaData.SetComment("This preprocessor fills an AliVZEROCalibData object");
134
135 Bool_t result = Store("Calib", "Data", calibData, &metaData, 0, kTRUE);
136
137 delete calibData;
138
139 if (!result) return 1;
140 return 0;
141}
142