Go to the documentation of this file.00001 #include "TrackerDigiGeometryESModule.h"
00002 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeomBuilderFromGeometricDet.h"
00003 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00004 #include "Geometry/TrackerNumberingBuilder/interface/GeometricDet.h"
00005 #include "Geometry/Records/interface/IdealGeometryRecord.h"
00006 #include "DetectorDescription/Core/interface/DDCompactView.h"
00007
00008
00009 #include "CondFormats/Alignment/interface/Alignments.h"
00010 #include "CondFormats/Alignment/interface/AlignmentErrors.h"
00011 #include "CondFormats/Alignment/interface/AlignmentSurfaceDeformations.h"
00012 #include "CondFormats/Alignment/interface/DetectorGlobalPosition.h"
00013 #include "CondFormats/AlignmentRecord/interface/GlobalPositionRcd.h"
00014 #include "CondFormats/AlignmentRecord/interface/TrackerAlignmentRcd.h"
00015 #include "CondFormats/AlignmentRecord/interface/TrackerAlignmentErrorRcd.h"
00016 #include "CondFormats/AlignmentRecord/interface/TrackerSurfaceDeformationRcd.h"
00017 #include "Geometry/TrackingGeometryAligner/interface/GeometryAligner.h"
00018
00019 #include "FWCore/Framework/interface/EventSetup.h"
00020 #include "FWCore/Framework/interface/ESHandle.h"
00021 #include "FWCore/Framework/interface/ModuleFactory.h"
00022 #include "FWCore/Framework/interface/ESProducer.h"
00023
00024
00025 #include <memory>
00026
00027
00028 TrackerDigiGeometryESModule::TrackerDigiGeometryESModule(const edm::ParameterSet & p)
00029 : alignmentsLabel_(p.getParameter<std::string>("alignmentsLabel")),
00030 myLabel_(p.getParameter<std::string>("appendToDataLabel"))
00031 {
00032
00033 applyAlignment_ = p.getParameter<bool>("applyAlignment");
00034 fromDDD_ = p.getParameter<bool>("fromDDD");
00035
00036 setWhatProduced(this);
00037
00038 edm::LogInfo("Geometry") << "@SUB=TrackerDigiGeometryESModule"
00039 << "Label '" << myLabel_ << "' "
00040 << (applyAlignment_ ? "looking for" : "IGNORING")
00041 << " alignment labels '" << alignmentsLabel_ << "'.";
00042 }
00043
00044
00045 TrackerDigiGeometryESModule::~TrackerDigiGeometryESModule() {}
00046
00047
00048 boost::shared_ptr<TrackerGeometry>
00049 TrackerDigiGeometryESModule::produce(const TrackerDigiGeometryRecord & iRecord)
00050 {
00051
00052
00053
00054 edm::ESHandle<GeometricDet> gD;
00055 iRecord.getRecord<IdealGeometryRecord>().get( gD );
00056
00057 TrackerGeomBuilderFromGeometricDet builder;
00058 _tracker = boost::shared_ptr<TrackerGeometry>(builder.build(&(*gD)));
00059
00060 if (applyAlignment_) {
00061
00062 edm::ESHandle<Alignments> globalPosition;
00063 iRecord.getRecord<GlobalPositionRcd>().get(alignmentsLabel_, globalPosition);
00064 edm::ESHandle<Alignments> alignments;
00065 iRecord.getRecord<TrackerAlignmentRcd>().get(alignmentsLabel_, alignments);
00066 edm::ESHandle<AlignmentErrors> alignmentErrors;
00067 iRecord.getRecord<TrackerAlignmentErrorRcd>().get(alignmentsLabel_, alignmentErrors);
00068
00069 if (alignments->empty() && alignmentErrors->empty() && globalPosition->empty()) {
00070 edm::LogInfo("Config") << "@SUB=TrackerDigiGeometryRecord::produce"
00071 << "Alignment(Error)s and global position (label '"
00072 << alignmentsLabel_ << "') empty: Geometry producer (label "
00073 << "'" << myLabel_ << "') assumes fake and does not apply.";
00074 } else {
00075 GeometryAligner ali;
00076 ali.applyAlignments<TrackerGeometry>(&(*_tracker), &(*alignments), &(*alignmentErrors),
00077 align::DetectorGlobalPosition(*globalPosition,
00078 DetId(DetId::Tracker)));
00079 }
00080
00081 edm::ESHandle<AlignmentSurfaceDeformations> surfaceDeformations;
00082 iRecord.getRecord<TrackerSurfaceDeformationRcd>().get(alignmentsLabel_, surfaceDeformations);
00083
00084 if (surfaceDeformations->empty()) {
00085 edm::LogInfo("Config") << "@SUB=TrackerDigiGeometryRecord::produce"
00086 << "AlignmentSurfaceDeformations (label '"
00087 << alignmentsLabel_ << "') empty: Geometry producer (label "
00088 << "'" << myLabel_ << "') assumes fake and does not apply.";
00089 } else {
00090 GeometryAligner ali;
00091 ali.attachSurfaceDeformations<TrackerGeometry>(&(*_tracker), &(*surfaceDeformations));
00092 }
00093 }
00094
00095 return _tracker;
00096 }
00097
00098
00099
00100
00101 DEFINE_FWK_EVENTSETUP_MODULE(TrackerDigiGeometryESModule);