Go to the documentation of this file.00001 #include "PGeometricDetBuilder.h"
00002
00003 #include "FWCore/ServiceRegistry/interface/Service.h"
00004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00005 #include "FWCore/Framework/interface/Event.h"
00006 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
00007 #include "FWCore/Framework/interface/EventSetup.h"
00008 #include "FWCore/Framework/interface/ESTransientHandle.h"
00009 #include "FWCore/Framework/interface/ESHandle.h"
00010 #include "CondFormats/GeometryObjects/interface/PGeometricDet.h"
00011
00012 #include "Geometry/Records/interface/IdealGeometryRecord.h"
00013 #include "Geometry/TrackerNumberingBuilder/interface/GeometricDet.h"
00014 #include <DetectorDescription/Core/interface/DDCompactView.h>
00015 #include <DetectorDescription/Core/interface/DDExpandedView.h>
00016 #include "DetectorDescription/Core/interface/DDExpandedNode.h"
00017
00018 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00019
00020 #include "Geometry/TrackerNumberingBuilder/interface/CmsTrackerStringToEnum.h"
00021
00022 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00023
00024 #include <iostream>
00025 #include <string>
00026 #include <vector>
00027
00028 PGeometricDetBuilder::PGeometricDetBuilder(const edm::ParameterSet& iConfig)
00029 {
00030 }
00031
00032 PGeometricDetBuilder::~PGeometricDetBuilder()
00033 {
00034 }
00035
00036 void
00037 PGeometricDetBuilder::beginRun( const edm::Run&, edm::EventSetup const& es)
00038 {
00039 PGeometricDet* pgd = new PGeometricDet;
00040 edm::Service<cond::service::PoolDBOutputService> mydbservice;
00041 if( !mydbservice.isAvailable() ){
00042 edm::LogError("PGeometricDetBuilder")<<"PoolDBOutputService unavailable";
00043 return;
00044 }
00045 edm::ESTransientHandle<DDCompactView> pDD;
00046 edm::ESHandle<GeometricDet> rDD;
00047 es.get<IdealGeometryRecord>().get( pDD );
00048 es.get<IdealGeometryRecord>().get( rDD );
00049 const GeometricDet* tracker = &(*rDD);
00050
00051
00052 putOne(tracker, pgd, 0);
00053 std::vector<const GeometricDet*> tc = tracker->components();
00054 std::vector<const GeometricDet*>::const_iterator git = tc.begin();
00055 std::vector<const GeometricDet*>::const_iterator egit = tc.end();
00056 int count=0;
00057 int lev = 1;
00058
00059 for (; git!= egit; ++git) {
00060 putOne(*git, pgd, lev);
00061 std::vector<const GeometricDet*> inone = (*git)->components();
00062
00063
00064 if ( inone.size() == 0 ) ++count;
00065 std::vector<const GeometricDet*>::const_iterator git2 = inone.begin();
00066 std::vector<const GeometricDet*>::const_iterator egit2 = inone.end();
00067 ++lev;
00068 for (; git2 != egit2; ++git2) {
00069 putOne(*git2, pgd, lev);
00070 std::vector<const GeometricDet*> intwo= (*git2)->components();
00071
00072 if ( intwo.size() == 0 ) ++count;
00073 std::vector<const GeometricDet*>::const_iterator git3 = intwo.begin();
00074 std::vector<const GeometricDet*>::const_iterator egit3 = intwo.end();
00075 ++lev;
00076 for (; git3 != egit3; ++git3) {
00077 putOne(*git3, pgd, lev);
00078 std::vector<const GeometricDet*> inthree= (*git3)->components();
00079
00080 if ( inthree.size() == 0 ) ++count;
00081 std::vector<const GeometricDet*>::const_iterator git4 = inthree.begin();
00082 std::vector<const GeometricDet*>::const_iterator egit4 = inthree.end();
00083 ++lev;
00084 for (; git4 != egit4; ++git4) {
00085 putOne(*git4, pgd, lev);
00086 std::vector<const GeometricDet*> infour= (*git4)->components();
00087
00088 if ( infour.size() == 0 ) ++count;
00089 std::vector<const GeometricDet*>::const_iterator git5 = infour.begin();
00090 std::vector<const GeometricDet*>::const_iterator egit5 = infour.end();
00091 ++lev;
00092 for (; git5 != egit5; ++git5) {
00093 putOne(*git5, pgd, lev);
00094 std::vector<const GeometricDet*> infive= (*git5)->components();
00095
00096 if ( infive.size() == 0 ) ++count;
00097 std::vector<const GeometricDet*>::const_iterator git6 = infive.begin();
00098 std::vector<const GeometricDet*>::const_iterator egit6 = infive.end();
00099 ++lev;
00100 for (; git6 != egit6; ++git6) {
00101 putOne(*git6, pgd, lev);
00102 std::vector<const GeometricDet*> insix= (*git6)->components();
00103
00104 if ( insix.size() == 0 ) ++count;
00105 }
00106 --lev;
00107 }
00108 --lev;
00109 }
00110 --lev;
00111 }
00112 --lev;
00113 }
00114 --lev;
00115 }
00116 std::vector<const GeometricDet*> modules = tracker->deepComponents();
00117 if ( mydbservice->isNewTagRequest("IdealGeometryRecord") ) {
00118 mydbservice->createNewIOV<PGeometricDet>( pgd,mydbservice->beginOfTime(),mydbservice->endOfTime(),"IdealGeometryRecord");
00119 } else {
00120 edm::LogError("PGeometricDetBuilder")<<"PGeometricDetBuilder Tag already present";
00121 }
00122 }
00123
00124 void PGeometricDetBuilder::putOne ( const GeometricDet* gd, PGeometricDet* pgd, int lev ) {
00125
00126 PGeometricDet::Item item;
00127 DDTranslation tran = gd->translation();
00128 DDRotationMatrix rot = gd->rotation();
00129 DD3Vector x, y, z;
00130 rot.GetComponents(x, y, z);
00131 item._name = gd->name().name();
00132 item._ns = gd->name().ns();
00133 item._level = lev;
00134 item._x = tran.X();
00135 item._y = tran.Y();
00136 item._z = tran.Z();
00137 item._phi = gd->phi();
00138 item._rho = gd->rho();
00139 item._a11 = x.X();
00140 item._a12 = y.X();
00141 item._a13 = z.X();
00142 item._a21 = x.Y();
00143 item._a22 = y.Y();
00144 item._a23 = z.Y();
00145 item._a31 = x.Z();
00146 item._a32 = y.Z();
00147 item._a33 = z.Z();
00148 item._shape = gd->shape();
00149 item._type = gd->type();
00150 if(gd->shape()==1){
00151 item._params0=gd->params()[0];
00152 item._params1=gd->params()[1];
00153 item._params2=gd->params()[2];
00154 item._params3=0;
00155 item._params4=0;
00156 item._params5=0;
00157 item._params6=0;
00158 item._params7=0;
00159 item._params8=0;
00160 item._params9=0;
00161 item._params10=0;
00162 }else if(gd->shape()==3){
00163 item._params0=gd->params()[0];
00164 item._params1=gd->params()[1];
00165 item._params2=gd->params()[2];
00166 item._params3=gd->params()[3];
00167 item._params4=gd->params()[4];
00168 item._params5=gd->params()[5];
00169 item._params6=gd->params()[6];
00170 item._params7=gd->params()[7];
00171 item._params8=gd->params()[8];
00172 item._params9=gd->params()[9];
00173 item._params10=gd->params()[10];
00174 }else{
00175 item._params0=0;
00176 item._params1=0;
00177 item._params2=0;
00178 item._params3=0;
00179 item._params4=0;
00180 item._params5=0;
00181 item._params6=0;
00182 item._params7=0;
00183 item._params8=0;
00184 item._params9=0;
00185 item._params10=0;
00186 }
00187 item._geographicalID = gd->geographicalID();
00188 item._radLength = gd->radLength();
00189 item._xi = gd->xi();
00190 item._pixROCRows = gd->pixROCRows();
00191 item._pixROCCols = gd->pixROCCols();
00192 item._pixROCx = gd->pixROCx();
00193 item._pixROCy = gd->pixROCy();
00194 item._stereo = gd->stereo();
00195 item._siliconAPVNum = gd->siliconAPVNum();
00196
00197 GeometricDet::nav_type const & nt = gd->navType();
00198 size_t nts = nt.size();
00199 item._numnt = nts;
00200 std::vector<int> tempnt(nt.begin(),nt.end());
00201 for ( size_t extrant = nt.size(); extrant < 11; ++extrant ) {
00202 tempnt.push_back(-1);
00203 }
00204 item._nt0 = tempnt[0];
00205 item._nt1 = tempnt[1];
00206 item._nt2 = tempnt[2];
00207 item._nt3 = tempnt[3];
00208 item._nt4 = tempnt[4];
00209 item._nt5 = tempnt[5];
00210 item._nt6 = tempnt[6];
00211 item._nt7 = tempnt[7];
00212 item._nt8 = tempnt[8];
00213 item._nt9 = tempnt[9];
00214 item._nt10 = tempnt[10];
00215
00216 pgd->pgeomdets_.push_back ( item );
00217 }
00218