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
15 #define FILE_OUT "daPhys.root"
16 #define FILE_IN "inPhys.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"
43 #include "TSpectrum.h"
44 #include "TVirtualFitter.h"
46 float clx,cmx,cclx,ccmx;
50 1- monitoring data source
52 int main(int argc, char **argv) {
57 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
65 inp = fopen(FILE_IN, "r");
66 while((c=getc(inp))!=EOF) {
68 case 'a': {fscanf(inp, "%d", &ccbx ); break;} //N of X bins hCFD1_CFD
69 case 'b': {fscanf(inp, "%f", &cclx ); break;} //Low x hCFD1_CFD
70 case 'c': {fscanf(inp, "%f", &ccmx ); break;} //High x hCFD1_CFD
71 case 'd': {fscanf(inp, "%d", &cbx ); break;} //N of X bins hCFD
72 case 'e': {fscanf(inp, "%f", &clx ); break;} //Low x hCFD
73 case 'f': {fscanf(inp, "%f", &cmx ); break;} //High x hCFD
79 printf("Wrong number of arguments\n");
84 /* define data source : this is argument 1 */
85 status=monitorSetDataSource( argv[1] );
87 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
92 /* declare monitoring program */
93 status=monitorDeclareMp( __FILE__ );
95 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
100 /* define wait event timeout - 1s max */
102 monitorSetNoWaitNetworkTimeout(1000);
105 /* log start of process */
106 printf("T0 monitoring program started\n");
108 // Allocation of histograms - start
113 for(Int_t ic=0; ic<24; ic++) {
115 hCFD1_CFD[ic] = new TH1F(Form("CFD1-CFD%d",ic+1),"CFD-CFD",ccbx,cclx,ccmx);
116 hCFD[ic] = new TH1F(Form("CFD%i",ic+1),"CFD",cbx,clx,cmx);
119 hCFD1_CFD[ic] = new TH1F(Form("CFD13-CFD%i",ic+1),"CFD-CFD",ccbx,cclx,ccmx);
120 hCFD[ic] = new TH1F(Form("CFD%i",ic+1),"CFD",cbx,clx,cmx);
124 // Allocation of histograms - end
127 /* main loop (infinite) */
129 struct eventHeaderStruct *event;
130 eventTypeType eventT;
132 /* check shutdown condition */
133 if (daqDA_checkShutdown()) {break;}
135 /* get next event (blocking call until timeout) */
136 status=monitorGetEventDynamic((void **)&event);
137 if (status==(int)MON_ERR_EOF) {
138 printf ("End of File detected\n");
139 break; /* end of monitoring file has been reached */
143 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
147 /* retry if got no event */
154 /* use event - here, just write event id to result file */
155 eventT=event->eventType;
157 switch (event->eventType){
166 printf(" event number = %i \n",iev);
169 // Initalize raw-data reading and decoding
170 AliRawReader *reader = new AliRawReaderDate((void*)event);
172 // Enable the following two lines in case of real-data
173 // reader->LoadEquipmentIdsMap("T0map.txt");
174 // reader->RequireHeader(kFALSE);
175 // reader->RequireHeader(kTRUE);
176 AliT0RawReader *start = new AliT0RawReader(reader, kTRUE);
179 Int_t allData[105][5];
180 for(Int_t i0=0;i0<105;i0++)
181 for(Int_t j0=0;j0<5;j0++)
186 for (Int_t i=0; i<105; i++) {
187 for(Int_t iHit=0;iHit<5;iHit++){
188 allData[i][iHit]= start->GetData(i,iHit);
192 printf("No T0 data found!!\n");
194 // Fill the histograms
196 for (Int_t ik = 0; ik<24; ik+=2)
197 for (Int_t iHt=0; iHt<5; iHt++){
199 if(allData[cc+1][iHt]!=0 ){
200 hCFD1_CFD[cc]->Fill(allData[cc+1][iHt]-allData[1][iHt]);
201 hCFD[cc]->Fill(allData[cc+13][iHt]);
205 for (Int_t ik = 24; ik<48; ik+=2)
206 for (Int_t iHt=0; iHt<5; iHt++){
208 if(allData[cc+45][iHt]!=0 ){
209 hCFD1_CFD[cc]->Fill(allData[cc+45][iHt]-allData[57][iHt]);
210 hCFD[cc]->Fill(allData[cc+45][iHt]);
217 // End of fill histograms
226 /* exit when last event received, no need to wait for TERM signal */
227 if (eventT==END_OF_RUN) {
228 printf("EOR event detected\n");
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 hCFD1_CFD[j]->Write();
245 /* export file to FXS */
246 if (daqDA_FES_storeFile(FILE_OUT, FILE_OUT)) {