]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/TPCCEda.cxx
Use symetric Mag field
[u/mrichter/AliRoot.git] / TPC / TPCCEda.cxx
CommitLineData
9c754ce7 1/*
2TPC DA for online calibration
3
4Contact: Haavard.Helstrup@cern.ch
5Link:
1b37fc95 6Run Type: PHYSICS STANDALONE DAQ
9c754ce7 7DA Type: MON
8Number of events needed: 500
9Input Files:
10Output Files: tpcCE.root, to be exported to the DAQ FXS
bd955ed2 11fileId: CE
9c754ce7 12Trigger types used: PHYSICS_EVENT
13
14*/
15
5a3a40fa 16/*
17
18TPCCEda.cxx - calibration algorithm for TPC Central Electrode events
19
2010/06/2007 sylvain.chapeland@cern.ch : first version - clean skeleton based on DAQ DA case1
2106/12/2007 haavard.helstrup@cern.ch : created CE DA based on pulser code
22
23contact: marian.ivanov@cern.ch
24
25
26This process reads RAW data from the files provided as command line arguments
27and save results in a file (named from RESULT_FILE define - see below).
28
29*/
30
9c754ce7 31#define RESULT_FILE "tpcCE.root"
bd955ed2 32#define FILE_ID "CE"
04049c81 33#define MAPPING_FILE "tpcMapping.root"
5a3a40fa 34
35
36#include <daqDA.h>
37#include "event.h"
38#include "monitor.h"
39#include <stdio.h>
40#include <stdlib.h>
41
42//
43//Root includes
44//
45#include <TFile.h>
46#include "TROOT.h"
47#include "TPluginManager.h"
48//
49//AliRoot includes
50//
51#include "AliRawReader.h"
52#include "AliRawReaderDate.h"
97b609ee 53#include "AliTPCmapper.h"
5a3a40fa 54#include "AliTPCRawStream.h"
55#include "AliTPCROC.h"
56#include "AliTPCCalROC.h"
57#include "AliTPCCalPad.h"
58#include "AliMathBase.h"
59#include "TTreeStream.h"
b401648b 60#include "AliLog.h"
61#include "TSystem.h"
5a3a40fa 62
63//
64// TPC calibration algorithm includes
65//
66#include "AliTPCCalibCE.h"
67
68
69
70
71/* Main routine
72 Arguments: list of DATE raw data files
73*/
74int main(int argc, char **argv) {
75
76 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
77 "*",
78 "TStreamerInfo",
79 "RIO",
80 "TStreamerInfo()");
81
bd955ed2 82 AliLog::SetClassDebugLevel("AliTPCRawStream",-5);
83 AliLog::SetClassDebugLevel("AliRawReaderDate",-5);
84 AliLog::SetClassDebugLevel("AliTPCAltroMapping",-5);
85 AliLog::SetModuleDebugLevel("RAW",-5);
5a3a40fa 86
87 int i,status;
b401648b 88 AliTPCmapper *mapping = 0; // The TPC mapping
89 // if test setup get parameters from $DAQDA_TEST_DIR
b401648b 90
91 if (!mapping){
92 /* copy locally the mapping file from daq detector config db */
93 status = daqDA_DB_getFile(MAPPING_FILE,"./tpcMapping.root");
94 if (status) {
95 printf("Failed to get mapping file (%s) from DAQdetDB, status=%d\n", MAPPING_FILE, status);
96 printf("Continue anyway ... maybe it works?\n"); // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
97 return -1; // temporarily uncommented for testing on pcald47 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
98 }
99
100 /* open the mapping file and retrieve mapping object */
101 TFile *fileMapping = new TFile(MAPPING_FILE, "read");
102 mapping = (AliTPCmapper*) fileMapping->Get("tpcMapping");
103 delete fileMapping;
04049c81 104 }
105
04049c81 106 if (mapping == 0) {
b401648b 107 printf("Failed to get mapping object from %s. ...\n", MAPPING_FILE);
108 //return -1;
04049c81 109 } else {
110 printf("Got mapping object from %s\n", MAPPING_FILE);
111 }
112
113
5a3a40fa 114 AliTPCCalibCE calibCE; // pedestal and noise calibration
115
116 if (argc<2) {
117 printf("Wrong number of arguments\n");
118 return -1;
119 }
120
121
122 /* log start of process */
123 printf("TPC CE DA started - %s\n",__FILE__);
124
125
ca273e23 126 /* set time bin range */
127 calibCE.SetRangeTime(800,940);
04049c81 128 calibCE.SetAltroMapping(mapping->GetAltroMapping()); // Use altro mapping we got from daqDetDb
ca273e23 129
5a3a40fa 130 /* declare monitoring program */
131 status=monitorDeclareMp( __FILE__ );
132 if (status!=0) {
133 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
134 return -1;
135 }
136
137
138 /* loop over RAW data files */
139 int nevents=0;
140 for(i=1;i<argc;i++) {
141
142 /* define data source : this is argument i */
143 printf("Processing file %s\n", argv[i]);
144 status=monitorSetDataSource( argv[i] );
145 if (status!=0) {
146 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
147 return -1;
148 }
149
150 /* read until EOF */
151 while (true) {
152 struct eventHeaderStruct *event;
153
154 /* check shutdown condition */
155 if (daqDA_checkShutdown()) {break;}
156
157 /* get next event (blocking call until timeout) */
158 status=monitorGetEventDynamic((void **)&event);
159 if (status==MON_ERR_EOF) {
160 printf ("End of File %d detected\n",i);
161 break; /* end of monitoring file has been reached */
162 }
163
164 if (status!=0) {
165 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
166 break;
167 }
168
169 /* retry if got no event */
170 if (event==NULL) {
171 continue;
172 }
173 nevents++;
174
175 // Pulser calibration
176
177 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
178 calibCE.ProcessEvent(rawReader);
179 delete rawReader;
180
181 /* free resources */
182 free(event);
183 }
184 }
185
186 calibCE.Analyse();
187 printf ("%d events processed\n",nevents);
188
189 TFile * fileTPC = new TFile (RESULT_FILE,"recreate");
e73181c9 190 calibCE.Write("tpcCalibCE");
5a3a40fa 191 delete fileTPC;
192 printf("Wrote %s\n",RESULT_FILE);
193
f2c72763 194 /* store the result file on FES */
195
bd955ed2 196 status=daqDA_FES_storeFile(RESULT_FILE,FILE_ID);
f2c72763 197 if (status) {
198 status = -2;
199 }
200
5a3a40fa 201 return status;
202}