Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DD4hep
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cepc
externals
mirroring
DD4hep
Commits
dc9e8929
Commit
dc9e8929
authored
11 years ago
by
Frank Gaede
Browse files
Options
Downloads
Patches
Plain Diff
- use new method Geant4VolumeManager::.volumeID( step.preTouchable() )
for the cellID
parent
965b6762
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
DDG4/src/Geant4SensitiveDetector.cpp
+73
-35
73 additions, 35 deletions
DDG4/src/Geant4SensitiveDetector.cpp
with
73 additions
and
35 deletions
DDG4/src/Geant4SensitiveDetector.cpp
+
73
−
35
View file @
dc9e8929
...
...
@@ -172,54 +172,92 @@ void Geant4SensitiveDetector::dumpStep(G4Step* st, G4TouchableHistory* /* histor
}
long
long
Geant4SensitiveDetector
::
getVolumeID
(
G4Step
*
s
tep
){
long
long
Geant4SensitiveDetector
::
getVolumeID
(
G4Step
*
aS
tep
){
Geant4Mapping
&
mapping
=
Geant4Mapping
::
instance
();
Geant4Mapping
&
mapping
=
Geant4Mapping
::
instance
();
Geant4StepHandler
step
(
aStep
);
const
G4NavigationHistory
*
hist
=
step
->
GetPreStepPoint
()
->
GetTouchableHandle
()
->
GetHistory
()
;
int
depth
=
hist
->
GetDepth
()
;
//------------ get the cellID description string -----------------------------------
const
G4VPhysicalVolume
*
g4v
=
hist
->
GetVolume
(
depth
)
;
Geometry
::
PlacedVolume
place
=
mapping
.
placement
(
g4v
)
;
if
(
!
place
.
isValid
()
||
!
place
.
volume
().
isSensitive
()
)
{
G4cout
<<
" **** Error in Geant4SensitiveDetector::getVolumeID: invalid first sensitive volume in buildHits is not sensitive !!! "
<<
std
::
endl
;
Geant4VolumeManager
volMgr
=
Geant4Mapping
::
instance
().
volumeManager
();
VolumeID
id
=
volMgr
.
volumeID
(
step
.
preTouchable
()
);
#if 0 // additional checks ...
const G4VPhysicalVolume* g4v = step.volume( step.pre );
if ( id == Geant4VolumeManager::InvalidPath ) {
::printf(" --> Severe ERROR: Invalid placement path: touchable corrupted?\n");
}
else if ( id == Geant4VolumeManager::Insensitive ) {
::printf(" --> WARNING: Only sensitive volumes may be decoded. %s\n" , g4v->GetName().c_str() );
}
else if ( id == Geant4VolumeManager::NonExisting ) {
::printf(" --> WARNING: non existing placement path.\n");
}
else {
std::stringstream str;
Geant4VolumeManager::VolIDDescriptor dsc;
Geant4VolumeManager::VolIDFields& fields = dsc.second;
volMgr.volumeDescriptor( step.preTouchable(), dsc );
for(Geant4VolumeManager::VolIDFields::iterator i=fields.begin(); i!=fields.end();++i){
str << (*i).first->name() << "=" << (*i).second << " ";
}
::printf(" --> CellID: %X [%X] -> %s\n",id,dsc.first,str.str().c_str());
}
Geometry
::
Volume
vol
=
place
.
volume
();
Geometry
::
SensitiveDetector
sd
=
vol
.
sensitiveDetector
();
Geometry
::
Readout
ro
=
sd
.
readout
();
std
::
string
idDescStr
=
ro
.
idSpec
().
fieldDescription
()
;
// G4cout << "----------- Geant4SensitiveDetector::getVolumeID - idDescStr = " << idDescStr << std::endl ;
#endif
return
id
;
// // old way of lookup ----------- does not work for assemblies ....
// //------------ get the cellID description string -----------------------------------
// Geometry::PlacedVolume place = mapping.placement( g4v ) ;
BitField64
bf
(
idDescStr
)
;
// if( ! place.isValid() || ! place.volume().isSensitive() ) {
// G4cout << " **** Error in Geant4SensitiveDetector::getVolumeID: invalid first sensitive volume in buildHits is not sensitive !!! " << std::endl ;
// }
// Geometry::Volume vol = place.volume();
// Geometry::SensitiveDetector sd = vol.sensitiveDetector();
// Geometry::Readout ro = sd.readout();
//------------ now fill the cellID from the volIDs of the complete path -----------------------------------
// std::string idDescStr = ro.idSpec().fieldDescription() ;
// BitField64 bf( idDescStr ) ;
// //------------ now fill the cellID from the volIDs of the complete path -----------------------------------
// const G4NavigationHistory* hist = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory() ;
// int depth = hist->GetDepth() ;
// //const G4VPhysicalVolume* g4v = hist->GetVolume( depth ) ;
for
(
int
i
=
depth
;
i
>
0
;
--
i
)
{
//
for(int i=depth ; i>0 ; --i ) {
g4v
=
hist
->
GetVolume
(
i
)
;
Geometry
::
PlacedVolume
place
=
mapping
.
placement
(
g4v
)
;
//
g4v = hist->GetVolume(i) ;
//
Geometry::PlacedVolume place = mapping.placement( g4v ) ;
if
(
!
place
.
isValid
()
)
{
G4cout
<<
" **** WARNING in Geant4SensitiveDetector::getVolumeID: ingnoring invalid PlacedVolume for : "
<<
g4v
->
GetName
()
<<
std
::
endl
;
continue
;
}
//
if( ! place.isValid() ) {
//
G4cout << " **** WARNING in Geant4SensitiveDetector::getVolumeID: ingnoring invalid PlacedVolume for : " << g4v->GetName() << std::endl ;
//
continue ;
//
}
// G4cout << "--- VolIDs : " << std::endl ;
Geometry
::
PlacedVolume
::
VolIDs
ids
=
place
.
volIDs
()
;
//
// G4cout << "--- VolIDs : " << std::endl ;
//
Geometry::PlacedVolume::VolIDs ids = place.volIDs() ;
for
(
Geometry
::
PlacedVolume
::
VolIDs
::
const_iterator
it
=
ids
.
begin
()
;
it
!=
ids
.
end
()
;
++
it
){
//
for( Geometry::PlacedVolume::VolIDs::const_iterator it = ids.begin() ; it != ids.end() ; ++it ){
// G4cout << "--- " << it->first << " -- " << it->second << std::
bf
[
it
->
first
]
=
it
->
second
;
}
}
// // G4cout << "--- " << it->first << " -- " << it->second << std::
// bf[ it->first ] = it->second ;
// }
// }
// return bf.getValue() ;
return
bf
.
getValue
()
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment