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