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