]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | ||
3 | FMD DA for online calibration of conditions | |
4 | ||
5 | Contact: canute@nbi.dk | |
6 | Link: fmd.nbi.dk/fmd/offline | |
7 | Run Type: PHYSICS | |
8 | DA Type: MON | |
9 | Number of events needed: depending on the run, being run-level | |
10 | Input Files: raw data | |
11 | Output Files: conditions.csv | |
12 | Trigger types used: PHYSICS_EVENT | |
13 | */ | |
14 | #include <cstdlib> | |
15 | #include <Riostream.h> | |
16 | #include "monitor.h" | |
17 | #include "event.h" | |
18 | #include <AliLog.h> | |
19 | #include <TSystem.h> | |
20 | #include <TString.h> | |
21 | #include <AliFMDParameters.h> | |
22 | #include <AliRawReader.h> | |
23 | #include <TStopwatch.h> | |
24 | #include <AliFMDBaseDA.h> | |
25 | #include <AliRawReaderDate.h> | |
26 | #include <AliRawReaderRoot.h> | |
27 | #include "daqDA.h" | |
28 | #include "TROOT.h" | |
29 | #include "TPluginManager.h" | |
30 | ||
31 | void | |
32 | usage(std::ostream& o, const char* progname) | |
33 | { | |
34 | o << "Usage: " << progname << " FILE [OPTIONS]\n\n" | |
35 | << "Options:\n" | |
36 | << "\t-h,--help Show this help\n" | |
37 | << "\t-d,--diagnostics Create diagnostics\n" | |
38 | << "\t-D,--debug LEVEL Set the debug level\n" | |
39 | << std::endl; | |
40 | } | |
41 | ||
42 | int main(int argc, char **argv) | |
43 | { | |
44 | ||
45 | #if 0 | |
46 | /* magic line from Rene - for future reference! */ | |
47 | gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo", | |
48 | "*", | |
49 | "TStreamerInfo", | |
50 | "RIO", | |
51 | "TStreamerInfo()"); | |
52 | #endif | |
53 | ||
54 | ||
55 | const Char_t* tableSOD[] = {"ALL", "no", "SOD", "all", NULL, NULL}; | |
56 | ||
57 | Bool_t old = kTRUE; | |
58 | monitorDeclareTable(const_cast<char**>(tableSOD)); | |
59 | ||
60 | AliFMDParameters::Instance()->Init(kFALSE,0); | |
61 | AliFMDParameters::Instance()->UseCompleteHeader(old); | |
62 | struct eventHeaderStruct *event; | |
63 | int status; | |
64 | ||
65 | Int_t debugLevel = 0; | |
66 | Bool_t badOption = false; | |
67 | char* source = 0; | |
68 | for (int i = 1; i < argc; i++) { | |
69 | if (argv[i][0] == '-') { // Options | |
70 | if (argv[i][1] == '-') { // Long option | |
71 | TString arg(&(argv[i][2])); | |
72 | if (arg.EqualTo("help")) { usage(std::cout, argv[0]); return 0; } | |
73 | if (arg.EqualTo("diagnostics")) { } | |
74 | else if (arg.EqualTo("debug")) debugLevel = atoi(argv[++i]); | |
75 | else badOption = true; | |
76 | } | |
77 | else { // Short option | |
78 | switch (argv[i][1]) { | |
79 | case 'h': usage(std::cout, argv[0]); return 0; | |
80 | case 'd': break; | |
81 | case 'D': debugLevel = atoi(argv[++i]); break; | |
82 | default: badOption = true; | |
83 | } | |
84 | } | |
85 | if (badOption) { | |
86 | std::cerr << argv[0] << ": Unknown option " << argv[i] | |
87 | << std::endl; | |
88 | return 1; | |
89 | } | |
90 | } | |
91 | else { | |
92 | if (!source) source = argv[i]; | |
93 | else debugLevel = atoi(argv[i]); | |
94 | } | |
95 | } | |
96 | if (!source) { | |
97 | printf("%s: No data source specified\n", argv[0]); | |
98 | return -1; | |
99 | } | |
100 | status=monitorSetDataSource(source); | |
101 | if (status!=0) { | |
102 | printf("monitorSetDataSource() failed for %s: %s\n", | |
103 | source, monitorDecodeError(status)); | |
104 | return -1; | |
105 | } | |
106 | ||
107 | AliLog::SetModuleDebugLevel("FMD", debugLevel); | |
108 | /* declare monitoring program */ | |
109 | status=monitorDeclareMp( __FILE__ ); | |
110 | if (status!=0) { | |
111 | printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status)); | |
112 | return -1; | |
113 | } | |
114 | ||
115 | monitorSetNowait(); | |
116 | monitorSetNoWaitNetworkTimeout(1000); | |
117 | ||
118 | AliRawReader *reader = 0; | |
119 | AliFMDBaseDA baseDA; | |
120 | Int_t retval = 0; | |
121 | Int_t iev = 0; | |
122 | Bool_t SODread = kFALSE; | |
123 | while(!SODread && iev<1000) { | |
124 | ||
125 | /* check shutdown condition */ | |
126 | if (daqDA_checkShutdown()) {break;} | |
127 | ||
128 | /* get next event (blocking call until timeout) */ | |
129 | status=monitorGetEventDynamic((void **)&event); | |
130 | if (status==MON_ERR_EOF) { | |
131 | printf ("End of File detected\n"); | |
132 | break; /* end of monitoring file has been reached */ | |
133 | } | |
134 | ||
135 | if (status!=0) { | |
136 | printf("monitorGetEventDynamic() failed : %s\n", | |
137 | monitorDecodeError(status)); | |
138 | break; | |
139 | } | |
140 | ||
141 | /* retry if got no event */ | |
142 | if (event==NULL) { | |
143 | continue; | |
144 | } | |
145 | ||
146 | iev++; | |
147 | ||
148 | switch (event->eventType){ | |
149 | ||
150 | case START_OF_DATA: | |
151 | reader = new AliRawReaderDate((void*)event); | |
152 | baseDA.Run(reader); | |
153 | SODread = kTRUE; | |
154 | retval = | |
155 | daqDA_FES_storeFile("conditions.csv", | |
156 | AliFMDParameters::Instance()->GetConditionsShuttleID()); | |
157 | if (retval != 0) std::cerr << "Base DA failed" << std::endl; | |
158 | ||
159 | break; | |
160 | ||
161 | default: | |
162 | break; | |
163 | ||
164 | } | |
165 | } | |
166 | ||
167 | ||
168 | return retval; | |
169 | } |