]> git.uio.no Git - u/mrichter/AliRoot.git/blame - FMD/FMDBaseda.cxx
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / FMD / FMDBaseda.cxx
CommitLineData
cb45bad5 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
c56bdf45 8 DA Type: MON
cb45bad5 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*/
a31ea3ce 14#include <cstdlib>
0a8abcad 15#include <Riostream.h>
c56bdf45 16#include "monitor.h"
d27e6de5 17#include "event.h"
9ef1fbe8 18#include <AliLog.h>
cb45bad5 19#include <TSystem.h>
f05d667d 20#include <TString.h>
cb45bad5 21#include <AliFMDParameters.h>
22#include <AliRawReader.h>
23#include <TStopwatch.h>
24#include <AliFMDBaseDA.h>
64c49452 25#include <AliRawReaderDate.h>
f05d667d 26#include <AliRawReaderRoot.h>
27#include "daqDA.h"
cb45bad5 28#include "TROOT.h"
29#include "TPluginManager.h"
30
a31ea3ce 31void
32usage(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}
cb45bad5 41
42int 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
aa947269 55 const Char_t* tableSOD[] = {"ALL", "no", "SOD", "all", NULL, NULL};
c851f39a 56
d27e6de5 57 Bool_t old = kTRUE;
aa947269 58 monitorDeclareTable(const_cast<char**>(tableSOD));
c851f39a 59
cb45bad5 60 AliFMDParameters::Instance()->Init(kFALSE,0);
d27e6de5 61 AliFMDParameters::Instance()->UseCompleteHeader(old);
62 struct eventHeaderStruct *event;
63 int status;
a31ea3ce 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]);
408bf2b4 98 return -1;
99 }
a31ea3ce 100 status=monitorSetDataSource(source);
d27e6de5 101 if (status!=0) {
a31ea3ce 102 printf("monitorSetDataSource() failed for %s: %s\n",
103 source, monitorDecodeError(status));
d27e6de5 104 return -1;
f05d667d 105 }
106
a31ea3ce 107 AliLog::SetModuleDebugLevel("FMD", debugLevel);
d27e6de5 108 /* declare monitoring program */
109 status=monitorDeclareMp( __FILE__ );
110 if (status!=0) {
111 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
112 return -1;
113 }
cb45bad5 114
d27e6de5 115 monitorSetNowait();
116 monitorSetNoWaitNetworkTimeout(1000);
cb45bad5 117
d27e6de5 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) {
a31ea3ce 136 printf("monitorGetEventDynamic() failed : %s\n",
137 monitorDecodeError(status));
d27e6de5 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;
6cf6e7a0 154 retval =
155 daqDA_FES_storeFile("conditions.csv",
156 AliFMDParameters::Instance()->GetConditionsShuttleID());
91c99839 157 if (retval != 0) std::cerr << "Base DA failed" << std::endl;
d27e6de5 158
159 break;
160
161 default:
162 break;
163
164 }
165 }
166
167
f05d667d 168 return retval;
cb45bad5 169}