CMS 3D CMS Logo

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