Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:14:38

0001 /****************************************************************************
0002 *
0003 * This is a part of TOTEM offline software.
0004 * Author:
0005 *   Laurent Forthomme
0006 *
0007 ****************************************************************************/
0008 
0009 #include "Geometry/ForwardGeometry/interface/TotemGeometry.h"
0010 
0011 TotemGeometry::TotemGeometry(const DetGeomDesc* dgd) { browse(dgd, false); }
0012 
0013 void TotemGeometry::browse(const DetGeomDesc* parent, bool in_t2) {
0014   if (parent->name() == "TotemT2")
0015     in_t2 = true;  // define the mother volume for all children
0016   if (in_t2)
0017     browseT2(parent);
0018   // start the recursive browsing
0019   for (const auto& child : parent->components())
0020     browse(child, in_t2);
0021 }
0022 
0023 void TotemGeometry::browseT2(const DetGeomDesc*& parent) {
0024   const unsigned short arm = parent->parentZPosition() > 0. ? 0 : 1;
0025   if (parent->name() == "TotemT2SupportBox")
0026     addT2Plane(TotemT2DetId(arm, parent->copyno() - 1), parent);
0027   else if (parent->name() == "TotemT2Scint") {
0028     unsigned short plane = 2 * (parent->copyno() / 10);
0029     unsigned short tile = parent->copyno() % 10;
0030     if (tile % 2 == 0)
0031       plane += 1;
0032     tile = (tile + 1) / 2 - 1;
0033     addT2Tile(TotemT2DetId(arm, plane, tile), parent);
0034   }
0035 }
0036 
0037 bool TotemGeometry::addT2Plane(const TotemT2DetId& detid, const DetGeomDesc*& dgd) {
0038   if (nt2_planes_.count(detid) != 0)
0039     return true;
0040   nt2_planes_[detid] = dgd;
0041   return true;
0042 }
0043 
0044 const DetGeomDesc* TotemGeometry::plane(const TotemT2DetId& detid) const { return nt2_planes_.at(detid); }
0045 
0046 bool TotemGeometry::addT2Tile(const TotemT2DetId& detid, const DetGeomDesc*& dgd) {
0047   if (nt2_tiles_.count(detid) != 0)
0048     return false;
0049   nt2_tiles_[detid] = TotemT2Tile(dgd);
0050   return true;
0051 }
0052 
0053 const TotemT2Tile& TotemGeometry::tile(const TotemT2DetId& detid) const { return nt2_tiles_.at(detid); }