]>
Commit | Line | Data |
---|---|---|
eb35e591 | 1 | /* |
2 | Contact: cvetan.cheshkov@cern.ch | |
bdffed96 | 3 | Link: http://alisoft.cern.ch/viewvc/trunk/ITS/ITSSPDVertexDiamondda.cxx?root=AliRoot&view=log , /afs/cern.ch/user/c/cheshkov/public/08000058338016.30.root.date.gz , /afs/cern.ch/user/c/cheshkov/public/ITS/VD_da_test.date |
6bf5b296 | 4 | Reference Run: 58338 |
eb35e591 | 5 | Run Type: PHYSICS |
6 | DA Type: MON | |
049f9cac | 7 | Number of events needed: 100 |
bdffed96 | 8 | Input Files: GRP/Geometry/Data , ITS/Align/Data , spd_noisy_ocdb , spd_dead_ocdb (all the files are taken from DQM OCDB snapshot) |
6bf5b296 | 9 | Output Files: SPDVertexDiamondDA.root |
bdffed96 | 10 | Trigger types used: All SPD F0 triggers |
eb35e591 | 11 | */ |
12 | ||
eb35e591 | 13 | #define OUTPUT_FILE "SPDVertexDiamondDA.root" |
eb35e591 | 14 | #define N_EVENTS_AUTOSAVE 50 |
eb35e591 | 15 | |
16 | extern "C" { | |
17 | #include "daqDA.h" | |
18 | } | |
19 | ||
20 | #include "event.h" | |
21 | #include "monitor.h" | |
22 | ||
55c5e86d | 23 | #ifdef ALI_AMORE |
24 | #include <AmoreDA.h> | |
308c2f7c | 25 | //int amore::da::Updated(char const*) {} |
55c5e86d | 26 | #endif |
27 | ||
eb35e591 | 28 | #include <TPluginManager.h> |
29 | #include <TROOT.h> | |
cf0b1cea | 30 | #include <TH1.h> |
31 | #include <TH2.h> | |
6bf5b296 | 32 | #include <TSystem.h> |
eb35e591 | 33 | |
e1f6be44 | 34 | #include "AliLog.h" |
eb35e591 | 35 | #include "AliRawReaderDate.h" |
eb35e591 | 36 | #include "AliCDBManager.h" |
cf0b1cea | 37 | #include "AliITSMeanVertexer.h" |
eb35e591 | 38 | |
39 | int main(int argc, char **argv) { | |
40 | ||
41 | gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo", | |
42 | "*", | |
43 | "TStreamerInfo", | |
44 | "RIO", | |
45 | "TStreamerInfo()"); | |
eb35e591 | 46 | |
47 | int status; | |
48 | if (argc<2) { | |
49 | printf("Wrong number of arguments\n"); | |
50 | return -1; | |
51 | } | |
52 | ||
53 | /* define data source : this is argument 1 */ | |
54 | status=monitorSetDataSource( argv[1] ); | |
55 | if (status!=0) { | |
56 | printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status)); | |
57 | return -1; | |
58 | } | |
59 | ||
60 | /* declare monitoring program */ | |
61 | status=monitorDeclareMp( __FILE__ ); | |
62 | if (status!=0) { | |
63 | printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status)); | |
64 | return -1; | |
65 | } | |
66 | ||
67 | /* define wait event timeout - 1s max */ | |
68 | monitorSetNowait(); | |
69 | monitorSetNoWaitNetworkTimeout(1000); | |
70 | ||
71 | /* log start of process */ | |
72 | printf("Vertex-Diamond SPD DA started\n"); | |
73 | ||
74 | /* init some counters */ | |
75 | int nevents_with_vertex = 0; | |
76 | int nevents_physics=0; | |
77 | int nevents_total=0; | |
78 | ||
79 | struct eventHeaderStruct *event; | |
80 | eventTypeType eventT; | |
81 | ||
82 | // Get run number | |
83 | if (getenv("DATE_RUN_NUMBER")==0) { | |
84 | printf("DATE_RUN_NUMBER not properly set.\n"); | |
85 | return -1; | |
86 | } | |
87 | int runNr = atoi(getenv("DATE_RUN_NUMBER")); | |
88 | ||
bdffed96 | 89 | /* |
6bf5b296 | 90 | // Get the necessary OCDB files from the DAQ detector DB |
91 | if (gSystem->AccessPathName("localOCDB/GRP/Geometry/Data",kFileExists)) { | |
92 | if (gSystem->mkdir("localOCDB/GRP/Geometry/Data",kTRUE) != 0) { | |
93 | printf("Failed to create directory: localOCDB/GRP/Geometry/Data"); | |
94 | return -1; | |
95 | } | |
96 | } | |
97 | status = daqDA_DB_getFile("GRP/Geometry/Data","localOCDB/GRP/Geometry/Data/Run0_999999999_v0_s0.root"); | |
98 | if (status) { | |
99 | printf("Failed to get geometry file (GRP/Geometry/Data) from DAQdetDB, status=%d\n", status); | |
100 | return -1; | |
101 | } | |
102 | ||
103 | if (gSystem->AccessPathName("localOCDB/ITS/Align/Data",kFileExists)) { | |
104 | if (gSystem->mkdir("localOCDB/ITS/Align/Data",kTRUE) != 0) { | |
105 | printf("Failed to create directory: localOCDB/ITS/Align/Data"); | |
106 | return -1; | |
107 | } | |
108 | } | |
109 | status = daqDA_DB_getFile("ITS/Align/Data","localOCDB/ITS/Align/Data/Run0_999999999_v0_s0.root"); | |
110 | if (status) { | |
111 | printf("Failed to get its-alignment file (ITS/Align/Data) from DAQdetDB, status=%d\n", status); | |
112 | return -1; | |
113 | } | |
114 | ||
115 | if (gSystem->AccessPathName("localOCDB/ITS/Calib/SPDNoisy",kFileExists)) { | |
116 | if (gSystem->mkdir("localOCDB/ITS/Calib/SPDNoisy",kTRUE) != 0) { | |
117 | printf("Failed to create directory: localOCDB/ITS/Calib/SPDNoisy"); | |
118 | return -1; | |
119 | } | |
120 | } | |
121 | status = daqDA_DB_getFile("spd_noisy_ocdb","localOCDB/ITS/Calib/SPDNoisy/Run0_999999999_v0_s0.root"); | |
122 | if (status) { | |
123 | printf("Failed to get spd file (spd_noisy_ocdb) from DAQdetDB, status=%d\n", status); | |
124 | return -1; | |
125 | } | |
126 | ||
127 | if (gSystem->AccessPathName("localOCDB/ITS/Calib/SPDDead",kFileExists)) { | |
128 | if (gSystem->mkdir("localOCDB/ITS/Calib/SPDDead",kTRUE) != 0) { | |
129 | printf("Failed to create directory: localOCDB/ITS/Calib/SPDDead"); | |
130 | return -1; | |
131 | } | |
132 | } | |
133 | status = daqDA_DB_getFile("spd_dead_ocdb","localOCDB/ITS/Calib/SPDDead/Run0_999999999_v0_s0.root"); | |
134 | if (status) { | |
135 | printf("Failed to get spd file (spd_dead_ocdb) from DAQdetDB, status=%d\n", status); | |
136 | return -1; | |
137 | } | |
138 | ||
bdffed96 | 139 | */ |
140 | ||
eb35e591 | 141 | // Global initializations |
e1f6be44 | 142 | AliLog::SetGlobalLogLevel(AliLog::kError); |
bdffed96 | 143 | if (gSystem->AccessPathName("/local/cdb",kFileExists)) { |
144 | printf("Local OCDB directory (/local/cdb) does not exist"); | |
145 | return -1; | |
146 | } | |
eb35e591 | 147 | AliCDBManager *man = AliCDBManager::Instance(); |
bdffed96 | 148 | man->SetDefaultStorage("local:///local/cdb"); |
eb35e591 | 149 | man->SetRun(runNr); |
eb35e591 | 150 | |
37add1d1 | 151 | // Init mean vertexer |
152 | AliITSMeanVertexer *mv = new AliITSMeanVertexer(); | |
153 | if (!mv->Init()) { | |
154 | printf("Initialization of mean vertexer object failed ! Check the log for details"); | |
155 | return -1; | |
156 | } | |
eb35e591 | 157 | |
55c5e86d | 158 | // Initialization of AMORE sender |
159 | #ifdef ALI_AMORE | |
160 | amore::da::AmoreDA vtxAmore(amore::da::AmoreDA::kSender); | |
161 | #endif | |
eb35e591 | 162 | /* main loop (infinite) */ |
163 | for(;;) { | |
164 | ||
165 | /* check shutdown condition */ | |
166 | if (daqDA_checkShutdown()) {break;} | |
167 | ||
168 | /* get next event (blocking call until timeout) */ | |
169 | status=monitorGetEventDynamic((void **)&event); | |
170 | if (status==MON_ERR_EOF) { | |
171 | printf ("End of File detected\n"); | |
172 | break; /* end of monitoring file has been reached */ | |
173 | } | |
174 | ||
175 | if (status!=0) { | |
176 | printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status)); | |
177 | break; | |
178 | } | |
179 | ||
180 | /* retry if got no event */ | |
181 | if (event==NULL) { | |
182 | continue; | |
183 | } | |
184 | ||
185 | nevents_total++; | |
186 | eventT=event->eventType; | |
187 | switch (event->eventType){ | |
188 | ||
189 | /* START OF RUN */ | |
190 | case START_OF_RUN: | |
191 | break; | |
192 | /* END START OF RUN */ | |
193 | ||
194 | /* END OF RUN */ | |
195 | case END_OF_RUN: | |
196 | break; | |
197 | ||
198 | case PHYSICS_EVENT: | |
199 | nevents_physics++; | |
200 | AliRawReader *rawReader = new AliRawReaderDate((void*)event); | |
201 | ||
37add1d1 | 202 | // Run mean-vertexer reco |
203 | if (mv->Reconstruct(rawReader)) nevents_with_vertex++; | |
eb35e591 | 204 | |
37add1d1 | 205 | // Auto save |
6bf5b296 | 206 | if ((nevents_physics%N_EVENTS_AUTOSAVE) == 0) { |
37add1d1 | 207 | mv->WriteVertices(OUTPUT_FILE); |
eb35e591 | 208 | |
6bf5b296 | 209 | #ifdef ALI_AMORE |
210 | // send the histos to AMORE pool | |
211 | printf("AMORE send status: %d\n",vtxAmore.Send(mv->GetVertexXY()->GetName(),mv->GetVertexXY())); | |
212 | printf("AMORE send status: %d\n",vtxAmore.Send(mv->GetVertexZ()->GetName(),mv->GetVertexZ())); | |
213 | #endif | |
214 | } | |
215 | ||
eb35e591 | 216 | delete rawReader; |
eb35e591 | 217 | } |
218 | ||
219 | /* free resources */ | |
220 | free(event); | |
221 | ||
222 | /* exit when last event received, no need to wait for TERM signal */ | |
223 | if (eventT==END_OF_RUN) { | |
224 | printf("EOR event detected\n"); | |
225 | break; | |
226 | } | |
227 | } | |
eb35e591 | 228 | |
37add1d1 | 229 | mv->WriteVertices(OUTPUT_FILE); |
eb35e591 | 230 | |
55c5e86d | 231 | #ifdef ALI_AMORE |
232 | // send the histos to AMORE pool | |
cf0b1cea | 233 | printf("AMORE send status: %d\n",vtxAmore.Send(mv->GetVertexXY()->GetName(),mv->GetVertexXY())); |
234 | printf("AMORE send status: %d\n",vtxAmore.Send(mv->GetVertexZ()->GetName(),mv->GetVertexZ())); | |
55c5e86d | 235 | #endif |
236 | ||
37add1d1 | 237 | delete mv; |
eb35e591 | 238 | |
239 | /* write report */ | |
240 | printf("Run #%s, received %d events with vertex, out of %d physics and out of %d total events\n",getenv("DATE_RUN_NUMBER"),nevents_with_vertex,nevents_physics,nevents_total); | |
241 | ||
242 | status=0; | |
243 | ||
244 | /* export file to FXS */ | |
245 | if (daqDA_FES_storeFile(OUTPUT_FILE, "VertexDiamond")) { | |
246 | status=-2; | |
247 | } | |
248 | ||
249 | return status; | |
250 | } |