]>
Commit | Line | Data |
---|---|---|
31af5828 | 1 | // --- ROOT system |
2 | #include <TFile.h> | |
79563ba1 | 3 | #include <TClonesArray.h> |
4 | #include <TList.h> | |
5 | #include <TObjString.h> | |
31af5828 | 6 | #include <TTimeStamp.h> |
64a7c78d | 7 | |
31af5828 | 8 | #include "AliZDCPreprocessor.h" |
9 | #include "AliCDBManager.h" | |
10 | #include "AliCDBEntry.h" | |
64a7c78d | 11 | #include "AliCDBMetaData.h" |
12 | #include "AliDCSValue.h" | |
79563ba1 | 13 | #include "AliAlignObj.h" |
90dbf5fb | 14 | #include "AliAlignObjParams.h" |
64a7c78d | 15 | #include "AliLog.h" |
16 | #include "AliZDCDataDCS.h" | |
1ee299a5 | 17 | #include "AliZDCChMap.h" |
6024ec85 | 18 | #include "AliZDCPedestals.h" |
1ee299a5 | 19 | #include "AliZDCLaserCalib.h" |
73bc3a3f | 20 | #include "AliZDCEnCalib.h" |
21 | #include "AliZDCTowerCalib.h" | |
64a7c78d | 22 | |
d5e687c2 | 23 | ///////////////////////////////////////////////////////////////////// |
24 | // // | |
73bc3a3f | 25 | // Class implementing Shuttle ZDC pre-processor. // |
26 | // It takes data from DCS and DAQ and writes calibration objects // | |
27 | // in the OCDB and reference values/histos in the ReferenceData. // | |
d5e687c2 | 28 | // // |
29 | ///////////////////////////////////////////////////////////////////// | |
64a7c78d | 30 | |
e83c8d88 | 31 | // ****************************************************************** |
32 | // RETURN CODES: | |
33 | // return=0 : everything OK | |
34 | // return=1 : no DCS input data Map | |
35 | // return=2 : error when storing in RefData DCS processed data | |
36 | // return=3 : error in storing alignment object in OCDB | |
37 | // return=4 : error retrieving/reading data file from DAQ FXS | |
38 | // return=5 : error when storing ADC ch. mapping in OCDB | |
39 | // return=6 : error when storing energy calibration coefficients | |
40 | // return=7 : error when storing tower inter-calibration coefficients | |
41 | // return=8 : error when storing pedestal parameters in OCDB | |
42 | // return=9 : error when storing pedestal histos in RefData | |
43 | // return=10: error when storing laser coefficients in OCDB | |
44 | // return=11: error when storing laser histos in RefData | |
45 | // ****************************************************************** | |
46 | ||
64a7c78d | 47 | ClassImp(AliZDCPreprocessor) |
48 | ||
49 | //______________________________________________________________________________________________ | |
857ece97 | 50 | AliZDCPreprocessor::AliZDCPreprocessor(AliShuttleInterface* shuttle) : |
51 | AliPreprocessor("ZDC", shuttle), | |
64a7c78d | 52 | fData(0) |
53 | { | |
54 | // constructor | |
b8d194f5 | 55 | // May 2009 - run types updated according to |
56 | // http://alice-ecs.web.cern.ch/alice-ecs/runtypes_3.36.html | |
cbf06263 | 57 | AddRunType("STANDALONE_PEDESTAL"); |
1ee299a5 | 58 | AddRunType("STANDALONE_LASER"); |
321fe3b8 | 59 | AddRunType("STANDALONE_COSMIC"); |
b8d194f5 | 60 | AddRunType("CALIBRATION_EMD"); |
61 | AddRunType("CALIBRATION_MB"); | |
62 | AddRunType("CALIBRATION_CENTRAL"); | |
63 | AddRunType("CALIBRATION_SEMICENTRAL"); | |
64 | AddRunType("CALIBRATION_BC"); | |
321fe3b8 | 65 | AddRunType("PHYSICS"); |
64a7c78d | 66 | } |
67 | ||
cbf06263 | 68 | |
64a7c78d | 69 | //______________________________________________________________________________________________ |
70 | AliZDCPreprocessor::~AliZDCPreprocessor() | |
71 | { | |
72 | // destructor | |
73 | } | |
74 | ||
7a78280f | 75 | |
64a7c78d | 76 | //______________________________________________________________________________________________ |
77 | void AliZDCPreprocessor::Initialize(Int_t run, UInt_t startTime, | |
78 | UInt_t endTime) | |
79 | { | |
80 | // Creates AliZDCDataDCS object | |
81 | ||
82 | AliPreprocessor::Initialize(run, startTime, endTime); | |
83 | ||
e83c8d88 | 84 | AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s \n\tStartTime DCS Query %s \n\tEndTime DCS Query %s", run, |
85 | TTimeStamp(startTime).AsString(), | |
86 | TTimeStamp(endTime).AsString(), ((TTimeStamp)GetStartTimeDCSQuery()).AsString(), ((TTimeStamp)GetEndTimeDCSQuery()).AsString())); | |
64a7c78d | 87 | |
73bc3a3f | 88 | fRun = run; |
89 | fStartTime = startTime; | |
90 | fEndTime = endTime; | |
79563ba1 | 91 | |
e83c8d88 | 92 | fData = new AliZDCDataDCS(fRun, fStartTime, fEndTime, GetStartTimeDCSQuery(), GetEndTimeDCSQuery()); |
93 | } | |
94 | ||
95 | //_____________________________________________________________________________ | |
96 | Bool_t AliZDCPreprocessor::ProcessDCS(){ | |
97 | ||
98 | // tells whether DCS should be processed or not | |
99 | ||
100 | TString runType = GetRunType(); | |
101 | Log(Form("RunType %s",runType.Data())); | |
102 | ||
103 | if (runType=="STANDALONE_COSMIC" || runType=="STANDALONE_PEDESTAL"){ | |
104 | return kFALSE; | |
105 | } | |
106 | ||
107 | return kTRUE; | |
108 | } | |
109 | ||
110 | //______________________________________________________________________________________________ | |
111 | UInt_t AliZDCPreprocessor::ProcessDCSData(TMap* dcsAliasMap) | |
112 | { | |
113 | ||
114 | // Fills data into a AliZDCDataDCS object | |
115 | if(!dcsAliasMap) return 1; | |
116 | Log(Form("Processing data from DCS")); | |
117 | ||
118 | // The processing of the DCS input data is forwarded to AliZDCDataDCS | |
119 | Float_t dcsValues[28]; // DCSAliases=28 | |
120 | fData->SetCalibData(dcsValues); | |
121 | Bool_t resDCSProcess = fData->ProcessData(*dcsAliasMap); | |
122 | //dcsAliasMap->Print(""); | |
123 | if(resDCSProcess==kFALSE) Log(" Problems in processing DCS DP"); | |
124 | ||
125 | // Store DCS data for reference | |
126 | AliCDBMetaData metadata; | |
127 | metadata.SetResponsible("Chiara Oppedisano"); | |
128 | metadata.SetComment("DCS data for ZDC"); | |
129 | Bool_t resDCSRef = kTRUE; | |
130 | resDCSRef = StoreReferenceData("DCS","Data",fData,&metadata); | |
131 | ||
132 | if(resDCSRef==kFALSE) return 2; | |
133 | ||
134 | // --- Writing ZDC table positions into alignment object | |
135 | TClonesArray *array = new TClonesArray("AliAlignObjParams",10); | |
136 | TClonesArray &alobj = *array; | |
137 | AliAlignObjParams a; | |
138 | Double_t dx=0., dz=0., dpsi=0., dtheta=0., dphi=0.; | |
139 | // Vertical table position in mm from DCS | |
140 | Double_t dyZN1 = (Double_t) (dcsValues[0]/10.); | |
141 | Double_t dyZP1 = (Double_t) (dcsValues[1]/10.); | |
142 | Double_t dyZN2 = (Double_t) (dcsValues[2]/10.); | |
143 | Double_t dyZP2 = (Double_t) (dcsValues[3]/10.); | |
144 | // | |
145 | const char *n1ZDC="ZDC/NeutronZDC_C"; | |
146 | const char *p1ZDC="ZDC/ProtonZDC_C"; | |
147 | const char *n2ZDC="ZDC/NeutronZDC_A"; | |
148 | const char *p2ZDC="ZDC/ProtonZDC_A"; | |
149 | // | |
150 | UShort_t iIndex=0; | |
151 | AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer; | |
152 | UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex); | |
153 | // | |
154 | new(alobj[0]) AliAlignObjParams(n1ZDC, volid, dx, dyZN1, dz, dpsi, dtheta, dphi, kTRUE); | |
155 | new(alobj[1]) AliAlignObjParams(p1ZDC, volid, dx, dyZP1, dz, dpsi, dtheta, dphi, kTRUE); | |
156 | new(alobj[2]) AliAlignObjParams(n2ZDC, volid, dx, dyZN2, dz, dpsi, dtheta, dphi, kTRUE); | |
157 | new(alobj[3]) AliAlignObjParams(p2ZDC, volid, dx, dyZP2, dz, dpsi, dtheta, dphi, kTRUE); | |
158 | ||
159 | // save in CDB storage | |
160 | AliCDBMetaData mdDCS; | |
161 | mdDCS.SetResponsible("Chiara Oppedisano"); | |
162 | mdDCS.SetComment("Alignment object for ZDC"); | |
163 | Bool_t resultAl = Store("Align","Data", array, &mdDCS, 0, 0); | |
164 | if(resultAl==kFALSE) return 3; | |
165 | ||
166 | return 0; | |
64a7c78d | 167 | } |
168 | ||
321fe3b8 | 169 | //______________________________________________________________________________________________ |
170 | UInt_t AliZDCPreprocessor::ProcessChMap(TString runType) | |
171 | { | |
e83c8d88 | 172 | const int kNch = 48; |
173 | ||
3c159ed0 | 174 | // Reading the file for mapping from FXS |
175 | TList* daqSource = GetFileSources(kDAQ, runType.Data()); | |
321fe3b8 | 176 | if(!daqSource){ |
3c159ed0 | 177 | AliError(Form("No sources run %d for run type %s!", fRun, runType.Data())); |
e83c8d88 | 178 | return 4; |
321fe3b8 | 179 | } |
73bc3a3f | 180 | Log("\t List of DAQ sources for mapping "); daqSource->Print(); |
321fe3b8 | 181 | // |
182 | TIter iter(daqSource); | |
183 | TObjString* source = 0; | |
b8d194f5 | 184 | Int_t isou = 0; |
e83c8d88 | 185 | Int_t readMap[kNch][6]; |
3c159ed0 | 186 | // |
321fe3b8 | 187 | while((source = dynamic_cast<TObjString*> (iter.Next()))){ |
188 | Log(Form("\n\t Getting file #%d\n",++isou)); | |
c00e895a | 189 | TString fileName = "ZDCChMapping.dat"; |
321fe3b8 | 190 | |
191 | if(fileName.Length() <= 0){ | |
192 | Log(Form("No file from source %s!", source->GetName())); | |
e83c8d88 | 193 | return 4; |
321fe3b8 | 194 | } |
c00e895a | 195 | // --- Reading file with calibration data |
196 | //const char* fname = fileName.Data(); | |
197 | if(fileName){ | |
321fe3b8 | 198 | FILE *file; |
c00e895a | 199 | if((file = fopen(fileName,"r")) == NULL){ |
200 | printf("Cannot open file %s \n",fileName.Data()); | |
e83c8d88 | 201 | return 4; |
321fe3b8 | 202 | } |
c00e895a | 203 | Log(Form("File %s connected to process data for ADC mapping", fileName.Data())); |
321fe3b8 | 204 | // |
e83c8d88 | 205 | for(Int_t j=0; j<kNch; j++){ |
321fe3b8 | 206 | for(Int_t k=0; k<6; k++){ |
73bc3a3f | 207 | int read = fscanf(file,"%d",&readMap[j][k]); |
e83c8d88 | 208 | if(read == 0) AliDebug(3," Failing in reading data from mapping file"); |
321fe3b8 | 209 | } |
321fe3b8 | 210 | } |
211 | fclose(file); | |
212 | } | |
213 | else{ | |
c00e895a | 214 | Log(Form("File %s not found", fileName.Data())); |
e83c8d88 | 215 | return 4; |
321fe3b8 | 216 | } |
3c159ed0 | 217 | } |
218 | delete daqSource; daqSource=0; | |
219 | ||
220 | // Store the currently read map ONLY IF it is different | |
221 | // from the entry in the OCDB | |
222 | Bool_t updateOCDB = kFALSE; | |
223 | ||
224 | AliCDBEntry *cdbEntry = GetFromOCDB("Calib","ChMap"); | |
225 | if(!cdbEntry){ | |
73bc3a3f | 226 | Log(" No existing CDB entry for ADC mapping"); |
3c159ed0 | 227 | updateOCDB = kTRUE; |
228 | } | |
229 | else{ | |
230 | AliZDCChMap *chMap = (AliZDCChMap*) cdbEntry->GetObject(); | |
e83c8d88 | 231 | for(Int_t i=0; i<kNch; i++){ |
3c159ed0 | 232 | if( (readMap[i][1] == chMap->GetADCModule(i)) |
233 | && (readMap[i][2] == chMap->GetADCChannel(i)) | |
234 | && (readMap[i][4] == chMap->GetDetector(i)) | |
235 | && (readMap[i][5] == chMap->GetSector(i))){ | |
236 | updateOCDB = kFALSE; | |
237 | } | |
238 | else updateOCDB = kTRUE; | |
239 | } | |
240 | } | |
241 | // | |
e83c8d88 | 242 | Bool_t resChMapStore = kTRUE; |
3c159ed0 | 243 | if(updateOCDB==kTRUE){ |
73bc3a3f | 244 | Log(" A new entry ZDC/Calib/ChMap will be created"); |
3c159ed0 | 245 | // |
246 | // --- Initializing mapping calibration object | |
247 | AliZDCChMap *mapCalib = new AliZDCChMap("ZDC"); | |
248 | // Writing channel map in the OCDB | |
e83c8d88 | 249 | for(Int_t k=0; k<kNch; k++){ |
3c159ed0 | 250 | mapCalib->SetADCModule(k,readMap[k][1]); |
251 | mapCalib->SetADCChannel(k,readMap[k][2]); | |
252 | mapCalib->SetDetector(k,readMap[k][4]); | |
253 | mapCalib->SetSector(k,readMap[k][5]); | |
254 | } | |
255 | //mapCalib->Print(""); | |
321fe3b8 | 256 | // |
257 | AliCDBMetaData metaData; | |
258 | metaData.SetBeamPeriod(0); | |
259 | metaData.SetResponsible("Chiara Oppedisano"); | |
260 | metaData.SetComment("Filling AliZDCChMap object"); | |
261 | // | |
e83c8d88 | 262 | resChMapStore = Store("Calib","ChMap",mapCalib, &metaData, 0, 1); |
321fe3b8 | 263 | } |
3c159ed0 | 264 | else{ |
73bc3a3f | 265 | Log(" ZDC/Calib/ChMap entry in OCDB is valid and won't be updated"); |
e83c8d88 | 266 | resChMapStore = kTRUE; |
3c159ed0 | 267 | } |
6f427255 | 268 | |
e83c8d88 | 269 | if(resChMapStore==kFALSE) return 5; |
270 | ||
271 | return 0; | |
321fe3b8 | 272 | |
273 | } | |
274 | ||
64a7c78d | 275 | //______________________________________________________________________________________________ |
e83c8d88 | 276 | UInt_t AliZDCPreprocessor::ProcessppData() |
64a7c78d | 277 | { |
e83c8d88 | 278 | Bool_t resEnCal=kTRUE, resTowCal=kTRUE; |
79563ba1 | 279 | |
73bc3a3f | 280 | // *********** Energy calibration |
3c159ed0 | 281 | // --- Cheking if there is already the entry in the OCDB |
5df9f417 | 282 | AliCDBEntry *cdbEnEntry = GetFromOCDB("Calib", "EnergyCalib"); |
73bc3a3f | 283 | if(!cdbEnEntry){ |
dd98e862 | 284 | Log(Form(" ZDC/Calib/EnergyCalib entry will be created")); |
3c159ed0 | 285 | // --- Initializing calibration object |
73bc3a3f | 286 | AliCDBMetaData metaData; |
287 | metaData.SetBeamPeriod(0); | |
288 | metaData.SetResponsible("Chiara Oppedisano"); | |
3c159ed0 | 289 | // |
73bc3a3f | 290 | AliZDCEnCalib *eCalib = new AliZDCEnCalib("ZDC"); |
3c159ed0 | 291 | for(Int_t j=0; j<6; j++) eCalib->SetEnCalib(j,1.); |
73bc3a3f | 292 | metaData.SetComment("AliZDCEnCalib object"); |
293 | //eCalib->Print(""); | |
5df9f417 | 294 | resEnCal = Store("Calib", "EnergyCalib", eCalib, &metaData, 0, 1); |
73bc3a3f | 295 | } |
296 | else{ | |
297 | // if entry exists it is still valid (=1 for all runs!) | |
dd98e862 | 298 | Log(Form(" Valid ZDC/Calib/EnergyCalib object already existing in OCDB!!!")); |
73bc3a3f | 299 | resEnCal = kTRUE; |
300 | } | |
e83c8d88 | 301 | |
302 | if(resEnCal==kFALSE) return 6; | |
303 | ||
73bc3a3f | 304 | // |
305 | // *********** Tower inter-calibration | |
306 | // --- Cheking if there is already the entry in the OCDB | |
5df9f417 | 307 | AliCDBEntry *cdbTowEntry = GetFromOCDB("Calib", "TowerCalib"); |
73bc3a3f | 308 | if(!cdbTowEntry){ |
309 | AliZDCTowerCalib *towCalib = new AliZDCTowerCalib("ZDC"); | |
3c159ed0 | 310 | for(Int_t j=0; j<5; j++){ |
73bc3a3f | 311 | towCalib->SetZN1EqualCoeff(j, 1.); |
312 | towCalib->SetZP1EqualCoeff(j, 1.); | |
313 | towCalib->SetZN2EqualCoeff(j, 1.); | |
314 | towCalib->SetZP2EqualCoeff(j, 1.); | |
3c159ed0 | 315 | } |
73bc3a3f | 316 | //towCalib->Print(""); |
317 | // | |
318 | AliCDBMetaData metaData; | |
319 | metaData.SetBeamPeriod(0); | |
320 | metaData.SetResponsible("Chiara Oppedisano"); | |
321 | metaData.SetComment("AliZDCTowerCalib object"); | |
322 | // | |
5df9f417 | 323 | resTowCal = Store("Calib", "TowerCalib", towCalib, &metaData, 0, 1); |
73bc3a3f | 324 | } |
325 | else{ | |
326 | // if entry exists it is still valid (=1 for all runs!) | |
dd98e862 | 327 | Log(Form(" Valid ZDC/Calib/TowerCalib object already existing in OCDB!!!")); |
73bc3a3f | 328 | resTowCal = kTRUE; |
329 | } | |
330 | ||
e83c8d88 | 331 | if(resTowCal==kFALSE) return 7; |
332 | ||
333 | return 0; | |
334 | } | |
335 | ||
336 | //______________________________________________________________________________________________ | |
337 | UInt_t AliZDCPreprocessor::ProcessCalibData() | |
338 | { | |
339 | TList* daqSources = GetFileSources(kDAQ, "ENERGYCALIB"); | |
340 | if(!daqSources){ | |
341 | AliError(Form("No sources for CALIBRATION_EMD run %d !", fRun)); | |
342 | return 4; | |
343 | } | |
344 | Log("\t List of DAQ sources for CALIBRATION_EMD run"); | |
345 | daqSources->Print(); | |
346 | // | |
347 | TIter iter2(daqSources); | |
348 | TObjString* source = 0; | |
349 | Int_t i=0; | |
350 | Bool_t resEnCal=kTRUE; | |
351 | while((source = dynamic_cast<TObjString*> (iter2.Next()))){ | |
352 | Log(Form("\n\t Getting file #%d\n",++i)); | |
353 | TString stringEMDFileName = GetFile(kDAQ, "ENERGYCALIB", source->GetName()); | |
354 | if(stringEMDFileName.Length() <= 0){ | |
355 | Log(Form("No file from source %s!", source->GetName())); | |
356 | return 4; | |
357 | } | |
358 | // --- Initializing energy calibration object | |
359 | AliZDCEnCalib *eCalib = new AliZDCEnCalib("ZDC"); | |
360 | // --- Reading file with pedestal calibration data | |
361 | const char* emdFileName = stringEMDFileName.Data(); | |
362 | if(emdFileName){ | |
363 | FILE *file; | |
364 | if((file = fopen(emdFileName,"r")) == NULL){ | |
365 | printf("Cannot open file %s \n",emdFileName); | |
366 | return 4; | |
367 | } | |
368 | Log(Form("File %s connected to process data from EM dissociation events", emdFileName)); | |
369 | // | |
370 | Float_t fitValEMD[6]; | |
371 | for(Int_t j=0; j<6; j++){ | |
372 | if(j<6){ | |
373 | int iread = fscanf(file,"%f",&fitValEMD[j]); | |
374 | if(iread==0) AliDebug(3," Failing reading daa from EMD calibration data file"); | |
375 | eCalib->SetEnCalib(j,fitValEMD[j]); | |
376 | } | |
377 | } | |
378 | // | |
379 | fclose(file); | |
380 | } | |
381 | else{ | |
382 | Log(Form("File %s not found", emdFileName)); | |
383 | return 4; | |
384 | } | |
385 | //eCalib->Print(""); | |
386 | // | |
387 | AliCDBMetaData metaData; | |
388 | metaData.SetBeamPeriod(0); | |
389 | metaData.SetResponsible("Chiara Oppedisano"); | |
390 | metaData.SetComment("Filling AliZDCEnCalib object"); | |
391 | // | |
392 | resEnCal = Store("Calib","EnergyCalib",eCalib, &metaData, 0, 1); | |
393 | if(resEnCal==kFALSE) return 6; | |
394 | } | |
395 | delete daqSources; daqSources = 0; | |
396 | ||
397 | ||
398 | TList* daqSourcesH = GetFileSources(kDAQ, "TOWERCALIB"); | |
399 | if(!daqSourcesH){ | |
400 | AliError(Form("No sources for CALIBRATION_EMD run %d !", fRun)); | |
401 | return 4; | |
402 | } | |
403 | Log("\t List of DAQ sources for CALIBRATION_EMD run"); | |
404 | daqSourcesH->Print(); | |
405 | // | |
406 | TIter iter2H(daqSourcesH); | |
407 | TObjString* sourceH = 0; | |
408 | Int_t iH=0; | |
409 | Bool_t resTowCal=kTRUE; | |
410 | while((sourceH = dynamic_cast<TObjString*> (iter2H.Next()))){ | |
411 | Log(Form("\n\t Getting file #%d\n",++iH)); | |
412 | TString stringEMDFileName = GetFile(kDAQ, "TOWERCALIB", sourceH->GetName()); | |
413 | if(stringEMDFileName.Length() <= 0){ | |
414 | Log(Form("No file from source %s!", sourceH->GetName())); | |
415 | return 4; | |
416 | } | |
417 | // --- Initializing energy calibration object | |
418 | AliZDCTowerCalib *towCalib = new AliZDCTowerCalib("ZDC"); | |
419 | // --- Reading file with pedestal calibration data | |
420 | const char* emdFileName = stringEMDFileName.Data(); | |
421 | if(emdFileName){ | |
422 | FILE *file; | |
423 | if((file = fopen(emdFileName,"r")) == NULL){ | |
424 | printf("Cannot open file %s \n",emdFileName); | |
425 | return 4; | |
426 | } | |
427 | Log(Form("File %s connected to process data from EM dissociation events", emdFileName)); | |
428 | // | |
429 | Float_t equalCoeff[4][5]; | |
430 | for(Int_t j=0; j<4; j++){ | |
431 | for(Int_t k=0; k<5; k++){ | |
432 | int leggi = fscanf(file,"%f",&equalCoeff[j][k]); | |
433 | if(leggi==0) AliDebug(3," Failing reading data from EMD calibration file"); | |
434 | if(j==0) towCalib->SetZN1EqualCoeff(k, equalCoeff[j][k]); | |
435 | else if(j==1) towCalib->SetZP1EqualCoeff(k, equalCoeff[j][k]); | |
436 | else if(j==2) towCalib->SetZN2EqualCoeff(k, equalCoeff[j][k]); | |
437 | else if(j==3) towCalib->SetZP2EqualCoeff(k, equalCoeff[j][k]); | |
438 | } | |
439 | } | |
440 | // | |
441 | fclose(file); | |
442 | } | |
443 | else{ | |
444 | Log(Form("File %s not found", emdFileName)); | |
445 | return 4; | |
446 | } | |
447 | //towCalib->Print(""); | |
448 | // | |
449 | AliCDBMetaData metaData; | |
450 | metaData.SetBeamPeriod(0); | |
451 | metaData.SetResponsible("Chiara Oppedisano"); | |
452 | metaData.SetComment("Filling AliZDCTowerCalib object"); | |
453 | // | |
454 | resTowCal = Store("Calib","TowerCalib",towCalib, &metaData, 0, 1); | |
455 | if(resTowCal==kFALSE) return 7; | |
456 | } | |
457 | delete daqSources; daqSources = 0; | |
458 | ||
459 | return 0; | |
460 | } | |
461 | ||
462 | //______________________________________________________________________________________________ | |
463 | UInt_t AliZDCPreprocessor::ProcessPedestalData() | |
464 | { | |
73bc3a3f | 465 | TList* daqSources = GetFileSources(kDAQ, "PEDESTALDATA"); |
cb50c7c8 | 466 | if(!daqSources){ |
78e8a1cc | 467 | Log(Form("No source for STANDALONE_PEDESTAL run %d !", fRun)); |
e83c8d88 | 468 | return 4; |
79563ba1 | 469 | } |
73bc3a3f | 470 | Log("\t List of DAQ sources for STANDALONE_PEDESTAL run"); |
cb50c7c8 | 471 | daqSources->Print(); |
79563ba1 | 472 | // |
cb50c7c8 | 473 | TIter iter(daqSources); |
474 | TObjString* source = 0; | |
79563ba1 | 475 | Int_t i=0; |
e83c8d88 | 476 | Bool_t resPedCal=kTRUE; |
cb50c7c8 | 477 | while((source = dynamic_cast<TObjString*> (iter.Next()))){ |
73bc3a3f | 478 | Log(Form("\n\t Getting file #%d\n",++i)); |
479 | TString stringPedFileName = GetFile(kDAQ, "PEDESTALDATA", source->GetName()); | |
480 | if(stringPedFileName.Length() <= 0){ | |
481 | Log(Form("No PEDESTAL file from source %s!", source->GetName())); | |
e83c8d88 | 482 | return 4; |
73bc3a3f | 483 | } |
484 | // calibration data | |
e83c8d88 | 485 | // --- Initializing pedestal calibration object |
486 | AliZDCPedestals *pedCalib = new AliZDCPedestals("ZDC"); | |
487 | // --- Reading file with pedestal calibration data | |
488 | const char* pedFileName = stringPedFileName.Data(); | |
489 | // no. ADCch = (22 signal ch. + 2 reference PMs) * 2 gain chain = 48 | |
490 | const Int_t knZDCch = 48; | |
73bc3a3f | 491 | |
e83c8d88 | 492 | FILE *file; |
493 | if((file = fopen(pedFileName,"r")) == NULL){ | |
494 | printf("Cannot open file %s \n",pedFileName); | |
495 | return 4; | |
496 | } | |
497 | Log(Form("File %s connected to process pedestal data", pedFileName)); | |
498 | Float_t pedVal[(2*knZDCch)][2]; | |
499 | for(Int_t k=0; k<(2*knZDCch); k++){ | |
500 | for(Int_t j=0; j<2; j++){ | |
501 | int aleggi = fscanf(file,"%f",&pedVal[k][j]); | |
502 | if(aleggi==0) AliDebug(3," Failing reading data from pedestal file"); | |
503 | //if(j==1) printf("pedVal[%d] -> %f, %f \n",k,pedVal[k][0],pedVal[k][1]); | |
504 | } | |
505 | if(k<knZDCch){ | |
506 | pedCalib->SetMeanPed(k,pedVal[k][0]); | |
507 | pedCalib->SetMeanPedWidth(k,pedVal[k][1]); | |
508 | } | |
509 | else if(k>=knZDCch && k<(2*knZDCch)){ | |
510 | pedCalib->SetOOTPed(k-knZDCch,pedVal[k][0]); | |
511 | pedCalib->SetOOTPedWidth(k-knZDCch,pedVal[k][1]); | |
512 | } | |
513 | else if(k>=(2*knZDCch) && k<(3*knZDCch)){ | |
514 | pedCalib->SetPedCorrCoeff(k-(2*knZDCch),pedVal[k][0],pedVal[k][1]); | |
515 | } | |
516 | } | |
517 | fclose(file); | |
518 | //pedCalib->Print(""); | |
519 | // | |
520 | AliCDBMetaData metaData; | |
521 | metaData.SetBeamPeriod(0); | |
522 | metaData.SetResponsible("Chiara Oppedisano"); | |
523 | metaData.SetComment("Filling AliZDCPedestals object"); | |
524 | // | |
525 | resPedCal = Store("Calib","Pedestals",pedCalib, &metaData, 0, 1); | |
526 | if(resPedCal==kFALSE) return 8; | |
64a7c78d | 527 | } |
cb50c7c8 | 528 | delete daqSources; daqSources = 0; |
e83c8d88 | 529 | |
73bc3a3f | 530 | // |
e83c8d88 | 531 | Bool_t resPedHist=kTRUE; |
73bc3a3f | 532 | TList* daqSourceH = GetFileSources(kDAQ, "PEDHISTOS"); |
533 | if(!daqSourceH){ | |
534 | Log(Form("No source for STANDALONE_PEDESTAL run %d !", fRun)); | |
e83c8d88 | 535 | return 4; |
73bc3a3f | 536 | } |
537 | Log("\t List of DAQ sources for STANDALONE_PEDESTAL run"); | |
538 | daqSourceH->Print(); | |
539 | // | |
540 | TIter iterH(daqSourceH); | |
541 | TObjString* sourceH = 0; | |
542 | Int_t iH=0; | |
543 | while((sourceH = dynamic_cast<TObjString*> (iterH.Next()))){ | |
544 | Log(Form("\n\t Getting file #%d\n",++iH)); | |
545 | TString stringPedFileName = GetFile(kDAQ, "PEDHISTOS", sourceH->GetName()); | |
546 | if(stringPedFileName.Length() <= 0){ | |
547 | Log(Form("No PEDESTAL file from source %s!", sourceH->GetName())); | |
e83c8d88 | 548 | return 4; |
73bc3a3f | 549 | } |
550 | TFile *histoFile = TFile::Open(stringPedFileName.Data()); | |
551 | // | |
db0907f4 | 552 | AliCDBMetaData metadata1; |
553 | metadata1.SetResponsible("Chiara Oppedisano"); | |
554 | metadata1.SetComment("Pedestal histos"); | |
555 | resPedHist = StoreReferenceData("Histos","Pedestal", histoFile, &metadata1); | |
e83c8d88 | 556 | if(resPedHist==kFALSE) return 9; |
73bc3a3f | 557 | } |
558 | delete daqSourceH; daqSourceH = 0; | |
e83c8d88 | 559 | |
560 | ||
561 | return 0; | |
562 | } | |
563 | ||
564 | //______________________________________________________________________________________________ | |
565 | UInt_t AliZDCPreprocessor::ProcessLaserData() | |
566 | { | |
73bc3a3f | 567 | TList* daqSources = GetFileSources(kDAQ, "LASERDATA"); |
1ee299a5 | 568 | if(!daqSources){ |
569 | AliError(Form("No sources for STANDALONE_LASER run %d !", fRun)); | |
570 | return 1; | |
571 | } | |
73bc3a3f | 572 | Log("\t List of DAQ sources for STANDALONE_LASER run"); |
1ee299a5 | 573 | daqSources->Print(); |
574 | // | |
575 | TIter iter2(daqSources); | |
576 | TObjString* source = 0; | |
577 | Int_t i=0; | |
e83c8d88 | 578 | Bool_t resLaserCal=kTRUE; |
1ee299a5 | 579 | while((source = dynamic_cast<TObjString*> (iter2.Next()))){ |
73bc3a3f | 580 | Log(Form("\n\t Getting file #%d\n",++i)); |
581 | TString stringLASERFileName = GetFile(kDAQ, "LASERDATA", source->GetName()); | |
582 | if(stringLASERFileName.Length() <= 0){ | |
583 | Log(Form("No LASER file from source %s!", source->GetName())); | |
584 | return 1; | |
585 | } | |
586 | // --- Initializing pedestal calibration object | |
587 | AliZDCLaserCalib *lCalib = new AliZDCLaserCalib("ZDC"); | |
588 | // --- Reading file with pedestal calibration data | |
589 | const char* laserFileName = stringLASERFileName.Data(); | |
590 | if(laserFileName){ | |
591 | FILE *file; | |
592 | if((file = fopen(laserFileName,"r")) == NULL){ | |
593 | printf("Cannot open file %s \n",laserFileName); | |
1ee299a5 | 594 | return 1; |
595 | } | |
73bc3a3f | 596 | Log(Form("File %s connected to process data from LASER events", laserFileName)); |
1ee299a5 | 597 | // |
73bc3a3f | 598 | Float_t ivalRead[22][4]; |
599 | for(Int_t j=0; j<22; j++){ | |
600 | for(Int_t k=0; k<4; k++){ | |
e83c8d88 | 601 | int aleggi = fscanf(file,"%f",&ivalRead[j][k]); |
602 | if(aleggi==0) AliDebug(3," Failng reading data from laser file"); | |
73bc3a3f | 603 | //printf(" %d %1.0f ",k, ivalRead[j][k]); |
604 | } | |
605 | lCalib->SetDetector(j, (Int_t) ivalRead[j][0]); | |
606 | lCalib->SetSector(j, (Int_t) ivalRead[j][1]); | |
607 | lCalib->SetfPMValue(j, ivalRead[j][2]); | |
608 | lCalib->SetfPMWidth(j, ivalRead[j][3]); | |
609 | } | |
610 | fclose(file); | |
611 | } | |
612 | else{ | |
613 | Log(Form("File %s not found", laserFileName)); | |
614 | return 1; | |
615 | } | |
616 | //lCalib->Print(""); | |
617 | // | |
618 | AliCDBMetaData metaData; | |
619 | metaData.SetBeamPeriod(0); | |
620 | metaData.SetResponsible("Chiara Oppedisano"); | |
621 | metaData.SetComment("Filling AliZDCLaserCalib object"); | |
622 | // | |
623 | resLaserCal = Store("Calib","LaserCalib",lCalib, &metaData, 0, 1); | |
e83c8d88 | 624 | if(resLaserCal==kFALSE) return 10; |
1ee299a5 | 625 | } |
73bc3a3f | 626 | delete daqSources; daqSources = 0; |
e83c8d88 | 627 | |
628 | ||
73bc3a3f | 629 | TList* daqSourceH = GetFileSources(kDAQ, "LASERHISTOS"); |
630 | if(!daqSourceH){ | |
631 | AliError(Form("No sources for STANDALONE_LASER run %d !", fRun)); | |
632 | return 1; | |
633 | } | |
634 | Log("\t List of DAQ sources for STANDALONE_LASER run"); | |
635 | daqSourceH->Print(); | |
636 | // | |
637 | TIter iter2H(daqSourceH); | |
638 | TObjString* sourceH = 0; | |
639 | Int_t iH=0; | |
e83c8d88 | 640 | Bool_t resPedHist = kTRUE; |
73bc3a3f | 641 | while((sourceH = dynamic_cast<TObjString*> (iter2H.Next()))){ |
642 | Log(Form("\n\t Getting file #%d\n",++iH)); | |
643 | TString stringLASERFileName = GetFile(kDAQ, "LASERHISTOS", sourceH->GetName()); | |
644 | if(stringLASERFileName.Length() <= 0){ | |
645 | Log(Form("No LASER file from source %s!", sourceH->GetName())); | |
646 | return 1; | |
647 | } | |
648 | TFile *histoFile = TFile::Open(stringLASERFileName.Data()); | |
649 | // | |
db0907f4 | 650 | AliCDBMetaData metadata2; |
651 | metadata2.SetResponsible("Chiara Oppedisano"); | |
652 | metadata2.SetComment("Laser run histos"); | |
653 | resPedHist = StoreReferenceData("Histos", "Laser", histoFile, &metadata2); | |
e83c8d88 | 654 | // |
655 | if(resPedHist==kFALSE) return 11; | |
73bc3a3f | 656 | } |
657 | delete daqSourceH; daqSourceH = 0; | |
e83c8d88 | 658 | |
659 | return 0; | |
660 | } | |
661 | ||
662 | //______________________________________________________________________________________________ | |
663 | UInt_t AliZDCPreprocessor::Process(TMap* dcsAliasMap) | |
664 | { | |
665 | UInt_t resDCS = 0; | |
666 | UInt_t resChMap=0; | |
667 | UInt_t resEnergyCalib=0, resPedestalCalib=0, resLaserCalib=0; | |
668 | ||
669 | // ************************* Process DCS data **************************** | |
670 | if(ProcessDCS()) resDCS = ProcessDCSData(dcsAliasMap); | |
671 | ||
672 | // ********************************* From DAQ ************************************ | |
673 | ||
674 | const char* beamType = GetRunParameter("beamType"); | |
675 | TString runType = GetRunType(); | |
676 | printf("\n\t AliZDCPreprocessor -> beamType %s, runType %s\n",beamType,runType.Data()); | |
677 | ||
678 | // ****************************************** | |
679 | // ADC channel mapping | |
680 | // ****************************************** | |
681 | resChMap = ProcessChMap(runType); | |
682 | ||
683 | // ****************************************** | |
684 | // Calibration param. for p-p data (all = 1) | |
685 | // ****************************************** | |
686 | // NO ENERGY CALIBRATION -> coefficients set to 1. | |
687 | // Temp -> also inter-calibration coefficients are set to 1. | |
688 | if(strcmp(beamType,"P-P")==0) resEnergyCalib = ProcessppData(); | |
689 | ||
b8d194f5 | 690 | // ***************************************************** |
e83c8d88 | 691 | // EMD EVENTS -> Energy calibration and equalization |
b8d194f5 | 692 | // ***************************************************** |
e83c8d88 | 693 | if(runType=="CALIBRATION_EMD" && strcmp(beamType,"A-A")==0) |
694 | resEnergyCalib = ProcessCalibData(); | |
695 | ||
696 | // ***************************************************** | |
697 | // STANDALONE_PEDESTALS -> Pedestal subtraction | |
698 | // ***************************************************** | |
699 | if(runType=="STANDALONE_PEDESTAL") resPedestalCalib = ProcessPedestalData(); | |
700 | ||
701 | // ***************************************************** | |
702 | // STANDALONE_LASER -> Signal stability and ageing | |
703 | // ***************************************************** | |
704 | if(runType=="STANDALONE_LASER") resLaserCalib = ProcessLaserData(); | |
705 | ||
028eb4a1 | 706 | |
e83c8d88 | 707 | if(resDCS!=0) return resDCS; |
708 | else if(resChMap!=0) return resChMap; | |
709 | else if(resEnergyCalib!=0) return resEnergyCalib; | |
710 | else if(resPedestalCalib!=0) return resPedestalCalib; | |
711 | else if(resLaserCalib!=0) return resLaserCalib; | |
79563ba1 | 712 | |
e83c8d88 | 713 | return 0; |
cb50c7c8 | 714 | |
64a7c78d | 715 | } |