]>
Commit | Line | Data |
---|---|---|
eb35e591 | 1 | /* |
2 | Contact: cvetan.cheshkov@cern.ch | |
3 | Link: missing | |
4 | Run Type: PHYSICS | |
5 | DA Type: MON | |
6 | Number of events needed: 10000 | |
7 | Input Files: | |
8 | Output Files: | |
9 | Trigger types used: PHYSICS | |
10 | */ | |
11 | ||
eb35e591 | 12 | #define OUTPUT_FILE "SPDVertexDiamondDA.root" |
13 | #define CDB_STORAGE "local://$ALICE_ROOT" | |
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> | |
eb35e591 | 32 | |
33 | #include "AliRawReaderDate.h" | |
eb35e591 | 34 | #include "AliCDBManager.h" |
cf0b1cea | 35 | #include "AliITSMeanVertexer.h" |
eb35e591 | 36 | |
37 | int main(int argc, char **argv) { | |
38 | ||
39 | gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo", | |
40 | "*", | |
41 | "TStreamerInfo", | |
42 | "RIO", | |
43 | "TStreamerInfo()"); | |
eb35e591 | 44 | |
45 | int status; | |
46 | if (argc<2) { | |
47 | printf("Wrong number of arguments\n"); | |
48 | return -1; | |
49 | } | |
50 | ||
51 | /* define data source : this is argument 1 */ | |
52 | status=monitorSetDataSource( argv[1] ); | |
53 | if (status!=0) { | |
54 | printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status)); | |
55 | return -1; | |
56 | } | |
57 | ||
58 | /* declare monitoring program */ | |
59 | status=monitorDeclareMp( __FILE__ ); | |
60 | if (status!=0) { | |
61 | printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status)); | |
62 | return -1; | |
63 | } | |
64 | ||
65 | /* define wait event timeout - 1s max */ | |
66 | monitorSetNowait(); | |
67 | monitorSetNoWaitNetworkTimeout(1000); | |
68 | ||
69 | /* log start of process */ | |
70 | printf("Vertex-Diamond SPD DA started\n"); | |
71 | ||
72 | /* init some counters */ | |
73 | int nevents_with_vertex = 0; | |
74 | int nevents_physics=0; | |
75 | int nevents_total=0; | |
76 | ||
77 | struct eventHeaderStruct *event; | |
78 | eventTypeType eventT; | |
79 | ||
80 | // Get run number | |
81 | if (getenv("DATE_RUN_NUMBER")==0) { | |
82 | printf("DATE_RUN_NUMBER not properly set.\n"); | |
83 | return -1; | |
84 | } | |
85 | int runNr = atoi(getenv("DATE_RUN_NUMBER")); | |
86 | ||
eb35e591 | 87 | // Global initializations |
88 | AliCDBManager *man = AliCDBManager::Instance(); | |
89 | man->SetDefaultStorage(CDB_STORAGE); | |
90 | man->SetRun(runNr); | |
eb35e591 | 91 | |
37add1d1 | 92 | // Init mean vertexer |
93 | AliITSMeanVertexer *mv = new AliITSMeanVertexer(); | |
94 | if (!mv->Init()) { | |
95 | printf("Initialization of mean vertexer object failed ! Check the log for details"); | |
96 | return -1; | |
97 | } | |
eb35e591 | 98 | |
55c5e86d | 99 | // Initialization of AMORE sender |
100 | #ifdef ALI_AMORE | |
101 | amore::da::AmoreDA vtxAmore(amore::da::AmoreDA::kSender); | |
102 | #endif | |
eb35e591 | 103 | /* main loop (infinite) */ |
104 | for(;;) { | |
105 | ||
106 | /* check shutdown condition */ | |
107 | if (daqDA_checkShutdown()) {break;} | |
108 | ||
109 | /* get next event (blocking call until timeout) */ | |
110 | status=monitorGetEventDynamic((void **)&event); | |
111 | if (status==MON_ERR_EOF) { | |
112 | printf ("End of File detected\n"); | |
113 | break; /* end of monitoring file has been reached */ | |
114 | } | |
115 | ||
116 | if (status!=0) { | |
117 | printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status)); | |
118 | break; | |
119 | } | |
120 | ||
121 | /* retry if got no event */ | |
122 | if (event==NULL) { | |
123 | continue; | |
124 | } | |
125 | ||
126 | nevents_total++; | |
127 | eventT=event->eventType; | |
128 | switch (event->eventType){ | |
129 | ||
130 | /* START OF RUN */ | |
131 | case START_OF_RUN: | |
132 | break; | |
133 | /* END START OF RUN */ | |
134 | ||
135 | /* END OF RUN */ | |
136 | case END_OF_RUN: | |
137 | break; | |
138 | ||
139 | case PHYSICS_EVENT: | |
140 | nevents_physics++; | |
141 | AliRawReader *rawReader = new AliRawReaderDate((void*)event); | |
142 | ||
37add1d1 | 143 | // Run mean-vertexer reco |
144 | if (mv->Reconstruct(rawReader)) nevents_with_vertex++; | |
eb35e591 | 145 | |
37add1d1 | 146 | // Auto save |
147 | if ((nevents_physics%N_EVENTS_AUTOSAVE) == 0) | |
148 | mv->WriteVertices(OUTPUT_FILE); | |
eb35e591 | 149 | |
eb35e591 | 150 | delete rawReader; |
eb35e591 | 151 | } |
152 | ||
153 | /* free resources */ | |
154 | free(event); | |
155 | ||
156 | /* exit when last event received, no need to wait for TERM signal */ | |
157 | if (eventT==END_OF_RUN) { | |
158 | printf("EOR event detected\n"); | |
159 | break; | |
160 | } | |
161 | } | |
eb35e591 | 162 | |
37add1d1 | 163 | mv->WriteVertices(OUTPUT_FILE); |
eb35e591 | 164 | |
55c5e86d | 165 | #ifdef ALI_AMORE |
166 | // send the histos to AMORE pool | |
cf0b1cea | 167 | printf("AMORE send status: %d\n",vtxAmore.Send(mv->GetVertexXY()->GetName(),mv->GetVertexXY())); |
168 | printf("AMORE send status: %d\n",vtxAmore.Send(mv->GetVertexZ()->GetName(),mv->GetVertexZ())); | |
55c5e86d | 169 | #endif |
170 | ||
37add1d1 | 171 | delete mv; |
eb35e591 | 172 | |
173 | /* write report */ | |
174 | 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); | |
175 | ||
176 | status=0; | |
177 | ||
178 | /* export file to FXS */ | |
179 | if (daqDA_FES_storeFile(OUTPUT_FILE, "VertexDiamond")) { | |
180 | status=-2; | |
181 | } | |
182 | ||
183 | return status; | |
184 | } |