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