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