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::HitaddHit (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 >
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
 
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) override
 
void fillHitBranch (TTree &tr, fair::mq::Parts &parts, int &index) override
 
FairModuleCloneModule () const final
 
void freeHitBuffers ()
 
bool setHits (int i, std::vector< Hit_t > *ptr)
 
void createHitBuffers ()
 
void initializeLate () final
 
void BeginEvent () final
 
 ~DetImpl () override
 
 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, Float_t theta1, Float_t phi1, Float_t theta2, Float_t phi2, Float_t theta3, Float_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
 
int registerSensitiveVolumeAndGetVolID (std::string const &name)
 
int registerSensitiveVolumeAndGetVolID (TGeoVolume const *vol)
 
TClonesArray * GetCollection (int iColl) const final
 

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 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)
 pointer to hit (collector) buffer location (strictly internal)
 
- Protected Member Functions inherited from o2::base::Detector
 Detector (const Detector &origin)
 
Detectoroperator= (const Detector &)
 

Protected Attributes

ExternalDetectorOptions mOptions
 
std::vector< std::string > mSensitiveVolumeNames
 
std::set< intmSensitiveVolIDs
 names of the volumes to be made sensitive (filled at geometry build)
 
std::unordered_map< int, intmVolID2SensorID
 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 >
bool * mShmBusy [NHITBUFFERS]
 
std::vector< void * > mCachedPtr [NHITBUFFERS]
 pointer to bool in shared mem indicating of IO busy
 
int mCurrentBuffer
 
int mInitialized
 
charmHitCollectorBufferPtr
 

Friends

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

Additional Inherited Members

- 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 ( )
inlineoverride

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 ( )
override

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

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 ( )
override

Definition at line 303 of file ExternalDetector.cxx.

◆ FinishPrimary()

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

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 ( )
inlineoverride

Definition at line 115 of file ExternalDetector.h.

◆ PreTrack()

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

Definition at line 116 of file ExternalDetector.h.

◆ ProcessHits()

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

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

Definition at line 187 of file ExternalDetector.cxx.

◆ Register()

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

Register the hit collection with the FairRootManager.

Definition at line 288 of file ExternalDetector.cxx.

◆ Reset()

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

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: