CMS 3D CMS Logo

PGeometricDetBuilder.cc
Go to the documentation of this file.
18 #include <vector>
19 
20 using DD3Vector = ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D<double>>;
21 using Translation = ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D<double>>;
22 using RotationMatrix = ROOT::Math::Rotation3D;
23 
24 class PGeometricDetBuilder : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
25 public:
27 
28  void beginRun(edm::Run const& iEvent, edm::EventSetup const&) override;
29  void analyze(edm::Event const& iEvent, edm::EventSetup const&) override {}
30  void endRun(edm::Run const& iEvent, edm::EventSetup const&) override {}
31 
32 private:
33  void putOne(const GeometricDet* gd, PGeometricDet* pgd, int lev);
35 };
36 
38  fromDD4hep_ = iConfig.getParameter<bool>("fromDD4hep");
39 }
40 
42  PGeometricDet* pgd = new PGeometricDet;
44  if (!mydbservice.isAvailable()) {
45  edm::LogError("PGeometricDetBuilder") << "PoolDBOutputService unavailable";
46  return;
47  }
48  if (!fromDD4hep_) {
50  es.get<IdealGeometryRecord>().get(pDD);
51  } else {
53  es.get<IdealGeometryRecord>().get(pDD);
54  }
56  es.get<IdealGeometryRecord>().get(rDD);
57  const GeometricDet* tracker = &(*rDD);
58 
59  // so now I have the tracker itself. loop over all its components to store them.
60  putOne(tracker, pgd, 0);
61  std::vector<const GeometricDet*> tc = tracker->components();
62  std::vector<const GeometricDet*>::const_iterator git = tc.begin();
63  std::vector<const GeometricDet*>::const_iterator egit = tc.end();
64  int count = 0;
65  int lev = 1;
66  for (; git != egit; ++git) { // one level below "tracker"
67  putOne(*git, pgd, lev);
68  std::vector<const GeometricDet*> inone = (*git)->components();
69  if (inone.empty())
70  ++count;
71  std::vector<const GeometricDet*>::const_iterator git2 = inone.begin();
72  std::vector<const GeometricDet*>::const_iterator egit2 = inone.end();
73  ++lev;
74  for (; git2 != egit2; ++git2) { // level 2
75  putOne(*git2, pgd, lev);
76  std::vector<const GeometricDet*> intwo = (*git2)->components();
77  if (intwo.empty())
78  ++count;
79  std::vector<const GeometricDet*>::const_iterator git3 = intwo.begin();
80  std::vector<const GeometricDet*>::const_iterator egit3 = intwo.end();
81  ++lev;
82  for (; git3 != egit3; ++git3) { // level 3
83  putOne(*git3, pgd, lev);
84  std::vector<const GeometricDet*> inthree = (*git3)->components();
85  if (inthree.empty())
86  ++count;
87  std::vector<const GeometricDet*>::const_iterator git4 = inthree.begin();
88  std::vector<const GeometricDet*>::const_iterator egit4 = inthree.end();
89  ++lev;
90  for (; git4 != egit4; ++git4) { //level 4
91  putOne(*git4, pgd, lev);
92  std::vector<const GeometricDet*> infour = (*git4)->components();
93  if (infour.empty())
94  ++count;
95  std::vector<const GeometricDet*>::const_iterator git5 = infour.begin();
96  std::vector<const GeometricDet*>::const_iterator egit5 = infour.end();
97  ++lev;
98  for (; git5 != egit5; ++git5) { // level 5
99  putOne(*git5, pgd, lev);
100  std::vector<const GeometricDet*> infive = (*git5)->components();
101  if (infive.empty())
102  ++count;
103  std::vector<const GeometricDet*>::const_iterator git6 = infive.begin();
104  std::vector<const GeometricDet*>::const_iterator egit6 = infive.end();
105  ++lev;
106  for (; git6 != egit6; ++git6) { //level 6
107  putOne(*git6, pgd, lev);
108  std::vector<const GeometricDet*> insix = (*git6)->components();
109  if (insix.empty())
110  ++count;
111  } // level 6
112  --lev;
113  } // level 5
114  --lev;
115  } // level 4
116  --lev;
117  } //level 3
118  --lev;
119  } // level 2
120  --lev;
121  }
122  std::vector<const GeometricDet*> modules = tracker->deepComponents();
123  if (mydbservice->isNewTagRequest("IdealGeometryRecord")) {
124  mydbservice->createNewIOV<PGeometricDet>(
125  pgd, mydbservice->beginOfTime(), mydbservice->endOfTime(), "IdealGeometryRecord");
126  } else {
127  edm::LogError("PGeometricDetBuilder") << "PGeometricDetBuilder Tag already present";
128  }
129 }
130 
133  const Translation& tran = gd->translation();
134  const RotationMatrix& rot = gd->rotation();
135  DD3Vector x, y, z;
136  rot.GetComponents(x, y, z);
137  item._name = gd->name();
138  item._ns = std::string();
139  item._level = lev;
141  const double tol = 1.e-10;
142  // Round very small calculated values to 0 to avoid discrepancies
143  // between +0 and -0 in comparisons.
144  item._x = roundIfNear0(tran.X(), tol);
145  item._y = roundIfNear0(tran.Y(), tol);
146  item._z = roundIfNear0(tran.Z(), tol);
147  item._phi = gd->phi();
148  item._rho = gd->rho();
149  item._a11 = roundIfNear0(x.X(), tol);
150  item._a12 = roundIfNear0(y.X(), tol);
151  item._a13 = roundIfNear0(z.X(), tol);
152  item._a21 = roundIfNear0(x.Y(), tol);
153  item._a22 = roundIfNear0(y.Y(), tol);
154  item._a23 = roundIfNear0(z.Y(), tol);
155  item._a31 = roundIfNear0(x.Z(), tol);
156  item._a32 = roundIfNear0(y.Z(), tol);
157  item._a33 = roundIfNear0(z.Z(), tol);
158  item._shape = static_cast<int>(gd->shape_dd4hep());
159  item._type = gd->type();
160  if (gd->shape_dd4hep() == cms::DDSolidShape::ddbox) {
161  item._params0 = gd->params()[0];
162  item._params1 = gd->params()[1];
163  item._params2 = gd->params()[2];
164  item._params3 = 0;
165  item._params4 = 0;
166  item._params5 = 0;
167  item._params6 = 0;
168  item._params7 = 0;
169  item._params8 = 0;
170  item._params9 = 0;
171  item._params10 = 0;
172  } else if (gd->shape_dd4hep() == cms::DDSolidShape::ddtrap) {
173  item._params0 = gd->params()[0];
174  item._params1 = gd->params()[1];
175  item._params2 = gd->params()[2];
176  item._params3 = gd->params()[3];
177  item._params4 = gd->params()[4];
178  item._params5 = gd->params()[5];
179  item._params6 = gd->params()[6];
180  item._params7 = gd->params()[7];
181  item._params8 = gd->params()[8];
182  item._params9 = gd->params()[9];
183  item._params10 = gd->params()[10];
184  } else {
185  item._params0 = 0;
186  item._params1 = 0;
187  item._params2 = 0;
188  item._params3 = 0;
189  item._params4 = 0;
190  item._params5 = 0;
191  item._params6 = 0;
192  item._params7 = 0;
193  item._params8 = 0;
194  item._params9 = 0;
195  item._params10 = 0;
196  }
197  item._geographicalID = gd->geographicalId();
198  item._radLength = gd->radLength();
199  item._xi = gd->xi();
200  item._pixROCRows = gd->pixROCRows();
201  item._pixROCCols = gd->pixROCCols();
202  item._pixROCx = gd->pixROCx();
203  item._pixROCy = gd->pixROCy();
204  item._stereo = gd->stereo();
205  item._siliconAPVNum = gd->siliconAPVNum();
206 
207  GeometricDet::nav_type const& nt = gd->navType();
208  size_t nts = nt.size();
209  item._numnt = nts;
210  std::vector<int> tempnt(nt.begin(), nt.end());
211  for (size_t extrant = nt.size(); extrant < 11; ++extrant) {
212  tempnt.push_back(-1);
213  }
214  item._nt0 = tempnt[0];
215  item._nt1 = tempnt[1];
216  item._nt2 = tempnt[2];
217  item._nt3 = tempnt[3];
218  item._nt4 = tempnt[4];
219  item._nt5 = tempnt[5];
220  item._nt6 = tempnt[6];
221  item._nt7 = tempnt[7];
222  item._nt8 = tempnt[8];
223  item._nt9 = tempnt[9];
224  item._nt10 = tempnt[10];
225 
226  pgd->pgeomdets_.push_back(item);
227 }
228 
GeometricDet::phi
double phi() const
Definition: GeometricDet.h:102
DDAxes::y
PGeometricDetBuilder::PGeometricDetBuilder
PGeometricDetBuilder(const edm::ParameterSet &)
Definition: PGeometricDetBuilder.cc:37
EDAnalyzer.h
ESTransientHandle.h
MessageLogger.h
cond::service::PoolDBOutputService::beginOfTime
cond::Time_t beginOfTime() const
Definition: PoolDBOutputService.cc:215
ESHandle.h
nt
int nt
Definition: AMPTWrapper.h:42
edm::Run
Definition: Run.h:45
modules
Definition: MuonCleanerBySegments.cc:35
PGeometricDetBuilder::endRun
void endRun(edm::Run const &iEvent, edm::EventSetup const &) override
Definition: PGeometricDetBuilder.cc:30
Rounding.h
PGeometricDetBuilder::putOne
void putOne(const GeometricDet *gd, PGeometricDet *pgd, int lev)
Definition: PGeometricDetBuilder.cc:131
DDAxes::x
GeometricDet::translation
const Translation & translation() const
Definition: GeometricDet.h:100
edm::one::EDAnalyzer
Definition: EDAnalyzer.h:30
RotationMatrix
ROOT::Math::Rotation3D RotationMatrix
Definition: PGeometricDetBuilder.cc:22
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
DDCompactView.h
MakerMacros.h
GeometricDet::name
const std::string & name() const
Definition: GeometricDet.h:90
PoolDBOutputService.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
GeometricDet::params
const std::vector< double > & params() const
Definition: GeometricDet.h:116
GeometricDet::shape_dd4hep
const cms::DDSolidShape & shape_dd4hep() const
Definition: GeometricDet.h:114
cond::service::PoolDBOutputService::createNewIOV
void createNewIOV(const T *firstPayloadObj, cond::Time_t firstSinceTime, cond::Time_t, const std::string &recordName)
Definition: PoolDBOutputService.h:116
GeometricDet::rotation
const RotationMatrix & rotation() const
Definition: GeometricDet.h:103
PGeometricDetBuilder::beginRun
void beginRun(edm::Run const &iEvent, edm::EventSetup const &) override
Definition: PGeometricDetBuilder.cc:41
Service.h
DDAxes::z
edm::ESHandle< GeometricDet >
GeometricDet
Definition: GeometricDet.h:31
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
DDCompactView.h
GeometricDet::radLength
double radLength() const
Definition: GeometricDet.h:126
PGeometricDet::Item
Definition: PGeometricDet.h:14
DD3Vector
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
Definition: PGeometricDetBuilder.cc:20
GeometricDet::nav_type
std::vector< int > nav_type
Definition: GeometricDet.h:42
PbPb_ZMuSkimMuonDPG_cff.tracker
tracker
Definition: PbPb_ZMuSkimMuonDPG_cff.py:60
GeometricDet::stereo
bool stereo() const
Definition: GeometricDet.h:137
TrackerDigiGeometryRecord.h
GeometricDet::geographicalId
const DetId & geographicalId() const
Definition: GeometricDet.h:96
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
GeometricDet::pixROCRows
double pixROCRows() const
Definition: GeometricDet.h:132
edm::Service< cond::service::PoolDBOutputService >
cms::DDSolidShape::ddtrap
iEvent
int iEvent
Definition: GenABIO.cc:224
cms::DDSolidShape::ddbox
Translation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > Translation
Definition: PGeometricDetBuilder.cc:21
IdealGeometryRecord.h
cms_rounding::roundIfNear0
constexpr valType roundIfNear0(valType value, double tolerance=1.e-7)
Definition: Rounding.h:11
GeometricDet::pixROCx
double pixROCx() const
Definition: GeometricDet.h:134
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
edm::EventSetup
Definition: EventSetup.h:58
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
GeometricDet.h
get
#define get
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ESTransientHandle
Definition: ESTransientHandle.h:41
GeometricDet::rho
double rho() const
Definition: GeometricDet.h:101
cond::service::PoolDBOutputService::endOfTime
cond::Time_t endOfTime() const
Definition: PoolDBOutputService.cc:213
PGeometricDetBuilder
Definition: PGeometricDetBuilder.cc:24
GeometricDet::siliconAPVNum
double siliconAPVNum() const
Definition: GeometricDet.h:140
GeometricDet::pixROCCols
double pixROCCols() const
Definition: GeometricDet.h:133
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
GeometricDet::xi
double xi() const
Definition: GeometricDet.h:127
GeometricDet::pixROCy
double pixROCy() const
Definition: GeometricDet.h:135
EventSetup.h
cond::service::PoolDBOutputService::isNewTagRequest
bool isNewTagRequest(const std::string &recordName)
Definition: PoolDBOutputService.cc:128
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
PGeometricDet.h
ParameterSet.h
GeometricDet::type
const GeometricEnumType & type() const
Definition: GeometricDet.h:91
PGeometricDet::pgeomdets_
std::vector< Item > pgeomdets_
Definition: PGeometricDet.h:50
edm::Event
Definition: Event.h:73
PGeometricDetBuilder::analyze
void analyze(edm::Event const &iEvent, edm::EventSetup const &) override
Definition: PGeometricDetBuilder.cc:29
PGeometricDet
Definition: PGeometricDet.h:9
IdealGeometryRecord
Definition: IdealGeometryRecord.h:25
PGeometricDetBuilder::fromDD4hep_
bool fromDD4hep_
Definition: PGeometricDetBuilder.cc:34
GeometricDet::navType
const nav_type & navType() const
Definition: GeometricDet.h:94