CMS 3D CMS Logo

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