]>
Commit | Line | Data |
---|---|---|
5a5a1232 | 1 | |
2 | #include "VSDSelector.h" | |
a8600b56 | 3 | #include "VSDEvent.h" |
5a5a1232 | 4 | #include "RGTopFrame.h" |
5 | ||
6 | #include <Reve/Track.h> | |
7 | #include <Reve/PointSet.h> | |
8 | ||
9 | #include <Reve/PODs.h> | |
10 | #include <Reve/TTreeTools.h> | |
11 | ||
12 | #include <TEventList.h> | |
13 | #include <TGLabel.h> | |
14 | #include <TGXYLayout.h> | |
15 | #include <TGClient.h> | |
16 | ||
17 | using namespace Reve; | |
18 | ||
19 | using Reve::Exc_t; | |
20 | ||
a8600b56 | 21 | VSDSelector::VSDSelector(TGCompositeFrame *tFrame) : |
265ecb21 | 22 | VSD(), |
23 | ||
265ecb21 | 24 | mParticleSelection(0), |
a8600b56 | 25 | fRecursiveSelect(0), |
26 | ||
265ecb21 | 27 | mHitSelection(0), |
28 | mClusterSelection(0), | |
a8600b56 | 29 | mRecSelection(0) |
265ecb21 | 30 | { |
5a5a1232 | 31 | //create gui |
32 | TGGroupFrame *gframe = new TGGroupFrame(tFrame, "Options", kVerticalFrame); | |
33 | TGLayoutHints* lh0 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY , 5, 5, 5, 5); | |
34 | gframe->SetTitlePos(TGGroupFrame::kRight); // right aligned | |
35 | tFrame->AddFrame(gframe, lh0); | |
5a5a1232 | 36 | |
37 | TGXYLayout* xyl = new TGXYLayout(gframe); | |
38 | gframe->SetLayoutManager(xyl); | |
39 | xyl->Layout(); | |
40 | ||
41 | TGXYLayoutHints* lh; | |
5a5a1232 | 42 | |
a8600b56 | 43 | UInt_t wH = 2; |
5a5a1232 | 44 | UInt_t labelw = 15; |
45 | UInt_t entryw = 39; | |
a8600b56 | 46 | UInt_t butw = 10; |
47 | ||
48 | Float_t x = 2, y = 2; | |
49 | ||
5a5a1232 | 50 | { |
51 | // particles | |
52 | TGLabel* label = new TGLabel(gframe, "ParticleSelection"); | |
53 | label->Resize(labelw, wH); | |
54 | label->SetTextJustify(kTextLeft | kTextCenterY); | |
55 | lh = new TGXYLayoutHints(x, y, labelw, wH,0); lh->SetPadLeft(2); lh->SetPadRight(2); | |
56 | gframe->AddFrame(label,lh); | |
57 | x += labelw ; | |
58 | ||
59 | mParticleSelection = new TGTextEntry(gframe, "fMother[0] == -1 && Pt() > 1"); | |
60 | mParticleSelection->Resize(entryw, wH); | |
61 | lh = new TGXYLayoutHints(x, y, entryw, wH,0); lh->SetPadLeft(2); lh->SetPadRight(2); | |
62 | gframe->AddFrame(mParticleSelection,lh); | |
63 | x += entryw+1; | |
64 | ||
65 | TGTextButton* but = new TGTextButton(gframe, "Select"); | |
66 | but->Resize(butw, wH); | |
67 | but->SetTextJustify(kTextCenterX | kTextCenterY); | |
68 | lh = new TGXYLayoutHints(x, y, butw, wH,0); lh->SetPadLeft(4); lh->SetPadRight(2); | |
69 | gframe->AddFrame(but,lh); | |
70 | but->Connect("Pressed()", "Reve::VSDSelector", this, "SelectParticles()"); | |
71 | ||
72 | UInt_t rbw = 11; | |
73 | x = x + butw + 0.5; | |
74 | fRecursiveSelect = new TGCheckButton(gframe, "Recursive"); | |
75 | fRecursiveSelect->Resize(rbw, wH); | |
76 | lh = new TGXYLayoutHints(x, y, rbw, wH,0); lh->SetPadLeft(4); lh->SetPadRight(2); | |
77 | gframe->AddFrame(fRecursiveSelect,lh); | |
78 | } | |
79 | x = 2.; | |
80 | y+= wH; y+= 1.; | |
81 | ||
82 | ||
83 | { // hits | |
84 | TGLabel* label = new TGLabel(gframe, "HitSelection"); | |
85 | label->Resize(labelw, wH); | |
86 | label->SetTextJustify(kTextLeft | kTextCenterY); | |
87 | lh = new TGXYLayoutHints(x, y, labelw, wH,0); lh->SetPadLeft(2); lh->SetPadRight(2); | |
88 | gframe->AddFrame(label,lh); | |
89 | x += labelw; | |
90 | ||
91 | mHitSelection = new TGTextEntry(gframe, "det_id == 0"); | |
92 | mHitSelection->Resize(entryw, wH); | |
93 | lh = new TGXYLayoutHints(x, y, entryw, wH,0); lh->SetPadLeft(2); lh->SetPadRight(2); | |
94 | gframe->AddFrame(mHitSelection,lh); | |
95 | x += entryw +1; | |
96 | ||
97 | TGTextButton* but = new TGTextButton(gframe, "Select"); | |
98 | but->Resize(butw, wH); | |
99 | but->SetTextJustify(kTextCenterX | kTextCenterY); | |
100 | lh = new TGXYLayoutHints(x, y, butw, wH,0); lh->SetPadLeft(4); lh->SetPadRight(2); | |
101 | gframe->AddFrame(but,lh); | |
102 | but->Connect("Pressed()", "Reve::VSDSelector", this, "SelectHits()"); | |
103 | ||
104 | } | |
105 | ||
106 | x = 2.; | |
107 | y+= wH; y+= 1.; | |
108 | ||
109 | { // particle selection | |
110 | TGLabel* label = new TGLabel(gframe, "ClusterSelection"); | |
111 | label->Resize(labelw, wH); | |
112 | label->SetTextJustify(kTextLeft | kTextCenterY); | |
113 | lh = new TGXYLayoutHints(x, y, labelw, wH,0); lh->SetPadLeft(2); lh->SetPadRight(2); | |
114 | gframe->AddFrame(label,lh); | |
115 | x += labelw; | |
116 | ||
eba2c372 | 117 | mClusterSelection = new TGTextEntry(gframe, "C.V.R() > 70"); |
5a5a1232 | 118 | mClusterSelection->Resize(entryw, wH); |
119 | lh = new TGXYLayoutHints(x, y, entryw, wH,0); lh->SetPadLeft(2); lh->SetPadRight(2); | |
120 | gframe->AddFrame(mClusterSelection,lh); | |
121 | x += entryw +1; | |
122 | ||
123 | TGTextButton* but = new TGTextButton(gframe, "Select"); | |
124 | but->Resize(butw, wH); | |
125 | but->SetTextJustify(kTextCenterX | kTextCenterY); | |
126 | lh = new TGXYLayoutHints(x, y, butw, wH,0); lh->SetPadLeft(4); lh->SetPadRight(2); | |
127 | gframe->AddFrame(but,lh); | |
128 | but->Connect("Pressed()", "Reve::VSDSelector", this, "SelectClusters()"); | |
a8600b56 | 129 | } |
130 | ||
131 | x = 2.; | |
5a5a1232 | 132 | y+= wH; y+= 1.; |
133 | ||
134 | { // reconstructed tracks selection | |
135 | TGLabel* label = new TGLabel(gframe, "RecSelection"); | |
136 | label->Resize(labelw, wH); | |
137 | label->SetTextJustify(kTextLeft | kTextCenterY); | |
138 | lh = new TGXYLayoutHints(x, y, labelw, wH,0); lh->SetPadLeft(2); lh->SetPadRight(2); | |
139 | gframe->AddFrame(label,lh); | |
140 | x += labelw; | |
141 | ||
142 | mRecSelection = new TGTextEntry(gframe, "Pt() > 1"); | |
143 | mRecSelection->Resize(entryw, wH); | |
144 | lh = new TGXYLayoutHints(x, y, entryw, wH,0); lh->SetPadLeft(2); lh->SetPadRight(2); | |
145 | gframe->AddFrame(mRecSelection,lh); | |
146 | x += entryw +1; | |
147 | ||
148 | TGTextButton* but = new TGTextButton(gframe, "Select"); | |
149 | but->Resize(butw, wH); | |
150 | but->SetTextJustify(kTextCenterX | kTextCenterY); | |
151 | lh = new TGXYLayoutHints(x, y, butw, wH,0); lh->SetPadLeft(4); lh->SetPadRight(2); | |
152 | gframe->AddFrame(but,lh); | |
153 | but->Connect("Pressed()", "Reve::VSDSelector", this, "SelectRecTracks()"); | |
154 | } | |
155 | ||
156 | gframe->Resize(60, 30); // resize to default size | |
157 | gframe->MapSubwindows(); | |
158 | gframe->MapWindow(); | |
159 | tFrame->MapSubwindows(); | |
160 | ||
161 | } | |
162 | ||
163 | /**************************************************************************/ | |
164 | ||
165 | void VSDSelector::LoadVSD(const Text_t* vsd_file_name, | |
166 | const Text_t* dir_name) | |
167 | { | |
168 | VSD::LoadVSD(vsd_file_name, dir_name); | |
a8600b56 | 169 | // !!!! Should create VSDEvent ... but it is not done yet. |
170 | EventBase* ev = new EventBase(vsd_file_name, dir_name); | |
171 | gReve->AddEvent(ev); | |
5a5a1232 | 172 | } |
173 | ||
174 | /**************************************************************************/ | |
175 | // selection methods | |
176 | /**************************************************************************/ | |
177 | ||
178 | void VSDSelector::SelectParticles(const Text_t* selection) | |
179 | { | |
180 | static const Exc_t eH("VSDSelector::SelectParticles "); | |
181 | ||
182 | if(mTreeK == 0) | |
183 | throw (eH + "kinematics not available."); | |
184 | ||
185 | if(selection == 0) | |
186 | selection = mParticleSelection->GetText(); | |
187 | ||
5a5a1232 | 188 | TTreeQuery evl; |
189 | Int_t n = evl.Select(mTreeK, selection); | |
190 | // printf("%d entries in selection '%s'.\n", n, selection); | |
191 | ||
192 | if(n == 0) | |
193 | throw (eH + "no entries found for selection in kinematics."); | |
194 | ||
a8600b56 | 195 | TrackList* cont = new TrackList(); |
196 | cont->GetRnrStyle()->SetColor(4); | |
197 | ||
198 | gReve->AddRenderElement(cont); | |
5a5a1232 | 199 | |
200 | if(n > 0) { | |
a8600b56 | 201 | Reve::PadHolder pHolder(true, gReve->GetGLCanvas()); |
5a5a1232 | 202 | for(Int_t i=0; i<n; i++) { |
203 | Int_t label = evl.GetEntry(i); | |
204 | mTreeK->GetEntry(label); | |
205 | Track* track = new Track(mpK, cont->GetRnrStyle()); | |
a8600b56 | 206 | track->SetName(Form("%s daughters:%d", mK.GetName(), mK.GetNDaughters())); |
207 | gReve->AddRenderElement(cont, track); | |
5a5a1232 | 208 | |
5a5a1232 | 209 | // printf("select daugters %s selection %s\n",mpK->GetName(),Form("fMother[0] == %d", track->GetLabel())); |
210 | if(fRecursiveSelect->IsOn()) { | |
211 | if(mK.GetNDaughters()) | |
a8600b56 | 212 | ImportDaughtersRec(track, cont, mK.GetFirstDaughter(), mK.GetLastDaughter()); |
5a5a1232 | 213 | // add decay point to path marks |
214 | if(mK.decayed) { | |
215 | Reve::PathMark* pm = new Reve::PathMark(Reve::PathMark::Decay); | |
216 | pm->V.x = mK.V_decay.x; | |
217 | pm->V.y = mK.V_decay.y; | |
218 | pm->V.z = mK.V_decay.z; | |
265ecb21 | 219 | track->AddPathMark(pm); |
5a5a1232 | 220 | } |
221 | } | |
222 | track->MakeTrack(); | |
223 | } | |
224 | cont->MakeMarkers(); | |
5a5a1232 | 225 | } |
226 | } | |
227 | ||
a8600b56 | 228 | void VSDSelector::ImportDaughtersRec(RenderElement* parent, TrackList* cont, |
5a5a1232 | 229 | Int_t first, Int_t last) |
230 | { | |
a8600b56 | 231 | Track* mother = dynamic_cast<Track*>(parent); |
5a5a1232 | 232 | |
233 | for(Int_t i=first; i<=last; i++) { | |
234 | mTreeK->GetEntry(i); | |
235 | Track* track = new Track(mpK, cont->GetRnrStyle()); | |
a8600b56 | 236 | track->SetName(Form("%s daughters:%d", mK.GetName(), mK.GetNDaughters())); |
237 | gReve->AddRenderElement(parent, track); | |
238 | cont->AddElement(track); // ?? is this ok ?? | |
5a5a1232 | 239 | if(mK.GetNDaughters()) |
a8600b56 | 240 | ImportDaughtersRec(track, cont, mK.GetFirstDaughter(), mK.GetLastDaughter()); |
5a5a1232 | 241 | |
242 | // add daughter mark to mother | |
243 | Reve::PathMark* dam = new Reve::PathMark(Reve::PathMark::Daughter); | |
244 | dam->V.x = mK.Vx(); | |
245 | dam->V.y = mK.Vy(); | |
246 | dam->V.z = mK.Vz(); | |
265ecb21 | 247 | mother->AddPathMark(dam); |
5a5a1232 | 248 | |
249 | if(mK.decayed) { | |
250 | Reve::PathMark* decm = new Reve::PathMark(Reve::PathMark::Decay); | |
251 | decm->V.x = mK.V_decay.x; | |
252 | decm->V.y = mK.V_decay.y; | |
253 | decm->V.z = mK.V_decay.z; | |
265ecb21 | 254 | track->AddPathMark(decm); |
5a5a1232 | 255 | |
256 | } | |
257 | track->MakeTrack(); | |
258 | } | |
259 | } | |
a8600b56 | 260 | |
261 | /**************************************************************************/ | |
5a5a1232 | 262 | /**************************************************************************/ |
263 | ||
264 | void VSDSelector::SelectHits() | |
265 | { | |
266 | static const Exc_t eH("VSDSelector::SelectHits "); | |
267 | ||
268 | if(mTreeH == 0) | |
269 | throw (eH + "hits not available."); | |
270 | ||
271 | const Text_t* selection; | |
272 | if(mHitSelection) | |
273 | selection = mHitSelection->GetText(); | |
274 | else | |
eba2c372 | 275 | selection ="1"; |
5a5a1232 | 276 | |
277 | TTreeQuery evl; | |
278 | Int_t n = evl.Select(mTreeH, selection); | |
279 | // printf("ImportHitsWithSelection %d entries for selection %s\n", n, selection); | |
280 | ||
281 | if(n==0) | |
282 | throw(eH + "no hits matching selection."); | |
283 | ||
284 | PointSet* container = new PointSet | |
285 | (Form("Hits %s", selection), n); | |
286 | for(Int_t i=0; i<n; i++) { | |
287 | const Int_t entry = evl.GetEntry(i); | |
288 | mTreeH->GetEntry(entry); | |
289 | container->SetPoint(i, mH.V.x, mH.V.y, mH.V.z); | |
290 | } | |
291 | ||
eba2c372 | 292 | container->SetTitle(Form("N=%d", container->GetN())); |
293 | container->SetMarkerColor(2); | |
294 | container->SetMarkerStyle(20); | |
a8600b56 | 295 | container->SetMarkerSize(0.5); |
5a5a1232 | 296 | gReve->AddRenderElement(container); |
a8600b56 | 297 | gReve->Redraw3D(); |
5a5a1232 | 298 | } |
299 | ||
300 | /**************************************************************************/ | |
301 | ||
302 | void VSDSelector::SelectClusters() | |
303 | { | |
304 | static const Exc_t eH("VSDSelector::SelectClusters "); | |
305 | ||
306 | if(mTreeC == 0) | |
307 | throw (eH + "clusters not available."); | |
308 | ||
309 | const Text_t* selection; | |
310 | if (mClusterSelection) | |
311 | selection = mClusterSelection->GetText(); | |
312 | else | |
eba2c372 | 313 | selection ="1"; |
5a5a1232 | 314 | |
315 | TTreeQuery evl; | |
316 | Int_t n = evl.Select(mTreeC, selection); | |
317 | printf(" cluster Selection %d entries for selection %s\n", n, selection); | |
318 | ||
319 | if(n==0) | |
320 | throw(eH + "no clusters matching selection."); | |
321 | ||
322 | PointSet* container = new PointSet | |
323 | (Form("Clusters %s", selection), n); | |
324 | for(Int_t i=0; i<n; i++) { | |
325 | const Int_t entry = evl.GetEntry(i); | |
326 | mTreeC->GetEntry(entry); | |
327 | container->SetPoint(i, mC.V.x, mC.V.y, mC.V.z); | |
328 | } | |
329 | ||
eba2c372 | 330 | container->SetTitle(Form("N=%d", container->GetN())); |
331 | container->SetMarkerColor(9); | |
332 | container->SetMarkerStyle(20); | |
a8600b56 | 333 | container->SetMarkerSize(0.5); |
eba2c372 | 334 | gReve->AddRenderElement(container); |
a8600b56 | 335 | gReve->Redraw3D(); |
5a5a1232 | 336 | } |
eba2c372 | 337 | |
5a5a1232 | 338 | /**************************************************************************/ |
339 | ||
340 | void VSDSelector::SelectRecTracks() | |
341 | { | |
342 | static const Exc_t eH("VSDSelector::SelectRecTracks "); | |
343 | ||
344 | if(mTreeR == 0) | |
345 | throw (eH + "reconstructed tracks not available."); | |
346 | ||
347 | const Text_t* selection; | |
348 | if(mRecSelection) | |
349 | selection = mRecSelection->GetText(); | |
350 | else | |
351 | selection = "Pt() > 1"; | |
352 | ||
353 | TTreeQuery evl; | |
354 | Int_t n = evl.Select(mTreeR, selection); | |
355 | // printf("%d entries in selection %s \n", n, selection); | |
356 | ||
357 | if (n == 0) | |
358 | throw (eH + "No entries found in ESD data."); | |
359 | ||
360 | if(n > 0) { | |
a8600b56 | 361 | TrackList* cont = new TrackList(Form("RecTracks %s [%d]",selection, n), n); |
362 | cont->GetRnrStyle()->SetColor(6); | |
363 | ||
364 | gReve->AddRenderElement(cont); | |
365 | ||
5a5a1232 | 366 | for (Int_t i=0; i<n; i++) { |
367 | Int_t label = evl.GetEntry(i); | |
368 | mTreeR->GetEntry(label); | |
369 | Track* track = new Track(mpR, cont->GetRnrStyle()); | |
370 | track->MakeTrack(); | |
5a5a1232 | 371 | |
a8600b56 | 372 | gReve->AddRenderElement(cont, track); |
5a5a1232 | 373 | } |
5a5a1232 | 374 | cont->MakeMarkers(); |
a8600b56 | 375 | gReve->Redraw3D(); |
5a5a1232 | 376 | } |
377 | } |