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