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