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