CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DDDTotemRPConstruction.cc
Go to the documentation of this file.
1 /****************************************************************************
2 *
3 * This is a part of TOTEM offline software.
4 * Authors:
5 * Jan Kaspar (jan.kaspar@gmail.com)
6 *
7 ****************************************************************************/
8 
14 
15 // this might be useful one day
16 //.#include "Geometry/TrackerNumberingBuilder/interface/ExtractStringFromDDD.h"
17 //.#include "Geometry/TrackerNumberingBuilder/interface/CmsTrackerBuilder.h"
18 //.#include "Geometry/TrackerNumberingBuilder/interface/CmsTrackerDetIdBuilder.h"
19 
20 #include <iostream>
21 
22 using namespace std;
23 
24 //----------------------------------------------------------------------------------------------------
25 
27 {
28 }
29 
30 //----------------------------------------------------------------------------------------------------
31 
33 {
34  // create DDFilteredView and apply the filter
35  DDFilteredView fv(*cpv);
36 
37  // conversion to DetGeomDesc structure
38  // create the root node and recursively propagates through the tree
39  // adds IDs
40  DetGeomDesc* tracker = new DetGeomDesc(&fv);
41  buildDetGeomDesc(&fv, tracker);
42 
43  // return the root of the structure
44  return tracker;
45 }
46 
47 //----------------------------------------------------------------------------------------------------
48 
50 {
51  // try to dive into next level
52  if (! fv->firstChild())
53  return;
54 
55  // loop over siblings in the level
56  do {
57  // create new DetGeomDesc node and add it to the parent's (gd) list
58  DetGeomDesc* newGD = new DetGeomDesc(fv);
59 
60  // add ID (only for detectors/sensors)
61  if (fv->logicalPart().name().name().compare(DDD_TOTEM_RP_DETECTOR_NAME) == 0)
62  {
63  const vector<int> &cN = fv->copyNumbers();
64  // check size of copy numubers array
65  if (cN.size() < 3)
66  throw cms::Exception("DDDTotemRPContruction") << "size of copyNumbers for RP_Silicon_Detector is "
67  << cN.size() << ". It must be >= 3." << endl;
68 
69  // extract information
70  const unsigned int A = cN[cN.size() - 3];
71  const unsigned int arm = A / 100;
72  const unsigned int station = (A % 100) / 10;
73  const unsigned int rp = A % 10;
74  const unsigned int detector = cN[cN.size() - 1];
75  newGD->setGeographicalID(TotemRPDetId(arm, station, rp, detector));
76  }
77 
78  if (fv->logicalPart().name().name().compare(DDD_TOTEM_RP_PRIMARY_VACUUM_NAME) == 0)
79  {
80  const uint32_t decRPId = fv->copyno();
81  const uint32_t armIdx = (decRPId / 100) % 10;
82  const uint32_t stIdx = (decRPId / 10) % 10;
83  const uint32_t rpIdx = decRPId % 10;
84 
85  newGD->setGeographicalID(TotemRPDetId(armIdx, stIdx, rpIdx));
86  }
87 
88  if (fv->logicalPart().name().name().compare(DDD_CTPPS_DIAMONDS_DETECTOR_NAME) == 0)
89  {
90  const vector<int>& copy_num = fv->copyNumbers();
91  const unsigned int id = copy_num[copy_num.size()-1],
92  arm = copy_num[1]-1,
93  station = 1,
94  rp = 6,
95  plane = ( id / 100 ),
96  channel = id % 100;
97  newGD->setGeographicalID( CTPPSDiamondDetId( arm, station, rp, plane, channel ) );
98  }
99 
100  gd->addComponent(newGD);
101 
102  // recursion
103  buildDetGeomDesc(fv, newGD);
104  } while (fv->nextSibling());
105 
106  // go a level up
107  fv->parent();
108 }
Detector ID class for TOTEM Si strip detectors.
Definition: TotemRPDetId.h:30
void buildDetGeomDesc(DDFilteredView *fv, DetGeomDesc *gd)
bool parent()
set the current node to the parent node ...
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the filtered-view.
const N & name() const
Definition: DDBase.h:78
nav_type copyNumbers() const
return the stack of copy numbers
bool nextSibling()
set the current node to the next sibling ...
const char DDD_TOTEM_RP_PRIMARY_VACUUM_NAME[]
DDD name of RP.
type of data representation of DDCompactView
Definition: DDCompactView.h:77
const DetGeomDesc * construct(const DDCompactView *cpv)
int copyno() const
Copy number associated with the current node.
void setGeographicalID(DetId id)
ID stuff.
Definition: DetGeomDesc.h:63
Geometrical description of a detector.
Definition: DetGeomDesc.h:40
const char DDD_CTPPS_DIAMONDS_DETECTOR_NAME[]
bool firstChild()
set the current node to the first child ...
Detector ID class for CTPPS Timing Diamond detectors. Bits [19:31] : Assigend in CTPPSDetId Calss Bit...
const char DDD_TOTEM_RP_DETECTOR_NAME[]
DDD name of RP detector.
void addComponent(DetGeomDesc *)
Definition: DetGeomDesc.cc:159
const std::string & name() const
Returns the name.
Definition: DDName.cc:87