]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/FMDBaseda.cxx
added test script
[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   if (argc < 2) { 
54     std::cout << "No monitor source set" << std::endl;
55     return -1;
56   }
57   status=monitorSetDataSource( argv[1] );
58   if (status!=0) {
59     printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
60     return -1;
61   }
62   
63   /* declare monitoring program */
64   status=monitorDeclareMp( __FILE__ );
65   if (status!=0) {
66     printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
67     return -1;
68   }
69   
70   monitorSetNowait();
71   monitorSetNoWaitNetworkTimeout(1000);
72
73   AliRawReader *reader = 0;
74   AliFMDBaseDA baseDA;
75   Int_t  retval = 0;
76   Int_t iev = 0;
77   Bool_t SODread = kFALSE;
78   while(!SODread && iev<1000) {
79     
80     /* check shutdown condition */
81     if (daqDA_checkShutdown()) {break;}
82     
83     /* get next event (blocking call until timeout) */
84     status=monitorGetEventDynamic((void **)&event);
85     if (status==MON_ERR_EOF) {
86       printf ("End of File detected\n");
87       break; /* end of monitoring file has been reached */
88     }
89     
90     if (status!=0) {
91       printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
92       break;
93     }
94     
95     /* retry if got no event */
96     if (event==NULL) {
97       continue;
98     }
99     
100     iev++; 
101     
102     switch (event->eventType){
103       
104     case START_OF_DATA:
105       reader = new AliRawReaderDate((void*)event);
106       baseDA.Run(reader);
107       SODread = kTRUE;
108       retval = 
109         daqDA_FES_storeFile("conditions.csv", 
110                             AliFMDParameters::Instance()->GetConditionsShuttleID());
111       if (retval != 0) std::cerr << "Base DA failed" << std::endl;
112       
113       break;
114     
115     default:
116       break;
117     
118     }
119   }
120  
121    
122   return retval;
123 }