]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/TPCPULSERda.cxx
moved component registration to agent; added component configuration/initialization...
[u/mrichter/AliRoot.git] / TPC / TPCPULSERda.cxx
1 /*
2 TPC DA for online calibration
3
4 Contact: Haavard.Helstrup@cern.ch
5 Link:
6 Run Type: PULSER_RUN
7 DA Type: LDC
8 Number of events needed: 100
9 Input Files: 
10 Output Files: tpcPulser.root, to be exported to the DAQ FXS
11 Trigger types used: CALIBRATION_EVENT
12
13 */
14
15 /*
16
17 TPCda_pulser.cxx - calibration algorithm for TPC pulser events
18
19 10/06/2007  sylvain.chapeland@cern.ch :  first version - clean skeleton based on DAQ DA case1
20 30/09/2007  haavard.helstrup@cern.ch  :  created pulser DA based on pedestal code
21
22 contact: marian.ivanov@cern.ch
23
24
25 This process reads RAW data from the files provided as command line arguments
26 and save results in a file (named from RESULT_FILE define - see below).
27
28 */
29
30 #define RESULT_FILE "tpcPulser.root"
31
32
33 #include <daqDA.h>
34 #include "event.h"
35 #include "monitor.h"
36 #include <stdio.h>
37 #include <stdlib.h>
38
39 //
40 //Root includes
41 //
42 #include <TFile.h>
43 #include "TROOT.h"
44 #include "TPluginManager.h"
45 //
46 //AliRoot includes
47 //
48 #include "AliRawReader.h"
49 #include "AliRawReaderDate.h"
50 #include "AliTPCRawStream.h"
51 #include "AliTPCROC.h"
52 #include "AliTPCCalROC.h"
53 #include "AliTPCCalPad.h"
54 #include "AliMathBase.h"
55 #include "TTreeStream.h"
56
57 //
58 // TPC calibration algorithm includes
59 //
60 #include "AliTPCCalibPulser.h"
61
62
63
64
65 /* Main routine
66       Arguments: list of DATE raw data files
67 */
68 int main(int argc, char **argv) {
69
70  gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
71                                          "*",
72                                          "TStreamerInfo",
73                                          "RIO",
74                                          "TStreamerInfo()");
75
76
77   int i,status;
78   AliTPCCalibPulser calibPulser;   // pedestal and noise calibration
79
80   if (argc<2) {
81     printf("Wrong number of arguments\n");
82     return -1;
83   }
84
85
86   /* log start of process */
87   printf("TPC Pulser DA started - %s\n",__FILE__);
88
89   /* set time bin range */
90   calibPulser.SetRangeTime(400,500);
91
92   /* declare monitoring program */
93   status=monitorDeclareMp( __FILE__ );
94   if (status!=0) {
95     printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
96     return -1;
97   }
98
99
100   /* loop over RAW data files */
101   int nevents=0;
102   for(i=1;i<argc;i++) {
103
104     /* define data source : this is argument i */
105     printf("Processing file %s\n", argv[i]);
106     status=monitorSetDataSource( argv[i] );
107     if (status!=0) {
108       printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
109       return -1;
110     }
111
112     /* read until EOF */
113     while (true) {
114       struct eventHeaderStruct *event;
115
116       /* check shutdown condition */
117       if (daqDA_checkShutdown()) {break;}
118
119       /* get next event (blocking call until timeout) */
120       status=monitorGetEventDynamic((void **)&event);
121       if (status==MON_ERR_EOF) {
122         printf ("End of File %d detected\n",i);
123         break; /* end of monitoring file has been reached */
124       }
125
126       if (status!=0) {
127         printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
128         break;
129       }
130
131       /* retry if got no event */
132       if (event==NULL) {
133         continue;
134       }
135       nevents++;
136
137       //  Pulser calibration
138
139       AliRawReader *rawReader = new AliRawReaderDate((void*)event);
140 //      calibPulser.ProcessEvent(rawReader);
141       calibPulser.ProcessEventFast(rawReader);
142       delete rawReader;
143
144       /* free resources */
145       free(event);
146     }
147   }
148
149   calibPulser.Analyse(); 
150   printf ("%d events processed\n",nevents);
151
152   TFile * fileTPC = new TFile (RESULT_FILE,"recreate");
153   calibPulser.Write("calibPulser");
154   delete fileTPC;
155   printf("Wrote %s\n",RESULT_FILE);
156
157   /* store the result file on FES */
158
159   status=daqDA_FES_storeFile(RESULT_FILE,RESULT_FILE);
160   if (status) {
161     status = -2;
162   }
163
164   return status;
165 }