CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GeometricDetLoader.cc
Go to the documentation of this file.
1 #include "GeometricDetLoader.h"
2 
10 
15 
17 
20 
21 #include <iostream>
22 #include <string>
23 #include <vector>
24 //#include <map>
25 //#include <sstream>
26 //#include <algorithm>
27 
28 // just a reminder to self... beware errors caused by levels. Look
29 // at how tracker is built and how GeometricSearchTracker.h is built
30 // up from the hierarchy.
31 
33 {
34  std::cout<<"GeometricDetLoader::GeometricDetLoader"<<std::endl;
35 }
36 
38 {
39  std::cout<<"GeometricDetLoader::~GeometricDetLoader"<<std::endl;
40 }
41 
42 void
44 {
45  std::cout<<"GeometricDetLoader::beginJob"<<std::endl;
46  PGeometricDet* pgd = new PGeometricDet;
48  if( !mydbservice.isAvailable() ){
49  std::cout<<"PoolDBOutputService unavailable"<<std::endl;
50  return;
51  }
54  es.get<IdealGeometryRecord>().get( pDD );
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::cout <<"Tracker has " << tc.size() << " components." << std::endl; //, lets go through them." << std::endl;
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  // CmsTrackerStringToEnum ctste;
67  for (; git!= egit; ++git) { // one level below "tracker"
68  putOne(*git, pgd, lev);
69  std::vector<const GeometricDet*> inone = (*git)->components();
70  // << ctste.name((*git)->type())
71  // std::cout << lev << " type " << (*git)->type() << " " << int((*git)->geographicalId()) << std::endl; // << " has " << inone.size() << " components." << std::endl;
72  if ( inone.size() == 0 ) ++count;
73  std::vector<const GeometricDet*>::const_iterator git2 = inone.begin();
74  std::vector<const GeometricDet*>::const_iterator egit2 = inone.end();
75  ++lev;
76  for (; git2 != egit2; ++git2) { // level 2
77  putOne(*git2, pgd, lev);
78  std::vector<const GeometricDet*> intwo= (*git2)->components();
79  // std::cout << lev << "\ttype " << (*git2)->type() << " " << int((*git2)->geographicalId()) << std::endl; // << " has " << intwo.size() << " components." << std::endl;
80  if ( intwo.size() == 0 ) ++count;
81  std::vector<const GeometricDet*>::const_iterator git3 = intwo.begin();
82  std::vector<const GeometricDet*>::const_iterator egit3 = intwo.end();
83  ++lev;
84  for (; git3 != egit3; ++git3) { // level 3
85  putOne(*git3, pgd, lev);
86  std::vector<const GeometricDet*> inthree= (*git3)->components();
87  // std::cout << lev << "\t\ttype " << (*git3)->type() << " " << int((*git3)->geographicalId()) << std::endl; // << " has " << inthree.size() << " components." << std::endl;
88  if ( inthree.size() == 0 ) ++count;
89  std::vector<const GeometricDet*>::const_iterator git4 = inthree.begin();
90  std::vector<const GeometricDet*>::const_iterator egit4 = inthree.end();
91  ++lev;
92  for (; git4 != egit4; ++git4) { //level 4
93  putOne(*git4, pgd, lev);
94  std::vector<const GeometricDet*> infour= (*git4)->components();
95  // std::cout << lev << "\t\t\ttype " << (*git4)->type() << " " << int((*git4)->geographicalId()) << std::endl; // << " has " << infour.size() << " components." << std::endl;
96  if ( infour.size() == 0 ) ++count;
97  std::vector<const GeometricDet*>::const_iterator git5 = infour.begin();
98  std::vector<const GeometricDet*>::const_iterator egit5 = infour.end();
99  ++lev;
100  for (; git5 != egit5; ++git5) { // level 5
101  putOne(*git5, pgd, lev);
102  std::vector<const GeometricDet*> infive= (*git5)->components();
103  // std::cout << lev << "\t\t\t\ttype " << (*git5)->type() << " " << int((*git5)->geographicalId()) << std::endl; // << " has " << infive.size() << " components." << std::endl;
104  if ( infive.size() == 0 ) ++count;
105  std::vector<const GeometricDet*>::const_iterator git6 = infive.begin();
106  std::vector<const GeometricDet*>::const_iterator egit6 = infive.end();
107  ++lev;
108  for (; git6 != egit6; ++git6) { //level 6
109  putOne(*git6, pgd, lev);
110  std::vector<const GeometricDet*> insix= (*git6)->components();
111  // std::cout << lev << "\t\t\t\t\ttype " << (*git6)->type() << " " << int((*git6)->geographicalId()) << std::endl; // << " has " << insix.size() << " components." << std::endl;
112  if ( insix.size() == 0 ) ++count;
113  } // level 6
114  --lev;
115  } // level 5
116  --lev;
117  } // level 4
118  --lev;
119  } //level 3
120  --lev;
121  } // level 2
122  --lev;
123  }
124  std::vector<const GeometricDet*> modules = tracker->deepComponents();
125  std::cout << " No. of Tracker components \"deepComponents\" = " << modules.size() << std::endl;
126  std::cout << " Counted # of lowest \"leaves\" = " << count << std::endl;
127  if ( mydbservice->isNewTagRequest("PGeometricDetRcd") ) {
128  mydbservice->createNewIOV<PGeometricDet>( pgd
129  , mydbservice->beginOfTime()
130  , mydbservice->endOfTime()
131  , "PGeometricDetRcd");
132  } else {
133  std::cout << "PGeometricDetRcd Tag is already present." << std::endl;
134  }
135 }
136 
137 void GeometricDetLoader::putOne ( const GeometricDet* gd, PGeometricDet* pgd, int lev ) {
138 
139 // std::cout << "putting name: " << gd->name().name();
140 // std::cout << " gid: " << gd->geographicalID();
141 // std::cout << " type: " << gd->type() << std::endl;
142 // static CmsTrackerStringToEnum ctste;
143 // std::cout << "shape = " << gd->shape()<<"; name = "<<gd->name().name()<<"; parameter number = "<<gd->params().size()<<std::endl;
144  PGeometricDet::Item item;
145  DDTranslation tran = gd->translation();
146  DDRotationMatrix rot = gd->rotation();
147  DD3Vector x, y, z;
148  rot.GetComponents(x, y, z);
149  item._name = gd->name().name();
150  item._level = lev;
151  item._x = tran.X();
152  item._y = tran.Y();
153  item._z = tran.Z();
154  item._phi = gd->phi();
155  item._rho = gd->rho();
156  item._a11 = x.X();
157  item._a12 = y.X();
158  item._a13 = z.X();
159  item._a21 = x.Y();
160  item._a22 = y.Y();
161  item._a23 = z.Y();
162  item._a31 = x.Z();
163  item._a32 = y.Z();
164  item._a33 = z.Z();
165  item._shape = gd->shape();
166  item._type = gd->type();
167  if(gd->shape()==1){
168  item._params0=gd->params()[0];
169  item._params1=gd->params()[1];
170  item._params2=gd->params()[2];
171  item._params3=0;
172  item._params4=0;
173  item._params5=0;
174  item._params6=0;
175  item._params7=0;
176  item._params8=0;
177  item._params9=0;
178  item._params10=0;
179  }else if(gd->shape()==3){
180  item._params0=gd->params()[0];
181  item._params1=gd->params()[1];
182  item._params2=gd->params()[2];
183  item._params3=gd->params()[3];
184  item._params4=gd->params()[4];
185  item._params5=gd->params()[5];
186  item._params6=gd->params()[6];
187  item._params7=gd->params()[7];
188  item._params8=gd->params()[8];
189  item._params9=gd->params()[9];
190  item._params10=gd->params()[10];
191  }else{
192  item._params0=0;
193  item._params1=0;
194  item._params2=0;
195  item._params3=0;
196  item._params4=0;
197  item._params5=0;
198  item._params6=0;
199  item._params7=0;
200  item._params8=0;
201  item._params9=0;
202  item._params10=0;
203  }
204  item._geographicalID = gd->geographicalID();
205  // FIXME: These are moved to PGeometricDetExtra:
206  //item._volume = gd->volume();
207  //item._density = gd->density();
208  //item._weight = gd->weight();
209  //item._copy = gd->copyno();
210  //item._material = gd->material();
211  item._radLength = gd->radLength();
212  item._xi = gd->xi();
213  item._pixROCRows = gd->pixROCRows();
214  item._pixROCCols = gd->pixROCCols();
215  item._pixROCx = gd->pixROCx();
216  item._pixROCy = gd->pixROCy();
217  item._stereo = gd->stereo();
218  item._siliconAPVNum = gd->siliconAPVNum();
219  pgd->pgeomdets_.push_back ( item );
220 }
221 
double pixROCy() const
Definition: GeometricDet.h:263
virtual void beginJob()
Definition: EDAnalyzer.h:58
double radLength() const
Definition: GeometricDet.h:240
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
DDSolidShape const & shape() const
Definition: GeometricDet.h:125
std::vector< Item > pgeomdets_
Definition: PGeometricDet.h:46
DetId geographicalID() const
Definition: GeometricDet.h:195
double double double z
GeometricDetLoader(const edm::ParameterSet &iConfig)
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)
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)
void putOne(const GeometricDet *gd, PGeometricDet *pgd, int lev)
double xi() const
Definition: GeometricDet.h:244
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
tuple cout
Definition: gather_cfg.py:121
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
double rho() const
Definition: GeometricDet.h:120