GGS(GenericGEANT4Simulation)Software  2.7.0
 All Data Structures Namespaces Files Functions Variables Typedefs Macros
Public Member Functions | Static Public Member Functions
GGSNameDecoder Class Reference

Class needed to decode sensitive volume names. More...

#include <GGSNameDecoder.h>

Public Member Functions

bool IsSensitive (const std::string &volumeName)
 Check if the logical volume is sensitive. More...
 
int GetHitType (const std::string &volumeName)
 Get hit type. More...
 
const std::string & GetDetectorName (const std::string &volumeName)
 Get detector name. More...
 

Static Public Member Functions

static GGSNameDecoderGetInstance ()
 Get instance of the singleton. More...
 

Detailed Description

Class needed to decode sensitive volume names.

This class is a helper for parsing the names of the logical volumes. Its methods recognize if a volume name complies with the pattern defining sensitive volumes (i.e. XXXXH::E), which kind of hit is to be associated with the volume etc.

Definition at line 25 of file GGSNameDecoder.h.

Member Function Documentation

const std::string & GGSNameDecoder::GetDetectorName ( const std::string &  volumeName)

Get detector name.

Returns the name of the detector. If volumeName is not the name of a sensitive volume then an empty string is returned.

Returns
The name of the detector.

Definition at line 48 of file GGSNameDecoder.cpp.

48  {
49  static std::string returnValue;
50  if (!IsSensitive(volumeName)) {
51  returnValue = "";
52  } else {
53  returnValue = volumeName.substr(0, 4);
54  }
55 
56  return returnValue;
57 }
bool IsSensitive(const std::string &volumeName)
Check if the logical volume is sensitive.
int GGSNameDecoder::GetHitType ( const std::string &  volumeName)

Get hit type.

1: position hit 2: particle hit 4: integrated hit

Returns
The hit type (-1 if the volume is not sensitive).

Definition at line 25 of file GGSNameDecoder.cpp.

25  {
26  if (!IsSensitive(volumeName)) {
27  return -1;
28  }
29  int hitType;
30  if (sscanf(volumeName.c_str(), "%*4cH%dE", &hitType) == 1) {
31  return hitType;
32  }
33  return -1;
34 }
bool IsSensitive(const std::string &volumeName)
Check if the logical volume is sensitive.
GGSNameDecoder & GGSNameDecoder::GetInstance ( )
static

Get instance of the singleton.

Method to access the pointer to the class

Returns
the reference to GGSNameDecoder

Definition at line 16 of file GGSNameDecoder.cpp.

16  {
17  static GGSNameDecoder instance;
18  return instance;
19 }
Class needed to decode sensitive volume names.
bool GGSNameDecoder::IsSensitive ( const std::string &  volumeName)

Check if the logical volume is sensitive.

Given the name of the logical volume, this method checks if the volume is sensitive.

Parameters
volumeNameThe name of the logical volume.
Returns
true if the volume is sensitive.

Definition at line 36 of file GGSNameDecoder.cpp.

36  {
37  if (volumeName.length() != 7)
38  return false;
39 
40  int hitType;
41  if (sscanf(volumeName.c_str(), "%*4cH%dE", &hitType) == 1) {
42  return true;
43  } else {
44  return false;
45  }
46 }

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