clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -main-file-name hdv_mainframe.cc -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=none -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /w/halld-scifs17exp/home/sdobbs/clang/llvm-project/install/lib/clang/12.0.0 -D HAVE_CCDB -D HAVE_RCDB -D HAVE_EVIO -D HAVE_TMVA=1 -D RCDB_MYSQL=1 -D RCDB_SQLITE=1 -D SQLITE_USE_LEGACY_STRUCT=ON -I .Linux_CentOS7.7-x86_64-gcc4.8.5/programs/Analysis/hdview2 -I programs/Analysis/hdview2 -I . -I libraries -I libraries/include -I /w/halld-scifs17exp/home/sdobbs/clang/halld_recon/Linux_CentOS7.7-x86_64-gcc4.8.5/include -I external/xstream/include -I /usr/include/tirpc -I /group/halld/Software/builds/Linux_CentOS7.7-x86_64-gcc4.8.5/root/root-6.08.06/include -I /w/halld-scifs17exp/halld2/home/sdobbs/Software/jana/jana_0.8.2/Linux_CentOS7.7-x86_64-gcc4.8.5/include -I /group/halld/Software/builds/Linux_CentOS7.7-x86_64-gcc4.8.5/ccdb/ccdb_1.06.06/include -I /group/halld/Software/builds/Linux_CentOS7.7-x86_64-gcc4.8.5/rcdb/rcdb_0.06.00/cpp/include -I /usr/include/mysql -I /group/halld/Software/builds/Linux_CentOS7.7-x86_64-gcc4.8.5/sqlitecpp/SQLiteCpp-2.2.0^bs130/include -I /group/halld/Software/builds/Linux_CentOS7.7-x86_64-gcc4.8.5/sqlite/sqlite-3.13.0^bs130/include -I /group/halld/Software/builds/Linux_CentOS7.7-x86_64-gcc4.8.5/hdds/hdds-4.9.0/Linux_CentOS7.7-x86_64-gcc4.8.5/src -I /group/halld/Software/builds/Linux_CentOS7.7-x86_64-gcc4.8.5/xerces-c/xerces-c-3.1.4/include -I /group/halld/Software/builds/Linux_CentOS7.7-x86_64-gcc4.8.5/evio/evio-4.4.6/Linux-x86_64/include -internal-isystem /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5 -internal-isystem /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/x86_64-redhat-linux -internal-isystem /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/backward -internal-isystem /usr/local/include -internal-isystem /w/halld-scifs17exp/home/sdobbs/clang/llvm-project/install/lib/clang/12.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /home/sdobbs/work/clang/halld_recon/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -vectorize-loops -vectorize-slp -analyzer-output=html -faddrsig -o /tmp/scan-build-2021-01-21-110224-160369-1 -x c++ programs/Analysis/hdview2/hdv_mainframe.cc
1 | |
2 | #include <iostream> |
3 | #include <iomanip> |
4 | #include <sstream> |
5 | #include <cmath> |
6 | #include <fstream> |
7 | using namespace std; |
8 | |
9 | #include <unistd.h> |
10 | #include <pthread.h> |
11 | #include <sys/time.h> |
12 | |
13 | #include <TRACKING/DMCThrown.h> |
14 | #include "hdv_mainframe.h" |
15 | #include "hdview2.h" |
16 | #include "MyProcessor.h" |
17 | #include "FDC/DFDCGeometry.h" |
18 | #include "FCAL/DFCALGeometry.h" |
19 | #include "TOF/DTOFGeometry.h" |
20 | #include "DVector2.h" |
21 | #include "HDGEOMETRY/DGeometry.h" |
22 | #include <PID/DNeutralParticle.h> |
23 | #include <DAQ/DEPICSvalue.h> |
24 | |
25 | #include <TPolyMarker.h> |
26 | #include <TLine.h> |
27 | #include <TMarker.h> |
28 | #include <TBox.h> |
29 | #include <TVector3.h> |
30 | #include <TGeoVolume.h> |
31 | #include <TGeoManager.h> |
32 | #include <TGLabel.h> |
33 | #include <TGComboBox.h> |
34 | #include <TGButton.h> |
35 | #include <TGButtonGroup.h> |
36 | #include <TGTextEntry.h> |
37 | #include <TArrow.h> |
38 | #include <TLatex.h> |
39 | #include <TColor.h> |
40 | #include <TMath.h> |
41 | #include <TArc.h> |
42 | |
43 | extern JApplication *japp; |
44 | |
45 | |
46 | |
47 | extern int GO; |
48 | extern bool SKIP_EPICS_EVENTS; |
49 | |
50 | |
51 | |
52 | |
53 | static float BCAL_Rmin=65.0; |
54 | static float BCAL_Rmax = 87.46; |
55 | static float BCAL_MIDRAD = 77.0; |
56 | static float BCAL_Zlen = 390.0; |
57 | static float BCAL_Zmin = 212.0 - BCAL_Zlen/2.0; |
58 | static float BCAL_MODS = 48; |
59 | static float BCAL_LAYS1 = 3; |
60 | |
61 | static float BCAL_SECS1 = 4; |
62 | static float BCAL_SECS2 = 4; |
63 | static float BCAL_PHI_SHIFT = 0.0; |
64 | static float FCAL_Zlen = 45.0; |
65 | static float FCAL_Zmin = 622.8; |
66 | static float FCAL_Rmin = 6.0; |
67 | static float FCAL_Rmax = 212.0/2.0; |
68 | static float CCAL_Zlen = 18.0; |
69 | static float CCAL_Zmin = 876.106; |
70 | static float CCAL_Rmin = 2.0; |
71 | static float CCAL_Rmax = 24.0; |
72 | static float CDC_Rmin = 9.0; |
73 | static float CDC_Rmax = 59.0; |
74 | static float CDC_Zlen = 150.0; |
75 | static float CDC_Zmin = 17.0; |
76 | static float TOF_Rmax = 125.0; |
77 | static float TOF_Rmin = 6.0; |
78 | static float TOF_Zlen = 2.54; |
79 | static float TOF_Zmin = 618.8; |
80 | static float FDC_Rmin = 3.5; |
81 | static float FDC_Rmax = 48.5; |
82 | static float TARGET_Zmid = 65.0; |
83 | static float TARGET_Zlen = 30.0; |
84 | |
85 | static DFCALGeometry *fcalgeom = NULL; |
86 | static DTOFGeometry *tofgeom = NULL; |
87 | |
88 | static vector<vector <DFDCWire *> >fdcwires; |
89 | |
90 | |
91 | |
92 | |
93 | hdv_mainframe::hdv_mainframe(const TGWindow *p, UInt_t w, UInt_t h):TGMainFrame(p,w,h) |
94 | { |
95 | |
96 | DApplication* dapp=dynamic_cast<DApplication*>(japp); |
97 | const DGeometry *dgeom = dapp->GetDGeometry(RUNNUMBER); |
98 | |
99 | tofgeom = new DTOFGeometry(dgeom); |
100 | fcalgeom= new DFCALGeometry(dgeom); |
101 | |
102 | dgeom->GetFDCWires(fdcwires); |
103 | |
104 | |
105 | double my_TARGET_Zmid = TARGET_Zmid; |
106 | double my_TARGET_Zlen = TARGET_Zlen; |
107 | dgeom->GetTargetZ(my_TARGET_Zmid); |
108 | dgeom->GetTargetLength(my_TARGET_Zlen); |
109 | TARGET_Zmid = my_TARGET_Zmid; |
110 | TARGET_Zlen = my_TARGET_Zlen; |
111 | |
112 | |
113 | float my_BCAL_PHI_SHIFT; |
114 | dgeom->GetBCALPhiShift(my_BCAL_PHI_SHIFT); |
115 | BCAL_PHI_SHIFT = my_BCAL_PHI_SHIFT*TMath::DegToRad(); |
116 | |
117 | UInt_t MainWidth = w; |
118 | |
119 | |
120 | |
121 | |
122 | |
123 | |
124 | |
125 | |
126 | |
127 | TGLayoutHints *hints = new TGLayoutHints(kLHintsNormal|kLHintsExpandX|kLHintsExpandY|kLHintsLeft, 5,5,5,5); |
128 | TGLayoutHints *lhints = new TGLayoutHints(kLHintsNormal, 2,2,2,2); |
129 | TGLayoutHints *rhints = new TGLayoutHints(kLHintsCenterY|kLHintsRight, 2,2,2,2); |
130 | TGLayoutHints *chints = new TGLayoutHints(kLHintsCenterY|kLHintsCenterX, 2,2,2,2); |
131 | TGLayoutHints *bhints = new TGLayoutHints(kLHintsBottom|kLHintsCenterX, 2,2,2,2); |
132 | |
133 | TGLayoutHints *xhints = new TGLayoutHints(kLHintsNormal|kLHintsExpandX, 2,2,2,2); |
134 | TGLayoutHints *yhints = new TGLayoutHints(kLHintsNormal|kLHintsExpandY, 2,2,2,2); |
135 | TGLayoutHints *dhints = new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 0,0,0,0); |
136 | TGLayoutHints *ehints = new TGLayoutHints(kLHintsNormal, 2,2,0,0); |
137 | TGLayoutHints *thints = new TGLayoutHints(kLHintsTop|kLHintsCenterX, 2,2,0,0); |
138 | TGLayoutHints *lxhints = new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 2,2,0,0); |
139 | TGHorizontalFrame *sourceframe = new TGHorizontalFrame(this,w,20); |
140 | TGHorizontalFrame *topframe = new TGHorizontalFrame(this, w, 200); |
141 | |
142 | TGCompositeFrame *midframe = new TGCompositeFrame(this, w, 200, kHorizontalFrame); |
143 | TGHorizontalFrame *botframe = new TGHorizontalFrame(this, w, 200); |
144 | AddFrame(sourceframe, lxhints); |
145 | AddFrame(topframe, lhints); |
146 | AddFrame(midframe, lhints); |
147 | AddFrame(botframe, lhints); |
148 | |
149 | |
150 | TGLabel *sourcelab = new TGLabel(sourceframe, "Source:"); |
151 | sourceframe->AddFrame(sourcelab,ehints); |
152 | source = new TGLabel(sourceframe, "--"); |
153 | sourceframe->AddFrame(source, lxhints); |
154 | source->SetTextJustify(1); |
155 | |
156 | |
157 | TGGroupFrame *viewcontrols = new TGGroupFrame(topframe, "View Controls", kHorizontalFrame); |
158 | TGGroupFrame *eventcontrols = new TGGroupFrame(topframe, "Event Controls", kHorizontalFrame); |
159 | TGGroupFrame *eventinfo = new TGGroupFrame(topframe, "Info", kHorizontalFrame); |
160 | TGGroupFrame *inspectors = new TGGroupFrame(topframe, "Inspectors", kVerticalFrame); |
161 | TGHorizontalFrame *programcontrols = new TGHorizontalFrame(topframe); |
162 | topframe->AddFrame(viewcontrols, lhints); |
163 | topframe->AddFrame(eventcontrols, hints); |
164 | topframe->AddFrame(eventinfo, yhints); |
165 | topframe->AddFrame(inspectors, yhints); |
166 | topframe->AddFrame(programcontrols, yhints); |
167 | |
168 | |
169 | TGVerticalFrame *panneg = new TGVerticalFrame(viewcontrols); |
170 | TGVerticalFrame *panpos = new TGVerticalFrame(viewcontrols); |
171 | viewcontrols->AddFrame(panneg, hints); |
172 | viewcontrols->AddFrame(panpos, hints); |
173 | TGTextButton *panxneg = new TGTextButton(panneg, "-X"); |
174 | TGTextButton *panyneg = new TGTextButton(panneg, "-Y"); |
175 | TGTextButton *panzneg = new TGTextButton(panneg, "-Z"); |
176 | panneg->AddFrame(panxneg, dhints); |
177 | panneg->AddFrame(panyneg, dhints); |
178 | panneg->AddFrame(panzneg, dhints); |
179 | |
180 | TGTextButton *panxpos = new TGTextButton(panpos, "X+"); |
181 | TGTextButton *panypos = new TGTextButton(panpos, "Y+"); |
182 | TGTextButton *panzpos = new TGTextButton(panpos, "Z+"); |
183 | panpos->AddFrame(panxpos, dhints); |
184 | panpos->AddFrame(panypos, dhints); |
185 | panpos->AddFrame(panzpos, dhints); |
186 | |
187 | panxneg->Connect("Clicked()","hdv_mainframe",this,"DoPanXneg()"); |
188 | panyneg->Connect("Clicked()","hdv_mainframe",this,"DoPanYneg()"); |
189 | panzneg->Connect("Clicked()","hdv_mainframe",this,"DoPanZneg()"); |
190 | panxpos->Connect("Clicked()","hdv_mainframe",this,"DoPanXpos()"); |
191 | panypos->Connect("Clicked()","hdv_mainframe",this,"DoPanYpos()"); |
192 | panzpos->Connect("Clicked()","hdv_mainframe",this,"DoPanZpos()"); |
193 | |
194 | TGVerticalFrame *zoom = new TGVerticalFrame(viewcontrols); |
195 | viewcontrols->AddFrame(zoom, lhints); |
196 | TGGroupFrame *zoomframe = new TGGroupFrame(zoom, "ZOOM", kHorizontalFrame); |
197 | zoom->AddFrame(zoomframe, thints); |
198 | TGTextButton *zoomout = new TGTextButton(zoomframe, " - "); |
199 | TGTextButton *zoomin = new TGTextButton(zoomframe, " + "); |
200 | zoomframe->AddFrame(zoomout, thints); |
201 | zoomframe->AddFrame(zoomin, thints); |
202 | TGTextButton *reset = new TGTextButton(zoom, "Reset"); |
203 | zoom->AddFrame(reset, chints); |
204 | |
205 | |
206 | TGVButtonGroup *coordinates = new TGVButtonGroup(viewcontrols,"Transverse Coordinates"); |
207 | viewcontrols->AddFrame(coordinates, lhints); |
208 | TGRadioButton *xy = new TGRadioButton(coordinates, "x/y"); |
209 | new TGRadioButton(coordinates, "r/phi"); |
210 | |
211 | |
212 | prev = new TGTextButton(eventcontrols, "<-- Prev"); |
213 | next = new TGTextButton(eventcontrols, "Next -->"); |
214 | TGVerticalFrame *contf = new TGVerticalFrame(eventcontrols); |
215 | eventcontrols->AddFrame(prev, chints); |
216 | eventcontrols->AddFrame(next, chints); |
217 | eventcontrols->AddFrame(contf, lhints); |
218 | |
219 | |
220 | checkbuttons["continuous"] = new TGCheckButton(contf, "continuous"); |
221 | TGHorizontalFrame *delayf = new TGHorizontalFrame(contf); |
222 | contf->AddFrame(checkbuttons["continuous"], lhints); |
223 | contf->AddFrame(delayf, lhints); |
224 | TGLabel *delaylab = new TGLabel(delayf, "delay:"); |
225 | delay = new TGComboBox(delayf, "0.25"); |
226 | delay->Resize(50,20); |
227 | float delays[]={0, 0.25, 0.5, 1, 2, 3, 5, 10}; |
228 | for(int i=0; i<8; i++){ |
229 | stringstream ss; |
230 | ss<<delays[i]; |
231 | delay->AddEntry(ss.str().c_str(),i); |
232 | } |
233 | delayf->AddFrame(delaylab, lhints); |
234 | delayf->AddFrame(delay, lhints); |
235 | |
236 | |
237 | TGVerticalFrame *eventlabs = new TGVerticalFrame(eventinfo); |
238 | TGVerticalFrame *eventvals = new TGVerticalFrame(eventinfo); |
239 | eventinfo->AddFrame(eventlabs, lhints); |
240 | eventinfo->AddFrame(eventvals, lhints); |
241 | |
242 | TGLabel *runlab = new TGLabel(eventlabs, "Run:"); |
243 | TGLabel *eventlab = new TGLabel(eventlabs, "Event:"); |
244 | TGLabel *triglab = new TGLabel(eventlabs, "GTP bits:"); |
245 | run = new TGLabel(eventvals, "--------------"); |
246 | event = new TGLabel(eventvals, "--------------"); |
247 | trig = new TGLabel(eventvals, "--------------"); |
248 | eventlabs->AddFrame(runlab, rhints); |
249 | eventlabs->AddFrame(eventlab,rhints); |
250 | eventlabs->AddFrame(triglab,rhints); |
251 | eventvals->AddFrame(run, lhints); |
252 | eventvals->AddFrame(event, lhints); |
253 | eventvals->AddFrame(trig, lhints); |
254 | |
255 | |
256 | TGTextButton *trackinspector = new TGTextButton(inspectors, "Track Inspector"); |
257 | |
258 | |
259 | |
260 | inspectors->AddFrame(trackinspector, xhints); |
261 | |
262 | |
263 | |
264 | |
265 | |
266 | |
267 | |
268 | |
269 | TGTextButton *quit = new TGTextButton(programcontrols, "&Quit"); |
270 | programcontrols->AddFrame(quit, new TGLayoutHints(kLHintsTop|kLHintsRight|kLHintsExpandX, 2,2,2,2)); |
271 | |
272 | |
273 | TGHorizontalFrame *detectorframe = new TGHorizontalFrame(midframe); |
274 | midframe->AddFrame(detectorframe, hints); |
275 | |
276 | |
277 | TGVerticalFrame *sideviews = new TGVerticalFrame(detectorframe); |
278 | TGVerticalFrame *endviews = new TGVerticalFrame(detectorframe); |
279 | TGVerticalFrame *drawopts = new TGVerticalFrame(detectorframe); |
280 | TGVerticalFrame *caloColorCodes = new TGVerticalFrame(detectorframe); |
281 | detectorframe->AddFrame(sideviews, lhints); |
282 | detectorframe->AddFrame(endviews, lhints); |
283 | detectorframe->AddFrame(caloColorCodes, lhints); |
284 | detectorframe->AddFrame(drawopts, lhints); |
285 | |
286 | |
287 | int width = MainWidth/6*2; |
288 | TGHorizontalFrame *sideviewAframe = new TGHorizontalFrame(sideviews); |
289 | TGHorizontalFrame *sideviewBframe = new TGHorizontalFrame(sideviews); |
290 | sideviews->AddFrame(sideviewAframe, lhints); |
291 | sideviews->AddFrame(sideviewBframe, lhints); |
292 | sideviewA = new TRootEmbeddedCanvas("sideviewA Canvas", sideviewAframe, width, width/2, kSunkenFrame, GetWhitePixel()); |
293 | sideviewB = new TRootEmbeddedCanvas("sideviewB Canvas", sideviewBframe, width, width/2, kSunkenFrame, GetWhitePixel()); |
294 | sideviewAframe->AddFrame(sideviewA, lhints); |
295 | sideviewBframe->AddFrame(sideviewB, lhints); |
296 | sideviewA->SetScrolling(TGCanvas::kCanvasScrollBoth); |
297 | sideviewB->SetScrolling(TGCanvas::kCanvasScrollBoth); |
298 | sideviewA->SetBackgroundColor(0xafeeee); |
299 | sideviewB->SetBackgroundColor(0xafeeee); |
300 | |
301 | |
302 | endviewA = new TRootEmbeddedCanvas("endviewA Canvas", endviews, width/2, width/2, kSunkenFrame, GetWhitePixel()); |
303 | endviewB = new TRootEmbeddedCanvas("endviewB Canvas", endviews, width/2, width/2, kSunkenFrame, GetWhitePixel()); |
304 | endviews->AddFrame(endviewA, lhints); |
305 | endviews->AddFrame(endviewB, lhints); |
306 | endviewA->SetScrolling(TGCanvas::kCanvasScrollBoth); |
307 | endviewB->SetScrolling(TGCanvas::kCanvasScrollBoth); |
308 | endviewA->GetCanvas()->SetFillColor(kGray+1); |
309 | endviewB->GetCanvas()->SetFillColor(kGray+1); |
310 | |
311 | |
312 | TGGroupFrame *trkdrawopts = new TGGroupFrame(drawopts, "Track Draw Options", kVerticalFrame); |
313 | TGGroupFrame *hitdrawopts = new TGGroupFrame(drawopts, "Hit Draw Options", kVerticalFrame); |
314 | drawopts->AddFrame(trkdrawopts, lhints); |
315 | drawopts->AddFrame(hitdrawopts, lhints); |
316 | |
317 | |
318 | TGHorizontalFrame *candidatesf = new TGHorizontalFrame(trkdrawopts); |
319 | checkbuttons["candidates"] = new TGCheckButton(candidatesf, "DTrackCandidate:"); |
320 | candidatesfactory = new TGComboBox(candidatesf, "<default>", 0); |
321 | candidatesfactory->Resize(80,20); |
322 | candidatesf->AddFrame(checkbuttons["candidates"], lhints); |
323 | for(int i=0; i<100; i++)candidatesfactory->AddEntry("a",i); |
324 | |
325 | candidatesf->AddFrame(candidatesfactory, lhints); |
326 | trkdrawopts->AddFrame(candidatesf, lhints); |
327 | |
328 | TGHorizontalFrame *wiretracksf = new TGHorizontalFrame(trkdrawopts); |
329 | checkbuttons["wiretracks"] = new TGCheckButton(wiretracksf, "DTrackWireBased:"); |
330 | wiretracksfactory = new TGComboBox(wiretracksf, "<default>", 0); |
331 | wiretracksfactory->Resize(80,20); |
332 | wiretracksf->AddFrame(checkbuttons["wiretracks"], lhints); |
333 | for(int i=0; i<100; i++)wiretracksfactory->AddEntry("a",i); |
334 | |
335 | wiretracksf->AddFrame(wiretracksfactory, lhints); |
336 | trkdrawopts->AddFrame(wiretracksf, lhints); |
337 | |
338 | TGHorizontalFrame *timetracksf = new TGHorizontalFrame(trkdrawopts); |
339 | checkbuttons["timetracks"] = new TGCheckButton(timetracksf, "DTrackTimeBased:"); |
340 | timetracksfactory = new TGComboBox(timetracksf, "<default>", 0); |
341 | timetracksfactory->Resize(80,20); |
342 | timetracksf->AddFrame(checkbuttons["timetracks"], lhints); |
343 | for(int i=0; i<100; i++)timetracksfactory->AddEntry("a",i); |
344 | |
345 | timetracksf->AddFrame(timetracksfactory, lhints); |
346 | trkdrawopts->AddFrame(timetracksf, lhints); |
347 | TGHorizontalFrame *chargedtracksf = new TGHorizontalFrame(trkdrawopts); |
348 | checkbuttons["chargedtracks"] = new TGCheckButton(chargedtracksf, "DChargedTrack:"); |
349 | chargedtracksfactory = new TGComboBox(chargedtracksf, "<default>", 0); |
350 | chargedtracksfactory->Resize(80,20); |
351 | chargedtracksf->AddFrame(checkbuttons["chargedtracks"], lhints); |
352 | for(int i=0; i<100; i++)chargedtracksfactory->AddEntry("a",i); |
353 | |
354 | chargedtracksf->AddFrame(chargedtracksfactory, lhints); |
355 | trkdrawopts->AddFrame(chargedtracksf, lhints); |
356 | |
357 | checkbuttons["neutrals"] = new TGCheckButton(trkdrawopts,"DNeutralParticle"); |
358 | checkbuttons["thrown"] = new TGCheckButton(trkdrawopts,"DMCThrown"); |
359 | checkbuttons["trajectories"] = new TGCheckButton(trkdrawopts, "DMCTrajectoryPoint"); |
360 | trkdrawopts->AddFrame(checkbuttons["neutrals"], lhints); |
361 | trkdrawopts->AddFrame(checkbuttons["thrown"], lhints); |
362 | trkdrawopts->AddFrame(checkbuttons["trajectories"], lhints); |
363 | |
364 | |
365 | checkbuttons["cdc"] = new TGCheckButton(hitdrawopts, "CDC"); |
366 | checkbuttons["cdcdrift"] = new TGCheckButton(hitdrawopts, "CDC Drift Time"); |
367 | checkbuttons["cdctruth"] = new TGCheckButton(hitdrawopts, "CDCTruth"); |
368 | checkbuttons["fdcwire"] = new TGCheckButton(hitdrawopts, "FDC Wire"); |
369 | checkbuttons["fdcpseudo"] = new TGCheckButton(hitdrawopts, "FDC Pseudo"); |
370 | checkbuttons["fdctruth"] = new TGCheckButton(hitdrawopts, "FDCTruth"); |
371 | checkbuttons["tof"] = new TGCheckButton(hitdrawopts, "TOF"); |
372 | checkbuttons["toftruth"] = new TGCheckButton(hitdrawopts, "TOFTruth"); |
373 | checkbuttons["fcal"] = new TGCheckButton(hitdrawopts, "FCAL"); |
374 | checkbuttons["bcal"] = new TGCheckButton(hitdrawopts, "BCAL"); |
375 | checkbuttons["ccal"] = new TGCheckButton(hitdrawopts, "CCAL"); |
376 | |
377 | hitdrawopts->AddFrame(checkbuttons["cdc"], lhints); |
378 | hitdrawopts->AddFrame(checkbuttons["cdcdrift"], lhints); |
379 | hitdrawopts->AddFrame(checkbuttons["cdctruth"], lhints); |
380 | hitdrawopts->AddFrame(checkbuttons["fdcwire"], lhints); |
381 | hitdrawopts->AddFrame(checkbuttons["fdcpseudo"], lhints); |
382 | hitdrawopts->AddFrame(checkbuttons["fdctruth"], lhints); |
383 | hitdrawopts->AddFrame(checkbuttons["tof"], lhints); |
384 | hitdrawopts->AddFrame(checkbuttons["toftruth"], lhints); |
385 | hitdrawopts->AddFrame(checkbuttons["fcal"], lhints); |
386 | hitdrawopts->AddFrame(checkbuttons["bcal"], lhints); |
387 | hitdrawopts->AddFrame(checkbuttons["ccal"], lhints); |
388 | |
389 | TGTextButton *moreOptions = new TGTextButton(hitdrawopts, "More options"); |
390 | hitdrawopts->AddFrame(moreOptions, lhints); |
391 | |
392 | |
393 | TGGroupFrame *bcalColorCodes = new TGGroupFrame(caloColorCodes, "BCAL colors", kVerticalFrame); |
394 | TGGroupFrame *fcalColorCodes = new TGGroupFrame(caloColorCodes, "FCAL colors", kVerticalFrame); |
395 | TGTextButton *debuger = new TGTextButton(caloColorCodes,"Debugger"); |
396 | TGTextButton *bcaldisp = new TGTextButton(caloColorCodes,"BcalDisp"); |
397 | |
398 | caloColorCodes->AddFrame(bcalColorCodes, thints); |
399 | caloColorCodes->AddFrame(debuger,lhints); |
400 | caloColorCodes->AddFrame(bcaldisp,lhints); |
401 | caloColorCodes->AddFrame(fcalColorCodes, bhints); |
402 | bcalColorCodes->SetWidth(30); |
403 | fcalColorCodes->SetWidth(30); |
404 | |
405 | |
406 | TGLabel* BCCLables[9]; |
407 | unsigned int BCccodes[9] = {0x0000FF,0x7700FF,0xFF00FF,0xFF0077,0xFF0000,0xFF7700,0xFFFF00,0xFFFF77,0xFFFFFF}; |
408 | for (int i=0;i<9;i++) { |
409 | double e = pow(10,((8-(double)i)/2.0)); |
410 | char str1[128]; |
411 | if (e >= 1000) { |
412 | sprintf(str1,"%7.2f GeV",e/1000.); |
413 | } else { |
414 | sprintf(str1,"%7.1f MeV",e); |
415 | } |
416 | BCCLables[i] = new TGLabel(bcalColorCodes, (const char*)str1); |
417 | |
418 | BCCLables[i]->SetBackgroundColor(BCccodes[i]); |
419 | bcalColorCodes->AddFrame(BCCLables[i],lhints); |
420 | } |
421 | |
422 | TGLabel* FCCLables[9]; |
423 | unsigned int FCccodes[9] = {0x0000FF,0x7700FF,0xFF00FF,0xFF0077,0xFF0000,0xFF7700,0xFFFF00,0xFFFF77,0xFFFFFF}; |
424 | for (int i=0;i<9;i++) { |
425 | double e = pow(10,((8-(double)i)/2.0)); |
426 | char str1[128]; |
427 | if (e >= 1000) { |
428 | sprintf(str1,"%7.2f GeV",e/1000.); |
429 | } else { |
430 | sprintf(str1,"%7.1f MeV",e); |
431 | } |
432 | FCCLables[i] = new TGLabel(fcalColorCodes, (const char*)str1); |
433 | FCCLables[i]->SetBackgroundColor(FCccodes[i]); |
434 | fcalColorCodes->AddFrame(FCCLables[i],lhints); |
435 | } |
436 | |
437 | |
438 | TGGroupFrame *trackinfo = new TGGroupFrame(botframe, "Track Info", kHorizontalFrame); |
439 | botframe->AddFrame(trackinfo, xhints); |
440 | |
441 | |
442 | throwninfo = new TGGroupFrame(trackinfo, "Thrown", kHorizontalFrame); |
443 | reconinfo = new TGGroupFrame(trackinfo, "Reconstructed", kHorizontalFrame); |
444 | trackinfo->AddFrame(throwninfo, lhints); |
445 | trackinfo->AddFrame(reconinfo, lhints); |
446 | |
447 | |
448 | vector<string> colnames; |
449 | colnames.push_back("trk"); |
450 | colnames.push_back("type"); |
451 | colnames.push_back("p"); |
452 | colnames.push_back("theta"); |
453 | colnames.push_back("phi"); |
454 | colnames.push_back("z"); |
455 | colnames.push_back("chisq/Ndof"); |
456 | colnames.push_back("Ndof"); |
457 | colnames.push_back("FOM"); |
458 | colnames.push_back("cand"); |
459 | |
460 | |
461 | for(unsigned int i=0; i<colnames.size(); i++){ |
462 | |
463 | TGVerticalFrame *tf = new TGVerticalFrame(throwninfo); |
464 | TGVerticalFrame *rf = new TGVerticalFrame(reconinfo); |
465 | throwninfo->AddFrame(tf, bhints); |
466 | reconinfo->AddFrame(rf, bhints); |
467 | |
468 | |
469 | string lab = colnames[i]+":"; |
470 | TGLabel *tl = new TGLabel(tf, lab.c_str()); |
471 | TGLabel *rl = new TGLabel(rf, lab.c_str()); |
472 | if(i<6)tf->AddFrame(tl, chints); |
473 | rf->AddFrame(rl, chints); |
474 | vector<TGLabel*> tv; |
475 | vector<TGLabel*> rv; |
476 | tv.push_back(tl); |
477 | rv.push_back(rl); |
478 | |
479 | |
480 | |
481 | |
482 | for(int j=0; j<14; j++){ |
483 | stringstream ss; |
484 | ss<<(5-j); |
485 | if(i<6)tl = new TGLabel(tf, i==0 ? ss.str().c_str():"--------"); |
486 | rl = new TGLabel(rf, i==0 ? ss.str().c_str():"--------"); |
487 | if(i<6)tf->AddFrame(tl, bhints); |
488 | rf->AddFrame(rl, bhints); |
489 | tv.push_back(tl); |
490 | rv.push_back(rl); |
491 | } |
492 | |
493 | |
494 | thrownlabs[colnames[i]] = tv; |
495 | reconlabs[colnames[i]] = rv; |
496 | } |
497 | |
498 | |
499 | TGVerticalFrame *vf = new TGVerticalFrame(reconinfo); |
500 | reconinfo->AddFrame(vf, yhints); |
501 | reconfactory = new TGComboBox(vf, "DTrackCandidate:", 0); |
502 | reconfactory->Resize(160,20); |
503 | for(int i=0; i<100; i++)reconfactory->AddEntry("a",i); |
504 | vf->AddFrame(reconfactory, thints); |
505 | |
506 | TGTextButton *listall = new TGTextButton(vf, "Full List"); |
507 | vf->AddFrame(listall, new TGLayoutHints(kLHintsBottom|kLHintsExpandX, 2,2,2,2)); |
508 | |
509 | |
510 | |
511 | trkmf = NULL; |
512 | bcaldispmf = NULL; |
513 | optionsmf = new hdv_optionsframe(this, NULL, 100, 100); |
514 | debugermf = new hdv_debugerframe(this, NULL, 800, 800); |
515 | fulllistmf = new hdv_fulllistframe(this, NULL, 100, 100); |
516 | endviewAmf = new hdv_endviewAframe(this, NULL, 600, 600); |
517 | endviewBmf = new hdv_endviewBframe(this, NULL, 600, 600); |
518 | |
519 | |
520 | ReadPreferences(); |
521 | xy->SetState(kButtonDown,kTRUE); |
522 | coordinatetype = COORD_XY; |
523 | r0 = 50.0; |
524 | phi0 = M_PI; |
525 | x0 = 0.0; |
526 | y0 = 0.0; |
527 | z0 = 350.0; |
528 | zoom_factor = 1.0; |
529 | |
530 | |
531 | zoomin->Connect("Clicked()","hdv_mainframe", this, "DoZoomIn()"); |
532 | zoomout->Connect("Clicked()","hdv_mainframe", this, "DoZoomOut()"); |
533 | reset->Connect("Clicked()","hdv_mainframe", this, "DoReset()"); |
534 | |
535 | coordinates->Connect("Clicked(Int_t)","hdv_mainframe", this, "DoSetCoordinates(Int_t)"); |
536 | coordinates->Connect("Clicked(Int_t)","hdv_mainframe", this, "DoMyRedraw()"); |
537 | |
538 | quit->Connect("Clicked()","hdv_mainframe", this, "DoQuit()"); |
539 | this->Connect("CloseWindow()", "hdv_mainframe", this, "DoQuit()"); |
540 | this->DontCallClose(); |
541 | next->Connect("Clicked()","hdv_mainframe", this, "DoNext()"); |
542 | prev->Connect("Clicked()","hdv_mainframe", this, "DoPrev()"); |
543 | checkbuttons["continuous"]->Connect("Clicked()","hdv_mainframe", this, "DoCont()"); |
544 | delay->Connect("Selected(Int_t)","hdv_mainframe", this, "DoSetDelay(Int_t)"); |
545 | |
546 | trackinspector->Connect("Clicked()","hdv_mainframe", this, "DoOpenTrackInspector()"); |
547 | moreOptions->Connect("Clicked()","hdv_mainframe", this, "DoOpenOptionsWindow()"); |
548 | listall->Connect("Clicked()","hdv_mainframe", this, "DoOpenFullListWindow()"); |
549 | debuger->Connect("Clicked()","hdv_mainframe", this, "DoOpenDebugerWindow()"); |
550 | bcaldisp->Connect("Clicked()","hdv_mainframe", this, "DoBcalDispFrame()"); |
551 | |
552 | |
553 | |
554 | |
555 | checkbuttons["candidates"]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()"); |
556 | checkbuttons["wiretracks"]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()"); |
557 | checkbuttons["timetracks"]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()"); |
558 | checkbuttons["chargedtracks"]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()"); |
559 | checkbuttons["neutrals"]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()"); |
560 | checkbuttons["thrown"]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()"); |
561 | |
562 | checkbuttons["cdc"]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()"); |
563 | checkbuttons["cdcdrift"]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()"); |
564 | checkbuttons["cdctruth"]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()"); |
565 | checkbuttons["fdcwire"]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()"); |
566 | checkbuttons["fdcpseudo"]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()"); |
567 | checkbuttons["fdctruth"]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()"); |
568 | checkbuttons["tof"]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()"); |
569 | checkbuttons["toftruth"]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()"); |
570 | checkbuttons["bcal"]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()"); |
571 | checkbuttons["bcaltruth"]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()"); |
572 | checkbuttons["fcal"]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()"); |
573 | checkbuttons["fcaltruth"]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()"); |
574 | checkbuttons["ccal"]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()"); |
575 | checkbuttons["trajectories"]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()"); |
576 | |
577 | for (Int_t n=1;n<debugermf->GetNTrCand();n++){ |
578 | char str1[128]; |
579 | sprintf(str1,"Candidate%d",n); |
580 | checkbuttons[str1]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()"); |
581 | } |
582 | |
583 | for (Int_t n=1;n<debugermf->GetNTrWB();n++){ |
584 | char str1[128]; |
585 | sprintf(str1,"WireBased%d",n); |
586 | checkbuttons[str1]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()"); |
587 | } |
588 | |
589 | for (Int_t n=1;n<debugermf->GetNTrTB();n++){ |
590 | char str1[128]; |
591 | sprintf(str1,"TimeBased%d",n); |
592 | checkbuttons[str1]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()"); |
593 | } |
594 | |
595 | candidatesfactory->Connect("Selected(Int_t)","hdv_mainframe", this, "DoMyRedraw()"); |
596 | wiretracksfactory->Connect("Selected(Int_t)","hdv_mainframe", this, "DoMyRedraw()"); |
597 | timetracksfactory->Connect("Selected(Int_t)","hdv_mainframe", this, "DoMyRedraw()"); |
598 | chargedtracksfactory->Connect("Selected(Int_t)","hdv_mainframe", this, "DoMyRedraw()"); |
599 | reconfactory->Connect("Selected(Int_t)","hdv_mainframe", this, "DoUpdateTrackLabels()"); |
600 | |
601 | endviewA->GetCanvas()->Connect("Selected(TVirtualPad*, TObject*, Int_t)", "hdv_mainframe", this, "DoEndViewAEvent(TVirtualPad*, TObject*, Int_t)"); |
602 | endviewB->GetCanvas()->Connect("Selected(TVirtualPad*, TObject*, Int_t)", "hdv_mainframe", this, "DoEndViewBEvent(TVirtualPad*, TObject*, Int_t)"); |
603 | |
604 | |
605 | |
606 | timer = new TTimer(); |
607 | timer->Connect("Timeout()", "hdv_mainframe", this, "DoTimer()"); |
608 | sleep_time = 250; |
609 | timer->Start(sleep_time, kFALSE); |
610 | |
611 | |
612 | SetWindowName("Hall-D Event Viewer"); |
613 | SetIconName("HDView"); |
614 | MapSubwindows(); |
615 | Resize(GetDefaultSize()); |
616 | MapWindow(); |
617 | |
618 | |
619 | viewcontrols->Resize(); |
620 | eventinfo->Resize(); |
621 | eventcontrols->Resize(); |
622 | inspectors->Resize(); |
623 | } |
624 | |
625 | |
626 | |
627 | |
628 | void hdv_mainframe::ReadPreferences(void) |
629 | { |
630 | |
631 | const char *home = getenv("HOME"); |
632 | if(!home)return; |
633 | |
634 | |
635 | string fname = string(home) + "/.hdview2"; |
636 | ifstream ifs(fname.c_str()); |
637 | if(!ifs.is_open())return; |
638 | cout<<"Reading preferences from \""<<fname<<"\" ..."<<endl; |
639 | |
640 | |
641 | char line[1024]; |
642 | while(!ifs.eof()){ |
643 | ifs.getline(line, 1024); |
644 | if(strlen(line)==0)continue; |
645 | if(line[0] == '#')continue; |
646 | string str(line); |
647 | |
648 | |
649 | vector<string> tokens; |
650 | string buf; |
651 | stringstream ss(str); |
652 | while (ss >> buf)tokens.push_back(buf); |
653 | if(tokens.size()<1)continue; |
654 | |
655 | |
656 | if(tokens[0] == "checkbutton"){ |
657 | if(tokens.size()!=4)continue; |
658 | map<string, TGCheckButton*>::iterator it = checkbuttons.find(tokens[1]); |
659 | if(it != checkbuttons.end()){ |
660 | if(tokens[3] == "on")(it->second)->SetState(kButtonDown); |
661 | } |
662 | } |
663 | |
664 | if(tokens[0] == "DTrackCandidate"){ |
665 | if(tokens.size()!=3)continue; |
666 | default_candidate = tokens[2]; |
667 | } |
668 | |
669 | if(tokens[0] == "DTrackWireBased"){ |
670 | if(tokens.size()!=3)continue; |
671 | default_track = tokens[2]; |
672 | } |
673 | |
674 | if(tokens[0] == "DTrackTimeBased"){ |
675 | if(tokens.size()!=3)continue; |
676 | default_track = tokens[2]; |
677 | } |
678 | |
679 | if(tokens[0] == "Reconstructed"){ |
680 | if(tokens.size()!=3)continue; |
681 | default_reconstructed = tokens[2]; |
682 | } |
683 | |
684 | } |
685 | |
686 | |
687 | ifs.close(); |
688 | } |
689 | |
690 | |
691 | |
692 | |
693 | void hdv_mainframe::SavePreferences(void) |
694 | { |
695 | |
696 | const char *home = getenv("HOME"); |
697 | if(!home)return; |
698 | |
699 | |
700 | string fname = string(home) + "/.hdview2"; |
701 | unlink(fname.c_str()); |
702 | ofstream ofs(fname.c_str()); |
703 | if(!ofs.is_open()){ |
704 | cout<<"Unable to create preferences file \""<<fname<<"\"!"<<endl; |
705 | return; |
706 | } |
707 | |
708 | |
709 | time_t t = time(NULL); |
710 | ofs<<"##### hdview2 preferences file ###"<<endl; |
711 | ofs<<"##### Auto-generated on "<<ctime(&t)<<endl; |
712 | ofs<<endl; |
713 | |
714 | |
715 | map<string, TGCheckButton*>::iterator iter; |
716 | for(iter=checkbuttons.begin(); iter!=checkbuttons.end(); iter++){ |
717 | TGCheckButton *but = iter->second; |
718 | if(but->GetState() == kButtonDown){ |
719 | ofs<<"checkbutton "<<(iter->first)<<" = on"<<endl; |
720 | } |
721 | } |
722 | ofs<<endl; |
723 | |
724 | ofs<<"DTrackCandidate = "<<(candidatesfactory->GetTextEntry()->GetText())<<endl; |
725 | ofs<<"DTrackWireBased = "<<(wiretracksfactory->GetTextEntry()->GetText())<<endl; |
726 | ofs<<"DTrackTimeBased = "<<(timetracksfactory->GetTextEntry()->GetText())<<endl; |
727 | ofs<<"Reconstructed = "<<(reconfactory->GetTextEntry()->GetText())<<endl; |
728 | |
729 | ofs<<endl; |
730 | ofs.close(); |
731 | cout<<"Preferences written to \""<<fname<<"\""<<endl; |
732 | } |
733 | |
734 | |
735 | |
736 | |
737 | void hdv_mainframe::SetRange(void) |
738 | { |
739 | |
740 | |
741 | |
742 | |
743 | |
744 | |
745 | |
746 | if(coordinatetype==COORD_XY){ |
747 | |
748 | double x_width = 350.0/zoom_factor; |
749 | double y_width = x_width; |
750 | double z_width = 2.70*x_width; |
751 | double xlo = x0 - x_width/2.0; |
752 | double xhi = x0 + x_width/2.0; |
753 | double ylo = y0 - y_width/2.0; |
754 | double yhi = y0 + y_width/2.0; |
755 | double zlo = z0 - z_width*0.40; |
756 | double zhi = z0 + z_width*0.60; |
757 | |
758 | sideviewA->GetCanvas()->cd(); |
759 | sideviewA->GetCanvas()->Range(zlo, xlo, zhi, xhi); |
760 | sideviewB->GetCanvas()->cd(); |
761 | sideviewB->GetCanvas()->Range(zlo, ylo, zhi, yhi); |
762 | |
763 | |
764 | double end_to_side_ratio=1.8; |
765 | xlo/=end_to_side_ratio; |
766 | xhi/=end_to_side_ratio; |
767 | ylo/=end_to_side_ratio; |
768 | yhi/=end_to_side_ratio; |
769 | |
770 | endviewA->GetCanvas()->cd(); |
771 | endviewA->GetCanvas()->Range(xlo, ylo, xhi, yhi); |
772 | endviewB->GetCanvas()->cd(); |
773 | endviewB->GetCanvas()->Range(xlo*1.3, ylo*1.3, xhi*1.3, yhi*1.3); |
774 | |
775 | endviewAmf->SetRange(xlo, ylo, xhi, yhi); |
776 | endviewBmf->SetRange(xlo*1.3, ylo*1.3, xhi*1.3, yhi*1.3); |
777 | |
778 | |
779 | }else{ |
780 | |
781 | double r_width = 400.0/zoom_factor; |
782 | |
783 | double z_width = 2.0*r_width/zoom_factor; |
784 | double rlo = r0 - r_width/2.0; |
785 | double rhi = r0 + r_width/2.0; |
786 | double zlo = z0 - z_width/2.0; |
787 | double zhi = z0 + z_width/2.0; |
788 | double philo = -0.2; |
789 | double phihi = 2.0*M_PI+0.2; |
790 | |
791 | sideviewA->GetCanvas()->cd(); |
792 | sideviewA->GetCanvas()->Range(zlo, rlo, zhi, rhi); |
793 | sideviewB->GetCanvas()->cd(); |
794 | sideviewB->GetCanvas()->Range(zlo, philo, zhi, phihi); |
795 | |
796 | |
797 | endviewA->GetCanvas()->cd(); |
798 | endviewA->GetCanvas()->Range(philo, rlo/2.5, phihi, rhi/2.5); |
799 | endviewB->GetCanvas()->cd(); |
800 | endviewB->GetCanvas()->Range(philo, rlo/10.0, phihi, rhi/1.9); |
801 | endviewAmf->SetRange(philo, rlo/2.5, phihi, rhi/2.5); |
802 | endviewBmf->SetRange(philo, rlo/10.0, phihi, rhi/1.9); |
803 | } |
804 | } |
805 | |
806 | |
807 | |
808 | |
809 | void hdv_mainframe::DoQuit(void) |
810 | { |
811 | SavePreferences(); |
812 | |
813 | japp->Quit(); |
814 | japp->Fini(); |
815 | delete japp; |
816 | japp = NULL; |
817 | |
818 | |
819 | |
820 | gApplication->Terminate(0); |
821 | } |
822 | |
823 | |
824 | |
825 | |
826 | void hdv_mainframe::DoNext(void) |
827 | { |
828 | if(eventloop){ |
| 3 | | Assuming 'eventloop' is non-null | |
|
| |
829 | if(SKIP_EPICS_EVENTS){ |
| 5 | | Assuming 'SKIP_EPICS_EVENTS' is true | |
|
| |
830 | while(true){ |
| 7 | | Loop condition is true. Entering loop body | |
|
831 | eventloop->OneEvent(); |
832 | vector<const DEPICSvalue*> epicsvalues; |
833 | eventloop->Get(epicsvalues); |
| 8 | | Calling 'JEventLoop::Get' | |
|
834 | if(epicsvalues.empty()) break; |
835 | cout << "Skipping EPICS event " << eventloop->GetJEvent().GetEventNumber() << endl; |
836 | } |
837 | }else{ |
838 | eventloop->OneEvent(); |
839 | } |
840 | } |
841 | } |
842 | |
843 | |
844 | |
845 | |
846 | void hdv_mainframe::DoPrev(void) |
847 | { |
848 | |
849 | |
850 | } |
851 | |
852 | |
853 | |
854 | |
855 | void hdv_mainframe::DoStop(void) |
856 | { |
857 | GO = 0; |
858 | } |
859 | |
860 | |
861 | |
862 | |
863 | void hdv_mainframe::DoCont(void) |
864 | { |
865 | GO = 1; |
866 | } |
867 | |
868 | |
869 | |
870 | |
871 | void hdv_mainframe::DoTimer(void) |
872 | { |
873 | |
874 | |
875 | |
876 | if(GetCheckButton("continuous")){ |
| |
877 | DoNext(); |
| 2 | | Calling 'hdv_mainframe::DoNext' | |
|
878 | if(sleep_time != (long)timer->GetTime())timer->SetTime(sleep_time); |
879 | }else{ |
880 | if(sleep_time == 0)timer->SetTime(10); |
881 | } |
882 | } |
883 | |
884 | |
885 | |
886 | |
887 | void hdv_mainframe::DoOpenTrackInspector(void) |
888 | { |
889 | if(trkmf==NULL){ |
890 | trkmf = new trk_mainframe(this, NULL, 100, 100); |
891 | if(trkmf){ |
892 | next->Connect("Clicked()","trk_mainframe", trkmf, "DoNewEvent()"); |
893 | prev->Connect("Clicked()","trk_mainframe", trkmf, "DoNewEvent()"); |
894 | } |
895 | }else{ |
896 | trkmf->RaiseWindow(); |
897 | trkmf->RequestFocus(); |
898 | } |
899 | } |
900 | |
901 | |
902 | |
903 | |
904 | void hdv_mainframe::DoOpenOptionsWindow(void) |
905 | { |
906 | if(optionsmf==NULL){ |
907 | optionsmf = new hdv_optionsframe(this, NULL, 100, 100); |
908 | }else{ |
909 | optionsmf->MapWindow(); |
910 | optionsmf->RaiseWindow(); |
911 | optionsmf->RequestFocus(); |
912 | } |
913 | } |
914 | |
915 | |
916 | |
917 | void hdv_mainframe::DoOpenDebugerWindow(void) |
918 | { |
919 | if(debugermf==NULL){ |
920 | debugermf = new hdv_debugerframe(this, NULL, 100, 100); |
921 | }else{ |
922 | debugermf->MapWindow(); |
923 | debugermf->RaiseWindow(); |
924 | debugermf->RequestFocus(); |
925 | DoUpdateTrackLabels(); |
926 | } |
927 | } |
928 | |
929 | |
930 | |
931 | void hdv_mainframe::DoBcalDispFrame(void) |
932 | { |
933 | if(bcaldispmf==NULL){ |
934 | bcaldispmf = new TCanvas("BCALHitCanvas", "BCAL Hit Distribution", 900, 900); |
935 | } |
936 | |
937 | DoUpdateBcalDisp(); |
938 | } |
939 | |
940 | |
941 | |
942 | void hdv_mainframe::DoUpdateBcalDisp(void) |
943 | { |
944 | gMYPROC->UpdateBcalDisp(); |
945 | |
946 | } |
947 | |
948 | |
949 | |
950 | void hdv_mainframe::DoOpenFullListWindow(void) |
951 | { |
952 | if(fulllistmf==NULL){ |
953 | fulllistmf = new hdv_fulllistframe(this, NULL, 100, 100); |
954 | }else{ |
955 | fulllistmf->MapWindow(); |
956 | fulllistmf->RaiseWindow(); |
957 | fulllistmf->RequestFocus(); |
958 | DoUpdateTrackLabels(); |
959 | } |
960 | } |
961 | |
962 | |
963 | |
964 | |
965 | void hdv_mainframe::DoOpenTOFInspector(void) |
966 | { |
967 | |
968 | } |
969 | |
970 | |
971 | |
972 | |
973 | void hdv_mainframe::DoOpenFCALInspector(void) |
974 | { |
975 | |
976 | } |
977 | |
978 | |
979 | |
980 | |
981 | void hdv_mainframe::DoOpenBCALInspector(void) |
982 | { |
983 | |
984 | } |
985 | |
986 | |
987 | |
988 | |
989 | void hdv_mainframe::DoClearTrackInspectorPointer(void) |
990 | { |
991 | trkmf = NULL; |
992 | } |
993 | |
994 | |
995 | |
996 | |
997 | void hdv_mainframe::DoClearOptionsWindowPointer(void) |
998 | { |
999 | optionsmf = NULL; |
1000 | } |
1001 | |
1002 | |
1003 | |
1004 | |
1005 | void hdv_mainframe::DoClearTOFInspectorPointer(void) |
1006 | { |
1007 | |
1008 | } |
1009 | |
1010 | |
1011 | |
1012 | |
1013 | void hdv_mainframe::DoClearFCALInspectorPointer(void) |
1014 | { |
1015 | |
1016 | } |
1017 | |
1018 | |
1019 | |
1020 | |
1021 | void hdv_mainframe::DoClearBCALInspectorPointer(void) |
1022 | { |
1023 | |
1024 | } |
1025 | |
1026 | |
1027 | |
1028 | |
1029 | void hdv_mainframe::DoEndViewAEvent(TVirtualPad* pad, TObject* obj, Int_t event) |
1030 | { |
1031 | |
1032 | |
1033 | if(endviewAmf==NULL){ |
1034 | endviewAmf = new hdv_endviewAframe(this, NULL, 100, 100); |
1035 | }else{ |
1036 | endviewAmf->MapWindow(); |
1037 | endviewAmf->RaiseWindow(); |
1038 | endviewAmf->RequestFocus(); |
1039 | DoMyRedraw(); |
1040 | } |
1041 | } |
1042 | |
1043 | |
1044 | |
1045 | |
1046 | |
1047 | void hdv_mainframe::DoEndViewBEvent(TVirtualPad* pad, TObject* obj, Int_t event) |
1048 | { |
1049 | |
1050 | |
1051 | if(endviewBmf==NULL){ |
1052 | endviewBmf = new hdv_endviewBframe(this, NULL, 100, 100); |
1053 | }else{ |
1054 | endviewBmf->MapWindow(); |
1055 | endviewBmf->RaiseWindow(); |
1056 | endviewBmf->RequestFocus(); |
1057 | DoMyRedraw(); |
1058 | } |
1059 | } |
1060 | |
1061 | |
1062 | |
1063 | |
1064 | void hdv_mainframe::DoPanXpos(void) |
1065 | { |
1066 | x0 += 50/zoom_factor; |
1067 | SetRange(); |
1068 | DoMyRedraw(); |
1069 | } |
1070 | |
1071 | |
1072 | |
1073 | |
1074 | void hdv_mainframe::DoPanXneg(void) |
1075 | { |
1076 | x0 -= 50/zoom_factor; |
1077 | SetRange(); |
1078 | DoMyRedraw(); |
1079 | } |
1080 | |
1081 | |
1082 | |
1083 | |
1084 | void hdv_mainframe::DoPanYpos(void) |
1085 | { |
1086 | y0 += 50/zoom_factor; |
1087 | SetRange(); |
1088 | DoMyRedraw(); |
1089 | } |
1090 | |
1091 | |
1092 | |
1093 | |
1094 | void hdv_mainframe::DoPanYneg(void) |
1095 | { |
1096 | y0 -= 50/zoom_factor; |
1097 | SetRange(); |
1098 | DoMyRedraw(); |
1099 | } |
1100 | |
1101 | |
1102 | |
1103 | |
1104 | void hdv_mainframe::DoPanZpos(void) |
1105 | { |
1106 | z0 += 50/zoom_factor; |
1107 | SetRange(); |
1108 | DoMyRedraw(); |
1109 | } |
1110 | |
1111 | |
1112 | |
1113 | |
1114 | void hdv_mainframe::DoPanZneg(void) |
1115 | { |
1116 | z0 -= 50/zoom_factor; |
1117 | SetRange(); |
1118 | DoMyRedraw(); |
1119 | } |
1120 | |
1121 | |
1122 | |
1123 | |
1124 | void hdv_mainframe::DoZoomIn(void) |
1125 | { |
1126 | zoom_factor*=1.25; |
1127 | SetRange(); |
1128 | DoMyRedraw(); |
1129 | |
1130 | } |
1131 | |
1132 | |
1133 | |
1134 | |
1135 | void hdv_mainframe::DoZoomOut(void) |
1136 | { |
1137 | zoom_factor/=1.25; |
1138 | SetRange(); |
1139 | DoMyRedraw(); |
1140 | |
1141 | } |
1142 | |
1143 | |
1144 | |
1145 | |
1146 | void hdv_mainframe::DoReset(void) |
1147 | { |
1148 | x0 = 0.0; |
1149 | y0 = 0.0; |
1150 | z0 = 350.0; |
1151 | zoom_factor = 1.0; |
1152 | DoMyRedraw(); |
1153 | } |
1154 | |
1155 | |
1156 | |
1157 | |
1158 | |
1159 | void hdv_mainframe::DoMyRedraw(void) |
1160 | { |
1161 | |
1162 | SetRange(); |
1163 | |
1164 | |
1165 | for(unsigned int i=0; i<graphics_sideA.size(); i++)delete graphics_sideA[i]; |
1166 | for(unsigned int i=0; i<graphics_sideB.size(); i++)delete graphics_sideB[i]; |
1167 | for(unsigned int i=0; i<graphics_endA.size(); i++)delete graphics_endA[i]; |
1168 | for(unsigned int i=0; i<graphics_endB.size(); i++)delete graphics_endB[i]; |
1169 | graphics_sideA.clear(); |
1170 | graphics_sideB.clear(); |
1171 | graphics_endA.clear(); |
1172 | graphics_endB.clear(); |
1173 | |
1174 | |
1175 | |
1176 | if(coordinatetype == COORD_XY){ |
1177 | DrawDetectorsXY(); |
1178 | }else{ |
1179 | DrawDetectorsRPhi(); |
1180 | } |
1181 | |
1182 | |
1183 | gMYPROC->FillGraphics(); |
1184 | |
1185 | |
1186 | AddGraphicsSideA(gMYPROC->graphics_xz); |
1187 | AddGraphicsSideB(gMYPROC->graphics_yz); |
1188 | AddGraphicsEndB(gMYPROC->graphics_tof_hits); |
1189 | |
1190 | |
1191 | vector<MyProcessor::DGraphicSet>::iterator iter = gMYPROC->graphics.begin(); |
1192 | for(; iter!=gMYPROC->graphics.end(); iter++){ |
1193 | |
1194 | if(iter->type==MyProcessor::kMarker){ |
1195 | |
1196 | TPolyMarker *sA = new TPolyMarker(); |
1197 | TPolyMarker *sB = new TPolyMarker(); |
1198 | TPolyMarker *eA = new TPolyMarker(); |
1199 | sA->SetMarkerColor(iter->color); |
1200 | sB->SetMarkerColor(iter->color); |
1201 | eA->SetMarkerColor(iter->color); |
1202 | sA->SetMarkerSize(iter->size); |
1203 | sB->SetMarkerSize(iter->size); |
1204 | eA->SetMarkerSize(iter->size); |
1205 | sA->SetMarkerStyle(iter->marker_style); |
1206 | sB->SetMarkerStyle(iter->marker_style); |
1207 | eA->SetMarkerStyle(iter->marker_style); |
1208 | FillPoly(sA, sB, eA, iter->points); |
1209 | }else{ |
1210 | |
1211 | TPolyLine *sA = new TPolyLine(); |
1212 | TPolyLine *sB = new TPolyLine(); |
1213 | TPolyLine *eA = new TPolyLine(); |
1214 | sA->SetLineColor(iter->color); |
1215 | sB->SetLineColor(iter->color); |
1216 | eA->SetLineColor(iter->color); |
1217 | sA->SetLineWidth((Width_t)iter->size); |
1218 | sB->SetLineWidth((Width_t)iter->size); |
1219 | eA->SetLineWidth((Width_t)iter->size); |
1220 | sA->SetFillStyle(0); |
1221 | sB->SetFillStyle(0); |
1222 | eA->SetFillStyle(0); |
1223 | FillPoly(sA, sB, eA, iter->points); |
1224 | |
1225 | |
1226 | |
1227 | if(eA->GetN()==2){ |
1228 | double *x = eA->GetX(); |
1229 | double *y = eA->GetY(); |
1230 | if(fabs(x[0]-x[1])<0.1 && fabs(y[0]==y[1])<0.1){ |
1231 | TMarker *m = new TMarker(x[0], y[0], 8); |
1232 | m->SetMarkerColor(iter->color); |
1233 | m->SetMarkerSize(0.5); |
1234 | graphics_endA.push_back(m); |
1235 | } |
1236 | } |
1237 | } |
1238 | } |
1239 | |
1240 | |
1241 | if(coordinatetype == COORD_XY){ |
1242 | for(unsigned int i=0; i<gMYPROC->graphics_xyA.size(); i++){ |
1243 | graphics_endA.push_back(gMYPROC->graphics_xyA[i]); |
1244 | } |
1245 | for(unsigned int i=0; i<gMYPROC->graphics_xyB.size(); i++){ |
1246 | graphics_endB.push_back(gMYPROC->graphics_xyB[i]); |
1247 | } |
1248 | } |
1249 | |
1250 | |
1251 | endviewA->GetCanvas()->cd(0); |
1252 | for(unsigned int i=0; i<graphics_endA.size(); i++){ |
1253 | TPolyLine *l = dynamic_cast<TPolyLine*>(graphics_endA[i]); |
1254 | if(l && l->GetFillStyle()!=0){ |
1255 | graphics_endA[i]->Draw("f"); |
1256 | }else{ |
1257 | graphics_endA[i]->Draw(""); |
1258 | } |
1259 | } |
1260 | endviewA->GetCanvas()->Update(); |
1261 | endviewAmf->DrawObjects(graphics_endA); |
1262 | |
1263 | endviewB->GetCanvas()->cd(0); |
1264 | for(unsigned int i=0; i<graphics_endB.size(); i++)graphics_endB[i]->Draw("f"); |
1265 | for(unsigned int i=0; i<graphics_endB.size(); i++)graphics_endB[i]->Draw(); |
1266 | endviewB->GetCanvas()->Update(); |
1267 | endviewBmf->DrawObjects(graphics_endB); |
1268 | |
1269 | sideviewA->GetCanvas()->cd(0); |
1270 | for(unsigned int i=0; i<graphics_sideA.size(); i++)graphics_sideA[i]->Draw(); |
1271 | sideviewA->GetCanvas()->Update(); |
1272 | sideviewB->GetCanvas()->cd(0); |
1273 | for(unsigned int i=0; i<graphics_sideB.size(); i++)graphics_sideB[i]->Draw(); |
1274 | sideviewB->GetCanvas()->Update(); |
1275 | |
1276 | |
1277 | DoUpdateTrackLabels(); |
1278 | } |
1279 | |
1280 | |
1281 | |
1282 | |
1283 | void hdv_mainframe::DoSetDelay(Int_t id) |
1284 | { |
1285 | stringstream ss; |
1286 | ss<<delay->GetSelectedEntry()->GetTitle(); |
1287 | double seconds; |
1288 | ss>>seconds; |
1289 | sleep_time = (int)(1000.0*seconds); |
1290 | timer->SetTime(sleep_time); |
1291 | } |
1292 | |
1293 | |
1294 | |
1295 | |
1296 | void hdv_mainframe::DoSetCoordinates(Int_t id) |
1297 | { |
1298 | coordinatetype = (coordsys_t)id; |
1299 | } |
1300 | |
1301 | |
1302 | |
1303 | |
1304 | void hdv_mainframe::DoUpdateTrackLabels(void) |
1305 | { |
1306 | gMYPROC->UpdateTrackLabels(); |
1307 | |
1308 | throwninfo->Resize(); |
1309 | reconinfo->Resize(); |
1310 | } |
1311 | |
1312 | |
1313 | |
1314 | |
1315 | void hdv_mainframe::DrawDetectorsXY(void) |
1316 | { |
1317 | |
1318 | { |
1319 | sideviewA->GetCanvas()->cd(0); |
1320 | sideviewA->GetCanvas()->Clear(); |
1321 | |
1322 | |
1323 | |
1324 | |
1325 | TBox *target = new TBox(TARGET_Zmid-TARGET_Zlen/2.0, -0.5, TARGET_Zmid+TARGET_Zlen/2.0, +0.5); |
1326 | target->SetFillColor(13); |
1327 | graphics_sideA.push_back(target); |
1328 | |
1329 | |
1330 | |
1331 | TBox *bcal1 = new TBox(BCAL_Zmin, BCAL_Rmin, BCAL_Zmin+BCAL_Zlen, BCAL_Rmax); |
1332 | TBox *bcal2 = new TBox(BCAL_Zmin, -BCAL_Rmin, BCAL_Zmin+BCAL_Zlen, -BCAL_Rmax); |
1333 | bcal1->SetFillColor(28); |
1334 | bcal2->SetFillColor(28); |
1335 | graphics_sideA.push_back(bcal1); |
1336 | graphics_sideA.push_back(bcal2); |
1337 | |
1338 | |
1339 | TBox *cdc1 = new TBox(CDC_Zmin, CDC_Rmin, CDC_Zmin + CDC_Zlen, CDC_Rmax); |
1340 | TBox *cdc2 = new TBox(CDC_Zmin, -CDC_Rmin, CDC_Zmin + CDC_Zlen, -CDC_Rmax); |
1341 | cdc1->SetFillColor(17); |
1342 | cdc2->SetFillColor(17); |
1343 | graphics_sideA.push_back(cdc1); |
1344 | graphics_sideA.push_back(cdc2); |
1345 | |
1346 | |
1347 | for(int i=0; i<4; i++){ |
1348 | |
1349 | float zu = fdcwires[i*6][0]->origin.z(); |
1350 | float zd = fdcwires[i*6+5][0]->origin.z(); |
1351 | TBox *fdc1 = new TBox(zu, FDC_Rmin, zd, FDC_Rmax); |
1352 | TBox *fdc2 = new TBox(zu, -FDC_Rmin, zd, -FDC_Rmax); |
1353 | fdc1->SetFillColor(21); |
1354 | fdc2->SetFillColor(21); |
1355 | graphics_sideA.push_back(fdc1); |
1356 | graphics_sideA.push_back(fdc2); |
1357 | } |
1358 | |
1359 | |
1360 | TBox *tof1 = new TBox(TOF_Zmin, TOF_Rmin, TOF_Zmin+TOF_Zlen, TOF_Rmax); |
1361 | TBox *tof2 = new TBox(TOF_Zmin, -TOF_Rmin, TOF_Zmin+TOF_Zlen, -TOF_Rmax); |
1362 | tof1->SetFillColor(11); |
1363 | tof2->SetFillColor(11); |
1364 | graphics_sideA.push_back(tof1); |
1365 | graphics_sideA.push_back(tof2); |
1366 | |
1367 | |
1368 | TBox *fcal1 = new TBox(FCAL_Zmin, FCAL_Rmin, FCAL_Zmin+FCAL_Zlen, FCAL_Rmax); |
1369 | TBox *fcal2 = new TBox(FCAL_Zmin, -FCAL_Rmin, FCAL_Zmin+FCAL_Zlen, -FCAL_Rmax); |
1370 | fcal1->SetFillColor(40); |
1371 | fcal2->SetFillColor(40); |
1372 | graphics_sideA.push_back(fcal1); |
1373 | graphics_sideA.push_back(fcal2); |
1374 | |
1375 | |
1376 | TBox *ccal1 = new TBox(CCAL_Zmin, CCAL_Rmin, CCAL_Zmin+CCAL_Zlen, CCAL_Rmax); |
1377 | TBox *ccal2 = new TBox(CCAL_Zmin, -CCAL_Rmin, CCAL_Zmin+CCAL_Zlen, -CCAL_Rmax); |
1378 | ccal1->SetFillColor(42); |
1379 | ccal2->SetFillColor(42); |
1380 | graphics_sideA.push_back(ccal1); |
1381 | graphics_sideA.push_back(ccal2); |
1382 | |
1383 | |
1384 | DrawScale(sideviewA->GetCanvas(), graphics_sideA); |
1385 | } |
1386 | |
1387 | |
1388 | { |
1389 | sideviewB->GetCanvas()->cd(0); |
1390 | sideviewB->GetCanvas()->Clear(); |
1391 | |
1392 | |
1393 | for(unsigned int i=0; i<graphics_sideA.size(); i++){ |
1394 | graphics_sideB.push_back(graphics_sideA[i]->Clone()); |
1395 | } |
1396 | } |
1397 | |
1398 | |
1399 | { |
1400 | endviewB->GetCanvas()->cd(0); |
1401 | endviewB->GetCanvas()->Clear(); |
1402 | |
1403 | |
1404 | TEllipse *bcal1 = new TEllipse(0.0, 0.0, BCAL_Rmax, BCAL_Rmax); |
1405 | TEllipse *bcal2 = new TEllipse(0.0, 0.0, BCAL_Rmin, BCAL_Rmin); |
1406 | bcal1->SetFillColor(0); |
1407 | bcal2->SetFillColor(0); |
1408 | graphics_endA.push_back(bcal1); |
1409 | graphics_endA.push_back(bcal2); |
1410 | |
1411 | double dlayer1 = 0.5*(BCAL_MIDRAD-BCAL_Rmin)/(double)BCAL_LAYS1; |
1412 | |
1413 | double dmodule = (double)TMath::TwoPi()/(double)BCAL_MODS; |
1414 | double dsector1 = dmodule/(double)BCAL_SECS1; |
1415 | double dsector2 = dmodule/(double)BCAL_SECS2; |
1416 | |
1417 | |
1418 | if(GetCheckButton("bcal")){ |
1419 | for(int imod=0; imod<BCAL_MODS; imod++){ |
1420 | double mod_phi = (double)imod*dmodule -2.0*dsector1 + BCAL_PHI_SHIFT; |
1421 | double r_min=BCAL_Rmin; |
1422 | for(int ilay=0; ilay<BCAL_LAYS1; ilay++){ |
1423 | r_min+=dlayer1*ilay; |
1424 | double r_max = r_min+(ilay+1)*dlayer1; |
1425 | for(int isec=0; isec<BCAL_SECS1; isec++){ |
1426 | double phimin = mod_phi + (double)isec*dsector1; |
1427 | double phimax = phimin + dsector1; |
1428 | |
1429 | double x[4], y[4]; |
1430 | x[0] = r_min*cos(phimin); |
1431 | y[0] = r_min*sin(phimin); |
1432 | x[1] = r_max*cos(phimin); |
1433 | y[1] = r_max*sin(phimin); |
1434 | x[2] = r_max*cos(phimax); |
1435 | y[2] = r_max*sin(phimax); |
1436 | x[3] = r_min*cos(phimax); |
1437 | y[3] = r_min*sin(phimax); |
1438 | |
1439 | TPolyLine *poly = new TPolyLine(4, x, y); |
1440 | poly->SetLineColor(12); |
1441 | poly->SetLineWidth(0); |
1442 | poly->SetFillColor(0); |
1443 | poly->SetFillStyle(0); |
1444 | int chan = (imod+1)*1000 + (ilay+1)*100 + (isec+1)*10; |
1445 | graphics_endA.push_back(poly); |
1446 | bcalblocks[chan] = poly; |
1447 | } |
1448 | |
1449 | for(int isec=0; isec<BCAL_SECS2; isec++){ |
1450 | double phimin = mod_phi + (double)isec*dsector2; |
1451 | double phimax = phimin + dsector2; |
1452 | |
1453 | double x[5], y[5]; |
1454 | x[0] = BCAL_MIDRAD*cos(phimin); |
1455 | y[0] = BCAL_MIDRAD*sin(phimin); |
1456 | x[1] = BCAL_Rmax*cos(phimin); |
1457 | y[1] = BCAL_Rmax*sin(phimin); |
1458 | x[2] = BCAL_Rmax*cos(phimax); |
1459 | y[2] = BCAL_Rmax*sin(phimax); |
1460 | x[3] = BCAL_MIDRAD*cos(phimax); |
1461 | y[3] = BCAL_MIDRAD*sin(phimax); |
1462 | x[4] = x[0]; |
1463 | y[4] = y[0]; |
1464 | TPolyLine *poly = new TPolyLine(5, x, y); |
1465 | poly->SetLineColor(12); |
1466 | poly->SetLineWidth(1); |
1467 | poly->SetFillColor(0); |
1468 | poly->SetFillStyle(0); |
1469 | int chan = (int)((imod+1)*1000 + (ilay+1+BCAL_LAYS1)*100 + (isec+1)*10); |
1470 | graphics_endA.push_back(poly); |
1471 | bcalblocks[chan] = poly; |
1472 | } |
1473 | } |
1474 | } |
1475 | } |
1476 | |
1477 | for(int imod=0; imod<BCAL_MODS; imod++){ |
1478 | |
1479 | double mod_phi = (double)imod*dmodule -2.0*dsector1 + BCAL_PHI_SHIFT; |
1480 | for(int isec=0; isec<BCAL_SECS1; isec++){ |
1481 | double rmin = BCAL_Rmin; |
1482 | double rmax = BCAL_MIDRAD; |
1483 | double phi = mod_phi + (double)isec*dsector1; |
1484 | |
1485 | TLine *l = new TLine(rmin*cos(phi), rmin*sin(phi), rmax*cos(phi), rmax*sin(phi)); |
1486 | l->SetLineColor(isec==0 ? kBlack:12); |
1487 | l->SetLineWidth((Width_t)(isec==0 ? 2.5:1.0)); |
1488 | graphics_endA.push_back(l); |
1489 | } |
1490 | for(int isec=0; isec<BCAL_SECS2; isec++){ |
1491 | double rmin = BCAL_MIDRAD; |
1492 | double rmax = BCAL_Rmax; |
1493 | double phi = mod_phi + (double)isec*dsector2; |
1494 | |
1495 | TLine *l = new TLine(rmin*cos(phi), rmin*sin(phi), rmax*cos(phi), rmax*sin(phi)); |
1496 | l->SetLineColor(isec==0 ? kBlack:12); |
1497 | l->SetLineWidth((Width_t)(isec==0 ? 2.5:1.0)); |
1498 | graphics_endA.push_back(l); |
1499 | } |
1500 | |
1501 | |
1502 | double r=BCAL_Rmin; |
1503 | for(int ilay=0; ilay<BCAL_LAYS1; ilay++){ |
1504 | r+=dlayer1*ilay; |
1505 | TLine *l = new TLine(r*cos(mod_phi), r*sin(mod_phi), r*cos(mod_phi+dmodule), r*sin(mod_phi+dmodule)); |
1506 | l->SetLineColor(ilay==0 ? kBlack:12); |
1507 | l->SetLineWidth((Width_t)(ilay==0 ? 1.0:1.0)); |
1508 | graphics_endA.push_back(l); |
1509 | } |
1510 | |
1511 | TLine *l = new TLine(BCAL_MIDRAD*cos(mod_phi), BCAL_MIDRAD*sin(mod_phi), BCAL_MIDRAD*cos(mod_phi+dmodule), BCAL_MIDRAD*sin(mod_phi+dmodule)); |
1512 | l->SetLineColor(12); |
1513 | l->SetLineWidth((Width_t)(1.0)); |
1514 | graphics_endA.push_back(l); |
1515 | } |
1516 | |
1517 | |
1518 | TEllipse *cdc1 = new TEllipse(0.0, 0.0, CDC_Rmax, CDC_Rmax); |
1519 | TEllipse *cdc2 = new TEllipse(0.0, 0.0, CDC_Rmin, CDC_Rmin); |
1520 | cdc1->SetFillColor(17); |
1521 | cdc1->SetLineColor(17); |
1522 | cdc2->SetFillColor(10); |
1523 | graphics_endA.push_back(cdc1); |
1524 | graphics_endA.push_back(cdc2); |
1525 | |
1526 | |
1527 | TEllipse *fdc1 = new TEllipse(0.0, 0.0, FDC_Rmax, FDC_Rmax); |
1528 | TEllipse *fdc2 = new TEllipse(0.0, 0.0, FDC_Rmin, FDC_Rmin); |
1529 | fdc1->SetFillColor(21); |
1530 | fdc1->SetLineColor(21); |
1531 | fdc2->SetFillColor(10); |
1532 | fdc2->SetLineColor(10); |
1533 | graphics_endA.push_back(fdc1); |
1534 | graphics_endA.push_back(fdc2); |
1535 | |
1536 | |
1537 | |
1538 | |
1539 | |
1540 | |
1541 | |
1542 | |
1543 | |
1544 | |
1545 | |
1546 | |
1547 | |
1548 | |
1549 | |
1550 | |
1551 | |
1552 | |
1553 | Double_t inner_radius = 7.7493; |
1554 | Double_t outer_radius = 8.0493; |
1555 | Double_t bottom_width = 1.6289; |
1556 | Double_t top_width = 1.692; |
1557 | Double_t dtr = 1.745329252e-02; |
1558 | |
1559 | |
1560 | Double_t x_coords[31][5]; |
1561 | Double_t y_coords[31][5]; |
1562 | |
1563 | |
1564 | x_coords[0][0] = -outer_radius; |
1565 | x_coords[0][1] = -(outer_radius - top_width*sin(6.0*dtr)); |
1566 | x_coords[0][2] = -(inner_radius - bottom_width*sin(6.0*dtr)); |
1567 | x_coords[0][3] = -inner_radius; |
1568 | x_coords[0][4] = -outer_radius; |
1569 | |
1570 | y_coords[0][0] = 0.0; |
1571 | y_coords[0][1] = top_width*cos(6.0*dtr); |
1572 | y_coords[0][2] = bottom_width*cos(6.0*dtr); |
1573 | y_coords[0][3] = 0.0; |
1574 | y_coords[0][4] = 0.0; |
1575 | |
1576 | |
1577 | TPolyLine *ch_pline[30]; |
1578 | |
1579 | |
1580 | for (int i = 1; i < 31; i++) |
1581 | { |
1582 | |
1583 | x_coords[i][0] = x_coords[i-1][1]; |
1584 | x_coords[i][1] = x_coords[i-1][1] + top_width*sin((6.0 + 12.0*i)*dtr); |
1585 | x_coords[i][2] = x_coords[i-1][2] + bottom_width*sin((6.0 + 12.0*i)*dtr); |
1586 | x_coords[i][3] = x_coords[i-1][2]; |
1587 | x_coords[i][4] = x_coords[i-1][1]; |
1588 | |
1589 | y_coords[i][0] = y_coords[i-1][1]; |
1590 | y_coords[i][1] = y_coords[i-1][1] + top_width*cos((6.0 + 12.0*i)*dtr); |
1591 | y_coords[i][2] = y_coords[i-1][2] + bottom_width*cos((6.0 + 12.0*i)*dtr); |
1592 | y_coords[i][3] = y_coords[i-1][2]; |
1593 | y_coords[i][4] = y_coords[i-1][1]; |
1594 | |
1595 | |
1596 | Double_t x[5] = {x_coords[i-1][0], x_coords[i-1][1], x_coords[i-1][2], x_coords[i-1][3], x_coords[i-1][4]}; |
1597 | Double_t y[5] = {y_coords[i-1][0], y_coords[i-1][1], y_coords[i-1][2], y_coords[i-1][3], y_coords[i-1][4]}; |
1598 | ch_pline[i-1] = new TPolyLine(5, x, y); |
1599 | ch_pline[i-1]->SetFillColor(18); |
1600 | ch_pline[i-1]->SetLineColor(1); |
1601 | ch_pline[i-1]->SetLineWidth(2); |
1602 | graphics_endA.push_back(ch_pline[i-1]); |
1603 | } |
1604 | |
1605 | |
1606 | TEllipse *target = new TEllipse(0.0, 0.0, 0.5, 0.5); |
1607 | target->SetFillColor(13); |
1608 | graphics_endA.push_back(target); |
1609 | |
1610 | |
1611 | DrawScale(endviewA->GetCanvas(), graphics_endA); |
1612 | } |
1613 | |
1614 | |
1615 | { |
1616 | endviewB->GetCanvas()->cd(0); |
1617 | endviewB->GetCanvas()->Clear(); |
1618 | |
1619 | |
1620 | |
1621 | |
1622 | |
1623 | |
1624 | |
1625 | double blocksize = fcalgeom->blockSize(); |
1626 | DVector2 shift[8]; |
1627 | shift[0].Set(-blocksize/2, -blocksize/2); |
1628 | shift[1].Set(-blocksize/2, +blocksize/2); |
1629 | shift[2].Set(+blocksize/2, +blocksize/2); |
1630 | shift[3].Set(+blocksize/2, -blocksize/2); |
1631 | double insertSize=fcalgeom->insertSize(); |
1632 | if (insertSize>0){ |
1633 | blocksize=fcalgeom->insertBlockSize(); |
1634 | shift[4].Set(-blocksize/2, -blocksize/2); |
1635 | shift[5].Set(-blocksize/2, +blocksize/2); |
1636 | shift[6].Set(+blocksize/2, +blocksize/2); |
1637 | shift[7].Set(+blocksize/2, -blocksize/2); |
1638 | } |
1639 | |
1640 | fcalblocks.clear(); |
1641 | if(GetCheckButton("fcal")){ |
1642 | for(unsigned int chan=0; chan<fcalgeom->numChannels(); chan++){ |
1643 | if (fcalgeom->isBlockActive(chan)==false) continue; |
1644 | DVector2 fcalBlockPos=fcalgeom->positionOnFace(chan); |
1645 | |
1646 | double x[5], y[5]; |
1647 | for(int i=0; i<4; i++){ |
1648 | DVector2 pos = fcalBlockPos; |
1649 | if (insertSize>0 |
1650 | && fabs(pos.X())<insertSize |
1651 | && fabs(pos.Y())<insertSize){ |
1652 | pos+=shift[i+4]; |
1653 | } |
1654 | else{ |
1655 | pos+=shift[i]; |
1656 | } |
1657 | x[i] = pos.X(); |
1658 | y[i] = pos.Y(); |
1659 | } |
1660 | x[4] = x[0]; |
1661 | y[4] = y[0]; |
1662 | |
1663 | TPolyLine *poly = new TPolyLine(5, x, y); |
1664 | poly->SetFillColor(0); |
1665 | poly->SetLineColor(kBlack); |
1666 | graphics_endB.push_back(poly); |
1667 | |
1668 | fcalblocks[chan] = poly; |
1669 | } |
1670 | } |
1671 | |
1672 | |
1673 | |
1674 | |
1675 | |
1676 | |
1677 | |
1678 | blocksize = 2.0; |
1679 | shift[0].Set(-blocksize/2, -blocksize/2); |
1680 | shift[1].Set(-blocksize/2, +blocksize/2); |
1681 | shift[2].Set(+blocksize/2, +blocksize/2); |
1682 | shift[3].Set(+blocksize/2, -blocksize/2); |
1683 | ccalblocks.clear(); |
1684 | |
1685 | if(GetCheckButton("ccal")){ |
1686 | for(int irow=0; irow<12; irow++){ |
1687 | for(int icol=0; icol<12; icol++){ |
1688 | if( (irow==5 || irow==6) && (icol==5 || icol==6) ) continue; |
1689 | |
1690 | double center_x = (-6.0 + (icol+0.5))*2.0; |
1691 | double center_y = (-6.0 + (irow+0.5))*2.0; |
1692 | DVector2 mypos(center_x,center_y); |
1693 | |
1694 | double x[5], y[5]; |
1695 | for(int i=0; i<4; i++){ |
1696 | DVector2 pos = shift[i] + mypos; |
1697 | x[i] = pos.X(); |
1698 | y[i] = pos.Y(); |
1699 | } |
1700 | x[4] = x[0]; |
1701 | y[4] = y[0]; |
1702 | |
1703 | TPolyLine *poly = new TPolyLine(5, x, y); |
1704 | poly->SetFillColor(0); |
1705 | poly->SetLineColor(kBlack); |
1706 | graphics_endB.push_back(poly); |
1707 | |
1708 | int channel = icol + 12*(irow); |
1709 | ccalblocks[channel] = poly; |
1710 | } |
1711 | } |
1712 | |
1713 | |
1714 | if(GetCheckButton("fcal")){ |
1715 | double x[5] = {-6.0, -6.0, 6.0, 6.0, -6.0}; |
1716 | double y[5] = {-6.0, 6.0, 6.0,-6.0, -6.0}; |
1717 | TPolyLine *poly = new TPolyLine(5, x, y); |
1718 | poly->SetFillColor(0); |
1719 | poly->SetLineColor(kBlack); |
1720 | poly->SetLineWidth(3); |
1721 | poly->SetLineStyle(2); |
1722 | graphics_endB.push_back(poly); |
1723 | } |
1724 | } |
1725 | |
1726 | |
1727 | tofblocks.clear(); |
1728 | if(GetCheckButton("tof")){ |
1729 | |
1730 | TPolyLine *pmtPline[4][44] = {{ NULL }, { NULL }}; |
1731 | |
1732 | |
1733 | Double_t pmtX[4][44][5]; |
1734 | Double_t pmtY[4][44][5]; |
1735 | |
1736 | Double_t x[5]; |
1737 | Double_t y[5]; |
1738 | |
1739 | |
1740 | Double_t position_x[4] = {-126,-126,-126,126}; |
1741 | Double_t position_y[4] = {-126,-126,126,-126}; |
1742 | |
1743 | |
1744 | Double_t step_x[4][5] = {{0,0,6,6,0},{0,-14,-14,0,0},{0,0,6,6,0},{0,14,14,0,0}}; |
1745 | Double_t step_y[4][5] = {{0,-14,-14,0,0},{0,0,6,6,0},{0,14,14,0,0},{0,0,6,6,0}}; |
1746 | Double_t step_xl[4][5] = {{0,0,3,3,0},{0,-20,-20,0,0},{0,0,3,3,0},{0,20,20,0,0}}; |
1747 | Double_t step_yl[4][5] = {{0,-20,-20,0,0},{0,0,3,3,0},{0,20,20,0,0},{0,0,3,3,0}}; |
1748 | Double_t step_X[4] = {6,0,6,0}; |
1749 | Double_t step_Y[4] = {0,6,0,6}; |
1750 | Double_t step_XL[4] = {3,0,3,0}; |
1751 | Double_t step_YL[4] = {0,3,0,3}; |
1752 | |
1753 | |
1754 | for (int sd=0; sd<4; sd++) |
1755 | { |
1756 | for (int i=0; i<44; i++) |
1757 | { |
1758 | for (int l=0; l<5; l++) |
1759 | { |
1760 | switch(l) |
1761 | { |
1762 | case 0: |
1763 | if (i == 19 || i == 20 || i == 23 || i == 24){ |
1764 | pmtX[sd][i][l]=position_x[sd] + step_xl[sd][l]; |
1765 | pmtY[sd][i][l]=position_y[sd] + step_yl[sd][l]; |
1766 | } |
1767 | else{ |
1768 | pmtX[sd][i][l]=position_x[sd] + step_x[sd][l]; |
1769 | pmtY[sd][i][l]=position_y[sd] + step_y[sd][l]; |
1770 | } |
1771 | break; |
1772 | case 1: |
1773 | if (i == 19 || i == 20 || i == 23 || i == 24){ |
1774 | pmtX[sd][i][l]=position_x[sd] + step_xl[sd][l]; |
1775 | pmtY[sd][i][l]=position_y[sd] + step_yl[sd][l]; |
1776 | } |
1777 | else{ |
1778 | pmtX[sd][i][l]=position_x[sd] + step_x[sd][l]; |
1779 | pmtY[sd][i][l]=position_y[sd] + step_y[sd][l]; |
1780 | } |
1781 | break; |
1782 | case 2: |
1783 | if (i == 19 || i == 20 || i == 23 || i == 24){ |
1784 | pmtX[sd][i][l]=position_x[sd] + step_xl[sd][l]; |
1785 | pmtY[sd][i][l]=position_y[sd] + step_yl[sd][l]; |
1786 | } |
1787 | else{ |
1788 | pmtX[sd][i][l]=position_x[sd] + step_x[sd][l]; |
1789 | pmtY[sd][i][l]=position_y[sd] + step_y[sd][l]; |
1790 | } |
1791 | break; |
1792 | case 3: |
1793 | if (i == 19 || i == 20 || i == 23 || i == 24){ |
1794 | pmtX[sd][i][l]=position_x[sd] + step_xl[sd][l]; |
1795 | pmtY[sd][i][l]=position_y[sd] + step_yl[sd][l]; |
1796 | } |
1797 | else{ |
1798 | pmtX[sd][i][l]=position_x[sd] + step_x[sd][l]; |
1799 | pmtY[sd][i][l]=position_y[sd] + step_y[sd][l]; |
1800 | } |
1801 | break; |
1802 | case 4: |
1803 | if (i == 19 || i == 20 || i == 23 || i == 24){ |
1804 | pmtX[sd][i][l]=position_x[sd] + step_xl[sd][l]; |
1805 | pmtY[sd][i][l]=position_y[sd] + step_yl[sd][l]; |
1806 | } |
1807 | else{ |
1808 | pmtX[sd][i][l]=position_x[sd] + step_x[sd][l]; |
1809 | pmtY[sd][i][l]=position_y[sd] + step_y[sd][l]; |
1810 | } |
1811 | break; |
1812 | } |
1813 | } |
1814 | if ( i == 19 || i == 20 || i == 23 || i == 24){ |
1815 | position_x[sd] = position_x[sd] + step_XL[sd]; |
1816 | position_y[sd] = position_y[sd] + step_YL[sd]; |
1817 | } |
1818 | else{ |
1819 | position_x[sd] = position_x[sd] + step_X[sd]; |
1820 | position_y[sd] = position_y[sd] + step_Y[sd]; |
1821 | } |
1822 | } |
1823 | } |
1824 | |
1825 | for (int sd=0; sd<4; sd++) |
1826 | { |
1827 | for (int j=0; j<44; j++) |
1828 | { |
1829 | for (int q=0; q<5; q++) |
1830 | { |
1831 | x[q] = pmtX[sd][j][q]; |
1832 | y[q] = pmtY[sd][j][q]; |
1833 | } |
1834 | pmtPline[sd][j] = new TPolyLine(5,x,y); |
1835 | } |
1836 | } |
1837 | |
1838 | int tof_count = 0; |
1839 | for (int sd=0; sd<4; sd++) |
1840 | { |
1841 | for (int j=0; j<44; j++) |
1842 | { |
1843 | pmtPline[sd][j]->SetFillColor(1); |
1844 | pmtPline[sd][j]->SetLineColor(41); |
1845 | pmtPline[sd][j]->SetLineWidth(2); |
1846 | tof_count++; |
1847 | graphics_endB.push_back(pmtPline[sd][j]); |
1848 | tofblocks[sd][tof_count] = pmtPline[sd][j]; |
1849 | } |
1850 | tof_count = 0; |
1851 | } |
1852 | |
1853 | } |
1854 | |
1855 | |
1856 | DrawScale(endviewB->GetCanvas(), graphics_endB); |
1857 | } |
1858 | |
1859 | |
1860 | |
1861 | DrawAxes(sideviewA->GetCanvas(), graphics_sideA, "Z", "X"); |
1862 | DrawAxes(sideviewB->GetCanvas(), graphics_sideB, "Z", "Y"); |
1863 | DrawAxes(endviewA->GetCanvas(), graphics_endA, "X", "Y"); |
1864 | DrawAxes(endviewB->GetCanvas(), graphics_endB, "X", "Y"); |
1865 | |
1866 | |
1867 | |
1868 | DrawLabel(sideviewA->GetCanvas(), graphics_sideA, "top view (looking down from above detector)"); |
1869 | DrawLabel(sideviewA->GetCanvas(), graphics_sideB, "side view from beam right (south)"); |
1870 | DrawLabel(endviewA->GetCanvas(), graphics_endA, "BCAL view from downstream looking upstream"); |
1871 | DrawLabel(endviewB->GetCanvas(), graphics_endB, "FCAL view from downstream looking upstream"); |
1872 | } |
1873 | |
1874 | |
1875 | |
1876 | |
1877 | void hdv_mainframe::DrawDetectorsRPhi(void) |
1878 | { |
1879 | |
1880 | { |
1881 | sideviewA->GetCanvas()->cd(0); |
1882 | sideviewA->GetCanvas()->Clear(); |
1883 | |
1884 | |
1885 | TBox *target = new TBox(TARGET_Zmid-TARGET_Zlen/2.0, 0.0, TARGET_Zmid+TARGET_Zlen/2.0, 0.5); |
1886 | target->SetFillColor(13); |
1887 | graphics_sideA.push_back(target); |
1888 | |
1889 | |
1890 | TBox *bcal1 = new TBox(BCAL_Zmin, BCAL_Rmin, BCAL_Zmin+BCAL_Zlen, BCAL_Rmax); |
1891 | bcal1->SetFillColor(28); |
1892 | graphics_sideA.push_back(bcal1); |
1893 | |
1894 | |
1895 | TBox *cdc1 = new TBox(CDC_Zmin, CDC_Rmin, CDC_Zmin + CDC_Zlen, CDC_Rmax); |
1896 | cdc1->SetFillColor(17); |
1897 | graphics_sideA.push_back(cdc1); |
1898 | |
1899 | |
1900 | for(int i=0; i<4; i++){ |
1901 | |
1902 | float zu = fdcwires[i*6][0]->origin.z(); |
1903 | float zd = fdcwires[i*6+5][0]->origin.z(); |
1904 | TBox *fdc1 = new TBox(zu, FDC_Rmin, zd, FDC_Rmax); |
1905 | fdc1->SetFillColor(21); |
1906 | graphics_sideA.push_back(fdc1); |
1907 | } |
1908 | |
1909 | |
1910 | TBox *tof1 = new TBox(TOF_Zmin, TOF_Rmin, TOF_Zmin+TOF_Zlen, TOF_Rmax); |
1911 | tof1->SetFillColor(11); |
1912 | graphics_sideA.push_back(tof1); |
1913 | |
1914 | |
1915 | TBox *fcal1 = new TBox(FCAL_Zmin, FCAL_Rmin, FCAL_Zmin+FCAL_Zlen, FCAL_Rmax); |
1916 | fcal1->SetFillColor(40); |
1917 | graphics_sideA.push_back(fcal1); |
1918 | |
1919 | |
1920 | DrawScale(endviewA->GetCanvas(), graphics_endA); |
1921 | } |
1922 | |
1923 | |
1924 | { |
1925 | sideviewB->GetCanvas()->cd(0); |
1926 | sideviewB->GetCanvas()->Clear(); |
1927 | |
1928 | |
1929 | TBox *target = new TBox(TARGET_Zmid-TARGET_Zlen/2.0, 0.0, TARGET_Zmid+TARGET_Zlen/2.0, 2.0*M_PI); |
1930 | target->SetFillColor(13); |
1931 | graphics_sideB.push_back(target); |
1932 | |
1933 | |
1934 | TBox *bcal1 = new TBox(BCAL_Zmin, 0.0, BCAL_Zmin+BCAL_Zlen, 2.0*M_PI); |
1935 | bcal1->SetFillColor(28); |
1936 | graphics_sideB.push_back(bcal1); |
1937 | |
1938 | |
1939 | TBox *cdc1 = new TBox(CDC_Zmin, 0.0, CDC_Zmin + CDC_Zlen, 2.0*M_PI); |
1940 | cdc1->SetFillColor(17); |
1941 | graphics_sideB.push_back(cdc1); |
1942 | |
1943 | |
1944 | for(int i=0; i<4; i++){ |
1945 | |
1946 | float zu = fdcwires[i*6][0]->origin.z(); |
1947 | float zd = fdcwires[i*6+5][0]->origin.z(); |
1948 | |
1949 | TBox *fdc1 = new TBox(zu, 0.0, zd, 2.0*M_PI); |
1950 | fdc1->SetFillColor(21); |
1951 | graphics_sideB.push_back(fdc1); |
1952 | } |
1953 | |
1954 | |
1955 | TBox *tof1 = new TBox(TOF_Zmin, 0.0, TOF_Zmin+TOF_Zlen, 2.0*M_PI); |
1956 | tof1->SetFillColor(11); |
1957 | graphics_sideB.push_back(tof1); |
1958 | |
1959 | |
1960 | TBox *fcal1 = new TBox(FCAL_Zmin, 0.0, FCAL_Zmin+FCAL_Zlen, 2.0*M_PI); |
1961 | fcal1->SetFillColor(40); |
1962 | graphics_sideB.push_back(fcal1); |
1963 | |
1964 | |
1965 | DrawScale(endviewA->GetCanvas(), graphics_endA); |
1966 | } |
1967 | |
1968 | |
1969 | { |
1970 | endviewA->GetCanvas()->cd(0); |
1971 | endviewA->GetCanvas()->Clear(); |
1972 | |
1973 | |
1974 | TBox *bcal1 = new TBox(0.0, BCAL_Rmin, 2.0*M_PI, BCAL_Rmax); |
1975 | bcal1->SetFillColor(28); |
1976 | graphics_endA.push_back(bcal1); |
1977 | |
1978 | |
1979 | TBox *cdc1 = new TBox(0.0, CDC_Rmin, 2.0*M_PI, CDC_Rmax); |
1980 | cdc1->SetFillColor(17); |
1981 | graphics_endA.push_back(cdc1); |
1982 | |
1983 | |
1984 | TBox *fdc1 = new TBox(0.0, FDC_Rmin, 2.0*M_PI, FDC_Rmax); |
1985 | fdc1->SetFillColor(21); |
1986 | graphics_endA.push_back(fdc1); |
1987 | |
1988 | |
1989 | TBox *target = new TBox(0.0, 0.0, 2.0*M_PI, 0.5); |
1990 | target->SetFillColor(13); |
1991 | graphics_endA.push_back(target); |
1992 | |
1993 | } |
1994 | |
1995 | |
1996 | { |
1997 | endviewB->GetCanvas()->cd(0); |
1998 | endviewB->GetCanvas()->Clear(); |
1999 | |
2000 | |
2001 | |
2002 | |
2003 | |
2004 | |
2005 | |
2006 | double blocksize = fcalgeom->blockSize(); |
2007 | DVector2 shift[8]; |
2008 | shift[0].Set(-blocksize/2, -blocksize/2); |
2009 | shift[1].Set(-blocksize/2, +blocksize/2); |
2010 | shift[2].Set(+blocksize/2, +blocksize/2); |
2011 | shift[3].Set(+blocksize/2, -blocksize/2); |
2012 | |
2013 | double insertSize=fcalgeom->insertSize(); |
2014 | if (insertSize>0){ |
2015 | blocksize=fcalgeom->insertBlockSize(); |
2016 | shift[4].Set(-blocksize/2, -blocksize/2); |
2017 | shift[5].Set(-blocksize/2, +blocksize/2); |
2018 | shift[6].Set(+blocksize/2, +blocksize/2); |
2019 | shift[7].Set(+blocksize/2, -blocksize/2); |
2020 | } |
2021 | fcalblocks.clear(); |
2022 | for(unsigned int chan=0; chan<fcalgeom->numChannels(); chan++){ |
2023 | if (fcalgeom->isBlockActive(chan)==false) continue; |
2024 | DVector2 fcalBlockPos=fcalgeom->positionOnFace(chan); |
2025 | |
2026 | double r[4], phi[4]; |
2027 | for(int i=0; i<4; i++){ |
2028 | DVector2 pos = fcalBlockPos; |
2029 | if (insertSize>0 |
2030 | && fabs(pos.X())<insertSize |
2031 | && fabs(pos.Y())<insertSize){ |
2032 | pos+=shift[i+4]; |
2033 | } |
2034 | else{ |
2035 | pos+=shift[i]; |
2036 | } |
2037 | r[i] = pos.Mod(); |
2038 | phi[i] = pos.Phi_0_2pi(pos.Phi()); |
2039 | } |
2040 | |
2041 | TPolyLine *poly = new TPolyLine(4, phi, r); |
2042 | poly->SetFillColor(18); |
2043 | poly->SetLineColor(kBlack); |
2044 | graphics_endB.push_back(poly); |
2045 | |
2046 | fcalblocks[chan] = poly; |
2047 | } |
2048 | } |
2049 | |
2050 | |
2051 | DrawAxes(sideviewA->GetCanvas(), graphics_sideA, "Z", "R"); |
2052 | DrawAxes(sideviewB->GetCanvas(), graphics_sideB, "Z", "#phi"); |
2053 | DrawAxes(endviewA->GetCanvas(), graphics_endA, "#phi", "R"); |
2054 | DrawAxes(endviewB->GetCanvas(), graphics_endB, "#phi", "R"); |
2055 | } |
2056 | |
2057 | |
2058 | |
2059 | |
2060 | void hdv_mainframe::DrawAxes(TCanvas *c, vector<TObject*> &graphics, const char *xlab, const char *ylab) |
2061 | { |
2062 | |
2063 | |
2064 | double x1 = c->GetX1(); |
2065 | double x2 = c->GetX2(); |
2066 | double y1 = c->GetY1(); |
2067 | double y2 = c->GetY2(); |
2068 | double deltax = x2-x1; |
2069 | deltax *= c->GetYsizeReal()/c->GetXsizeReal(); |
2070 | double deltay = y2-y1; |
2071 | double xlo = x1+0.04*deltax; |
2072 | double xhi = xlo + 0.075*deltax; |
2073 | double ylo = y1+0.04*deltay; |
2074 | double yhi = ylo + 0.075*deltay; |
2075 | TArrow *yarrow = new TArrow(xlo, ylo, xlo, yhi, 0.02, ">"); |
2076 | yarrow->SetLineWidth((Width_t)1.5); |
2077 | graphics.push_back(yarrow); |
2078 | |
2079 | TLatex *ylabel = new TLatex(xlo, yhi+0.005*deltay, ylab); |
2080 | ylabel->SetTextAlign(21); |
2081 | graphics.push_back(ylabel); |
2082 | |
2083 | TArrow *xarrow = new TArrow(xlo, ylo, xhi, ylo, 0.02, ">"); |
2084 | xarrow->SetLineWidth((Width_t)1.5); |
2085 | graphics.push_back(xarrow); |
2086 | |
2087 | TLatex *xlabel = new TLatex(xhi+0.005*deltax, ylo, xlab); |
2088 | xlabel->SetTextAlign(12); |
2089 | graphics.push_back(xlabel); |
2090 | } |
2091 | |
2092 | |
2093 | |
2094 | |
2095 | void hdv_mainframe::DrawScale(TCanvas *c, vector<TObject*> &graphics) |
2096 | { |
2097 | |
2098 | |
2099 | double x1 = c->GetX1(); |
2100 | double x2 = c->GetX2(); |
2101 | double y1 = c->GetY1(); |
2102 | double y2 = c->GetY2(); |
2103 | double deltax = x2-x1; |
2104 | double deltay = y2-y1; |
2105 | double p = floor(log(0.1*deltax)/log(10.0)); |
2106 | double m = floor(0.1*deltax/pow(10.0, p) + 0.5); |
2107 | double xlo = x1+0.72*deltax; |
2108 | double xhi = xlo + m*pow(10.0, p); |
2109 | double y = y1+0.04*deltay; |
2110 | TArrow *arrow = new TArrow(xlo, y, xhi, y, 0.02, "|-|"); |
2111 | arrow->SetLineWidth((Width_t)1.0); |
2112 | graphics.push_back(arrow); |
2113 | |
2114 | const char *units="<out of range>"; |
2115 | switch((int)p){ |
2116 | case -5: |
2117 | units = "#mum"; |
2118 | break; |
2119 | case -4: |
2120 | units = "#mum"; |
2121 | break; |
2122 | case -3: |
2123 | m*=10.0; |
2124 | units = "#mum"; |
2125 | break; |
2126 | case -2: |
2127 | m*=100.0; |
2128 | units="#mum"; |
2129 | break; |
2130 | case -1: |
2131 | units="mm"; |
2132 | break; |
2133 | case 0: |
2134 | units = "cm"; |
2135 | break; |
2136 | case 1: |
2137 | m*=10.0; |
2138 | units = "cm"; |
2139 | break; |
2140 | case 2: |
2141 | units = "m"; |
2142 | break; |
2143 | case 3: |
2144 | m*=10.0; |
2145 | units = "m"; |
2146 | break; |
2147 | case 4: |
2148 | m*=100.0; |
2149 | units = "m"; |
2150 | break; |
2151 | case 5: |
2152 | units = "km"; |
2153 | break; |
2154 | case 6: |
2155 | m*=10.0; |
2156 | units = "km"; |
2157 | break; |
2158 | } |
2159 | char str[256]; |
2160 | sprintf(str,"%d %s", (int)m, units); |
2161 | TLatex *label = new TLatex(xhi+0.01*deltax, y, str); |
2162 | label->SetTextAlign(12); |
2163 | graphics.push_back(label); |
2164 | } |
2165 | |
2166 | |
2167 | |
2168 | |
2169 | void hdv_mainframe::DrawLabel(TCanvas *c, vector<TObject*> &graphics, const char *txt) |
2170 | { |
2171 | |
2172 | |
2173 | |
2174 | double x1 = c->GetX1(); |
2175 | double x2 = c->GetX2(); |
2176 | double y1 = c->GetY1(); |
2177 | double y2 = c->GetY2(); |
2178 | double deltax = x2-x1; |
2179 | double deltay = y2-y1; |
2180 | deltax *= c->GetYsizeReal()/c->GetXsizeReal(); |
2181 | double x = x1 + 0.005*deltax; |
2182 | double y = y2 - 0.003*deltay; |
2183 | |
2184 | TLatex *label = new TLatex(x, y, txt); |
2185 | label->SetTextAlign(13); |
2186 | label->SetTextSize(0.045); |
2187 | graphics.push_back(label); |
2188 | } |
2189 | |
2190 | |
2191 | |
2192 | |
2193 | |
2194 | void hdv_mainframe::SetEvent(ULong64_t id) |
2195 | { |
2196 | if(!event)return; |
2197 | |
2198 | stringstream ss; |
2199 | ss << id; |
2200 | event->SetTitle(ss.str().c_str()); |
2201 | event->Draw(); |
2202 | } |
2203 | |
2204 | |
2205 | |
2206 | |
2207 | void hdv_mainframe::SetRun(Int_t id) |
2208 | { |
2209 | if(!event)return; |
2210 | |
2211 | stringstream ss; |
2212 | ss << id; |
2213 | run->SetTitle(ss.str().c_str()); |
2214 | run->Draw(); |
2215 | } |
2216 | |
2217 | |
2218 | |
2219 | |
2220 | void hdv_mainframe::SetTrig(char *trigstring) |
2221 | { |
2222 | if(!event)return; |
2223 | |
2224 | trig->SetTitle(trigstring); |
2225 | trig->Draw(); |
2226 | } |
2227 | |
2228 | |
2229 | |
2230 | |
2231 | |
2232 | void hdv_mainframe::SetSource(string source) |
2233 | { |
2234 | this->source->SetTitle(source.c_str()); |
2235 | this->source->Draw(); |
2236 | } |
2237 | |
2238 | |
2239 | |
2240 | |
2241 | void hdv_mainframe::SetCandidateFactories(vector<string> &facnames) |
2242 | { |
2243 | |
2244 | |
2245 | |
2246 | |
2247 | candidatesfactory->RemoveAll(); |
2248 | candidatesfactory->AddEntry("<default>", 0); |
2249 | candidatesfactory->GetTextEntry()->SetText("<default>"); |
2250 | candidatesfactory->Select(0, kFALSE); |
2251 | |
2252 | for(unsigned int i=0; i< facnames.size(); i++){ |
2253 | string name = "DTrackCandidate:"; |
2254 | string::size_type pos = facnames[i].find(name); |
2255 | if(pos==string::npos)continue; |
2256 | string tag = facnames[i]; |
2257 | tag.erase(0, name.size()); |
2258 | candidatesfactory->AddEntry(tag.c_str(), i); |
2259 | if(tag==default_candidate){ |
2260 | candidatesfactory->Select(i, kTRUE); |
2261 | candidatesfactory->GetTextEntry()->SetText(tag.c_str()); |
2262 | } |
2263 | } |
2264 | } |
2265 | |
2266 | |
2267 | |
2268 | |
2269 | void hdv_mainframe::SetWireBasedTrackFactories(vector<string> &facnames) |
2270 | { |
2271 | |
2272 | |
2273 | |
2274 | |
2275 | |
2276 | wiretracksfactory->RemoveAll(); |
2277 | wiretracksfactory->AddEntry("<default>", 0); |
2278 | wiretracksfactory->GetTextEntry()->SetText("<default>"); |
2279 | wiretracksfactory->Select(0, kFALSE); |
2280 | |
2281 | for(unsigned int i=0; i< facnames.size(); i++){ |
2282 | string name = "DTrackWireBased:"; |
2283 | string::size_type pos = facnames[i].find(name); |
2284 | if(pos==string::npos)continue; |
2285 | string tag = facnames[i]; |
2286 | tag.erase(0, name.size()); |
2287 | wiretracksfactory->AddEntry(tag.c_str(), i+1); |
2288 | if(tag==default_track){ |
2289 | wiretracksfactory->Select(i, kTRUE); |
2290 | wiretracksfactory->GetTextEntry()->SetText(tag.c_str()); |
2291 | } |
2292 | } |
2293 | } |
2294 | |
2295 | |
2296 | |
2297 | |
2298 | void hdv_mainframe::SetTimeBasedTrackFactories(vector<string> &facnames) |
2299 | { |
2300 | |
2301 | |
2302 | |
2303 | |
2304 | |
2305 | timetracksfactory->RemoveAll(); |
2306 | timetracksfactory->AddEntry("<default>", 0); |
2307 | timetracksfactory->GetTextEntry()->SetText("<default>"); |
2308 | timetracksfactory->Select(0, kFALSE); |
2309 | |
2310 | for(unsigned int i=0; i< facnames.size(); i++){ |
2311 | string name = "DTrackTimeBased:"; |
2312 | string::size_type pos = facnames[i].find(name); |
2313 | if(pos==string::npos)continue; |
2314 | string tag = facnames[i]; |
2315 | tag.erase(0, name.size()); |
2316 | timetracksfactory->AddEntry(tag.c_str(), i+1); |
2317 | if(tag==default_track){ |
2318 | timetracksfactory->Select(i, kTRUE); |
2319 | timetracksfactory->GetTextEntry()->SetText(tag.c_str()); |
2320 | } |
2321 | } |
2322 | } |
2323 | |
2324 | |
2325 | |
2326 | |
2327 | void hdv_mainframe::SetChargedTrackFactories(vector<string> &facnames) |
2328 | { |
2329 | |
2330 | |
2331 | |
2332 | |
2333 | |
2334 | chargedtracksfactory->RemoveAll(); |
2335 | chargedtracksfactory->AddEntry("<default>", 0); |
2336 | chargedtracksfactory->GetTextEntry()->SetText("<default>"); |
2337 | chargedtracksfactory->Select(0, kFALSE); |
2338 | |
2339 | for(unsigned int i=0; i< facnames.size(); i++){ |
2340 | string name = "DChargedTrack:"; |
2341 | string::size_type pos = facnames[i].find(name); |
2342 | if(pos==string::npos)continue; |
2343 | string tag = facnames[i]; |
2344 | tag.erase(0, name.size()); |
2345 | chargedtracksfactory->AddEntry(tag.c_str(), i+1); |
2346 | if(tag==default_track){ |
2347 | chargedtracksfactory->Select(i, kTRUE); |
2348 | chargedtracksfactory->GetTextEntry()->SetText(tag.c_str()); |
2349 | } |
2350 | } |
2351 | } |
2352 | |
2353 | |
2354 | |
2355 | |
2356 | |
2357 | |
2358 | void hdv_mainframe::SetReconstructedFactories(vector<string> &facnames) |
2359 | { |
2360 | |
2361 | |
2362 | |
2363 | |
2364 | |
2365 | int id =0; |
2366 | reconfactory->RemoveAll(); |
2367 | reconfactory->AddEntry("DTrackTimeBased:", id++); |
2368 | reconfactory->Select(0, kFALSE); |
2369 | reconfactory->GetTextEntry()->SetText("DTrackTimeBased:"); |
2370 | |
2371 | |
2372 | for(unsigned int i=0; i< facnames.size(); i++){ |
2373 | string name = "DTrackTimeBased:"; |
2374 | string::size_type pos = facnames[i].find(name); |
2375 | if(pos==string::npos)continue; |
2376 | string tag = facnames[i].substr(name.size(), facnames[i].size()-name.size()); |
2377 | reconfactory->AddEntry(facnames[i].c_str(), id++); |
2378 | if(facnames[i]==default_reconstructed){ |
2379 | reconfactory->Select(id-1, kTRUE); |
2380 | reconfactory->GetTextEntry()->SetText(facnames[i].c_str()); |
2381 | } |
2382 | } |
2383 | |
2384 | |
2385 | reconfactory->AddEntry("DTrackWireBased:", id++); |
2386 | for(unsigned int i=0; i< facnames.size(); i++){ |
2387 | string name = "DTrackWireBased:"; |
2388 | string::size_type pos = facnames[i].find(name); |
2389 | if(pos==string::npos)continue; |
2390 | string tag = facnames[i].substr(name.size(), facnames[i].size()-name.size()); |
2391 | reconfactory->AddEntry(facnames[i].c_str(), id++); |
2392 | if(facnames[i]==default_reconstructed){ |
2393 | reconfactory->Select(id-1, kTRUE); |
2394 | reconfactory->GetTextEntry()->SetText(facnames[i].c_str()); |
2395 | } |
2396 | } |
2397 | |
2398 | |
2399 | reconfactory->AddEntry("DTrackCandidate:", id++); |
2400 | for(unsigned int i=0; i< facnames.size(); i++){ |
2401 | string name = "DTrackCandidate:"; |
2402 | string::size_type pos = facnames[i].find(name); |
2403 | if(pos==string::npos)continue; |
2404 | string tag = facnames[i].substr(name.size(), facnames[i].size()-name.size()); |
2405 | reconfactory->AddEntry(facnames[i].c_str(), id++); |
2406 | if(facnames[i]==default_reconstructed){ |
2407 | reconfactory->Select(id-1, kTRUE); |
2408 | reconfactory->GetTextEntry()->SetText(facnames[i].c_str()); |
2409 | } |
2410 | } |
2411 | |
2412 | |
2413 | |
2414 | reconfactory->AddEntry("DNeutralParticle:", id++); |
2415 | for(unsigned int i=0; i< facnames.size(); i++){ |
2416 | string name = "DNeutralParticle:"; |
2417 | string::size_type pos = facnames[i].find(name); |
2418 | if(pos==string::npos)continue; |
2419 | string tag = facnames[i].substr(name.size(), facnames[i].size()-name.size()); |
2420 | reconfactory->AddEntry(facnames[i].c_str(), id++); |
2421 | if(facnames[i]==default_reconstructed){ |
2422 | reconfactory->Select(id-1, kTRUE); |
2423 | reconfactory->GetTextEntry()->SetText(facnames[i].c_str()); |
2424 | } |
2425 | } |
2426 | |
2427 | |
2428 | reconfactory->AddEntry("DChargedTrack:", id++); |
2429 | for(unsigned int i=0; i< facnames.size(); i++){ |
2430 | string name = "DChargedTrack:"; |
2431 | string::size_type pos = facnames[i].find(name); |
2432 | if(pos==string::npos)continue; |
2433 | string tag = facnames[i].substr(name.size(), facnames[i].size()-name.size()); |
2434 | reconfactory->AddEntry(facnames[i].c_str(), id++); |
2435 | if(facnames[i]==default_reconstructed){ |
2436 | reconfactory->Select(id-1, kTRUE); |
2437 | reconfactory->GetTextEntry()->SetText(facnames[i].c_str()); |
2438 | } |
2439 | } |
2440 | |
2441 | |
2442 | } |
2443 | |
2444 | |
2445 | |
2446 | |
2447 | bool hdv_mainframe::GetCheckButton(string who) |
2448 | { |
2449 | map<string, TGCheckButton*>::iterator iter = checkbuttons.find(who); |
2450 | if(iter==checkbuttons.end())return false; |
2451 | return iter->second->GetState()==kButtonDown; |
2452 | } |
2453 | |
2454 | |
2455 | |
2456 | void hdv_mainframe::AddCheckButtons(map<string, TGCheckButton*> &checkbuttons) |
2457 | { |
2458 | this->checkbuttons.insert(checkbuttons.begin(), checkbuttons.end()); |
2459 | } |
2460 | |
2461 | |
2462 | |
2463 | |
2464 | const char* hdv_mainframe::GetFactoryTag(string who) |
2465 | { |
2466 | const char *tag = ""; |
2467 | |
2468 | if(who=="DTrackWireBased"){ |
2469 | tag = wiretracksfactory->GetTextEntry()->GetTitle(); |
2470 | |
2471 | } |
2472 | if(who=="DTrackCandidate"){ |
2473 | tag = candidatesfactory->GetTextEntry()->GetTitle(); |
2474 | |
2475 | } |
2476 | if(who=="DTrackTimeBased"){ |
2477 | tag = timetracksfactory->GetTextEntry()->GetTitle(); |
2478 | |
2479 | } |
2480 | if (who=="DChargedTrack"){ |
2481 | tag=chargedtracksfactory->GetTextEntry()->GetTitle(); |
2482 | } |
2483 | if(string(tag) == "<default>")tag = ""; |
2484 | |
2485 | return tag; |
2486 | } |
2487 | |
2488 | |
2489 | |
2490 | |
2491 | void hdv_mainframe::GetReconFactory(string &name, string &tag) |
2492 | { |
2493 | if(!reconfactory) return; |
2494 | if(!reconfactory->GetSelectedEntry()) return; |
2495 | if(!reconfactory->GetSelectedEntry()->GetTitle()) return; |
2496 | string nametag(reconfactory->GetSelectedEntry()->GetTitle()); |
2497 | string::size_type pos = nametag.find(":"); |
2498 | name = nametag.substr(0, pos); |
2499 | tag = nametag.substr(pos+1, nametag.size()-(pos+1)); |
2500 | } |
2501 | |
2502 | |
2503 | |
2504 | |
2505 | TPolyLine* hdv_mainframe::GetFCALPolyLine(int channel) |
2506 | { |
2507 | map<int, TPolyLine*>::iterator iter = fcalblocks.find(channel); |
2508 | if(iter==fcalblocks.end())return NULL; |
2509 | return iter->second; |
2510 | } |
2511 | |
2512 | |
2513 | |
2514 | |
2515 | TPolyLine* hdv_mainframe::GetFCALPolyLine(int row, int column) |
2516 | { |
2517 | if(!fcalgeom)return NULL; |
2518 | return GetFCALPolyLine(fcalgeom->channel(row, column)); |
2519 | } |
2520 | |
2521 | |
2522 | |
2523 | |
2524 | TPolyLine* hdv_mainframe::GetCCALPolyLine(int row, int col) |
2525 | { |
2526 | int channel = col + 12*(row); |
2527 | map<int, TPolyLine*>::iterator iter = ccalblocks.find(channel); |
2528 | if(iter==ccalblocks.end())return NULL; |
2529 | return iter->second; |
2530 | } |
2531 | |
2532 | |
2533 | |
2534 | |
2535 | |
2536 | TPolyLine* hdv_mainframe::GetTOFPolyLine(int translate_side, int tof_ch) |
2537 | { |
2538 | map <int, map<int, TPolyLine*> >::iterator iter; |
2539 | iter = tofblocks.find(translate_side); |
2540 | map <int, TPolyLine*>::iterator iter2 = iter->second.find(tof_ch); |
2541 | if(iter2==iter->second.end())return NULL; |
2542 | return iter2->second; |
2543 | } |
2544 | |
2545 | |
2546 | |
2547 | |
2548 | TPolyLine* hdv_mainframe::GetBCALPolyLine(int module, int layer, int sector) |
2549 | { |
2550 | int chan = module*1000 + layer*100 + sector*10; |
2551 | map<int, TPolyLine*>::iterator iter = bcalblocks.find(chan); |
2552 | if(iter==bcalblocks.end()){ |
2553 | _DBG_<<"ERROR: No BCAL readout segment display poly for module="<<module<<" layer="<<layer<<" sector="<<sector<<endl; |
2554 | return NULL; |
2555 | } |
2556 | return iter->second; |
2557 | } |
2558 | |
2559 | |
2560 | |
2561 | |
2562 | void hdv_mainframe::AddGraphicsSideA(vector<TObject*> &v) |
2563 | { |
2564 | for(unsigned int i=0; i<v.size(); i++)graphics_sideA.push_back(v[i]); |
2565 | } |
2566 | |
2567 | |
2568 | |
2569 | |
2570 | void hdv_mainframe::AddGraphicsSideB(vector<TObject*> &v) |
2571 | { |
2572 | for(unsigned int i=0; i<v.size(); i++)graphics_sideB.push_back(v[i]); |
2573 | } |
2574 | |
2575 | |
2576 | |
2577 | |
2578 | void hdv_mainframe::AddGraphicsEndA(vector<TObject*> &v) |
2579 | { |
2580 | for(unsigned int i=0; i<v.size(); i++)graphics_endA.push_back(v[i]); |
2581 | } |
2582 | |
2583 | |
2584 | |
2585 | |
2586 | void hdv_mainframe::AddGraphicsEndB(vector<TObject*> &v) |
2587 | { |
2588 | for(unsigned int i=0; i<v.size(); i++)graphics_endB.push_back(v[i]); |
2589 | } |
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | |
21 | |
22 | |
23 | |
24 | |
25 | |
26 | |
27 | |
28 | |
29 | |
30 | |
31 | |
32 | |
33 | |
34 | |
35 | |
36 | |
37 | |
38 | |
39 | |
40 | |
41 | |
42 | |
43 | |
44 | |
45 | |
46 | |
47 | |
48 | |
49 | |
50 | |
51 | |
52 | |
53 | |
54 | |
55 | |
56 | |
57 | |
58 | |
59 | |
60 | #ifndef _STL_ITERATOR_H |
61 | #define _STL_ITERATOR_H 1 |
62 | |
63 | #include <bits/cpp_type_traits.h> |
64 | #include <ext/type_traits.h> |
65 | #include <bits/move.h> |
66 | |
67 | namespace std _GLIBCXX_VISIBILITY(default) |
68 | { |
69 | _GLIBCXX_BEGIN_NAMESPACE_VERSION |
70 | |
71 | |
72 | |
73 | |
74 | |
75 | |
76 | |
77 | |
78 | |
79 | |
80 | |
81 | |
82 | |
83 | |
84 | |
85 | |
86 | |
87 | |
88 | |
89 | |
90 | |
91 | |
92 | |
93 | |
94 | |
95 | template<typename _Iterator> |
96 | class reverse_iterator |
97 | : public iterator<typename iterator_traits<_Iterator>::iterator_category, |
98 | typename iterator_traits<_Iterator>::value_type, |
99 | typename iterator_traits<_Iterator>::difference_type, |
100 | typename iterator_traits<_Iterator>::pointer, |
101 | typename iterator_traits<_Iterator>::reference> |
102 | { |
103 | protected: |
104 | _Iterator current; |
105 | |
106 | typedef iterator_traits<_Iterator> __traits_type; |
107 | |
108 | public: |
109 | typedef _Iterator iterator_type; |
110 | typedef typename __traits_type::difference_type difference_type; |
111 | typedef typename __traits_type::pointer pointer; |
112 | typedef typename __traits_type::reference reference; |
113 | |
114 | |
115 | |
116 | |
117 | |
118 | |
119 | |
120 | reverse_iterator() : current() { } |
121 | |
122 | |
123 | |
124 | |
125 | explicit |
126 | reverse_iterator(iterator_type __x) : current(__x) { } |
127 | |
128 | |
129 | |
130 | |
131 | reverse_iterator(const reverse_iterator& __x) |
132 | : current(__x.current) { } |
133 | |
134 | |
135 | |
136 | |
137 | |
138 | template<typename _Iter> |
139 | reverse_iterator(const reverse_iterator<_Iter>& __x) |
140 | : current(__x.base()) { } |
141 | |
142 | |
143 | |
144 | |
145 | iterator_type |
146 | base() const |
147 | { return current; } |
148 | |
149 | |
150 | |
151 | |
152 | |
153 | |
154 | |
155 | |
156 | |
157 | |
158 | |
159 | reference |
160 | operator*() const |
161 | { |
162 | _Iterator __tmp = current; |
163 | return *--__tmp; |
164 | } |
165 | |
166 | |
167 | |
168 | |
169 | |
170 | |
171 | pointer |
172 | operator->() const |
173 | { return &(operator*()); } |
174 | |
175 | |
176 | |
177 | |
178 | |
179 | |
180 | reverse_iterator& |
181 | operator++() |
182 | { |
183 | --current; |
184 | return *this; |
185 | } |
186 | |
187 | |
188 | |
189 | |
190 | |
191 | |
192 | reverse_iterator |
193 | operator++(int) |
194 | { |
195 | reverse_iterator __tmp = *this; |
196 | --current; |
197 | return __tmp; |
198 | } |
199 | |
200 | |
201 | |
202 | |
203 | |
204 | |
205 | reverse_iterator& |
206 | operator--() |
207 | { |
208 | ++current; |
209 | return *this; |
210 | } |
211 | |
212 | |
213 | |
214 | |
215 | |
216 | |
217 | reverse_iterator |
218 | operator--(int) |
219 | { |
220 | reverse_iterator __tmp = *this; |
221 | ++current; |
222 | return __tmp; |
223 | } |
224 | |
225 | |
226 | |
227 | |
228 | |
229 | |
230 | reverse_iterator |
231 | operator+(difference_type __n) const |
232 | { return reverse_iterator(current - __n); } |
233 | |
234 | |
235 | |
236 | |
237 | |
238 | |
239 | |
240 | reverse_iterator& |
241 | operator+=(difference_type __n) |
242 | { |
243 | current -= __n; |
244 | return *this; |
245 | } |
246 | |
247 | |
248 | |
249 | |
250 | |
251 | |
252 | reverse_iterator |
253 | operator-(difference_type __n) const |
254 | { return reverse_iterator(current + __n); } |
255 | |
256 | |
257 | |
258 | |
259 | |
260 | |
261 | |
262 | reverse_iterator& |
263 | operator-=(difference_type __n) |
264 | { |
265 | current += __n; |
266 | return *this; |
267 | } |
268 | |
269 | |
270 | |
271 | |
272 | |
273 | |
274 | reference |
275 | operator[](difference_type __n) const |
276 | { return *(*this + __n); } |
277 | }; |
278 | |
279 | |
280 | |
281 | |
282 | |
283 | |
284 | |
285 | |
286 | |
287 | |
288 | |
289 | template<typename _Iterator> |
290 | inline bool |
291 | operator==(const reverse_iterator<_Iterator>& __x, |
292 | const reverse_iterator<_Iterator>& __y) |
293 | { return __x.base() == __y.base(); } |
294 | |
295 | template<typename _Iterator> |
296 | inline bool |
297 | operator<(const reverse_iterator<_Iterator>& __x, |
298 | const reverse_iterator<_Iterator>& __y) |
299 | { return __y.base() < __x.base(); } |
300 | |
301 | template<typename _Iterator> |
302 | inline bool |
303 | operator!=(const reverse_iterator<_Iterator>& __x, |
304 | const reverse_iterator<_Iterator>& __y) |
305 | { return !(__x == __y); } |
306 | |
307 | template<typename _Iterator> |
308 | inline bool |
309 | operator>(const reverse_iterator<_Iterator>& __x, |
310 | const reverse_iterator<_Iterator>& __y) |
311 | { return __y < __x; } |
312 | |
313 | template<typename _Iterator> |
314 | inline bool |
315 | operator<=(const reverse_iterator<_Iterator>& __x, |
316 | const reverse_iterator<_Iterator>& __y) |
317 | { return !(__y < __x); } |
318 | |
319 | template<typename _Iterator> |
320 | inline bool |
321 | operator>=(const reverse_iterator<_Iterator>& __x, |
322 | const reverse_iterator<_Iterator>& __y) |
323 | { return !(__x < __y); } |
324 | |
325 | template<typename _Iterator> |
326 | inline typename reverse_iterator<_Iterator>::difference_type |
327 | operator-(const reverse_iterator<_Iterator>& __x, |
328 | const reverse_iterator<_Iterator>& __y) |
329 | { return __y.base() - __x.base(); } |
330 | |
331 | template<typename _Iterator> |
332 | inline reverse_iterator<_Iterator> |
333 | operator+(typename reverse_iterator<_Iterator>::difference_type __n, |
334 | const reverse_iterator<_Iterator>& __x) |
335 | { return reverse_iterator<_Iterator>(__x.base() - __n); } |
336 | |
337 | |
338 | |
339 | template<typename _IteratorL, typename _IteratorR> |
340 | inline bool |
341 | operator==(const reverse_iterator<_IteratorL>& __x, |
342 | const reverse_iterator<_IteratorR>& __y) |
343 | { return __x.base() == __y.base(); } |
344 | |
345 | template<typename _IteratorL, typename _IteratorR> |
346 | inline bool |
347 | operator<(const reverse_iterator<_IteratorL>& __x, |
348 | const reverse_iterator<_IteratorR>& __y) |
349 | { return __y.base() < __x.base(); } |
350 | |
351 | template<typename _IteratorL, typename _IteratorR> |
352 | inline bool |
353 | operator!=(const reverse_iterator<_IteratorL>& __x, |
354 | const reverse_iterator<_IteratorR>& __y) |
355 | { return !(__x == __y); } |
356 | |
357 | template<typename _IteratorL, typename _IteratorR> |
358 | inline bool |
359 | operator>(const reverse_iterator<_IteratorL>& __x, |
360 | const reverse_iterator<_IteratorR>& __y) |
361 | { return __y < __x; } |
362 | |
363 | template<typename _IteratorL, typename _IteratorR> |
364 | inline bool |
365 | operator<=(const reverse_iterator<_IteratorL>& __x, |
366 | const reverse_iterator<_IteratorR>& __y) |
367 | { return !(__y < __x); } |
368 | |
369 | template<typename _IteratorL, typename _IteratorR> |
370 | inline bool |
371 | operator>=(const reverse_iterator<_IteratorL>& __x, |
372 | const reverse_iterator<_IteratorR>& __y) |
373 | { return !(__x < __y); } |
374 | |
375 | template<typename _IteratorL, typename _IteratorR> |
376 | #if __cplusplus >= 201103L |
377 | |
378 | inline auto |
379 | operator-(const reverse_iterator<_IteratorL>& __x, |
380 | const reverse_iterator<_IteratorR>& __y) |
381 | -> decltype(__y.base() - __x.base()) |
382 | #else |
383 | inline typename reverse_iterator<_IteratorL>::difference_type |
384 | operator-(const reverse_iterator<_IteratorL>& __x, |
385 | const reverse_iterator<_IteratorR>& __y) |
386 | #endif |
387 | { return __y.base() - __x.base(); } |
388 | |
389 | |
390 | |
391 | |
392 | |
393 | |
394 | |
395 | |
396 | |
397 | |
398 | |
399 | |
400 | |
401 | template<typename _Container> |
402 | class back_insert_iterator |
403 | : public iterator<output_iterator_tag, void, void, void, void> |
404 | { |
405 | protected: |
406 | _Container* container; |
407 | |
408 | public: |
409 | |
410 | typedef _Container container_type; |
411 | |
412 | |
413 | explicit |
414 | back_insert_iterator(_Container& __x) : container(&__x) { } |
415 | |
416 | |
417 | |
418 | |
419 | |
420 | |
421 | |
422 | |
423 | |
424 | |
425 | |
426 | |
427 | #if __cplusplus < 201103L |
428 | back_insert_iterator& |
429 | operator=(typename _Container::const_reference __value) |
430 | { |
431 | container->push_back(__value); |
432 | return *this; |
433 | } |
434 | #else |
435 | back_insert_iterator& |
436 | operator=(const typename _Container::value_type& __value) |
437 | { |
438 | container->push_back(__value); |
439 | return *this; |
440 | } |
441 | |
442 | back_insert_iterator& |
443 | operator=(typename _Container::value_type&& __value) |
444 | { |
445 | container->push_back(std::move(__value)); |
446 | return *this; |
447 | } |
448 | #endif |
449 | |
450 | |
451 | back_insert_iterator& |
452 | operator*() |
453 | { return *this; } |
454 | |
455 | |
456 | back_insert_iterator& |
457 | operator++() |
458 | { return *this; } |
459 | |
460 | |
461 | back_insert_iterator |
462 | operator++(int) |
463 | { return *this; } |
464 | }; |
465 | |
466 | |
467 | |
468 | |
469 | |
470 | |
471 | |
472 | |
473 | |
474 | |
475 | |
476 | |
477 | template<typename _Container> |
478 | inline back_insert_iterator<_Container> |
479 | back_inserter(_Container& __x) |
480 | { return back_insert_iterator<_Container>(__x); } |
481 | |
482 | |
483 | |
484 | |
485 | |
486 | |
487 | |
488 | |
489 | |
490 | |
491 | |
492 | template<typename _Container> |
493 | class front_insert_iterator |
494 | : public iterator<output_iterator_tag, void, void, void, void> |
495 | { |
496 | protected: |
497 | _Container* container; |
498 | |
499 | public: |
500 | |
501 | typedef _Container container_type; |
502 | |
503 | |
504 | explicit front_insert_iterator(_Container& __x) : container(&__x) { } |
505 | |
506 | |
507 | |
508 | |
509 | |
510 | |
511 | |
512 | |
513 | |
514 | |
515 | |
516 | |
517 | #if __cplusplus < 201103L |
518 | front_insert_iterator& |
519 | operator=(typename _Container::const_reference __value) |
520 | { |
521 | container->push_front(__value); |
522 | return *this; |
523 | } |
524 | #else |
525 | front_insert_iterator& |
526 | operator=(const typename _Container::value_type& __value) |
527 | { |
528 | container->push_front(__value); |
529 | return *this; |
530 | } |
531 | |
532 | front_insert_iterator& |
533 | operator=(typename _Container::value_type&& __value) |
534 | { |
535 | container->push_front(std::move(__value)); |
536 | return *this; |
537 | } |
538 | #endif |
539 | |
540 | |
541 | front_insert_iterator& |
542 | operator*() |
543 | { return *this; } |
544 | |
545 | |
546 | front_insert_iterator& |
547 | operator++() |
548 | { return *this; } |
549 | |
550 | |
551 | front_insert_iterator |
552 | operator++(int) |
553 | { return *this; } |
554 | }; |
555 | |
556 | |
557 | |
558 | |
559 | |
560 | |
561 | |
562 | |
563 | |
564 | |
565 | |
566 | |
567 | template<typename _Container> |
568 | inline front_insert_iterator<_Container> |
569 | front_inserter(_Container& __x) |
570 | { return front_insert_iterator<_Container>(__x); } |
571 | |
572 | |
573 | |
574 | |
575 | |
576 | |
577 | |
578 | |
579 | |
580 | |
581 | |
582 | |
583 | |
584 | |
585 | |
586 | template<typename _Container> |
587 | class insert_iterator |
588 | : public iterator<output_iterator_tag, void, void, void, void> |
589 | { |
590 | protected: |
591 | _Container* container; |
592 | typename _Container::iterator iter; |
593 | |
594 | public: |
595 | |
596 | typedef _Container container_type; |
597 | |
598 | |
599 | |
600 | |
601 | |
602 | insert_iterator(_Container& __x, typename _Container::iterator __i) |
603 | : container(&__x), iter(__i) {} |
604 | |
605 | |
606 | |
607 | |
608 | |
609 | |
610 | |
611 | |
612 | |
613 | |
614 | |
615 | |
616 | |
617 | |
618 | |
619 | |
620 | |
621 | |
622 | |
623 | |
624 | |
625 | |
626 | |
627 | |
628 | #if __cplusplus < 201103L |
629 | insert_iterator& |
630 | operator=(typename _Container::const_reference __value) |
631 | { |
632 | iter = container->insert(iter, __value); |
633 | ++iter; |
634 | return *this; |
635 | } |
636 | #else |
637 | insert_iterator& |
638 | operator=(const typename _Container::value_type& __value) |
639 | { |
640 | iter = container->insert(iter, __value); |
641 | ++iter; |
642 | return *this; |
643 | } |
644 | |
645 | insert_iterator& |
646 | operator=(typename _Container::value_type&& __value) |
647 | { |
648 | iter = container->insert(iter, std::move(__value)); |
649 | ++iter; |
650 | return *this; |
651 | } |
652 | #endif |
653 | |
654 | |
655 | insert_iterator& |
656 | operator*() |
657 | { return *this; } |
658 | |
659 | |
660 | insert_iterator& |
661 | operator++() |
662 | { return *this; } |
663 | |
664 | |
665 | insert_iterator& |
666 | operator++(int) |
667 | { return *this; } |
668 | }; |
669 | |
670 | |
671 | |
672 | |
673 | |
674 | |
675 | |
676 | |
677 | |
678 | |
679 | |
680 | |
681 | template<typename _Container, typename _Iterator> |
682 | inline insert_iterator<_Container> |
683 | inserter(_Container& __x, _Iterator __i) |
684 | { |
685 | return insert_iterator<_Container>(__x, |
686 | typename _Container::iterator(__i)); |
687 | } |
688 | |
689 | |
690 | |
691 | _GLIBCXX_END_NAMESPACE_VERSION |
692 | } |
693 | |
694 | namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) |
695 | { |
696 | _GLIBCXX_BEGIN_NAMESPACE_VERSION |
697 | |
698 | |
699 | |
700 | |
701 | |
702 | |
703 | |
704 | |
705 | using std::iterator_traits; |
706 | using std::iterator; |
707 | template<typename _Iterator, typename _Container> |
708 | class __normal_iterator |
709 | { |
710 | protected: |
711 | _Iterator _M_current; |
712 | |
713 | typedef iterator_traits<_Iterator> __traits_type; |
714 | |
715 | public: |
716 | typedef _Iterator iterator_type; |
717 | typedef typename __traits_type::iterator_category iterator_category; |
718 | typedef typename __traits_type::value_type value_type; |
719 | typedef typename __traits_type::difference_type difference_type; |
720 | typedef typename __traits_type::reference reference; |
721 | typedef typename __traits_type::pointer pointer; |
722 | |
723 | _GLIBCXX_CONSTEXPR __normal_iterator() : _M_current(_Iterator()) { } |
724 | |
725 | explicit |
726 | __normal_iterator(const _Iterator& __i) : _M_current(__i) { } |
727 | |
728 | |
729 | template<typename _Iter> |
730 | __normal_iterator(const __normal_iterator<_Iter, |
731 | typename __enable_if< |
732 | (std::__are_same<_Iter, typename _Container::pointer>::__value), |
733 | _Container>::__type>& __i) |
734 | : _M_current(__i.base()) { } |
735 | |
736 | |
737 | reference |
738 | operator*() const |
739 | { return *_M_current; } |
740 | |
741 | pointer |
742 | operator->() const |
743 | { return _M_current; } |
744 | |
745 | __normal_iterator& |
746 | operator++() |
747 | { |
748 | ++_M_current; |
749 | return *this; |
750 | } |
751 | |
752 | __normal_iterator |
753 | operator++(int) |
754 | { return __normal_iterator(_M_current++); } |
755 | |
756 | |
757 | __normal_iterator& |
758 | operator--() |
759 | { |
760 | --_M_current; |
761 | return *this; |
762 | } |
763 | |
764 | __normal_iterator |
765 | operator--(int) |
766 | { return __normal_iterator(_M_current--); } |
767 | |
768 | |
769 | reference |
770 | operator[](const difference_type& __n) const |
771 | { return _M_current[__n]; } |
772 | |
773 | __normal_iterator& |
774 | operator+=(const difference_type& __n) |
775 | { _M_current += __n; return *this; } |
776 | |
777 | __normal_iterator |
778 | operator+(const difference_type& __n) const |
779 | { return __normal_iterator(_M_current + __n); } |
780 | |
781 | __normal_iterator& |
782 | operator-=(const difference_type& __n) |
783 | { _M_current -= __n; return *this; } |
784 | |
785 | __normal_iterator |
786 | operator-(const difference_type& __n) const |
787 | { return __normal_iterator(_M_current - __n); } |
788 | |
789 | const _Iterator& |
790 | base() const |
791 | { return _M_current; } |
792 | }; |
793 | |
794 | |
795 | |
796 | |
797 | |
798 | |
799 | |
800 | |
801 | |
802 | |
803 | template<typename _IteratorL, typename _IteratorR, typename _Container> |
804 | inline bool |
805 | operator==(const __normal_iterator<_IteratorL, _Container>& __lhs, |
806 | const __normal_iterator<_IteratorR, _Container>& __rhs) |
807 | { return __lhs.base() == __rhs.base(); } |
808 | |
809 | template<typename _Iterator, typename _Container> |
810 | inline bool |
811 | operator==(const __normal_iterator<_Iterator, _Container>& __lhs, |
812 | const __normal_iterator<_Iterator, _Container>& __rhs) |
813 | { return __lhs.base() == __rhs.base(); } |
814 | |
815 | template<typename _IteratorL, typename _IteratorR, typename _Container> |
816 | inline bool |
817 | operator!=(const __normal_iterator<_IteratorL, _Container>& __lhs, |
818 | const __normal_iterator<_IteratorR, _Container>& __rhs) |
819 | { return __lhs.base() != __rhs.base(); } |
820 | |
821 | template<typename _Iterator, typename _Container> |
822 | inline bool |
823 | operator!=(const __normal_iterator<_Iterator, _Container>& __lhs, |
824 | const __normal_iterator<_Iterator, _Container>& __rhs) |
825 | { return __lhs.base() != __rhs.base(); } |
| 24 | | Assuming the condition is true | |
|
| 25 | | Returning the value 1, which participates in a condition later | |
|
826 | |
827 | |
828 | template<typename _IteratorL, typename _IteratorR, typename _Container> |
829 | inline bool |
830 | operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, |
831 | const __normal_iterator<_IteratorR, _Container>& __rhs) |
832 | { return __lhs.base() < __rhs.base(); } |
833 | |
834 | template<typename _Iterator, typename _Container> |
835 | inline bool |
836 | operator<(const __normal_iterator<_Iterator, _Container>& __lhs, |
837 | const __normal_iterator<_Iterator, _Container>& __rhs) |
838 | { return __lhs.base() < __rhs.base(); } |
839 | |
840 | template<typename _IteratorL, typename _IteratorR, typename _Container> |
841 | inline bool |
842 | operator>(const __normal_iterator<_IteratorL, _Container>& __lhs, |
843 | const __normal_iterator<_IteratorR, _Container>& __rhs) |
844 | { return __lhs.base() > __rhs.base(); } |
845 | |
846 | template<typename _Iterator, typename _Container> |
847 | inline bool |
848 | operator>(const __normal_iterator<_Iterator, _Container>& __lhs, |
849 | const __normal_iterator<_Iterator, _Container>& __rhs) |
850 | { return __lhs.base() > __rhs.base(); } |
851 | |
852 | template<typename _IteratorL, typename _IteratorR, typename _Container> |
853 | inline bool |
854 | operator<=(const __normal_iterator<_IteratorL, _Container>& __lhs, |
855 | const __normal_iterator<_IteratorR, _Container>& __rhs) |
856 | { return __lhs.base() <= __rhs.base(); } |
857 | |
858 | template<typename _Iterator, typename _Container> |
859 | inline bool |
860 | operator<=(const __normal_iterator<_Iterator, _Container>& __lhs, |
861 | const __normal_iterator<_Iterator, _Container>& __rhs) |
862 | { return __lhs.base() <= __rhs.base(); } |
863 | |
864 | template<typename _IteratorL, typename _IteratorR, typename _Container> |
865 | inline bool |
866 | operator>=(const __normal_iterator<_IteratorL, _Container>& __lhs, |
867 | const __normal_iterator<_IteratorR, _Container>& __rhs) |
868 | { return __lhs.base() >= __rhs.base(); } |
869 | |
870 | template<typename _Iterator, typename _Container> |
871 | inline bool |
872 | operator>=(const __normal_iterator<_Iterator, _Container>& __lhs, |
873 | const __normal_iterator<_Iterator, _Container>& __rhs) |
874 | { return __lhs.base() >= __rhs.base(); } |
875 | |
876 | |
877 | |
878 | |
879 | |
880 | template<typename _IteratorL, typename _IteratorR, typename _Container> |
881 | #if __cplusplus >= 201103L |
882 | |
883 | inline auto |
884 | operator-(const __normal_iterator<_IteratorL, _Container>& __lhs, |
885 | const __normal_iterator<_IteratorR, _Container>& __rhs) |
886 | -> decltype(__lhs.base() - __rhs.base()) |
887 | #else |
888 | inline typename __normal_iterator<_IteratorL, _Container>::difference_type |
889 | operator-(const __normal_iterator<_IteratorL, _Container>& __lhs, |
890 | const __normal_iterator<_IteratorR, _Container>& __rhs) |
891 | #endif |
892 | { return __lhs.base() - __rhs.base(); } |
893 | |
894 | template<typename _Iterator, typename _Container> |
895 | inline typename __normal_iterator<_Iterator, _Container>::difference_type |
896 | operator-(const __normal_iterator<_Iterator, _Container>& __lhs, |
897 | const __normal_iterator<_Iterator, _Container>& __rhs) |
898 | { return __lhs.base() - __rhs.base(); } |
899 | |
900 | template<typename _Iterator, typename _Container> |
901 | inline __normal_iterator<_Iterator, _Container> |
902 | operator+(typename __normal_iterator<_Iterator, _Container>::difference_type |
903 | __n, const __normal_iterator<_Iterator, _Container>& __i) |
904 | { return __normal_iterator<_Iterator, _Container>(__i.base() + __n); } |
905 | |
906 | _GLIBCXX_END_NAMESPACE_VERSION |
907 | } |
908 | |
909 | #if __cplusplus >= 201103L |
910 | |
911 | namespace std _GLIBCXX_VISIBILITY(default) |
912 | { |
913 | _GLIBCXX_BEGIN_NAMESPACE_VERSION |
914 | |
915 | |
916 | |
917 | |
918 | |
919 | |
920 | |
921 | |
922 | |
923 | |
924 | |
925 | |
926 | |
927 | |
928 | |
929 | template<typename _Iterator> |
930 | class move_iterator |
931 | { |
932 | protected: |
933 | _Iterator _M_current; |
934 | |
935 | typedef iterator_traits<_Iterator> __traits_type; |
936 | |
937 | public: |
938 | typedef _Iterator iterator_type; |
939 | typedef typename __traits_type::iterator_category iterator_category; |
940 | typedef typename __traits_type::value_type value_type; |
941 | typedef typename __traits_type::difference_type difference_type; |
942 | |
943 | typedef _Iterator pointer; |
944 | typedef value_type&& reference; |
945 | |
946 | move_iterator() |
947 | : _M_current() { } |
948 | |
949 | explicit |
950 | move_iterator(iterator_type __i) |
951 | : _M_current(__i) { } |
952 | |
953 | template<typename _Iter> |
954 | move_iterator(const move_iterator<_Iter>& __i) |
955 | : _M_current(__i.base()) { } |
956 | |
957 | iterator_type |
958 | base() const |
959 | { return _M_current; } |
960 | |
961 | reference |
962 | operator*() const |
963 | { return std::move(*_M_current); } |
964 | |
965 | pointer |
966 | operator->() const |
967 | { return _M_current; } |
968 | |
969 | move_iterator& |
970 | operator++() |
971 | { |
972 | ++_M_current; |
973 | return *this; |
974 | } |
975 | |
976 | move_iterator |
977 | operator++(int) |
978 | { |
979 | move_iterator __tmp = *this; |
980 | ++_M_current; |
981 | return __tmp; |
982 | } |
983 | |
984 | move_iterator& |
985 | operator--() |
986 | { |
987 | --_M_current; |
988 | return *this; |
989 | } |
990 | |
991 | move_iterator |
992 | operator--(int) |
993 | { |
994 | move_iterator __tmp = *this; |
995 | --_M_current; |
996 | return __tmp; |
997 | } |
998 | |
999 | move_iterator |
1000 | operator+(difference_type __n) const |
1001 | { return move_iterator(_M_current + __n); } |
1002 | |
1003 | move_iterator& |
1004 | operator+=(difference_type __n) |
1005 | { |
1006 | _M_current += __n; |
1007 | return *this; |
1008 | } |
1009 | |
1010 | move_iterator |
1011 | operator-(difference_type __n) const |
1012 | { return move_iterator(_M_current - __n); } |
1013 | |
1014 | move_iterator& |
1015 | operator-=(difference_type __n) |
1016 | { |
1017 | _M_current -= __n; |
1018 | return *this; |
1019 | } |
1020 | |
1021 | reference |
1022 | operator[](difference_type __n) const |
1023 | { return std::move(_M_current[__n]); } |
1024 | }; |
1025 | |
1026 | |
1027 | |
1028 | |
1029 | template<typename _IteratorL, typename _IteratorR> |
1030 | inline bool |
1031 | operator==(const move_iterator<_IteratorL>& __x, |
1032 | const move_iterator<_IteratorR>& __y) |
1033 | { return __x.base() == __y.base(); } |
1034 | |
1035 | template<typename _Iterator> |
1036 | inline bool |
1037 | operator==(const move_iterator<_Iterator>& __x, |
1038 | const move_iterator<_Iterator>& __y) |
1039 | { return __x.base() == __y.base(); } |
1040 | |
1041 | template<typename _IteratorL, typename _IteratorR> |
1042 | inline bool |
1043 | operator!=(const move_iterator<_IteratorL>& __x, |
1044 | const move_iterator<_IteratorR>& __y) |
1045 | { return !(__x == __y); } |
1046 | |
1047 | template<typename _Iterator> |
1048 | inline bool |
1049 | operator!=(const move_iterator<_Iterator>& __x, |
1050 | const move_iterator<_Iterator>& __y) |
1051 | { return !(__x == __y); } |
1052 | |
1053 | template<typename _IteratorL, typename _IteratorR> |
1054 | inline bool |
1055 | operator<(const move_iterator<_IteratorL>& __x, |
1056 | const move_iterator<_IteratorR>& __y) |
1057 | { return __x.base() < __y.base(); } |
1058 | |
1059 | template<typename _Iterator> |
1060 | inline bool |
1061 | operator<(const move_iterator<_Iterator>& __x, |
1062 | const move_iterator<_Iterator>& __y) |
1063 | { return __x.base() < __y.base(); } |
1064 | |
1065 | template<typename _IteratorL, typename _IteratorR> |
1066 | inline bool |
1067 | operator<=(const move_iterator<_IteratorL>& __x, |
1068 | const move_iterator<_IteratorR>& __y) |
1069 | { return !(__y < __x); } |
1070 | |
1071 | template<typename _Iterator> |
1072 | inline bool |
1073 | operator<=(const move_iterator<_Iterator>& __x, |
1074 | const move_iterator<_Iterator>& __y) |
1075 | { return !(__y < __x); } |
1076 | |
1077 | template<typename _IteratorL, typename _IteratorR> |
1078 | inline bool |
1079 | operator>(const move_iterator<_IteratorL>& __x, |
1080 | const move_iterator<_IteratorR>& __y) |
1081 | { return __y < __x; } |
1082 | |
1083 | template<typename _Iterator> |
1084 | inline bool |
1085 | operator>(const move_iterator<_Iterator>& __x, |
1086 | const move_iterator<_Iterator>& __y) |
1087 | { return __y < __x; } |
1088 | |
1089 | template<typename _IteratorL, typename _IteratorR> |
1090 | inline bool |
1091 | operator>=(const move_iterator<_IteratorL>& __x, |
1092 | const move_iterator<_IteratorR>& __y) |
1093 | { return !(__x < __y); } |
1094 | |
1095 | template<typename _Iterator> |
1096 | inline bool |
1097 | operator>=(const move_iterator<_Iterator>& __x, |
1098 | const move_iterator<_Iterator>& __y) |
1099 | { return !(__x < __y); } |
1100 | |
1101 | |
1102 | template<typename _IteratorL, typename _IteratorR> |
1103 | inline auto |
1104 | operator-(const move_iterator<_IteratorL>& __x, |
1105 | const move_iterator<_IteratorR>& __y) |
1106 | -> decltype(__x.base() - __y.base()) |
1107 | { return __x.base() - __y.base(); } |
1108 | |
1109 | template<typename _Iterator> |
1110 | inline auto |
1111 | operator-(const move_iterator<_Iterator>& __x, |
1112 | const move_iterator<_Iterator>& __y) |
1113 | -> decltype(__x.base() - __y.base()) |
1114 | { return __x.base() - __y.base(); } |
1115 | |
1116 | template<typename _Iterator> |
1117 | inline move_iterator<_Iterator> |
1118 | operator+(typename move_iterator<_Iterator>::difference_type __n, |
1119 | const move_iterator<_Iterator>& __x) |
1120 | { return __x + __n; } |
1121 | |
1122 | template<typename _Iterator> |
1123 | inline move_iterator<_Iterator> |
1124 | make_move_iterator(_Iterator __i) |
1125 | { return move_iterator<_Iterator>(__i); } |
1126 | |
1127 | template<typename _Iterator, typename _ReturnType |
1128 | = typename conditional<__move_if_noexcept_cond |
1129 | <typename iterator_traits<_Iterator>::value_type>::value, |
1130 | _Iterator, move_iterator<_Iterator>>::type> |
1131 | inline _ReturnType |
1132 | __make_move_if_noexcept_iterator(_Iterator __i) |
1133 | { return _ReturnType(__i); } |
1134 | |
1135 | |
1136 | |
1137 | _GLIBCXX_END_NAMESPACE_VERSION |
1138 | } |
1139 | |
1140 | #define _GLIBCXX_MAKE_MOVE_ITERATOR(_Iter) std::make_move_iterator(_Iter) |
1141 | #define _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(_Iter) \ |
1142 | std::__make_move_if_noexcept_iterator(_Iter) |
1143 | #else |
1144 | #define _GLIBCXX_MAKE_MOVE_ITERATOR(_Iter) (_Iter) |
1145 | #define _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(_Iter) (_Iter) |
1146 | #endif // C++11 |
1147 | |
1148 | #endif |