Project
Loading...
Searching...
No Matches
o2::ext::ExternalDetector Class Reference

#include <ExternalDetector.h>

Inherits o2::base::DetImpl< ExternalDetector >.

Classes

struct  TrackData
 dense sensor index per sensitive MC volume ID More...
 

Public Types

using SensitiveFcn = std::function< bool(o2::ext::ExternalDetector *)>
 

Public Member Functions

 ExternalDetector (const char *name, const char *title, ExternalDetectorOptions options)
 
 ExternalDetector ()
 
 ~ExternalDetector () override
 
void ConstructGeometry () override
 Build the CAD geometry, remap its media and register the sensitive volumes.
 
void InitializeO2Detector () override
 Resolve the Monte Carlo volume IDs of the sensitive volumes.
 
Bool_t ProcessHits (FairVolume *v=nullptr) override
 Called for each tracking step; produces hits in the sensitive volumes.
 
void Register () override
 Register the hit collection with the FairRootManager.
 
std::vector< o2::ext::Hit > * getHits (Int_t iColl) const
 Get the produced hit collection (probe interface used by DetImpl).
 
void Reset () override
 
void EndOfEvent () override
 
void FinishPrimary () override
 
void BeginPrimary () override
 
void PostTrack () override
 
void PreTrack () override
 
Helpers usable from a user-provided sensitive-action macro

These wrap the bookkeeping a sensitive action typically needs so that a macro can stay focused on physics and the TVirtualMC queries.

Append a hit to the output collection and flag the MCTrack as having left a hit in this detector. Returns a pointer to the stored hit.

o2::ext::Hit * addHit (int trackID, int sensorID, const TVector3 &startPos, const TVector3 &endPos, const TVector3 &startMom, double startE, double endTime, double eLoss, unsigned char startStatus, unsigned char endStatus, int pdg=0, float length=0.f)
 
int currentSensorID () const
 
int currentTrackID () const
 MCTrack number of the track currently being stepped.
 
- Public Member Functions inherited from o2::base::DetImpl< ExternalDetector >
 DetImpl (const DetImpl &rhs)
 copy for a worker thread of multithreaded Geant4; the copy creates its own hit buffers in initializeLate
 
DetImpl & operator= (const DetImpl &)=delete
 
std::string getHitBranchNames (int probe) const override
 
void updateHitTrackIndices (std::map< int, int > const &indexmapping) override
 
void attachHits (fair::mq::Channel &channel, fair::mq::Parts &parts) override
 
void mergeAndAdjustHits (std::string const &brname, TTree &origin, TTree &target, std::vector< int > const &trackoffsets, std::vector< int > const &nprimaries, std::vector< int > const &subevtsOrdered)
 
void mergeAndAdjustHits (std::string const &brname, L &hitbuffervector, TTree &target, std::vector< int > const &trackoffsets, std::vector< int > const &nprimaries, std::vector< int > const &subevtsOrdered)
 
void mergeHitEntries (TTree &origin, TTree &target, std::vector< int > const &trackoffsets, std::vector< int > const &nprimaries, std::vector< int > const &subevtsOrdered) final
 
auto & hitCollector ()
 
void mergeHitEntriesAndFlush (int eventID, TTree &target, std::vector< int > const &trackoffsets, std::vector< int > const &nprimaries, std::vector< int > const &subevtsOrdered) final
 
void collectHits (int eventID, fair::mq::Parts &parts, int &index, bool shm) override
 
void fillHitBranch (TTree &tr, fair::mq::Parts &parts, int &index) override
 
FairModule * CloneModule () const final
 
void freeHitBuffers ()
 
bool setHits (int i, std::vector< Hit_t > *ptr)
 
void createHitBuffers ()
 
void initializeLate () final
 
void BeginEvent () final
 
 ~DetImpl () override
 
void Streamer (TBuffer &)
 
 Detector (const char *name, Bool_t Active)
 
 Detector ()
 Default Constructor.
 
 Detector (const Detector &origin)
 
- Public Member Functions inherited from o2::base::Detector
 Detector (const char *name, Bool_t Active)
 
 Detector ()
 Default Constructor.
 
 ~Detector () override
 Default Destructor.
 
void Material (Int_t imat, const char *name, Float_t a, Float_t z, Float_t dens, Float_t radl, Float_t absl, Float_t *buf=nullptr, Int_t nwbuf=0)
 
