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 
22 //----------------------------------------------------------------------------------------------------
23 
25 {
26 }
27 
28 //----------------------------------------------------------------------------------------------------
29 
31 {
32  using namespace std;
33 
34  // create DDFilteredView and apply the filter
35  DDFilteredView fv(*cpv);
36  //.fv.addFilter(filter);
37 
38  // conversion to DetGeomDesc structure
39  // create the root node and recursively propagates through the tree
40  // adds IDs
41  DetGeomDesc* tracker = new DetGeomDesc(&fv);
43 
44  // return the root of the structure
45  return tracker;
46 }
47 
48 //----------------------------------------------------------------------------------------------------
49 
51 {
52  using namespace std;
53 
54  // try to dive into next level
55  if (! fv->firstChild()) return;
56 
57  // loop over siblings in the level
58  do {
59  // create new DetGeomDesc node and add it to the parent's (gd) list
60  DetGeomDesc* newGD = new DetGeomDesc(fv);
61 
62  // add ID (only for detectors)
63  if (! fv->logicalPart().name().name().compare(DDD_TOTEM_RP_DETECTOR_NAME)) {
64  const vector<int> &cN = fv->copyNumbers();
65  // check size of copy numubers array
66  if (cN.size() < 3)
67  throw cms::Exception("DDDTotemRPContruction") << "size of copyNumbers for RP_Silicon_Detector is " << cN.size() << ". It must be >= 3." << endl;
68 
69  // extract information
70  unsigned int A = cN[cN.size() - 3];
71  unsigned int arm = A / 100;
72  unsigned int station = (A % 100) / 10;
73  unsigned int rp = A % 10;
74  unsigned int detector = cN[cN.size() - 1];
75  //.std::cout<<"arm:"<<arm<<", station:"<<station<<", rp:"<<rp<<", detector:"<<detector<<std::endl;
76  //.std::cout<<"TotemRPDetId(arm, station, rp, detector) "<<TotemRPDetId(arm, station, rp, detector).DetectorDecId()<<", "<<TotemRPDetId(arm, station, rp, detector).rawId()<<std::endl;
77  newGD->setGeographicalID(TotemRPDetId(arm, station, rp, detector));
78  //.cout << "A = " << A << "; arm = " << arm << " st = " << station << " rp = " << rp << " det = " << detector << " --> "<< gd->geographicalID().rawId() << endl;
79  }
80 
81  gd->addComponent(newGD);
82 
83  // recursion
84  buildDetGeomDesc(fv, newGD);
85  } while (fv->nextSibling());
86 
87  // go a level up
88  fv->parent();
89 }
Roman Pot detector ID.
Definition: TotemRPDetId.h:51
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 ...
type of data representation of DDCompactView
Definition: DDCompactView.h:77
const DetGeomDesc * construct(const DDCompactView *cpv)
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:87