CMS 3D CMS Logo

TrackerSystematicMisalignments.cc
Go to the documentation of this file.
7 
10 
17 
21 
26 #include "CLHEP/Random/RandGauss.h"
27 
29 
30 #include "DataFormats/SiStripDetId/interface/SiStripDetId.h" // for enums TID/TIB/etc.
31 
32 // Database
35 
36 // -----------------------------------------------------------------
37 // 2010-05-20 Frank Meier
38 // Changed sign of z-correction, i.e. z-expansion is now an expansion
39 // made some variables constant, removed obviously dead code and comments
40 
42  : geomDetToken_(esConsumes()),
43  ptpToken_(esConsumes()),
44  ptitpToken_(esConsumes()),
45  topoToken_(esConsumes()),
46  aliToken_(esConsumes()),
47  aliErrorToken_(esConsumes()),
48  gprToken_(esConsumes()),
49  theAlignableTracker(nullptr) {
50  // use existing geometry
51  m_fromDBGeom = cfg.getUntrackedParameter<bool>("fromDBGeom");
52 
53  // constants
54  m_radialEpsilon = cfg.getUntrackedParameter<double>("radialEpsilon");
55  m_telescopeEpsilon = cfg.getUntrackedParameter<double>("telescopeEpsilon");
56  m_layerRotEpsilon = cfg.getUntrackedParameter<double>("layerRotEpsilon");
57  m_bowingEpsilon = cfg.getUntrackedParameter<double>("bowingEpsilon");
58  m_zExpEpsilon = cfg.getUntrackedParameter<double>("zExpEpsilon");
59  m_twistEpsilon = cfg.getUntrackedParameter<double>("twistEpsilon");
60  m_ellipticalEpsilon = cfg.getUntrackedParameter<double>("ellipticalEpsilon");
61  m_skewEpsilon = cfg.getUntrackedParameter<double>("skewEpsilon");
62  m_sagittaEpsilon = cfg.getUntrackedParameter<double>("sagittaEpsilon");
63 
64  m_ellipticalDelta = cfg.getUntrackedParameter<double>("ellipticalDelta");
65  m_skewDelta = cfg.getUntrackedParameter<double>("skewDelta");
66  m_sagittaDelta = cfg.getUntrackedParameter<double>("sagittaDelta");
67 
68  if (m_radialEpsilon > -990.0) {
69  edm::LogWarning("MisalignedTracker") << "Applying radial ...";
70  }
71  if (m_telescopeEpsilon > -990.0) {
72  edm::LogWarning("MisalignedTracker") << "Applying telescope ...";
73  }
74  if (m_layerRotEpsilon > -990.0) {
75  edm::LogWarning("MisalignedTracker") << "Applying layer rotation ...";
76  }
77  if (m_bowingEpsilon > -990.0) {
78  edm::LogWarning("MisalignedTracker") << "Applying bowing ...";
79  }
80  if (m_zExpEpsilon > -990.0) {
81  edm::LogWarning("MisalignedTracker") << "Applying z-expansion ...";
82  }
83  if (m_twistEpsilon > -990.0) {
84  edm::LogWarning("MisalignedTracker") << "Applying twist ...";
85  }
86  if (m_ellipticalEpsilon > -990.0) {
87  edm::LogWarning("MisalignedTracker") << "Applying elliptical ...";
88  }
89  if (m_skewEpsilon > -990.0) {
90  edm::LogWarning("MisalignedTracker") << "Applying skew ...";
91  }
92  if (m_sagittaEpsilon > -990.0) {
93  edm::LogWarning("MisalignedTracker") << "Applying sagitta ...";
94  }
95 
96  // get flag for suppression of blind movements
97  suppressBlindMvmts = cfg.getUntrackedParameter<bool>("suppressBlindMvmts");
98  if (suppressBlindMvmts) {
99  edm::LogWarning("MisalignedTracker") << "Blind movements suppressed (TIB/TOB in z, TID/TEC in r)";
100  }
101 
102  // compatibility with old (weird) z convention
103  oldMinusZconvention = cfg.getUntrackedParameter<bool>("oldMinusZconvention");
104  if (oldMinusZconvention) {
105  edm::LogWarning("MisalignedTracker") << "Old z convention: dz --> -dz";
106  } else {
107  edm::LogWarning("MisalignedTracker") << "New z convention: dz --> dz";
108  }
109 }
110 
112 
114  //Retrieve tracker topology from geometry
115  const GeometricDet* geom = &setup.getData(geomDetToken_);
116  const PTrackerParameters& ptp = setup.getData(ptpToken_);
117  const PTrackerAdditionalParametersPerDet* ptitp = &setup.getData(ptitpToken_);
118  const TrackerTopology* tTopo = &setup.getData(topoToken_);
119 
121 
122  //take geometry from DB or randomly generate geometry
123  if (m_fromDBGeom) {
124  //build the tracker
125  const Alignments* alignments = &setup.getData(aliToken_);
126  const AlignmentErrorsExtended* alignmentErrors = &setup.getData(aliErrorToken_);
127  const Alignments* globalPositionRcd = &setup.getData(gprToken_);
128 
129  //apply the latest alignments
130  GeometryAligner aligner;
131  aligner.applyAlignments<TrackerGeometry>(&(*tracker),
132  &(*alignments),
133  &(*alignmentErrors),
134  align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Tracker)));
135  }
136 
137  theAlignableTracker = new AlignableTracker(&(*tracker), tTopo);
138 
140 
141  // -------------- writing out to alignment record --------------
142  Alignments* myAlignments = theAlignableTracker->alignments();
143  AlignmentErrorsExtended* myAlignmentErrorsExtended = theAlignableTracker->alignmentErrors();
144 
145  // Store alignment[Error]s to DB
147  std::string theAlignRecordName = "TrackerAlignmentRcd";
148  std::string theErrorRecordName = "TrackerAlignmentErrorExtendedRcd";
149 
150  // Call service
151  if (!poolDbService.isAvailable()) // Die if not available
152  throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
153 
154  poolDbService->writeOne<Alignments>(&(*myAlignments), poolDbService->beginOfTime(), theAlignRecordName);
155  poolDbService->writeOne<AlignmentErrorsExtended>(
156  &(*myAlignmentErrorsExtended), poolDbService->beginOfTime(), theErrorRecordName);
157 }
158 
160  const align::Alignables& comp = ali->components();
161  unsigned int nComp = comp.size();
162  //move then do for lower level object
163  //for issue of det vs detunit
164  bool usecomps = true;
165  if ((ali->alignableObjectId() == 2) && (nComp >= 1))
166  usecomps = false;
167  for (unsigned int i = 0; i < nComp; ++i) {
168  if (usecomps)
170  }
171 
172  // if suppression of blind mvmts: check if subdet is blind to a certain mode
173  bool blindToZ(false), blindToR(false);
174  if (suppressBlindMvmts) {
175  const int subdetid = ali->geomDetId().subdetId();
176  switch (subdetid) {
177  // TIB/TON blind to z
178  case SiStripDetId::TIB:
179  case SiStripDetId::TOB:
180  blindToZ = true;
181  break;
182  // TID/TEC blind to R
183  case SiStripDetId::TID:
184  case SiStripDetId::TEC:
185  blindToR = true;
186  break;
187  default:
188  break;
189  }
190  }
191 
192  const int level = ali->alignableObjectId();
193  if ((level == 1) || (level == 2)) {
194  const align::PositionType gP = ali->globalPosition();
195  const align::GlobalVector gVec = findSystematicMis(gP, blindToZ, blindToR);
196  ali->move(gVec);
197  }
198 }
199 
201  const bool blindToZ,
202  const bool blindToR) {
203  //align::GlobalVector TrackerSystematicMisalignments::findSystematicMis( align::PositionType globalPos ){
204  // calculates shift for the current alignable
205  // all corrections are calculated w.r.t. the original geometry
206  double deltaX = 0.0;
207  double deltaY = 0.0;
208  double deltaZ = 0.0;
209  const double oldX = globalPos.x();
210  const double oldY = globalPos.y();
211  const double oldZ = globalPos.z();
212  const double oldPhi = globalPos.phi();
213  const double oldR = sqrt(globalPos.x() * globalPos.x() + globalPos.y() * globalPos.y());
214 
215  if (m_radialEpsilon > -990.0 && !blindToR) {
216  deltaX += m_radialEpsilon * oldX;
217  deltaY += m_radialEpsilon * oldY;
218  }
219  if (m_telescopeEpsilon > -990.0 && !blindToZ) {
220  deltaZ += m_telescopeEpsilon * oldR;
221  }
222  if (m_layerRotEpsilon > -990.0) {
223  // The following number was chosen such that the Layer Rotation systematic
224  // misalignment would not cause an overall rotation of the tracker.
225  const double Roffset = 57.0;
226  const double xP = oldR * cos(oldPhi + m_layerRotEpsilon * (oldR - Roffset));
227  const double yP = oldR * sin(oldPhi + m_layerRotEpsilon * (oldR - Roffset));
228  deltaX += (xP - oldX);
229  deltaY += (yP - oldY);
230  }
231  if (m_bowingEpsilon > -990.0 && !blindToR) {
232  const double trackeredgePlusZ = 271.846;
233  const double bowfactor = m_bowingEpsilon * (trackeredgePlusZ * trackeredgePlusZ - oldZ * oldZ);
234  deltaX += oldX * bowfactor;
235  deltaY += oldY * bowfactor;
236  }
237  if (m_zExpEpsilon > -990.0 && !blindToZ) {
238  deltaZ += oldZ * m_zExpEpsilon;
239  }
240  if (m_twistEpsilon > -990.0) {
241  const double xP = oldR * cos(oldPhi + m_twistEpsilon * oldZ);
242  const double yP = oldR * sin(oldPhi + m_twistEpsilon * oldZ);
243  deltaX += (xP - oldX);
244  deltaY += (yP - oldY);
245  }
246  if (m_ellipticalEpsilon > -990.0 && !blindToR) {
247  deltaX += oldX * m_ellipticalEpsilon * cos(2.0 * oldPhi + m_ellipticalDelta);
248  deltaY += oldY * m_ellipticalEpsilon * cos(2.0 * oldPhi + m_ellipticalDelta);
249  }
250  if (m_skewEpsilon > -990.0 && !blindToZ) {
251  deltaZ += m_skewEpsilon * cos(oldPhi + m_skewDelta);
252  }
253  if (m_sagittaEpsilon > -990.0) {
254  // deltaX += oldX/fabs(oldX)*m_sagittaEpsilon; // old one...
255  deltaX += oldR * m_sagittaEpsilon * sin(m_sagittaDelta);
256  deltaY += oldR * m_sagittaEpsilon * cos(m_sagittaDelta); //Delta y is cos so that delta=0 reflects the old behavior
257  }
258 
259  // Compatibility with old version <= 1.5
261  deltaZ = -deltaZ;
262 
263  align::GlobalVector gV(deltaX, deltaY, deltaZ);
264  return gV;
265 }
266 
267 // Plug in to framework
268 
270 
Vector3DBase< Scalar, GlobalTag >
personalPlayback.level
level
Definition: personalPlayback.py:22
AlignmentErrorsExtended.h
TrackerSystematicMisalignments::findSystematicMis
align::GlobalVector findSystematicMis(const align::PositionType &, const bool blindToZ, const bool blindToR)
Definition: TrackerSystematicMisalignments.cc:200
GlobalPositionRcd.h
AlCaHLTBitMon_QueryRunRegistry.comp
string comp
Definition: AlCaHLTBitMon_QueryRunRegistry.py:249
mps_fire.i
i
Definition: mps_fire.py:428
TrackerSystematicMisalignments::m_telescopeEpsilon
double m_telescopeEpsilon
Definition: TrackerSystematicMisalignments.h:53
MessageLogger.h
TrackerGeometry.h
TrackerSystematicMisalignments.h
cond::service::PoolDBOutputService::beginOfTime
cond::Time_t beginOfTime() const
Definition: PoolDBOutputService.cc:215
PTrackerParameters
Definition: PTrackerParameters.h:6
ESHandle.h
TrackerSystematicMisalignments::m_ellipticalEpsilon
double m_ellipticalEpsilon
Definition: TrackerSystematicMisalignments.h:58
TrackerSystematicMisalignments::m_zExpEpsilon
double m_zExpEpsilon
Definition: TrackerSystematicMisalignments.h:56
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
TrackerSystematicMisalignments::ptitpToken_
const edm::ESGetToken< PTrackerAdditionalParametersPerDet, PTrackerAdditionalParametersPerDetRcd > ptitpToken_
Definition: TrackerSystematicMisalignments.h:42
TrackerGeomBuilderFromGeometricDet::build
TrackerGeometry * build(const GeometricDet *gd, const PTrackerAdditionalParametersPerDet *ptitp, const PTrackerParameters &ptp, const TrackerTopology *tTopo)
Definition: TrackerGeomBuilderFromGeometricDet.cc:44
TrackerSystematicMisalignments::oldMinusZconvention
bool oldMinusZconvention
Definition: TrackerSystematicMisalignments.h:71
TrackerTopology
Definition: TrackerTopology.h:16
Alignable
Definition: Alignable.h:27
TrackerSystematicMisalignments::m_skewDelta
double m_skewDelta
Definition: TrackerSystematicMisalignments.h:64
PTrackerAdditionalParametersPerDet
Definition: PTrackerAdditionalParametersPerDet.h:9
TrackerSystematicMisalignments::m_sagittaDelta
double m_sagittaDelta
Definition: TrackerSystematicMisalignments.h:65
Alignments.h
TrackerSystematicMisalignments::m_fromDBGeom
bool m_fromDBGeom
Definition: TrackerSystematicMisalignments.h:50
DetectorGlobalPosition.h
SiStripDetId.h
PTrackerParameters.h
TrackerSystematicMisalignments::beginJob
void beginJob() override
Read ideal tracker geometry from DB.
Definition: TrackerSystematicMisalignments.cc:111
TrackerSystematicMisalignments::m_radialEpsilon
double m_radialEpsilon
Definition: TrackerSystematicMisalignments.h:52
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
GeometryAligner::applyAlignments
void applyAlignments(const C *geometry, const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates)
Definition: GeometryAligner.h:52
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
TrackerAlignmentErrorExtendedRcd.h
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
DetId
Definition: DetId.h:17
TrackerSystematicMisalignments::suppressBlindMvmts
bool suppressBlindMvmts
Definition: TrackerSystematicMisalignments.h:68
MakerMacros.h
PoolDBOutputService.h
TrackerSystematicMisalignments::ptpToken_
const edm::ESGetToken< PTrackerParameters, PTrackerParametersRcd > ptpToken_
Definition: TrackerSystematicMisalignments.h:41
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
TrackerTopologyRcd.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
AlignableTracker::alignmentErrors
AlignmentErrorsExtended * alignmentErrors() const override
Return alignment errors, sorted by DetId.
Definition: AlignableTracker.cc:59
TrackerSystematicMisalignments::geomDetToken_
const edm::ESGetToken< GeometricDet, IdealGeometryRecord > geomDetToken_
Definition: TrackerSystematicMisalignments.h:40
Alignable::alignableObjectId
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
TrackerSystematicMisalignments::gprToken_
const edm::ESGetToken< Alignments, GlobalPositionRcd > gprToken_
Definition: TrackerSystematicMisalignments.h:46
Service.h
TrackerSystematicMisalignments::m_skewEpsilon
double m_skewEpsilon
Definition: TrackerSystematicMisalignments.h:59
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
AlignableTracker
Definition: AlignableTracker.h:17
TrackerSystematicMisalignments::m_sagittaEpsilon
double m_sagittaEpsilon
Definition: TrackerSystematicMisalignments.h:60
GeometricDet
Definition: GeometricDet.h:31
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
Point3DBase< Scalar, GlobalTag >
SiStripDetId::TEC
static constexpr auto TEC
Definition: SiStripDetId.h:40
DetId::subdetId
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum)
Definition: DetId.h:48
PbPb_ZMuSkimMuonDPG_cff.tracker
tracker
Definition: PbPb_ZMuSkimMuonDPG_cff.py:60
TrackerSystematicMisalignments::m_bowingEpsilon
double m_bowingEpsilon
Definition: TrackerSystematicMisalignments.h:55
TrackerDigiGeometryRecord.h
edm::ParameterSet
Definition: ParameterSet.h:47
DetId::Tracker
Definition: DetId.h:25
align::DetectorGlobalPosition
const AlignTransform & DetectorGlobalPosition(const Alignments &allGlobals, const DetId &id)
Definition: DetectorGlobalPosition.cc:10
PTrackerParametersRcd.h
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
edm::Service< cond::service::PoolDBOutputService >
TrackerSystematicMisalignments::applySystematicMisalignment
void applySystematicMisalignment(Alignable *)
Definition: TrackerSystematicMisalignments.cc:159
Alignable::geomDetId
const DetId & geomDetId() const
Definition: Alignable.h:177
TrackerSystematicMisalignments::aliToken_
const edm::ESGetToken< Alignments, TrackerAlignmentRcd > aliToken_
Definition: TrackerSystematicMisalignments.h:44
SiStripDetId::TOB
static constexpr auto TOB
Definition: SiStripDetId.h:39
IdealGeometryRecord.h
TrackerAlignmentRcd.h
edm::EventSetup
Definition: EventSetup.h:58
AlignmentErrorsExtended
Definition: AlignmentErrorsExtended.h:10
TrackerSystematicMisalignments::topoToken_
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoToken_
Definition: TrackerSystematicMisalignments.h:43
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
Alignable::move
virtual void move(const GlobalVector &displacement)=0
Movement with respect to the global reference frame.
looper.cfg
cfg
Definition: looper.py:296
TrackerSystematicMisalignments
Definition: TrackerSystematicMisalignments.h:26
SiStripDetId::TID
static constexpr auto TID
Definition: SiStripDetId.h:38
TrackerSystematicMisalignments::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: TrackerSystematicMisalignments.cc:113
align::Alignables
std::vector< Alignable * > Alignables
Definition: Utilities.h:31
TrackerSystematicMisalignments::m_ellipticalDelta
double m_ellipticalDelta
Definition: TrackerSystematicMisalignments.h:63
TrackerSystematicMisalignments::theAlignableTracker
AlignableTracker * theAlignableTracker
Definition: TrackerSystematicMisalignments.h:47
AlignableTracker::alignments
Alignments * alignments() const override
Return alignments, sorted by DetId.
Definition: AlignableTracker.cc:42
L1TkHTMissProducer_cfi.deltaZ
deltaZ
Definition: L1TkHTMissProducer_cfi.py:13
GeometryAligner.h
DetId.h
cond::service::PoolDBOutputService::writeOne
Hash writeOne(const T *payload, Time_t time, const std::string &recordName)
Definition: PoolDBOutputService.h:63
SiStripDetId::TIB
static constexpr auto TIB
Definition: SiStripDetId.h:37
EventSetup.h
TrackerSystematicMisalignments::aliErrorToken_
const edm::ESGetToken< AlignmentErrorsExtended, TrackerAlignmentErrorExtendedRcd > aliErrorToken_
Definition: TrackerSystematicMisalignments.h:45
TrackerGeomBuilderFromGeometricDet.h
TrackerGeomBuilderFromGeometricDet
Definition: TrackerGeomBuilderFromGeometricDet.h:18
AlignableTracker.h
cms::Exception
Definition: Exception.h:70
ParameterSet.h
SurveyDet.h
Alignable::globalPosition
const PositionType & globalPosition() const
Return the global position of the object.
Definition: Alignable.h:135
event
Definition: event.py:1
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::Event
Definition: Event.h:73
Alignable::components
virtual const Alignables & components() const =0
Return vector of all direct components.
TrackerSystematicMisalignments::m_twistEpsilon
double m_twistEpsilon
Definition: TrackerSystematicMisalignments.h:57
TrackerSystematicMisalignments::m_layerRotEpsilon
double m_layerRotEpsilon
Definition: TrackerSystematicMisalignments.h:54
Alignments
Definition: Alignments.h:10
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
GeometryAligner
Class to update a given geometry with a set of alignments.
Definition: GeometryAligner.h:33
TrackerSystematicMisalignments::TrackerSystematicMisalignments
TrackerSystematicMisalignments(const edm::ParameterSet &)
Definition: TrackerSystematicMisalignments.cc:41
TrackerGeometry
Definition: TrackerGeometry.h:14