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