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