CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/CondTools/Geometry/plugins/PGeometricDetExtraBuilder.cc

Go to the documentation of this file.
00001 #include "PGeometricDetExtraBuilder.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/PGeometricDetExtra.h"
00011 #include "Geometry/Records/interface/PGeometricDetExtraRcd.h"
00012 #include "Geometry/TrackerNumberingBuilder/interface/GeometricDetExtra.h"
00013 #include <DetectorDescription/Core/interface/DDCompactView.h>
00014 #include <DetectorDescription/Core/interface/DDExpandedView.h>
00015 #include "DetectorDescription/Core/interface/DDExpandedNode.h"
00016 
00017 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00018 
00019 #include "Geometry/TrackerGeometryBuilder/interface/GeomDetTypeIdToEnum.h"
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 PGeometricDetExtraBuilder::PGeometricDetExtraBuilder(const edm::ParameterSet& iConfig)
00029 {
00030 }
00031 
00032 PGeometricDetExtraBuilder::~PGeometricDetExtraBuilder()
00033 {
00034 }
00035 
00036 void
00037 PGeometricDetExtraBuilder::beginRun( const edm::Run&, edm::EventSetup const& es) 
00038 {
00039   PGeometricDetExtra* pgde = new PGeometricDetExtra;
00040   edm::Service<cond::service::PoolDBOutputService> mydbservice;
00041   if( !mydbservice.isAvailable() ){
00042     edm::LogError("PGeometricDetExtraBuilder")<<"PoolDBOutputService unavailable";
00043     return;
00044   }
00045   edm::ESTransientHandle<DDCompactView> cpvH;
00046   edm::ESHandle<std::vector<GeometricDetExtra> > gdeH;
00047   es.get<IdealGeometryRecord>().get( cpvH );
00048   es.get<IdealGeometryRecord>().get( gdeH );
00049   const std::vector<GeometricDetExtra>& gdes = (*gdeH);
00050 
00051   std::vector<GeometricDetExtra>::const_iterator git = gdes.begin();
00052   std::vector<GeometricDetExtra>::const_iterator egit = gdes.end();
00053 
00054   for (; git!= egit; ++git) {  // one level below "tracker"
00055     putOne(*git, pgde);
00056   }
00057   if ( mydbservice->isNewTagRequest("PGeometricDetExtraRcd") ) {
00058     mydbservice->createNewIOV<PGeometricDetExtra>( pgde,mydbservice->beginOfTime(),mydbservice->endOfTime(),"PGeometricDetExtraRcd");
00059   } else {
00060     edm::LogError("PGeometricDetExtraBuilder")<<"PGeometricDetExtra and PGeometricDetExtraRcd Tag already present";
00061   }
00062 }
00063   
00064 void PGeometricDetExtraBuilder::putOne ( const GeometricDetExtra& gde, PGeometricDetExtra* pgde ) {
00065   PGeometricDetExtra::Item item;
00066   item._geographicalId = gde.geographicalId();
00067   item._volume         = gde.volume();
00068   item._density        = gde.density();
00069   item._weight         = gde.weight();
00070   item._copy           = gde.copyno();
00071   item._material       = gde.material();
00072   pgde->pgdes_.push_back ( item );
00073 }
00074