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