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: inCosmicLaser.dat, external parameters
10 Output Files: daCosmicLaser.root, to be exported to the DAQ FXS
11 Trigger types used: PHYSICS_EVENT
15 #define FILE_OUT "daCosmic.root"
17 //author Michal Oledzki
18 //DA for old cosmic runs
21 #define FILE_IN "inCosmic.dat"
26 #include <Riostream.h>
31 #include <AliRawReaderDate.h>
32 #include <AliRawReader.h>
33 #include <AliT0RawReader.h>
37 #include "TPluginManager.h"
42 #include "TBenchmark.h"
49 #include "TSpectrum.h"
50 #include "TVirtualFitter.h"
51 //#include "TProfile.h"
56 1- monitoring data source
58 int main(int argc, char **argv) {
62 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
68 if(daqDA_DB_getFile(FILE_IN, FILE_IN)){
69 printf("Couldn't get input file >>inCosmic.dat<< from DAQ_DB !!!\n");
76 inp = fopen(FILE_IN, "r");
78 printf("Input file >>inCosmic.dat<< not found !!!\n");
82 while((c=getc(inp))!=EOF) {
84 case 'a': {fscanf(inp, "%d", &kCcbx ); break;} //N of X bins hCFD1_CFD
85 case 'b': {fscanf(inp, "%f", &kCclx ); break;} //Low x hCFD1_CFD
86 case 'c': {fscanf(inp, "%f", &kCcmx ); break;} //High x hCFD1_CFD
92 printf("Wrong number of arguments\n");
97 /* define data source : this is argument 1 */
98 status=monitorSetDataSource( argv[1] );
100 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
105 /* declare monitoring program */
106 status=monitorDeclareMp( __FILE__ );
108 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
113 /* define wait event timeout - 1s max */
115 monitorSetNoWaitNetworkTimeout(1000);
118 /* log start of process */
119 printf("T0 monitoring program started\n");
121 // Allocation of histograms - start
122 TH1F *hCFD1minCFD[24];
124 for(Int_t ic=0; ic<24; ic++) {
125 hCFD1minCFD[ic] = new TH1F(Form("CFD1-CFD%d",ic+1),"CFD-CFD",kCcbx,kCclx,kCcmx);
128 // Allocation of histograms - end
131 /* main loop (infinite) */
133 struct eventHeaderStruct *event;
134 eventTypeType eventT;
136 /* check shutdown condition */
137 if (daqDA_checkShutdown()) {break;}
139 /* get next event (blocking call until timeout) */
140 status=monitorGetEventDynamic((void **)&event);
141 if (status==(int)MON_ERR_EOF) {
142 printf ("End of File detected\n");
143 break; /* end of monitoring file has been reached */
147 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
151 /* retry if got no event */
158 /* use event - here, just write event id to result file */
159 eventT=event->eventType;
161 switch (event->eventType){
169 case CALIBRATION_EVENT:
170 // case PHYSICS_EVENT:
174 printf("First event - %i\n",iev);
177 // Initalize raw-data reading and decoding
178 AliRawReader *reader = new AliRawReaderDate((void*)event);
180 // Enable the following two lines in case of real-data
181 reader->RequireHeader(kTRUE);
182 AliT0RawReader *start = new AliT0RawReader(reader, kTRUE);
185 Int_t allData[105][5];
186 for(Int_t i0=0;i0<105;i0++)
187 for(Int_t j0=0;j0<5;j0++)
191 for (Int_t i=0; i<105; i++) {
192 for(Int_t iHit=0;iHit<5;iHit++){
193 allData[i][iHit]= start->GetData(i,iHit);
198 printf("No T0 data found!!!\n");
200 // Fill the histograms
202 for (Int_t ik = 0; ik<24; ik++)
203 for (Int_t iHt=0; iHt<5; iHt++){
204 if(allData[ik+1][iHt]!=0 ){
206 hCFD1minCFD[ik]->Fill(allData[ik+1][iHt]-allData[1][iHt]);
209 hCFD1minCFD[ik]->Fill(allData[ik+45][iHt]-allData[57][iHt]);
217 // End of fill histograms
224 /* exit when last event received, no need to wait for TERM signal */
225 if (eventT==END_OF_RUN) {
226 printf("EOR event detected\n");
227 printf("Number of events processed - %i\n ",iev);
231 printf("After loop, before writing histos\n");
232 // write a file with the histograms
233 TFile *hist = new TFile(FILE_OUT,"RECREATE");
235 for(Int_t j=0;j<24;j++){
236 hCFD1minCFD[j]->Write();
243 /* export file to FXS */
244 if (daqDA_FES_storeFile(FILE_OUT, "COSMIC")) {