]>
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" | |
6024ec85 | 17 | #include "AliZDCPedestals.h" |
18 | #include "AliZDCCalib.h" | |
19 | #include "AliZDCRecParam.h" | |
64a7c78d | 20 | |
d5e687c2 | 21 | ///////////////////////////////////////////////////////////////////// |
22 | // // | |
23 | // Class implementing ZDC pre-processor. // | |
24 | // It takes data from DCS and passes it to the class AliZDCDataDCS // | |
25 | // The class is then written to the CDB. // | |
26 | // // | |
27 | ///////////////////////////////////////////////////////////////////// | |
64a7c78d | 28 | |
29 | ClassImp(AliZDCPreprocessor) | |
30 | ||
31 | //______________________________________________________________________________________________ | |
857ece97 | 32 | AliZDCPreprocessor::AliZDCPreprocessor(AliShuttleInterface* shuttle) : |
33 | AliPreprocessor("ZDC", shuttle), | |
64a7c78d | 34 | fData(0) |
35 | { | |
36 | // constructor | |
cbf06263 | 37 | AddRunType("STANDALONE_PEDESTAL"); |
38 | AddRunType("STANDALONE_EMD"); | |
a4a56567 | 39 | AddRunType("PHYSICS"); |
64a7c78d | 40 | } |
41 | ||
cbf06263 | 42 | |
64a7c78d | 43 | //______________________________________________________________________________________________ |
44 | AliZDCPreprocessor::~AliZDCPreprocessor() | |
45 | { | |
46 | // destructor | |
47 | } | |
48 | ||
7a78280f | 49 | |
64a7c78d | 50 | //______________________________________________________________________________________________ |
51 | void AliZDCPreprocessor::Initialize(Int_t run, UInt_t startTime, | |
52 | UInt_t endTime) | |
53 | { | |
54 | // Creates AliZDCDataDCS object | |
55 | ||
56 | AliPreprocessor::Initialize(run, startTime, endTime); | |
57 | ||
79563ba1 | 58 | Log(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run, |
64a7c78d | 59 | TTimeStamp(startTime).AsString(), |
60 | TTimeStamp(endTime).AsString())); | |
61 | ||
79563ba1 | 62 | fRun = run; |
63 | fStartTime = startTime; | |
64 | fEndTime = endTime; | |
65 | ||
64a7c78d | 66 | fData = new AliZDCDataDCS(fRun, fStartTime, fEndTime); |
67 | } | |
68 | ||
69 | //______________________________________________________________________________________________ | |
70 | UInt_t AliZDCPreprocessor::Process(TMap* dcsAliasMap) | |
71 | { | |
79563ba1 | 72 | // *************** From DCS ****************** |
64a7c78d | 73 | // Fills data into a AliZDCDataDCS object |
f181c9b8 | 74 | if(!dcsAliasMap) return 1; |
64a7c78d | 75 | |
76 | // The processing of the DCS input data is forwarded to AliZDCDataDCS | |
d5e687c2 | 77 | Float_t dcsValues[28]; // DCSAliases=28 |
92339a90 | 78 | fData->SetCalibData(dcsValues); |
79 | fData->ProcessData(*dcsAliasMap); | |
86fd32fd | 80 | // Store DCS data for reference |
81 | AliCDBMetaData metadata; | |
82 | metadata.SetResponsible("Chiara Oppedisano"); | |
83 | metadata.SetComment("DCS data for ZDC"); | |
427e15da | 84 | Bool_t resDCSRef = kTRUE; |
86fd32fd | 85 | resDCSRef = StoreReferenceData("DCS","Data",fData,&metadata); |
e1ea0c63 | 86 | //dcsAliasMap->Print(""); |
31af5828 | 87 | // |
79563ba1 | 88 | // --- Writing ZDC table positions into alignment object |
90dbf5fb | 89 | TClonesArray *array = new TClonesArray("AliAlignObjParams",10); |
79563ba1 | 90 | TClonesArray &alobj = *array; |
90dbf5fb | 91 | AliAlignObjParams a; |
79563ba1 | 92 | Double_t dx=0., dz=0., dpsi=0., dtheta=0., dphi=0.; |
cb50c7c8 | 93 | // Vertical table position in mm from DCS |
d5e687c2 | 94 | Double_t dyZN1 = (Double_t) (dcsValues[0]/10.); |
95 | Double_t dyZP1 = (Double_t) (dcsValues[1]/10.); | |
96 | Double_t dyZN2 = (Double_t) (dcsValues[2]/10.); | |
97 | Double_t dyZP2 = (Double_t) (dcsValues[3]/10.); | |
98 | const char *n1ZDC="ZDC/NeutronZDC1"; | |
99 | const char *p1ZDC="ZDC/ProtonZDC1"; | |
100 | const char *n2ZDC="ZDC/NeutronZDC2"; | |
101 | const char *p2ZDC="ZDC/ProtonZDC2"; | |
79563ba1 | 102 | UShort_t iIndex=0; |
ae079791 | 103 | AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer; |
104 | UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex); | |
79563ba1 | 105 | // |
d5e687c2 | 106 | new(alobj[0]) AliAlignObjParams(n1ZDC, volid, dx, dyZN1, dz, dpsi, dtheta, dphi, kTRUE); |
107 | new(alobj[1]) AliAlignObjParams(p1ZDC, volid, dx, dyZP1, dz, dpsi, dtheta, dphi, kTRUE); | |
108 | new(alobj[2]) AliAlignObjParams(n2ZDC, volid, dx, dyZN2, dz, dpsi, dtheta, dphi, kTRUE); | |
109 | new(alobj[3]) AliAlignObjParams(p2ZDC, volid, dx, dyZP2, dz, dpsi, dtheta, dphi, kTRUE); | |
79563ba1 | 110 | // save in CDB storage |
111 | AliCDBMetaData md; | |
112 | md.SetResponsible("Chiara Oppedisano"); | |
113 | md.SetComment("Alignment object for ZDC"); | |
427e15da | 114 | Bool_t resultAl = kTRUE; |
cb50c7c8 | 115 | resultAl = Store("Align","Data", array, &md, 0, 0); |
79563ba1 | 116 | |
028eb4a1 | 117 | // *************** From DAQ ****************** |
0ce2858d | 118 | Bool_t resPedCal = kTRUE, resECal = kTRUE, resRecPar = kTRUE; |
d2317a93 | 119 | // |
120 | const char* beamType = GetRunParameter("beamType"); | |
121 | TString runType = GetRunType(); | |
122 | printf("\n\t AliZDCPreprocessor -> beamType %s\n",beamType); | |
123 | printf("\t AliZDCPreprocessor -> runType %s\n\n",runType.Data()); | |
124 | // | |
125 | // | |
126 | if(strcmp(beamType,"p-p")==0){ | |
127 | // --- Initializing pedestal calibration object | |
128 | AliZDCCalib *eCalib = new AliZDCCalib("ZDC"); | |
129 | // | |
130 | for(Int_t j=0; j<6; j++) eCalib->SetEnCalib(j,1.); | |
131 | for(Int_t j=0; j<5; j++){ | |
132 | eCalib->SetZN1EqualCoeff(j, 1.); | |
133 | eCalib->SetZP1EqualCoeff(j, 1.); | |
134 | eCalib->SetZN2EqualCoeff(j, 1.); | |
135 | eCalib->SetZP2EqualCoeff(j, 1.); | |
136 | } | |
137 | //eCalib->Print(""); | |
138 | // | |
139 | AliCDBMetaData metaData; | |
140 | metaData.SetBeamPeriod(0); | |
141 | metaData.SetResponsible("Chiara"); | |
142 | metaData.SetComment("AliZDCCalib object"); | |
143 | // | |
144 | resECal = Store("Calib","Calib",eCalib, &metaData, 0, 1); | |
145 | } | |
146 | // | |
028eb4a1 | 147 | // ***************************************************** |
148 | // [a] PEDESTALS -> Pedestal subtraction | |
149 | // ***************************************************** | |
d2317a93 | 150 | // |
151 | if(runType=="STANDALONE_PEDESTAL"){ | |
cb50c7c8 | 152 | TList* daqSources = GetFileSources(kDAQ, "PEDESTALS"); |
153 | if(!daqSources){ | |
78e8a1cc | 154 | Log(Form("No source for STANDALONE_PEDESTAL run %d !", fRun)); |
c58c7e82 | 155 | return 1; |
79563ba1 | 156 | } |
78e8a1cc | 157 | Log("\t List of sources for STANDALONE_PEDESTAL"); |
cb50c7c8 | 158 | daqSources->Print(); |
79563ba1 | 159 | // |
cb50c7c8 | 160 | TIter iter(daqSources); |
161 | TObjString* source = 0; | |
79563ba1 | 162 | Int_t i=0; |
cb50c7c8 | 163 | while((source = dynamic_cast<TObjString*> (iter.Next()))){ |
79563ba1 | 164 | Log(Form("\n\t Getting file #%d\n",++i)); |
cb50c7c8 | 165 | TString stringPedFileName = GetFile(kDAQ, "PEDESTALS", source->GetName()); |
166 | if(stringPedFileName.Length() <= 0){ | |
167 | Log(Form("No PEDESTAL file from source %s!", source->GetName())); | |
c58c7e82 | 168 | return 1; |
cb50c7c8 | 169 | } |
6024ec85 | 170 | // --- Initializing pedestal calibration object |
171 | AliZDCPedestals *pedCalib = new AliZDCPedestals("ZDC"); | |
172 | // --- Reading file with pedestal calibration data | |
d5e687c2 | 173 | const char* pedFileName = stringPedFileName.Data(); |
c0aec6f6 | 174 | // no. ADCch = (22 signal ch. + 2 reference PMs) * 2 gain chain = 48 |
d5e687c2 | 175 | const Int_t knZDCch = 48; |
176 | if(pedFileName){ | |
79563ba1 | 177 | FILE *file; |
d5e687c2 | 178 | if((file = fopen(pedFileName,"r")) == NULL){ |
179 | printf("Cannot open file %s \n",pedFileName); | |
c58c7e82 | 180 | return 1; |
79563ba1 | 181 | } |
d5e687c2 | 182 | Log(Form("File %s connected to process pedestal data", pedFileName)); |
c35ed519 | 183 | Float_t pedVal[(3*knZDCch)][3]; |
92339a90 | 184 | for(Int_t k=0; k<(3*knZDCch); k++){ |
c35ed519 | 185 | for(Int_t j=0; j<3; j++){ |
92339a90 | 186 | fscanf(file,"%f",&pedVal[k][j]); |
187 | //if(j==1) printf("pedVal[%d] -> %f, %f \n",k,pedVal[k][0],pedVal[k][1]); | |
79563ba1 | 188 | } |
92339a90 | 189 | if(k<knZDCch){ |
190 | pedCalib->SetMeanPed(k,pedVal[k][1]); | |
191 | pedCalib->SetMeanPedWidth(i,pedVal[k][2]); | |
79563ba1 | 192 | } |
92339a90 | 193 | else if(k>=knZDCch && k<(2*knZDCch)){ |
194 | pedCalib->SetOOTPed(k-knZDCch,pedVal[k][1]); | |
195 | pedCalib->SetOOTPedWidth(k-knZDCch,pedVal[k][2]); | |
79563ba1 | 196 | } |
92339a90 | 197 | else if(k>=(2*knZDCch) && k<(3*knZDCch)){ |
198 | pedCalib->SetPedCorrCoeff(k-(2*knZDCch),pedVal[k][1],pedVal[k][2]); | |
79563ba1 | 199 | } |
200 | } | |
e1ea0c63 | 201 | } |
79563ba1 | 202 | else{ |
d5e687c2 | 203 | Log(Form("File %s not found", pedFileName)); |
c58c7e82 | 204 | return 1; |
e1ea0c63 | 205 | } |
79563ba1 | 206 | // |
6024ec85 | 207 | //pedCalib->Print(""); |
208 | // | |
209 | AliCDBMetaData metaData; | |
210 | metaData.SetBeamPeriod(0); | |
211 | metaData.SetResponsible("Chiara"); | |
212 | metaData.SetComment("Filling AliZDCPedestals object"); | |
213 | // | |
214 | resPedCal = Store("Calib","Pedestals",pedCalib, &metaData, 0, 1); | |
64a7c78d | 215 | } |
cb50c7c8 | 216 | delete daqSources; daqSources = 0; |
04bd7caa | 217 | } |
028eb4a1 | 218 | // ***************************************************** |
219 | // [b] EMD EVENTS -> Energy calibration and equalization | |
220 | // ***************************************************** | |
d2317a93 | 221 | else if(runType=="STANDALONE_EMD"){ |
028eb4a1 | 222 | TList* daqSources = GetFileSources(kDAQ, "EMDCALIB"); |
cb50c7c8 | 223 | if(!daqSources){ |
78e8a1cc | 224 | AliError(Form("No sources for STANDALONE_EMD run %d !", fRun)); |
c58c7e82 | 225 | return 1; |
64a7c78d | 226 | } |
78e8a1cc | 227 | Log("\t List of sources for STANDALONE_EMD"); |
cb50c7c8 | 228 | daqSources->Print(); |
e1ea0c63 | 229 | // |
cb50c7c8 | 230 | TIter iter2(daqSources); |
06db4c54 | 231 | TObjString* source = 0; |
92339a90 | 232 | Int_t i=0; |
cb50c7c8 | 233 | while((source = dynamic_cast<TObjString*> (iter2.Next()))){ |
92339a90 | 234 | Log(Form("\n\t Getting file #%d\n",++i)); |
028eb4a1 | 235 | TString stringEMDFileName = GetFile(kDAQ, "EMDCALIB", source->GetName()); |
cb50c7c8 | 236 | if(stringEMDFileName.Length() <= 0){ |
028eb4a1 | 237 | Log(Form("No EMDCALIB file from source %s!", source->GetName())); |
c58c7e82 | 238 | return 1; |
cb50c7c8 | 239 | } |
6024ec85 | 240 | // --- Initializing pedestal calibration object |
241 | AliZDCCalib *eCalib = new AliZDCCalib("ZDC"); | |
242 | // --- Reading file with pedestal calibration data | |
d5e687c2 | 243 | const char* emdFileName = stringEMDFileName.Data(); |
244 | if(emdFileName){ | |
79563ba1 | 245 | FILE *file; |
d5e687c2 | 246 | if((file = fopen(emdFileName,"r")) == NULL){ |
247 | printf("Cannot open file %s \n",emdFileName); | |
c58c7e82 | 248 | return 1; |
79563ba1 | 249 | } |
d5e687c2 | 250 | Log(Form("File %s connected to process data from EM dissociation events", emdFileName)); |
b12033ab | 251 | // |
252 | Float_t fitValEMD[6]; Float_t equalCoeff[5][4]; | |
d5e687c2 | 253 | Float_t calibVal[4]; |
028eb4a1 | 254 | for(Int_t j=0; j<10; j++){ |
255 | if(j<6){ | |
256 | fscanf(file,"%f",&fitValEMD[j]); | |
257 | if(j<4){ | |
4ef37af5 | 258 | calibVal[j] = 2.76/fitValEMD[j]; |
6024ec85 | 259 | eCalib->SetEnCalib(j,calibVal[j]); |
028eb4a1 | 260 | } |
6024ec85 | 261 | else eCalib->SetEnCalib(j,fitValEMD[j]); |
028eb4a1 | 262 | } |
263 | else{ | |
264 | for(Int_t k=0; k<5; k++){ | |
265 | fscanf(file,"%f",&equalCoeff[j][k]); | |
d2317a93 | 266 | if(j==6) eCalib->SetZN1EqualCoeff(k, equalCoeff[j][k]); |
6024ec85 | 267 | else if(j==7) eCalib->SetZP1EqualCoeff(k, equalCoeff[j][k]); |
268 | else if(j==8) eCalib->SetZN2EqualCoeff(k, equalCoeff[j][k]); | |
269 | else if(j==9) eCalib->SetZP2EqualCoeff(k, equalCoeff[j][k]); | |
028eb4a1 | 270 | } |
271 | } | |
79563ba1 | 272 | } |
79563ba1 | 273 | } |
274 | else{ | |
d5e687c2 | 275 | Log(Form("File %s not found", emdFileName)); |
c58c7e82 | 276 | return 1; |
79563ba1 | 277 | } |
d2317a93 | 278 | //eCalib->Print(""); |
6024ec85 | 279 | // |
280 | AliCDBMetaData metaData; | |
281 | metaData.SetBeamPeriod(0); | |
282 | metaData.SetResponsible("Chiara"); | |
283 | metaData.SetComment("Filling AliZDCCalib object"); | |
284 | // | |
285 | resECal = Store("Calib","Calib",eCalib, &metaData, 0, 1); | |
79563ba1 | 286 | } |
b12033ab | 287 | } |
288 | // ******************************************************** | |
d2317a93 | 289 | // [c] PHYSICS RUNS -> Parameters needed for reconstruction |
290 | // NB -> ONLY IN Pb-Pb!!!!!!! | |
b12033ab | 291 | // ******************************************************** |
d2317a93 | 292 | else if((runType=="PHYSICS") && (strcmp(beamType,"Pb-Pb")==0)){ |
b12033ab | 293 | TList* daqSources = GetFileSources(kDAQ, "PHYSICS"); |
294 | if(!daqSources){ | |
295 | AliError(Form("No sources for PHYSICS run %d !", fRun)); | |
296 | return 1; | |
297 | } | |
298 | Log("\t List of sources for PHYSICS"); | |
299 | daqSources->Print(); | |
300 | // | |
301 | TIter iter2(daqSources); | |
302 | TObjString* source = 0; | |
92339a90 | 303 | Int_t i=0; |
b12033ab | 304 | while((source = dynamic_cast<TObjString*> (iter2.Next()))){ |
92339a90 | 305 | Log(Form("\n\t Getting file #%d\n",++i)); |
b12033ab | 306 | TString stringPHYSFileName = GetFile(kDAQ, "PHYSICS", source->GetName()); |
307 | if(stringPHYSFileName.Length() <= 0){ | |
308 | Log(Form("No PHYSICS file from source %s!", source->GetName())); | |
309 | return 1; | |
310 | } | |
6024ec85 | 311 | // --- Initializing pedestal calibration object |
312 | AliZDCRecParam *recCalib = new AliZDCRecParam("ZDC"); | |
313 | // --- Reading file with pedestal calibration data | |
d5e687c2 | 314 | const char* physFileName = stringPHYSFileName.Data(); |
315 | if(physFileName){ | |
b12033ab | 316 | FILE *file; |
d5e687c2 | 317 | if((file = fopen(physFileName,"r")) == NULL){ |
318 | printf("Cannot open file %s \n",physFileName); | |
b12033ab | 319 | return 1; |
320 | } | |
d5e687c2 | 321 | Log(Form("File %s connected to process data from PHYSICS runs", physFileName)); |
b12033ab | 322 | // |
d5e687c2 | 323 | Float_t physRecParam[10]; |
324 | for(Int_t j=0; j<10; j++) fscanf(file,"%f",&physRecParam[j]); | |
6024ec85 | 325 | recCalib->SetZEMEndValue(physRecParam[0]); |
326 | recCalib->SetZEMCutFraction(physRecParam[1]); | |
327 | recCalib->SetDZEMSup(physRecParam[2]); | |
328 | recCalib->SetDZEMInf(physRecParam[3]); | |
329 | recCalib->SetEZN1MaxValue(physRecParam[4]); | |
330 | recCalib->SetEZP1MaxValue(physRecParam[5]); | |
331 | recCalib->SetEZDC1MaxValue(physRecParam[6]); | |
332 | recCalib->SetEZN2MaxValue(physRecParam[7]); | |
333 | recCalib->SetEZP2MaxValue(physRecParam[8]); | |
334 | recCalib->SetEZDC2MaxValue(physRecParam[9]); | |
b12033ab | 335 | } |
336 | else{ | |
d5e687c2 | 337 | Log(Form("File %s not found", physFileName)); |
b12033ab | 338 | return 1; |
339 | } | |
340 | //calibdata->Print(""); | |
6024ec85 | 341 | // |
342 | AliCDBMetaData metaData; | |
343 | metaData.SetBeamPeriod(0); | |
344 | metaData.SetResponsible("Chiara"); | |
345 | metaData.SetComment("Filling AliZDCCalib object"); | |
346 | // | |
347 | resRecPar = Store("Calib","RecParam",recCalib, &metaData, 0, 1); | |
b12033ab | 348 | } |
c58c7e82 | 349 | } |
350 | else { | |
bff168f8 | 351 | Log(Form("Nothing to do: run type is %s", runType.Data())); |
352 | return 0; | |
c58c7e82 | 353 | } |
028eb4a1 | 354 | |
e1ea0c63 | 355 | // note that the parameters are returned as character strings! |
356 | const char* nEvents = GetRunParameter("totalEvents"); | |
79563ba1 | 357 | if(nEvents) Log(Form("Number of events for run %d: %s",fRun, nEvents)); |
358 | else Log(Form("Number of events not put in logbook!")); | |
79563ba1 | 359 | |
cb50c7c8 | 360 | UInt_t result = 0; |
86fd32fd | 361 | if(resDCSRef==kFALSE || resultAl==kFALSE || |
362 | resPedCal==kFALSE || resECal==kFALSE || resRecPar==kFALSE){ | |
363 | if(resDCSRef == kFALSE) result = 1; | |
364 | else if(resultAl == kFALSE) result = 2; | |
365 | else if(resPedCal == kFALSE) result = 3; | |
366 | else if(resECal == kFALSE) result = 4; | |
367 | else if(resRecPar == kFALSE) result = 5; | |
cb50c7c8 | 368 | } |
369 | ||
64a7c78d | 370 | return result; |
cb50c7c8 | 371 | |
64a7c78d | 372 | } |