1 | //
|
---|
2 | // All functions here should be OnX callbacks, that is to say
|
---|
3 | // functions with signature :
|
---|
4 | // extern "C" {
|
---|
5 | // void callback_without_arguments(Slash::UI::IUI&);
|
---|
6 | // void callback_with_arguments(Slash::UI::IUI&,const std::vector<std::string>&);
|
---|
7 | // }
|
---|
8 | //
|
---|
9 |
|
---|
10 | #include <OnX/Helpers/OnX.h>
|
---|
11 | #include <OnX/Helpers/Inventor.h>
|
---|
12 |
|
---|
13 | // Slash :
|
---|
14 | #include <Slash/Core/ISession.h>
|
---|
15 | #include <Slash/UI/IUI.h>
|
---|
16 |
|
---|
17 | // Lib :
|
---|
18 | #include <Lib/Manager.h>
|
---|
19 | #include <Lib/Out.h>
|
---|
20 |
|
---|
21 | // BatchLab :
|
---|
22 | #include <BatchLab/Helpers/AIDA.h>
|
---|
23 |
|
---|
24 | // OnXLab :
|
---|
25 | #include <OnXLab/Helpers/OnXLab.h>
|
---|
26 |
|
---|
27 | // G4Lab :
|
---|
28 | #include <G4Lab/Interfaces/IGeant4Manager.h>
|
---|
29 |
|
---|
30 | // ELYSE :
|
---|
31 | #include <ELYSE/IAppManager.hh>
|
---|
32 |
|
---|
33 | extern "C" {
|
---|
34 |
|
---|
35 | //////////////////////////////////////////////////////////////////////////////
|
---|
36 | //////////////////////////////////////////////////////////////////////////////
|
---|
37 | //////////////////////////////////////////////////////////////////////////////
|
---|
38 | void ELYSE_Initialize(
|
---|
39 | Slash::UI::IUI& aUI
|
---|
40 | )
|
---|
41 | //////////////////////////////////////////////////////////////////////////////
|
---|
42 | // Should be executed (in a widget create callback)
|
---|
43 | // when the GUI is constructed
|
---|
44 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
---|
45 | {
|
---|
46 | aUI.setCallback("OnX_File_exit","activate","DLD","G4Lab G4Lab_exit");
|
---|
47 | //StoreTrajectory customized in TrackingAction.
|
---|
48 | //aUI.executeScript("G4","/tracking/storeTrajectory 1");
|
---|
49 |
|
---|
50 | Slash::UI::ISoViewer* soViewer = ui_SoViewer(aUI);
|
---|
51 | if(soViewer) {
|
---|
52 | soViewer->setDecoration(true);
|
---|
53 | soViewer->setViewing(true);
|
---|
54 | }
|
---|
55 |
|
---|
56 | Slash::Core::ISession& session = aUI.session();
|
---|
57 |
|
---|
58 | session.setParameter("event.scan","yes");//Used in ELYSE_eventEnd callback.
|
---|
59 |
|
---|
60 | IGeant4Manager* g4Manager =
|
---|
61 | Lib_findManager(session,"Geant4Manager",IGeant4Manager);
|
---|
62 | if(!g4Manager) {
|
---|
63 | Lib::Out out(session.printer());
|
---|
64 | out << "ELYSE_Initialize :"
|
---|
65 | << " Geant4Manager not found."
|
---|
66 | << Lib::endl;
|
---|
67 | } else {
|
---|
68 | // Declare a callback executed at each end of event :
|
---|
69 | g4Manager->setEventEndScript("DLD","ELYSE ELYSE_eventEnd");
|
---|
70 | }
|
---|
71 |
|
---|
72 | ELYSE::IAppManager* appManager =
|
---|
73 | Lib_findManager(session,"ELYSE::AppManager",ELYSE::IAppManager);
|
---|
74 | if(!appManager) {
|
---|
75 | Lib::Out out(session.printer());
|
---|
76 | out << "ELYSE_Initialize :"
|
---|
77 | << " ELYSE::AppManager not found."
|
---|
78 | << Lib::endl;
|
---|
79 | } else {
|
---|
80 | // Create the Types. Initialize G4Lab SoNodes.
|
---|
81 | appManager->initialize();
|
---|
82 | }
|
---|
83 | }
|
---|
84 | //////////////////////////////////////////////////////////////////////////////
|
---|
85 | void ELYSE_Finalize(
|
---|
86 | Slash::UI::IUI&
|
---|
87 | )
|
---|
88 | //////////////////////////////////////////////////////////////////////////////
|
---|
89 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
---|
90 | {
|
---|
91 | }
|
---|
92 | //////////////////////////////////////////////////////////////////////////////
|
---|
93 | void ELYSE_Geant4_detector(
|
---|
94 | Slash::UI::IUI& aUI
|
---|
95 | )
|
---|
96 | //////////////////////////////////////////////////////////////////////////////
|
---|
97 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
---|
98 | {
|
---|
99 | Slash::Core::ISession& session = aUI.session();
|
---|
100 |
|
---|
101 | data_collect(session,"PV","name==\"waterTank\"");
|
---|
102 | data_visualize(session);
|
---|
103 |
|
---|
104 | data_collect(session,"PV","name==\"TyvekSheet\"");
|
---|
105 | data_visualize(session);
|
---|
106 |
|
---|
107 | data_collect(session,"PV","name==\"GlassVol\"");
|
---|
108 | data_visualize(session);
|
---|
109 |
|
---|
110 |
|
---|
111 |
|
---|
112 | }
|
---|
113 | //////////////////////////////////////////////////////////////////////////////
|
---|
114 | void ELYSE_analysis_closeTree(
|
---|
115 | Slash::UI::IUI& aUI
|
---|
116 | )
|
---|
117 | //////////////////////////////////////////////////////////////////////////////
|
---|
118 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
---|
119 | {
|
---|
120 | Slash::Core::ISession& session = aUI.session();
|
---|
121 |
|
---|
122 | ELYSE::IAppManager* appManager =
|
---|
123 | Lib_findManager(session,"ELYSE::AppManager",ELYSE::IAppManager);
|
---|
124 | if(!appManager) {
|
---|
125 | Lib::Out out(session.printer());
|
---|
126 | out << "ELYSE_analysis_closeTree :"
|
---|
127 | << " ELYSE::AnalysisManager not found."
|
---|
128 | << Lib::endl;
|
---|
129 | return;
|
---|
130 | }
|
---|
131 |
|
---|
132 | appManager->closeTree();
|
---|
133 | }
|
---|
134 |
|
---|
135 | //////////////////////////////////////////////////////////////////////////////
|
---|
136 | void ELYSE_plot_hits_times(
|
---|
137 | Slash::UI::IUI& aUI
|
---|
138 | )
|
---|
139 | //////////////////////////////////////////////////////////////////////////////
|
---|
140 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
---|
141 | {
|
---|
142 | Slash::Core::ISession& session = aUI.session();
|
---|
143 |
|
---|
144 | AIDA::IAnalysisFactory* aida = find_aida(session);
|
---|
145 | if(!aida) return;
|
---|
146 |
|
---|
147 | AIDA::ITree* memoryTree = find_memoryTree(*aida);
|
---|
148 | if(!memoryTree) return;
|
---|
149 |
|
---|
150 | std::string hname = "h_hits_times";
|
---|
151 | if(memoryTree->find(hname)) memoryTree->rm(hname);
|
---|
152 |
|
---|
153 | AIDA::IHistogram1D* h =
|
---|
154 | create_histogram1D(*aida,*memoryTree,hname,"Hits times.",100,0,3000);
|
---|
155 | if(!h) return;
|
---|
156 |
|
---|
157 | // Fill histogram with a data_collect :
|
---|
158 | data_collect(session,"WCPMT","");
|
---|
159 | data_number(session);
|
---|
160 |
|
---|
161 | data_fill1D(session,hname,"Times");
|
---|
162 |
|
---|
163 | // Get current plotter :
|
---|
164 | AIDA::IPlotter* plotter = create_plotter(*aida);
|
---|
165 | if(plotter) {
|
---|
166 | AIDA::IPlotterRegion& region = plotter->currentRegion();
|
---|
167 | region.plot(*h);
|
---|
168 | delete plotter;
|
---|
169 | }
|
---|
170 | }
|
---|
171 | #define MINIMUM(a,b) ((a)<(b)?a:b)
|
---|
172 | #define MAXIMUM(a,b) ((a)>(b)?a:b)
|
---|
173 | //////////////////////////////////////////////////////////////////////////////
|
---|
174 | void ELYSE_vis_bins(
|
---|
175 | Slash::UI::IUI& aUI
|
---|
176 | )
|
---|
177 | //////////////////////////////////////////////////////////////////////////////
|
---|
178 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
---|
179 | {
|
---|
180 | Slash::Core::ISession& session = aUI.session();
|
---|
181 |
|
---|
182 | Slash::UI::IWidget* cw = aUI.currentWidget();
|
---|
183 | Slash::UI::IWidget* widget = aUI.findWidget("Viewer_2");
|
---|
184 | if(!widget) return;
|
---|
185 | aUI.setCurrentWidget(widget);
|
---|
186 |
|
---|
187 | //FIXME : check that current region is a plotter.
|
---|
188 | data_collect(session,"SceneGraph","highlight==true");
|
---|
189 | data_filter(session,"name");
|
---|
190 |
|
---|
191 | std::vector<double> mins;
|
---|
192 | Lib::smanip::todoubles(data_values(session,"lowerEdge"),mins);
|
---|
193 | std::vector<double> maxs;
|
---|
194 | Lib::smanip::todoubles(data_values(session,"upperEdge"),maxs);
|
---|
195 | if(maxs.size()!=mins.size()) return;
|
---|
196 | if(!mins.size()) {
|
---|
197 | Lib::Out out(session.printer());
|
---|
198 | out << "ELYSE_vis_bins :"
|
---|
199 | << " no highlighted bins."
|
---|
200 | << Lib::endl;
|
---|
201 | return;
|
---|
202 | }
|
---|
203 | double mn = mins[0];
|
---|
204 | double mx = maxs[0];
|
---|
205 | for(unsigned int index=1;index<mins.size();index++) {
|
---|
206 | mn = MINIMUM(mn,mins[index]);
|
---|
207 | mx = MAXIMUM(mx,maxs[index]);
|
---|
208 | }
|
---|
209 |
|
---|
210 | Lib::Out out(session.printer());
|
---|
211 | out << "ELYSE_vis_bins :"
|
---|
212 | << " min " << mn
|
---|
213 | << " max " << mx
|
---|
214 | << Lib::endl;
|
---|
215 |
|
---|
216 | aUI.setCurrentWidget(cw);
|
---|
217 |
|
---|
218 | std::string filter;
|
---|
219 | Lib::smanip::printf(filter,128,"(!(Times<%g))&&(!(Times>=%g))",mn,mx);
|
---|
220 | data_collect(session,"WCPMT",filter);
|
---|
221 | data_visualize(session);
|
---|
222 | }
|
---|
223 |
|
---|
224 |
|
---|
225 | } // extern "C"
|
---|