AliRoot Core  edcc906 (edcc906)
FMDBaseda.cxx
Go to the documentation of this file.
1 /*
2  FMD DA for online calibration of conditions
3 
4  Contact: christian.holm.christensen@cern.ch
5  Link: fmd.nbi.dk/fmd/offline
6  Run Type: PHYSICS
7  DA Type: MON
8  Number of events needed: depending on the run, being run-level
9  Input Files: raw data
10  Output Files: conditions.csv
11  Trigger types used: PHYSICS_EVENT
12 */
13 #include <cstdlib>
14 #include <Riostream.h>
15 #include "monitor.h"
16 #include "event.h"
17 #include <AliLog.h>
18 #include <TSystem.h>
19 #include <TString.h>
20 #include <AliFMDParameters.h>
21 #include <AliRawReader.h>
22 #include <TStopwatch.h>
23 #include <AliFMDBaseDA.h>
24 #include <AliRawReaderDate.h>
25 #include <AliRawReaderRoot.h>
26 #include "daqDA.h"
27 #include "TROOT.h"
28 #include "TPluginManager.h"
29 
30 void
31 usage(std::ostream& o, const char* progname)
32 {
33  o << "Usage: " << progname << " FILE [OPTIONS]\n\n"
34  << "Options:\n"
35  << "\t-h,--help Show this help\n"
36  << "\t-d,--diagnostics Create diagnostics\n"
37  << "\t-D,--debug LEVEL Set the debug level\n"
38  << std::endl;
39 }
40 
41 int main(int argc, char **argv)
42 {
43 
44 #if 0
45  /* magic line from Rene - for future reference! */
46  gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
47  "*",
48  "TStreamerInfo",
49  "RIO",
50  "TStreamerInfo()");
51 #endif
53 
54  Int_t ret = r.Init(argc, argv, false);
55  if (ret < 0) return -ret;
56  if (ret > 0) return 0;
57 
58 
59 
60  const Char_t* tableSOD[] = {"ALL", "no", "SOD", "all", NULL, NULL};
61 
62  monitorDeclareTable(const_cast<char**>(tableSOD));
63 
64  int status = monitorSetDataSource(r.fSource.Data());
65  if (status!=0) {
66  printf("monitorSetDataSource() failed for %s: %s\n",
67  r.fSource.Data(), monitorDecodeError(status));
68  return -1;
69  }
70 
71  /* declare monitoring program */
72  status = monitorDeclareMp( __FILE__ );
73  if (status!=0) {
74  printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
75  return -1;
76  }
77 
78  monitorSetNowait();
79  monitorSetNoWaitNetworkTimeout(1000);
80 
81  AliFMDBaseDA baseDA;
82  Int_t iev = 0;
83  Bool_t sodSeen = false;
84  Bool_t success = false;
85  while(!sodSeen && iev<1000) {
86 
87  /* check shutdown condition */
88  if (daqDA_checkShutdown()) break;
89 
90  /* get next event (blocking call until timeout) */
91  struct eventHeaderStruct *event = 0;
92  status = monitorGetEventDynamic((void **)&event);
93  if (status == MON_ERR_EOF) {
94  printf ("End of File detected\n");
95  break; /* end of monitoring file has been reached */
96  }
97 
98  if (status != 0) {
99  printf("monitorGetEventDynamic() failed : %s\n",
100  monitorDecodeError(status));
101  break;
102  }
103 
104  /* retry if got no event */
105  if (!event) continue;
106 
107  iev++;
108 
109  switch (event->eventType) {
110  case START_OF_DATA: {
111  std::cout << "Got START OF DATA event" << std::endl;
112  AliRawReader* reader = new AliRawReaderDate((void*)event);
113  if (!(success = baseDA.Run(reader, r.fAppendRun, true)))
114  std::cout << "Base DA failed" << std::endl;
115  sodSeen = kTRUE;
116  }
117  break;
118  default:
119  break;
120 
121  }
122  }
123  int retval = success ? 0 : 1;
124  if (r.fUpload && success) {
125  std::cout << "Pushing to FXS" << std::endl;
126  retval =
127  daqDA_FES_storeFile("conditions.csv",
129  ->GetConditionsShuttleID());
130  if (retval != 0) std::cerr << "Base DA failed" << std::endl;
131 
132  }
133  std::cout << "End of FMD-Base - return " << retval << std::endl;
134 
135  return retval;
136 }
137 //
138 // EOF
139 //
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
Manager of FMD parameters.
TROOT * gROOT
Int_t Init(int argc, char **argv, Bool_t reader=true)
Bool_t Run(AliRawReader *fmdReader, Bool_t appendRun, Bool_t isBase=false)
void usage(std::ostream &o, const char *progname)
Definition: FMDBaseda.cxx:31
static AliFMDParameters * Instance()
int main(int argc, char **argv)
Definition: FMDBaseda.cxx:41