Skip to content

Commit

Permalink
update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Zehvogel committed Apr 11, 2024
1 parent dbb8f2a commit 209f3fb
Showing 1 changed file with 16 additions and 68 deletions.
84 changes: 16 additions & 68 deletions doc/starterkit/k4MarlinWrapperCLIC/CEDViaWrapper.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
# Running an Event Display with EDM4hep input
# Running an Event Display with EDM4hep or LCIO input

It is possible to run the [C Event Display (CED)](https://github.com/iLCSoft/CED) via a wrapped [CEDViewer](https://github.com/iLCSoft/CEDViewer) Marlin Processor. This makes it possible to run the Event Dispaly with EDM4hep input files using an on the fly conversion to LCIO for CED. This introduction shows the basic concepts and also provides a options file that should work for most use cases. This example will be using the CLIC detector but should also work for other DD4hep detector models. The example is fully self contained, if you already have everything set up you can jump directly to [running the event display](#running-the-event-display).
It is possible to run the [C Event Display (CED)](https://github.com/iLCSoft/CED) via a wrapped [CEDViewer](https://github.com/iLCSoft/CEDViewer) Marlin Processor. This makes it possible to run the Event Display with EDM4hep input files using an on the fly conversion to LCIO for CED. This introduction shows the basic concepts and also provides a options file that should work for most use cases. This example will be using the CLIC detector but should also work for other DD4hep detector models. The example is fully self contained, if you already have everything set up you can jump directly to [running the event display](#running-the-event-display).

## Setting up an environment

Expand Down Expand Up @@ -53,87 +53,35 @@ You should now have a `gamma_10GeV_edm4hep.root` file containing 10 events.

## Running the event display

In order to run the event display via the `DDCEDViewer` we use the Marlin wrapper and attach an EDM4hep to LCIO converter to the wrapped processor. In the following we will build the complete Gaudi options file step by step. Here we simply present the most important steps, but do not go over all details of the `DDCEDViewer` configuration, for that it is probably best to directly look at the [CEDViewer repository](https://github.com/iLCSoft/CEDViewer) directly. The complete Gaudi configuration can be found in [`k4MarlinWrapper/examples/event_display.py`](https://github.com/key4hep/k4MarlinWrapper/blob/master/k4MarlinWrapper/examples/event_display.py) which is also installed at `$K4MARLINWRAPPER/examples/event_display.py`
In order to run the event display via the `DDCEDViewer` we use the Marlin wrapper. Here we simply present the most important steps, but do not go over all details of the `DDCEDViewer` configuration, for that it is probably best to directly look at the [CEDViewer repository](https://github.com/iLCSoft/CEDViewer) directly. The complete Gaudi configuration can be found in [`k4MarlinWrapper/examples/event_display.py`](https://github.com/key4hep/k4MarlinWrapper/blob/master/k4MarlinWrapper/examples/event_display.py) which is also installed at `$K4MARLINWRAPPER/examples/event_display.py`

To read EDM4hep input we use the `PodioInput` module and the `k4DataSvc`
```python
from Gaudi.Configuration import *
from Configurables import k4DataSvc, PodioInput

algList = []

evtsvc = k4DataSvc('EventDataSvc')
evtsvc.input = ''

inp = PodioInput('InputReader')
inp.collections = [
# ... all collections that should be read ...
]
In order to run the event display we first have to start the `glced` server program to which the wrapped `CEDViewer` processor will then connect. Starting the server and running the wrapped processor can be done via
```bash
glced &

algList.append(inp)
k4run $K4MARLINWRAPPER/examples/event_display.py --inputFiles=gamma_10GeV_edm4hep.root
```

The `DDCEDViewer` also requires setting up a DD4hep geometry, which can simply be done by wrapping the `InitializeDD4hep` Marlin Processor
```python
from Configurables import MarlinProcessorWrapper
If you want to run the event display for a different geometry you can do so with the `--compactFile` argument. However, depending on your detector model you might also need to change some of the `DDCEDViewer` parameters. The default compact file is `"CLICPerformance/Visualisation/CLIC_o3_v06_CED/CLIC_o3_v06_CED.xml"`.

MyInitializeDD4hep = MarlinProcessorWrapper("MyInitializeDD4hep")
MyInitializeDD4hep.OutputLevel = INFO
MyInitializeDD4hep.ProcessorType = "InitializeDD4hep"
MyInitializeDD4hep.Parameters = {
"DD4hepXMLFile": ["CLICPerformance/Visualisation/CLIC_o3_v06_CED/CLIC_o3_v06_CED.xml"]
}

algList.append(MyInitializeDD4hep)
```
Note that in this case we already have passed in the geometry that we want to use for the event display.
## Details

Finally, the main work is done by the `DDCEDViewer`, which we again use via the `MarlinProcessorWrapper` (omitting a lot of the detailed configuration here). In order to convert the EDM4hep inputs to LCIO we attach an `EDM4hep2LcioTool` to this algorithm
```python
from Configurables import EDM4hep2LcioTool
The main work is done by the `DDCEDViewer`, which we use via the `MarlinProcessorWrapper`. It is the following part of example `event_display.py`.

```python
MyCEDViewer = MarlinProcessorWrapper("MyCEDViewer")
MyCEDViewer.OutputLevel = INFO
MyCEDViewer.ProcessorType = "DDCEDViewer"
MyCEDViewer.Parameters = {
# ... lots of CEDViewer configuration ...
}

# EDM4hep to LCIO converter
edmConvTool = EDM4hep2LcioTool("EDM4hep2lcio")
edmConvTool.convertAll = True
edmConvTool.collNameMapping = {'MCParticles': 'MCParticle'}
edmConvTool.OutputLevel = DEBUG
MyCEDViewer.EDM4hep2LcioTool = edmConvTool

algList.append(MyCEDViewer)
```

The only thing that is left to do now is to put everything into the `ApplicationManager` in order to run things
```python
from Configurables import ApplicationMgr
ApplicationMgr( TopAlg = algList,
EvtSel = 'NONE',
EvtMax = 10,
ExtSvc = [evtsvc],
OutputLevel=INFO
)
```

With all these pieces put together (as in `examples/event_display.py`) it is now possible to run the event display. In order to run the event display we first have to start the `glced` server program to which the wrapped `CEDViewer` processor will then connect. Starting the server and running the wrapped processor can be done via
```bash
glced &

k4run $K4MARLINWRAPPER/examples/event_display.py --EventDataSvc.input=gamma_10GeV_edm4hep.root
```
Some of the more commonly used parameters have self explanatory names.

## Creating a Gaudi options file
## Troubleshooting / Using other detectors

The `event_display.py` options file that is used above and that is present in the examples has been produced following these steps:
- Using an `.slcio` input file and the desired geometry, run `ced2go` with the desired arguments.
- This produces a Marlin XML steering file on the fly and stores it at `/tmp/ced2go_${USER}_steering.xml`
- Using the `convertMarlinSteeringToGaudi.py` converter script convert this into a Gaudi options file
- Exchange the LCIO input reading by the podio input reading (see above)
- Attach the `EDM4hep2LcioTool` to the wrapped `CEDViewer` processor
When running this for a detector different than CLD, CLIC or ILD (or a derivative of one of them) you might not see anything in the event display.

This should allow one to arrive at a similar steering file even for slightly different configurations. One potential pitfall is the slightly different naming of the `ddsim` outputs between LCIO and EDM4hep (see [this issue](https://github.com/AIDASoft/DD4hep/issues/921)). This can be addressed by configuring the EDM4hep to LCIO converter (`edmConvTool` in the code above) to map the names accordingly.
If you are not seeing the detector make sure that it has the proper visualisation attributes, e.g. by comparing it to the compact file used above.
If you are not seeing any hits, tracks etc. from your event, make sure to add their collection names to the `DrawInLayer` list in the `DDCEDViewer` parameters.

0 comments on commit 209f3fb

Please sign in to comment.