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