]>
Commit | Line | Data |
---|---|---|
1 | // --- ROOT system | |
2 | #include <TFile.h> | |
3 | #include <TClonesArray.h> | |
4 | #include <TList.h> | |
5 | #include <TObjString.h> | |
6 | #include <TTimeStamp.h> | |
7 | ||
8 | #include "AliZDCPreprocessor.h" | |
9 | #include "AliCDBManager.h" | |
10 | #include "AliCDBEntry.h" | |
11 | #include "AliCDBMetaData.h" | |
12 | #include "AliDCSValue.h" | |
13 | #include "AliAlignObj.h" | |
14 | #include "AliAlignObjParams.h" | |
15 | #include "AliLog.h" | |
16 | #include "AliZDCDataDCS.h" | |
17 | #include "AliZDCPedestals.h" | |
18 | #include "AliZDCCalib.h" | |
19 | ||
20 | ///////////////////////////////////////////////////////////////////// | |
21 | // // | |
22 | // Class implementing ZDC pre-processor. // | |
23 | // It takes data from DCS and passes it to the class AliZDCDataDCS // | |
24 | // The class is then written to the CDB. // | |
25 | // // | |
26 | ///////////////////////////////////////////////////////////////////// | |
27 | ||
28 | ClassImp(AliZDCPreprocessor) | |
29 | ||
30 | //______________________________________________________________________________________________ | |
31 | AliZDCPreprocessor::AliZDCPreprocessor(AliShuttleInterface* shuttle) : | |
32 | AliPreprocessor("ZDC", shuttle), | |
33 | fData(0) | |
34 | { | |
35 | // constructor | |
36 | AddRunType("STANDALONE_PEDESTAL"); | |
37 | AddRunType("STANDALONE_EMD"); | |
38 | AddRunType("PHYSICS"); | |
39 | } | |
40 | ||
41 | ||
42 | //______________________________________________________________________________________________ | |
43 | AliZDCPreprocessor::~AliZDCPreprocessor() | |
44 | { | |
45 | // destructor | |
46 | } | |
47 | ||
48 | ||
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 | ||
57 | Log(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run, | |
58 | TTimeStamp(startTime).AsString(), | |
59 | TTimeStamp(endTime).AsString())); | |
60 | ||
61 | fRun = run; | |
62 | fStartTime = startTime; | |
63 | fEndTime = endTime; | |
64 | ||
65 | fData = new AliZDCDataDCS(fRun, fStartTime, fEndTime); | |
66 | } | |
67 | ||
68 | //______________________________________________________________________________________________ | |
69 | UInt_t AliZDCPreprocessor::Process(TMap* dcsAliasMap) | |
70 | { | |
71 | // *************** From DCS ****************** | |
72 | // Fills data into a AliZDCDataDCS object | |
73 | if(!dcsAliasMap) return 1; | |
74 | ||
75 | // The processing of the DCS input data is forwarded to AliZDCDataDCS | |
76 | Float_t dcsValues[28]; // DCSAliases=28 | |
77 | fData->SetCalibData(dcsValues); | |
78 | fData->ProcessData(*dcsAliasMap); | |
79 | // Store DCS data for reference | |
80 | AliCDBMetaData metadata; | |
81 | metadata.SetResponsible("Chiara Oppedisano"); | |
82 | metadata.SetComment("DCS data for ZDC"); | |
83 | Bool_t resDCSRef = kTRUE; | |
84 | resDCSRef = StoreReferenceData("DCS","Data",fData,&metadata); | |
85 | //dcsAliasMap->Print(""); | |
86 | // | |
87 | // --- Writing ZDC table positions into alignment object | |
88 | TClonesArray *array = new TClonesArray("AliAlignObjParams",10); | |
89 | TClonesArray &alobj = *array; | |
90 | AliAlignObjParams a; | |
91 | Double_t dx=0., dz=0., dpsi=0., dtheta=0., dphi=0.; | |
92 | // Vertical table position in mm from DCS | |
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"; | |
101 | UShort_t iIndex=0; | |
102 | AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer; | |
103 | UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex); | |
104 | // | |
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); | |
109 | // save in CDB storage | |
110 | AliCDBMetaData md; | |
111 | md.SetResponsible("Chiara Oppedisano"); | |
112 | md.SetComment("Alignment object for ZDC"); | |
113 | Bool_t resultAl = kTRUE; | |
114 | resultAl = Store("Align","Data", array, &md, 0, 0); | |
115 | ||
116 | // *************** From DAQ ****************** | |
117 | Bool_t resPedCal = kTRUE, resECal = kTRUE, resRecPar = kTRUE; | |
118 | // | |
119 | const char* beamType = GetRunParameter("beamType"); | |
120 | TString runType = GetRunType(); | |
121 | printf("\n\t AliZDCPreprocessor -> beamType %s\n",beamType); | |
122 | printf("\t AliZDCPreprocessor -> runType %s\n\n",runType.Data()); | |
123 | // | |
124 | // | |
125 | if(strcmp(beamType,"p-p")==0){ | |
126 | // --- Initializing pedestal calibration object | |
127 | AliZDCCalib *eCalib = new AliZDCCalib("ZDC"); | |
128 | // | |
129 | for(Int_t j=0; j<6; j++) eCalib->SetEnCalib(j,1.); | |
130 | for(Int_t j=0; j<5; j++){ | |
131 | eCalib->SetZN1EqualCoeff(j, 1.); | |
132 | eCalib->SetZP1EqualCoeff(j, 1.); | |
133 | eCalib->SetZN2EqualCoeff(j, 1.); | |
134 | eCalib->SetZP2EqualCoeff(j, 1.); | |
135 | } | |
136 | //eCalib->Print(""); | |
137 | // | |
138 | AliCDBMetaData metaData; | |
139 | metaData.SetBeamPeriod(0); | |
140 | metaData.SetResponsible("Chiara"); | |
141 | metaData.SetComment("AliZDCCalib object"); | |
142 | // | |
143 | resECal = Store("Calib","Calib",eCalib, &metaData, 0, 1); | |
144 | } | |
145 | // | |
146 | // ***************************************************** | |
147 | // [a] PEDESTALS -> Pedestal subtraction | |
148 | // ***************************************************** | |
149 | // | |
150 | if(runType=="STANDALONE_PEDESTAL"){ | |
151 | TList* daqSources = GetFileSources(kDAQ, "PEDESTALS"); | |
152 | if(!daqSources){ | |
153 | Log(Form("No source for STANDALONE_PEDESTAL run %d !", fRun)); | |
154 | return 1; | |
155 | } | |
156 | Log("\t List of sources for STANDALONE_PEDESTAL"); | |
157 | daqSources->Print(); | |
158 | // | |
159 | TIter iter(daqSources); | |
160 | TObjString* source = 0; | |
161 | Int_t i=0; | |
162 | while((source = dynamic_cast<TObjString*> (iter.Next()))){ | |
163 | Log(Form("\n\t Getting file #%d\n",++i)); | |
164 | TString stringPedFileName = GetFile(kDAQ, "PEDESTALS", source->GetName()); | |
165 | if(stringPedFileName.Length() <= 0){ | |
166 | Log(Form("No PEDESTAL file from source %s!", source->GetName())); | |
167 | return 1; | |
168 | } | |
169 | // --- Initializing pedestal calibration object | |
170 | AliZDCPedestals *pedCalib = new AliZDCPedestals("ZDC"); | |
171 | // --- Reading file with pedestal calibration data | |
172 | const char* pedFileName = stringPedFileName.Data(); | |
173 | // no. ADCch = (22 signal ch. + 2 reference PMs) * 2 gain chain = 48 | |
174 | const Int_t knZDCch = 48; | |
175 | if(pedFileName){ | |
176 | FILE *file; | |
177 | if((file = fopen(pedFileName,"r")) == NULL){ | |
178 | printf("Cannot open file %s \n",pedFileName); | |
179 | return 1; | |
180 | } | |
181 | Log(Form("File %s connected to process pedestal data", pedFileName)); | |
182 | Float_t pedVal[(3*knZDCch)][3]; | |
183 | for(Int_t k=0; k<(3*knZDCch); k++){ | |
184 | for(Int_t j=0; j<3; j++){ | |
185 | fscanf(file,"%f",&pedVal[k][j]); | |
186 | //if(j==1) printf("pedVal[%d] -> %f, %f \n",k,pedVal[k][0],pedVal[k][1]); | |
187 | } | |
188 | if(k<knZDCch){ | |
189 | pedCalib->SetMeanPed(k,pedVal[k][1]); | |
190 | pedCalib->SetMeanPedWidth(i,pedVal[k][2]); | |
191 | } | |
192 | else if(k>=knZDCch && k<(2*knZDCch)){ | |
193 | pedCalib->SetOOTPed(k-knZDCch,pedVal[k][1]); | |
194 | pedCalib->SetOOTPedWidth(k-knZDCch,pedVal[k][2]); | |
195 | } | |
196 | else if(k>=(2*knZDCch) && k<(3*knZDCch)){ | |
197 | pedCalib->SetPedCorrCoeff(k-(2*knZDCch),pedVal[k][1],pedVal[k][2]); | |
198 | } | |
199 | } | |
200 | } | |
201 | else{ | |
202 | Log(Form("File %s not found", pedFileName)); | |
203 | return 1; | |
204 | } | |
205 | // | |
206 | //pedCalib->Print(""); | |
207 | // | |
208 | AliCDBMetaData metaData; | |
209 | metaData.SetBeamPeriod(0); | |
210 | metaData.SetResponsible("Chiara"); | |
211 | metaData.SetComment("Filling AliZDCPedestals object"); | |
212 | // | |
213 | resPedCal = Store("Calib","Pedestals",pedCalib, &metaData, 0, 1); | |
214 | } | |
215 | delete daqSources; daqSources = 0; | |
216 | } | |
217 | // ***************************************************** | |
218 | // [b] EMD EVENTS -> Energy calibration and equalization | |
219 | // ***************************************************** | |
220 | else if(runType=="STANDALONE_EMD"){ | |
221 | TList* daqSources = GetFileSources(kDAQ, "EMDCALIB"); | |
222 | if(!daqSources){ | |
223 | AliError(Form("No sources for STANDALONE_EMD run %d !", fRun)); | |
224 | return 1; | |
225 | } | |
226 | Log("\t List of sources for STANDALONE_EMD"); | |
227 | daqSources->Print(); | |
228 | // | |
229 | TIter iter2(daqSources); | |
230 | TObjString* source = 0; | |
231 | Int_t i=0; | |
232 | while((source = dynamic_cast<TObjString*> (iter2.Next()))){ | |
233 | Log(Form("\n\t Getting file #%d\n",++i)); | |
234 | TString stringEMDFileName = GetFile(kDAQ, "EMDCALIB", source->GetName()); | |
235 | if(stringEMDFileName.Length() <= 0){ | |
236 | Log(Form("No EMDCALIB file from source %s!", source->GetName())); | |
237 | return 1; | |
238 | } | |
239 | // --- Initializing pedestal calibration object | |
240 | AliZDCCalib *eCalib = new AliZDCCalib("ZDC"); | |
241 | // --- Reading file with pedestal calibration data | |
242 | const char* emdFileName = stringEMDFileName.Data(); | |
243 | if(emdFileName){ | |
244 | FILE *file; | |
245 | if((file = fopen(emdFileName,"r")) == NULL){ | |
246 | printf("Cannot open file %s \n",emdFileName); | |
247 | return 1; | |
248 | } | |
249 | Log(Form("File %s connected to process data from EM dissociation events", emdFileName)); | |
250 | // | |
251 | Float_t fitValEMD[6]; Float_t equalCoeff[5][4]; | |
252 | Float_t calibVal[4]; | |
253 | for(Int_t j=0; j<10; j++){ | |
254 | if(j<6){ | |
255 | fscanf(file,"%f",&fitValEMD[j]); | |
256 | if(j<4){ | |
257 | calibVal[j] = 2.76/fitValEMD[j]; | |
258 | eCalib->SetEnCalib(j,calibVal[j]); | |
259 | } | |
260 | else eCalib->SetEnCalib(j,fitValEMD[j]); | |
261 | } | |
262 | else{ | |
263 | for(Int_t k=0; k<5; k++){ | |
264 | fscanf(file,"%f",&equalCoeff[j][k]); | |
265 | if(j==6) eCalib->SetZN1EqualCoeff(k, equalCoeff[j][k]); | |
266 | else if(j==7) eCalib->SetZP1EqualCoeff(k, equalCoeff[j][k]); | |
267 | else if(j==8) eCalib->SetZN2EqualCoeff(k, equalCoeff[j][k]); | |
268 | else if(j==9) eCalib->SetZP2EqualCoeff(k, equalCoeff[j][k]); | |
269 | } | |
270 | } | |
271 | } | |
272 | } | |
273 | else{ | |
274 | Log(Form("File %s not found", emdFileName)); | |
275 | return 1; | |
276 | } | |
277 | //eCalib->Print(""); | |
278 | // | |
279 | AliCDBMetaData metaData; | |
280 | metaData.SetBeamPeriod(0); | |
281 | metaData.SetResponsible("Chiara"); | |
282 | metaData.SetComment("Filling AliZDCCalib object"); | |
283 | // | |
284 | resECal = Store("Calib","Calib",eCalib, &metaData, 0, 1); | |
285 | } | |
286 | } | |
287 | else { | |
288 | Log(Form("Nothing to do: run type is %s", runType.Data())); | |
289 | return 0; | |
290 | } | |
291 | ||
292 | // note that the parameters are returned as character strings! | |
293 | const char* nEvents = GetRunParameter("totalEvents"); | |
294 | if(nEvents) Log(Form("Number of events for run %d: %s",fRun, nEvents)); | |
295 | else Log(Form("Number of events not put in logbook!")); | |
296 | ||
297 | UInt_t result = 0; | |
298 | if(resDCSRef==kFALSE || resultAl==kFALSE || | |
299 | resPedCal==kFALSE || resECal==kFALSE || resRecPar==kFALSE){ | |
300 | if(resDCSRef == kFALSE) result = 1; | |
301 | else if(resultAl == kFALSE) result = 2; | |
302 | else if(resPedCal == kFALSE) result = 3; | |
303 | else if(resECal == kFALSE) result = 4; | |
304 | else if(resRecPar == kFALSE) result = 5; | |
305 | } | |
306 | ||
307 | return result; | |
308 | ||
309 | } |