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