| Summary: | GetCollectionID very slow - obvious bug in HCTable | ||
|---|---|---|---|
| Product: | Geant4 | Reporter: | Laurie Nevay <laurie.nevay> |
| Component: | digits_hits | Assignee: | asai |
| Status: | RESOLVED WONTFIX | ||
| Severity: | minor | CC: | jochem.snuverink, laurie.nevay |
| Priority: | P5 | ||
| Version: | 10.0 | ||
| Hardware: | All | ||
| OS: | All | ||
|
Description
Laurie Nevay
2014-03-04 11:46:09 CET
Also, the for loop in the algorithm does not break when it finds a match - it continues to iterate through the vector.
HCtable.cc line51
for(size_t j=0;j<HClist.size();j++)
{
if(HClist[j]==HCname)
{
if(i>=0) return -2; //so only break if there's another with the same name
i = j; //should break here
}
So if the intention is to search through the whole vector to make sure there's not another with the same name, the safety from this is quite costly. If we keep this safety check, this should perhaps be in the register process.
It is a surprise to me that you reported this method dominated the processing time of the first event. How many sensitive detectors do you have? Makoto Hello,
We have between 10k and 40k sensitive detectors. Usually much fewer, but at this level, this became quite apparent as the cause of the slow down. I can certainly imagine our implementation isn't the best, but this part certainly seems to follow the examples I've seen.
In our sensitive detector class we have:
void BDSEnergyCounterSD::Initialize(G4HCofThisEvent*HCE)
{
BDSEnergyCounterCollection = new BDSEnergyCounterHitsCollection
(SensitiveDetectorName,collectionName[0]);
if (itsHCID < 0){
itsHCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);}
// itsHCID = G4SDManager::GetSDMpointer()->GetCollectionID(BDSEnergyCounterCollection);} //slow version
HCE->AddHitsCollection(itsHCID,BDSEnergyCounterCollection);
}
Equivalent to #1588. |