]>
Commit | Line | Data |
---|---|---|
ef7aea93 | 1 | /* |
2 | ||
3 | Contact: r.bailhache@gsi.de | |
4 | Link: | |
5 | Reference run: 104892 | |
6 | Run Type: PHYSICS | |
7 | DA Type: MON | |
8 | Number of events needed: many | |
9 | Input Files: TRD raw files | |
10 | Output Files: trdCalibrationhcs.root | |
11 | Trigger types used: PHYSICS_EVENT | |
12 | ||
13 | */ | |
14 | ||
15 | #define RESULT_FILE "trdHalfChamberStatus.root" | |
16 | #define FILE_ID "HALFCHAMBERSTATUS" | |
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> | |
32 | #include "TROOT.h" | |
33 | #include "TPluginManager.h" | |
34 | // | |
35 | // AliRoot includes | |
36 | // | |
37 | #include "AliRawReader.h" | |
38 | #include "AliRawReaderDate.h" | |
39 | #include "AliTRDrawFastStream.h" | |
40 | #include "AliTRDrawStreamBase.h" | |
df7153c8 | 41 | #include "AliLog.h" |
ef7aea93 | 42 | //#include "AliCDBManager.h" |
43 | ||
44 | // | |
45 | //AMORE | |
46 | // | |
47 | #include <AmoreDA.h> | |
48 | ||
49 | // | |
50 | // AliRoot TRD calib classes | |
51 | // | |
52 | #include "AliTRDCalibChamberStatus.h" | |
53 | ||
54 | //functios, implementation below | |
55 | //void SendToAmoreDB(TObject *o, unsigned long32 runNb); | |
56 | ||
57 | /* Main routine | |
58 | Arguments: list of DATE raw data files | |
59 | */ | |
60 | int main(int argc, char **argv) { | |
61 | ||
62 | /* magic line from Rene */ | |
63 | gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo", | |
64 | "*", | |
65 | "TStreamerInfo", | |
66 | "RIO", | |
67 | "TStreamerInfo()"); | |
68 | ||
69 | int status; | |
70 | ||
71 | ||
72 | /* log start of process */ | |
73 | printf("TRD DA HALFCHAMBERSTATUS started\n"); | |
74 | ||
df7153c8 | 75 | if (argc!=2) { |
ef7aea93 | 76 | printf("Wrong number of arguments\n"); |
77 | return -1; | |
78 | } | |
79 | ||
80 | ||
df7153c8 | 81 | /* define data source : this is argument 1 */ |
82 | status=monitorSetDataSource( argv[1] ); | |
83 | if (status!=0) { | |
84 | printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status)); | |
85 | return -1; | |
86 | } | |
87 | ||
88 | ||
89 | /* declare monitoring program */ | |
90 | status=monitorDeclareMp( __FILE__ ); | |
91 | if (status!=0) { | |
92 | printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status)); | |
93 | return -1; | |
94 | } | |
95 | ||
96 | ||
97 | /* define wait event timeout - 1s max */ | |
98 | monitorSetNowait(); | |
99 | monitorSetNoWaitNetworkTimeout(1000); | |
ef7aea93 | 100 | |
101 | /* init some counters */ | |
102 | int nevents_total=0; | |
103 | int nevents =0; | |
104 | ||
105 | //Instance of AliCDBManager: needed by AliTRDRawStream | |
106 | //AliCDBManager *man = AliCDBManager::Instance(); | |
107 | //man->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); | |
108 | //man->SetRun(0); | |
109 | // AliTRDCalibPadStatus object | |
110 | AliTRDCalibChamberStatus calipad = AliTRDCalibChamberStatus(); | |
111 | calipad.Init(); | |
112 | //unsigned long32 runNb=0; //run number | |
113 | ||
114 | // setting | |
115 | AliTRDrawFastStream::DisableSkipData(); | |
df7153c8 | 116 | AliLog::SetGlobalLogLevel(AliLog::kFatal); |
117 | ||
118 | /* read the file until EOF */ | |
119 | for(;;) { | |
120 | struct eventHeaderStruct *event; | |
121 | eventTypeType eventT; | |
122 | ||
123 | /* check shutdown condition */ | |
124 | if (daqDA_checkShutdown()) {break;} | |
125 | ||
126 | /* get next event */ | |
127 | status=monitorGetEventDynamic((void **)&event); | |
128 | if (status==MON_ERR_EOF) { | |
129 | printf("End of File detected\n"); | |
130 | break; /* end of monitoring file has been reached */ | |
131 | } | |
ef7aea93 | 132 | if (status!=0) { |
df7153c8 | 133 | printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status)); |
134 | break; | |
ef7aea93 | 135 | } |
df7153c8 | 136 | |
137 | /* retry if got no event */ | |
138 | if (event==NULL) { | |
139 | continue; | |
140 | } | |
141 | ||
142 | /* use event - here, just write event id to result file */ | |
143 | eventT=event->eventType; | |
144 | ||
145 | if(eventT==PHYSICS_EVENT){ | |
ef7aea93 | 146 | |
df7153c8 | 147 | AliRawReader *rawReader = new AliRawReaderDate((void*)event); |
148 | rawReader->Select("TRD"); | |
149 | ||
150 | calipad.ProcessEvent((AliRawReader *) rawReader,nevents); | |
151 | nevents++; | |
152 | delete rawReader; | |
ef7aea93 | 153 | |
df7153c8 | 154 | } |
155 | ||
156 | nevents_total++; | |
157 | ||
158 | // get the run number | |
159 | //runNb = event->eventRunNb; | |
160 | ||
161 | /* free resources */ | |
162 | free(event); | |
163 | ||
164 | /* exit when last event received, no need to wait for TERM signal */ | |
165 | if (eventT==END_OF_RUN) { | |
166 | printf("EOR event detected\n"); | |
167 | break; | |
ef7aea93 | 168 | } |
169 | } | |
df7153c8 | 170 | |
ef7aea93 | 171 | |
172 | /* report progress */ | |
173 | printf("%d events processed and %d used\n",nevents_total,nevents); | |
df7153c8 | 174 | |
ef7aea93 | 175 | /* write file in any case to see what happens in case of problems*/ |
176 | TFile *fileTRD = new TFile(RESULT_FILE,"recreate"); | |
177 | calipad.AnalyseHisto(); | |
178 | calipad.Write("calibchamberstatus"); | |
179 | fileTRD->Close(); | |
180 | ||
181 | /* store the result file on FES */ | |
182 | status=daqDA_FES_storeFile(RESULT_FILE,FILE_ID); | |
183 | if (status) { | |
184 | printf("Failed to export file : %d\n",status); | |
185 | return -1; | |
186 | } | |
187 | ||
188 | ||
189 | return status; | |
190 | ||
df7153c8 | 191 | } |