]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/TPCCEda.cxx
Adding missing header file for altro mapping (Marian)
[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"
04049c81 31#define MAPPING_FILE "tpcMapping.root"
5a3a40fa 32
33
34#include <daqDA.h>
35#include "event.h"
36#include "monitor.h"
37#include <stdio.h>
38#include <stdlib.h>
39
40//
41//Root includes
42//
43#include <TFile.h>
44#include "TROOT.h"
45#include "TPluginManager.h"
46//
47//AliRoot includes
48//
49#include "AliRawReader.h"
50#include "AliRawReaderDate.h"
97b609ee 51#include "AliTPCmapper.h"
5a3a40fa 52#include "AliTPCRawStream.h"
53#include "AliTPCROC.h"
54#include "AliTPCCalROC.h"
55#include "AliTPCCalPad.h"
56#include "AliMathBase.h"
57#include "TTreeStream.h"
58
59//
60// TPC calibration algorithm includes
61//
62#include "AliTPCCalibCE.h"
63
64
65
66
67/* Main routine
68 Arguments: list of DATE raw data files
69*/
70int main(int argc, char **argv) {
71
72 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
73 "*",
74 "TStreamerInfo",
75 "RIO",
76 "TStreamerInfo()");
77
78
79 int i,status;
04049c81 80
81 /* copy locally the mapping file from daq detector config db */
82 status = daqDA_DB_getFile(MAPPING_FILE,"./tpcMapping.root");
83 if (status) {
84 printf("Failed to get mapping file (%s) from DAQdetDB, status=%d\n", MAPPING_FILE, status);
85 printf("Continue anyway ... maybe it works?\n"); // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
86 //return -1; // temporarily uncommented for testing on pcald47 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
87 }
88
89 /* open the mapping file and retrieve mapping object */
90 AliTPCmapper *mapping = 0; // The TPC mapping
91 TFile *fileMapping = new TFile(MAPPING_FILE, "read");
92 mapping = (AliTPCmapper*) fileMapping->Get("tpcMapping");
93 if (mapping == 0) {
94 printf("Failed to get mapping object from %s. Exiting ...\n", MAPPING_FILE);
95 delete fileMapping;
96 return -1;
97 } else {
98 printf("Got mapping object from %s\n", MAPPING_FILE);
99 }
100
101
5a3a40fa 102 AliTPCCalibCE calibCE; // pedestal and noise calibration
103
104 if (argc<2) {
105 printf("Wrong number of arguments\n");
106 return -1;
107 }
108
109
110 /* log start of process */
111 printf("TPC CE DA started - %s\n",__FILE__);
112
113
ca273e23 114 /* set time bin range */
115 calibCE.SetRangeTime(800,940);
04049c81 116 calibCE.SetAltroMapping(mapping->GetAltroMapping()); // Use altro mapping we got from daqDetDb
ca273e23 117
5a3a40fa 118 /* declare monitoring program */
119 status=monitorDeclareMp( __FILE__ );
120 if (status!=0) {
121 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
122 return -1;
123 }
124
125
126 /* loop over RAW data files */
127 int nevents=0;
128 for(i=1;i<argc;i++) {
129
130 /* define data source : this is argument i */
131 printf("Processing file %s\n", argv[i]);
132 status=monitorSetDataSource( argv[i] );
133 if (status!=0) {
134 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
135 return -1;
136 }
137
138 /* read until EOF */
139 while (true) {
140 struct eventHeaderStruct *event;
141
142 /* check shutdown condition */
143 if (daqDA_checkShutdown()) {break;}
144
145 /* get next event (blocking call until timeout) */
146 status=monitorGetEventDynamic((void **)&event);
147 if (status==MON_ERR_EOF) {
148 printf ("End of File %d detected\n",i);
149 break; /* end of monitoring file has been reached */
150 }
151
152 if (status!=0) {
153 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
154 break;
155 }
156
157 /* retry if got no event */
158 if (event==NULL) {
159 continue;
160 }
161 nevents++;
162
163 // Pulser calibration
164
165 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
166 calibCE.ProcessEvent(rawReader);
167 delete rawReader;
168
169 /* free resources */
170 free(event);
171 }
172 }
173
174 calibCE.Analyse();
175 printf ("%d events processed\n",nevents);
176
177 TFile * fileTPC = new TFile (RESULT_FILE,"recreate");
178 calibCE.Write("calibCE");
179 delete fileTPC;
180 printf("Wrote %s\n",RESULT_FILE);
181
f2c72763 182 /* store the result file on FES */
183
184 status=daqDA_FES_storeFile(RESULT_FILE,RESULT_FILE);
185 if (status) {
186 status = -2;
187 }
188
5a3a40fa 189 return status;
190}