]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/TPCCEda.cxx
By default all the sectors should be active
[u/mrichter/AliRoot.git] / TPC / TPCCEda.cxx
CommitLineData
9c754ce7 1/*
2TPC DA for online calibration
3
4Contact: Haavard.Helstrup@cern.ch
5Link:
6Run Type: PHYSICS_RUN STANDALONE DAQ
7DA Type: MON
8Number of events needed: 500
9Input Files:
10Output Files: tpcCE.root, to be exported to the DAQ FXS
11Trigger types used: PHYSICS_EVENT
12
13*/
14
5a3a40fa 15/*
16
17TPCCEda.cxx - calibration algorithm for TPC Central Electrode events
18
1910/06/2007 sylvain.chapeland@cern.ch : first version - clean skeleton based on DAQ DA case1
2006/12/2007 haavard.helstrup@cern.ch : created CE DA based on pulser code
21
22contact: marian.ivanov@cern.ch
23
24
25This process reads RAW data from the files provided as command line arguments
26and save results in a file (named from RESULT_FILE define - see below).
27
28*/
29
9c754ce7 30#define RESULT_FILE "tpcCE.root"
5a3a40fa 31
32
33#include <daqDA.h>
34#include "event.h"
35#include "monitor.h"
36#include <stdio.h>
37#include <stdlib.h>
38
39//
40//Root includes
41//
42#include <TFile.h>
43#include "TROOT.h"
44#include "TPluginManager.h"
45//
46//AliRoot includes
47//
48#include "AliRawReader.h"
49#include "AliRawReaderDate.h"
50#include "AliTPCRawStream.h"
51#include "AliTPCROC.h"
52#include "AliTPCCalROC.h"
53#include "AliTPCCalPad.h"
54#include "AliMathBase.h"
55#include "TTreeStream.h"
56
57//
58// TPC calibration algorithm includes
59//
60#include "AliTPCCalibCE.h"
61
62
63
64
65/* Main routine
66 Arguments: list of DATE raw data files
67*/
68int main(int argc, char **argv) {
69
70 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
71 "*",
72 "TStreamerInfo",
73 "RIO",
74 "TStreamerInfo()");
75
76
77 int i,status;
78 AliTPCCalibCE calibCE; // pedestal and noise calibration
79
80 if (argc<2) {
81 printf("Wrong number of arguments\n");
82 return -1;
83 }
84
85
86 /* log start of process */
87 printf("TPC CE DA started - %s\n",__FILE__);
88
89
90 /* declare monitoring program */
91 status=monitorDeclareMp( __FILE__ );
92 if (status!=0) {
93 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
94 return -1;
95 }
96
97
98 /* loop over RAW data files */
99 int nevents=0;
100 for(i=1;i<argc;i++) {
101
102 /* define data source : this is argument i */
103 printf("Processing file %s\n", argv[i]);
104 status=monitorSetDataSource( argv[i] );
105 if (status!=0) {
106 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
107 return -1;
108 }
109
110 /* read until EOF */
111 while (true) {
112 struct eventHeaderStruct *event;
113
114 /* check shutdown condition */
115 if (daqDA_checkShutdown()) {break;}
116
117 /* get next event (blocking call until timeout) */
118 status=monitorGetEventDynamic((void **)&event);
119 if (status==MON_ERR_EOF) {
120 printf ("End of File %d detected\n",i);
121 break; /* end of monitoring file has been reached */
122 }
123
124 if (status!=0) {
125 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
126 break;
127 }
128
129 /* retry if got no event */
130 if (event==NULL) {
131 continue;
132 }
133 nevents++;
134
135 // Pulser calibration
136
137 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
138 calibCE.ProcessEvent(rawReader);
139 delete rawReader;
140
141 /* free resources */
142 free(event);
143 }
144 }
145
146 calibCE.Analyse();
147 printf ("%d events processed\n",nevents);
148
149 TFile * fileTPC = new TFile (RESULT_FILE,"recreate");
150 calibCE.Write("calibCE");
151 delete fileTPC;
152 printf("Wrote %s\n",RESULT_FILE);
153
154 return status;
155}