Add class to access simulation parameters, AliEMCALSimParam, to be set in configurati...
[u/mrichter/AliRoot.git] / ZDC / ZDCEMDda.cxx
CommitLineData
f16f149b 1/*
2
442e1b18 3This program reads the DAQ data files passed as argument using the monitoring library.
f16f149b 4
442e1b18 5It computes the average event size and populates local "./result.txt" file with the
6result.
f16f149b 7
442e1b18 8The program reports about its processing progress.
f16f149b 9
10Messages on stdout are exported to DAQ log system.
11
f9641c3b 12DA for ZDC standalone CALIBRATION_EMD runs
442e1b18 13
ea628de7 14Contact: Chiara.Oppedisano@to.infn.it
442e1b18 15Link:
ea628de7 16Run Type: STANDALONE_EMD_RUN
442e1b18 17DA Type: LDC
18Number of events needed: at least ~5*10^3
ea628de7 19Input Files: ZDCPedestal.dat
442e1b18 20Output Files: ZDCEMDCalib.dat, ZDCChMapping.dat
ea628de7 21Trigger Types Used: Standalone Trigger
f16f149b 22
23*/
78beff0d 24#define PEDDATA_FILE "ZDCPedestal.dat"
218f916a 25#define MAPDATA_FILE "ZDCChMapping.dat"
92fdeb0e 26#define ENCALIBDATA_FILE "ZDCEnergyCalib.dat"
f9641c3b 27#define TOWCALIBDATA_FILE "ZDCTowerCalib.dat"
f16f149b 28
29#include <stdio.h>
30#include <Riostream.h>
442e1b18 31#include <Riostream.h>
f16f149b 32
33// DATE
34#include <daqDA.h>
35#include <event.h>
36#include <monitor.h>
37
38//ROOT
f9641c3b 39#include <TROOT.h>
40#include <TPluginManager.h>
f16f149b 41#include <TH1F.h>
42#include <TH2F.h>
43#include <TProfile.h>
44#include <TF1.h>
45#include <TFile.h>
442e1b18 46#include <TFitter.h>
f9641c3b 47#include "TMinuitMinimizer.h"
f16f149b 48
49//AliRoot
50#include <AliRawReaderDate.h>
442e1b18 51#include <AliRawEventHeaderBase.h>
f16f149b 52#include <AliZDCRawStream.h>
53
54
55/* Main routine
56 Arguments:
57 1- monitoring data source
58*/
59int main(int argc, char **argv) {
60
f9641c3b 61
62 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
63 "*",
64 "TStreamerInfo",
65 "RIO",
66 "TStreamerInfo()");
67
68 TMinuitMinimizer m;
69 gROOT->GetPluginManager()->AddHandler("ROOT::Math::Minimizer", "Minuit","TMinuitMinimizer",
70 "Minuit", "TMinuitMinimizer(const char *)");
71 TVirtualFitter::SetDefaultFitter("Minuit");
442e1b18 72
73 int status = 0;
f9641c3b 74 // No. of ZDC cabled ch.
75 int const kNChannels = 24;
27afc0c8 76 int const kNScChannels = 32;
8700404e 77 Int_t kFirstADCGeo=0, kLastADCGeo=3;
442e1b18 78
79 /* log start of process */
80 printf("ZDC EMD program started\n");
81
82 /* check that we got some arguments = list of files */
83 if (argc<2) {
84 printf("Wrong number of arguments\n");
85 return -1;
86 }
87
f16f149b 88 // --- Preparing histos for EM dissociation spectra
89 //
90 TH1F* histoEMDRaw[4];
91 TH1F* histoEMDCorr[4];
e968a349 92 //
f16f149b 93 char namhistr[50], namhistc[50];
94 for(Int_t i=0; i<4; i++) {
95 if(i==0){
96 sprintf(namhistr,"ZN%d-EMDRaw",i+1);
97 sprintf(namhistc,"ZN%d-EMDCorr",i+1);
98 }
99 else if(i==1){
100 sprintf(namhistr,"ZP%d-EMDRaw",i);
101 sprintf(namhistc,"ZP%d-EMDCorr",i);
102 }
103 else if(i==2){
104 sprintf(namhistr,"ZN%d-EMDRaw",i);
105 sprintf(namhistc,"ZN%d-EMDCorr",i);
106 }
107 else if(i==3){
108 sprintf(namhistr,"ZP%d-EMDRaw",i-1);
109 sprintf(namhistc,"ZP%d-EMDCorr",i-1);
110 }
111 histoEMDRaw[i] = new TH1F(namhistr,namhistr,100,0.,4000.);
112 histoEMDCorr[i] = new TH1F(namhistc,namhistc,100,0.,4000.);
113 }
114
e968a349 115 // --- Preparing histos for tower inter-calibration
116 //
117 TH1F* histZNCtow[4]; TH1F* histZPCtow[4];
118 TH1F* histZNAtow[4]; TH1F* histZPAtow[4];
119 //
120 char namhistznc[50], namhistzpc[50];
121 char namhistzna[50], namhistzpa[50];
122 for(Int_t i=0; i<4; i++) {
123 sprintf(namhistznc,"ZNC-tow%d",i+1);
124 sprintf(namhistzpc,"ZPC-tow%d",i+1);
125 sprintf(namhistzna,"ZNA-tow%d",i+1);
126 sprintf(namhistzpa,"ZPA-tow%d",i+1);
127 //
128 histZNCtow[i] = new TH1F(namhistznc,namhistznc,100,0.,4000.);
129 histZPCtow[i] = new TH1F(namhistzpc,namhistzpc,100,0.,4000.);
130 histZNAtow[i] = new TH1F(namhistzna,namhistzna,100,0.,4000.);
131 histZPAtow[i] = new TH1F(namhistzpa,namhistzpa,100,0.,4000.);
132 }
133
f16f149b 134 /* open result file */
135 FILE *fp=NULL;
136 fp=fopen("./result.txt","a");
137 if (fp==NULL) {
138 printf("Failed to open file\n");
139 return -1;
140 }
141
442e1b18 142 FILE *mapFile4Shuttle;
218f916a 143
f9641c3b 144 // *** To analyze EMD events you MUST have a pedestal data file!!!
145 // *** -> check if a pedestal run has been analyzed
78beff0d 146 int read = 0;
218f916a 147 read = daqDA_DB_getFile(PEDDATA_FILE,PEDDATA_FILE);
78beff0d 148 if(read){
149 printf("\t ERROR!!! ZDCPedestal.dat file NOT FOUND in DAQ db!!!\n");
f16f149b 150 return -1;
151 }
78beff0d 152 else printf("\t ZDCPedestal.dat file retrieved from DAQ db\n");
153
154 FILE *filePed = fopen(PEDDATA_FILE,"r");
155 if (filePed==NULL) {
156 printf("\t ERROR!!! Can't open ZDCPedestal.dat file!!!\n");
f16f149b 157 return -1;
158 }
159
78beff0d 160 // 144 = 48 in-time + 48 out-of-time + 48 correlations
f9641c3b 161 Float_t readValues[2][3*2*kNChannels];
162 Float_t MeanPed[2*kNChannels];
163 Float_t CorrCoeff0[2*kNChannels], CorrCoeff1[2*kNChannels];
78beff0d 164 // ***************************************************
165 // Unless we have a narrow correlation to fit we
166 // don't fit and store in-time vs. out-of-time
167 // histograms -> mean pedstal subtracted!!!!!!
168 // ***************************************************
78beff0d 169 //
f9641c3b 170 for(int jj=0; jj<6*kNChannels; jj++){
78beff0d 171 for(int ii=0; ii<2; ii++){
172 fscanf(filePed,"%f",&readValues[ii][jj]);
173 }
f9641c3b 174 if(jj<kNChannels && jj<2*kNChannels){
78beff0d 175 MeanPed[jj] = readValues[0][jj];
f9641c3b 176 //printf("\t MeanPedhg[%d] = %1.1f\n",jj, MeanPedhg[jj]);
78beff0d 177 }
f9641c3b 178 else if(jj>2*kNChannels && jj>4*kNChannels){
179 CorrCoeff0[jj-4*kNChannels] = readValues[0][jj];
180 CorrCoeff1[jj-4*kNChannels] = readValues[1][jj];;
78beff0d 181 }
78beff0d 182 }
f16f149b 183
442e1b18 184 /* report progress */
185 daqDA_progressReport(10);
186
187
f16f149b 188 /* init some counters */
189 int nevents_physics=0;
190 int nevents_total=0;
191
d3f256ca 192 struct eventHeaderStruct *event;
193 eventTypeType eventT;
194
442e1b18 195 /* read the data files */
196 int n;
197 for(n=1;n<argc;n++){
198
199 status=monitorSetDataSource( argv[n] );
f16f149b 200 if (status!=0) {
442e1b18 201 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
202 return -1;
f16f149b 203 }
204
442e1b18 205 /* report progress */
206 /* in this example, indexed on the number of files */
207 daqDA_progressReport(10+80*n/argc);
208
209 /* read the file */
210 for(;;){
f16f149b 211
442e1b18 212 /* get next event */
213 status=monitorGetEventDynamic((void **)&event);
214 if(status==MON_ERR_EOF) break; /* end of monitoring file has been reached */
215 if(status!=0) {
216 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
217 return -1;
218 }
f16f149b 219
442e1b18 220 /* retry if got no event */
221 if(event==NULL) {
222 break;
223 }
224
225 // Initalize raw-data reading and decoding
226 AliRawReader *reader = new AliRawReaderDate((void*)event);
227 reader->Select("ZDC");
228 // --- Reading event header
229 //UInt_t evtype = reader->GetType();
230 //printf("\n\t ZDCEMDda -> ev. type %d\n",evtype);
231 //printf("\t ZDCEMDda -> run # %d\n",reader->GetRunNumber());
232 //
233 AliZDCRawStream *rawStreamZDC = new AliZDCRawStream(reader);
234
235
236 /* use event - here, just write event id to result file */
237 eventT=event->eventType;
238
f9641c3b 239 Int_t ich=0;
27afc0c8 240 Int_t adcMod[2*kNChannels], adcCh[2*kNChannels], sigCode[2*kNChannels];
241 Int_t det[2*kNChannels], sec[2*kNChannels];
242 for(Int_t y=0; y<2*kNChannels; y++){
243 adcMod[y]=adcCh[y]=sigCode[y]=det[y]=sec[y]=0;
244 }
245
246 Int_t iScCh=0;
247 Int_t scMod[kNScChannels], scCh[kNScChannels], scSigCode[kNScChannels];
248 Int_t scDet[kNScChannels], scSec[kNScChannels];
249 for(Int_t y=0; y<kNScChannels; y++){
250 scMod[y]=scCh[y]=scSigCode[y]=scDet[y]=scSec[y]=0;
251 }
252 //
253 Int_t modNum=-1, modType=-1;
f9641c3b 254
442e1b18 255 if(eventT==START_OF_DATA){
256
27afc0c8 257 rawStreamZDC->SetSODReading(kTRUE);
258
f9641c3b 259 // --------------------------------------------------------
260 // --- Writing ascii data file for the Shuttle preprocessor
261 mapFile4Shuttle = fopen(MAPDATA_FILE,"w");
442e1b18 262 if(!rawStreamZDC->Next()) printf(" \t No raw data found!! \n");
263 else{
27afc0c8 264 while((rawStreamZDC->Next())){
265 if(rawStreamZDC->IsHeaderMapping()){ // mapping header
266 modNum = rawStreamZDC->GetADCModule();
267 modType = rawStreamZDC->GetModType();
268 }
269 if(rawStreamZDC->IsChMapping()){
270 if(modType==1){ // ADC mapping ----------------------
271 adcMod[ich] = rawStreamZDC->GetADCModFromMap(ich);
272 adcCh[ich] = rawStreamZDC->GetADCChFromMap(ich);
273 sigCode[ich] = rawStreamZDC->GetADCSignFromMap(ich);
274 det[ich] = rawStreamZDC->GetDetectorFromMap(ich);
275 sec[ich] = rawStreamZDC->GetTowerFromMap(ich);
276 //
277 fprintf(mapFile4Shuttle,"\t%d\t%d\t%d\t%d\t%d\t%d\n",
278 ich,adcMod[ich],adcCh[ich],sigCode[ich],det[ich],sec[ich]);
279 //
280 //printf(" Mapping in DA -> %d ADC: mod %d ch %d, code %d det %d, sec %d\n",
281 // ich,adcMod[ich],adcCh[ich],sigCode[ich],det[ich],sec[ich]);
282 //
283 ich++;
284 }
285 else if(modType==2){ //VME scaler mapping --------------------
286 scMod[iScCh] = rawStreamZDC->GetScalerModFromMap(iScCh);
287 scCh[iScCh] = rawStreamZDC->GetScalerChFromMap(iScCh);
288 scSigCode[iScCh] = rawStreamZDC->GetScalerSignFromMap(iScCh);
289 scDet[iScCh] = rawStreamZDC->GetScDetectorFromMap(iScCh);
290 scSec[iScCh] = rawStreamZDC->GetScTowerFromMap(iScCh);
291 //
292 fprintf(mapFile4Shuttle,"\t%d\t%d\t%d\t%d\t%d\t%d\n",
293 iScCh,scMod[iScCh],scCh[iScCh],scSigCode[iScCh],scDet[iScCh],scSec[iScCh]);
294 //
295 //printf(" Mapping in DA -> %d Scaler: mod %d ch %d, code %d det %d, sec %d\n",
296 // iScCh,scMod[iScCh],scCh[iScCh],scSigCode[iScCh],scDet[iScCh],scSec[iScCh]);
297 //
298 iScCh++;
299 }
442e1b18 300 }
301 }
302 }
442e1b18 303 fclose(mapFile4Shuttle);
27afc0c8 304 }// SOD event
f16f149b 305
306 if(eventT==PHYSICS_EVENT){
78beff0d 307 // --- Reading data header
308 reader->ReadHeader();
f16f149b 309 const AliRawDataHeader* header = reader->GetDataHeader();
310 if(header){
ea628de7 311 UChar_t message = header->GetAttributes();
a5747d8f 312 if((message & 0x70) == 0x70){ // DEDICATED EMD RUN
442e1b18 313 //printf("\t STANDALONE_EMD_RUN raw data found\n");
ea628de7 314 continue;
315 }
316 else{
317 printf("\t NO STANDALONE_EMD_RUN raw data found\n");
318 return -1;
319 }
f16f149b 320 }
442e1b18 321 else{
322 printf("\t ATTENTION! No Raw Data Header found!!!\n");
323 return -1;
324 }
7f4bde92 325
326 rawStreamZDC->SetSODReading(kTRUE);
442e1b18 327
f16f149b 328 if (!rawStreamZDC->Next()) printf(" \t No raw data found!! ");
329 //
442e1b18 330 // ----- Setting ch. mapping -----
f9641c3b 331 for(Int_t jk=0; jk<2*kNChannels; jk++){
442e1b18 332 rawStreamZDC->SetMapADCMod(jk, adcMod[jk]);
333 rawStreamZDC->SetMapADCCh(jk, adcCh[jk]);
334 rawStreamZDC->SetMapADCSig(jk, sigCode[jk]);
335 rawStreamZDC->SetMapDet(jk, det[jk]);
336 rawStreamZDC->SetMapTow(jk, sec[jk]);
337 }
338 //
f16f149b 339 Float_t ZDCRawADC[4], ZDCCorrADC[4], ZDCCorrADCSum[4];
340 for(Int_t g=0; g<4; g++){
341 ZDCCorrADCSum[g] = 0.;
342 ZDCRawADC[g] = 0.;
343 }
344 //
345 while(rawStreamZDC->Next()){
f9641c3b 346 Int_t det = rawStreamZDC->GetSector(0);
347 Int_t quad = rawStreamZDC->GetSector(1);
348
349 if(rawStreamZDC->IsADCDataWord() && !(rawStreamZDC->IsUnderflow())
350 && !(rawStreamZDC->IsOverflow()) && det!=-1
8700404e 351 && (rawStreamZDC->GetADCGain() == 1 && // Selecting LOW RES ch.s
352 rawStreamZDC->GetADCModule()>=kFirstADCGeo && rawStreamZDC->GetADCModule()<=kLastADCGeo)){
f9641c3b 353
354 //printf(" IsADCWord %d, IsUnderflow %d, IsOverflow %d\n",
355 // rawStreamZDC->IsADCDataWord(),rawStreamZDC->IsUnderflow(),rawStreamZDC->IsOverflow());
356
e968a349 357 // Taking LOW RES channels -> ch.+kNChannels !!!!
ea628de7 358 Int_t DetIndex=999, PedIndex=999;
e968a349 359 // Not ZEM not PMRef && low gain chain
360 if((det!=3) && (quad!=5) && (rawStreamZDC->GetADCGain()==1)){
f9641c3b 361 if(det == 1){
362 DetIndex = det-1;
e968a349 363 PedIndex = quad+kNChannels;
f9641c3b 364 }
365 else if(det==2){
366 DetIndex = det-1;
367 PedIndex = quad+5+kNChannels;
368 }
369 else if(det == 4){
370 DetIndex = det-2;
371 PedIndex = quad+12+kNChannels;
372 }
373 else if(det == 5){
374 DetIndex = det-2;
375 PedIndex = quad+17+kNChannels;
376 }
e968a349 377 // Mean pedestal subtraction
378 Float_t Pedestal = MeanPed[PedIndex];
379 // Pedestal subtraction from correlation with out-of-time signals
380 //Float_t Pedestal = CorrCoeff0[PedIndex]+CorrCoeff1[PedIndex]*MeanPedOOT[PedIndex];
381 //
382 if(DetIndex!=999 || PedIndex!=999){
f9641c3b 383 //
384 ZDCRawADC[DetIndex] += (Float_t) rawStreamZDC->GetADCValue();
385 //
f9641c3b 386 //
387 ZDCCorrADC[DetIndex] = (rawStreamZDC->GetADCValue()) - Pedestal;
388 ZDCCorrADCSum[DetIndex] += ZDCCorrADC[DetIndex];
389 //
390 /*printf("\t det %d quad %d res %d pedInd %d detInd %d:"
391 "ADCCorr = %d, ZDCCorrADCSum = %d\n",
392 det,quad,rawStreamZDC->GetADCGain(),PedIndex,DetIndex,
393 (Int_t) ZDCCorrADC[DetIndex],(Int_t) ZDCCorrADCSum[DetIndex]);
e968a349 394 */
395 }
396 // Not common nor ref. PM && low gain chain
397 if((quad!=0) && (rawStreamZDC->GetADCGain()==1)){
398 Float_t corrADCval = (rawStreamZDC->GetADCValue()) - Pedestal;
399 if(det==1) histZNCtow[quad]->Fill(corrADCval);
400 else if(det==2) histZPCtow[quad]->Fill(corrADCval);
401 else if(det==4) histZNAtow[quad]->Fill(corrADCval);
402 else if(det==5) histZPAtow[quad]->Fill(corrADCval);
f9641c3b 403 }
e968a349 404
f9641c3b 405 if(DetIndex==999 || PedIndex==999)
406 printf(" WARNING! Detector a/o pedestal index are WRONG!!!\n");
407
e968a349 408 }
f16f149b 409 }//IsADCDataWord()
e968a349 410
f16f149b 411 }
412 //
413 nevents_physics++;
414 //
415 for(Int_t j=0; j<4; j++){
416 histoEMDRaw[j]->Fill(ZDCRawADC[j]);
417 histoEMDCorr[j]->Fill(ZDCCorrADCSum[j]);
418 }
d3f256ca 419 }//(if PHYSICS_EVENT)
f16f149b 420
421 nevents_total++;
422
442e1b18 423 }
d3f256ca 424
425 /* free resources */
426 free(event);
f16f149b 427 }
442e1b18 428
f16f149b 429 /* Analysis of the histograms */
430 //
f9641c3b 431 FILE *fileShuttle1 = fopen(ENCALIBDATA_FILE,"w");
f16f149b 432 //
433 Int_t BinMax[4];
434 Float_t YMax[4];
435 Int_t NBinsx[4];
436 Float_t MeanFitVal[4];
437 TF1 *fitfun[4];
438 for(Int_t k=0; k<4; k++){
f9641c3b 439 if(histoEMDCorr[k]->GetEntries() == 0){
440 printf("\n WARNING! Empty histos -> ending DA WITHOUT writing output\n\n");
441 return -1;
442 }
f16f149b 443 BinMax[k] = histoEMDCorr[k]->GetMaximumBin();
444 YMax[k] = (histoEMDCorr[k]->GetXaxis())->GetXmax();
445 NBinsx[k] = (histoEMDCorr[k]->GetXaxis())->GetNbins();
ea628de7 446// printf("\n\t Det%d -> BinMax = %d, ChXMax = %f\n", k+1, BinMax[k], BinMax[k]*YMax[k]/NBinsx[k]);
f16f149b 447 histoEMDCorr[k]->Fit("gaus","Q","",BinMax[k]*YMax[k]/NBinsx[k]*0.7,BinMax[k]*YMax[k]/NBinsx[k]*1.25);
448 fitfun[k] = histoEMDCorr[k]->GetFunction("gaus");
449 MeanFitVal[k] = (Float_t) (fitfun[k]->GetParameter(1));
c38bc7ef 450 //printf("\n\t Mean Value from gaussian fit = %f\n", MeanFitVal[k]);
f16f149b 451 }
452 //
218f916a 453 Float_t CalibCoeff[6];
e968a349 454 //Float_t icoeff[5];
218f916a 455 //
f9641c3b 456 for(Int_t j=0; j<6; j++){
218f916a 457 if(j<4){
458 CalibCoeff[j] = MeanFitVal[j];
f9641c3b 459 fprintf(fileShuttle1,"\t%f\n",CalibCoeff[j]);
218f916a 460 }
f9641c3b 461 // ZEM energy calib. coeff. = 1
218f916a 462 else if(j==4 || j==5){
463 CalibCoeff[j] = 1.;
f9641c3b 464 fprintf(fileShuttle1,"\t%f\n",CalibCoeff[j]);
218f916a 465 }
f9641c3b 466 }
467 fclose(fileShuttle1);
e968a349 468
f9641c3b 469 FILE *fileShuttle2 = fopen(TOWCALIBDATA_FILE,"w");
e968a349 470 Float_t meanvalznc[4], meanvalzpc[4], meanvalzna[4], meanvalzpa[4];
f9641c3b 471 for(Int_t j=0; j<4; j++){
e968a349 472 if(histZNCtow[j]->GetEntries() == 0){
473 printf("\n WARNING! Empty histos -> ending DA WITHOUT writing output\n\n");
474 return -1;
475 }
476 meanvalznc[j] = histZNCtow[j]->GetMean();
477 meanvalzpc[j] = histZPCtow[j]->GetMean();
478 meanvalzna[j] = histZNAtow[j]->GetMean();
479 meanvalzpa[j] = histZPAtow[j]->GetMean();
480
f9641c3b 481 // Note -> For the moment the inter-calibration coeff. are set to 1
e968a349 482 /*for(Int_t k=0; k<4; k++){
f9641c3b 483 icoeff[k] = 1.;
484 fprintf(fileShuttle2,"\t%f",icoeff[k]);
485 if(k==4) fprintf(fileShuttle2,"\n");
e968a349 486 }*/
487 }
488 if(meanvalznc[1]!=0 && meanvalznc[2]!=0 && meanvalznc[3]!=0 &&
489 meanvalzpc[1]!=0 && meanvalzpc[2]!=0 && meanvalzpc[3]!=0 &&
490 meanvalzna[1]!=0 && meanvalzna[2]!=0 && meanvalzna[3]!=0 &&
491 meanvalzpa[1]!=0 && meanvalzpa[2]!=0 && meanvalzpa[3]!=0){
492 fprintf(fileShuttle2,"\t%f\t%f\t%f\t%f\n",
493 1.0,meanvalznc[0]/meanvalznc[1],meanvalznc[0]/meanvalznc[2],meanvalznc[0]/meanvalznc[3]);
494 fprintf(fileShuttle2,"\t%f\t%f\t%f\t%f\n",
495 1.0,meanvalzpc[0]/meanvalzpc[1],meanvalzpc[0]/meanvalzpc[2],meanvalzpc[0]/meanvalzpc[3]);
496 fprintf(fileShuttle2,"\t%f\t%f\t%f\t%f\n",
497 1.0,meanvalzna[0]/meanvalzna[1],meanvalzpc[0]/meanvalzna[2],meanvalzpc[0]/meanvalzna[3]);
498 fprintf(fileShuttle2,"\t%f\t%f\t%f\t%f\n",
499 1.0,meanvalzpa[0]/meanvalzpa[1],meanvalzpc[0]/meanvalzpa[2],meanvalzpc[0]/meanvalzpa[3]);
500 }
501 else{
502 printf("\n Tower intercalib. coeff. CAN'T be calculated (some mean values are ZERO)!!!\n\n");
503 return -1;
f16f149b 504 }
f9641c3b 505 fclose(fileShuttle2);
f16f149b 506
442e1b18 507 for(Int_t ij=0; ij<4; ij++){
508 delete histoEMDRaw[ij];
509 delete histoEMDCorr[ij];
510 }
511
512 //delete minuitFit;
513 TVirtualFitter::SetFitter(0);
f16f149b 514
515 /* write report */
516 fprintf(fp,"Run #%s, received %d physics events out of %d\n",getenv("DATE_RUN_NUMBER"),nevents_physics,nevents_total);
517
518 /* close result file */
519 fclose(fp);
442e1b18 520
521 /* report progress */
522 daqDA_progressReport(90);
523
524 /* store the result file on FES */
a8eaff64 525 status = daqDA_FES_storeFile(MAPDATA_FILE, "MAPPING");
442e1b18 526 if(status){
527 printf("Failed to export file : %d\n",status);
528 return -1;
529 }
530 //
a8eaff64 531 status = daqDA_FES_storeFile(ENCALIBDATA_FILE, "EMDENERGYCALIB");
f9641c3b 532 if(status){
533 printf("Failed to export file : %d\n",status);
534 return -1;
535 }
536 //
a8eaff64 537 status = daqDA_FES_storeFile(TOWCALIBDATA_FILE, "EMDTOWERCALIB");
442e1b18 538 if(status){
539 printf("Failed to export file : %d\n",status);
540 return -1;
541 }
f16f149b 542
442e1b18 543 /* report progress */
544 daqDA_progressReport(100);
f16f149b 545
546 return status;
547}