2 TOF DA for online calibration
4 Contact: Michal.Oledzki@cern.ch
5 Link: www.if.pw.edu.pl:/~oledzki
8 Number of events needed: depending on the run, being run-level
10 Output Files: daLaser.root, to be exported to the DAQ FXS
11 Trigger types used: PHYSICS_EVENT
16 #define FILE_OUT "daLaser.root"
22 #include <Riostream.h>
27 #include <AliRawReaderDate.h>
28 #include <AliRawReader.h>
29 #include <AliT0RawReader.h>
36 #include "TBenchmark.h"
43 #include "TSpectrum.h"
44 #include "TVirtualFitter.h"
49 1- monitoring data source
51 int main(int argc, char **argv) {
56 printf("Wrong number of arguments\n");
61 /* define data source : this is argument 1 */
62 status=monitorSetDataSource( argv[1] );
64 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
69 /* declare monitoring program */
70 status=monitorDeclareMp( __FILE__ );
72 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
77 /* define wait event timeout - 1s max */
79 monitorSetNoWaitNetworkTimeout(1000);
82 /* log start of process */
83 printf("T0 monitoring program started\n");
85 // Allocation of histograms - start
87 TH2F *hCFD_QTC[24]; TH2F *hCFD_LED[24];
88 Char_t buf1[10], buf2[10],buf3[10],buf4[10];
90 for(Int_t ic=0; ic<24; ic++) {
91 sprintf(buf1,"CFD_QTC%i",ic+1);
92 sprintf(buf2,"CFD_LED%i",ic+1);
94 hCFD_QTC[ic] = new TH2F(buf1,"CFD_QTC",8000,0.5,8000.5,2000,10000.5,20000.5);
95 hCFD_LED[ic] = new TH2F(buf2,"CFD_LED",1000,-500.0,500.0,100,14600.0,14700.0);
97 sprintf(buf3,"T0_C_%i_CFD",ic+1);
98 hCFD[ic] = new TH1F(buf3,"CFD", 30000,0., 30000.);
101 sprintf(buf4,"T0_A_%i_CFD",ic-11);
102 hCFD[ic] = new TH1F(buf4,"CFD", 30000,0., 30000.);
106 // Allocation of histograms - end
109 /* main loop (infinite) */
111 struct eventHeaderStruct *event;
112 eventTypeType eventT;
114 /* check shutdown condition */
115 if (daqDA_checkShutdown()) {break;}
117 /* get next event (blocking call until timeout) */
118 status=monitorGetEventDynamic((void **)&event);
119 if (status==(int)MON_ERR_EOF) {
120 printf ("End of File detected\n");
121 break; /* end of monitoring file has been reached */
125 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
129 /* retry if got no event */
136 /* use event - here, just write event id to result file */
137 eventT=event->eventType;
139 switch (event->eventType){
147 // case CALIBRATION_EVENT:
149 printf(" event number = %i \n",iev);
152 // Initalize raw-data reading and decoding
153 AliRawReader *reader = new AliRawReaderDate((void*)event);
155 // Enable the following two lines in case of real-data
156 // reader->LoadEquipmentIdsMap("T0map.txt");
157 // reader->RequireHeader(kFALSE);
158 // reader->RequireHeader(kTRUE);
159 AliT0RawReader *start = new AliT0RawReader(reader, kTRUE);
162 Int_t allData[105][5];
163 for(Int_t i0=0;i0<105;i0++)
164 for(Int_t j0=0;j0<5;j0++)
168 for (Int_t i=0; i<105; i++) {
169 for(Int_t iHit=0;iHit<5;iHit++){
170 allData[i][iHit]= start->GetData(i,iHit);
174 printf("No T0 data found!!\n");
176 // Fill the histograms
178 for (Int_t ik = 0; ik<24; ik+=2)
179 for (Int_t iHt=0; iHt<5; iHt++){
181 if((allData[cc+1][iHt]-allData[0][0])>0){
182 hCFD[cc]->Fill(allData[cc+1][iHt]-allData[0][0]);
184 if(allData[ik+25][iHt]!=0 && allData[ik+26][iHt]!=0 && allData[cc+1][iHt]!=0){
185 hCFD_QTC[cc]->Fill((allData[ik+25][iHt]-allData[ik+26][iHt]) , (allData[cc+1][iHt]-allData[0][0]));
187 if(allData[cc+13][iHt]!=0 && allData[cc+1][iHt]!=0){
188 hCFD_LED[cc]->Fill(allData[cc+13][iHt]-allData[cc+1][iHt],allData[cc+1][iHt]-allData[0][0]);
192 for (Int_t ik = 24; ik<48; ik+=2)
193 for (Int_t iHt=0; iHt<5; iHt++){
195 if((allData[cc+45][iHt]-allData[0][0])>0){
196 hCFD[cc]->Fill(allData[cc+45][iHt]-allData[0][0]);
199 if(allData[ik+57][iHt]!=0 && allData[ik+58][iHt]!=0){
200 if(allData[cc+45][iHt]!=0)
201 hCFD_QTC[cc]->Fill(allData[ik+57][iHt]-allData[ik+58][iHt],allData[cc+45][iHt]-allData[0][0]);
203 if(allData[cc+57][iHt]!=0 && allData[cc+45][iHt]!=0){
204 hCFD_LED[cc]->Fill(allData[cc+57][iHt]-allData[cc+45][iHt],allData[cc+45][iHt]-allData[0][0]);
212 // End of fill histograms
221 /* exit when last event received, no need to wait for TERM signal */
222 if (eventT==END_OF_RUN) {
223 printf("EOR event detected\n");
227 printf("After loop, before writing histos\n");
228 // write a file with the histograms
229 TFile *hist = new TFile(FILE_OUT,"RECREATE");
231 for(Int_t j=0;j<24;j++){
232 hCFD_QTC[j]->Write();
233 hCFD_LED[j]->Write();