]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/ITSSPDVertexDiamondda.cxx
fixed the tainted variables
[u/mrichter/AliRoot.git] / ITS / ITSSPDVertexDiamondda.cxx
CommitLineData
eb35e591 1/*
2Contact: cvetan.cheshkov@cern.ch
9141d382 3Link: http://alisoft.cern.ch/viewvc/trunk/ITS/ITSSPDVertexDiamondda.cxx?root=AliRoot&view=log , /afs/cern.ch/user/c/cheshkov/public/ITS/VD_da_test.date , /afs/cern.ch/user/c/cheshkov/public/08000058338016.30.root.date.gz
6bf5b296 4Reference Run: 58338
eb35e591 5Run Type: PHYSICS
6DA Type: MON
049f9cac 7Number of events needed: 100
9141d382 8Input Files: GRP/Geometry/Data , ITS/Align/Data , spd_noisy_ocdb , spd_dead_ocdb , TRIGGER/SPD/PITConditions (all the files are taken from SPD daqDetDB)
6bf5b296 9Output Files: SPDVertexDiamondDA.root
9141d382 10Trigger types used: PHYSICS, SPD-F0
eb35e591 11*/
12
eb35e591 13#define OUTPUT_FILE "SPDVertexDiamondDA.root"
eb35e591 14#define N_EVENTS_AUTOSAVE 50
eb35e591 15
16extern "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
39int 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
6bf5b296 89 // Get the necessary OCDB files from the DAQ detector DB
90 if (gSystem->AccessPathName("localOCDB/GRP/Geometry/Data",kFileExists)) {
91 if (gSystem->mkdir("localOCDB/GRP/Geometry/Data",kTRUE) != 0) {
92 printf("Failed to create directory: localOCDB/GRP/Geometry/Data");
93 return -1;
94 }
95 }
96 status = daqDA_DB_getFile("GRP/Geometry/Data","localOCDB/GRP/Geometry/Data/Run0_999999999_v0_s0.root");
97 if (status) {
98 printf("Failed to get geometry file (GRP/Geometry/Data) from DAQdetDB, status=%d\n", status);
99 return -1;
100 }
101
102 if (gSystem->AccessPathName("localOCDB/ITS/Align/Data",kFileExists)) {
103 if (gSystem->mkdir("localOCDB/ITS/Align/Data",kTRUE) != 0) {
104 printf("Failed to create directory: localOCDB/ITS/Align/Data");
105 return -1;
106 }
107 }
108 status = daqDA_DB_getFile("ITS/Align/Data","localOCDB/ITS/Align/Data/Run0_999999999_v0_s0.root");
109 if (status) {
110 printf("Failed to get its-alignment file (ITS/Align/Data) from DAQdetDB, status=%d\n", status);
111 return -1;
112 }
113
114 if (gSystem->AccessPathName("localOCDB/ITS/Calib/SPDNoisy",kFileExists)) {
115 if (gSystem->mkdir("localOCDB/ITS/Calib/SPDNoisy",kTRUE) != 0) {
116 printf("Failed to create directory: localOCDB/ITS/Calib/SPDNoisy");
117 return -1;
118 }
119 }
120 status = daqDA_DB_getFile("spd_noisy_ocdb","localOCDB/ITS/Calib/SPDNoisy/Run0_999999999_v0_s0.root");
121 if (status) {
122 printf("Failed to get spd file (spd_noisy_ocdb) from DAQdetDB, status=%d\n", status);
123 return -1;
124 }
125
126 if (gSystem->AccessPathName("localOCDB/ITS/Calib/SPDDead",kFileExists)) {
127 if (gSystem->mkdir("localOCDB/ITS/Calib/SPDDead",kTRUE) != 0) {
128 printf("Failed to create directory: localOCDB/ITS/Calib/SPDDead");
129 return -1;
130 }
131 }
132 status = daqDA_DB_getFile("spd_dead_ocdb","localOCDB/ITS/Calib/SPDDead/Run0_999999999_v0_s0.root");
133 if (status) {
134 printf("Failed to get spd file (spd_dead_ocdb) from DAQdetDB, status=%d\n", status);
135 return -1;
136 }
137
9141d382 138 if (gSystem->AccessPathName("localOCDB/TRIGGER/SPD/PITConditions",kFileExists)) {
139 if (gSystem->mkdir("localOCDB/TRIGGER/SPD/PITConditions",kTRUE) != 0) {
140 printf("Failed to create directory: localOCDB/TRIGGER/SPD/PITConditions");
141 return -1;
142 }
143 }
144 status = daqDA_DB_getFile("TRIGGER/SPD/PITConditions","localOCDB/TRIGGER/SPD/PITConditions/Run0_999999999_v0_s0.root");
145 if (status) {
146 printf("Failed to get spd trigger file (TRIGGER/SPD/PITConditions) from DAQdetDB, status=%d\n", status);
147 return -1;
148 }
bdffed96 149
eb35e591 150 // Global initializations
e1f6be44 151 AliLog::SetGlobalLogLevel(AliLog::kError);
eb35e591 152 AliCDBManager *man = AliCDBManager::Instance();
9141d382 153 man->SetDefaultStorage("local://localOCDB");
eb35e591 154 man->SetRun(runNr);
eb35e591 155
37add1d1 156 // Init mean vertexer
157 AliITSMeanVertexer *mv = new AliITSMeanVertexer();
158 if (!mv->Init()) {
159 printf("Initialization of mean vertexer object failed ! Check the log for details");
160 return -1;
161 }
eb35e591 162
55c5e86d 163 // Initialization of AMORE sender
164#ifdef ALI_AMORE
165 amore::da::AmoreDA vtxAmore(amore::da::AmoreDA::kSender);
166#endif
eb35e591 167 /* main loop (infinite) */
168 for(;;) {
169
170 /* check shutdown condition */
171 if (daqDA_checkShutdown()) {break;}
172
173 /* get next event (blocking call until timeout) */
174 status=monitorGetEventDynamic((void **)&event);
175 if (status==MON_ERR_EOF) {
176 printf ("End of File detected\n");
177 break; /* end of monitoring file has been reached */
178 }
179
180 if (status!=0) {
181 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
182 break;
183 }
184
185 /* retry if got no event */
186 if (event==NULL) {
187 continue;
188 }
189
190 nevents_total++;
191 eventT=event->eventType;
192 switch (event->eventType){
193
194 /* START OF RUN */
195 case START_OF_RUN:
196 break;
197 /* END START OF RUN */
198
199 /* END OF RUN */
200 case END_OF_RUN:
201 break;
202
203 case PHYSICS_EVENT:
204 nevents_physics++;
205 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
206
37add1d1 207 // Run mean-vertexer reco
208 if (mv->Reconstruct(rawReader)) nevents_with_vertex++;
eb35e591 209
37add1d1 210 // Auto save
6bf5b296 211 if ((nevents_physics%N_EVENTS_AUTOSAVE) == 0) {
37add1d1 212 mv->WriteVertices(OUTPUT_FILE);
eb35e591 213
6bf5b296 214#ifdef ALI_AMORE
215 // send the histos to AMORE pool
216 printf("AMORE send status: %d\n",vtxAmore.Send(mv->GetVertexXY()->GetName(),mv->GetVertexXY()));
217 printf("AMORE send status: %d\n",vtxAmore.Send(mv->GetVertexZ()->GetName(),mv->GetVertexZ()));
218#endif
219 }
220
eb35e591 221 delete rawReader;
eb35e591 222 }
223
224 /* free resources */
225 free(event);
226
227 /* exit when last event received, no need to wait for TERM signal */
228 if (eventT==END_OF_RUN) {
229 printf("EOR event detected\n");
230 break;
231 }
232 }
eb35e591 233
37add1d1 234 mv->WriteVertices(OUTPUT_FILE);
eb35e591 235
55c5e86d 236#ifdef ALI_AMORE
237 // send the histos to AMORE pool
cf0b1cea 238 printf("AMORE send status: %d\n",vtxAmore.Send(mv->GetVertexXY()->GetName(),mv->GetVertexXY()));
239 printf("AMORE send status: %d\n",vtxAmore.Send(mv->GetVertexZ()->GetName(),mv->GetVertexZ()));
55c5e86d 240#endif
241
37add1d1 242 delete mv;
eb35e591 243
244 /* write report */
245 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);
246
247 status=0;
248
249 /* export file to FXS */
250 if (daqDA_FES_storeFile(OUTPUT_FILE, "VertexDiamond")) {
251 status=-2;
252 }
253
254 return status;
255}