void Mixture (Int_t imat, const char *name, Float_t *a, Float_t *z, Float_t dens, Int_t nlmat, Float_t *wmat)
 
void Medium (Int_t numed, const char *name, Int_t nmat, Int_t isvol, Int_t ifield, Float_t fieldm, Float_t tmaxfd, Float_t stemax, Float_t deemax, Float_t epsil, Float_t stmin, Float_t *ubuf=nullptr, Int_t nbuf=0)
 
void SpecialCuts (Int_t numed, const std::initializer_list< std::pair< ECut, Float_t > > &parIDValMap)
 Custom processes and transport cuts.
 
void SpecialCut (Int_t numed, ECut parID, Float_t val)
 Set cut by name and value.
 
void SpecialProcesses (Int_t numed, const std::initializer_list< std::pair< EProc, int > > &parIDValMap)
 
void SpecialProcess (Int_t numed, EProc parID, int val)
 Set process by name and value.
 
void Matrix (Int_t &nmat, Double_t theta1, Double_t phi1, Double_t theta2, Double_t phi2, Double_t theta3, Double_t phi3) const
 
void SetSpecialPhysicsCuts () override
 
virtual void addAlignableVolumes () const
 declare alignable volumes of detector
 
virtual void fillParallelWorld () const
 fill parallel geometry with sensitive volumes of detector
 
virtual void defineWrapperVolume (Int_t id, Double_t rmin, Double_t rmax, Double_t zspan)
 Sets per wrapper volume parameters.
 
virtual void setNumberOfWrapperVolumes (Int_t n)
 Books arrays for wrapper volumes.
 
virtual void defineLayer (Int_t nlay, Double_t phi0, Double_t r, Int_t nladd, Int_t nmod, Double_t lthick=0., Double_t dthick=0., UInt_t detType=0, Int_t buildFlag=0)
 
virtual void defineLayerTurbo (Int_t nlay, Double_t phi0, Double_t r, Int_t nladd, Int_t nmod, Double_t width, Double_t tilt, Double_t lthick=0., Double_t dthick=0., UInt_t detType=0, Int_t buildFlag=0)
 
int getMaterialID (int imat) const
 
int getMediumID (int imed) const
 
void getMediumIDMappingAsVector (std::vector< int > &mapping)
 
std::string addNameTo (const char *ext) const
 
void Initialize () final
 
virtual bool isMTSafe () const
 whether this detector may run in multithreaded Geant4, with one clone per worker thread
 
int registerSensitiveVolumeAndGetVolID (std::string const &name)
 
int registerSensitiveVolumeAndGetVolID (TGeoVolume const *vol)
 
TClonesArray * GetCollection (int iColl) const final
 
- Public Member Functions inherited from FairDetector
 FairDetector (const char *Name, Bool_t Active, Int_t DetId=0)
 
 FairDetector ()
 
virtual ~FairDetector ()
 
virtual TClonesArray * GetCollection (Int_t iColl) const =0
 
virtual void CopyClones (TClonesArray *, TClonesArray *, Int_t)
 
virtual void FinishRun ()
 
virtual void FinishEvent ()
 
void SaveGeoParams ()
 
Int_t GetDetId ()
 
- Public Member Functions inherited from FairModule
 FairModule ()
 
 FairModule (const char *Name, const char *title, Bool_t Active=kFALSE)
 
virtual ~FairModule ()
 
virtual void Print (Option_t *) const
 
virtual void SetGeometryFileName (TString fname, TString geoVer="0")
 
virtual TString GetGeometryFileName ()
 
virtual TString GetGeometryFileVer ()
 
virtual void ConstructOpGeometry ()
 
virtual void ConstructRootGeometry (TGeoMatrix *shiftM=nullptr)
 
virtual void ConstructASCIIGeometry ()
 
