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->ProcessData(*dcsAliasMap, dcsValues);
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("");
87 // --- Writing ZDC table positions into alignment object
88 TClonesArray *array = new TClonesArray("AliAlignObjParams",10);
89 TClonesArray &alobj = *array;
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";
102 AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
103 UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);
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
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);
116 // *************** From DAQ ******************
117 Bool_t resPedCal = kTRUE, resECal = kTRUE, resRecPar = kTRUE;
118 // *****************************************************
119 // [a] PEDESTALS -> Pedestal subtraction
120 // *****************************************************
121 TString runType = GetRunType();
122 printf("\n\t AliZDCPreprocessor -> runType detected %s\n\n",runType.Data());
123 if(runType == "STANDALONE_PEDESTAL"){
124 TList* daqSources = GetFileSources(kDAQ, "PEDESTALS");
126 Log(Form("No source for STANDALONE_PEDESTAL run %d !", fRun));
129 Log("\t List of sources for STANDALONE_PEDESTAL");
132 TIter iter(daqSources);
133 TObjString* source = 0;
135 while((source = dynamic_cast<TObjString*> (iter.Next()))){
136 Log(Form("\n\t Getting file #%d\n",++i));
137 TString stringPedFileName = GetFile(kDAQ, "PEDESTALS", source->GetName());
138 if(stringPedFileName.Length() <= 0){
139 Log(Form("No PEDESTAL file from source %s!", source->GetName()));
142 // --- Initializing pedestal calibration object
143 AliZDCPedestals *pedCalib = new AliZDCPedestals("ZDC");
144 // --- Reading file with pedestal calibration data
145 const char* pedFileName = stringPedFileName.Data();
146 // no. ADCch = (22 signal ch. + 2 reference PMs) * 2 gain chain = 48
147 const Int_t knZDCch = 48;
150 if((file = fopen(pedFileName,"r")) == NULL){
151 printf("Cannot open file %s \n",pedFileName);
154 Log(Form("File %s connected to process pedestal data", pedFileName));
155 Float_t pedVal[(3*knZDCch)][3];
156 for(Int_t i=0; i<(3*knZDCch); i++){
157 for(Int_t j=0; j<3; j++){
158 fscanf(file,"%f",&pedVal[i][j]);
159 //if(j==1) printf("pedVal[%d] -> %f, %f \n",i,pedVal[i][0],pedVal[i][1]);
162 pedCalib->SetMeanPed(i,pedVal[i][1]);
163 pedCalib->SetMeanPedWidth(i,pedVal[i][2]);
165 else if(i>=knZDCch && i<(2*knZDCch)){
166 pedCalib->SetOOTPed(i-knZDCch,pedVal[i][1]);
167 pedCalib->SetOOTPedWidth(i-knZDCch,pedVal[i][2]);
169 else if(i>=(2*knZDCch) && i<(3*knZDCch)){
170 pedCalib->SetPedCorrCoeff(i-(2*knZDCch),pedVal[i][1],pedVal[i][2]);
175 Log(Form("File %s not found", pedFileName));
179 //pedCalib->Print("");
181 AliCDBMetaData metaData;
182 metaData.SetBeamPeriod(0);
183 metaData.SetResponsible("Chiara");
184 metaData.SetComment("Filling AliZDCPedestals object");
186 resPedCal = Store("Calib","Pedestals",pedCalib, &metaData, 0, 1);
188 delete daqSources; daqSources = 0;
190 // *****************************************************
191 // [b] EMD EVENTS -> Energy calibration and equalization
192 // *****************************************************
193 else if(runType == "STANDALONE_EMD"){
194 TList* daqSources = GetFileSources(kDAQ, "EMDCALIB");
196 AliError(Form("No sources for STANDALONE_EMD run %d !", fRun));
199 Log("\t List of sources for STANDALONE_EMD");
202 TIter iter2(daqSources);
203 TObjString* source = 0;
205 while((source = dynamic_cast<TObjString*> (iter2.Next()))){
206 Log(Form("\n\t Getting file #%d\n",++j));
207 TString stringEMDFileName = GetFile(kDAQ, "EMDCALIB", source->GetName());
208 if(stringEMDFileName.Length() <= 0){
209 Log(Form("No EMDCALIB file from source %s!", source->GetName()));
212 // --- Initializing pedestal calibration object
213 AliZDCCalib *eCalib = new AliZDCCalib("ZDC");
214 // --- Reading file with pedestal calibration data
215 const char* emdFileName = stringEMDFileName.Data();
218 if((file = fopen(emdFileName,"r")) == NULL){
219 printf("Cannot open file %s \n",emdFileName);
222 Log(Form("File %s connected to process data from EM dissociation events", emdFileName));
224 Float_t fitValEMD[6]; Float_t equalCoeff[5][4];
226 for(Int_t j=0; j<10; j++){
228 fscanf(file,"%f",&fitValEMD[j]);
230 calibVal[j] = 2.76/fitValEMD[j];
231 eCalib->SetEnCalib(j,calibVal[j]);
233 else eCalib->SetEnCalib(j,fitValEMD[j]);
236 for(Int_t k=0; k<5; k++){
237 fscanf(file,"%f",&equalCoeff[j][k]);
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]);
247 Log(Form("File %s not found", emdFileName));
250 //calibdata->Print("");
252 AliCDBMetaData metaData;
253 metaData.SetBeamPeriod(0);
254 metaData.SetResponsible("Chiara");
255 metaData.SetComment("Filling AliZDCCalib object");
257 resECal = Store("Calib","Calib",eCalib, &metaData, 0, 1);
260 // ********************************************************
261 // [c] PHYSICS RUNS -> Parameters needed for reconstruction
262 // ********************************************************
263 else if(runType == "PHYSICS"){
264 TList* daqSources = GetFileSources(kDAQ, "PHYSICS");
266 AliError(Form("No sources for PHYSICS run %d !", fRun));
269 Log("\t List of sources for PHYSICS");
272 TIter iter2(daqSources);
273 TObjString* source = 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()));
282 // --- Initializing pedestal calibration object
283 AliZDCRecParam *recCalib = new AliZDCRecParam("ZDC");
284 // --- Reading file with pedestal calibration data
285 const char* physFileName = stringPHYSFileName.Data();
288 if((file = fopen(physFileName,"r")) == NULL){
289 printf("Cannot open file %s \n",physFileName);
292 Log(Form("File %s connected to process data from PHYSICS runs", physFileName));
294 Float_t physRecParam[10];
295 for(Int_t j=0; j<10; j++) fscanf(file,"%f",&physRecParam[j]);
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]);
308 Log(Form("File %s not found", physFileName));
311 //calibdata->Print("");
313 AliCDBMetaData metaData;
314 metaData.SetBeamPeriod(0);
315 metaData.SetResponsible("Chiara");
316 metaData.SetComment("Filling AliZDCCalib object");
318 resRecPar = Store("Calib","RecParam",recCalib, &metaData, 0, 1);
322 Log(Form("Nothing to do: run type is %s", runType.Data()));
326 // note that the parameters are returned as character strings!
327 const char* nEvents = GetRunParameter("totalEvents");
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!"));
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;