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