2 T0 DA for online calibration
4 Contact: Michal.Oledzki@cern.ch
5 Link: http://users.jyu.fi/~mioledzk/
8 Number of events needed: 500000
9 Input Files: inPhys.dat, external parameters
10 Output Files: daPhys.root, to be exported to the DAQ FXS
11 Trigger types used: PHYSICS_EVENT
12 ------------------------------Alla
13 Now trigger type changed to CALICRATION_EVENT
14 to have data during test.
15 SOULD BE CHANGED BACK BEFORE BEAM
16 ------------------------------- Alla
19 #define FILE_OUT "daPhys.root"
20 #define FILE_IN "inPhys.dat"
25 #include <Riostream.h>
30 #include <AliRawReaderDate.h>
31 #include <AliRawReader.h>
32 #include <AliT0RawReader.h>
36 #include "TPluginManager.h"
41 #include "TBenchmark.h"
47 #include "TSpectrum.h"
48 #include "TVirtualFitter.h"
50 float clx,cmx,cclx,ccmx;
54 1- monitoring data source
56 int main(int argc, char **argv) {
61 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
67 if(daqDA_DB_getFile(FILE_IN, FILE_IN)){
68 printf("Couldn't get input file >>inPhys.dat<< from DAQ_DB !!!\n");
75 inp = fopen(FILE_IN, "r");
77 printf("Input file >>inPhys.dat<< not found !!!\n");
81 while((c=getc(inp))!=EOF) {
83 case 'a': {fscanf(inp, "%d", &ccbx ); break;} //N of X bins hCFD1_CFD
84 case 'b': {fscanf(inp, "%f", &cclx ); break;} //Low x hCFD1_CFD
85 case 'c': {fscanf(inp, "%f", &ccmx ); break;} //High x hCFD1_CFD
86 // case 'd': {fscanf(inp, "%d", &cbx ); break;} //N of X bins hCFD
87 // case 'e': {fscanf(inp, "%f", &clx ); break;} //Low x hCFD
88 // case 'f': {fscanf(inp, "%f", &cmx ); break;} //High x hCFD
94 printf("Wrong number of arguments\n");
99 /* define data source : this is argument 1 */
100 status=monitorSetDataSource( argv[1] );
102 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
107 /* declare monitoring program */
108 status=monitorDeclareMp( __FILE__ );
110 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
115 /* define wait event timeout - 1s max */
117 monitorSetNoWaitNetworkTimeout(1000);
120 /* log start of process */
121 printf("T0 monitoring program started\n");
123 // Allocation of histograms - start
125 TH1F *hCFD1minCFD[24];
127 for(Int_t ic=0; ic<24; ic++) {
128 hCFD1minCFD[ic] = new TH1F(Form("CFD1-CFD%d",ic+1),"CFD-CFD",ccbx,cclx,ccmx);
131 // Allocation of histograms - end
134 /* main loop (infinite) */
136 struct eventHeaderStruct *event;
137 eventTypeType eventT;
139 /* check shutdown condition */
140 if (daqDA_checkShutdown()) {break;}
142 /* get next event (blocking call until timeout) */
143 status=monitorGetEventDynamic((void **)&event);
144 if (status==(int)MON_ERR_EOF) {
145 printf ("End of File detected\n");
146 break; /* end of monitoring file has been reached */
150 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
154 /* retry if got no event */
159 /* use event - here, just write event id to result file */
160 eventT=event->eventType;
162 switch (event->eventType){
171 // case CALIBRATION_EVENT:
175 printf("First event - %i\n",iev);
178 // Initalize raw-data reading and decoding
179 AliRawReader *reader = new AliRawReaderDate((void*)event);
181 // Enable the following two lines in case of real-data
182 reader->RequireHeader(kTRUE);
183 AliT0RawReader *start = new AliT0RawReader(reader, kTRUE);
186 Int_t allData[105][5];
187 for(Int_t i0=0;i0<105;i0++)
188 for(Int_t j0=0;j0<5;j0++)
192 for (Int_t i=0; i<105; i++) {
193 for(Int_t iHit=0;iHit<5;iHit++){
194 allData[i][iHit]= start->GetData(i,iHit);
199 printf("No T0 data found!!!\n");
201 // Fill the histograms
203 for (Int_t ik = 0; ik<24; ik++)
204 for (Int_t iHt=0; iHt<1; iHt++){
205 if(allData[ik+1][iHt]!=0 ){
207 hCFD1minCFD[ik]->Fill(allData[ik+1][iHt]-allData[1][iHt]);
210 hCFD1minCFD[ik]->Fill(allData[ik+45][iHt]-allData[57][iHt]);
218 // End of fill histograms
225 /* exit when last event received, no need to wait for TERM signal */
226 if (eventT==END_OF_RUN) {
227 printf("EOR event detected\n");
228 printf("Number of events processed - %i\n ",iev);
232 printf("After loop, before writing histos\n");
233 // write a file with the histograms
234 TFile *hist = new TFile(FILE_OUT,"RECREATE");
236 for(Int_t j=0;j<24;j++){
237 hCFD1minCFD[j]->Write();
244 /* export file to FXS */
245 if (daqDA_FES_storeFile(FILE_OUT, "PHYSICS")) {