CMS 3D CMS Logo

DDDCmsTrackerContruction.cc
Go to the documentation of this file.
2 
3 #include <deque>
4 #include <fstream>
5 #include <utility>
15 
16 #define DEBUG false
17 
18 std::unique_ptr<GeometricDet> DDDCmsTrackerContruction::construct(const DDCompactView& cpv,
19  std::vector<int> const& detidShifts) {
20  std::string attribute = "TkDDDStructure";
22 
23  DDFilteredView fv(cpv, filter);
24 
25  CmsTrackerStringToEnum theCmsTrackerStringToEnum;
26  if (theCmsTrackerStringToEnum.type(ExtractStringFromDDD<DDFilteredView>::getString(attribute, &fv)) !=
28  fv.firstChild();
29  if (theCmsTrackerStringToEnum.type(ExtractStringFromDDD<DDFilteredView>::getString(attribute, &fv)) !=
31  throw cms::Exception("Configuration") << " The first child of the DDFilteredView is not what is expected \n"
32  << ExtractStringFromDDD<DDFilteredView>::getString(attribute, &fv) << "\n";
33  }
34  }
35 
36  auto tracker = std::make_unique<GeometricDet>(&fv, GeometricDet::Tracker);
37 
38  edm::LogVerbatim("DDDCmsTrackerContruction") << "DDDCmsTrackerContruction::construct: Call Tracker builder.";
39  CmsTrackerBuilder<DDFilteredView> theCmsTrackerBuilder;
40  theCmsTrackerBuilder.build(fv, tracker.get(), attribute);
41 
42  edm::LogVerbatim("DDDCmsTrackerContruction") << "Assign DetIds";
43  CmsTrackerDetIdBuilder theCmsTrackerDetIdBuilder(detidShifts);
44  theCmsTrackerDetIdBuilder.buildId(*tracker);
45 
46  if (DEBUG) {
48  }
49 
50  fv.parent();
51  //
52  // set the Tracker
53  //
54  //TrackerMapDDDtoID::instance().setTracker(tracker);
55  //NOTE: If it is decided that the TrackerMapDDDtoID should be
56  // constructed here, then we should return from this
57  // function so that the EventSetup can manage it
58 
59  return tracker;
60 }
61 
62 std::unique_ptr<GeometricDet> DDDCmsTrackerContruction::construct(const cms::DDCompactView& cpv,
63  std::vector<int> const& detidShifts) {
64  std::string attribute("TkDDDStructure");
65  cms::DDFilteredView fv(cpv, cms::DDFilter(attribute));
66  fv.firstChild();
67 
68  CmsTrackerStringToEnum theCmsTrackerStringToEnum;
69  if (theCmsTrackerStringToEnum.type(ExtractStringFromDDD<cms::DDFilteredView>::getString("TkDDDStructure", &fv)) !=
71  fv.firstChild();
72  if (theCmsTrackerStringToEnum.type(ExtractStringFromDDD<cms::DDFilteredView>::getString(attribute, &fv)) !=
74  throw cms::Exception("Configuration")
75  << " The first child of the DDFilteredView is not what is expected \n"
77  }
78  }
79 
80  auto tracker = std::make_unique<GeometricDet>(&fv, GeometricDet::Tracker);
81 
82  edm::LogVerbatim("DDDCmsTrackerContruction") << "DDDCmsTrackerContruction::construct: Call Tracker builder.";
83  CmsTrackerBuilder<cms::DDFilteredView> theCmsTrackerBuilder;
84  theCmsTrackerBuilder.build(fv, tracker.get(), attribute);
85 
86  edm::LogVerbatim("DDDCmsTrackerContruction") << "Assign DetIds";
87  CmsTrackerDetIdBuilder theCmsTrackerDetIdBuilder(detidShifts);
88  theCmsTrackerDetIdBuilder.buildId(*tracker);
89 
90  if (DEBUG) {
92  }
93 
94  return tracker;
95 }
96 
97 /*
98  * Print all Tracker GeometricDets, before DetIds building process.
99  * The tree is already fully constructed from XMLs,
100  * and all GeometricDets are sorted according to their geometric position.
101  * This allows a convenient debugging, as the DetIds will be later assigned according to this information.
102  */
104  std::ofstream outputFile("All_Tracker_GeometricDets_before_DetId_building.log", std::ios::out);
105 
106  // Tree navigation: queue for BFS (we want to see same hierarchy level together).
107  // (for DFS, would just use a stack instead).
108  std::deque<const GeometricDet*> queue;
109  queue.emplace_back(tracker);
110 
111  while (!queue.empty()) {
112  const GeometricDet* myDet = queue.front();
113  queue.pop_front();
114 
115  for (auto& child : myDet->components()) {
116  queue.emplace_back(child);
117  }
118 
119  outputFile << " " << std::endl;
120  outputFile << " " << std::endl;
121  outputFile << "............................." << std::endl;
122  outputFile << "myDet->geographicalID() = " << myDet->geographicalId() << std::endl;
123  outputFile << "myDet->name() = " << myDet->name() << std::endl;
124  outputFile << "myDet->module->type() = " << std::fixed << std::setprecision(7) << myDet->type() << std::endl;
125  outputFile << "myDet->module->translation() = " << std::fixed << std::setprecision(7) << myDet->translation()
126  << std::endl;
127  outputFile << "myDet->module->rho() = " << std::fixed << std::setprecision(7) << myDet->rho() << std::endl;
128  if (fabs(myDet->rho()) > 0.00001) {
129  outputFile << "myDet->module->phi() = " << std::fixed << std::setprecision(7) << myDet->phi() << std::endl;
130  }
131  outputFile << "myDet->module->rotation() = " << std::fixed << std::setprecision(7) << myDet->rotation()
132  << std::endl;
133  outputFile << "myDet->module->shape() = " << std::fixed << std::setprecision(7) << myDet->shape() << std::endl;
136  outputFile << "myDet->params() = " << std::fixed << std::setprecision(7);
137  for (const auto& para : myDet->params()) {
138  outputFile << para << " ";
139  }
140  outputFile << " " << std::endl;
141  }
142  outputFile << "myDet->radLength() = " << myDet->radLength() << std::endl;
143  outputFile << "myDet->xi() = " << myDet->xi() << std::endl;
144  outputFile << "myDet->pixROCRows() = " << myDet->pixROCRows() << std::endl;
145  outputFile << "myDet->pixROCCols() = " << myDet->pixROCCols() << std::endl;
146  outputFile << "myDet->pixROCx() = " << myDet->pixROCx() << std::endl;
147  outputFile << "myDet->pixROCy() = " << myDet->pixROCy() << std::endl;
148  outputFile << "myDet->stereo() = " << myDet->stereo() << std::endl;
149  outputFile << "myDet->isLowerSensor() = " << myDet->isLowerSensor() << std::endl;
150  outputFile << "myDet->isUpperSensor() = " << myDet->isUpperSensor() << std::endl;
151  outputFile << "myDet->siliconAPVNum() = " << myDet->siliconAPVNum() << std::endl;
152  }
153 }
double siliconAPVNum() const
Definition: GeometricDet.h:142
Log< level::Info, true > LogVerbatim
double pixROCy() const
Definition: GeometricDet.h:137
static std::string getString(const std::string &, FilteredView *)
#define DEBUG
double phi() const
Definition: GeometricDet.h:104
const std::vector< double > & params() const
Definition: GeometricDet.h:118
const cms::DDSolidShape & shape_dd4hep() const
Definition: GeometricDet.h:116
bool isUpperSensor() const
Definition: GeometricDet.h:141
bool isLowerSensor() const
Definition: GeometricDet.h:140
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
bool stereo() const
Definition: GeometricDet.h:139
void build(FilteredView &, GeometricDet *, const std::string &) override
ConstGeometricDetContainer & components()
Definition: GeometricDet.h:152
void buildId(GeometricDet &det)
const Translation & translation() const
Definition: GeometricDet.h:102
LegacySolidShape shape() const
Definition: GeometricDet.h:114
double rho() const
Definition: GeometricDet.h:103
const std::string & name() const
Definition: GeometricDet.h:92
bool firstChild()
set the current node to the first child
GeometricDet::GeometricEnumType type(std::string const &) const
const RotationMatrix & rotation() const
Definition: GeometricDet.h:105
double xi() const
Definition: GeometricDet.h:129
void printAllTrackerGeometricDets(const GeometricDet *tracker)
const DetId & geographicalId() const
Definition: GeometricDet.h:98
double radLength() const
Definition: GeometricDet.h:128
const GeometricEnumType & type() const
Definition: GeometricDet.h:93
double pixROCRows() const
Definition: GeometricDet.h:134
double pixROCx() const
Definition: GeometricDet.h:136
bool firstChild()
set the current node to the first child ...
std::unique_ptr< GeometricDet > construct(DDCompactView const &cpv, std::vector< int > const &detidShifts)
double pixROCCols() const
Definition: GeometricDet.h:135