13 #include <AliRawReaderDate.h>
14 #include <AliRawReader.h>
15 #include <AliT0RawReader.h>
16 #include <AliCDBManager.h>
23 #include "TBenchmark.h"
30 #include "TSpectrum.h"
31 #include "TVirtualFitter.h"
36 1- monitoring data source
38 int main(int argc, char **argv) {
43 printf("Wrong number of arguments\n");
48 /* define data source : this is argument 1 */
49 status=monitorSetDataSource( argv[1] );
51 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
56 /* declare monitoring program */
57 status=monitorDeclareMp( __FILE__ );
59 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
64 /* define wait event timeout - 1s max */
66 monitorSetNoWaitNetworkTimeout(1000);
69 /* log start of process */
70 printf("T0 monitoring program started\n");
72 // Allocation of histograms - start
74 TH2F *hCFD_QTC[24]; TH2F *hCFD_LED[24];
75 Char_t buf1[10], buf2[10],buf3[10],buf4[10];
77 for(Int_t ic=0; ic<24; ic++) {
78 sprintf(buf1,"CFD_QTC%i",ic+1);
79 sprintf(buf2,"CFD_LED%i",ic+1);
81 hCFD_QTC[ic] = new TH2F(buf1,"CFD_QTC",8000,0.5,8000.5,2000,10000.5,20000.5);
82 hCFD_LED[ic] = new TH2F(buf2,"CFD_LED",1000,-500.0,500.0,100,14600.0,14700.0);
84 sprintf(buf3,"T0_C_%i_CFD",ic+1);
85 hCFD[ic] = new TH1F(buf3,"CFD", 30000,0., 30000.);
88 sprintf(buf4,"T0_A_%i_CFD",ic-11);
89 hCFD[ic] = new TH1F(buf4,"CFD", 30000,0., 30000.);
93 // Allocation of histograms - end
96 /* main loop (infinite) */
98 struct eventHeaderStruct *event;
101 /* check shutdown condition */
102 if (daqDA_checkShutdown()) {break;}
104 /* get next event (blocking call until timeout) */
105 status=monitorGetEventDynamic((void **)&event);
106 if (status==(int)MON_ERR_EOF) {
107 printf ("End of File detected\n");
108 break; /* end of monitoring file has been reached */
112 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
116 /* retry if got no event */
123 /* use event - here, just write event id to result file */
124 eventT=event->eventType;
126 switch (event->eventType){
134 // case CALIBRATION_EVENT:
136 printf(" event number = %i \n",iev);
139 // Initalize raw-data reading and decoding
140 AliRawReader *reader = new AliRawReaderDate((void*)event);
142 // Enable the following two lines in case of real-data
143 // reader->LoadEquipmentIdsMap("T0map.txt");
144 // reader->RequireHeader(kFALSE);
145 // reader->RequireHeader(kTRUE);
146 AliT0RawReader *start = new AliT0RawReader(reader, kTRUE);
149 Int_t allData[105][5];
150 for(Int_t i0=0;i0<105;i0++)
151 for(Int_t j0=0;j0<5;j0++)
155 for (Int_t i=0; i<105; i++) {
156 for(Int_t iHit=0;iHit<5;iHit++){
157 allData[i][iHit]= start->GetData(i,iHit);
161 printf("No T0 data found!!\n");
163 // Fill the histograms
165 for (Int_t ik = 0; ik<24; ik+=2)
166 for (Int_t iHt=0; iHt<5; iHt++){
168 if((allData[cc+1][iHt]-allData[0][0])>0){
169 hCFD[cc]->Fill(allData[cc+1][iHt]-allData[0][0]);
171 if(allData[ik+25][iHt]!=0 && allData[ik+26][iHt]!=0 && allData[cc+1][iHt]!=0){
172 hCFD_QTC[cc]->Fill((allData[ik+25][iHt]-allData[ik+26][iHt]) , (allData[cc+1][iHt]-allData[0][0]));
174 if(allData[cc+13][iHt]!=0 && allData[cc+1][iHt]!=0){
175 hCFD_LED[cc]->Fill(allData[cc+13][iHt]-allData[cc+1][iHt],allData[cc+1][iHt]-allData[0][0]);
179 for (Int_t ik = 24; ik<48; ik+=2)
180 for (Int_t iHt=0; iHt<5; iHt++){
182 if((allData[cc+45][iHt]-allData[0][0])>0){
183 hCFD[cc]->Fill(allData[cc+45][iHt]-allData[0][0]);
186 if(allData[ik+57][iHt]!=0 && allData[ik+58][iHt]!=0){
187 if(allData[cc+45][iHt]!=0)
188 hCFD_QTC[cc]->Fill(allData[ik+57][iHt]-allData[ik+58][iHt],allData[cc+45][iHt]-allData[0][0]);
190 if(allData[cc+57][iHt]!=0 && allData[cc+45][iHt]!=0){
191 hCFD_LED[cc]->Fill(allData[cc+57][iHt]-allData[cc+45][iHt],allData[cc+45][iHt]-allData[0][0]);
199 // End of fill histograms
208 /* exit when last event received, no need to wait for TERM signal */
209 if (eventT==END_OF_RUN) {
210 printf("EOR event detected\n");
214 printf("After loop, before writing histos\n");
215 // write a file with the histograms
217 sprintf(filehist,"daLaser.root");
218 TFile *hist = new TFile(filehist,"RECREATE");
220 for(Int_t j=0;j<24;j++){
221 hCFD_QTC[j]->Write();
222 hCFD_LED[j]->Write();