]>
Commit | Line | Data |
---|---|---|
9c754ce7 | 1 | /* |
2 | TPC DA for online calibration | |
3 | ||
4 | Contact: Haavard.Helstrup@cern.ch | |
5 | Link: | |
6 | Run Type: PHYSICS_RUN STANDALONE DAQ | |
7 | DA Type: MON | |
8 | Number of events needed: 500 | |
9 | Input Files: | |
10 | Output Files: tpcCE.root, to be exported to the DAQ FXS | |
11 | Trigger types used: PHYSICS_EVENT | |
12 | ||
13 | */ | |
14 | ||
5a3a40fa | 15 | /* |
16 | ||
17 | TPCCEda.cxx - calibration algorithm for TPC Central Electrode events | |
18 | ||
19 | 10/06/2007 sylvain.chapeland@cern.ch : first version - clean skeleton based on DAQ DA case1 | |
20 | 06/12/2007 haavard.helstrup@cern.ch : created CE DA based on pulser code | |
21 | ||
22 | contact: marian.ivanov@cern.ch | |
23 | ||
24 | ||
25 | This process reads RAW data from the files provided as command line arguments | |
26 | and 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" | |
b401648b | 58 | #include "AliLog.h" |
59 | #include "TSystem.h" | |
5a3a40fa | 60 | |
61 | // | |
62 | // TPC calibration algorithm includes | |
63 | // | |
64 | #include "AliTPCCalibCE.h" | |
65 | ||
66 | ||
67 | ||
68 | ||
69 | /* Main routine | |
70 | Arguments: list of DATE raw data files | |
71 | */ | |
72 | int main(int argc, char **argv) { | |
73 | ||
74 | gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo", | |
75 | "*", | |
76 | "TStreamerInfo", | |
77 | "RIO", | |
78 | "TStreamerInfo()"); | |
79 | ||
b401648b | 80 | AliLog::SetClassDebugLevel("AliTPCRawStream",AliLog::kFatal); |
81 | AliLog::SetClassDebugLevel("AliRawReaderDate",AliLog::kFatal); | |
82 | AliLog::SetClassDebugLevel("AliTPCAltroMapping",AliLog::kFatal); | |
83 | AliLog::SetModuleDebugLevel("TPC",AliLog::kFatal); | |
84 | AliLog::SetModuleDebugLevel("RAW",AliLog::kFatal); | |
5a3a40fa | 85 | |
86 | int i,status; | |
b401648b | 87 | AliTPCmapper *mapping = 0; // The TPC mapping |
88 | // if test setup get parameters from $DAQDA_TEST_DIR | |
b401648b | 89 | |
90 | if (!mapping){ | |
91 | /* copy locally the mapping file from daq detector config db */ | |
92 | status = daqDA_DB_getFile(MAPPING_FILE,"./tpcMapping.root"); | |
93 | if (status) { | |
94 | printf("Failed to get mapping file (%s) from DAQdetDB, status=%d\n", MAPPING_FILE, status); | |
95 | printf("Continue anyway ... maybe it works?\n"); // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
96 | return -1; // temporarily uncommented for testing on pcald47 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
97 | } | |
98 | ||
99 | /* open the mapping file and retrieve mapping object */ | |
100 | TFile *fileMapping = new TFile(MAPPING_FILE, "read"); | |
101 | mapping = (AliTPCmapper*) fileMapping->Get("tpcMapping"); | |
102 | delete fileMapping; | |
04049c81 | 103 | } |
104 | ||
04049c81 | 105 | if (mapping == 0) { |
b401648b | 106 | printf("Failed to get mapping object from %s. ...\n", MAPPING_FILE); |
107 | //return -1; | |
04049c81 | 108 | } else { |
109 | printf("Got mapping object from %s\n", MAPPING_FILE); | |
110 | } | |
111 | ||
112 | ||
5a3a40fa | 113 | AliTPCCalibCE calibCE; // pedestal and noise calibration |
114 | ||
115 | if (argc<2) { | |
116 | printf("Wrong number of arguments\n"); | |
117 | return -1; | |
118 | } | |
119 | ||
120 | ||
121 | /* log start of process */ | |
122 | printf("TPC CE DA started - %s\n",__FILE__); | |
123 | ||
124 | ||
ca273e23 | 125 | /* set time bin range */ |
126 | calibCE.SetRangeTime(800,940); | |
04049c81 | 127 | calibCE.SetAltroMapping(mapping->GetAltroMapping()); // Use altro mapping we got from daqDetDb |
ca273e23 | 128 | |
5a3a40fa | 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); | |
177 | calibCE.ProcessEvent(rawReader); | |
178 | delete rawReader; | |
179 | ||
180 | /* free resources */ | |
181 | free(event); | |
182 | } | |
183 | } | |
184 | ||
185 | calibCE.Analyse(); | |
186 | printf ("%d events processed\n",nevents); | |
187 | ||
188 | TFile * fileTPC = new TFile (RESULT_FILE,"recreate"); | |
189 | calibCE.Write("calibCE"); | |
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 | ||
5a3a40fa | 200 | return status; |
201 | } |