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_Tuning1.dat
11 FXS file V0_Tuning1.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 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. *
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",
66 for(Int_t i=0; i<128; i++) {
71 /* log start of process */
72 printf("VZERO DA program started - Tuning FEE parameters\n");
74 /* check that we got some arguments */
76 printf("Wrong number of arguments\n");
79 /* open result file to be exported to FES */
81 fp=fopen("./V0_Tuning1.dat","a");
83 printf("Failed to open result file\n");
86 /* open log file to inform user */
88 flog=fopen("./V00log.txt","a");
90 printf("Failed to open log file\n");
94 daqDA_progressReport(10);
96 /* init counters on events */
97 int nevents_physics=0;
102 status=monitorSetDataSource( argv[1] );
104 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
107 /* report progress */
108 daqDA_progressReport(50);
110 /* read the data file */
112 struct eventHeaderStruct *event;
113 eventTypeType eventT;
116 status=monitorGetEventDynamic((void **)&event);
117 if (status==MON_ERR_EOF) break; /* end of monitoring file has been reached */
119 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
122 /* retry if got no event */
123 if (event==NULL) break;
126 eventT=event->eventType;
128 switch (event->eventType){
134 printf("End Of Run detected\n");
140 // fprintf(flog,"Run #%lu, event size: %lu, BC:%u, Orbit:%u, Period:%u\n",
141 // (unsigned long)event->eventRunNb,
142 // (unsigned long)event->eventSize,
143 // EVENT_ID_GET_BUNCH_CROSSING(event->eventId),
144 // EVENT_ID_GET_ORBIT(event->eventId),
145 // EVENT_ID_GET_PERIOD(event->eventId) );
147 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
149 AliVZERORawStream* rawStream = new AliVZERORawStream(rawReader);
151 for(Int_t i=0; i<64; i++) {
152 if(!rawStream->GetIntegratorFlag(i,10))
154 if(rawStream->GetBBFlag(i,10)) BBFlag[i]++; // even integrator - channel 0 to 63
155 if(rawStream->GetBGFlag(i,10)) BGFlag[i]++; // even integrator - channel 0 to 63
159 if(rawStream->GetBBFlag(i,10)) BBFlag[i+64]++; // odd integrator - channel 64 to 123
160 if(rawStream->GetBGFlag(i,10)) BGFlag[i+64]++; // odd integrator - channel 64 to 123
167 } // end of switch on event type
173 } // loop over events
175 //________________________________________________________________________
176 // Computes mean values, dumps them into the output text file
178 for(Int_t i=0; i<128; i++) {
179 BBFlag[i] = BBFlag[i]/nevents_physics;
180 BGFlag[i] = BGFlag[i]/nevents_physics;
181 fprintf(fp," %d %d %f %f\n",argc,i,BBFlag[i],BGFlag[i]);
182 fprintf(flog," %d %d %f %f\n",argc,i,BBFlag[i],BGFlag[i]);
185 //________________________________________________________________________
188 fprintf(flog,"Run #%s, received %d physics events out of %d\n",getenv("DATE_RUN_NUMBER"),nevents_physics,nevents_total);
189 printf("Run #%s, received %d physics events out of %d\n",getenv("DATE_RUN_NUMBER"),nevents_physics,nevents_total);
191 /* close result and log files */
195 /* report progress */
196 daqDA_progressReport(90);
198 /* export result file to FES */
199 status=daqDA_FES_storeFile("./V0_Tuning1.dat","V00da_results");
201 printf("Failed to export file : %d\n",status);
204 /* report progress */
205 daqDA_progressReport(100);