1 I can not find the definition of “collectionName” and “SensitiveDetectorName”. It seems like user define not the G4class has. But this program can run well.(I do not find these in Geant4 Book For Application Developers Release 11.1)
2 In the function"Initialize", the mean of this new TrackerHistCollection is what. It means append a collection to sensitivedetector?
It’s a container (think like std::vector or std::map) that TrackerSD will use to store any hits created in its ProcessHits member function. So you can think of it as “appending” a collection, but it’s really just holding a pointer to the collection for the current event that this SD will use.
No, the association of sensitive detectors to logical volumes is handled in the ConstructSDandField() member function of the detector construction. These lines are registering the newly constructed TrackerHitsCollection object with the set of all hits collections for the event, G4HCofThisEvent. Example Basic/B5 demonstrates how this works with multiple sensitive detectors and hit collections.
Thanks, I think I have deeper understanding about the meaning of these functions, and next time I try to use LXR code browser to search the information.
And I want to ask another question about the data handling. In the exampleB2 and B3, the author use sensitive detector to handle the specific logical volumes, and use the hit G4VHit G4THitsCollection to handle the data. In B3, the author uses the G4VPrimitiveScorer to handle datas. In B3b, the author uses G4run class to handle data.
I find the G4 gives us varity of ways to handle data. But if there are some ways better than others? If there some reference material or answers or some valuable experience in your practice?
My teacher tells us we can use G4RootAnalysisManager in runAction. In BeginOfRunAction() to create root file and TTree. In UserSteppingAction() of stepingAction, we can get the information we want, and Fill them to the root. And we can use StackingAction to change the state of our simulation, use TrackingAction, EventAcion an so on to meet demand.
After simulation, we use ROOT to analysis our data. I want to know weather this way can achieve the same goal in extend or basic examples. I have learned Root, and I can use root to do some analysis. If
this way can achieve same goal, I will try to use it when I plan to use G4 to do my project.
Indeed there are different way to get information of your simulation. I would say the SensitiveDetector way is probably THE way to go if you intend to analyze your simulation event-by-event.
If on the other hand you mainly care for the accumulated response, I would probably have a look at the different Scorers.
Now… independent on which way you go, you can always dump the acquired information at different stages (Step, Event, Run) to file using the G4Analysis class which includes options like CSV, ROOT, …
thank you very much. These days I sees lots of examples, and sensitive detector or scorers are convenient to get the information. while to only record original information of G4step and anlysis these data may be some too trouble.
and I have a new quesion about scorers and sensitive detector.
If I let a SD to a Logical Volume, such as
example B2a
G4String trackerChamberSDname = "B2/TrackerChamberSD";
auto aTrackerSD = new TrackerSD(trackerChamberSDname, "TrackerHitsCollection");
G4SDManager::GetSDMpointer()->AddNewDetector(aTrackerSD);
SetSensitiveDetector( fLogicChamber, aTrackerSD );
If the fLogicChamber has lots of copies, whether only the “B2/TrackerChamberSD” only create one “TrackerHitsCollection” in one event. If the particle is in the fLogicChamber (lots of fLogicChamber), the ProcessHit() will be called .
Another question is about scores. such as G4PSEnergyDeposit (use G4HitMap). If
example B4d
// declare Absorber as a MultiFunctionalDetector scorer
//
auto absDetector = new G4MultiFunctionalDetector("Absorber");
G4SDManager::GetSDMpointer()->AddNewDetector(absDetector);
G4VPrimitiveScorer* primitive;
primitive = new G4PSEnergyDeposit("Edep");
absDetector->RegisterPrimitive(primitive);
primitive = new G4PSTrackLength("TrackLength");
auto charged = new G4SDChargedFilter("chargedFilter");
primitive ->SetFilter(charged);
absDetector->RegisterPrimitive(primitive);
SetSensitiveDetector("AbsoLV",absDetector);
if the AbsoLV has lots of copies in his mother LV, and his mother LV has lots of copies, is the G4PSEnergyDeposit will not distinguish AbsoLVs with the same copy number.
If I want to distinguish, is I need to use G4PSEnergyDeposit3D(Example RE02).
I want to know the idea behind these scorers.(I see the code of G4PSEnergyDeposit3D, but not understand)
I think in general for both question the answer is that even though they may be only one logical volume once you place them (via Placemente, Replica, Imprint, etc…) they become “real”… that is… they stop being “the idea” of a shape with a material and they are brought into “existence”.
Those volumes that exist it mean you can “touch” them. Therefore touchables objects in Geant4. For element in the geometry is unique via its own name, own name + copy number, own name + copy number + copy number of parent volume…
Using that uniqueness you can identify which actual fLogicChamber was hit, for instance.
Please have a look at this code snippet that may help you understand this idea:
Thank you very much
It is vivd to help me understand this question.
with this answer, I think I can handle the origion data from G4step to construct my data.