DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Geant4ReadoutVolumeFilter.cpp
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 
14 // Framework include files
15 #include <DD4hep/Readout.h>
16 #include <DD4hep/InstanceCount.h>
18 #include <DDG4/Geant4Mapping.h>
19 #include <DDG4/Geant4StepHandler.h>
23 
24 using namespace dd4hep::sim;
25 
28  const std::string& nam,
29  Readout ro,
30  const std::string& coll)
31  : Geant4Filter(ctxt, nam), m_readout(ro), m_collection(0), m_key(0)
32 {
34  for(size_t i=0; i<ro->hits.size(); ++i) {
35  const HitCollection& c = ro->hits[i];
36  if ( c.name == coll ) {
37  m_collection = &c;
38  m_key = ro.idSpec().field(c.key);
39  return;
40  }
41  }
42  except("+++ Custom collection name '%s' not defined in the Readout object: %s.",
43  coll.c_str(), ro.name());
44 }
45 
49 }
50 
52 bool Geant4ReadoutVolumeFilter::operator()(const G4Step* step) const {
53  Geant4StepHandler stepH(step);
55  VolumeID id = volMgr.volumeID(stepH.preTouchable());
56  FieldID key = m_key->value(id);
58  return true;
59  return false;
60 }
61 
64  Geant4FastSimHandler spotH(spot);
66  VolumeID id = volMgr.volumeID(spotH.touchable());
67  FieldID key = m_key->value(id);
69  return true;
70  return false;
71 }
dd4hep::HitCollection::name
std::string name
Hit collection name.
Definition: ObjectsInterna.h:160
dd4hep::HitCollection::key_min
long key_min
Range values of the key is not empty.
Definition: ObjectsInterna.h:164
Geant4Mapping.h
dd4hep::HitCollection
Definition of the HitCollection parameters used by the Readout.
Definition: ObjectsInterna.h:157
dd4hep::IDDescriptor::field
const BitFieldElement * field(const std::string &field_name) const
Get the field descriptor of one field by name.
Definition: IDDescriptor.cpp:96
dd4hep::sim::Geant4ReadoutVolumeFilter::m_collection
const HitCollection * m_collection
Collection index.
Definition: Geant4ReadoutVolumeFilter.h:38
Geant4VolumeManager.h
dd4hep::HitCollection::key
std::string key
Discriminator key name from the <id> string.
Definition: ObjectsInterna.h:162
dd4hep::DDSegmentation::BitFieldElement::value
FieldID value(CellID bitfield) const
calculate this field's value given an external 64 bit bitmap
Definition: BitFieldCoder.cpp:55
dd4hep::sim::Geant4FastSimHandler
Helper class to ease the extraction of information from a G4FastSimSpot object.
Definition: Geant4FastSimHandler.h:43
dd4hep::sim::Geant4ReadoutVolumeFilter::~Geant4ReadoutVolumeFilter
virtual ~Geant4ReadoutVolumeFilter()
Default destructor.
Definition: Geant4ReadoutVolumeFilter.cpp:47
dd4hep::InstanceCount::increment
static void increment(T *)
Increment count according to type information.
Definition: InstanceCount.h:98
Geant4StepHandler.h
dd4hep::sim::Geant4Mapping::instance
static Geant4Mapping & instance()
Possibility to define a singleton instance.
Definition: Geant4Mapping.cpp:35
dd4hep::Handle::name
const char * name() const
Access the object name (or "" if not supported by the object)
dd4hep::DDSegmentation::FieldID
int64_t FieldID
Definition: BitFieldCoder.h:25
dd4hep::sim::Geant4FastSimSpot
Spot definition for fast simulation and GFlash.
Definition: Geant4FastSimSpot.h:71
dd4hep::sim::Geant4StepHandler
Helper class to ease the extraction of information from a G4Step object.
Definition: Geant4StepHandler.h:46
dd4hep::sim::Geant4Action::except
void except(const char *fmt,...) const
Support of exceptions: Print fatal message and throw runtime_error.
Definition: Geant4Action.cpp:256
dd4hep::sim::Geant4VolumeManager::volumeID
VolumeID volumeID(const G4VTouchable *touchable) const
Access CELLID by placement path.
Definition: Geant4VolumeManager.cpp:268
dd4hep::HitCollection::key_max
long key_max
Definition: ObjectsInterna.h:164
Readout.h
dd4hep::sim::Geant4HitHandler::touchable
const G4VTouchable * touchable() const
Definition: Geant4HitHandler.h:63
dd4hep::InstanceCount::decrement
static void decrement(T *)
Decrement count according to type information.
Definition: InstanceCount.h:102
Geant4ReadoutVolumeFilter.h
Geant4FastSimHandler.h
dd4hep::sim::Geant4VolumeManager
The Geant4VolumeManager to facilitate optimized lookups of cell IDs from touchables.
Definition: Geant4VolumeManager.h:42
dd4hep::sim::Geant4Mapping::volumeManager
Geant4VolumeManager volumeManager() const
Access the volume manager.
Definition: Geant4Mapping.cpp:69
dd4hep::sim::Geant4ReadoutVolumeFilter::operator()
virtual bool operator()(const G4Step *step) const override
Filter action. Return true if hits should be processed.
Definition: Geant4ReadoutVolumeFilter.cpp:52
dd4hep::sim::Geant4ReadoutVolumeFilter::Geant4ReadoutVolumeFilter
Geant4ReadoutVolumeFilter(Geant4Context *context, const std::string &name, Readout ro, const std::string &coll)
Standard constructor.
Definition: Geant4ReadoutVolumeFilter.cpp:27
VolumeID
dd4hep::DDSegmentation::VolumeID VolumeID
Definition: SegmentationDictionary.h:50
key
unsigned char key
Definition: AlignmentsCalculator.cpp:69
dd4hep::sim
Namespace for the Geant4 based simulation part of the AIDA detector description toolkit.
Definition: Geant4Output2EDM4hep.cpp:49
ObjectsInterna.h
dd4hep::sim::Geant4Filter
Base class to construct filters for Geant4 sensitive detectors.
Definition: Geant4SensDetAction.h:94
dd4hep::Readout
Handle to the implementation of the readout structure of a subdetector.
Definition: Readout.h:38
dd4hep::Readout::idSpec
IDDescriptor idSpec() const
Access IDDescription structure.
Definition: Readout.cpp:112
dd4hep::sim::Geant4ReadoutVolumeFilter::m_key
const BitFieldElement * m_key
Bit field value from ID descriptor.
Definition: Geant4ReadoutVolumeFilter.h:40
InstanceCount.h
dd4hep::sim::Geant4StepHandler::preTouchable
const G4VTouchable * preTouchable() const
Definition: Geant4StepHandler.h:141
dd4hep::sim::Geant4Context
Generic context to extend user, run and event information.
Definition: Geant4Context.h:201