DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
OtherDetectorHelpers.h
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 //==========================================================================
11 #ifndef DDDETECTORS_OTHERDETECTORHELPERS_H
12 #define DDDETECTORS_OTHERDETECTORHELPERS_H 1
13 
14 #include "DD4hep/Printout.h"
15 
16 #include <iostream>
17 #include <map>
18 #include <stdexcept>
19 
20 namespace ODH {//OtherDetectorHelpers
21 
22  typedef enum { // These constants are also used in the MySQL database:
23  kCenter = 0, // centered on the z-axis
24  kUpstream = 1, // on the upstream branch, rotated by half the crossing angle
25  kDnstream = 2, // on the downstream branch, rotated by half the crossing angle
26  kPunchedCenter = 3, // centered, with one or two inner holes
27  kPunchedUpstream = 4, // on the upstream branch, with two inner holes
28  kPunchedDnstream = 5, // on the downstrem branch, with two inner holes
29  kUpstreamClippedFront = 6, // upstream, with the front face parallel to the xy-plane
30  kDnstreamClippedFront = 7, // downstream, with the front face parallel to the xy-plane
31  kUpstreamClippedRear = 8, // upstream, with the rear face parallel to the xy-plane
32  kDnstreamClippedRear = 9, // downstream, with the rear face parallel to the xy-plane
33  kUpstreamClippedBoth = 10, // upstream, with both faces parallel to the xy-plane
34  kDnstreamClippedBoth = 11, // downstream, with both faces parallel to the xy-plane
35  kUpstreamSlicedFront = 12, // upstream, with the front face parallel to a tilted piece
36  kDnstreamSlicedFront = 13, // downstream, with the front face parallel to a tilted piece
37  kUpstreamSlicedRear = 14, // upstream, with the rear face parallel to a tilted piece
38  kDnstreamSlicedRear = 15, // downstream, with the rear face parallel to a tilted piece
39  kUpstreamSlicedBoth = 16, // upstream, with both faces parallel to a tilted piece
40  kDnstreamSlicedBoth = 17 // downstream, with both faces parallel to a tilted piece
42 
43 
44 
45  static ECrossType getCrossType( std::string const & type) {
46 
47  std::map< std::string, ODH::ECrossType > CrossTypes;
48  CrossTypes["Center"] = ODH::kCenter ;
49  CrossTypes["Upstream"] = ODH::kUpstream ;
50  CrossTypes["Dnstream"] = ODH::kDnstream ;
51  CrossTypes["PunchedCenter"] = ODH::kPunchedCenter ;
52  CrossTypes["PunchedUpstream"] = ODH::kPunchedUpstream ;
53  CrossTypes["PunchedDnstream"] = ODH::kPunchedDnstream ;
54  CrossTypes["UpstreamClippedFront"] = ODH::kUpstreamClippedFront ;
55  CrossTypes["DnstreamClippedFront"] = ODH::kDnstreamClippedFront ;
56  CrossTypes["UpstreamClippedRear"] = ODH::kUpstreamClippedRear ;
57  CrossTypes["DnstreamClippedRear"] = ODH::kDnstreamClippedRear ;
58  CrossTypes["UpstreamClippedBoth"] = ODH::kUpstreamClippedBoth ;
59  CrossTypes["DnstreamClippedBoth"] = ODH::kDnstreamClippedBoth ;
60  CrossTypes["UpstreamSlicedFront"] = ODH::kUpstreamSlicedFront ;
61  CrossTypes["DnstreamSlicedFront"] = ODH::kDnstreamSlicedFront ;
62  CrossTypes["UpstreamSlicedRear"] = ODH::kUpstreamSlicedRear ;
63  CrossTypes["DnstreamSlicedRear"] = ODH::kDnstreamSlicedRear ;
64  CrossTypes["UpstreamSlicedBoth"] = ODH::kUpstreamSlicedBoth ;
65  CrossTypes["DnstreamSlicedBoth"] = ODH::kDnstreamSlicedBoth ;
66 
67  std::map < std::string, ODH::ECrossType>::const_iterator ct = CrossTypes.find(type);
68  if ( ct == CrossTypes.end() ) {
69  throw std::runtime_error("Unknown Crossing Type for this geometry");
70  }
71  return ct->second;
72  }
73 
74  static bool checkForSensibleGeometry(double crossingAngle, ECrossType crossType) {
75  if (crossingAngle == 0 && crossType != kCenter) {
76  printout(dd4hep::ERROR, "Mask/Beampip", "You are trying to build a crossing geometry without a crossing angle.\n" );
77  printout(dd4hep::ERROR, "Mask/Beampip", "This is probably not what you want - better check your geometry data!");
78  return false; // premature exit, dd4hep will abort now
79  }
80  return true;
81  }
82 
83 
84  static double getCurrentAngle( double crossingAngle, ECrossType crossType ) {
85  double tmpAngle;
86  switch (crossType) {
87  case kUpstream:
88  case kPunchedUpstream:
95  tmpAngle = -crossingAngle; break;
96  case kDnstream:
97  case kPunchedDnstream:
102  case kDnstreamSlicedRear:
103  case kDnstreamSlicedBoth:
104  tmpAngle = +crossingAngle; break;
105  default:
106  tmpAngle = 0; break;
107  }
108 
109  return tmpAngle;
110  }
111 
112 }//namespace
113 
114 #endif // DDDETECTORS_OTHERDETECTORHELPERS_H
ODH::kCenter
@ kCenter
Definition: OtherDetectorHelpers.h:23
ODH::kUpstreamSlicedFront
@ kUpstreamSlicedFront
Definition: OtherDetectorHelpers.h:35
ODH::kUpstreamSlicedBoth
@ kUpstreamSlicedBoth
Definition: OtherDetectorHelpers.h:39
ODH::kPunchedUpstream
@ kPunchedUpstream
Definition: OtherDetectorHelpers.h:27
ODH::kUpstreamClippedFront
@ kUpstreamClippedFront
Definition: OtherDetectorHelpers.h:29
ODH::kDnstreamClippedFront
@ kDnstreamClippedFront
Definition: OtherDetectorHelpers.h:30
ODH::kUpstreamSlicedRear
@ kUpstreamSlicedRear
Definition: OtherDetectorHelpers.h:37
ODH::ECrossType
ECrossType
Definition: OtherDetectorHelpers.h:22
ODH::kDnstreamClippedRear
@ kDnstreamClippedRear
Definition: OtherDetectorHelpers.h:32
ODH
Definition: OtherDetectorHelpers.h:20
ODH::kDnstreamSlicedBoth
@ kDnstreamSlicedBoth
Definition: OtherDetectorHelpers.h:40
ODH::kDnstreamSlicedFront
@ kDnstreamSlicedFront
Definition: OtherDetectorHelpers.h:36
ODH::kPunchedCenter
@ kPunchedCenter
Definition: OtherDetectorHelpers.h:26
ODH::kUpstreamClippedRear
@ kUpstreamClippedRear
Definition: OtherDetectorHelpers.h:31
ODH::kPunchedDnstream
@ kPunchedDnstream
Definition: OtherDetectorHelpers.h:28
ODH::kUpstreamClippedBoth
@ kUpstreamClippedBoth
Definition: OtherDetectorHelpers.h:33
ODH::kDnstream
@ kDnstream
Definition: OtherDetectorHelpers.h:25
ODH::kDnstreamClippedBoth
@ kDnstreamClippedBoth
Definition: OtherDetectorHelpers.h:34
Printout.h
ODH::kDnstreamSlicedRear
@ kDnstreamSlicedRear
Definition: OtherDetectorHelpers.h:38
ODH::kUpstream
@ kUpstream
Definition: OtherDetectorHelpers.h:24