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