CMS 3D CMS Logo

GeometricTimingDetLoader.cc
Go to the documentation of this file.
2 
10 
15 
17 
18 #include <iostream>
19 #include <string>
20 #include <vector>
21 
22 // just a reminder to self... beware errors caused by levels. Look
23 // at how tracker is built and how GeometricSearchTracker.h is built
24 // up from the hierarchy.
25 
27  LogDebug("GeometricTimingDetLoader") << "GeometricTimingDetLoader::GeometricTimingDetLoader" << std::endl;
28 }
29 
31  LogDebug("GeometricTimingDetLoader") << "GeometricTimingDetLoader::~GeometricTimingDetLoader" << std::endl;
32 }
33 
34 void GeometricTimingDetLoader::beginRun(edm::Run const& /* iEvent */, edm::EventSetup const& es) {
35  std::cout << "GeometricTimingDetLoader::beginJob" << std::endl;
38  if (!mydbservice.isAvailable()) {
39  std::cout << "PoolDBOutputService unavailable" << std::endl;
40  return;
41  }
44  es.get<IdealGeometryRecord>().get(pDD);
45  es.get<IdealGeometryRecord>().get(rDD);
46  const GeometricTimingDet* tracker = &(*rDD);
47 
48  // so now I have the tracker itself. loop over all its components to store them.
49  putOne(tracker, pgd, 0);
50  std::vector<const GeometricTimingDet*> tc = tracker->components();
51  std::cout << "Tracker has " << tc.size() << " components." << std::endl; //, lets go through them." << std::endl;
52  std::vector<const GeometricTimingDet*>::const_iterator git = tc.begin();
53  std::vector<const GeometricTimingDet*>::const_iterator egit = tc.end();
54  int count = 0;
55  int lev = 1;
56  for (; git != egit; ++git) { // one level below "tracker"
57  putOne(*git, pgd, lev);
58  std::vector<const GeometricTimingDet*> inone = (*git)->components();
59  // << ctste.name((*git)->type())
60  // std::cout << lev << " type " << (*git)->type() << " " << int((*git)->geographicalId()) << std::endl; // << " has " << inone.size() << " components." << std::endl;
61  if (inone.empty())
62  ++count;
63  std::vector<const GeometricTimingDet*>::const_iterator git2 = inone.begin();
64  std::vector<const GeometricTimingDet*>::const_iterator egit2 = inone.end();
65  ++lev;
66  for (; git2 != egit2; ++git2) { // level 2
67  putOne(*git2, pgd, lev);
68  std::vector<const GeometricTimingDet*> intwo = (*git2)->components();
69  // std::cout << lev << "\ttype " << (*git2)->type() << " " << int((*git2)->geographicalId()) << std::endl; // << " has " << intwo.size() << " components." << std::endl;
70  if (intwo.empty())
71  ++count;
72  std::vector<const GeometricTimingDet*>::const_iterator git3 = intwo.begin();
73  std::vector<const GeometricTimingDet*>::const_iterator egit3 = intwo.end();
74  ++lev;
75  for (; git3 != egit3; ++git3) { // level 3
76  putOne(*git3, pgd, lev);
77  std::vector<const GeometricTimingDet*> inthree = (*git3)->components();
78  // std::cout << lev << "\t\ttype " << (*git3)->type() << " " << int((*git3)->geographicalId()) << std::endl; // << " has " << inthree.size() << " components." << std::endl;
79  if (inthree.empty())
80  ++count;
81  std::vector<const GeometricTimingDet*>::const_iterator git4 = inthree.begin();
82  std::vector<const GeometricTimingDet*>::const_iterator egit4 = inthree.end();
83  ++lev;
84  for (; git4 != egit4; ++git4) { //level 4
85  putOne(*git4, pgd, lev);
86  std::vector<const GeometricTimingDet*> infour = (*git4)->components();
87  // std::cout << lev << "\t\t\ttype " << (*git4)->type() << " " << int((*git4)->geographicalId()) << std::endl; // << " has " << infour.size() << " components." << std::endl;
88  if (infour.empty())
89  ++count;
90  std::vector<const GeometricTimingDet*>::const_iterator git5 = infour.begin();
91  std::vector<const GeometricTimingDet*>::const_iterator egit5 = infour.end();
92  ++lev;
93  for (; git5 != egit5; ++git5) { // level 5
94  putOne(*git5, pgd, lev);
95  std::vector<const GeometricTimingDet*> infive = (*git5)->components();
96  // std::cout << lev << "\t\t\t\ttype " << (*git5)->type() << " " << int((*git5)->geographicalId()) << std::endl; // << " has " << infive.size() << " components." << std::endl;
97  if (infive.empty())
98  ++count;
99  std::vector<const GeometricTimingDet*>::const_iterator git6 = infive.begin();
100  std::vector<const GeometricTimingDet*>::const_iterator egit6 = infive.end();
101  ++lev;
102  for (; git6 != egit6; ++git6) { //level 6
103  putOne(*git6, pgd, lev);
104  std::vector<const GeometricTimingDet*> insix = (*git6)->components();
105  // std::cout << lev << "\t\t\t\t\ttype " << (*git6)->type() << " " << int((*git6)->geographicalId()) << std::endl; // << " has " << insix.size() << " components." << std::endl;
106  if (insix.empty())
107  ++count;
108  } // level 6
109  --lev;
110  } // level 5
111  --lev;
112  } // level 4
113  --lev;
114  } //level 3
115  --lev;
116  } // level 2
117  --lev;
118  }
119  std::vector<const GeometricTimingDet*> modules = tracker->deepComponents();
120  std::cout << " No. of Tracker components \"deepComponents\" = " << modules.size() << std::endl;
121  std::cout << " Counted # of lowest \"leaves\" = " << count << std::endl;
122  if (mydbservice->isNewTagRequest("PGeometricTimingDetRcd")) {
123  mydbservice->createNewIOV<PGeometricTimingDet>(
124  pgd, mydbservice->beginOfTime(), mydbservice->endOfTime(), "PGeometricTimingDetRcd");
125  } else {
126  std::cout << "PGeometricTimingDetRcd Tag is already present." << std::endl;
127  }
128 }
129 
131  // std::cout << "putting name: " << gd->name().name();
132  // std::cout << " gid: " << gd->geographicalID();
133  // std::cout << " type: " << gd->type() << std::endl;
134  // std::cout << "shape = " << gd->shape()<<"; name = "<<gd->name().name()<<"; parameter number = "<<gd->params().size()<<std::endl;
136  const DDTranslation& tran = gd->translation();
137  const DDRotationMatrix& rot = gd->rotation();
138  DD3Vector x, y, z;
139  rot.GetComponents(x, y, z);
140  item.name_ = gd->name();
141  item.level_ = lev;
142  item.x_ = tran.X();
143  item.y_ = tran.Y();
144  item.z_ = tran.Z();
145  item.phi_ = gd->phi();
146  item.rho_ = gd->rho();
147  item.a11_ = x.X();
148  item.a12_ = y.X();
149  item.a13_ = z.X();
150  item.a21_ = x.Y();
151  item.a22_ = y.Y();
152  item.a23_ = z.Y();
153  item.a31_ = x.Z();
154  item.a32_ = y.Z();
155  item.a33_ = z.Z();
156  item.shape_ = static_cast<int>(gd->shape());
157  item.type_ = gd->type();
158  if (gd->shape() == DDSolidShape::ddbox) {
159  item.params_0 = gd->params()[0];
160  item.params_1 = gd->params()[1];
161  item.params_2 = gd->params()[2];
162  item.params_3 = 0;
163  item.params_4 = 0;
164  item.params_5 = 0;
165  item.params_6 = 0;
166  item.params_7 = 0;
167  item.params_8 = 0;
168  item.params_9 = 0;
169  item.params_10 = 0;
170  } else if (gd->shape() == DDSolidShape::ddtrap) {
171  item.params_0 = gd->params()[0];
172  item.params_1 = gd->params()[1];
173  item.params_2 = gd->params()[2];
174  item.params_3 = gd->params()[3];
175  item.params_4 = gd->params()[4];
176  item.params_5 = gd->params()[5];
177  item.params_6 = gd->params()[6];
178  item.params_7 = gd->params()[7];
179  item.params_8 = gd->params()[8];
180  item.params_9 = gd->params()[9];
181  item.params_10 = gd->params()[10];
182  } else {
183  item.params_0 = 0;
184  item.params_1 = 0;
185  item.params_2 = 0;
186  item.params_3 = 0;
187  item.params_4 = 0;
188  item.params_5 = 0;
189  item.params_6 = 0;
190  item.params_7 = 0;
191  item.params_8 = 0;
192  item.params_9 = 0;
193  item.params_10 = 0;
194  }
195  item.geographicalID_ = gd->geographicalID();
196  // FIXME: These are moved to PGeometricTimingDetExtra:
197  //item.volume_ = gd->volume();
198  //item.density_ = gd->density();
199  //item.weight_ = gd->weight();
200  //item.copy_ = gd->copyno();
201  //item.material_ = gd->material();
202  item.radLength_ = gd->radLength();
203  item.xi_ = gd->xi();
204  item.pixROCRows_ = gd->pixROCRows();
205  item.pixROCCols_ = gd->pixROCCols();
206  item.pixROCx_ = gd->pixROCx();
207  item.pixROCy_ = gd->pixROCy();
208  item.stereo_ = gd->stereo();
209  item.siliconAPVNum_ = gd->siliconAPVNum();
210  pgd->pgeomdets_.push_back(item);
211 }
212 
#define LogDebug(id)
void beginRun(edm::Run const &iEvent, edm::EventSetup const &) override
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
GeometricTimingEnumType type() const
double siliconAPVNum() const
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
double pixROCCols() const
double phi() const
std::vector< Item > pgeomdets_
double radLength() const
ConstGeometricTimingDetContainer & components()
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
Definition: DDTranslation.h:6
bool isNewTagRequest(const std::string &recordName)
ConstGeometricTimingDetContainer deepComponents() const
bool isAvailable() const
Definition: Service.h:40
double rho() const
double pixROCRows() const
void createNewIOV(T *firstPayloadObj, cond::Time_t firstSinceTime, cond::Time_t firstTillTime, const std::string &recordName, bool withlogging=false)
void putOne(const GeometricTimingDet *gd, PGeometricTimingDet *pgd, int lev)
std::string const & name() const
DetId geographicalID() const
std::vector< double > const & params() const
double pixROCx() const
T get() const
Definition: EventSetup.h:73
RotationMatrix const & rotation() const
GeometricTimingDetLoader(const edm::ParameterSet &iConfig)
DDSolidShape const & shape() const
double pixROCy() const
Definition: Run.h:45
Translation const & translation() const