3 #include <TClonesArray.h>
5 #include <TObjString.h>
6 #include <TTimeStamp.h>
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"
16 #include "AliZDCDataDCS.h"
17 #include "AliZDCPedestals.h"
18 #include "AliZDCCalib.h"
19 #include "AliZDCRecParam.h"
21 /////////////////////////////////////////////////////////////////////
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. //
27 /////////////////////////////////////////////////////////////////////
29 ClassImp(AliZDCPreprocessor)
31 //______________________________________________________________________________________________
32 AliZDCPreprocessor::AliZDCPreprocessor(AliShuttleInterface* shuttle) :
33 AliPreprocessor("ZDC", shuttle),
37 AddRunType("STANDALONE_PEDESTAL");
38 AddRunType("STANDALONE_EMD");
39 AddRunType("PHYSICS");
43 //______________________________________________________________________________________________
44 AliZDCPreprocessor::~AliZDCPreprocessor()
50 //______________________________________________________________________________________________
51 void AliZDCPreprocessor::Initialize(Int_t run, UInt_t startTime,
54 // Creates AliZDCDataDCS object
56 AliPreprocessor::Initialize(run, startTime, endTime);
58 Log(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
59 TTimeStamp(startTime).AsString(),
60 TTimeStamp(endTime).AsString()));
63 fStartTime = startTime;
66 fData = new AliZDCDataDCS(fRun, fStartTime, fEndTime);
69 //______________________________________________________________________________________________
70 UInt_t AliZDCPreprocessor::Process(TMap* dcsAliasMap)
72 // *************** From DCS ******************
73 // Fills data into a AliZDCDataDCS object
74 if(!dcsAliasMap) return 1;
76 // The processing of the DCS input data is forwarded to AliZDCDataDCS
77 Float_t dcsValues[28]; // DCSAliases=28
78 fData->SetCalibData(dcsValues);
79 fData->ProcessData(*dcsAliasMap);
80 // Store DCS data for reference
81 AliCDBMetaData metadata;
82 metadata.SetResponsible("Chiara Oppedisano");
83 metadata.SetComment("DCS data for ZDC");
84 Bool_t resDCSRef = kTRUE;
85 resDCSRef = StoreReferenceData("DCS","Data",fData,&metadata);
86 //dcsAliasMap->Print("");
88 // --- Writing ZDC table positions into alignment object
89 TClonesArray *array = new TClonesArray("AliAlignObjParams",10);
90 TClonesArray &alobj = *array;
92 Double_t dx=0., dz=0., dpsi=0., dtheta=0., dphi=0.;
93 // Vertical table position in mm from DCS
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";
103 AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
104 UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);
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);
110 // save in CDB storage
112 md.SetResponsible("Chiara Oppedisano");
113 md.SetComment("Alignment object for ZDC");
114 Bool_t resultAl = kTRUE;
115 resultAl = Store("Align","Data", array, &md, 0, 0);
117 // *************** From DAQ ******************
118 Bool_t resPedCal = kTRUE, resECal = kTRUE, resRecPar = kTRUE;
119 // *****************************************************
120 // [a] PEDESTALS -> Pedestal subtraction
121 // *****************************************************
122 TString runType = GetRunType();
123 printf("\n\t AliZDCPreprocessor -> runType detected %s\n\n",runType.Data());
124 if(runType == "STANDALONE_PEDESTAL"){
125 TList* daqSources = GetFileSources(kDAQ, "PEDESTALS");
127 Log(Form("No source for STANDALONE_PEDESTAL run %d !", fRun));
130 Log("\t List of sources for STANDALONE_PEDESTAL");
133 TIter iter(daqSources);
134 TObjString* source = 0;
136 while((source = dynamic_cast<TObjString*> (iter.Next()))){
137 Log(Form("\n\t Getting file #%d\n",++i));
138 TString stringPedFileName = GetFile(kDAQ, "PEDESTALS", source->GetName());
139 if(stringPedFileName.Length() <= 0){
140 Log(Form("No PEDESTAL file from source %s!", source->GetName()));
143 // --- Initializing pedestal calibration object
144 AliZDCPedestals *pedCalib = new AliZDCPedestals("ZDC");
145 // --- Reading file with pedestal calibration data
146 const char* pedFileName = stringPedFileName.Data();
147 // no. ADCch = (22 signal ch. + 2 reference PMs) * 2 gain chain = 48
148 const Int_t knZDCch = 48;
151 if((file = fopen(pedFileName,"r")) == NULL){
152 printf("Cannot open file %s \n",pedFileName);
155 Log(Form("File %s connected to process pedestal data", pedFileName));
156 Float_t pedVal[(3*knZDCch)][3];
157 for(Int_t k=0; k<(3*knZDCch); k++){
158 for(Int_t j=0; j<3; j++){
159 fscanf(file,"%f",&pedVal[k][j]);
160 //if(j==1) printf("pedVal[%d] -> %f, %f \n",k,pedVal[k][0],pedVal[k][1]);
163 pedCalib->SetMeanPed(k,pedVal[k][1]);
164 pedCalib->SetMeanPedWidth(i,pedVal[k][2]);
166 else if(k>=knZDCch && k<(2*knZDCch)){
167 pedCalib->SetOOTPed(k-knZDCch,pedVal[k][1]);
168 pedCalib->SetOOTPedWidth(k-knZDCch,pedVal[k][2]);
170 else if(k>=(2*knZDCch) && k<(3*knZDCch)){
171 pedCalib->SetPedCorrCoeff(k-(2*knZDCch),pedVal[k][1],pedVal[k][2]);
176 Log(Form("File %s not found", pedFileName));
180 //pedCalib->Print("");
182 AliCDBMetaData metaData;
183 metaData.SetBeamPeriod(0);
184 metaData.SetResponsible("Chiara");
185 metaData.SetComment("Filling AliZDCPedestals object");
187 resPedCal = Store("Calib","Pedestals",pedCalib, &metaData, 0, 1);
189 delete daqSources; daqSources = 0;
191 // *****************************************************
192 // [b] EMD EVENTS -> Energy calibration and equalization
193 // *****************************************************
194 else if(runType == "STANDALONE_EMD"){
195 TList* daqSources = GetFileSources(kDAQ, "EMDCALIB");
197 AliError(Form("No sources for STANDALONE_EMD run %d !", fRun));
200 Log("\t List of sources for STANDALONE_EMD");
203 TIter iter2(daqSources);
204 TObjString* source = 0;
206 while((source = dynamic_cast<TObjString*> (iter2.Next()))){
207 Log(Form("\n\t Getting file #%d\n",++i));
208 TString stringEMDFileName = GetFile(kDAQ, "EMDCALIB", source->GetName());
209 if(stringEMDFileName.Length() <= 0){
210 Log(Form("No EMDCALIB file from source %s!", source->GetName()));
213 // --- Initializing pedestal calibration object
214 AliZDCCalib *eCalib = new AliZDCCalib("ZDC");
215 // --- Reading file with pedestal calibration data
216 const char* emdFileName = stringEMDFileName.Data();
219 if((file = fopen(emdFileName,"r")) == NULL){
220 printf("Cannot open file %s \n",emdFileName);
223 Log(Form("File %s connected to process data from EM dissociation events", emdFileName));
225 Float_t fitValEMD[6]; Float_t equalCoeff[5][4];
227 for(Int_t j=0; j<10; j++){
229 fscanf(file,"%f",&fitValEMD[j]);
231 calibVal[j] = 2.76/fitValEMD[j];
232 eCalib->SetEnCalib(j,calibVal[j]);
234 else eCalib->SetEnCalib(j,fitValEMD[j]);
237 for(Int_t k=0; k<5; k++){
238 fscanf(file,"%f",&equalCoeff[j][k]);
239 if(j==6) eCalib->SetZN1EqualCoeff(k, equalCoeff[j][k]);
240 else if(j==7) eCalib->SetZP1EqualCoeff(k, equalCoeff[j][k]);
241 else if(j==8) eCalib->SetZN2EqualCoeff(k, equalCoeff[j][k]);
242 else if(j==9) eCalib->SetZP2EqualCoeff(k, equalCoeff[j][k]);
248 Log(Form("File %s not found", emdFileName));
251 //calibdata->Print("");
253 AliCDBMetaData metaData;
254 metaData.SetBeamPeriod(0);
255 metaData.SetResponsible("Chiara");
256 metaData.SetComment("Filling AliZDCCalib object");
258 resECal = Store("Calib","Calib",eCalib, &metaData, 0, 1);
261 // ********************************************************
262 // [c] PHYSICS RUNS -> Parameters needed for reconstruction
263 // ********************************************************
264 else if(runType == "PHYSICS"){
265 TList* daqSources = GetFileSources(kDAQ, "PHYSICS");
267 AliError(Form("No sources for PHYSICS run %d !", fRun));
270 Log("\t List of sources for PHYSICS");
273 TIter iter2(daqSources);
274 TObjString* source = 0;
276 while((source = dynamic_cast<TObjString*> (iter2.Next()))){
277 Log(Form("\n\t Getting file #%d\n",++i));
278 TString stringPHYSFileName = GetFile(kDAQ, "PHYSICS", source->GetName());
279 if(stringPHYSFileName.Length() <= 0){
280 Log(Form("No PHYSICS file from source %s!", source->GetName()));
283 // --- Initializing pedestal calibration object
284 AliZDCRecParam *recCalib = new AliZDCRecParam("ZDC");
285 // --- Reading file with pedestal calibration data
286 const char* physFileName = stringPHYSFileName.Data();
289 if((file = fopen(physFileName,"r")) == NULL){
290 printf("Cannot open file %s \n",physFileName);
293 Log(Form("File %s connected to process data from PHYSICS runs", physFileName));
295 Float_t physRecParam[10];
296 for(Int_t j=0; j<10; j++) fscanf(file,"%f",&physRecParam[j]);
297 recCalib->SetZEMEndValue(physRecParam[0]);
298 recCalib->SetZEMCutFraction(physRecParam[1]);
299 recCalib->SetDZEMSup(physRecParam[2]);
300 recCalib->SetDZEMInf(physRecParam[3]);
301 recCalib->SetEZN1MaxValue(physRecParam[4]);
302 recCalib->SetEZP1MaxValue(physRecParam[5]);
303 recCalib->SetEZDC1MaxValue(physRecParam[6]);
304 recCalib->SetEZN2MaxValue(physRecParam[7]);
305 recCalib->SetEZP2MaxValue(physRecParam[8]);
306 recCalib->SetEZDC2MaxValue(physRecParam[9]);
309 Log(Form("File %s not found", physFileName));
312 //calibdata->Print("");
314 AliCDBMetaData metaData;
315 metaData.SetBeamPeriod(0);
316 metaData.SetResponsible("Chiara");
317 metaData.SetComment("Filling AliZDCCalib object");
319 resRecPar = Store("Calib","RecParam",recCalib, &metaData, 0, 1);
323 Log(Form("Nothing to do: run type is %s", runType.Data()));
327 // note that the parameters are returned as character strings!
328 const char* nEvents = GetRunParameter("totalEvents");
329 if(nEvents) Log(Form("Number of events for run %d: %s",fRun, nEvents));
330 else Log(Form("Number of events not put in logbook!"));
333 if(resDCSRef==kFALSE || resultAl==kFALSE ||
334 resPedCal==kFALSE || resECal==kFALSE || resRecPar==kFALSE){
335 if(resDCSRef == kFALSE) result = 1;
336 else if(resultAl == kFALSE) result = 2;
337 else if(resPedCal == kFALSE) result = 3;
338 else if(resECal == kFALSE) result = 4;
339 else if(resRecPar == kFALSE) result = 5;