]>
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" | |
0d579f58 | 22 | #include "AliZDCMBCalib.h" |
27d1ff1f | 23 | #include "AliZDCTDCCalib.h" |
64a7c78d | 24 | |
d5e687c2 | 25 | ///////////////////////////////////////////////////////////////////// |
26 | // // | |
73bc3a3f | 27 | // Class implementing Shuttle ZDC pre-processor. // |
28 | // It takes data from DCS and DAQ and writes calibration objects // | |
29 | // in the OCDB and reference values/histos in the ReferenceData. // | |
d5e687c2 | 30 | // // |
31 | ///////////////////////////////////////////////////////////////////// | |
64a7c78d | 32 | |
e83c8d88 | 33 | // ****************************************************************** |
34 | // RETURN CODES: | |
da2b6160 | 35 | // return 0 : everything OK |
36 | // return 1 : no DCS input data Map | |
37 | // return 2 : error storing DCS data in RefData | |
38 | // return 3 : error storing alignment object in OCDB | |
39 | // return 4 : error in ZDCMapping.dat file retrieved from DAQ FXS (not existing|empty|corrupted) | |
40 | // return 5 : error storing mapping obj. in OCDB | |
41 | // return 6 : error storing energy calibration obj. in OCDB | |
42 | // return 7 : error storing tower inter-calibration obj. in OCDB | |
43 | // return 8 : error in ZDCEnergyCalib.dat file retrieved from DAQ FXS | |
44 | // return 9 : error in ZDCTowerCalib.dat file retrieved from DAQ FXS | |
45 | // return 10: error in ZDCPedestal.dat file retrieved from DAQ FXS | |
46 | // return 11: error storing pedestal calibration obj. in OCDB | |
47 | // return 12: error in ZDCPedHisto.root file retrieved from DAQ FXS | |
48 | // return 13: error storing pedestal histos in RefData | |
49 | // return 14: error in ZDCLaserCalib.dat file retrieved from DAQ FXS | |
50 | // return 15: error storing laser calibration obj. in OCDB | |
51 | // return 16: error in ZDCLaserHisto.root file retrieved from DAQ FXS | |
52 | // return 17: error storing laser histos in RefData | |
0d579f58 | 53 | // return 18: error in ZDCMBCalib.root file retrieved from DAQ FXS |
54 | // return 19: error storing MB calibration obj. in OCDB | |
27d1ff1f | 55 | // return 20: error in ZDCTDCCalib.root file retrieved from DAQ FXS |
56 | // return 21: error in storing TDC calibration obj. in OCDB | |
57 | // return 22: error in ZDCTDCHisto.root file retrieved from DAQ FXS | |
58 | // Return 23: error storing TDC reference histos in RefData | |
e83c8d88 | 59 | // ****************************************************************** |
60 | ||
64a7c78d | 61 | ClassImp(AliZDCPreprocessor) |
62 | ||
63 | //______________________________________________________________________________________________ | |
857ece97 | 64 | AliZDCPreprocessor::AliZDCPreprocessor(AliShuttleInterface* shuttle) : |
65 | AliPreprocessor("ZDC", shuttle), | |
64a7c78d | 66 | fData(0) |
67 | { | |
68 | // constructor | |
b8d194f5 | 69 | // May 2009 - run types updated according to |
70 | // http://alice-ecs.web.cern.ch/alice-ecs/runtypes_3.36.html | |
cbf06263 | 71 | AddRunType("STANDALONE_PEDESTAL"); |
1ee299a5 | 72 | AddRunType("STANDALONE_LASER"); |
321fe3b8 | 73 | AddRunType("STANDALONE_COSMIC"); |
b8d194f5 | 74 | AddRunType("CALIBRATION_EMD"); |
75 | AddRunType("CALIBRATION_MB"); | |
76 | AddRunType("CALIBRATION_CENTRAL"); | |
77 | AddRunType("CALIBRATION_SEMICENTRAL"); | |
78 | AddRunType("CALIBRATION_BC"); | |
321fe3b8 | 79 | AddRunType("PHYSICS"); |
64a7c78d | 80 | } |
81 | ||
cbf06263 | 82 | |
64a7c78d | 83 | //______________________________________________________________________________________________ |
84 | AliZDCPreprocessor::~AliZDCPreprocessor() | |
85 | { | |
86 | // destructor | |
87 | } | |
88 | ||
7a78280f | 89 | |
64a7c78d | 90 | //______________________________________________________________________________________________ |
da2b6160 | 91 | void AliZDCPreprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime) |
64a7c78d | 92 | { |
93 | // Creates AliZDCDataDCS object | |
94 | ||
95 | AliPreprocessor::Initialize(run, startTime, endTime); | |
96 | ||
57c85e6e | 97 | AliDebug(2,Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s \n\tStartTime DCS Query %s \n\tEndTime DCS Query %s", run, |
e83c8d88 | 98 | TTimeStamp(startTime).AsString(), |
99 | TTimeStamp(endTime).AsString(), ((TTimeStamp)GetStartTimeDCSQuery()).AsString(), ((TTimeStamp)GetEndTimeDCSQuery()).AsString())); | |
64a7c78d | 100 | |
73bc3a3f | 101 | fRun = run; |
102 | fStartTime = startTime; | |
103 | fEndTime = endTime; | |
79563ba1 | 104 | |
e83c8d88 | 105 | fData = new AliZDCDataDCS(fRun, fStartTime, fEndTime, GetStartTimeDCSQuery(), GetEndTimeDCSQuery()); |
106 | } | |
107 | ||
108 | //_____________________________________________________________________________ | |
109 | Bool_t AliZDCPreprocessor::ProcessDCS(){ | |
110 | ||
111 | // tells whether DCS should be processed or not | |
112 | ||
113 | TString runType = GetRunType(); | |
114 | Log(Form("RunType %s",runType.Data())); | |
115 | ||
116 | if (runType=="STANDALONE_COSMIC" || runType=="STANDALONE_PEDESTAL"){ | |
117 | return kFALSE; | |
118 | } | |
119 | ||
120 | return kTRUE; | |
121 | } | |
122 | ||
123 | //______________________________________________________________________________________________ | |
124 | UInt_t AliZDCPreprocessor::ProcessDCSData(TMap* dcsAliasMap) | |
125 | { | |
126 | ||
127 | // Fills data into a AliZDCDataDCS object | |
bf867209 | 128 | if(!dcsAliasMap){ |
129 | Log(" No DCS map found: ZDC exiting from Shuttle"); | |
57c85e6e | 130 | if(fData){ |
131 | delete fData; | |
132 | fData = 0; | |
133 | } | |
bf867209 | 134 | return 1; |
135 | } | |
136 | ||
e83c8d88 | 137 | Log(Form("Processing data from DCS")); |
bf867209 | 138 | |
e83c8d88 | 139 | // The processing of the DCS input data is forwarded to AliZDCDataDCS |
e83c8d88 | 140 | //dcsAliasMap->Print(""); |
bf867209 | 141 | Bool_t resDCSProcess = fData->ProcessData(*dcsAliasMap); |
142 | if(resDCSProcess==kFALSE){ | |
143 | Log(" Problems in processing DCS DP"); | |
144 | return 1; | |
57c85e6e | 145 | } |
e83c8d88 | 146 | |
0d579f58 | 147 | // ------------------------------------------------------ |
148 | // Change introduced 26/9/09 in order NOT to process the | |
149 | // HV DP since some of them are never found in amanda DB | |
150 | // ------------------------------------------------------ | |
57c85e6e | 151 | // Store DCS data as reference |
aee13a2d | 152 | AliCDBMetaData metadata; |
e83c8d88 | 153 | metadata.SetResponsible("Chiara Oppedisano"); |
57c85e6e | 154 | metadata.SetComment("DCS DP TMap for ZDC"); |
e83c8d88 | 155 | Bool_t resDCSRef = kTRUE; |
57c85e6e | 156 | resDCSRef = StoreReferenceData("DCS","Data", dcsAliasMap, &metadata); |
e83c8d88 | 157 | |
158 | if(resDCSRef==kFALSE) return 2; | |
aee13a2d | 159 | |
e83c8d88 | 160 | // --- Writing ZDC table positions into alignment object |
161 | TClonesArray *array = new TClonesArray("AliAlignObjParams",10); | |
162 | TClonesArray &alobj = *array; | |
163 | AliAlignObjParams a; | |
164 | Double_t dx=0., dz=0., dpsi=0., dtheta=0., dphi=0.; | |
165 | // Vertical table position in mm from DCS | |
57c85e6e | 166 | Double_t dyZN1 = (Double_t) (fData->GetAlignData(0)/10.); |
167 | Double_t dyZP1 = (Double_t) (fData->GetAlignData(1)/10.); | |
168 | Double_t dyZN2 = (Double_t) (fData->GetAlignData(2)/10.); | |
169 | Double_t dyZP2 = (Double_t) (fData->GetAlignData(3)/10.); | |
e83c8d88 | 170 | // |
171 | const char *n1ZDC="ZDC/NeutronZDC_C"; | |
172 | const char *p1ZDC="ZDC/ProtonZDC_C"; | |
173 | const char *n2ZDC="ZDC/NeutronZDC_A"; | |
174 | const char *p2ZDC="ZDC/ProtonZDC_A"; | |
175 | // | |
176 | UShort_t iIndex=0; | |
177 | AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer; | |
178 | UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex); | |
179 | // | |
180 | new(alobj[0]) AliAlignObjParams(n1ZDC, volid, dx, dyZN1, dz, dpsi, dtheta, dphi, kTRUE); | |
181 | new(alobj[1]) AliAlignObjParams(p1ZDC, volid, dx, dyZP1, dz, dpsi, dtheta, dphi, kTRUE); | |
182 | new(alobj[2]) AliAlignObjParams(n2ZDC, volid, dx, dyZN2, dz, dpsi, dtheta, dphi, kTRUE); | |
183 | new(alobj[3]) AliAlignObjParams(p2ZDC, volid, dx, dyZP2, dz, dpsi, dtheta, dphi, kTRUE); | |
184 | ||
185 | // save in CDB storage | |
186 | AliCDBMetaData mdDCS; | |
187 | mdDCS.SetResponsible("Chiara Oppedisano"); | |
188 | mdDCS.SetComment("Alignment object for ZDC"); | |
1a1c78d4 | 189 | Bool_t resultAl = Store("Align","Data", array, &mdDCS, 0, kFALSE); |
e83c8d88 | 190 | if(resultAl==kFALSE) return 3; |
191 | ||
192 | return 0; | |
64a7c78d | 193 | } |
194 | ||
321fe3b8 | 195 | //______________________________________________________________________________________________ |
da2b6160 | 196 | UInt_t AliZDCPreprocessor::ProcessChMap() |
321fe3b8 | 197 | { |
82dffa48 | 198 | const int kNModules=10, kNch=48, kNScch=32, kNtdcch=32; |
e83c8d88 | 199 | |
3c159ed0 | 200 | // Reading the file for mapping from FXS |
da2b6160 | 201 | TList* daqSource = GetFileSources(kDAQ, "MAPPING"); |
321fe3b8 | 202 | if(!daqSource){ |
da2b6160 | 203 | AliError(Form("No sources for file ZDCChMapping.dat in run %d ", fRun)); |
e83c8d88 | 204 | return 4; |
321fe3b8 | 205 | } |
da2b6160 | 206 | if(daqSource->GetEntries()==0) return 4; |
207 | Log("\t List of DAQ sources for MAPPING id: "); daqSource->Print(); | |
321fe3b8 | 208 | // |
209 | TIter iter(daqSource); | |
210 | TObjString* source = 0; | |
b8d194f5 | 211 | Int_t isou = 0; |
82dffa48 | 212 | Int_t modMap[kNModules][3], adcMap[kNch][6], scMap[kNScch][6], tdcMap[kNtdcch][4]; |
3c159ed0 | 213 | // |
321fe3b8 | 214 | while((source = dynamic_cast<TObjString*> (iter.Next()))){ |
92508ce2 | 215 | TString fileName = GetFile(kDAQ, "MAPPING", source->GetName()); |
da2b6160 | 216 | Log(Form("\t Getting file #%d: ZDCChMapping.dat from %s\n",++isou, source->GetName())); |
321fe3b8 | 217 | |
218 | if(fileName.Length() <= 0){ | |
219 | Log(Form("No file from source %s!", source->GetName())); | |
e83c8d88 | 220 | return 4; |
321fe3b8 | 221 | } |
c00e895a | 222 | // --- Reading file with calibration data |
223 | //const char* fname = fileName.Data(); | |
224 | if(fileName){ | |
321fe3b8 | 225 | FILE *file; |
c00e895a | 226 | if((file = fopen(fileName,"r")) == NULL){ |
227 | printf("Cannot open file %s \n",fileName.Data()); | |
e83c8d88 | 228 | return 4; |
321fe3b8 | 229 | } |
c00e895a | 230 | Log(Form("File %s connected to process data for ADC mapping", fileName.Data())); |
321fe3b8 | 231 | // |
608444fb | 232 | for(Int_t j=0; j<kNch; j++){ |
233 | for(Int_t k=0; k<6; k++){ | |
234 | int read = fscanf(file,"%d",&adcMap[j][k]); | |
198f612a | 235 | if(read == 0) AliDebug(3," Failing in reading data from mapping file"); |
236 | } | |
237 | } | |
608444fb | 238 | for(Int_t j=kNch; j<kNch+kNScch; j++){ |
198f612a | 239 | for(Int_t k=0; k<6; k++){ |
608444fb | 240 | int read = fscanf(file,"%d",&scMap[j-kNch][k]); |
198f612a | 241 | if(read == 0) AliDebug(3," Failing in reading data from mapping file"); |
242 | } | |
243 | } | |
82dffa48 | 244 | for(Int_t j=kNch+kNScch; j<kNch+kNScch+kNtdcch; j++){ |
245 | for(Int_t k=0; k<4; k++){ | |
246 | int read = fscanf(file,"%d",&tdcMap[j-kNch-kNScch][k]); | |
247 | if(read == 0) AliDebug(3," Failing in reading data from mapping file"); | |
248 | } | |
249 | } | |
250 | for(Int_t j=kNch+kNScch+kNtdcch; j<kNch+kNScch+kNtdcch+kNModules; j++){ | |
608444fb | 251 | for(Int_t k=0; k<3; k++){ |
82dffa48 | 252 | int read = fscanf(file,"%d",&modMap[j-kNch-kNScch-kNtdcch][k]); |
e83c8d88 | 253 | if(read == 0) AliDebug(3," Failing in reading data from mapping file"); |
321fe3b8 | 254 | } |
321fe3b8 | 255 | } |
256 | fclose(file); | |
257 | } | |
258 | else{ | |
c00e895a | 259 | Log(Form("File %s not found", fileName.Data())); |
e83c8d88 | 260 | return 4; |
321fe3b8 | 261 | } |
3c159ed0 | 262 | } |
3c159ed0 | 263 | |
264 | // Store the currently read map ONLY IF it is different | |
265 | // from the entry in the OCDB | |
82dffa48 | 266 | Bool_t adcMapUpdated=kFALSE, scMapUpdated=kFALSE, tdcMapUpdated=kFALSE; |
3c159ed0 | 267 | Bool_t updateOCDB = kFALSE; |
268 | ||
269 | AliCDBEntry *cdbEntry = GetFromOCDB("Calib","ChMap"); | |
270 | if(!cdbEntry){ | |
73bc3a3f | 271 | Log(" No existing CDB entry for ADC mapping"); |
3c159ed0 | 272 | updateOCDB = kTRUE; |
273 | } | |
274 | else{ | |
275 | AliZDCChMap *chMap = (AliZDCChMap*) cdbEntry->GetObject(); | |
e83c8d88 | 276 | for(Int_t i=0; i<kNch; i++){ |
ba3ffd74 | 277 | if( (adcMap[i][1] != chMap->GetADCModule(i)) |
278 | || (adcMap[i][2] != chMap->GetADCChannel(i)) | |
216a94dd | 279 | || (adcMap[i][3] != chMap->GetADCSignalCode(i)) |
ba3ffd74 | 280 | || (adcMap[i][4] != chMap->GetDetector(i)) |
281 | || (adcMap[i][5] != chMap->GetSector(i))) | |
282 | adcMapUpdated = kTRUE; | |
198f612a | 283 | } |
284 | for(Int_t i=0; i<kNScch; i++){ | |
ba3ffd74 | 285 | if( (scMap[i][2] != chMap->GetScChannel(i)) |
216a94dd | 286 | || (scMap[i][3] != chMap->GetScSignalCode(i)) ) |
ba3ffd74 | 287 | scMapUpdated = kTRUE; |
3c159ed0 | 288 | } |
82dffa48 | 289 | for(Int_t i=0; i<kNtdcch; i++){ |
290 | if( (tdcMap[i][2] != chMap->GetTDCChannel(i)) | |
291 | || (tdcMap[i][3] != chMap->GetTDCSignalCode(i))) | |
292 | tdcMapUpdated = kTRUE; | |
293 | } | |
3c159ed0 | 294 | } |
82dffa48 | 295 | if(adcMapUpdated || scMapUpdated || tdcMapUpdated) updateOCDB = kTRUE; |
0d579f58 | 296 | // |
e83c8d88 | 297 | Bool_t resChMapStore = kTRUE; |
3c159ed0 | 298 | if(updateOCDB==kTRUE){ |
73bc3a3f | 299 | Log(" A new entry ZDC/Calib/ChMap will be created"); |
3c159ed0 | 300 | // |
301 | // --- Initializing mapping calibration object | |
302 | AliZDCChMap *mapCalib = new AliZDCChMap("ZDC"); | |
303 | // Writing channel map in the OCDB | |
198f612a | 304 | for(Int_t k=0; k<kNModules; k++){ |
305 | mapCalib->SetModuleMap(k, modMap[k][0], modMap[k][1], modMap[k][2]); | |
306 | } | |
e83c8d88 | 307 | for(Int_t k=0; k<kNch; k++){ |
198f612a | 308 | mapCalib->SetADCModule(k,adcMap[k][1]); |
309 | mapCalib->SetADCChannel(k,adcMap[k][2]); | |
82dffa48 | 310 | mapCalib->SetADCSignalCode(k,adcMap[k][3]); |
198f612a | 311 | mapCalib->SetDetector(k,adcMap[k][4]); |
312 | mapCalib->SetSector(k,adcMap[k][5]); | |
313 | } | |
314 | for(Int_t k=0; k<kNScch; k++){ | |
7d1d8256 | 315 | mapCalib->SetScChannel(k, scMap[k][2]); |
82dffa48 | 316 | mapCalib->SetScSignalCode(k, scMap[k][3]); |
7d1d8256 | 317 | mapCalib->SetScDetector(k, scMap[k][4]); |
318 | mapCalib->SetScSector(k, scMap[k][5]); | |
3c159ed0 | 319 | } |
82dffa48 | 320 | for(Int_t k=0; k<kNtdcch; k++){ |
321 | mapCalib->SetTDCChannel(k, tdcMap[k][2]); | |
322 | mapCalib->SetTDCSignalCode(k, tdcMap[k][3]); | |
323 | } | |
198f612a | 324 | // |
216a94dd | 325 | //mapCalib->Print(""); |
321fe3b8 | 326 | // |
327 | AliCDBMetaData metaData; | |
328 | metaData.SetBeamPeriod(0); | |
198f612a | 329 | metaData.SetResponsible("Chiara Oppedisano"); |
82dffa48 | 330 | metaData.SetComment("AliZDCChMap object created by ZDC preprocessor"); |
321fe3b8 | 331 | // |
1a1c78d4 | 332 | resChMapStore = Store("Calib","ChMap",mapCalib, &metaData, 0, kTRUE); |
333 | printf(" Mapping object stored in OCDB\n"); | |
321fe3b8 | 334 | } |
3c159ed0 | 335 | else{ |
73bc3a3f | 336 | Log(" ZDC/Calib/ChMap entry in OCDB is valid and won't be updated"); |
e83c8d88 | 337 | resChMapStore = kTRUE; |
3c159ed0 | 338 | } |
0d579f58 | 339 | |
aee13a2d | 340 | delete daqSource; daqSource=0; |
27d1ff1f | 341 | // Reading the file for mapping from FXS |
342 | TList* daqSourcetdc = GetFileSources(kDAQ, "TDCDATA"); | |
343 | if(!daqSourcetdc){ | |
344 | AliError(Form("No sources for file ZDCChMappingTDCCalib.dat in run %d ", fRun)); | |
345 | return 20; | |
346 | } | |
347 | if(daqSourcetdc->GetEntries()==0) return 20; | |
348 | Log("\t List of DAQ sources for TDCDATA id: "); daqSourcetdc->Print(); | |
349 | // | |
350 | Bool_t resTDCcal = kTRUE; | |
351 | TIter itertdc(daqSourcetdc); | |
352 | TObjString* sourcetdc = 0; | |
353 | Int_t isoutdc = 0; | |
354 | // | |
355 | while((sourcetdc = dynamic_cast<TObjString*> (itertdc.Next()))){ | |
356 | TString fileNametdc = GetFile(kDAQ, "TDCDATA", sourcetdc->GetName()); | |
357 | Log(Form("\t Getting file #%d: ZDCTDCdata.dat from %s\n",++isoutdc, sourcetdc->GetName())); | |
358 | ||
359 | if(fileNametdc.Length() <= 0){ | |
360 | Log(Form("No file from source %s!", sourcetdc->GetName())); | |
361 | return 20; | |
362 | } | |
363 | // --- Initializing TDC calibration object | |
364 | AliZDCTDCCalib *tdcCalib = new AliZDCTDCCalib("ZDC"); | |
365 | // --- Reading file with calibration data | |
366 | //const char* fname = fileName.Data(); | |
367 | if(fileNametdc){ | |
368 | FILE *filetdc; | |
369 | if((filetdc = fopen(fileNametdc,"r")) == NULL){ | |
370 | printf("Cannot open file %s \n",fileNametdc.Data()); | |
371 | return 20; | |
372 | } | |
373 | Log(Form("File %s connected to process TDC data", fileNametdc.Data())); | |
374 | // | |
375 | Float_t tdcMean[6][2]; | |
376 | for(Int_t it=0; it<6; it++){ | |
377 | for(Int_t iu=0; iu<2; iu++) tdcMean[it][iu]=0.; | |
378 | } | |
379 | for(Int_t k=0; k<6; k++){ | |
380 | for(Int_t j=0; j<2; j++){ | |
381 | int leggi = fscanf(filetdc,"%f",&tdcMean[k][j]); | |
382 | if(leggi==0) AliDebug(3," Failing reading data from tdc file"); | |
383 | tdcCalib->SetMeanTDC(k, tdcMean[k][0]); | |
384 | tdcCalib->SetWidthTDC(k, tdcMean[k][1]); | |
385 | } | |
386 | } | |
387 | fclose(filetdc); | |
388 | } | |
389 | else{ | |
390 | Log(Form("File %s not found", fileNametdc.Data())); | |
391 | return 20; | |
392 | } | |
393 | // | |
394 | AliCDBMetaData metaData; | |
395 | metaData.SetBeamPeriod(0); | |
396 | metaData.SetResponsible("Chiara Oppedisano"); | |
397 | metaData.SetComment("Filling AliZDCTDCCalib object"); | |
398 | // | |
399 | resTDCcal = Store("Calib","TDCCalib",tdcCalib, &metaData, 0, kTRUE); | |
400 | if(resTDCcal==kFALSE) return 21; | |
401 | } | |
402 | delete daqSourcetdc; daqSourcetdc = 0; | |
403 | ||
404 | Bool_t restdcHist = kTRUE; | |
405 | TList* daqSourceH = GetFileSources(kDAQ, "TDCHISTOS"); | |
406 | if(!daqSourceH){ | |
407 | Log(Form("No source for TDCHISTOS id run %d !", fRun)); | |
408 | return 22; | |
409 | } | |
410 | Log("\t List of DAQ sources for TDCHISTOS id: "); daqSourceH->Print(); | |
411 | // | |
412 | TIter iterH(daqSourceH); | |
413 | TObjString* sourceH = 0; | |
414 | Int_t iH=0; | |
415 | while((sourceH = dynamic_cast<TObjString*> (iterH.Next()))){ | |
416 | TString stringTDCFileName = GetFile(kDAQ, "TDCHISTOS", sourceH->GetName()); | |
417 | if(stringTDCFileName.Length() <= 0){ | |
418 | Log(Form("No TDCHISTOS file from source %s!", sourceH->GetName())); | |
419 | return 22; | |
420 | } | |
421 | const char* tdcFileName = stringTDCFileName.Data(); | |
422 | Log(Form("\t Getting file #%d: %s from %s\n",++iH, tdcFileName, sourceH->GetName())); | |
423 | restdcHist = StoreReferenceFile(tdcFileName, "tdcReference.root"); | |
424 | if(restdcHist==kFALSE) return 23; | |
425 | } | |
426 | delete daqSourceH; daqSourceH=0; | |
427 | ||
6f427255 | 428 | |
e83c8d88 | 429 | if(resChMapStore==kFALSE) return 5; |
aee13a2d | 430 | else return 0; |
321fe3b8 | 431 | |
432 | } | |
433 | ||
64a7c78d | 434 | //______________________________________________________________________________________________ |
e83c8d88 | 435 | UInt_t AliZDCPreprocessor::ProcessppData() |
64a7c78d | 436 | { |
e83c8d88 | 437 | Bool_t resEnCal=kTRUE, resTowCal=kTRUE; |
79563ba1 | 438 | |
73bc3a3f | 439 | // *********** Energy calibration |
3c159ed0 | 440 | // --- Cheking if there is already the entry in the OCDB |
5df9f417 | 441 | AliCDBEntry *cdbEnEntry = GetFromOCDB("Calib", "EnergyCalib"); |
73bc3a3f | 442 | if(!cdbEnEntry){ |
dd98e862 | 443 | Log(Form(" ZDC/Calib/EnergyCalib entry will be created")); |
3c159ed0 | 444 | // --- Initializing calibration object |
73bc3a3f | 445 | AliCDBMetaData metaData; |
446 | metaData.SetBeamPeriod(0); | |
447 | metaData.SetResponsible("Chiara Oppedisano"); | |
3c159ed0 | 448 | // |
73bc3a3f | 449 | AliZDCEnCalib *eCalib = new AliZDCEnCalib("ZDC"); |
3c159ed0 | 450 | for(Int_t j=0; j<6; j++) eCalib->SetEnCalib(j,1.); |
73bc3a3f | 451 | metaData.SetComment("AliZDCEnCalib object"); |
452 | //eCalib->Print(""); | |
1a1c78d4 | 453 | resEnCal = Store("Calib", "EnergyCalib", eCalib, &metaData, 0, kTRUE); |
73bc3a3f | 454 | } |
455 | else{ | |
456 | // if entry exists it is still valid (=1 for all runs!) | |
dd98e862 | 457 | Log(Form(" Valid ZDC/Calib/EnergyCalib object already existing in OCDB!!!")); |
73bc3a3f | 458 | resEnCal = kTRUE; |
459 | } | |
e83c8d88 | 460 | |
461 | if(resEnCal==kFALSE) return 6; | |
462 | ||
73bc3a3f | 463 | // |
464 | // *********** Tower inter-calibration | |
465 | // --- Cheking if there is already the entry in the OCDB | |
5df9f417 | 466 | AliCDBEntry *cdbTowEntry = GetFromOCDB("Calib", "TowerCalib"); |
73bc3a3f | 467 | if(!cdbTowEntry){ |
468 | AliZDCTowerCalib *towCalib = new AliZDCTowerCalib("ZDC"); | |
3c159ed0 | 469 | for(Int_t j=0; j<5; j++){ |
73bc3a3f | 470 | towCalib->SetZN1EqualCoeff(j, 1.); |
471 | towCalib->SetZP1EqualCoeff(j, 1.); | |
472 | towCalib->SetZN2EqualCoeff(j, 1.); | |
473 | towCalib->SetZP2EqualCoeff(j, 1.); | |
3c159ed0 | 474 | } |
73bc3a3f | 475 | //towCalib->Print(""); |
476 | // | |
477 | AliCDBMetaData metaData; | |
478 | metaData.SetBeamPeriod(0); | |
479 | metaData.SetResponsible("Chiara Oppedisano"); | |
480 | metaData.SetComment("AliZDCTowerCalib object"); | |
481 | // | |
1a1c78d4 | 482 | resTowCal = Store("Calib", "TowerCalib", towCalib, &metaData, 0, kTRUE); |
73bc3a3f | 483 | } |
484 | else{ | |
485 | // if entry exists it is still valid (=1 for all runs!) | |
dd98e862 | 486 | Log(Form(" Valid ZDC/Calib/TowerCalib object already existing in OCDB!!!")); |
73bc3a3f | 487 | resTowCal = kTRUE; |
488 | } | |
489 | ||
e83c8d88 | 490 | if(resTowCal==kFALSE) return 7; |
491 | ||
492 | return 0; | |
493 | } | |
494 | ||
495 | //______________________________________________________________________________________________ | |
2c62f191 | 496 | UInt_t AliZDCPreprocessor::ProcessCalibData(Float_t beamEnergy) |
e83c8d88 | 497 | { |
da2b6160 | 498 | TList* daqSources = GetFileSources(kDAQ, "EMDENERGYCALIB"); |
e83c8d88 | 499 | if(!daqSources){ |
500 | AliError(Form("No sources for CALIBRATION_EMD run %d !", fRun)); | |
da2b6160 | 501 | return 8; |
e83c8d88 | 502 | } |
da2b6160 | 503 | Log("\t List of DAQ sources for EMDENERGYCALIB id: "); daqSources->Print(); |
e83c8d88 | 504 | // |
505 | TIter iter2(daqSources); | |
506 | TObjString* source = 0; | |
507 | Int_t i=0; | |
da2b6160 | 508 | Bool_t resEnCal=kTRUE, resTowCal=kTRUE; |
509 | ||
e83c8d88 | 510 | while((source = dynamic_cast<TObjString*> (iter2.Next()))){ |
da2b6160 | 511 | TString stringEMDFileName = GetFile(kDAQ, "EMDENERGYCALIB", source->GetName()); |
e83c8d88 | 512 | if(stringEMDFileName.Length() <= 0){ |
513 | Log(Form("No file from source %s!", source->GetName())); | |
da2b6160 | 514 | return 8; |
e83c8d88 | 515 | } |
da2b6160 | 516 | const char* emdFileName = stringEMDFileName.Data(); |
517 | Log(Form("\t Getting file #%d: %s from %s\n",++i,emdFileName,source->GetName())); | |
518 | // | |
e83c8d88 | 519 | // --- Initializing energy calibration object |
520 | AliZDCEnCalib *eCalib = new AliZDCEnCalib("ZDC"); | |
da2b6160 | 521 | // --- Reading file with calibration data |
e83c8d88 | 522 | if(emdFileName){ |
523 | FILE *file; | |
524 | if((file = fopen(emdFileName,"r")) == NULL){ | |
da2b6160 | 525 | printf("Cannot open file %s \n",emdFileName); |
526 | return 8; | |
e83c8d88 | 527 | } |
528 | Log(Form("File %s connected to process data from EM dissociation events", emdFileName)); | |
529 | // | |
530 | Float_t fitValEMD[6]; | |
531 | for(Int_t j=0; j<6; j++){ | |
da2b6160 | 532 | if(j<6){ |
533 | int iread = fscanf(file,"%f",&fitValEMD[j]); | |
c1ae51a3 | 534 | if(iread==0) AliDebug(3," Failing reading data from EMD calibration data file"); |
535 | if(fitValEMD[j]!=1.) eCalib->SetEnCalib(j, beamEnergy/fitValEMD[j]); | |
536 | else eCalib->SetEnCalib(j, fitValEMD[j]); | |
da2b6160 | 537 | } |
e83c8d88 | 538 | } |
539 | // | |
540 | fclose(file); | |
541 | } | |
542 | else{ | |
543 | Log(Form("File %s not found", emdFileName)); | |
da2b6160 | 544 | return 8; |
e83c8d88 | 545 | } |
546 | //eCalib->Print(""); | |
547 | // | |
548 | AliCDBMetaData metaData; | |
549 | metaData.SetBeamPeriod(0); | |
550 | metaData.SetResponsible("Chiara Oppedisano"); | |
551 | metaData.SetComment("Filling AliZDCEnCalib object"); | |
552 | // | |
1a1c78d4 | 553 | resEnCal = Store("Calib","EnergyCalib",eCalib, &metaData, 0, kTRUE); |
e83c8d88 | 554 | if(resEnCal==kFALSE) return 6; |
555 | } | |
556 | delete daqSources; daqSources = 0; | |
da2b6160 | 557 | |
558 | TList* daqSourcesH = GetFileSources(kDAQ, "EMDTOWERCALIB"); | |
e83c8d88 | 559 | if(!daqSourcesH){ |
560 | AliError(Form("No sources for CALIBRATION_EMD run %d !", fRun)); | |
da2b6160 | 561 | return 9; |
e83c8d88 | 562 | } |
da2b6160 | 563 | Log("\t List of DAQ sources for EMDTOWERCALIB id: "); daqSourcesH->Print(); |
e83c8d88 | 564 | // |
565 | TIter iter2H(daqSourcesH); | |
566 | TObjString* sourceH = 0; | |
567 | Int_t iH=0; | |
e83c8d88 | 568 | while((sourceH = dynamic_cast<TObjString*> (iter2H.Next()))){ |
da2b6160 | 569 | TString stringtowEMDFileName = GetFile(kDAQ, "EMDTOWERCALIB", sourceH->GetName()); |
570 | if(stringtowEMDFileName.Length() <= 0){ | |
e83c8d88 | 571 | Log(Form("No file from source %s!", sourceH->GetName())); |
da2b6160 | 572 | return 9; |
e83c8d88 | 573 | } |
da2b6160 | 574 | const char * towEMDFileName = stringtowEMDFileName.Data(); |
575 | Log(Form("\t Getting file #%d: %s from source %s\n",++iH,towEMDFileName,sourceH->GetName())); | |
e83c8d88 | 576 | // --- Initializing energy calibration object |
577 | AliZDCTowerCalib *towCalib = new AliZDCTowerCalib("ZDC"); | |
da2b6160 | 578 | // --- Reading file with calibration data |
579 | if(towEMDFileName){ | |
e83c8d88 | 580 | FILE *file; |
da2b6160 | 581 | if((file = fopen(towEMDFileName,"r")) == NULL){ |
582 | printf("Cannot open file %s \n",towEMDFileName); | |
583 | return 9; | |
e83c8d88 | 584 | } |
e83c8d88 | 585 | // |
586 | Float_t equalCoeff[4][5]; | |
587 | for(Int_t j=0; j<4; j++){ | |
da2b6160 | 588 | for(Int_t k=0; k<5; k++){ |
589 | int leggi = fscanf(file,"%f",&equalCoeff[j][k]); | |
590 | if(leggi==0) AliDebug(3," Failing reading data from EMD calibration file"); | |
591 | if(j==0) towCalib->SetZN1EqualCoeff(k, equalCoeff[j][k]); | |
592 | else if(j==1) towCalib->SetZP1EqualCoeff(k, equalCoeff[j][k]); | |
593 | else if(j==2) towCalib->SetZN2EqualCoeff(k, equalCoeff[j][k]); | |
594 | else if(j==3) towCalib->SetZP2EqualCoeff(k, equalCoeff[j][k]); | |
595 | } | |
e83c8d88 | 596 | } |
597 | // | |
598 | fclose(file); | |
599 | } | |
600 | else{ | |
da2b6160 | 601 | Log(Form("File %s not found", towEMDFileName)); |
602 | return 9; | |
e83c8d88 | 603 | } |
604 | //towCalib->Print(""); | |
605 | // | |
606 | AliCDBMetaData metaData; | |
607 | metaData.SetBeamPeriod(0); | |
608 | metaData.SetResponsible("Chiara Oppedisano"); | |
609 | metaData.SetComment("Filling AliZDCTowerCalib object"); | |
610 | // | |
1a1c78d4 | 611 | resTowCal = Store("Calib","TowerCalib",towCalib, &metaData, 0, kTRUE); |
e83c8d88 | 612 | if(resTowCal==kFALSE) return 7; |
613 | } | |
da2b6160 | 614 | delete daqSourcesH; daqSourcesH = 0; |
e83c8d88 | 615 | |
da2b6160 | 616 | |
e83c8d88 | 617 | return 0; |
618 | } | |
619 | ||
620 | //______________________________________________________________________________________________ | |
621 | UInt_t AliZDCPreprocessor::ProcessPedestalData() | |
622 | { | |
73bc3a3f | 623 | TList* daqSources = GetFileSources(kDAQ, "PEDESTALDATA"); |
cb50c7c8 | 624 | if(!daqSources){ |
78e8a1cc | 625 | Log(Form("No source for STANDALONE_PEDESTAL run %d !", fRun)); |
da2b6160 | 626 | return 10; |
79563ba1 | 627 | } |
da2b6160 | 628 | if(daqSources->GetEntries()==0) return 10; |
629 | Log("\t List of DAQ sources for PEDESTALDATA id: "); daqSources->Print(); | |
79563ba1 | 630 | // |
cb50c7c8 | 631 | TIter iter(daqSources); |
da2b6160 | 632 | TObjString* source; |
79563ba1 | 633 | Int_t i=0; |
da2b6160 | 634 | Bool_t resPedCal=kTRUE, resPedHist=kTRUE; |
635 | ||
cb50c7c8 | 636 | while((source = dynamic_cast<TObjString*> (iter.Next()))){ |
73bc3a3f | 637 | TString stringPedFileName = GetFile(kDAQ, "PEDESTALDATA", source->GetName()); |
638 | if(stringPedFileName.Length() <= 0){ | |
da2b6160 | 639 | Log(Form("No PEDESTALDATA file from source %s!", source->GetName())); |
640 | return 10; | |
73bc3a3f | 641 | } |
da2b6160 | 642 | const char* pedFileName = stringPedFileName.Data(); |
643 | Log(Form("\t Getting file #%d: %s from %s\n",++i,pedFileName,source->GetName())); | |
644 | // | |
e83c8d88 | 645 | // --- Initializing pedestal calibration object |
646 | AliZDCPedestals *pedCalib = new AliZDCPedestals("ZDC"); | |
647 | // --- Reading file with pedestal calibration data | |
e83c8d88 | 648 | // no. ADCch = (22 signal ch. + 2 reference PMs) * 2 gain chain = 48 |
649 | const Int_t knZDCch = 48; | |
e83c8d88 | 650 | FILE *file; |
651 | if((file = fopen(pedFileName,"r")) == NULL){ | |
652 | printf("Cannot open file %s \n",pedFileName); | |
da2b6160 | 653 | return 10; |
e83c8d88 | 654 | } |
655 | Log(Form("File %s connected to process pedestal data", pedFileName)); | |
796c8b58 | 656 | Float_t pedVal[(3*knZDCch)][2]; |
93d32e24 | 657 | for(Int_t k=0; k<(3*knZDCch); k++){ |
da2b6160 | 658 | for(Int_t j=0; j<2; j++){ |
659 | int aleggi = fscanf(file,"%f",&pedVal[k][j]); | |
660 | if(aleggi==0) AliDebug(3," Failing reading data from pedestal file"); | |
661 | //if(j==1) printf("pedVal[%d] -> %f, %f \n",k,pedVal[k][0],pedVal[k][1]); | |
662 | } | |
663 | if(k<knZDCch){ | |
664 | pedCalib->SetMeanPed(k,pedVal[k][0]); | |
665 | pedCalib->SetMeanPedWidth(k,pedVal[k][1]); | |
666 | } | |
667 | else if(k>=knZDCch && k<(2*knZDCch)){ | |
668 | pedCalib->SetOOTPed(k-knZDCch,pedVal[k][0]); | |
669 | pedCalib->SetOOTPedWidth(k-knZDCch,pedVal[k][1]); | |
670 | } | |
671 | else if(k>=(2*knZDCch) && k<(3*knZDCch)){ | |
672 | pedCalib->SetPedCorrCoeff(k-(2*knZDCch),pedVal[k][0],pedVal[k][1]); | |
673 | } | |
e83c8d88 | 674 | } |
675 | fclose(file); | |
676 | //pedCalib->Print(""); | |
677 | // | |
678 | AliCDBMetaData metaData; | |
679 | metaData.SetBeamPeriod(0); | |
680 | metaData.SetResponsible("Chiara Oppedisano"); | |
681 | metaData.SetComment("Filling AliZDCPedestals object"); | |
682 | // | |
1a1c78d4 | 683 | resPedCal = Store("Calib","Pedestals",pedCalib, &metaData, 0, kTRUE); |
da2b6160 | 684 | if(resPedCal==kFALSE) return 11; |
64a7c78d | 685 | } |
cb50c7c8 | 686 | delete daqSources; daqSources = 0; |
da2b6160 | 687 | |
688 | TList* daqSourceH = GetFileSources(kDAQ, "PEDESTALHISTOS"); | |
73bc3a3f | 689 | if(!daqSourceH){ |
da2b6160 | 690 | Log(Form("No source for PEDESTALHISTOS id run %d !", fRun)); |
691 | return 12; | |
73bc3a3f | 692 | } |
da2b6160 | 693 | Log("\t List of DAQ sources for PEDESTALHISTOS id: "); daqSourceH->Print(); |
73bc3a3f | 694 | // |
695 | TIter iterH(daqSourceH); | |
696 | TObjString* sourceH = 0; | |
697 | Int_t iH=0; | |
698 | while((sourceH = dynamic_cast<TObjString*> (iterH.Next()))){ | |
da2b6160 | 699 | TString stringPedFileName = GetFile(kDAQ, "PEDESTALHISTOS", sourceH->GetName()); |
73bc3a3f | 700 | if(stringPedFileName.Length() <= 0){ |
da2b6160 | 701 | Log(Form("No PEDESTALHISTOS file from source %s!", sourceH->GetName())); |
702 | return 12; | |
73bc3a3f | 703 | } |
da2b6160 | 704 | const char* pedFileName = stringPedFileName.Data(); |
705 | Log(Form("\t Getting file #%d: %s from %s\n",++iH, pedFileName, sourceH->GetName())); | |
706 | resPedHist = StoreReferenceFile(pedFileName, "pedestalReference.root"); | |
707 | if(resPedHist==kFALSE) return 13; | |
73bc3a3f | 708 | } |
da2b6160 | 709 | delete daqSourceH; daqSourceH=0; |
e83c8d88 | 710 | |
711 | return 0; | |
712 | } | |
713 | ||
714 | //______________________________________________________________________________________________ | |
715 | UInt_t AliZDCPreprocessor::ProcessLaserData() | |
716 | { | |
73bc3a3f | 717 | TList* daqSources = GetFileSources(kDAQ, "LASERDATA"); |
1ee299a5 | 718 | if(!daqSources){ |
719 | AliError(Form("No sources for STANDALONE_LASER run %d !", fRun)); | |
da2b6160 | 720 | return 14; |
1ee299a5 | 721 | } |
da2b6160 | 722 | if(daqSources->GetEntries()==0) return 14; |
723 | Log("\t List of DAQ sources for LASERDATA id: "); daqSources->Print(); | |
1ee299a5 | 724 | // |
725 | TIter iter2(daqSources); | |
726 | TObjString* source = 0; | |
727 | Int_t i=0; | |
da2b6160 | 728 | Bool_t resLaserCal=kTRUE, resLaserHist=kTRUE; |
729 | ||
1ee299a5 | 730 | while((source = dynamic_cast<TObjString*> (iter2.Next()))){ |
da2b6160 | 731 | TString stringLaserFileName = GetFile(kDAQ, "LASERDATA", source->GetName()); |
732 | if(stringLaserFileName.Length() <= 0){ | |
73bc3a3f | 733 | Log(Form("No LASER file from source %s!", source->GetName())); |
da2b6160 | 734 | return 14; |
73bc3a3f | 735 | } |
da2b6160 | 736 | const char* laserFileName = stringLaserFileName.Data(); |
737 | Log(Form("\t Getting file #%d: %s from %s\n",++i,laserFileName,source->GetName())); | |
738 | // | |
73bc3a3f | 739 | // --- Initializing pedestal calibration object |
740 | AliZDCLaserCalib *lCalib = new AliZDCLaserCalib("ZDC"); | |
741 | // --- Reading file with pedestal calibration data | |
73bc3a3f | 742 | if(laserFileName){ |
743 | FILE *file; | |
744 | if((file = fopen(laserFileName,"r")) == NULL){ | |
745 | printf("Cannot open file %s \n",laserFileName); | |
da2b6160 | 746 | return 14; |
1ee299a5 | 747 | } |
73bc3a3f | 748 | Log(Form("File %s connected to process data from LASER events", laserFileName)); |
1ee299a5 | 749 | // |
73bc3a3f | 750 | Float_t ivalRead[22][4]; |
751 | for(Int_t j=0; j<22; j++){ | |
da2b6160 | 752 | for(Int_t k=0; k<4; k++){ |
753 | int aleggi = fscanf(file,"%f",&ivalRead[j][k]); | |
754 | if(aleggi==0) AliDebug(3," Failng reading data from laser file"); | |
73bc3a3f | 755 | //printf(" %d %1.0f ",k, ivalRead[j][k]); |
756 | } | |
757 | lCalib->SetDetector(j, (Int_t) ivalRead[j][0]); | |
758 | lCalib->SetSector(j, (Int_t) ivalRead[j][1]); | |
759 | lCalib->SetfPMValue(j, ivalRead[j][2]); | |
760 | lCalib->SetfPMWidth(j, ivalRead[j][3]); | |
761 | } | |
762 | fclose(file); | |
763 | } | |
764 | else{ | |
765 | Log(Form("File %s not found", laserFileName)); | |
da2b6160 | 766 | return 14; |
73bc3a3f | 767 | } |
768 | //lCalib->Print(""); | |
769 | // | |
770 | AliCDBMetaData metaData; | |
771 | metaData.SetBeamPeriod(0); | |
772 | metaData.SetResponsible("Chiara Oppedisano"); | |
773 | metaData.SetComment("Filling AliZDCLaserCalib object"); | |
774 | // | |
1a1c78d4 | 775 | resLaserCal = Store("Calib","LaserCalib",lCalib, &metaData, 0, kTRUE); |
da2b6160 | 776 | if(resLaserCal==kFALSE) return 15; |
1ee299a5 | 777 | } |
73bc3a3f | 778 | delete daqSources; daqSources = 0; |
da2b6160 | 779 | |
73bc3a3f | 780 | TList* daqSourceH = GetFileSources(kDAQ, "LASERHISTOS"); |
781 | if(!daqSourceH){ | |
782 | AliError(Form("No sources for STANDALONE_LASER run %d !", fRun)); | |
da2b6160 | 783 | return 16; |
73bc3a3f | 784 | } |
da2b6160 | 785 | Log("\t List of DAQ sources for LASERHISTOS id: "); daqSourceH->Print(); |
73bc3a3f | 786 | // |
787 | TIter iter2H(daqSourceH); | |
788 | TObjString* sourceH = 0; | |
789 | Int_t iH=0; | |
790 | while((sourceH = dynamic_cast<TObjString*> (iter2H.Next()))){ | |
da2b6160 | 791 | Log(Form("\t Getting file #%d\n",++iH)); |
792 | TString stringLaserFileName = GetFile(kDAQ, "LASERHISTOS", sourceH->GetName()); | |
793 | if(stringLaserFileName.Length() <= 0){ | |
73bc3a3f | 794 | Log(Form("No LASER file from source %s!", sourceH->GetName())); |
da2b6160 | 795 | return 16; |
73bc3a3f | 796 | } |
da2b6160 | 797 | resLaserHist = StoreReferenceFile(stringLaserFileName.Data(), "laserReference.root"); |
e83c8d88 | 798 | // |
da2b6160 | 799 | if(resLaserHist==kFALSE) return 17; |
73bc3a3f | 800 | } |
801 | delete daqSourceH; daqSourceH = 0; | |
e83c8d88 | 802 | |
803 | return 0; | |
804 | } | |
805 | ||
0d579f58 | 806 | |
807 | //______________________________________________________________________________________________ | |
808 | UInt_t AliZDCPreprocessor::ProcessMBCalibData() | |
809 | { | |
810 | TList* daqSources = GetFileSources(kDAQ, "MBCALIB"); | |
811 | if(!daqSources){ | |
812 | AliError(Form("No sources for CALIBRATION_MB run %d !", fRun)); | |
813 | return 18; | |
814 | } | |
815 | if(daqSources->GetEntries()==0) return 18; | |
816 | Log("\t List of DAQ sources for MBCALIB id: "); daqSources->Print(); | |
817 | // | |
818 | TIter iter2(daqSources); | |
819 | TObjString* source = 0; | |
820 | Int_t i=0; | |
821 | Bool_t resMBCal=kTRUE; | |
822 | ||
823 | while((source = dynamic_cast<TObjString*> (iter2.Next()))){ | |
824 | TString stringMBFileName = GetFile(kDAQ, "MBCALIB", source->GetName()); | |
825 | if(stringMBFileName.Length() <= 0){ | |
826 | Log(Form("No MBCALIB file from source %s!", source->GetName())); | |
827 | return 18; | |
828 | } | |
829 | const char* mbFileName = stringMBFileName.Data(); | |
830 | Log(Form("\t Getting file #%d: %s from %s\n",++i,mbFileName,source->GetName())); | |
831 | // | |
832 | // --- Initializing calibration object | |
833 | AliZDCMBCalib *mbCalib = new AliZDCMBCalib("ZDC"); | |
834 | // --- Reading file with calibration data | |
835 | if(mbFileName){ | |
836 | TFile * fileHistos = TFile::Open(mbFileName); | |
837 | Log(Form("File %s connected to process data from CALIBRATION_MB events", mbFileName)); | |
838 | // | |
839 | fileHistos->cd(); | |
840 | TH2F *hZDCvsZEM = (TH2F*) fileHistos->Get("hZDCvsZEM"); | |
841 | TH2F *hZDCCvsZEM = (TH2F*) fileHistos->Get("hZDCCvsZEM"); | |
842 | TH2F *hZDCAvsZEM = (TH2F*) fileHistos->Get("hZDCAvsZEM"); | |
843 | // | |
844 | mbCalib->SetZDCvsZEM(hZDCvsZEM); | |
845 | mbCalib->SetZDCCvsZEM(hZDCCvsZEM); | |
846 | mbCalib->SetZDCAvsZEM(hZDCAvsZEM); | |
847 | // | |
848 | //fileHistos->Close(); | |
849 | } | |
850 | else{ | |
851 | Log(Form("File %s not found", mbFileName)); | |
852 | return 14; | |
853 | } | |
854 | // | |
855 | AliCDBMetaData metaData; | |
856 | metaData.SetBeamPeriod(0); | |
857 | metaData.SetResponsible("Chiara Oppedisano"); | |
858 | metaData.SetComment("Filling AliZDCMBCalib object"); | |
859 | // | |
860 | //mbCalib->Dump(); | |
861 | // | |
862 | resMBCal = Store("Calib","MBCalib",mbCalib, &metaData, 0, kTRUE); | |
863 | printf(" here 1000\n"); | |
864 | if(resMBCal==kFALSE) return 19; | |
865 | } | |
866 | delete daqSources; daqSources = 0; | |
867 | ||
868 | return 0; | |
869 | } | |
870 | ||
e83c8d88 | 871 | //______________________________________________________________________________________________ |
872 | UInt_t AliZDCPreprocessor::Process(TMap* dcsAliasMap) | |
873 | { | |
874 | UInt_t resDCS = 0; | |
875 | UInt_t resChMap=0; | |
0d579f58 | 876 | UInt_t resEnergyCalib=0, resPedestalCalib=0, resLaserCalib=0, resMBCalib=0; |
e83c8d88 | 877 | |
878 | // ************************* Process DCS data **************************** | |
879 | if(ProcessDCS()) resDCS = ProcessDCSData(dcsAliasMap); | |
880 | ||
881 | // ********************************* From DAQ ************************************ | |
882 | ||
883 | const char* beamType = GetRunParameter("beamType"); | |
884 | TString runType = GetRunType(); | |
2c62f191 | 885 | Float_t beamEnergy = (Float_t)(((TString)GetRunParameter("beamEnergy")).Atof()); |
886 | printf("\t **** AliZDCPreprocessor -> runType %s, beamType %s, beamEnergy %1.0f ****\n", | |
887 | runType.Data(),beamType,beamEnergy); | |
e83c8d88 | 888 | |
889 | // ****************************************** | |
0d579f58 | 890 | // ADC channel mapping |
e83c8d88 | 891 | // ****************************************** |
da2b6160 | 892 | resChMap = ProcessChMap(); |
e83c8d88 | 893 | |
894 | // ****************************************** | |
0d579f58 | 895 | // Calibration param. for p-p data (all = 1) |
e83c8d88 | 896 | // ****************************************** |
897 | // NO ENERGY CALIBRATION -> coefficients set to 1. | |
898 | // Temp -> also inter-calibration coefficients are set to 1. | |
da2b6160 | 899 | if((strcmp(beamType,"p-p")==0) || (strcmp(beamType,"P-P")==0)) resEnergyCalib = ProcessppData(); |
e83c8d88 | 900 | |
b8d194f5 | 901 | // ***************************************************** |
0d579f58 | 902 | // CALIBRATION_EMD -> Energy calibration and equalization |
b8d194f5 | 903 | // ***************************************************** |
0d579f58 | 904 | if((strcmp(beamType,"A-A")==0) && (runType.CompareTo("CALIBRATION_EMD")==0)) |
2c62f191 | 905 | resEnergyCalib = ProcessCalibData(beamEnergy); |
e83c8d88 | 906 | |
907 | // ***************************************************** | |
908 | // STANDALONE_PEDESTALS -> Pedestal subtraction | |
909 | // ***************************************************** | |
da2b6160 | 910 | if(runType.CompareTo("STANDALONE_PEDESTAL")==0) resPedestalCalib = ProcessPedestalData(); |
e83c8d88 | 911 | |
912 | // ***************************************************** | |
913 | // STANDALONE_LASER -> Signal stability and ageing | |
914 | // ***************************************************** | |
0d579f58 | 915 | else if(runType.CompareTo("STANDALONE_LASER")==0) resLaserCalib = ProcessLaserData(); |
916 | ||
917 | // ***************************************************** | |
918 | // CALIBRATION_MB -> Signal stability and ageing | |
919 | // ***************************************************** | |
920 | else if(runType.CompareTo("CALIBRATION_MB")==0) resMBCalib = ProcessMBCalibData(); | |
e83c8d88 | 921 | |
028eb4a1 | 922 | |
e83c8d88 | 923 | if(resDCS!=0) return resDCS; |
924 | else if(resChMap!=0) return resChMap; | |
925 | else if(resEnergyCalib!=0) return resEnergyCalib; | |
926 | else if(resPedestalCalib!=0) return resPedestalCalib; | |
927 | else if(resLaserCalib!=0) return resLaserCalib; | |
0d579f58 | 928 | else if(resMBCalib!=0) return resMBCalib; |
79563ba1 | 929 | |
e83c8d88 | 930 | return 0; |
cb50c7c8 | 931 | |
64a7c78d | 932 | } |