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