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