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