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