DetectorHistogrammer empty when using module's redirection

Hello,

I am currently attempting to simulate a Timepix3 detector with CdTe. For this, I need to simulate two different digitizer behaviors (later would be different digitizers modules CSA and Default). However, when using module redirection the DetectorHistogrammer results appear empty, event after the input/output parameter is set accordingly to the reference manual. By using the output plots of both digitizers I can confirm the simulation chain works until them. The output plots from both digitizers confirm that the simulation chain functions correctly up until this point. Do you have any insights into what could be causing this behavior?

The general configuration file is:

[Allpix]
number_of_events = 100
detectors_file = "geometry.conf"
random_seed = 123456789

[GeometryBuilderGeant4]

[DepositionPointCharge]
source_type = "point"
model = "spot"
position = 7015um 7015um 950um
spot_size = 110um
number_of_charges = 100000  

[ElectricFieldReader]
model="constant"
bias_voltage = -800V
output_plots = 1

[GenericPropagation]
temperature = 300K
charge_per_step = 25
mobility_model = "constant"
mobility_electron = 1050cm*cm/V/s
mobility_hole = 104cm*cm/V/s
propagate_holes = 0
propagate_electrons = 1
integration_time = 300ns
output_plots = 1

[PulseTransfer]


[DefaultDigitizer]
output = "low_noise"
threshold = 1e
electronics_noise = 100e
output_plots = 1
output_plots_scale = 150ke

[DefaultDigitizer]
output = "high_noise"
threshold = 1e
electronics_noise = 500e
output_plots = 1
output_plots_scale = 150ke

[DetectorHistogrammer]
input = "low_noise"
max_cluster_charge = 150ke
granularity = 256, 256

[DetectorHistogrammer]
input = "high_noise"
max_cluster_charge = 150ke
granularity = 256, 256
output_plots = 1

and the geometry:

[detector1]
type = "timepix"
sensor_thickness = 2mm
sensor_material = "CADMIUM_TELLURIDE"
position = 0mm 0mm 0mm
orientation = 0 0 0

Thank you,
Sebastian

Dear @jseb

the reason is a bit intricate and only shows up on TRACE logging level:

|18:31:20.428|   (TRACE) Running event 3 [DetectorHistogrammer:detector1_low_noise]
|18:31:20.428|   (TRACE) Not all required messages are received for DetectorHistogrammer:detector1_low_noise, skipping module!
|18:31:20.428|   (TRACE) Running event 3 [DetectorHistogrammer:detector1_high_noise]
|18:31:20.428|   (TRACE) Not all required messages are received for DetectorHistogrammer:detector1_high_noise, skipping module!

The underlying reason is discussed in an old ticket and summarized below:

  • The DetectorHistogrammer requires two input messages: PixelHit and MCParticle, the former optional, the latter mandatory to be able to calculate efficiencies.
  • Your DepositionPointCharge dispatches MCParticle (unnamed message) and DepositedCharge.
  • The DefaultDigitizer receives an (unnamed) PixelCharge message and dispatches a named PixelHit.
  • The DetectorHistogrammer listens for high_noise-named messages, receives the named PixelHit message but no named MCParticle message.

I have not yet found a clean/clear way of solving this issue but I agree that the setup as you have it is a sensible configuration that we should make working.

The only solution I came up with so far is to write a MessageRelay module which you can find here:

[MessageRelay]
include = MCParticle
output = "low_noise"

which redispatches unnamed messages (in this case) under a new name:

|18:43:56.218|   (TRACE) (Event 3) [R:DepositionPointCharge:detector1] Sending message Message<allpix::MCParticle> from DepositionPointCharge:detector1 to generic listener MessageRelay:detector1_high_noise
[...]
|18:47:14.291|   (DEBUG) (Event 3) [R:MessageRelay:detector1_low_noise] Relaying 1 messages
|18:47:14.291|   (DEBUG) (Event 3) [R:MessageRelay:detector1_low_noise] Relaying message with 1 objects from detector detector1
|18:47:14.291|   (TRACE) (Event 3) [R:MessageRelay:detector1_low_noise] Sending message Message<allpix::MCParticle> from MessageRelay:detector1_low_noise to DetectorHistogrammer:detector1_low_noise
|18:47:14.291|   (TRACE) Running event 3 [DetectorHistogrammer:detector1_low_noise]
|18:47:14.291|   (DEBUG) (Event 3) [R:DetectorHistogrammer:detector1_low_noise] Received 2 pixel hits

