]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/TRDPEDESTALda.cxx
Test beam raw data reading
[u/mrichter/AliRoot.git] / TRD / TRDPEDESTALda.cxx
CommitLineData
6ace5fe2 1/*
2
b770893d 3- "Contact: r.bailhache@gsi.de"
4- "Link: http://www-linux.gsi.de/~bailhach/PEDESTAL/raw.root.date"
5- "Run Type: dedicated pedestals run"
6- "DA Type: LDC"
7- "Number of events needed: 100"
8- "Input Files: no config files, no previous result files, RAW DATA files from DDL = 1024 to DDL = 1041 included"
9- "Output Files: trdCalibration.root, trdCalibration.root, no persitent file over runs"
10- "Trigger types used: PEDESTAL_RUN"
6ace5fe2 11
12*/
13
14#define RESULT_FILE "trdCalibration.root"
15
16extern "C" {
17#include <daqDA.h>
18}
19
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 <TStopwatch.h>
30
31//
32// AliRoot includes
33//
34#include "AliRawReader.h"
35#include "AliRawReaderDate.h"
289cc637 36#include "AliTRDRawStreamV2.h"
6ace5fe2 37#include "AliCDBManager.h"
38//
39// AliRoot TRD calib classes
40//
41#include "AliTRDCalibPadStatus.h"
42
43
44/* Main routine
45 Arguments: list of DATE raw data files
46*/
47int main(int argc, char **argv) {
48
49 int status;
50
51
52 /* log start of process */
53 printf("TRD DA PEDESTAL started\n");
54
55
56 /* check that we got some arguments = list of files */
57 if (argc<2) {
58 printf("Wrong number of arguments\n");
59 return -1;
60 }
61
62
63 /* copy locally a file from daq detector config db */
64 //status=daqDA_DB_getFile("myconfig","./myconfig.txt");
65 //if (status) {
66 // printf("Failed to get config file : %d\n",status);
67 // return -1;
68 //}
69 /* and possibly use it */
70
71
72 /* init some counters */
73 int nevents_total=0;
74 int nevents =0;
75
76 //Instance of AliCDBManager: needed by AliTRDRawStream
77 AliCDBManager *man = AliCDBManager::Instance();
78 man->SetDefaultStorage("local://$ALICE_ROOT");
79 man->SetRun(0);
80 // AliTRDCalibPadStatus object
81 AliTRDCalibPadStatus calipad = AliTRDCalibPadStatus();
82 Bool_t passpadstatus = kTRUE;
83
84
85 /*see the time*/
86 TStopwatch timer;
87 timer.Start();
88
89
90 /* read the data files */
91 int n;
92 for (n=1;n<argc;n++) {
93
94 /* define data source : this is argument i */
95 printf("Processing file %s\n",argv[n]);
96 status=monitorSetDataSource( argv[n] );
97 if (status!=0) {
98 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
99 return -1;
100 }
101
102 /* read the file until EOF */
103 for(;;) {
104 struct eventHeaderStruct *event;
105
106 /* get next event */
107 status=monitorGetEventDynamic((void **)&event);
108 if (status==MON_ERR_EOF) {
109 printf("End of File %d detected\n",n);
110 break; /* end of monitoring file has been reached */
111 }
112 if (status!=0) {
113 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
114 break;
115 }
116
117 /* retry if got no event */
118 if (event==NULL) {
119 break;
120 }
121
122 if(passpadstatus){
123
124 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
289cc637 125 AliTRDRawStreamV2 *trdRawStream = new AliTRDRawStreamV2((AliRawReader *)rawReader);
6ace5fe2 126 if(!calipad.ProcessEvent(trdRawStream,(Bool_t)nevents_total)) passpadstatus = kFALSE;
127 nevents++;
128 delete trdRawStream;
129 delete rawReader;
130
131 }
132
133 nevents_total++;
134
135 /* free resources */
136 free(event);
137 }
138 }
139
140
141 /* report progress */
142 printf("%d events processed and %d used\n",nevents_total,nevents);
143
144 /*see the time*/
145 timer.Stop();
146 timer.Print();
147
148 /* write file in any case to see what happens in case of problems*/
289cc637 149 /*see the time*/
150 TStopwatch timer1;
151 timer1.Start();
6ace5fe2 152 TFile *fileTRD = new TFile(RESULT_FILE,"recreate");
289cc637 153 calipad.AnalyseHisto();
6ace5fe2 154 calipad.Write("calibpadstatus");
155 fileTRD->Close();
156 printf("Wrote local file %s\n",RESULT_FILE);
289cc637 157 /*see the time*/
158 timer1.Stop();
159 timer1.Print();
6ace5fe2 160
161 /* store the result file on FES */
162 status=daqDA_FES_storeFile(RESULT_FILE,RESULT_FILE);
163 if (status) {
164 printf("Failed to export file : %d\n",status);
165 return -1;
166 }
167
168
169 /* report progress */
170 daqDA_progressReport(100);
171
172
173 return status;
174}