1 /*********************************************************************************
2 - Contact: Brigitte Cheynis b.cheynis@ipnl.in2p3.fr
5 - Reference run number :
8 - Number of events needed: 500
9 - Input Files: argument list
10 - Output Files: local file V0_Tuning2.dat
11 FXS file V0_Tuning2.dat
12 - Trigger types used: PHYSICS_EVENT
13 **********************************************************************************/
16 /**********************************************************************************
18 * VZERO Detector Algorithm used for tuning FEE parameters *
20 * This program reads data on the LDC *
21 * It cumulates mean ADC responses (above pedestals), populates local *
22 * "./V0_Tuning2.dat" 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. *
27 ***********************************************************************************/
35 #include <AliVZERORawStream.h>
36 #include <AliRawReaderDate.h>
37 #include <AliRawReader.h>
46 #include "TPluginManager.h"
52 /* Main routine --- Arguments: iteration number, data file */
54 int main(int argc, char **argv) {
56 /* magic line from Cvetan */
57 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
64 Float_t ADC_Mean[128];
65 for(Int_t i=0; i<128; i++) {
69 /* log start of process */
70 printf("VZERO DA program started - Tuning FEE parameters\n");
72 /* check that we got some arguments = list of files */
74 printf("Wrong number of arguments\n");
77 /* open pedestal data file to read pedestal values for zero suppression */
79 file=fopen("./V0_Ped_Width_Gain.dat","read");
81 printf("Failed to open pedestal data file\n");
83 float Pedestal[128], Sigma[128];
84 for(Int_t j=0; j<128; j++){
85 fscanf(file,"%f %f ", &Pedestal[j], &Sigma[j]);
86 // printf("Pedestals = %f %f\n",Pedestal[j], Sigma[j]);
89 /* end of pedestal data retrieval */
91 /* open result file to be exported to FES */
93 fp=fopen("./V0_Tuning2.dat","a");
95 printf("Failed to open result file\n");
98 /* open log file to inform user */
100 flog=fopen("./V00log.txt","a");
102 printf("Failed to open log file\n");
105 /* report progress */
106 daqDA_progressReport(10);
108 /* init counters on events */
109 int nevents_physics=0;
114 status=monitorSetDataSource( argv[1] );
116 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
119 /* report progress */
120 daqDA_progressReport(50);
122 /* read the data file */
124 struct eventHeaderStruct *event;
125 eventTypeType eventT;
128 status=monitorGetEventDynamic((void **)&event);
129 if (status==MON_ERR_EOF) break; /* end of monitoring file has been reached */
131 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
134 /* retry if got no event */
135 if (event==NULL) break;
138 eventT=event->eventType;
140 switch (event->eventType){
146 printf("End Of Run detected\n");
152 // fprintf(flog,"Run #%lu, event size: %lu, BC:%u, Orbit:%u, Period:%u\n",
153 // (unsigned long)event->eventRunNb,
154 // (unsigned long)event->eventSize,
155 // EVENT_ID_GET_BUNCH_CROSSING(event->eventId),
156 // EVENT_ID_GET_ORBIT(event->eventId),
157 // EVENT_ID_GET_PERIOD(event->eventId) );
159 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
161 AliVZERORawStream* rawStream = new AliVZERORawStream(rawReader);
163 for(Int_t i=0; i<64; i++) {
164 if(!rawStream->GetIntegratorFlag(i,10))
166 if((rawStream->GetADC(i)-Pedestal[i]) > (Pedestal[i]+3*Sigma[i]) )
167 ADC_Mean[i]=ADC_Mean[i]+(rawStream->GetADC(i)-Pedestal[i]); // even integrator
171 if((rawStream->GetADC(i)-Pedestal[i+64]) > (Pedestal[i+64]+3*Sigma[i+64]) )
172 ADC_Mean[i+64]=ADC_Mean[i+64]+(rawStream->GetADC(i)-Pedestal[i+64]); // odd integrator
179 } // end of switch on event type
185 } // loop over events
187 //________________________________________________________________________
188 // Computes mean values, dumps them into the output text file
190 for(Int_t i=0; i<128; i++) {
191 ADC_Mean[i]=ADC_Mean[i]/nevents_physics;
192 fprintf(fp," %d %d %f\n",argc,i,ADC_Mean[i]);
193 fprintf(flog," %d %d %f\n",argc,i,ADC_Mean[i]);
196 //________________________________________________________________________
199 fprintf(flog,"Run #%s, received %d physics events out of %d\n",getenv("DATE_RUN_NUMBER"),nevents_physics,nevents_total);
200 printf("Run #%s, received %d physics events out of %d\n",getenv("DATE_RUN_NUMBER"),nevents_physics,nevents_total);
202 /* close result and log files */
206 /* report progress */
207 daqDA_progressReport(90);
209 /* export result file to FES */
210 status=daqDA_FES_storeFile("./V0_Tuning2.dat","V00da_results");
212 printf("Failed to export file : %d\n",status);
215 /* report progress */
216 daqDA_progressReport(100);