However, in its current version (and probably the current version of the messaging system) this doesn’t work with multiple relays because messages start piling up… :confused:

|18:49:39.962|   (TRACE) Running event 3 [MessageRelay:detector1_low_noise]
|18:49:39.962|   (DEBUG) (Event 3) [R:MessageRelay:detector1_low_noise] Relaying 1 messages
|18:49:39.962|   (DEBUG) (Event 3) [R:MessageRelay:detector1_low_noise] Relaying message with 1 objects from detector detector1
|18:49:39.962|   (TRACE) (Event 3) [R:MessageRelay:detector1_low_noise] Sending message Message<allpix::MCParticle> from MessageRelay:detector1_low_noise to DetectorHistogrammer:detector1_low_noise
|18:49:39.962|   (TRACE) (Event 3) [R:MessageRelay:detector1_low_noise] Sending message Message<allpix::MCParticle> from MessageRelay:detector1_low_noise to generic listener MessageRelay:detector1_high_noise
|18:49:39.962|   (TRACE) (Event 3) [R:MessageRelay:detector1_low_noise] Message relay received Message<allpix::MCParticle> named low_noise

[...]
|18:49:39.984|   (TRACE) Running event 3 [MessageRelay:detector1_high_noise]
|18:49:39.984|   (DEBUG) (Event 3) [R:MessageRelay:detector1_high_noise] Relaying 2 messages
|18:49:39.984|   (DEBUG) (Event 3) [R:MessageRelay:detector1_high_noise] Relaying message with 1 objects from detector detector1
|18:49:39.984|   (TRACE) (Event 3) [R:MessageRelay:detector1_high_noise] Sending message Message<allpix::MCParticle> from MessageRelay:detector1_high_noise to DetectorHistogrammer:detector1_high_noise
|18:49:39.984|   (TRACE) (Event 3) [R:MessageRelay:detector1_high_noise] Sending message Message<allpix::MCParticle> from MessageRelay:detector1_high_noise to generic listener MessageRelay:detector1_low_noise
|18:49:39.984|   (TRACE) (Event 3) [R:MessageRelay:detector1_high_noise] Message relay received Message<allpix::MCParticle> named high_noise
|18:49:39.984|   (DEBUG) (Event 3) [R:MessageRelay:detector1_high_noise] Relaying message with 1 objects from detector detector1
|18:49:39.984|   (TRACE) (Event 3) [R:MessageRelay:detector1_high_noise] Sending message Message<allpix::MCParticle> from MessageRelay:detector1_high_noise to DetectorHistogrammer:detector1_high_noise
|18:49:39.985|   (FATAL) Error during execution of run:
                         Unexpected message Message<allpix::MCParticle> received by module DetectorHistogrammer:detector1_high_noise (only a single one expected per event)
                         Please check your configuration and modules. Cannot continue.

If you have a brilliant idea how to solve this, let me know! I’ll also return my thoughts to this a bit - it’s been a while :slight_smile:

All the best,
Simon

…some addition:

I just saw that this is literally the example we included in the manual :see_no_evil:

For some more reading on the message passing system, have a look at section 4 of the manual

Simon

Issue here: Message Passing Issues with Redirection (#280) · Issues · Allpix Squared / Allpix Squared · GitLab

Dear @simonspa,

Thank you very much for the detailed answer. I’m glad that I can assist the development by identifying undesired behavior :slight_smile.

Using your solution:

It works well for me when one digitizer is named and the other remains unnamed. The unnamed messages are caught by the other DetectorHistogrammer just fine. Of course, this is merely a workaround, and having two named outputs should be feasible.

Cheers,
Sebastian