test
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 
13 
14 // this might be useful one day
15 //.#include "Geometry/TrackerNumberingBuilder/interface/ExtractStringFromDDD.h"
16 //.#include "Geometry/TrackerNumberingBuilder/interface/CmsTrackerBuilder.h"
17 //.#include "Geometry/TrackerNumberingBuilder/interface/CmsTrackerDetIdBuilder.h"
18 
19 #include <iostream>
20 
21 using namespace std;
22 
23 //----------------------------------------------------------------------------------------------------
24 
26 {
27 }
28 
29 //----------------------------------------------------------------------------------------------------
30 
32 {
33  // create DDFilteredView and apply the filter
34  DDFilteredView fv(*cpv);
35 
36  // conversion to DetGeomDesc structure
37  // create the root node and recursively propagates through the tree
38  // adds IDs
39  DetGeomDesc* tracker = new DetGeomDesc(&fv);
40  buildDetGeomDesc(&fv, tracker);
41 
42  // return the root of the structure
43  return tracker;
44 }
45 
46 //----------------------------------------------------------------------------------------------------
47 
49 {
50  // try to dive into next level
51  if (! fv->firstChild())
52  return;
53 
54  // loop over siblings in the level
55  do {
56  // create new DetGeomDesc node and add it to the parent's (gd) list
57  DetGeomDesc* newGD = new DetGeomDesc(fv);
58 
59  // add ID (only for detectors/sensors)
60  if (fv->logicalPart().name().name().compare(DDD_TOTEM_RP_DETECTOR_NAME) == 0)
61  {
62  const vector<int> &cN = fv->copyNumbers();
63  // check size of copy numubers array
64  if (cN.size() < 3)
65  throw cms::Exception("DDDTotemRPContruction") << "size of copyNumbers for RP_Silicon_Detector is "
66  << cN.size() << ". It must be >= 3." << endl;
67 
68  // extract information
69  const unsigned int A = cN[cN.size() - 3];
70  const unsigned int arm = A / 100;
71  const unsigned int station = (A % 100) / 10;
72  const unsigned int rp = A % 10;
73  const unsigned int detector = cN[cN.size() - 1];
74  newGD->setGeographicalID(TotemRPDetId(arm, station, rp, detector));
75  }
76 
77  if (fv->logicalPart().name().name().compare(DDD_TOTEM_RP_PRIMARY_VACUUM_NAME) == 0)
78  {
79  const uint32_t decRPId = fv->copyno();
80  const uint32_t armIdx = (decRPId / 100) % 10;
81  const uint32_t stIdx = (decRPId / 10) % 10;
82  const uint32_t rpIdx = decRPId % 10;
83 
84  newGD->setGeographicalID(TotemRPDetId(armIdx, stIdx, rpIdx));
85  }
86 
87  gd->addComponent(newGD);
88 
89  // recursion
90  buildDetGeomDesc(fv, newGD);
91  } while (fv->nextSibling());
92 
93  // go a level up
94  fv->parent();
95 }
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:90
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
bool firstChild()
set the current node to the first child ...
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:90