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