Skip to content

Commit 53f0e6c

Browse files
update ldmx-sw analysis tutorial with more info about linking
1 parent da2c322 commit 53f0e6c

File tree

5 files changed

+60
-26
lines changed

5 files changed

+60
-26
lines changed

src/using/analysis/ana-cfg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from LDMX.Framework import ldmxcfg
22
p = ldmxcfg.Process('ana')
3-
p.sequence = [ ldmxcfg.Analyzer.from_file('MyAnalyzer.cxx') ]
3+
p.sequence = [ ldmxcfg.Analyzer.from_file('MyAnalyzer.cxx', needs=['Ecal_Event']) ]
44
p.inputFiles = [ 'events.root' ]
55
p.histogramFile = 'hist.root'

src/using/analysis/analyzer-total-rec-energy.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void MyAnalyzer::onProcessStart() {
2727
}
2828

2929
void MyAnalyzer::analyze(const framework::Event& event) {
30-
const auto& ecal_rec_hits{event.getCollection<ldmx::EcalHit>("EcalRecHits")};
30+
const auto& ecal_rec_hits{event.getCollection<ldmx::EcalHit>("EcalRecHits","")};
3131
double total = 0.0;
3232
for (const auto& hit : ecal_rec_hits) {
3333
total += hit.getEnergy();

src/using/analysis/gen.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from LDMX.Framework import ldmxcfg
2+
p = ldmxcfg.Process('test')
3+
from LDMX.SimCore import simulator as sim
4+
mySim = sim.simulator( "mySim" )
5+
mySim.setDetector( 'ldmx-det-v14-8gev', True )
6+
from LDMX.SimCore import generators as gen
7+
mySim.generators = [ gen.single_8gev_e_upstream_tagger() ]
8+
mySim.beamSpotSmear = [20.,80.,0.]
9+
mySim.description = 'Basic test Simulation'
10+
p.sequence = [ mySim ]
11+
p.run = 1
12+
p.maxEvents = 10000
13+
p.outputFiles = [ 'events.root' ]
14+
15+
import LDMX.Ecal.EcalGeometry
16+
import LDMX.Ecal.ecal_hardcoded_conditions
17+
import LDMX.Hcal.HcalGeometry
18+
import LDMX.Ecal.digi as ecal_digi
19+
20+
p.sequence = [
21+
mySim,
22+
ecal_digi.EcalDigiProducer(),
23+
ecal_digi.EcalRecProducer()
24+
]

src/using/analysis/ldmx-sw.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,39 @@ are located.
5454
```python
5555
{{#include ana-cfg.py}}
5656
```
57+
58+
~~~admonish error title="Unable to Load Library" collapsible=true
59+
If you see an error like the one below, you are probably not linking
60+
your stand-alone processor to its necessary libraries.
61+
The configuration script needs to be updated with `needs` listing
62+
the ldmx-sw libraries that the stand-alone processor needs to be
63+
linked to.
64+
65+
For example, this tutorial uses the Ecal hits defined in the
66+
`Ecal/Event` area which means we need to add `'Ecal_Event'` to
67+
the `needs` list.
68+
69+
Example error you could see...
70+
```
71+
$ denv fire ana-cfg.py
72+
---- LDMXSW: Loading configuration --------
73+
Processor source file /home/tom/code/ldmx/website/src/using/analysis/MyAnalyzer.cxx is newer than its compiled library
74+
/home/tom/code/ldmx/website/src/using/analysis/libMyAnalyzer.so (or library does not exist), recompiling...
75+
done compiling /home/tom/code/ldmx/website/src/using/analysis/MyAnalyzer.cxx
76+
---- LDMXSW: Configuration load complete --------
77+
---- LDMXSW: Starting event processing --------
78+
Warning in <TClass::Init>: no dictionary for class pair<int,ldmx::SimParticle> is available
79+
Warning in <TClass::Init>: no dictionary for class ldmx::SimParticle is available
80+
Warning in <TClass::Init>: no dictionary for class ldmx::SimTrackerHit is available
81+
Warning in <TClass::Init>: no dictionary for class ldmx::SimCalorimeterHit is available
82+
Warning in <TClass::Init>: no dictionary for class ldmx::HgcrocDigiCollection is available
83+
Warning in <TClass::Init>: no dictionary for class ldmx::EcalHit is available
84+
Warning in <TClass::Init>: no dictionary for class ldmx::CalorimeterHit is available
85+
86+
... proceeds to seg fault on getEnergy ...
87+
```
88+
~~~
89+
5790
A quick test can show that the code is compiling and running
5891
(although it will not print out anything or create any files).
5992
```

src/using/analysis/python.md

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -61,30 +61,7 @@ mv events.root path/to/work-area/
6161
```
6262
where `config.py` is the following python configuration script.
6363
```python
64-
from LDMX.Framework import ldmxcfg
65-
p = ldmxcfg.Process('test')
66-
from LDMX.SimCore import simulator as sim
67-
mySim = sim.simulator( "mySim" )
68-
mySim.setDetector( 'ldmx-det-v14-8gev', True )
69-
from LDMX.SimCore import generators as gen
70-
mySim.generators = [ gen.single_8gev_e_upstream_tagger() ]
71-
mySim.beamSpotSmear = [20.,80.,0.]
72-
mySim.description = 'Basic test Simulation'
73-
p.sequence = [ mySim ]
74-
p.run = 1
75-
p.maxEvents = 10_000
76-
p.outputFiles = [ 'events.root' ]
77-
78-
import LDMX.Ecal.EcalGeometry
79-
import LDMX.Ecal.ecal_hardcoded_conditions
80-
import LDMX.Hcal.HcalGeometry
81-
import LDMX.Ecal.digi as ecal_digi
82-
83-
p.sequence = [
84-
mySim,
85-
ecal_digi.EcalDigiProducer(),
86-
ecal_digi.EcalRecProducer()
87-
]
64+
{{#include gen.py}}
8865
```
8966
~~~
9067

0 commit comments

Comments
 (0)