]>
Commit | Line | Data |
---|---|---|
77fcf351 | 1 | /********************************************************************************* |
2 | - Contact: Brigitte Cheynis b.cheynis@ipnl.in2p3.fr | |
3 | - Link: http | |
4 | - Raw data test file : | |
5 | - Reference run number : | |
6 | - Run Type: STANDALONE | |
7 | - DA Type: LDC | |
8 | - Number of events needed: 500 | |
9 | - Input Files: argument list | |
10 | - Output Files: local file V0_Tuning1.dat | |
11 | FXS file V0_Tuning1.dat | |
12 | - Trigger types used: PHYSICS_EVENT | |
13 | **********************************************************************************/ | |
14 | ||
15 | ||
16 | /********************************************************************************** | |
17 | * * | |
18 | * VZERO Detector Algorithm used for tuning FEE parameters * | |
19 | * * | |
20 | * This program reads data on the LDC * | |
21 | * It cumulates fBB and fBG flags, populates local "./V0_Tuning1.dat" * | |
22 | * file and exports it to the FES. * | |
23 | * We have 128 channels instead of 64 as expected for V0 due to the two sets of * | |
24 | * charge integrators which are used by the FEE ... * | |
25 | * The program reports about its processing progress. * | |
26 | * * | |
27 | ***********************************************************************************/ | |
28 | ||
29 | // DATE | |
30 | #include "event.h" | |
31 | #include "monitor.h" | |
32 | #include "daqDA.h" | |
33 | ||
34 | //AliRoot | |
35 | #include <AliVZERORawStream.h> | |
36 | #include <AliRawReaderDate.h> | |
37 | #include <AliRawReader.h> | |
38 | #include <AliDAQ.h> | |
39 | ||
40 | // standard | |
41 | #include <stdio.h> | |
42 | #include <stdlib.h> | |
43 | ||
44 | //ROOT | |
45 | #include "TROOT.h" | |
46 | #include "TPluginManager.h" | |
47 | #include <TFile.h> | |
48 | #include <TH1F.h> | |
49 | #include <TMath.h> | |
50 | ||
51 | ||
7242408b | 52 | /* Main routine --- Arguments: list of DATE raw data files */ |
77fcf351 | 53 | |
54 | int main(int argc, char **argv) { | |
55 | ||
56 | /* magic line from Cvetan */ | |
57 | gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo", | |
58 | "*", | |
59 | "TStreamerInfo", | |
60 | "RIO", | |
61 | "TStreamerInfo()"); | |
62 | int status; | |
63 | ||
64 | Float_t BBFlag[128]; | |
65 | Float_t BGFlag[128]; | |
66 | for(Int_t i=0; i<128; i++) { | |
67 | BBFlag[i] = 0.0; | |
68 | BGFlag[i] = 0.0; | |
69 | } | |
70 | ||
71 | /* log start of process */ | |
72 | printf("VZERO DA program started - Tuning FEE parameters\n"); | |
73 | ||
fb319739 | 74 | /* check that we got some arguments */ |
77fcf351 | 75 | if (argc<2) { |
76 | printf("Wrong number of arguments\n"); | |
77 | return -1;} | |
78 | ||
79 | /* open result file to be exported to FES */ | |
80 | FILE *fp=NULL; | |
81 | fp=fopen("./V0_Tuning1.dat","a"); | |
82 | if (fp==NULL) { | |
83 | printf("Failed to open result file\n"); | |
84 | return -1;} | |
85 | ||
86 | /* open log file to inform user */ | |
87 | FILE *flog=NULL; | |
88 | flog=fopen("./V00log.txt","a"); | |
89 | if (flog==NULL) { | |
90 | printf("Failed to open log file\n"); | |
91 | return -1; } | |
92 | ||
93 | /* report progress */ | |
94 | daqDA_progressReport(10); | |
95 | ||
96 | /* init counters on events */ | |
97 | int nevents_physics=0; | |
98 | int nevents_total=0; | |
311f00a2 | 99 | int iteration; |
100 | sscanf(argv[1],"%d",&iteration); | |
77fcf351 | 101 | |
7242408b | 102 | /* read the n data files */ |
311f00a2 | 103 | for (int n=2; n<argc; n++) { |
7242408b | 104 | |
105 | /* read the data */ | |
106 | status=monitorSetDataSource( argv[n] ); | |
107 | if (status!=0) { | |
108 | printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status)); | |
109 | return -1; } | |
77fcf351 | 110 | |
111 | /* report progress */ | |
7242408b | 112 | daqDA_progressReport(10+50*n/argc); |
77fcf351 | 113 | |
114 | /* read the data file */ | |
7242408b | 115 | for(;;) { |
77fcf351 | 116 | struct eventHeaderStruct *event; |
117 | eventTypeType eventT; | |
118 | ||
119 | /* get next event */ | |
120 | status=monitorGetEventDynamic((void **)&event); | |
121 | if (status==MON_ERR_EOF) break; /* end of monitoring file has been reached */ | |
122 | if (status!=0) { | |
123 | printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status)); | |
124 | return -1; } | |
125 | ||
126 | /* retry if got no event */ | |
127 | if (event==NULL) break; | |
128 | ||
129 | /* decode event */ | |
130 | eventT=event->eventType; | |
131 | ||
132 | switch (event->eventType){ | |
133 | ||
134 | case START_OF_RUN: | |
135 | break; | |
136 | ||
137 | case END_OF_RUN: | |
138 | printf("End Of Run detected\n"); | |
139 | break; | |
140 | ||
141 | case PHYSICS_EVENT: | |
142 | nevents_physics++; | |
7242408b | 143 | |
77fcf351 | 144 | AliRawReader *rawReader = new AliRawReaderDate((void*)event); |
145 | ||
146 | AliVZERORawStream* rawStream = new AliVZERORawStream(rawReader); | |
147 | rawStream->Next(); | |
148 | for(Int_t i=0; i<64; i++) { | |
149 | if(!rawStream->GetIntegratorFlag(i,10)) | |
150 | { | |
151 | if(rawStream->GetBBFlag(i,10)) BBFlag[i]++; // even integrator - channel 0 to 63 | |
152 | if(rawStream->GetBGFlag(i,10)) BGFlag[i]++; // even integrator - channel 0 to 63 | |
153 | } | |
154 | else | |
155 | { | |
156 | if(rawStream->GetBBFlag(i,10)) BBFlag[i+64]++; // odd integrator - channel 64 to 123 | |
157 | if(rawStream->GetBGFlag(i,10)) BGFlag[i+64]++; // odd integrator - channel 64 to 123 | |
158 | } | |
159 | } | |
160 | delete rawStream; | |
161 | rawStream = 0x0; | |
162 | delete rawReader; | |
163 | rawReader = 0x0; | |
164 | } // end of switch on event type | |
165 | ||
166 | nevents_total++; | |
167 | /* free resources */ | |
168 | free(event); | |
169 | ||
7242408b | 170 | } // end of loop over events |
171 | } // end of loop over data files | |
172 | ||
77fcf351 | 173 | //________________________________________________________________________ |
174 | // Computes mean values, dumps them into the output text file | |
175 | ||
176 | for(Int_t i=0; i<128; i++) { | |
177 | BBFlag[i] = BBFlag[i]/nevents_physics; | |
178 | BGFlag[i] = BGFlag[i]/nevents_physics; | |
311f00a2 | 179 | fprintf(fp," %d %d %f %f\n",iteration,i,BBFlag[i],BGFlag[i]); |
180 | fprintf(flog," %d %d %f %f\n",iteration,i,BBFlag[i],BGFlag[i]); | |
77fcf351 | 181 | } |
311f00a2 | 182 | |
77fcf351 | 183 | //________________________________________________________________________ |
184 | ||
185 | /* write report */ | |
186 | fprintf(flog,"Run #%s, received %d physics events out of %d\n",getenv("DATE_RUN_NUMBER"),nevents_physics,nevents_total); | |
187 | printf("Run #%s, received %d physics events out of %d\n",getenv("DATE_RUN_NUMBER"),nevents_physics,nevents_total); | |
188 | ||
189 | /* close result and log files */ | |
190 | fclose(fp); | |
191 | fclose(flog); | |
192 | ||
193 | /* report progress */ | |
194 | daqDA_progressReport(90); | |
195 | ||
196 | /* export result file to FES */ | |
197 | status=daqDA_FES_storeFile("./V0_Tuning1.dat","V00da_results"); | |
198 | if (status) { | |
199 | printf("Failed to export file : %d\n",status); | |
200 | return -1; } | |
201 | ||
202 | /* report progress */ | |
203 | daqDA_progressReport(100); | |
204 | ||
205 | return status; | |
206 | } |