GGS(GenericGEANT4Simulation)Software  2.6.0
 All Data Structures Namespaces Files Functions Variables Typedefs Macros
GGSNameDecoder.cpp
Go to the documentation of this file.
1 /*
2  * GGSNameDecoder.cpp
3  *
4  * Created on: 2010-10-06
5  * Author: Emiliano Mocchiutti
6  */
7 
10 #include "utils/GGSNameDecoder.h"
11 
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <cstring>
15 
16 
17 
19  static GGSNameDecoder instance;
20  return instance;
21 }
22 
23 GGSNameDecoder::GGSNameDecoder() {
24 }
25 
26 GGSNameDecoder::~GGSNameDecoder() {
27 }
28 
29 int GGSNameDecoder::GetHitType(const std::string &volumeName) {
30  if (!IsSensitive(volumeName)) {
31  return -1;
32  }
33  int hitType;
34  if (sscanf(volumeName.c_str(), "%*4cH%dE", &hitType) == 1) {
35  return hitType;
36  }
37  return -1;
38 
39 }
40 
41 bool GGSNameDecoder::IsSensitive(const std::string &volumeName) {
42  if (volumeName.length() != 7)
43  return false;
44 
45  int hitType;
46  if (sscanf(volumeName.c_str(), "%*4cH%dE", &hitType) == 1) {
47  return true;
48  }
49  else {
50  return false;
51  }
52 
53 }
54 
55 const std::string &GGSNameDecoder::GetDetectorName(const std::string &volumeName) {
56  static std::string returnValue;
57  if (!IsSensitive(volumeName)) {
58  returnValue = "";
59  }
60  else {
61  returnValue = volumeName.substr(0,4);
62  }
63 
64  return returnValue;
65 }
const std::string & GetDetectorName(const std::string &volumeName)
Get detector name.
int GetHitType(const std::string &volumeName)
Get hit type.
static GGSNameDecoder & GetInstance()
Get instance of the singleton.
bool IsSensitive(const std::string &volumeName)
Check if the logical volume is sensitive.
Class needed to decode sensitive volume names.