]>
Commit | Line | Data |
---|---|---|
6ace5fe2 | 1 | /* |
2 | ||
3 | TRDPEDESTALda.cxx - calibration algorithm for the pedestal to be run in parallel on the LDCs | |
4 | DAcase1.c | |
5 | ||
6 | ||
7 | AliTRDCalibPadStatus - pad status calibration | |
8 | ||
9 | This program reads the DAQ data files passed as argument using the monitoring library. | |
10 | ||
11 | It fills a TRD calib object AliTRDCalibPadStatus and write it in a local file trdPedestal.root before | |
12 | exporting it to the file exchange server. | |
13 | ||
14 | Messages on stdout are exported to DAQ log system. | |
15 | ||
16 | contact: alice-datesupport@cern.ch | |
17 | ||
18 | */ | |
19 | ||
20 | #define RESULT_FILE "trdCalibration.root" | |
21 | ||
22 | extern "C" { | |
23 | #include <daqDA.h> | |
24 | } | |
25 | ||
26 | #include "event.h" | |
27 | #include "monitor.h" | |
28 | #include <stdio.h> | |
29 | #include <stdlib.h> | |
30 | ||
31 | // | |
32 | // Root includes | |
33 | // | |
34 | #include <TFile.h> | |
35 | #include <TStopwatch.h> | |
36 | ||
37 | // | |
38 | // AliRoot includes | |
39 | // | |
40 | #include "AliRawReader.h" | |
41 | #include "AliRawReaderDate.h" | |
289cc637 | 42 | #include "AliTRDRawStreamV2.h" |
6ace5fe2 | 43 | #include "AliCDBManager.h" |
44 | // | |
45 | // AliRoot TRD calib classes | |
46 | // | |
47 | #include "AliTRDCalibPadStatus.h" | |
48 | ||
49 | ||
50 | /* Main routine | |
51 | Arguments: list of DATE raw data files | |
52 | */ | |
53 | int main(int argc, char **argv) { | |
54 | ||
55 | int status; | |
56 | ||
57 | ||
58 | /* log start of process */ | |
59 | printf("TRD DA PEDESTAL started\n"); | |
60 | ||
61 | ||
62 | /* check that we got some arguments = list of files */ | |
63 | if (argc<2) { | |
64 | printf("Wrong number of arguments\n"); | |
65 | return -1; | |
66 | } | |
67 | ||
68 | ||
69 | /* copy locally a file from daq detector config db */ | |
70 | //status=daqDA_DB_getFile("myconfig","./myconfig.txt"); | |
71 | //if (status) { | |
72 | // printf("Failed to get config file : %d\n",status); | |
73 | // return -1; | |
74 | //} | |
75 | /* and possibly use it */ | |
76 | ||
77 | ||
78 | /* init some counters */ | |
79 | int nevents_total=0; | |
80 | int nevents =0; | |
81 | ||
82 | //Instance of AliCDBManager: needed by AliTRDRawStream | |
83 | AliCDBManager *man = AliCDBManager::Instance(); | |
84 | man->SetDefaultStorage("local://$ALICE_ROOT"); | |
85 | man->SetRun(0); | |
86 | // AliTRDCalibPadStatus object | |
87 | AliTRDCalibPadStatus calipad = AliTRDCalibPadStatus(); | |
88 | Bool_t passpadstatus = kTRUE; | |
89 | ||
90 | ||
91 | /*see the time*/ | |
92 | TStopwatch timer; | |
93 | timer.Start(); | |
94 | ||
95 | ||
96 | /* read the data files */ | |
97 | int n; | |
98 | for (n=1;n<argc;n++) { | |
99 | ||
100 | /* define data source : this is argument i */ | |
101 | printf("Processing file %s\n",argv[n]); | |
102 | status=monitorSetDataSource( argv[n] ); | |
103 | if (status!=0) { | |
104 | printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status)); | |
105 | return -1; | |
106 | } | |
107 | ||
108 | /* read the file until EOF */ | |
109 | for(;;) { | |
110 | struct eventHeaderStruct *event; | |
111 | ||
112 | /* get next event */ | |
113 | status=monitorGetEventDynamic((void **)&event); | |
114 | if (status==MON_ERR_EOF) { | |
115 | printf("End of File %d detected\n",n); | |
116 | break; /* end of monitoring file has been reached */ | |
117 | } | |
118 | if (status!=0) { | |
119 | printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status)); | |
120 | break; | |
121 | } | |
122 | ||
123 | /* retry if got no event */ | |
124 | if (event==NULL) { | |
125 | break; | |
126 | } | |
127 | ||
128 | if(passpadstatus){ | |
129 | ||
130 | AliRawReader *rawReader = new AliRawReaderDate((void*)event); | |
289cc637 | 131 | AliTRDRawStreamV2 *trdRawStream = new AliTRDRawStreamV2((AliRawReader *)rawReader); |
6ace5fe2 | 132 | if(!calipad.ProcessEvent(trdRawStream,(Bool_t)nevents_total)) passpadstatus = kFALSE; |
133 | nevents++; | |
134 | delete trdRawStream; | |
135 | delete rawReader; | |
136 | ||
137 | } | |
138 | ||
139 | nevents_total++; | |
140 | ||
141 | /* free resources */ | |
142 | free(event); | |
143 | } | |
144 | } | |
145 | ||
146 | ||
147 | /* report progress */ | |
148 | printf("%d events processed and %d used\n",nevents_total,nevents); | |
149 | ||
150 | /*see the time*/ | |
151 | timer.Stop(); | |
152 | timer.Print(); | |
153 | ||
154 | /* write file in any case to see what happens in case of problems*/ | |
289cc637 | 155 | /*see the time*/ |
156 | TStopwatch timer1; | |
157 | timer1.Start(); | |
6ace5fe2 | 158 | TFile *fileTRD = new TFile(RESULT_FILE,"recreate"); |
289cc637 | 159 | calipad.AnalyseHisto(); |
6ace5fe2 | 160 | calipad.Write("calibpadstatus"); |
161 | fileTRD->Close(); | |
162 | printf("Wrote local file %s\n",RESULT_FILE); | |
289cc637 | 163 | /*see the time*/ |
164 | timer1.Stop(); | |
165 | timer1.Print(); | |
6ace5fe2 | 166 | |
167 | /* store the result file on FES */ | |
168 | status=daqDA_FES_storeFile(RESULT_FILE,RESULT_FILE); | |
169 | if (status) { | |
170 | printf("Failed to export file : %d\n",status); | |
171 | return -1; | |
172 | } | |
173 | ||
174 | ||
175 | /* report progress */ | |
176 | daqDA_progressReport(100); | |
177 | ||
178 | ||
179 | return status; | |
180 | } |