Geant4 and our apps on Android

This section emphasize what is done on Android related to Geant4 following users questionning on the Geant4 forum about that point.

We must emphasize first that the way we do things for Android is by using a maximum of GL-ES from C/C++, then by bypassing good part of the java tools of an Android SDK, and then by using the "native way" through the Android NDK. The idea being to have a maximum of code (including the GUI!) to be the same for all platforms. This is highly exotic from an "Android developer purist" point of view and people wanting to following the official way to develop for Android must look elsewhere.

A roadmap

This being say, interested people can first look at the inexlib_android section describing the build of quite simple GL-ES applications by using the native way. One of it (exlib/gl) draws a bunch of triangles and lines, and the other one (exlib/sg) draws a cube by using the C++ inlib/sg scene graph manager. These apps are more here to help setup the dev environment doing GL-ES in a native way without having to engage, in a first step, in a complicated app.

After somone can look to the pmx section. This app is some quite simple "event display" to show the LHCb detector and some events in it. (pmx exists on GooglePlay, Apple iOS and Mac app stores). There is no Geant4 in it, then it is more easy to build, but it starts to bring more "serious" things related to physics by using more code of the inlib/sg scene graph manager.

The g4exa app is probably the app to look at from the point of view of someone having cloned one of the Geant4 example and wanting to attempt to go on Android (by using then our native exotic way). The g4exa/Android/jni/Android.mk and jni/geant4.mk are the files to look at to declare the Geant4 core to the Android build make system.

The g4view app is intended to be a more general app and contains then too much material for a Geant4 example cloner. Then we do not advise to start from it. In fact this app had been done because Apple rejected g4exa because it was... an example! Apple wants apps that "do something" (!) and an app as g4view which is presented at least as a viewer for the GDML file format is ok for them.

No Geant4 core cut-down

We must point out that in g4exa (as in the g4view or MEMPHYS_vis apps), there is no cut-down of the Geant4 core, if "cut-down" is taken in the sense of bringing all what is needed to run this (these) simulation. All what is needed, from the Geant4 core, to run this simulation is brought in the app. But, since g4exa is intended to be an app, and not a toolkit, that's right that all the Geant4 core binaries is not present in the final .apk. The linker, at end, sort out what is needed of Geant4 core for these apps. Must be said also that in the Geant4 source code, it had not been needed to crowd it with "ifdef ANDROID". It passes without problem (which is great! A lot of core software experiment developers should take example of that). It is rather remarkable that the final .apk is very, very light and passes easily the GooglePlay size limit.

Geant4 data files

One problem may anyway remain if targeting the stores; it is the size of the Geant4 data files. Here clearly all the data files "as it" (in particular the hadronic ones) explode the limits. For g4exa, we arranged to bring only what is needed to run this particular app. It is ok for this app, but may be a problem for other apps (it is a problem for the MEMPHYS_vis app). For the moment we have no clean solution to fix this problem. Google and Apple have some mechanism to handle "side data files" (because game developers need that), but it is not as clean as to "bring at once" all the material in the distribution kit. This is a pending problem.

Relation to G4/vis

For the moment we do not use the G4/vis system, but it was more to have free hands to put first a feet on these touchable platforms (Android and iOS) and sort out in first place a lot of technicalities. A lot is done now and having some G4/vis inlib/sg driver which would permit to bring G4/vis in our Android and iOS environment is something which may enter now in the scope...

Does it make sense?

In general, that's right that all this is definitely on the side of R&D and what to do with a Geant4 app on Android and iOS is quite not clear yet. For outreach and eduction that's right that there is a huge potential here; g4view is probably used by some just to show what an EM shower looks like (and its difference with what does a proton).

For display, running on something as a 12 inches iPad makes sense to us. The big challenge here is definitely around the ergonomy; we just can't imagine to give to people an app where they will have to type commands on a virtual keyboard to see something. (The problem would be the same for any generic analysis app and any event display of any HEP experiment). And here, it is quite amazing the kind of ergonomy Apple is able to reach on their apps; compared to, some academic "big science" areas look as living in a cave. (Well, in fact some, with their detectors, are!).

Geant4 contains a lot of informations about particles, materials, cross sections and all that; some application able to easily navigate and show these may make sense too.