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 {
28  LogDebug("GeometricTimingDetLoader")
29  <<"GeometricTimingDetLoader::GeometricTimingDetLoader"<<std::endl;
30 }
31 
33 {
34  LogDebug("GeometricTimingDetLoader")
35  <<"GeometricTimingDetLoader::~GeometricTimingDetLoader"<<std::endl;
36 }
37 
38 void
40 {
41  std::cout<<"GeometricTimingDetLoader::beginJob"<<std::endl;
44  if( !mydbservice.isAvailable() ){
45  std::cout<<"PoolDBOutputService unavailable"<<std::endl;
46  return;
47  }
50  es.get<IdealGeometryRecord>().get( pDD );
51  es.get<IdealGeometryRecord>().get( rDD );
52  const GeometricTimingDet* tracker = &(*rDD);
53 
54  // so now I have the tracker itself. loop over all its components to store them.
55  putOne(tracker, pgd, 0);
56  std::vector<const GeometricTimingDet*> tc = tracker->components();
57  std::cout <<"Tracker has " << tc.size() << " components." << std::endl; //, lets go through them." << std::endl;
58  std::vector<const GeometricTimingDet*>::const_iterator git = tc.begin();
59  std::vector<const GeometricTimingDet*>::const_iterator egit = tc.end();
60  int count=0;
61  int lev = 1;
62  for (; git!= egit; ++git) { // one level below "tracker"
63  putOne(*git, pgd, lev);
64  std::vector<const GeometricTimingDet*> inone = (*git)->components();
65  // << ctste.name((*git)->type())
66  // std::cout << lev << " type " << (*git)->type() << " " << int((*git)->geographicalId()) << std::endl; // << " has " << inone.size() << " components." << std::endl;
67  if ( inone.empty() ) ++count;
68  std::vector<const GeometricTimingDet*>::const_iterator git2 = inone.begin();
69  std::vector<const GeometricTimingDet*>::const_iterator egit2 = inone.end();
70  ++lev;
71  for (; git2 != egit2; ++git2) { // level 2
72  putOne(*git2, pgd, lev);
73  std::vector<const GeometricTimingDet*> intwo= (*git2)->components();
74  // std::cout << lev << "\ttype " << (*git2)->type() << " " << int((*git2)->geographicalId()) << std::endl; // << " has " << intwo.size() << " components." << std::endl;
75  if ( intwo.empty() ) ++count;
76  std::vector<const GeometricTimingDet*>::const_iterator git3 = intwo.begin();
77  std::vector<const GeometricTimingDet*>::const_iterator egit3 = intwo.end();
78  ++lev;
79  for (; git3 != egit3; ++git3) { // level 3
80  putOne(*git3, pgd, lev);
81  std::vector<const GeometricTimingDet*> inthree= (*git3)->components();
82  // std::cout << lev << "\t\ttype " << (*git3)->type() << " " << int((*git3)->geographicalId()) << std::endl; // << " has " << inthree.size() << " components." << std::endl;
83  if ( inthree.empty() ) ++count;
84  std::vector<const GeometricTimingDet*>::const_iterator git4 = inthree.begin();
85  std::vector<const GeometricTimingDet*>::const_iterator egit4 = inthree.end();
86  ++lev;
87  for (; git4 != egit4; ++git4) { //level 4
88  putOne(*git4, pgd, lev);
89  std::vector<const GeometricTimingDet*> infour= (*git4)->components();
90  // std::cout << lev << "\t\t\ttype " << (*git4)->type() << " " << int((*git4)->geographicalId()) << std::endl; // << " has " << infour.size() << " components." << std::endl;
91  if ( infour.empty() ) ++count;
92  std::vector<const GeometricTimingDet*>::const_iterator git5 = infour.begin();
93  std::vector<const GeometricTimingDet*>::const_iterator egit5 = infour.end();
94  ++lev;
95  for (; git5 != egit5; ++git5) { // level 5
96  putOne(*git5, pgd, lev);
97  std::vector<const GeometricTimingDet*> infive= (*git5)->components();
98  // std::cout << lev << "\t\t\t\ttype " << (*git5)->type() << " " << int((*git5)->geographicalId()) << std::endl; // << " has " << infive.size() << " components." << std::endl;
99  if ( infive.empty() ) ++count;
100  std::vector<const GeometricTimingDet*>::const_iterator git6 = infive.begin();
101  std::vector<const GeometricTimingDet*>::const_iterator egit6 = infive.end();
102  ++lev;
103  for (; git6 != egit6; ++git6) { //level 6
104  putOne(*git6, pgd, lev);
105  std::vector<const GeometricTimingDet*> insix= (*git6)->components();
106  // std::cout << lev << "\t\t\t\t\ttype " << (*git6)->type() << " " << int((*git6)->geographicalId()) << std::endl; // << " has " << insix.size() << " components." << std::endl;
107  if ( insix.empty() ) ++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>( pgd
124  , mydbservice->beginOfTime()
125  , mydbservice->endOfTime()
126  , "PGeometricTimingDetRcd");
127  } else {
128  std::cout << "PGeometricTimingDetRcd Tag is already present." << std::endl;
129  }
130 }
131 
133 
134 // std::cout << "putting name: " << gd->name().name();
135 // std::cout << " gid: " << gd->geographicalID();
136 // std::cout << " type: " << gd->type() << std::endl;
137 // std::cout << "shape = " << gd->shape()<<"; name = "<<gd->name().name()<<"; parameter number = "<<gd->params().size()<<std::endl;
139  const DDTranslation& tran = gd->translation();
140  const DDRotationMatrix& rot = gd->rotation();
141  DD3Vector x, y, z;
142  rot.GetComponents(x, y, z);
143  item.name_ = gd->name().name();
144  item.level_ = lev;
145  item.x_ = tran.X();
146  item.y_ = tran.Y();
147  item.z_ = tran.Z();
148  item.phi_ = gd->phi();
149  item.rho_ = gd->rho();
150  item.a11_ = x.X();
151  item.a12_ = y.X();
152  item.a13_ = z.X();
153  item.a21_ = x.Y();
154  item.a22_ = y.Y();
155  item.a23_ = z.Y();
156  item.a31_ = x.Z();
157  item.a32_ = y.Z();
158  item.a33_ = z.Z();
159  item.shape_ = static_cast<int>(gd->shape());
160  item.type_ = gd->type();
161  if(gd->shape()==DDSolidShape::ddbox){
162  item.params_0=gd->params()[0];
163  item.params_1=gd->params()[1];
164  item.params_2=gd->params()[2];
165  item.params_3=0;
166  item.params_4=0;
167  item.params_5=0;
168  item.params_6=0;
169  item.params_7=0;
170  item.params_8=0;
171  item.params_9=0;
172  item.params_10=0;
173  }else if(gd->shape()==DDSolidShape::ddtrap){
174  item.params_0=gd->params()[0];
175  item.params_1=gd->params()[1];
176  item.params_2=gd->params()[2];
177  item.params_3=gd->params()[3];
178  item.params_4=gd->params()[4];
179  item.params_5=gd->params()[5];
180  item.params_6=gd->params()[6];
181  item.params_7=gd->params()[7];
182  item.params_8=gd->params()[8];
183  item.params_9=gd->params()[9];
184  item.params_10=gd->params()[10];
185  }else{
186  item.params_0=0;
187  item.params_1=0;
188  item.params_2=0;
189  item.params_3=0;
190  item.params_4=0;
191  item.params_5=0;
192  item.params_6=0;
193  item.params_7=0;
194  item.params_8=0;
195  item.params_9=0;
196  item.params_10=0;
197  }
198  item.geographicalID_ = gd->geographicalID();
199  // FIXME: These are moved to PGeometricTimingDetExtra:
200  //item.volume_ = gd->volume();
201  //item.density_ = gd->density();
202  //item.weight_ = gd->weight();
203  //item.copy_ = gd->copyno();
204  //item.material_ = gd->material();
205  item.radLength_ = gd->radLength();
206  item.xi_ = gd->xi();
207  item.pixROCRows_ = gd->pixROCRows();
208  item.pixROCCols_ = gd->pixROCCols();
209  item.pixROCx_ = gd->pixROCx();
210  item.pixROCy_ = gd->pixROCy();
211  item.stereo_ = gd->stereo();
212  item.siliconAPVNum_ = gd->siliconAPVNum();
213  pgd->pgeomdets_.push_back ( item );
214 }
215 
#define LogDebug(id)
void beginRun(edm::Run const &iEvent, edm::EventSetup const &) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
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
std::vector< Item > pgeomdets_
double radLength() const
ConstGeometricTimingDetContainer & components()
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)
DDTranslation const & translation() const
ConstGeometricTimingDetContainer deepComponents() const
bool isAvailable() const
Definition: Service.h:46
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)
DetId geographicalID() const
std::vector< double > const & params() const
DDName const & name() const
double pixROCx() const
DDRotationMatrix const & rotation() const
T get() const
Definition: EventSetup.h:62
GeometricTimingDetLoader(const edm::ParameterSet &iConfig)
DDSolidShape const & shape() const
double pixROCy() const
const std::string & name() const
Returns the name.
Definition: DDName.cc:53
Definition: Run.h:44