Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:14:40

0001 #ifndef Other_Helpers_hh
0002 #define Other_Helpers_hh 1
0003 //====================================================================
0004 //  LCGeo - LC detector models in DD4hep
0005 //--------------------------------------------------------------------
0006 //  Helper functions used by detector constructers
0007 //  A.Sailer, CERN
0008 //  $Id$
0009 //====================================================================
0010 
0011 #include <iostream>
0012 #include <map>
0013 #include <stdexcept>
0014 
0015 namespace ODH {  // OtherDetectorHelpers
0016 
0017 typedef enum {                // These constants are also used in the MySQL database:
0018   kCenter = 0,                // centered on the z-axis
0019   kUpstream = 1,              // on the upstream branch, rotated by half the crossing angle
0020   kDnstream = 2,              // on the downstream branch, rotated by half the crossing angle
0021   kPunchedCenter = 3,         // centered, with one or two inner holes
0022   kPunchedUpstream = 4,       // on the upstream branch, with two inner holes
0023   kPunchedDnstream = 5,       // on the downstrem branch, with two inner holes
0024   kUpstreamClippedFront = 6,  // upstream, with the front face parallel to the xy-plane
0025   kDnstreamClippedFront = 7,  // downstream, with the front face parallel to the xy-plane
0026   kUpstreamClippedRear = 8,   // upstream, with the rear face parallel to the xy-plane
0027   kDnstreamClippedRear = 9,   // downstream, with the rear face parallel to the xy-plane
0028   kUpstreamClippedBoth = 10,  // upstream, with both faces parallel to the xy-plane
0029   kDnstreamClippedBoth = 11,  // downstream, with both faces parallel to the xy-plane
0030   kUpstreamSlicedFront = 12,  // upstream, with the front face parallel to a tilted piece
0031   kDnstreamSlicedFront = 13,  // downstream, with the front face parallel to a tilted piece
0032   kUpstreamSlicedRear = 14,   // upstream, with the rear face parallel to a tilted piece
0033   kDnstreamSlicedRear = 15,   // downstream, with the rear face parallel to a tilted piece
0034   kUpstreamSlicedBoth = 16,   // upstream, with both faces parallel to a tilted piece
0035   kDnstreamSlicedBoth = 17    // downstream, with both faces parallel to a tilted piece
0036 } ECrossType;
0037 
0038 inline ECrossType getCrossType(std::string const& type) {
0039 
0040   std::map<std::string, ODH::ECrossType> CrossTypes;
0041   CrossTypes["Center"] = ODH::kCenter;
0042   CrossTypes["Upstream"] = ODH::kUpstream;
0043   CrossTypes["Dnstream"] = ODH::kDnstream;
0044   CrossTypes["PunchedCenter"] = ODH::kPunchedCenter;
0045   CrossTypes["PunchedUpstream"] = ODH::kPunchedUpstream;
0046   CrossTypes["PunchedDnstream"] = ODH::kPunchedDnstream;
0047   CrossTypes["UpstreamClippedFront"] = ODH::kUpstreamClippedFront;
0048   CrossTypes["DnstreamClippedFront"] = ODH::kDnstreamClippedFront;
0049   CrossTypes["UpstreamClippedRear"] = ODH::kUpstreamClippedRear;
0050   CrossTypes["DnstreamClippedRear"] = ODH::kDnstreamClippedRear;
0051   CrossTypes["UpstreamClippedBoth"] = ODH::kUpstreamClippedBoth;
0052   CrossTypes["DnstreamClippedBoth"] = ODH::kDnstreamClippedBoth;
0053   CrossTypes["UpstreamSlicedFront"] = ODH::kUpstreamSlicedFront;
0054   CrossTypes["DnstreamSlicedFront"] = ODH::kDnstreamSlicedFront;
0055   CrossTypes["UpstreamSlicedRear"] = ODH::kUpstreamSlicedRear;
0056   CrossTypes["DnstreamSlicedRear"] = ODH::kDnstreamSlicedRear;
0057   CrossTypes["UpstreamSlicedBoth"] = ODH::kUpstreamSlicedBoth;
0058   CrossTypes["DnstreamSlicedBoth"] = ODH::kDnstreamSlicedBoth;
0059 
0060   std::map<std::string, ODH::ECrossType>::const_iterator ct = CrossTypes.find(type);
0061   if (ct == CrossTypes.end()) {
0062     throw std::runtime_error("Unknown Crossing Type for this geometry");
0063   }
0064   return ct->second;
0065 }
0066 
0067 inline bool checkForSensibleGeometry(double crossingAngle, ECrossType crossType) {
0068   if (crossingAngle == 0 && crossType != kCenter) {
0069     std::cout << "Mask: You are trying to build a crossing geometry without a crossing angle.\n"
0070                  "This is probably not what you want - better check your geometry data!"
0071               << std::endl;
0072     return false;  // premature exit, dd4hep will abort now
0073   }
0074   return true;
0075 }
0076 
0077 inline double getCurrentAngle(double crossingAngle, ECrossType crossType) {
0078   double tmpAngle;
0079   switch (crossType) {
0080   case kUpstream:
0081   case kPunchedUpstream:
0082   case kUpstreamClippedFront:
0083   case kUpstreamClippedRear:
0084   case kUpstreamClippedBoth:
0085   case kUpstreamSlicedFront:
0086   case kUpstreamSlicedRear:
0087   case kUpstreamSlicedBoth:
0088     tmpAngle = -crossingAngle;
0089     break;
0090   case kDnstream:
0091   case kPunchedDnstream:
0092   case kDnstreamClippedFront:
0093   case kDnstreamClippedRear:
0094   case kDnstreamClippedBoth:
0095   case kDnstreamSlicedFront:
0096   case kDnstreamSlicedRear:
0097   case kDnstreamSlicedBoth:
0098     tmpAngle = +crossingAngle;
0099     break;
0100   default:
0101     tmpAngle = 0;
0102     break;
0103   }
0104 
0105   return tmpAngle;
0106 }
0107 
0108 }  // namespace
0109 
0110 #endif  // Other_Helpers_hh