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 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
00024 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
00025
00026 #include <memory>
00027
00028
00029 TrackerDigiGeometryESModule::TrackerDigiGeometryESModule(const edm::ParameterSet & p)
00030 : alignmentsLabel_(p.getParameter<std::string>("alignmentsLabel")),
00031 myLabel_(p.getParameter<std::string>("appendToDataLabel")),
00032 m_pSet( p )
00033 {
00034 applyAlignment_ = p.getParameter<bool>("applyAlignment");
00035 fromDDD_ = p.getParameter<bool>("fromDDD");
00036
00037 setWhatProduced(this);
00038
00039 edm::LogInfo("Geometry") << "@SUB=TrackerDigiGeometryESModule"
00040 << "Label '" << myLabel_ << "' "
00041 << (applyAlignment_ ? "looking for" : "IGNORING")
00042 << " alignment labels '" << alignmentsLabel_ << "'.";
00043 }
00044
00045
00046 TrackerDigiGeometryESModule::~TrackerDigiGeometryESModule() {}
00047
00048 void
00049 TrackerDigiGeometryESModule::fillDescriptions(edm::ConfigurationDescriptions & descriptions)
00050 {
00051 edm::ParameterSetDescription descTrackerGeometryConstants;
00052 descTrackerGeometryConstants.add<bool>( "upgradeGeometry", false );
00053 descTrackerGeometryConstants.add<int>( "ROWS_PER_ROC", 80 );
00054 descTrackerGeometryConstants.add<int>( "COLS_PER_ROC", 52 );
00055 descTrackerGeometryConstants.add<int>( "BIG_PIX_PER_ROC_X", 1 );
00056 descTrackerGeometryConstants.add<int>( "BIG_PIX_PER_ROC_Y", 2 );
00057 descTrackerGeometryConstants.add<int>( "ROCS_X", 0 );
00058 descTrackerGeometryConstants.add<int>( "ROCS_Y", 0 );
00059
00060 edm::ParameterSetDescription descTrackerSLHCGeometryConstants;
00061 descTrackerSLHCGeometryConstants.add<bool>( "upgradeGeometry", true );
00062 descTrackerSLHCGeometryConstants.add<int>( "ROWS_PER_ROC", 80 );
00063 descTrackerSLHCGeometryConstants.add<int>( "COLS_PER_ROC", 52 );
00064 descTrackerSLHCGeometryConstants.add<int>( "BIG_PIX_PER_ROC_X", 0 );
00065 descTrackerSLHCGeometryConstants.add<int>( "BIG_PIX_PER_ROC_Y", 0 );
00066 descTrackerSLHCGeometryConstants.add<int>( "ROCS_X", 2 );
00067 descTrackerSLHCGeometryConstants.add<int>( "ROCS_Y", 8 );
00068
00069 edm::ParameterSetDescription descDB;
00070 descDB.add<std::string>( "appendToDataLabel", "" );
00071 descDB.add<bool>( "fromDDD", false );
00072 descDB.add<bool>( "applyAlignment", true );
00073 descDB.add<std::string>( "alignmentsLabel", "" );
00074 descDB.addOptional<edm::ParameterSetDescription>( "trackerGeometryConstants", descTrackerGeometryConstants );
00075 descriptions.add( "trackerGeometryDB", descDB );
00076
00077 edm::ParameterSetDescription desc;
00078 desc.add<std::string>( "appendToDataLabel", "" );
00079 desc.add<bool>( "fromDDD", true );
00080 desc.add<bool>( "applyAlignment", true );
00081 desc.add<std::string>( "alignmentsLabel", "" );
00082 desc.addOptional<edm::ParameterSetDescription>( "trackerGeometryConstants", descTrackerGeometryConstants );
00083 descriptions.add( "trackerGeometry", desc );
00084
00085 edm::ParameterSetDescription descSLHCDB;
00086 descSLHCDB.add<std::string>( "appendToDataLabel", "" );
00087 descSLHCDB.add<bool>( "fromDDD", false );
00088 descSLHCDB.add<bool>( "applyAlignment", true );
00089 descSLHCDB.add<std::string>( "alignmentsLabel", "" );
00090 descSLHCDB.addOptional<edm::ParameterSetDescription>( "trackerGeometryConstants", descTrackerSLHCGeometryConstants );
00091 descriptions.add( "trackerSLHCGeometryDB", descSLHCDB );
00092
00093 edm::ParameterSetDescription descSLHC;
00094 descSLHC.add<std::string>( "appendToDataLabel", "" );
00095 descSLHC.add<bool>( "fromDDD", true );
00096 descSLHC.add<bool>( "applyAlignment", true );
00097 descSLHC.add<std::string>( "alignmentsLabel", "" );
00098 descSLHC.addOptional<edm::ParameterSetDescription>( "trackerGeometryConstants", descTrackerSLHCGeometryConstants );
00099 descriptions.add( "trackerSLHCGeometry", descSLHC );
00100 }
00101
00102
00103 boost::shared_ptr<TrackerGeometry>
00104 TrackerDigiGeometryESModule::produce(const TrackerDigiGeometryRecord & iRecord)
00105 {
00106
00107
00108
00109 edm::ESHandle<GeometricDet> gD;
00110 iRecord.getRecord<IdealGeometryRecord>().get( gD );
00111
00112 TrackerGeomBuilderFromGeometricDet builder;
00113 _tracker = boost::shared_ptr<TrackerGeometry>(builder.build(&(*gD), m_pSet ));
00114
00115 if (applyAlignment_) {
00116
00117 edm::ESHandle<Alignments> globalPosition;
00118 iRecord.getRecord<GlobalPositionRcd>().get(alignmentsLabel_, globalPosition);
00119 edm::ESHandle<Alignments> alignments;
00120 iRecord.getRecord<TrackerAlignmentRcd>().get(alignmentsLabel_, alignments);
00121 edm::ESHandle<AlignmentErrors> alignmentErrors;
00122 iRecord.getRecord<TrackerAlignmentErrorRcd>().get(alignmentsLabel_, alignmentErrors);
00123
00124 if (alignments->empty() && alignmentErrors->empty() && globalPosition->empty()) {
00125 edm::LogInfo("Config") << "@SUB=TrackerDigiGeometryRecord::produce"
00126 << "Alignment(Error)s and global position (label '"
00127 << alignmentsLabel_ << "') empty: Geometry producer (label "
00128 << "'" << myLabel_ << "') assumes fake and does not apply.";
00129 } else {
00130 GeometryAligner ali;
00131 ali.applyAlignments<TrackerGeometry>(&(*_tracker), &(*alignments), &(*alignmentErrors),
00132 align::DetectorGlobalPosition(*globalPosition,
00133 DetId(DetId::Tracker)));
00134 }
00135
00136 edm::ESHandle<AlignmentSurfaceDeformations> surfaceDeformations;
00137 iRecord.getRecord<TrackerSurfaceDeformationRcd>().get(alignmentsLabel_, surfaceDeformations);
00138
00139 if (surfaceDeformations->empty()) {
00140 edm::LogInfo("Config") << "@SUB=TrackerDigiGeometryRecord::produce"
00141 << "AlignmentSurfaceDeformations (label '"
00142 << alignmentsLabel_ << "') empty: Geometry producer (label "
00143 << "'" << myLabel_ << "') assumes fake and does not apply.";
00144 } else {
00145 GeometryAligner ali;
00146 ali.attachSurfaceDeformations<TrackerGeometry>(&(*_tracker), &(*surfaceDeformations));
00147 }
00148 }
00149
00150 return _tracker;
00151 }
00152
00153 DEFINE_FWK_EVENTSETUP_MODULE(TrackerDigiGeometryESModule);