|
DD4hep
1.30.0
Detector Description Toolkit for High Energy Physics
|
Go to the documentation of this file.
13 #ifndef DD4HEP_DDG4_GEANT4SURFACETEST_H
14 #define DD4HEP_DDG4_GEANT4SURFACETEST_H
36 virtual void begin(
const G4Event* event);
38 virtual void end(
const G4Event* event);
48 #endif // DD4HEP_DDG4_GEANT4SURFACETEST_H
67 #include <G4VHitsCollection.hh>
68 #include <G4HCofThisEvent.hh>
76 using namespace dd4hep::DDRec;
105 const SurfaceMap& surfMap = *surfMan.map(
"world" ) ;
106 G4HCofThisEvent* hce = evt->GetHCofThisEvent();
109 error(
"Event:%d: No Geant4 event record (HCE) found.",evt->GetEventID());
113 for(
int j=0, nCol=hce->GetNumberOfCollections(); j<nCol; ++j) {
123 error(
"Event:%d: Collection:%s Invalid sensitive detector.",
124 evt->GetEventID(),hc->GetName().c_str());
130 info(
"Event: %d [%s: %d hits] Desc:%s",
131 evt->GetEventID(),hc->GetName().c_str(),coll->
GetSize(),idStr.c_str());
132 for(
size_t i=0, nHit=coll->
GetSize(); i<nHit; ++i) {
137 SurfaceMap::const_iterator si = surfMap.find(h->
cellID);
138 ISurface* surf = (si != surfMap.end() ? si->second : 0);
142 error(
"FAILED: Hit:%ld Track:%d No surface found cell id: %016llX",i,trackID,h->
cellID);
145 info(
"PASSED: Hit:%ld Track:%d Surface found for cell: %016llX",i,trackID,h->
cellID);
147 Vector3D hit_point(pos.x()*dd4hep::mm,pos.y()*dd4hep::mm,pos.z()*dd4hep::mm);
148 bool isInside = surf->insideBounds(hit_point);
162 sst << hc->GetName() <<
" " <<
"PASSED: Track:" << trackID <<
" Hit:" << i
164 <<
" is ON SURFACE. "
165 <<
"(FLAG:" << h->
flag << flag <<
").";
166 print(sst.str().c_str());
169 double dist = surf->distance(hit_point)/dd4hep::mm;
171 sst << hc->GetName() <<
" FAILED: Track:" << trackID <<
" Hit:" << i
172 <<
" Point: " << hit_point;
173 error(sst.str().c_str());
178 sst <<
" -> Hit is NOT ON SURFACE (Flag:" << h->
flag << flag <<
")"
179 <<
" Distance to surface:" <<
dist <<
" mm.";
180 error(sst.str().c_str());
185 hit_point = hit_point + 1e-3 * surf->normal() ;
187 sst <<
"Track:" << trackID <<
" Hit:" << i <<
" Moved:" << hit_point;
188 if ( (isInside=surf->insideBounds(hit_point)) ) {
189 error(
"FAILED: %s is ON SURFACE (SHOULD NOT BE)",sst.str().c_str());
192 info(
"PASSED: %s is NOT ON SURFACE (SHOULD NOT BE)",sst.str().c_str());
Position position
Hit position.
long flag
User flag to classify hits.
virtual size_t GetSize() const override
Access the collection size.
Detector & detectorDescription() const
Access to detector description.
Handle class to hold the information of a sensitive detector.
A bit field of 64bits that allows convenient declaration.
Generic hit container class using Geant4HitWrapper objects.
bool isValid() const
Check the validity of the object held by the handle.
Geant4HitWrapper & hit(size_t which)
Access the hit wrapper.
Class of the Geant4 toolkit. See http://www-geant4.kek.jp/Reference.
std::multimap< unsigned long, ISurface * > SurfaceMap
typedef for surface maps, keyed by the cellID
static void increment(T *)
Increment count according to type information.
Geant4SurfaceTest(Geant4Context *context, const std::string &nam)
Standard constructor.
#define DECLARE_GEANT4ACTION(name)
Plugin defintion to create Geant4Action objects.
long long int cellID
cellID
Plugin that creates a SurfaceManager object and attaches it to description as a user extension object...
void setValue(CellID value)
virtual void begin(const G4Event *event)
Begin-of-event callback.
void info(const char *fmt,...) const
Support of info messages.
Concrete basic implementation of the Geant4 event action.
Geant4Sensitive * sensitive() const
Access the sensitive detector.
void error(const char *fmt,...) const
Support of error messages.
DD4hep internal namespace.
DDG4 tracker hit class used by the generic DDG4 tracker sensitive detector.
SensitiveDetector sensitiveDetector() const
Access the dd4hep sensitive detector.
static void decrement(T *)
Decrement count according to type information.
virtual void end(const G4Event *event)
End-of-event callback.
Contribution truth
Monte Carlo / Geant4 information.
IDDescriptor IDDescriptor
const ComponentCast & type() const
Type information of the object stored.
void print(const char *fmt,...) const
Support for messages with variable output level using output level.
int trackID
Geant 4 Track identifier.
virtual ~Geant4SurfaceTest()
Destructor.
ROOT::Math::XYZVector Position
Namespace for the Geant4 based simulation part of the AIDA detector description toolkit.
double dist(const Position &p0, const Position &p1)
std::string fieldDescription() const
The string description of all fields from the BitField.
IFACE * extension(bool alert=true) const
Access extension element by the type.
Namespace for the AIDA detector description toolkit.
Readout readout() const
Access readout structure of the sensitive detector.
The main interface to the dd4hep detector description package.
IDDescriptor idSpec() const
Access IDDescription structure.
Generic context to extend user, run and event information.
Geant4Context * context() const
Access the context.