]>
Commit | Line | Data |
---|---|---|
e43e472f | 1 | /* |
2 | PMD DA for online calibration | |
3 | ||
4 | contact: basanta@phy.iitb.ac.in | |
5 | Link:/afs/cern.ch/user/a/alicepmd/public/pedestaldata/run31270.raw | |
6 | Run Type: STANDALONE | |
722ccc67 | 7 | DA Type: LDC |
e43e472f | 8 | Number of events needed: 1000 |
9 | Input Files: data raw | |
10 | Output Files: pmd_ped.root, to be exported to the DAQ FXS | |
722ccc67 | 11 | Trigger types used: PHYSICS_EVENT |
e43e472f | 12 | |
13 | */ | |
14 | extern "C" { | |
15 | #include <daqDA.h> | |
16 | } | |
17 | ||
18 | #include "event.h" | |
19 | #include "monitor.h" | |
20 | //#include "daqDA.h" | |
21 | ||
22 | #include <Riostream.h> | |
23 | #include <stdio.h> | |
24 | #include <stdlib.h> | |
25 | ||
26 | //AliRoot | |
27 | #include "AliRawReaderDate.h" | |
28 | #include "AliPMDCalibPedestal.h" | |
29 | ||
30 | //ROOT | |
31 | #include "TFile.h" | |
32 | #include "TH1F.h" | |
33 | #include "TBenchmark.h" | |
34 | #include "TTree.h" | |
35 | #include "TROOT.h" | |
36 | #include "TPluginManager.h" | |
37 | ||
38 | ||
39 | ||
40 | /* Main routine | |
41 | Arguments: | |
42 | 1- monitoring data source | |
43 | */ | |
44 | int main(int argc, char **argv) { | |
45 | ||
46 | /* magic line from Rene */ | |
47 | gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo", | |
48 | "*", | |
49 | "TStreamerInfo", | |
50 | "RIO", | |
51 | "TStreamerInfo()"); | |
52 | ||
53 | ||
54 | AliPMDCalibPedestal calibped; | |
55 | ||
56 | TTree *ped = new TTree("ped","PMD Pedestal tree"); | |
57 | ||
58 | TH1F::AddDirectory(0); | |
59 | ||
60 | ||
61 | // decoding the events | |
62 | ||
63 | int status; | |
64 | ||
65 | if (argc!=2) { | |
66 | printf("Wrong number of arguments\n"); | |
67 | return -1; | |
68 | } | |
69 | ||
e43e472f | 70 | |
71 | /* define data source : this is argument 1 */ | |
72 | status=monitorSetDataSource( argv[1] ); | |
73 | if (status!=0) { | |
74 | printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status)); | |
75 | return -1; | |
76 | } | |
77 | ||
78 | /* declare monitoring program */ | |
79 | status=monitorDeclareMp( __FILE__ ); | |
80 | if (status!=0) { | |
81 | printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status)); | |
82 | return -1; | |
83 | } | |
84 | ||
85 | /* define wait event timeout - 1s max */ | |
86 | monitorSetNowait(); | |
87 | monitorSetNoWaitNetworkTimeout(1000); | |
88 | ||
89 | /* log start of process */ | |
90 | printf("DA example case2 monitoring program started\n"); | |
91 | ||
92 | /* init some counters */ | |
722ccc67 | 93 | |
e43e472f | 94 | |
95 | struct eventHeaderStruct *event; | |
96 | eventTypeType eventT; | |
97 | Int_t iev=0; | |
98 | ||
99 | /* main loop (infinite) */ | |
100 | for(;;) { | |
101 | ||
102 | /* check shutdown condition */ | |
103 | if (daqDA_checkShutdown()) {break;} | |
104 | ||
105 | /* get next event (blocking call until timeout) */ | |
106 | status=monitorGetEventDynamic((void **)&event); | |
107 | if (status==MON_ERR_EOF) { | |
108 | printf ("End of File detected\n"); | |
109 | break; /* end of monitoring file has been reached */ | |
110 | } | |
111 | ||
112 | if (status!=0) { | |
113 | printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status)); | |
114 | break; | |
115 | } | |
116 | ||
117 | /* retry if got no event */ | |
118 | if (event==NULL) { | |
119 | continue; | |
120 | } | |
121 | ||
122 | iev++; | |
123 | ||
124 | /* use event - here, just write event id to result file */ | |
125 | eventT=event->eventType; | |
126 | switch (event->eventType){ | |
127 | ||
128 | /* START OF RUN */ | |
129 | case START_OF_RUN: | |
130 | break; | |
131 | /* END START OF RUN */ | |
132 | ||
133 | /* END OF RUN */ | |
134 | case END_OF_RUN: | |
135 | break; | |
136 | ||
722ccc67 | 137 | case PHYSICS_EVENT: |
e43e472f | 138 | printf(" event number = %i \n",iev); |
722ccc67 | 139 | //if (iev == 10) break; |
e43e472f | 140 | AliRawReader *rawReader = new AliRawReaderDate((void*)event); |
141 | calibped.ProcessEvent(rawReader); | |
142 | ||
143 | delete rawReader; | |
144 | rawReader = 0x0; | |
145 | } | |
146 | ||
147 | /* free resources */ | |
148 | free(event); | |
149 | ||
150 | /* exit when last event received, no need to wait for TERM signal */ | |
151 | if (eventT==END_OF_RUN) { | |
152 | printf("EOR event detected\n"); | |
153 | calibped.Analyse(ped); | |
154 | break; | |
155 | } | |
722ccc67 | 156 | |
157 | /* | |
158 | if (iev == 10) { | |
159 | printf("EOR event detected\n"); | |
160 | calibped.Analyse(ped); | |
161 | break; | |
162 | } | |
163 | */ | |
e43e472f | 164 | } |
165 | ||
166 | ||
722ccc67 | 167 | TFile * pedRun = new TFile ("PMD_PED.root","RECREATE"); |
e43e472f | 168 | ped->Write(); |
169 | pedRun->Close(); | |
170 | ||
171 | ||
e43e472f | 172 | return status; |
173 | } |