2 T0 DA for online calibration
4 Contact: Michal.Oledzki@cern.ch
5 Link: http://users.jyu.fi/~mioledzk/
8 Number of events needed: 400000
9 Input Files: inLaser.dat, external parameters
10 Output Files: daLaser.root, to be exported to the DAQ FXS
11 Trigger types used: CALIBRATION_EVENT
15 #define FILE_OUT "daLaser.root"
16 #define FILE_IN "inLaser.dat"
21 #include <Riostream.h>
26 #include <AliRawReaderDate.h>
27 #include <AliRawReader.h>
28 #include <AliT0RawReader.h>
32 #include "TPluginManager.h"
37 #include "TBenchmark.h"
44 #include "TSpectrum.h"
45 #include "TVirtualFitter.h"
46 //#include "TProfile.h"
47 int cqbx,cqby,clbx,clby,mod;
48 float cqlx,cqmx,cqly,cqmy,cllx,clmx,clly,clmy;
51 1- monitoring data source
53 int main(int argc, char **argv) {
57 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
63 if(daqDA_DB_getFile(FILE_IN, FILE_IN)){
64 printf("Couldn't get input file >>inLaser.dat<< from DAQ_DB !!!\n");
71 inp = fopen(FILE_IN, "r");
73 printf("Input file >>inLaser.dat<< not found !!!\n");
77 while((c=getc(inp))!=EOF) {
79 case 'a': {fscanf(inp, "%d", &cqbx ); break;} //N of X bins hCFD_QTC
80 case 'b': {fscanf(inp, "%f", &cqlx ); break;} //Low x hCFD_QTC
81 case 'c': {fscanf(inp, "%f", &cqmx ); break;} //High x hCFD_QTC
82 case 'd': {fscanf(inp, "%d", &cqby ); break;} //N of Y bins hCFD_QTC
83 case 'e': {fscanf(inp, "%f", &cqly ); break;} //Low y hCFD_QTC
84 case 'f': {fscanf(inp, "%f", &cqmy ); break;} //High y hCFD_QTC
85 case 'g': {fscanf(inp, "%d", &clbx ); break;} //N of X bins hCFD_LED
86 case 'h': {fscanf(inp, "%f", &cllx ); break;} //Low x hCFD_LED
87 case 'i': {fscanf(inp, "%f", &clmx ); break;} //High x hCFD_LED
88 case 'j': {fscanf(inp, "%d", &clby ); break;} //N of Y bins hCFD_LED
89 case 'k': {fscanf(inp, "%f", &clly ); break;} //Low y hCFD_LED
90 case 'l': {fscanf(inp, "%f", &clmy ); break;} //High y hCFD_LED
91 case 'm': {fscanf(inp, "%d", &mod ); break;} //Modulo number
97 printf("Wrong number of arguments\n");
102 /* define data source : this is argument 1 */
103 status=monitorSetDataSource( argv[1] );
105 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
110 /* declare monitoring program */
111 status=monitorDeclareMp( __FILE__ );
113 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
118 /* define wait event timeout - 1s max */
120 monitorSetNoWaitNetworkTimeout(1000);
123 /* log start of process */
124 printf("T0 monitoring program started\n");
126 // Allocation of histograms - start
127 TH2F *hCFDvsQTC[24][10];
128 TH2F *hCFDvsLED[24][10];
130 for(Int_t ic=0; ic<24; ic++)
131 for(Int_t im=0;im<10;im++)
133 hCFDvsQTC[ic][im] = new TH2F(Form("CFDvsQTC%d_%d",ic+1,im+1),"CFDvsQTC",cqbx,cqlx,cqmx,cqby,cqly,cqmy);
134 hCFDvsLED[ic][im] = new TH2F(Form("CFDvsLED%d_%d",ic+1,im+1),"CFDvsLED",clbx,cllx,clmx,clby,clly,clmy);
137 // Allocation of histograms - end
141 /* main loop (infinite) */
143 struct eventHeaderStruct *event;
144 eventTypeType eventT;
146 /* check shutdown condition */
147 if (daqDA_checkShutdown()) {break;}
149 /* get next event (blocking call until timeout) */
150 status=monitorGetEventDynamic((void **)&event);
151 if (status==(int)MON_ERR_EOF) {
152 printf ("End of File detected\n");
153 break; /* end of monitoring file has been reached */
157 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
161 /* retry if got no event */
166 /* use event - here, just write event id to result file */
167 eventT=event->eventType;
169 switch (event->eventType){
177 case CALIBRATION_EVENT:
178 // case PHYSICS_EVENT:
182 printf("First event - %i\n",iev);
185 // Initalize raw-data reading and decoding
186 AliRawReader *reader = new AliRawReaderDate((void*)event);
188 // Enable the following two lines in case of real-data
189 reader->RequireHeader(kTRUE);
190 AliT0RawReader *start = new AliT0RawReader(reader, kTRUE);
193 Int_t allData[106][5];
194 for(Int_t i0=0;i0<106;i0++)
195 for(Int_t j0=0;j0<5;j0++)
199 for (Int_t i=0; i<106; i++) {
200 for(Int_t iHit=0;iHit<5;iHit++){
201 allData[i][iHit]= start->GetData(i,iHit);
206 printf("No data for T0 found!!!\n");
208 // Fill the histograms
215 // printf("mip = %d\n",mip);
219 for (Int_t ik = 0; ik<24; ik+=2)
220 for (Int_t iHt=0; iHt<1; iHt++){
222 if(allData[ik+25][iHt]!=0 && allData[ik+26][iHt]!=0 && allData[cc+1][iHt]!=0){
223 hCFDvsQTC[cc][mip]->Fill((allData[ik+25][iHt]-allData[ik+26][iHt]) , (allData[cc+1][iHt]-allData[0][0]+5000));
225 if(allData[cc+13][iHt]!=0 && allData[cc+1][iHt]!=0){
226 hCFDvsLED[cc][mip]->Fill(allData[cc+13][iHt]-allData[cc+1][iHt],allData[cc+1][iHt]-allData[0][0]+5000);
230 for (Int_t ik = 24; ik<48; ik+=2)
231 for (Int_t iHt=0; iHt<1; iHt++){
233 if(allData[ik+57][iHt]!=0 && allData[ik+58][iHt]!=0 && allData[cc+45][iHt]!=0){
234 hCFDvsQTC[cc][mip]->Fill(allData[ik+57][iHt]-allData[ik+58][iHt],allData[cc+45][iHt]-allData[0][0]+5000);
236 if(allData[cc+57][iHt]!=0 && allData[cc+45][iHt]!=0){
237 hCFDvsLED[cc][mip]->Fill(allData[cc+57][iHt]-allData[cc+45][iHt],allData[cc+45][iHt]-allData[0][0]+5000);
244 // End of fill histograms
251 /* exit when last event received, no need to wait for TERM signal */
252 if (eventT==END_OF_RUN) {
253 printf("EOR event detected\n");
254 printf("Number of events processed - %i\n ",iev);
258 printf("After loop, before writing histos\n");
259 // write a file with the histograms
260 TFile *hist = new TFile(FILE_OUT,"RECREATE");
262 for(Int_t j=0;j<24;j++)
263 for(Int_t k=0;k<10;k++)
265 hCFDvsQTC[j][k]->Write();
266 hCFDvsLED[j][k]->Write();
273 /* export file to FXS */
274 if (daqDA_FES_storeFile(FILE_OUT, "LASER")) {