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