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