1 /********************************************************************************
3 * VZERO Detector Algorithm used for extracting calibration parameters *
5 * This program reads the DDL data file passed as argument using the monitoring *
7 * It computes calibration parameters, populates local "./V0_Ped_Width_Gain.dat" *
8 * file and exports it to the FES *
10 * The program reports about its processing progress. *
12 *********************************************************************************/
20 #include <AliVZERORawStream.h>
21 #include <AliRawReaderDate.h>
22 #include <AliRawReader.h>
36 /* Main routine --- Arguments: list of DATE raw data files */
38 int main(int argc, char **argv) {
42 printf(" argc = %d, argv = %s \n",argc, &(**argv));
44 Int_t kHighCut = 50; // high cut on pedestal distribution - to be tuned
45 Int_t kLowCut = 30; // low cut on signal distribution - to be tuned
48 Double_t PEDsigma[64];
50 //___________________________________________________
51 // Book HISTOGRAMS - dynamics of p-p collisions -
59 for (Int_t i=0; i<64; i++) {
60 sprintf(ADCname,"hADC%d",i);
61 sprintf(texte,"ADC cell%d",i);
62 hADCname[i] = new TH1F(ADCname,texte,1024,0,2047);
63 sprintf(PEDname,"hPED%d",i);
64 sprintf(texte,"PED cell%d",i);
65 hPEDname[i] = new TH1F(PEDname,texte,1024,0,2047);}
66 //___________________________________________________
69 /* log start of process */
70 printf("VZERO DA program started\n");
72 /* check that we got some arguments = list of files */
74 printf("Wrong number of arguments\n");
77 /* open result file to be exported to FES */
79 fp=fopen("./V0_Ped_Width_Gain.dat","a");
81 printf("Failed to open result file\n");
84 /* open log file to inform user */
86 flog=fopen("./V00log.txt","a");
88 printf("Failed to open log file\n");
92 daqDA_progressReport(10);
95 /* init counters on events */
96 int nevents_physics=0;
99 /* read the data files, considering n files */
103 for (n=1;n<argc;n++) {
105 status=monitorSetDataSource( argv[n] );
107 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
110 /* report progress - here indexed on the number of files */
111 daqDA_progressReport(10+80*n/argc);
113 /* read the data file */
115 struct eventHeaderStruct *event;
116 eventTypeType eventT;
119 status=monitorGetEventDynamic((void **)&event);
120 if (status==MON_ERR_EOF) break; /* end of monitoring file has been reached */
122 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
125 /* retry if got no event */
126 if (event==NULL) break;
129 eventT=event->eventType;
131 switch (event->eventType){
137 printf("End Of Run detected\n");
143 fprintf(flog,"Run #%lu, event size: %lu, BC:%u, Orbit:%u, Period:%u\n",
144 (unsigned long)event->eventRunNb,
145 (unsigned long)event->eventSize,
146 EVENT_ID_GET_BUNCH_CROSSING(event->eventId),
147 EVENT_ID_GET_ORBIT(event->eventId),
148 EVENT_ID_GET_PERIOD(event->eventId) );
150 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
151 rawReader->RequireHeader(kFALSE);
152 AliVZERORawStream* rawStream = new AliVZERORawStream(rawReader);
154 for(Int_t i=0; i<64; i++) {
155 hADCname[i]->Fill(rawStream->GetADC(i));
156 for(Int_t j=0; j<21; j++) {
158 hPEDname[i]->Fill(rawStream->GetPedestal(i,j)); }
164 } // end of switch on event type
170 } // loop over events
172 } // loop over data files
173 //________________________________________________________________________
174 // Computes mean values, dumps them into the output text file
176 for(Int_t i=0; i<64; i++) {
177 hPEDname[i]->GetXaxis()->SetRange(0,kHighCut);
178 PEDmean[i] = hPEDname[i]->GetMean();
179 PEDsigma[i] = hPEDname[i]->GetRMS();
180 hADCname[i]->GetXaxis()->SetRange(kLowCut,2047);
181 ADCmean[i] = hADCname[i]->GetMean() ;
182 fprintf(fp," %.3f %.3f %.3f\n",PEDmean[i],PEDsigma[i],ADCmean[i]);
185 //________________________________________________________________________
186 // Write root file with histos for users further check - just in case -
188 TFile *histoFile = new TFile("VZERO_histos.root","RECREATE");
190 for (Int_t i=0; i<64; i++) {
191 hADCname[i]->Write();
192 hPEDname[i]->Write(); }
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);
210 /* export result file to FES */
211 status=daqDA_FES_storeFile("./V0_Ped_Width_Gain.dat","V00da_results");
213 printf("Failed to export file : %d\n",status);
216 /* report progress */
217 daqDA_progressReport(100);