]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/FMDBaseda.cxx
In AliMUONChamberCalibrationTask:
[u/mrichter/AliRoot.git] / FMD / FMDBaseda.cxx
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 "monitor.h"
15 #include "event.h"
16 #include <TSystem.h>
17 #include <TString.h>
18 #include <AliFMDParameters.h>
19 #include <AliRawReader.h>
20 #include <TStopwatch.h>
21 #include <AliFMDBaseDA.h>
22 #include <AliRawReaderDate.h>
23 #include <AliRawReaderRoot.h>
24 #include "daqDA.h"
25 #include "TROOT.h"
26 #include "TPluginManager.h"
27
28
29
30 int main(int argc, char **argv) 
31 {
32
33 #if 0
34   /* magic line from Rene - for future reference! */
35   gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
36                                         "*",
37                                         "TStreamerInfo",
38                                         "RIO",
39                                         "TStreamerInfo()");
40 #endif
41   
42   
43   const Char_t* tableSOD[]  = {"ALL", "no", "SOD", "all", NULL, NULL};
44
45   Bool_t old = kTRUE;
46   monitorDeclareTable(const_cast<char**>(tableSOD));
47
48   AliFMDParameters::Instance()->Init(kFALSE,0);
49   AliFMDParameters::Instance()->UseCompleteHeader(old);
50   struct eventHeaderStruct *event;
51   int status;
52   /* define data source : this is argument 1 */  
53   status=monitorSetDataSource( argv[1] );
54   if (status!=0) {
55     printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
56     return -1;
57   }
58   
59   /* declare monitoring program */
60   status=monitorDeclareMp( __FILE__ );
61   if (status!=0) {
62     printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
63     return -1;
64   }
65   
66   monitorSetNowait();
67   monitorSetNoWaitNetworkTimeout(1000);
68
69   AliRawReader *reader = 0;
70   AliFMDBaseDA baseDA;
71   Int_t  retval = 0;
72   Int_t iev = 0;
73   Bool_t SODread = kFALSE;
74   while(!SODread && iev<1000) {
75     
76     /* check shutdown condition */
77     if (daqDA_checkShutdown()) {break;}
78     
79     /* get next event (blocking call until timeout) */
80     status=monitorGetEventDynamic((void **)&event);
81     if (status==MON_ERR_EOF) {
82       printf ("End of File detected\n");
83       break; /* end of monitoring file has been reached */
84     }
85     
86     if (status!=0) {
87       printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
88       break;
89     }
90     
91     /* retry if got no event */
92     if (event==NULL) {
93       continue;
94     }
95     
96     iev++; 
97     
98     switch (event->eventType){
99       
100     case START_OF_DATA:
101       reader = new AliRawReaderDate((void*)event);
102       baseDA.Run(reader);
103       SODread = kTRUE;
104       retval = daqDA_FES_storeFile("conditions.csv", AliFMDParameters::Instance()->GetConditionsShuttleID());
105       if (retval != 0) std::cerr << "Base DA failed" << std::endl;
106       
107       break;
108     
109     default:
110       break;
111     
112     }
113   }
114  
115    
116   return retval;
117 }