virtual void ModifyGeometry () __attribute__((deprecated("Use FairAlignmentHandler instead
 
virtual void RegisterAlignmentMatrices ()
 
virtual void ConstructGDMLGeometry (__attribute__((unused)) TGeoMatrix *posrot)
 
virtual void BeginWorkerRun () const
 
virtual void FinishWorkerRun () const
 
virtual Bool_t IsSensitive (const std::string &name)
 
virtual Bool_t CheckIfSensitive (__attribute__((unused)) std::string name) __attribute__((deprecated("The method CheckIfSensitive is deprecated. Implement IsSensitive in the detector classes.")))
 
virtual void ExpandNode (TGeoNode *Node)
 
virtual void ExpandNodeForGDML (__attribute__((unused)) TGeoNode *curNode)
 
virtual Int_t getVolId (const TString &) const
 
Int_t GetModId ()
 
void SetVerboseLevel (Int_t level)
 
Bool_t IsActive ()
 
void SetModId (Int_t id)
 
void SetMotherVolume (TString volName)
 
virtual void SetParContainers ()
 
virtual void InitParContainers ()
 
TList * GetListOfGeoPar ()
 
FairVolume * getFairVolume (FairGeoNode *fNode)
 
void AddSensitiveVolume (TGeoVolume *v)
 
void SetMC (TVirtualMC *mc)
 cahed pointer to MC (available only after initialization)
 
 ClassDef (FairModule, 4)
 

Static Public Member Functions

static std::vector< ExternalDetector * > createFromJSON (const std::string &jsonfile)
 
- Static Public Member Functions inherited from o2::base::Detector
static void setDensityFactor (Float_t density)
 
static Float_t getDensityFactor ()
 
static int updatedTrackIndex (std::map< int, int > const &indexmapping, int trackID)
 
static int offsetTrackIndex (int trackID, int nprimaries, int primaryOffset, int secondaryOffset)
 
static void initFieldTrackingParams (int &mode, float &maxfield)
 
static void setDetId2HitBitIndex (std::vector< int > const &v)
 set the DetID to HitBitIndex mapping. Succeeds if not already set.
 
static std::vector< int > const & getDetId2HitBitIndex ()
 

Protected Member Functions

Bool_t defaultProcessHits ()
 the built-in sensitive action used when no macro is configured (generic entrance/exit hit)
 
void collectSensitiveVolumeNames (TGeoVolume *vol, std::set< TGeoVolume * > &visited)
 recursively collect names of volumes whose medium matches the configured sensitive media
 
- Protected Member Functions inherited from o2::base::DetImpl< ExternalDetector >
 ClassDefOverride (DetImpl, 0)
 type-erased hit buffers of this instance in the hit merger (see hitCollector())
 
- Protected Member Functions inherited from o2::base::Detector
 Detector (const Detector &origin)
 
Detector & operator= (const Detector &)
 
- Protected Member Functions inherited from FairDetector
 FairDetector (const FairDetector &)
 
FairDetector & operator= (const FairDetector &)
 
void DefineSensitiveVolumes ()
 
 ClassDef (FairDetector, 1)
 /// FairLogger
 
- Protected Member Functions inherited from FairModule
 FairModule (const FairModule &)
 
FairModule & operator= (const FairModule &)
 

Protected Attributes

ExternalDetectorOptions mOptions
 
std::vector< std::string > mSensitiveVolumeNames
 
std::set< int > mSensitiveVolIDs
 names of the volumes to be made sensitive (filled at geometry build)
 
std::unordered_map< int, int > mVolID2SensorID
 MC volume IDs of the sensitive volumes.
 
struct o2::ext::ExternalDetector::TrackData mTrackData
 
std::vector< o2::ext::Hit > * mHits = nullptr
 
SensitiveFcn mSensitiveAction
 container for produced hits
 
FairVolume * mCurrentVolume = nullptr
 optional user-provided sensitive action (loaded from a macro)
 
int mStepCount = 0
 volume currently passed to ProcessHits (for the action helpers)
 
- Protected Attributes inherited from o2::base::DetImpl< ExternalDetector >
ShmBusyFlag * mShmBusy [NHITBUFFERS]
 
std::vector< void * > mCachedPtr [NHITBUFFERS]
 pointer to flag in shared mem indicating of IO busy
 
int mCurrentBuffer
 
int mInitialized
 
std::shared_ptr< void > mHitCollector
 
- Protected Attributes inherited from FairDetector
Int_t fDetId
 
FairLogger * fLogger
 
- Protected Attributes inherited from FairModule
TString fgeoVer
 
TString fgeoName
 
Int_t fModId
 
Bool_t fActive
 
Int_t fNbOfSensitiveVol
 
Int_t fVerboseLevel
 
TList * flGeoPar
 
Bool_t fGeoSaved
 list of Detector Geometry parameters
 
TVirtualMC * fMC
 flag for initialisation
 

Friends

template<typename Det >
class o2::base::DetImpl
 

Additional Inherited Members

- Public Attributes inherited from FairModule
virtual void see Tutorial4 for examples
 
TString fMotherVolumeName
 
- Static Public Attributes inherited from FairModule
static thread_local FairVolumeList * vList = 0
 
static thread_local Int_t fNbOfVolumes = 0
 
static thread_local TRefArray * svList = 0
 
static thread_local TArrayI * volNumber = 0
 
- Static Protected Attributes inherited from o2::base::DetImpl< ExternalDetector >
static constexpr int NHITBUFFERS
 

Detailed Description

Definition at line 67 of file ExternalDetector.h.

Member Typedef Documentation

◆ SensitiveFcn

Signature of a (JIT-able) sensitive action. The function is handed the detector instance and is expected to query the TVirtualMC singleton (TVirtualMC::GetMC()) for the current step and to call addHit(...) to produce hits. Returning true means a hit-relevant step was processed (mirrors the ProcessHits return value).

Definition at line 74 of file ExternalDetector.h.

Constructor & Destructor Documentation

◆ ExternalDetector() [1/2]

o2::ext::ExternalDetector::ExternalDetector ( const char *  name,
const char *  title,
ExternalDetectorOptions  options 
)

Definition at line 41 of file ExternalDetector.cxx.

◆ ExternalDetector() [2/2]

o2::ext::ExternalDetector::ExternalDetector ( )

Definition at line 55 of file ExternalDetector.cxx.

◆ ~ExternalDetector()

o2::ext::ExternalDetector::~ExternalDetector ( )
override

Definition at line 73 of file ExternalDetector.cxx.

Member Function Documentation

◆ addHit()

o2::ext::Hit * o2::ext::ExternalDetector::addHit ( int  trackID,
int  sensorID,
const TVector3 &  startPos,
const TVector3 &  endPos,
const TVector3 &  startMom,
double  startE,
double  endTime,
double  eLoss,
unsigned char  startStatus,
unsigned char  endStatus,
int  pdg = 0,
float  length = 0.f 
)

Definition at line 277 of file ExternalDetector.cxx.

◆ BeginPrimary()

void o2::ext::ExternalDetector::BeginPrimary ( )
inlineoverridevirtual

User actions at beginning of a primary track

Reimplemented from FairDetector.

Definition at line 114 of file ExternalDetector.h.

◆ collectSensitiveVolumeNames()

void o2::ext::ExternalDetector::collectSensitiveVolumeNames ( TGeoVolume *  vol,
std::set< TGeoVolume * > &  visited 
)
protected

recursively collect names of volumes whose medium matches the configured sensitive media

Definition at line 80 of file ExternalDetector.cxx.

◆ ConstructGeometry()

void o2::ext::ExternalDetector::ConstructGeometry ( )
overridevirtual

Build the CAD geometry, remap its media and register the sensitive volumes.

Reimplemented from FairModule.

Definition at line 120 of file ExternalDetector.cxx.

◆ createFromJSON()

std::vector< ExternalDetector * > o2::ext::ExternalDetector::createFromJSON ( const std::string &  jsonfile)
static

Build a list of sensitive external detectors from a JSON description file. The file must contain an "externalDetectors" array; each entry needs at least "name", "macro", "anchor" and at least one of "sensitiveMedia" / "sensitiveVolumes" (arrays of substrings matched against medium / volume names); an optional "detID" (name, default "ITS") ties the hit output to an existing detector, and an optional "placement" object may carry "translation"/"rotation_deg". Ownership of the returned detectors is transferred to the caller.

Definition at line 343 of file ExternalDetector.cxx.

◆ currentSensorID()

int o2::ext::ExternalDetector::currentSensorID ( ) const

Running sensor index of the volume currently being processed, or -1 if the current volume is not one of the configured sensitive volumes.

Definition at line 265 of file ExternalDetector.cxx.

◆ currentTrackID()

int o2::ext::ExternalDetector::currentTrackID ( ) const

MCTrack number of the track currently being stepped.

Definition at line 272 of file ExternalDetector.cxx.

◆ defaultProcessHits()

Bool_t o2::ext::ExternalDetector::defaultProcessHits ( )
protected

the built-in sensitive action used when no macro is configured (generic entrance/exit hit)

Definition at line 200 of file ExternalDetector.cxx.

◆ EndOfEvent()

void o2::ext::ExternalDetector::EndOfEvent ( )
overridevirtual

this is called at the end of an event after the call to tree fill in the FairRootManager

Reimplemented from FairDetector.

Definition at line 303 of file ExternalDetector.cxx.

◆ FinishPrimary()

void o2::ext::ExternalDetector::FinishPrimary ( )
inlineoverridevirtual

User actions after finishing of a primary track

Reimplemented from FairDetector.

Definition at line 113 of file ExternalDetector.h.

◆ getHits()

std::vector< o2::ext::Hit > * o2::ext::ExternalDetector::getHits ( Int_t  iColl) const
inline

Get the produced hit collection (probe interface used by DetImpl).

Definition at line 102 of file ExternalDetector.h.

◆ InitializeO2Detector()

void o2::ext::ExternalDetector::InitializeO2Detector ( )
overridevirtual

Resolve the Monte Carlo volume IDs of the sensitive volumes.

Implements o2::base::Detector.

Definition at line 153 of file ExternalDetector.cxx.

◆ PostTrack()

void o2::ext::ExternalDetector::PostTrack ( )
inlineoverridevirtual

User actions after finishing of each track

Reimplemented from FairDetector.

Definition at line 115 of file ExternalDetector.h.

◆ PreTrack()

void o2::ext::ExternalDetector::PreTrack ( )
inlineoverridevirtual

User actions at beginning of each track

Reimplemented from FairDetector.

Definition at line 116 of file ExternalDetector.h.

◆ ProcessHits()

Bool_t o2::ext::ExternalDetector::ProcessHits ( FairVolume *  v = nullptr)
overridevirtual

Called for each tracking step; produces hits in the sensitive volumes.

Implements FairDetector.

Definition at line 187 of file ExternalDetector.cxx.

◆ Register()

void o2::ext::ExternalDetector::Register ( )
overridevirtual

Register the hit collection with the FairRootManager.

Implements FairDetector.

Definition at line 288 of file ExternalDetector.cxx.

◆ Reset()

void o2::ext::ExternalDetector::Reset ( )
overridevirtual

has to be called after each event to reset the containers

Implements FairDetector.

Definition at line 296 of file ExternalDetector.cxx.

Friends And Related Symbol Documentation

◆ o2::base::DetImpl

template<typename Det >
friend class o2::base::DetImpl
friend

Definition at line 170 of file ExternalDetector.h.

Member Data Documentation

◆ mCurrentVolume

FairVolume* o2::ext::ExternalDetector::mCurrentVolume = nullptr
protected

optional user-provided sensitive action (loaded from a macro)

Definition at line 161 of file ExternalDetector.h.

◆ mHits

std::vector<o2::ext::Hit>* o2::ext::ExternalDetector::mHits = nullptr
protected

Definition at line 158 of file ExternalDetector.h.

◆ mOptions

ExternalDetectorOptions o2::ext::ExternalDetector::mOptions
protected

Definition at line 143 of file ExternalDetector.h.

◆ mSensitiveAction

SensitiveFcn o2::ext::ExternalDetector::mSensitiveAction
protected

container for produced hits

Definition at line 160 of file ExternalDetector.h.

◆ mSensitiveVolIDs

std::set<int> o2::ext::ExternalDetector::mSensitiveVolIDs
protected

names of the volumes to be made sensitive (filled at geometry build)

Definition at line 146 of file ExternalDetector.h.

◆ mSensitiveVolumeNames

std::vector<std::string> o2::ext::ExternalDetector::mSensitiveVolumeNames
protected

Definition at line 145 of file ExternalDetector.h.

◆ mStepCount

int o2::ext::ExternalDetector::mStepCount = 0
protected

volume currently passed to ProcessHits (for the action helpers)

Definition at line 163 of file ExternalDetector.h.

◆ mTrackData

struct o2::ext::ExternalDetector::TrackData o2::ext::ExternalDetector::mTrackData
protected

◆ mVolID2SensorID

std::unordered_map<int, int> o2::ext::ExternalDetector::mVolID2SensorID
protected

MC volume IDs of the sensitive volumes.

Definition at line 147 of file ExternalDetector.h.


The documentation for this class was generated from the following files: