Detector Multiplicity

How to select the detector multiplicity in GEANT4? I have about 100 small similar detector placed at different positions. Now to I want to store the energy when at least any two detector fired in each event.
How to implement it?

1 Like
  1. If the detectors are all identical, then create one single Logical Volume, and attach one single SensitiveDetector to that LV.

  2. Make sure that each placement has a unique “copyNumber.” If you do this manually, you need to write your code appropriately. If you use a PVReplica, then Geant4 will assign unique copy numbers according the the scheme you code.

  3. In your SD, get the copy number from the G4Touchable associated with the G4Step. Record that copy number in your N-tuple.

1 Like

Thank you so much. I created a single logical volume and attached the logical volume as my fScoringVolume. Now here I placed my logical volume at different theta phi using loop and got like this:

But @mkelsey I don’t know how to get the copy number from the G4Touchable associated with the G4Step.
In SteppingAction.cc file this is all I have

void B1SteppingAction::UserSteppingAction(const G4Step* step)
{
G4AnalysisManager *man = G4AnalysisManager::Instance();

G4LogicalVolume *volume = step->GetPreStepPoint()->GetTouchableHandle()->GetVolume()->GetLogicalVolume();

In example B5 I found :

auto touchable = step->GetPreStepPoint()->GetTouchable();
  auto rowNo = touchable->GetCopyNumber();
  G4cout<<" rowNo = "<<rowNo<<G4endl;

is it correct? How does this make sure that I am getting energy deposition in all detectors when any two detector fired in one event?

Yes, that’s correct; that’s why it’s in the example. Do you want the total of all energy deposits in all of your individual detectors, or do you want to keep separate records for each one? I encourage you to look at exampleB5 more completely. It does exactly what you’re trying to do, with a different geometry. It should show you what you need to do.

Thank you again .
I don’t want to keep separate records for each detector. I want single energy spectra as a total energy deposition of all individual detectors. But the condition I want to impose in each event any two detector must fired.
@mkelsey Yes, exampleB5 helps but I couldn’t get the idea how to implement the above condition.

Ah! You’re wanting to implement a coincidence trigger, and you don’t care which detectors fired. Do you want to do this with your simulation code, or do you think you’re going to want to look at other information later (like the pattern of which detectors fired in an event, or how much energy was deposited in the individual detectors)?

If you want to do it in your simulation, then you can set up your SD with a HitsCollection, and a very simple G4VHit subclass, with just two elements: a std::set<G4int> detsHit, and G4double Etotal. For every hit, insert the copyNumber into the detsHit set, and accumulate the energy deposit in Etotal.
At the end of your event, access that HitsCollection in your EventAction. detsHit.size() will tell you how many detectors were hit, and you can decide whether to save Etotal to your output or not.

If you want to be able to do more detailed analysis after the fact, I’d recommend creating an N-tuple with three columns: eventID, detector index (copy number), and Edep. You can fill the N-tuple directly in your SD, and you don’t need an EventAction. Then, in your analysis code you can read back the N-tuple and apply whatever filters you like.

1 Like

’d recommend creating an N-tuple with three columns: eventID, detector index (copy number), and Edep. You can fill the N-tuple directly in your SD, and you don’t need an EventAction. Then, in your analysis code you can read back the N-tuple and apply whatever filters you like.

This is a very good idea. I will try to implement it . Thank you very much.

I am also trying to do the same. I just ran the code and it worked fine,the visualization was correct but histogram is empty. Please help @mkelsey @shapeandsymmetry in this regard

I can help you definitely until I figure out what went wrong. Without having a look at your code Whether you are storing correctly or not it is difficult to comment for me. If you want , I can share my code with you only.

1 Like