]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/TPCPULSERda.cxx
Add macro for pedestal calibration (Jens)
[u/mrichter/AliRoot.git] / TPC / TPCPULSERda.cxx
CommitLineData
9c754ce7 1/*
2TPC DA for online calibration
3
4Contact: Haavard.Helstrup@cern.ch
5Link:
6Run Type: PULSER_RUN
7DA Type: LDC
8Number of events needed: 100
9Input Files:
10Output Files: tpcPulser.root, to be exported to the DAQ FXS
11Trigger types used: CALIBRATION_EVENT
12
13*/
14
ec2624ea 15/*
16
17TPCda_pulser.cxx - calibration algorithm for TPC pulser events
18
1910/06/2007 sylvain.chapeland@cern.ch : first version - clean skeleton based on DAQ DA case1
2030/09/2007 haavard.helstrup@cern.ch : created pulser DA based on pedestal 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
30#define RESULT_FILE "tpcPulser.root"
04049c81 31#define MAPPING_FILE "tpcMapping.root"
b401648b 32#define AliDebugLevel() -1
ec2624ea 33
34
35#include <daqDA.h>
36#include "event.h"
37#include "monitor.h"
38#include <stdio.h>
39#include <stdlib.h>
40
41//
42//Root includes
43//
44#include <TFile.h>
45#include "TROOT.h"
46#include "TPluginManager.h"
47//
48//AliRoot includes
49//
50#include "AliRawReader.h"
51#include "AliRawReaderDate.h"
97b609ee 52#include "AliTPCmapper.h"
ec2624ea 53#include "AliTPCRawStream.h"
54#include "AliTPCROC.h"
55#include "AliTPCCalROC.h"
56#include "AliTPCCalPad.h"
57#include "AliMathBase.h"
58#include "TTreeStream.h"
b401648b 59#include "AliLog.h"
60#include "TSystem.h"
ec2624ea 61
62//
63// TPC calibration algorithm includes
64//
65#include "AliTPCCalibPulser.h"
66
67
68
69
70/* Main routine
71 Arguments: list of DATE raw data files
72*/
73int main(int argc, char **argv) {
b401648b 74 AliLog::SetClassDebugLevel("AliTPCRawStream",AliLog::kFatal);
75 AliLog::SetClassDebugLevel("AliRawReaderDate",AliLog::kFatal);
76 AliLog::SetClassDebugLevel("AliTPCAltroMapping",AliLog::kFatal);
77 AliLog::SetModuleDebugLevel("TPC",AliLog::kFatal);
78 AliLog::SetModuleDebugLevel("RAW",AliLog::kFatal);
ec2624ea 79
80 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
81 "*",
82 "TStreamerInfo",
83 "RIO",
84 "TStreamerInfo()");
85
86
87 int i,status;
b401648b 88 AliTPCmapper *mapping = 0; // The TPC mapping
89 // if test setup get parameters from $DAQDA_TEST_DIR
5d694e7e 90
b401648b 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
ec2624ea 114 AliTPCCalibPulser calibPulser; // 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 Pulser DA started - %s\n",__FILE__);
124
ca273e23 125 /* set time bin range */
86dd6fa4 126 calibPulser.SetRangeTime(400,500);
04049c81 127 calibPulser.SetAltroMapping(mapping->GetAltroMapping()); // Use altro mapping we got from daqDetDb
ec2624ea 128 /* declare monitoring program */
129 status=monitorDeclareMp( __FILE__ );
130 if (status!=0) {
131 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
132 return -1;
133 }
134
135
136 /* loop over RAW data files */
137 int nevents=0;
138 for(i=1;i<argc;i++) {
139
140 /* define data source : this is argument i */
141 printf("Processing file %s\n", argv[i]);
142 status=monitorSetDataSource( argv[i] );
143 if (status!=0) {
144 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
145 return -1;
146 }
147
148 /* read until EOF */
149 while (true) {
150 struct eventHeaderStruct *event;
151
152 /* check shutdown condition */
153 if (daqDA_checkShutdown()) {break;}
154
155 /* get next event (blocking call until timeout) */
156 status=monitorGetEventDynamic((void **)&event);
157 if (status==MON_ERR_EOF) {
158 printf ("End of File %d detected\n",i);
159 break; /* end of monitoring file has been reached */
160 }
161
162 if (status!=0) {
163 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
164 break;
165 }
166
167 /* retry if got no event */
168 if (event==NULL) {
169 continue;
170 }
171 nevents++;
172
173 // Pulser calibration
174
175 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
86dd6fa4 176// calibPulser.ProcessEvent(rawReader);
177 calibPulser.ProcessEventFast(rawReader);
ec2624ea 178 delete rawReader;
179
180 /* free resources */
181 free(event);
182 }
183 }
184
185 calibPulser.Analyse();
186 printf ("%d events processed\n",nevents);
187
188 TFile * fileTPC = new TFile (RESULT_FILE,"recreate");
189 calibPulser.Write("calibPulser");
190 delete fileTPC;
191 printf("Wrote %s\n",RESULT_FILE);
192
f2c72763 193 /* store the result file on FES */
194
195 status=daqDA_FES_storeFile(RESULT_FILE,RESULT_FILE);
196 if (status) {
197 status = -2;
198 }
199
ec2624ea 200 return status;
201}