]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/TPCPEDESTALda.cxx
New method to get the ratio between the expected and actual cluster shape. Will be...
[u/mrichter/AliRoot.git] / TPC / TPCPEDESTALda.cxx
CommitLineData
c12208b8 1/*
2
3TPCda_pedestal.cxx - calibration algorithm for TPC pedestal runs
4
510/06/2007 sylvain.chapeland@cern.ch : first version - clean skeleton based on DAQ DA case1
6
7contact: marian.ivanov@cern.ch
8
9
10This process reads RAW data from the files provided as command line arguments
11and save results in a file (named from RESULT_FILE define - see below).
12
13*/
14
15#define RESULT_FILE "tpcPedestal.root"
16
17
18extern "C" {
19#include <daqDA.h>
20}
21#include "event.h"
22#include "monitor.h"
23#include <stdio.h>
24#include <stdlib.h>
25
26//
27//Root includes
28//
29#include <TFile.h>
30
31//
32//AliRoot includes
33//
34#include "AliRawReader.h"
35#include "AliRawReaderDate.h"
36#include "AliTPCRawStream.h"
37#include "AliTPCROC.h"
38#include "AliTPCCalROC.h"
39#include "AliTPCCalPad.h"
40#include "AliMathBase.h"
41#include "TTreeStream.h"
42
43//
44// TPC calibration algorithm includes
45//
46#include "AliTPCCalibPedestal.h"
47
48
49
50
51/* Main routine
52 Arguments: list of DATE raw data files
53*/
54int main(int argc, char **argv) {
55
56 int i,status;
57 AliTPCCalibPedestal calibPedestal; // pedestal and noise calibration
58
59 if (argc<2) {
60 printf("Wrong number of arguments\n");
61 return -1;
62 }
63
64
65 /* log start of process */
66 printf("TPC DA started - %s\n",__FILE__);
67
68
69 /* declare monitoring program */
70 status=monitorDeclareMp( __FILE__ );
71 if (status!=0) {
72 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
73 return -1;
74 }
75
76
77 /* loop over RAW data files */
78 int nevents=0;
79 for(i=1;i<argc;i++) {
80
81 /* define data source : this is argument i */
82 printf("Processing file %s\n", argv[i]);
83 status=monitorSetDataSource( argv[i] );
84 if (status!=0) {
85 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
86 return -1;
87 }
88
89 /* read until EOF */
90 for(;;) {
91 struct eventHeaderStruct *event;
92
93 /* check shutdown condition */
94 if (daqDA_checkShutdown()) {break;}
95
96 /* get next event (blocking call until timeout) */
97 status=monitorGetEventDynamic((void **)&event);
98 if (status==MON_ERR_EOF) {
99 printf ("End of File %d detected\n",i);
100 break; /* end of monitoring file has been reached */
101 }
102
103 if (status!=0) {
104 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
105 break;
106 }
107
108 /* retry if got no event */
109 if (event==NULL) {
110 continue;
111 }
112 nevents++;
113
114 // Pedestal calibration
115 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
116 calibPedestal.ProcessEvent(rawReader);
117 delete rawReader;
118
119 /* free resources */
120 free(event);
121 }
122 }
123
124 calibPedestal.Analyse();
125 printf ("%d events processed\n",nevents);
126
127 TFile * fileTPC = new TFile (RESULT_FILE,"recreate");
128 calibPedestal.Write("calibPedestal");
129 delete fileTPC;
130 printf("Wrote %s\n",RESULT_FILE);
131
132 return status;
133}