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