CMS 3D CMS Logo

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