]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/TRDPEDESTALda.cxx
added protection
[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"
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
162a3e73 77 //AliCDBManager *man = AliCDBManager::Instance();
78 //man->SetDefaultStorage("local://$ALICE_ROOT");
79 //man->SetRun(0);
6ace5fe2 80 // AliTRDCalibPadStatus object
81 AliTRDCalibPadStatus calipad = AliTRDCalibPadStatus();
82 Bool_t passpadstatus = kTRUE;
83
84
85 /*see the time*/
86 TStopwatch timer;
87 timer.Start();
f222df8d 88
162a3e73 89 // setting
90 // AliTRDrawStreamTB::SetNoDebug();
91 AliTRDrawStreamTB::SetNoErrorWarning();
92 AliTRDrawStreamTB::SetForceCleanDataOnly();
93 AliTRDrawStreamTB::AllowCorruptedData();
94 //AliTRDrawStreamTB::SetSkipCDH();
95 //AliTRDrawStreamTB::SetExtraWordsFix();
96 //AliTRDrawStreamTB::EnableDebugStream();
97 //AliTRDrawStreamTB::SetDumpHead(320);
98 //AliTRDrawStreamTB::SetDumpHead(80);
6ace5fe2 99
100 /* read the data files */
101 int n;
102 for (n=1;n<argc;n++) {
103
104 /* define data source : this is argument i */
105 printf("Processing file %s\n",argv[n]);
106 status=monitorSetDataSource( argv[n] );
107 if (status!=0) {
108 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
109 return -1;
110 }
111
112 /* read the file until EOF */
113 for(;;) {
114 struct eventHeaderStruct *event;
115
116 /* get next event */
117 status=monitorGetEventDynamic((void **)&event);
118 if (status==MON_ERR_EOF) {
119 printf("End of File %d detected\n",n);
120 break; /* end of monitoring file has been reached */
121 }
122 if (status!=0) {
123 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
124 break;
125 }
126
127 /* retry if got no event */
128 if (event==NULL) {
129 break;
130 }
131
132 if(passpadstatus){
133
134 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
f222df8d 135 rawReader->Select("TRD");
80cb9622 136 AliTRDrawStreamTB *trdRawStream = new AliTRDrawStreamTB((AliRawReader *)rawReader);
f222df8d 137 //trdRawStream->Init();
6ace5fe2 138 if(!calipad.ProcessEvent(trdRawStream,(Bool_t)nevents_total)) passpadstatus = kFALSE;
139 nevents++;
140 delete trdRawStream;
141 delete rawReader;
142
143 }
144
145 nevents_total++;
146
147 /* free resources */
148 free(event);
149 }
150 }
151
152
153 /* report progress */
154 printf("%d events processed and %d used\n",nevents_total,nevents);
155
156 /*see the time*/
157 timer.Stop();
158 timer.Print();
159
160 /* write file in any case to see what happens in case of problems*/
289cc637 161 /*see the time*/
162 TStopwatch timer1;
163 timer1.Start();
6ace5fe2 164 TFile *fileTRD = new TFile(RESULT_FILE,"recreate");
289cc637 165 calipad.AnalyseHisto();
6ace5fe2 166 calipad.Write("calibpadstatus");
167 fileTRD->Close();
168 printf("Wrote local file %s\n",RESULT_FILE);
289cc637 169 /*see the time*/
170 timer1.Stop();
171 timer1.Print();
6ace5fe2 172
173 /* store the result file on FES */
174 status=daqDA_FES_storeFile(RESULT_FILE,RESULT_FILE);
175 if (status) {
176 printf("Failed to export file : %d\n",status);
177 return -1;
178 }
179
180
181 /* report progress */
182 daqDA_progressReport(100);
183
184
185 return status;
186}