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