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