Multiple Sensitive Detectors

Hi guys,

If I have more than one logic volume and I want to associate a Sensitive Volume to each of them, how can I do?

Have I to replicate the SensitiveDetector.cc code calling it in different ways each time (e.x. SensitiveDetector1.cc, SensitiveDetector2.cc …) and the same for other classes such as Hit.cc or EventAction.cc? Or is there a quicker and more efficient way?

Regards

1 Like

Is your SD going to do the same thing each time, for each different LV? Are you going to save the same information in your Hit objects for all of the SDs?

If you want to do the same thing, then you only need one class, but you may want to create separate instances for each of your LVs. Similarly, if you’re saving the same information, use the same Hit class.

If your different LVs have unique identifiers (for example, the LV name combined with the PV copy number), then you can even have all your different SDs store hits into one single hit collection! Just include that unique identifier as part of your Hit data.

Hi @mkelsey,

Thanks for your reply.

Yes, I want to do the same things (collecting the same type of info) from each LV.

So, what do you mean when you suggest to create multiple instances? I tried to invoke two times the constructor of the sensitive detector class, but the building failed. It was written something like ‘declaration already done…’

Here I posted the code related to the sensitive volume definitions.

Is this because you tried to register the second instance into the SDManager with the same name string? That’s okay! In that case, don’t create multiple instances. Just get back the same instance you already registered, and attach it to each of the LVs in turn. You will have to have a unique identifier (as I discussed above) in order to distiguish hits in the different volumes.

How exactly could such an unique identifier be included to store the hits data?

If you’re using an SD with a HitsCollection and HitData object, then you can put whatever data you want to into the hit. If all the LV’s are the same, just different placements, then the placement “copy number” is a unique identifier. If the LVs are different, then the volume name could be used as a unique identifier.

If uniqueness is determined by the overall geometry structure, then you can use the G4Touchable passed into the SD to navigate the geometry to the particular hit and compute a unique identifier in whatever way you like.

Hi @mkelsey ,
Thanks. I suppose my LV’s are different since they have the same geometry (basically one is the copy of the other) but different names and placements.

So, following your suggestion, I should use their name as identifier and indeed this is what I would like to do by invoking the SD constructor. I was thinking that the problem in my code is not there, but in this statement:

fHitsCollection = new HitsCollection(SensitiveDetectorName, collectionName[0]);

and precisely in collectionName[0]. I imagine it’s an array, so I could put collectionName[0] for the first LV and collectionName[1] for the second one. Is it correct?

I googled it, but I didn’t find any useful suggestions.

Regards,
Valeria

That’s definitely a way to do it. In your constructor (or wherever you like, you populate that vector with a list of names. Then you can associate each name with a different LV.

Alternatively, put a unique identifier (like the LV name and/or the PV copy number) into your hit data, and use the same hits collection for all the SDs. Then you end up with one collection of all the hits in the event, but there’s a data member for each hit that tells you which detector was involved.

Doing that, and including that information in your output Ntuple, will make it easier to do correlation studies (multihit events, energy leakage, etc.) in your analysis.