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