A question about the definition of SD

Hi:
Hello experts, I have recently defined a model using G4PVParameterised, which is composed of square microelements of the same dimensions. Since the Physical Volumes are defined using G4PVParameterised, the Logical Volumes of each micro-element have the same name.

Start registering my SD in the ConstructSDandField function. Here is the procedure for registering my SD:

  auto ite = fScorers.cbegin();
  auto voxelSD = new DicomSD("voxelsd");
  G4SDManager::GetSDMpointer()->AddNewDetector(voxelSD);
  SetSensitiveDetector((*ite)->GetName(),voxelSD);

I store the Logical Volume of each micro element in fScorers and finally specify to define that object as SD by entering the name of the Logical Volume.

I would like to ask if my program can successfully define all the microelements as SD if all of them have the same name for Logical Volumes.

The SD will get passed in the G4Step* each time. You can get the G4Touchable from the G4Step, and then you get the replica number from the G4Touchable. Even though the LV name is the same, the copy number will tell you which little micro element was hit. If you need coordinates, you can also get that from the G4Step.

Hi:
Thank you for your answer.I can understand what you mean, this is just like the B5 example of HadCalorimeterSD file to locate the exact SD where the particle is located by replica number.

Does the program look like the following?

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

In fact, I have one more question, that is, when registering SD for Logical Volume with the same name whether I can achieve to define all Logical Volumes with the same name as SD by registering only once.

Here is my SD registration program, can I define 196608 micro elements as SD by writing it only once?

  auto ite = fScorers.cbegin();
  auto voxelSD = new DicomSD("voxelsd");
  G4SDManager::GetSDMpointer()->AddNewDetector(voxelSD);
  SetSensitiveDetector((*ite)->GetName(),voxelSD);

Also, I have a personal understanding of Hit in SD: if I don’t need to use Hit to store particle information, but fill the information in Step directly into ntuple is it possible for me to not call Hit in the ProcessHits function?

This way I can avoid calculating the numbering of SDs via G4Touchable, assuming of course that all the microelements are successfully defined as SDs.

I don’t know if I understand this correctly, and I don’t know if all Logical Volumes of the same name need only be registered once to be registered as SD.

Your first question,

No, you can’t. SDs are attached to the logical volume uniquely using the LV pointer. The function you show above, which does it by name, is probably part of your own code, is just a convenience. It spends extra time using the name string to search the G4LogicalVolumeStore to find the pointer. You could write your above code very slightly differently, and just call the LV function directly (read G4LogicalVolume.hh):

  (*ite)->SetSensitiveDetector(voxelSD);

However, you will still need some way to uniquely identify the volume within your SD code. Normally, that’s done by having a different SD instance attached to each LV, but if you do something like have a guaranteed unique placement copy number across all your LVs, that’s fine.

As for your second question,

Sure. If you’ve written your SD to directly populate an N-tuple, there’s no reason for you to create a hit object, or to fill a HitsCollection.

Thanks again for your help and guidance, for SD registration I will improve my code as you said, thanks a lot, this is really helpful for me.