]>
Commit | Line | Data |
---|---|---|
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" | |
6472f844 | 8 | #include "AliShuttleInterface.h" |
9 | #include "AliVZERODataFEE.h" | |
10 | #include "AliVZERODataDCS.h" | |
11 | ||
d2b85094 | 12 | #include <TFile.h> |
13 | #include <TTimeStamp.h> | |
14 | #include <TObjString.h> | |
15 | #include <TSystem.h> | |
13067c49 | 16 | #include <TH1F.h> |
d2b85094 | 17 | |
6472f844 | 18 | |
19 | class Tlist; | |
20 | ||
21 | // | |
22 | // This class is a simple preprocessor for VZERO detector. | |
d2b85094 | 23 | // |
6472f844 | 24 | // It gets High Voltage values for a given run from DCS and Pedestal values from DAQ |
25 | // and writes them as Calibration MetaData into OCDB/VZERO/Calib/Data | |
26 | // It also retrieves FEE parameters from DCS archive | |
27 | // and writes them as Trigger MetaData into OCDB/VZERO/Trigger/Data | |
28 | // (to be used for trigger simulation) | |
d2b85094 | 29 | // |
30 | ||
31 | ClassImp(AliVZEROPreprocessor) | |
32 | ||
33 | //______________________________________________________________________________________________ | |
34 | AliVZEROPreprocessor::AliVZEROPreprocessor(AliShuttleInterface* shuttle) : | |
fad64858 | 35 | AliPreprocessor("V00", shuttle), |
36 | fData(0), | |
37 | fFEEData(0) | |
d2b85094 | 38 | |
39 | { | |
6b6c5c59 | 40 | // constructor |
41 | ||
e58b4e66 | 42 | AddRunType("STANDALONE_PULSER"); |
43 | AddRunType("STANDALONE_BC"); | |
6b6c5c59 | 44 | AddRunType("PHYSICS"); |
45 | ||
d2b85094 | 46 | } |
47 | ||
48 | //______________________________________________________________________________________________ | |
49 | AliVZEROPreprocessor::~AliVZEROPreprocessor() | |
50 | { | |
51 | // destructor | |
fad64858 | 52 | delete fFEEData; |
53 | delete fData; | |
54 | ||
d2b85094 | 55 | } |
56 | ||
57 | //______________________________________________________________________________________________ | |
58 | void AliVZEROPreprocessor::Initialize(Int_t run, UInt_t startTime, | |
59 | UInt_t endTime) | |
60 | { | |
fad64858 | 61 | // Creates AliVZERODataDCS object |
d2b85094 | 62 | |
d1c61c72 | 63 | AliPreprocessor::Initialize(run, startTime, endTime); |
64 | ||
65 | Log(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run, | |
d2b85094 | 66 | TTimeStamp(startTime).AsString(), |
67 | TTimeStamp(endTime).AsString())); | |
68 | ||
d1c61c72 | 69 | fRun = run; |
312388a6 | 70 | // fStartTime = startTime; |
71 | // fEndTime = endTime; | |
72 | fStartTime = GetStartTimeDCSQuery (); | |
73 | fEndTime = GetEndTimeDCSQuery (); | |
3b757990 | 74 | time_t daqStart = (time_t) (((TString)GetRunParameter("DAQ_time_start")).Atoi()); |
75 | time_t daqEnd = (time_t) (((TString)GetRunParameter("DAQ_time_end")).Atoi()); | |
e20f4da1 | 76 | time_t ctpStart = (time_t) (((TString)GetRunParameter("TRGTimeStart")).Atoi()); |
77 | time_t ctpEnd = (time_t) (((TString)GetRunParameter("TRGTimeEnd")).Atoi()); | |
3b757990 | 78 | |
e20f4da1 | 79 | fData = new AliVZERODataDCS(fRun, fStartTime, fEndTime,(UInt_t)daqStart, (UInt_t)daqEnd,(UInt_t)ctpStart, (UInt_t)ctpEnd); |
fad64858 | 80 | fFEEData = new AliVZERODataFEE(fRun, fStartTime, fEndTime); |
d1c61c72 | 81 | |
d2b85094 | 82 | } |
83 | ||
d2b85094 | 84 | //______________________________________________________________________________________________ |
85 | UInt_t AliVZEROPreprocessor::Process(TMap* dcsAliasMap) | |
86 | { | |
87 | // Fills data retrieved from DCS and DAQ into a AliVZEROCalibData object and | |
88 | // stores it into CalibrationDB | |
89 | ||
90 | ||
91 | // *** GET RUN TYPE *** | |
92 | TString runType = GetRunType(); | |
93 | ||
94 | ||
95 | // *** REFERENCE DATA *** | |
96 | ||
97 | TString fileName; | |
98 | AliVZEROCalibData *calibData = new AliVZEROCalibData(); | |
99 | ||
fad64858 | 100 | // *************** HV From DCS ****************** |
d2b85094 | 101 | // Fills data into a AliVZERODataDCS object |
102 | if(!dcsAliasMap) return 1; | |
103 | ||
fad64858 | 104 | // The Processing of the DCS input data is forwarded to AliVZERODataDCS |
75f53676 | 105 | if (!fData->ProcessData(*dcsAliasMap)) return 1; |
d2b85094 | 106 | |
d5deaaa5 | 107 | // Writes VZERO PMs HV values into VZERO calibration object and Timing resolution parameters |
108 | calibData->FillDCSData(fData); | |
7495d2be | 109 | |
d2b85094 | 110 | // *************** From DAQ ****************** |
96da3fe8 | 111 | |
6472f844 | 112 | TString sourcesId = "V00da_results"; |
96da3fe8 | 113 | |
6472f844 | 114 | TList* sourceList = GetFileSources(kDAQ, sourcesId.Data()); |
96da3fe8 | 115 | if (!sourceList) { |
6472f844 | 116 | Log(Form("No sources found for id %s", sourcesId.Data())); |
96da3fe8 | 117 | return 1; } |
6472f844 | 118 | Log(Form("The following sources produced files with the id %s",sourcesId.Data())); |
96da3fe8 | 119 | sourceList->Print(); |
120 | ||
121 | TIter iter(sourceList); | |
e5c19018 | 122 | TObjString *source; |
96da3fe8 | 123 | |
124 | while((source=dynamic_cast<TObjString*> (iter.Next()))){ | |
6472f844 | 125 | fileName = GetFile(kDAQ, sourcesId.Data(), source->GetName()); |
96da3fe8 | 126 | if (fileName.Length() > 0) |
d1c61c72 | 127 | Log(Form("Got the file %s, now we can extract some values.", fileName.Data())); |
96da3fe8 | 128 | FILE *file; |
129 | if((file = fopen(fileName.Data(),"r")) == NULL){ | |
d1c61c72 | 130 | Log(Form("Cannot open file %s",fileName.Data())); |
96da3fe8 | 131 | return 1;} |
6472f844 | 132 | Float_t pedMean[128], pedSigma[128], adcMean[128], adcSigma[128] ; |
93f60e03 | 133 | for(Int_t j=0; j<128; j++) { |
134 | Int_t resScan = fscanf(file,"%f %f %f %f", | |
135 | &pedMean[j], &pedSigma[j], &adcMean[j], &adcSigma[j]); | |
136 | if (resScan != 4) Log(Form("Bad data in file %s !",fileName.Data())); | |
137 | } | |
96da3fe8 | 138 | fclose(file); |
139 | ||
6472f844 | 140 | calibData->SetPedestal(pedMean); |
141 | calibData->SetSigma(pedSigma); | |
6472f844 | 142 | calibData->SetADCsigma(adcSigma); |
982d0603 | 143 | } |
025eb721 | 144 | |
96da3fe8 | 145 | delete source; |
d2b85094 | 146 | |
147 | // Check that everything was properly transmitted | |
148 | ||
982d0603 | 149 | // for(Int_t j=0; j<128; j++){printf("Pedestal[%d] -> %f \n",j,calibData->GetPedestal(j));} |
6472f844 | 150 | // for(Int_t j=0; j<128; j++){printf("pedSigma[%d] -> %f \n",j,calibData->GetSigma(j));} |
982d0603 | 151 | // for(Int_t j=0; j<128; j++){printf("Gain[%d] -> %f \n",j,calibData->GetGain(j));} |
6472f844 | 152 | // for(Int_t j=0; j<128; j++){printf("adcSigma[%d] -> %f \n",j,calibData->GetADCsigma(j));} |
d2b85094 | 153 | // for(Int_t j=0; j<64; j++){printf("MeanHV[%d] -> %f \n",j,calibData->GetMeanHV(j));} |
154 | // for(Int_t j=0; j<64; j++){printf("WidthHV[%d] -> %f \n",j,calibData->GetWidthHV(j));} | |
96da3fe8 | 155 | |
d1c61c72 | 156 | // Now we store the VZERO Calibration Object into CalibrationDB |
312388a6 | 157 | |
158 | Bool_t resECal=kTRUE; | |
159 | ||
160 | Bool_t result = 0; | |
161 | // if(sourceList && sourceList->GetEntries()>0) | |
162 | // { | |
163 | AliCDBMetaData metaData; | |
164 | metaData.SetBeamPeriod(0); | |
165 | metaData.SetResponsible("Brigitte Cheynis"); | |
166 | metaData.SetComment("This preprocessor fills an AliVZEROCalibData object"); | |
167 | ||
168 | resECal = Store("Calib", "Data", calibData, &metaData, 0, kTRUE); | |
169 | // } | |
170 | if(resECal==kFALSE ) result = 1; | |
d2b85094 | 171 | |
d2b85094 | 172 | |
173 | delete calibData; | |
025eb721 | 174 | delete sourceList; |
d2b85094 | 175 | |
fad64858 | 176 | // ----------------------------------------------------------------------- |
6472f844 | 177 | // Retrieves Front End Electronics Parameters from DCS archive |
fad64858 | 178 | // ----------------------------------------------------------------------- |
179 | AliVZEROTriggerData *triggerData = new AliVZEROTriggerData(); | |
180 | ||
181 | // The processing of the DCS input data is forwarded to AliVZERODataFEE | |
182 | fFEEData->ProcessData(*dcsAliasMap); | |
183 | ||
184 | // Writes VZERO FEE parameters values into VZERO Trigger parametrization object | |
185 | triggerData->FillData(fFEEData); | |
186 | ||
6472f844 | 187 | // Stores the VZERO Trigger Object into TriggerDB |
fad64858 | 188 | |
189 | resECal=kTRUE; | |
190 | ||
fad64858 | 191 | metaData.SetBeamPeriod(0); |
192 | metaData.SetResponsible("Brigitte Cheynis"); | |
193 | metaData.SetComment("This preprocessor fills an AliVZEROTriggerData object"); | |
194 | ||
195 | resECal = Store("Trigger", "Data", triggerData, &metaData, 0, kTRUE); | |
196 | if(resECal==kFALSE ) result = 1; | |
197 | ||
13067c49 | 198 | |
199 | // *************** From DAQ DA - Equalization factors ****************** | |
200 | ||
201 | TH1F *eqFactors = new TH1F("VZEROEqualizationFactors","VZERO Equalization Factors for Pb-Pb",64,-0.5,63.5); | |
202 | sourcesId = "V00DAEqualFactors"; | |
203 | ||
204 | TList* sourceList2 = GetFileSources(kDAQ, sourcesId.Data()); | |
205 | if (!sourceList2) { | |
206 | Log(Form("No sources found for id %s", sourcesId.Data())); | |
207 | return 1; } | |
208 | Log(Form("The following sources produced files with the id %s",sourcesId.Data())); | |
209 | sourceList2->Print(); | |
210 | ||
211 | TIter iter2(sourceList2); | |
212 | TObjString *source2; | |
213 | ||
214 | while((source2=dynamic_cast<TObjString*> (iter2.Next()))){ | |
215 | fileName = GetFile(kDAQ, sourcesId.Data(), source2->GetName()); | |
216 | if (fileName.Length() > 0) | |
217 | Log(Form("Got the file %s, now we can extract some values.", fileName.Data())); | |
218 | FILE *file2; | |
219 | if((file2 = fopen(fileName.Data(),"r")) == NULL){ | |
220 | Log(Form("Cannot open file %s",fileName.Data())); | |
221 | return 1;} | |
222 | ||
223 | Double_t alpha[66]; | |
224 | alpha[0] = alpha[65] = 0; | |
225 | Int_t tempCh; | |
226 | Float_t tempAlpha; | |
227 | for(Int_t j=0; j<64; ++j) { | |
93f60e03 | 228 | Int_t resScan = fscanf(file2,"%d %f", &tempCh, &tempAlpha); |
229 | if (resScan != 2) Log(Form("Bad data in file %s !",fileName.Data())); | |
13067c49 | 230 | alpha[tempCh+1] = tempAlpha; |
231 | } | |
232 | fclose(file2); | |
233 | ||
234 | // Check that everything was properly transmitted | |
235 | printf("Equalization factors (0->64): "); | |
2716ecba | 236 | for(Int_t j=0; j<64; ++j) printf("%.5f ",alpha[j+1]); |
13067c49 | 237 | printf("\n"); |
238 | ||
239 | eqFactors->SetContent(alpha); | |
240 | } | |
241 | ||
242 | delete source2; | |
243 | ||
244 | // Now we store the VZERO Equalization Factors Object into OCDB | |
245 | ||
246 | resECal=kTRUE; | |
247 | ||
248 | AliCDBMetaData metaData2; | |
249 | metaData2.SetBeamPeriod(0); | |
250 | metaData2.SetResponsible("Brigitte Cheynis"); | |
251 | metaData2.SetComment("VZERO Equalization Factors object filled by VZERO preprocessor"); | |
252 | ||
253 | resECal = Store("Calib", "EqualizationFactors", eqFactors, &metaData2, 0, kTRUE); | |
254 | ||
255 | if(resECal==kFALSE ) result = 1; | |
256 | ||
257 | delete eqFactors; | |
258 | delete sourceList2; | |
259 | ||
fad64858 | 260 | |
5fc81083 | 261 | return result; |
d2b85094 | 262 | } |
263 |