]>
Commit | Line | Data |
---|---|---|
0bbeb14b | 1 | /* |
2 | contact: Boris.Polishchuk@cern.ch | |
3 | link: http://aliceinfo.cern.ch/static/phpBB3/viewtopic.php?f=4&t=17 | |
4 | reference run: /castor/cern.ch/alice/phos/2007/10/02/13/07000008232001.10.root | |
5 | run type: STANDALONE | |
6 | DA type: MON | |
7 | number of events needed: 1000 | |
8 | input files: RCU0.data RCU1.data RCU2.data RCU3.data | |
9 | Output files: PHOS_Module2_BCM.root | |
10 | Trigger types used: CALIBRATION_EVENT or PHYSICS | |
11 | */ | |
12 | ||
13 | ||
14 | #include "event.h" | |
15 | #include "monitor.h" | |
16 | extern "C" { | |
17 | #include "daqDA.h" | |
18 | } | |
19 | ||
20 | #include <stdio.h> | |
21 | #include <stdlib.h> | |
22 | ||
23 | #include <TSystem.h> | |
24 | #include <TROOT.h> | |
25 | #include <TPluginManager.h> | |
26 | ||
27 | #include "AliRawReader.h" | |
28 | #include "AliRawReaderDate.h" | |
29 | #include "AliPHOSDA2.h" | |
30 | #include "AliPHOSRawDecoderv1.h" | |
31 | #include "AliCaloAltroMapping.h" | |
32 | ||
33 | ||
34 | /* Main routine | |
35 | Arguments: | |
36 | 1- monitoring data source | |
37 | */ | |
38 | int main(int argc, char **argv) { | |
39 | ||
40 | gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo", | |
41 | "*", | |
42 | "TStreamerInfo", | |
43 | "RIO", | |
44 | "TStreamerInfo()"); | |
45 | ||
46 | int status; | |
47 | ||
48 | if (argc!=2) { | |
49 | printf("Wrong number of arguments\n"); | |
50 | return -1; | |
51 | } | |
52 | ||
53 | ||
54 | /* Retrieve mapping files from DAQ DB */ | |
55 | const char* mapFiles[4] = {"RCU0.data","RCU1.data","RCU2.data","RCU3.data"}; | |
56 | ||
57 | for(Int_t iFile=0; iFile<4; iFile++) { | |
58 | int failed = daqDA_DB_getFile(mapFiles[iFile], mapFiles[iFile]); | |
59 | if(failed) { | |
60 | printf("Cannot retrieve file %s from DAQ DB. Exit.\n",mapFiles[iFile]); | |
61 | return -1; | |
62 | } | |
63 | } | |
64 | ||
65 | /* Open mapping files */ | |
66 | AliAltroMapping *mapping[4]; | |
67 | TString path = "./"; | |
68 | path += "RCU"; | |
69 | TString path2; | |
70 | for(Int_t i = 0; i < 4; i++) { | |
71 | path2 = path; | |
72 | path2 += i; | |
73 | path2 += ".data"; | |
74 | mapping[i] = new AliCaloAltroMapping(path2.Data()); | |
75 | } | |
76 | ||
77 | ||
78 | /* define data source : this is argument 1 */ | |
79 | status=monitorSetDataSource( argv[1] ); | |
80 | if (status!=0) { | |
81 | printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status)); | |
82 | return -1; | |
83 | } | |
84 | ||
85 | ||
86 | /* declare monitoring program */ | |
87 | status=monitorDeclareMp( __FILE__ ); | |
88 | if (status!=0) { | |
89 | printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status)); | |
90 | return -1; | |
91 | } | |
92 | ||
93 | ||
94 | /* define wait event timeout - 1s max */ | |
95 | monitorSetNowait(); | |
96 | monitorSetNoWaitNetworkTimeout(1000); | |
97 | ||
98 | ||
99 | /* log start of process */ | |
100 | printf("DA2 (bad channels search) started.\n"); | |
101 | ||
102 | ||
103 | /* init some counters */ | |
104 | int nevents_physics=0; | |
105 | int nevents_total=0; | |
106 | ||
107 | AliRawReader *rawReader = NULL; | |
108 | ||
109 | AliPHOSDA2 da2(2); // DA2 ("Checking for bad channels") for module2 | |
110 | ||
111 | Float_t q[64][56][2]; | |
112 | ||
113 | Int_t gain = -1; | |
114 | Int_t X = -1; | |
115 | Int_t Z = -1; | |
116 | ||
117 | /* main loop (infinite) */ | |
118 | for(;;) { | |
119 | struct eventHeaderStruct *event; | |
120 | eventTypeType eventT; | |
121 | ||
122 | /* check shutdown condition */ | |
123 | if (daqDA_checkShutdown()) {break;} | |
124 | ||
125 | /* get next event (blocking call until timeout) */ | |
126 | status=monitorGetEventDynamic((void **)&event); | |
127 | if (status==MON_ERR_EOF) { | |
128 | printf ("End of File detected\n"); | |
129 | break; /* end of monitoring file has been reached */ | |
130 | } | |
131 | ||
132 | if (status!=0) { | |
133 | printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status)); | |
134 | break; | |
135 | } | |
136 | ||
137 | /* retry if got no event */ | |
138 | if (event==NULL) { | |
139 | continue; | |
140 | } | |
141 | ||
142 | ||
143 | /* use event - here, just write event id to result file */ | |
144 | eventT=event->eventType; | |
145 | ||
146 | if (eventT==PHYSICS_EVENT || eventT==CALIBRATION_EVENT) { | |
147 | ||
148 | for(Int_t iX=0; iX<64; iX++) { | |
149 | for(Int_t iZ=0; iZ<56; iZ++) { | |
150 | for(Int_t iGain=0; iGain<2; iGain++) { | |
151 | q[iX][iZ][iGain] = 0.; | |
152 | } | |
153 | } | |
154 | } | |
155 | ||
156 | rawReader = new AliRawReaderDate((void*)event); | |
157 | AliPHOSRawDecoderv1 dc(rawReader,mapping); | |
158 | dc.SubtractPedestals(kTRUE); | |
159 | ||
160 | while(dc.NextDigit()) { | |
161 | ||
162 | X = dc.GetRow() - 1; | |
163 | Z = dc.GetColumn() - 1; | |
164 | ||
165 | if(dc.IsLowGain()) gain = 0; | |
166 | else | |
167 | gain = 1; | |
168 | ||
169 | q[X][Z][gain] = dc.GetSampleQuality(); | |
170 | ||
171 | } | |
172 | ||
173 | da2.FillQualityHistograms(q); | |
174 | //da1.UpdateHistoFile(); | |
175 | ||
176 | delete rawReader; | |
177 | nevents_physics++; | |
178 | } | |
179 | ||
180 | nevents_total++; | |
181 | ||
182 | /* free resources */ | |
183 | free(event); | |
184 | ||
185 | /* exit when last event received, no need to wait for TERM signal */ | |
186 | if (eventT==END_OF_RUN) { | |
187 | printf("EOR event detected\n"); | |
188 | break; | |
189 | } | |
190 | } | |
191 | ||
192 | for(Int_t i = 0; i < 4; i++) delete mapping[i]; | |
193 | ||
194 | /* Store output files to the File Exchange Server */ | |
195 | char localfile[128]; | |
196 | ||
197 | for(Int_t iMod=0; iMod<5; iMod++) { | |
198 | sprintf(localfile,"PHOS_Module%d_BCM.root",iMod); | |
199 | daqDA_FES_storeFile(localfile,"BAD_CHANNELS"); | |
200 | } | |
201 | ||
202 | return status; | |
203 | } |