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