DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
BuildType.cpp
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 
14 // Framework includes
15 #include <DD4hep/BuildType.h>
16 #include <DD4hep/Detector.h>
17 
18 // C/C++ include files
19 #include <stdexcept>
20 #include <cstring>
21 #include <string>
22 
25  if ( !value )
26  return BUILD_DEFAULT;
27  else if ( strncmp(value,"BUILD_DEFAULT",9)==0 )
28  return BUILD_DEFAULT;
29  else if ( strncmp(value,"BUILD_SIMU",9)==0 )
30  return BUILD_SIMU;
31  else if ( strcmp(value,"1")==0 )
32  return BUILD_SIMU;
33  else if ( strncmp(value,"BUILD_RECO",9)==0 )
34  return BUILD_RECO;
35  else if ( strcmp(value,"2")==0 )
36  return BUILD_RECO;
37  else if ( strncmp(value,"BUILD_DISPLAY",9)==0 )
38  return BUILD_DISPLAY;
39  else if ( strcmp(value,"3")==0 )
40  return BUILD_DISPLAY;
41  else if ( strncmp(value,"BUILD_ENVELOPE",9)==0 )
42  return BUILD_ENVELOPE;
43  else if ( strcmp(value,"4")==0 )
44  return BUILD_ENVELOPE;
45  throw std::runtime_error(std::string("Invalid build type value: ")+value);
46 }
47 
49 dd4hep::DetectorBuildType dd4hep::buildType(const std::string& value) {
50  return buildType(value.c_str());
51 }
52 
55  switch(type) {
56  case BUILD_NONE:
57  return "BUILD_NONE";
58  case BUILD_DEFAULT:
59  return "BUILD_DEFAULT";
60  //case BUILD_SIMU:
61  //return "BUILD_SIMU";
62  case BUILD_RECO:
63  return "BUILD_RECO";
64  case BUILD_DISPLAY:
65  return "BUILD_DISPLAY";
66  case BUILD_ENVELOPE:
67  return "BUILD_ENVELOPE";
68  default:
69  throw std::runtime_error("Invalid build type value: "+std::to_string(int(type)));
70  }
71 }
72 
74 std::string dd4hep::buildTypeName(dd4hep::Detector& detector) {
75  return buildTypeName(detector.buildType());
76 }
77 
79 bool dd4hep::buildMatch(const std::string& value, DetectorBuildType match) {
80  switch(match) {
81  case BUILD_RECO:
82  return value.find("REC") != std::string::npos;
83  case BUILD_ENVELOPE:
84  return value.find("ENV") != std::string::npos;
85  case BUILD_DISPLAY:
86  return value.find("DIS") != std::string::npos;
87  //case BUILD_SIMU:
88  //return value.find("SIM") != std::string::npos;
89  case BUILD_DEFAULT:
90  return true;
91  default:
92  return true;
93  }
94 }
dd4hep::BUILD_DISPLAY
@ BUILD_DISPLAY
Definition: BuildType.h:39
Detector.h
dd4hep::buildType
DetectorBuildType buildType(const char *value)
Translate string representation of the geometry build type to value.
Definition: BuildType.cpp:24
dd4hep::BUILD_ENVELOPE
@ BUILD_ENVELOPE
Definition: BuildType.h:40
dd4hep::BUILD_NONE
@ BUILD_NONE
Definition: BuildType.h:35
dd4hep::buildMatch
bool buildMatch(const std::string &value, DetectorBuildType match)
Check if a build type matches the current.
Definition: BuildType.cpp:79
BuildType.h
dd4hep::BUILD_RECO
@ BUILD_RECO
Definition: BuildType.h:38
dd4hep::BUILD_SIMU
@ BUILD_SIMU
Definition: BuildType.h:37
dd4hep::Detector::buildType
virtual DetectorBuildType buildType() const =0
Access flag to steer the detail of building of the geometry/detector description.
dd4hep::DetectorBuildType
DetectorBuildType
Detector description build types.
Definition: BuildType.h:34
dd4hep::buildTypeName
std::string buildTypeName(DetectorBuildType type)
Translate the geometry build type to value to the string representation.
Definition: BuildType.cpp:54
dd4hep::Detector
The main interface to the dd4hep detector description package.
Definition: Detector.h:90
dd4hep::BUILD_DEFAULT
@ BUILD_DEFAULT
Definition: BuildType.h:36