1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
|
/** \class TrackerSystematicMisalignments
*
* Class to misaligned tracker from DB.
*
* $Date: 2012/06/13 09:24:50 $
* $Revision: 1.5 $
* \author Chung Khim Lae
*/
// user include files
#include "Alignment/CommonAlignment/interface/Alignable.h"
#include "Alignment/CommonAlignment/interface/SurveyDet.h"
#include "Alignment/TrackerAlignment/interface/AlignableTracker.h"
#include "CLHEP/Random/RandGauss.h"
#include "CondFormats/Alignment/interface/AlignmentErrorsExtended.h"
#include "CondFormats/Alignment/interface/Alignments.h"
#include "CondFormats/Alignment/interface/DetectorGlobalPosition.h"
#include "CondFormats/AlignmentRecord/interface/GlobalPositionRcd.h"
#include "CondFormats/AlignmentRecord/interface/TrackerAlignmentErrorExtendedRcd.h"
#include "CondFormats/AlignmentRecord/interface/TrackerAlignmentRcd.h"
#include "CondFormats/GeometryObjects/interface/PTrackerParameters.h"
#include "DataFormats/DetId/interface/DetId.h"
#include "DataFormats/SiStripDetId/interface/SiStripDetId.h" // for enums TID/TIB/etc.
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "Geometry/GeometryAligner/interface/GeometryAligner.h"
#include "Geometry/Records/interface/IdealGeometryRecord.h"
#include "Geometry/Records/interface/PTrackerParametersRcd.h"
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
#include "Geometry/Records/interface/TrackerTopologyRcd.h"
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeomBuilderFromGeometricDet.h"
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
// Database
#include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
class AlignableSurface;
class Alignments;
namespace edm {
class ParameterSet;
}
class TrackerSystematicMisalignments : public edm::one::EDAnalyzer<> {
public:
TrackerSystematicMisalignments(const edm::ParameterSet&);
/// Read ideal tracker geometry from DB
void beginJob() override;
void analyze(const edm::Event&, const edm::EventSetup&) override;
private:
void applySystematicMisalignment(Alignable*);
//align::GlobalVector findSystematicMis( align::PositionType );
align::GlobalVector findSystematicMis(const align::PositionType&, const bool blindToZ, const bool blindToR);
const edm::ESGetToken<GeometricDet, IdealGeometryRecord> geomDetToken_;
const edm::ESGetToken<PTrackerParameters, PTrackerParametersRcd> ptpToken_;
const edm::ESGetToken<PTrackerAdditionalParametersPerDet, PTrackerAdditionalParametersPerDetRcd> ptitpToken_;
const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> topoToken_;
const edm::ESGetToken<Alignments, TrackerAlignmentRcd> aliToken_;
const edm::ESGetToken<AlignmentErrorsExtended, TrackerAlignmentErrorExtendedRcd> aliErrorToken_;
const edm::ESGetToken<Alignments, GlobalPositionRcd> gprToken_;
AlignableTracker* theAlignableTracker;
// configurables needed for the systematic misalignment
bool m_fromDBGeom;
double m_radialEpsilon;
double m_telescopeEpsilon;
double m_layerRotEpsilon;
double m_bowingEpsilon;
double m_zExpEpsilon;
double m_twistEpsilon;
double m_ellipticalEpsilon;
double m_skewEpsilon;
double m_sagittaEpsilon;
//misalignment phases
double m_ellipticalDelta;
double m_skewDelta;
double m_sagittaDelta;
// flag to steer suppression of blind movements
bool suppressBlindMvmts;
// flag for old z behaviour, version <= 1.5
bool oldMinusZconvention;
};
// -----------------------------------------------------------------
// 2010-05-20 Frank Meier
// Changed sign of z-correction, i.e. z-expansion is now an expansion
// made some variables constant, removed obviously dead code and comments
TrackerSystematicMisalignments::TrackerSystematicMisalignments(const edm::ParameterSet& cfg)
: geomDetToken_(esConsumes()),
ptpToken_(esConsumes()),
ptitpToken_(esConsumes()),
topoToken_(esConsumes()),
aliToken_(esConsumes()),
aliErrorToken_(esConsumes()),
gprToken_(esConsumes()),
theAlignableTracker(nullptr) {
// use existing geometry
m_fromDBGeom = cfg.getUntrackedParameter<bool>("fromDBGeom");
// constants
m_radialEpsilon = cfg.getUntrackedParameter<double>("radialEpsilon");
m_telescopeEpsilon = cfg.getUntrackedParameter<double>("telescopeEpsilon");
m_layerRotEpsilon = cfg.getUntrackedParameter<double>("layerRotEpsilon");
m_bowingEpsilon = cfg.getUntrackedParameter<double>("bowingEpsilon");
m_zExpEpsilon = cfg.getUntrackedParameter<double>("zExpEpsilon");
m_twistEpsilon = cfg.getUntrackedParameter<double>("twistEpsilon");
m_ellipticalEpsilon = cfg.getUntrackedParameter<double>("ellipticalEpsilon");
m_skewEpsilon = cfg.getUntrackedParameter<double>("skewEpsilon");
m_sagittaEpsilon = cfg.getUntrackedParameter<double>("sagittaEpsilon");
m_ellipticalDelta = cfg.getUntrackedParameter<double>("ellipticalDelta");
m_skewDelta = cfg.getUntrackedParameter<double>("skewDelta");
m_sagittaDelta = cfg.getUntrackedParameter<double>("sagittaDelta");
if (m_radialEpsilon > -990.0) {
edm::LogWarning("MisalignedTracker") << "Applying radial ...";
}
if (m_telescopeEpsilon > -990.0) {
edm::LogWarning("MisalignedTracker") << "Applying telescope ...";
}
if (m_layerRotEpsilon > -990.0) {
edm::LogWarning("MisalignedTracker") << "Applying layer rotation ...";
}
if (m_bowingEpsilon > -990.0) {
edm::LogWarning("MisalignedTracker") << "Applying bowing ...";
}
if (m_zExpEpsilon > -990.0) {
edm::LogWarning("MisalignedTracker") << "Applying z-expansion ...";
}
if (m_twistEpsilon > -990.0) {
edm::LogWarning("MisalignedTracker") << "Applying twist ...";
}
if (m_ellipticalEpsilon > -990.0) {
edm::LogWarning("MisalignedTracker") << "Applying elliptical ...";
}
if (m_skewEpsilon > -990.0) {
edm::LogWarning("MisalignedTracker") << "Applying skew ...";
}
if (m_sagittaEpsilon > -990.0) {
edm::LogWarning("MisalignedTracker") << "Applying sagitta ...";
}
// get flag for suppression of blind movements
suppressBlindMvmts = cfg.getUntrackedParameter<bool>("suppressBlindMvmts");
if (suppressBlindMvmts) {
edm::LogWarning("MisalignedTracker") << "Blind movements suppressed (TIB/TOB in z, TID/TEC in r)";
}
// compatibility with old (weird) z convention
oldMinusZconvention = cfg.getUntrackedParameter<bool>("oldMinusZconvention");
if (oldMinusZconvention) {
edm::LogWarning("MisalignedTracker") << "Old z convention: dz --> -dz";
} else {
edm::LogWarning("MisalignedTracker") << "New z convention: dz --> dz";
}
}
void TrackerSystematicMisalignments::beginJob() {}
void TrackerSystematicMisalignments::analyze(const edm::Event& event, const edm::EventSetup& setup) {
//Retrieve tracker topology from geometry
const GeometricDet* geom = &setup.getData(geomDetToken_);
const PTrackerParameters& ptp = setup.getData(ptpToken_);
const PTrackerAdditionalParametersPerDet* ptitp = &setup.getData(ptitpToken_);
const TrackerTopology* tTopo = &setup.getData(topoToken_);
TrackerGeometry* tracker = TrackerGeomBuilderFromGeometricDet().build(geom, ptitp, ptp, tTopo);
//take geometry from DB or randomly generate geometry
if (m_fromDBGeom) {
//build the tracker
const Alignments* alignments = &setup.getData(aliToken_);
const AlignmentErrorsExtended* alignmentErrors = &setup.getData(aliErrorToken_);
const Alignments* globalPositionRcd = &setup.getData(gprToken_);
//apply the latest alignments
GeometryAligner aligner;
aligner.applyAlignments<TrackerGeometry>(&(*tracker),
&(*alignments),
&(*alignmentErrors),
align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Tracker)));
}
theAlignableTracker = new AlignableTracker(&(*tracker), tTopo);
applySystematicMisalignment(&(*theAlignableTracker));
// -------------- writing out to alignment record --------------
Alignments myAlignments = *(theAlignableTracker->alignments());
AlignmentErrorsExtended myAlignmentErrorsExtended = *(theAlignableTracker->alignmentErrors());
// Store alignment[Error]s to DB
edm::Service<cond::service::PoolDBOutputService> poolDbService;
std::string theAlignRecordName = "TrackerAlignmentRcd";
std::string theErrorRecordName = "TrackerAlignmentErrorExtendedRcd";
// Call service
if (!poolDbService.isAvailable()) // Die if not available
throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
poolDbService->writeOneIOV<Alignments>(myAlignments, poolDbService->beginOfTime(), theAlignRecordName);
poolDbService->writeOneIOV<AlignmentErrorsExtended>(
myAlignmentErrorsExtended, poolDbService->beginOfTime(), theErrorRecordName);
}
void TrackerSystematicMisalignments::applySystematicMisalignment(Alignable* ali) {
const align::Alignables& comp = ali->components();
unsigned int nComp = comp.size();
//move then do for lower level object
//for issue of det vs detunit
bool usecomps = true;
if ((ali->alignableObjectId() == 2) && (nComp >= 1))
usecomps = false;
for (unsigned int i = 0; i < nComp; ++i) {
if (usecomps)
applySystematicMisalignment(comp[i]);
}
// if suppression of blind mvmts: check if subdet is blind to a certain mode
bool blindToZ(false), blindToR(false);
if (suppressBlindMvmts) {
const int subdetid = ali->geomDetId().subdetId();
switch (subdetid) {
// TIB/TON blind to z
case SiStripDetId::TIB:
case SiStripDetId::TOB:
blindToZ = true;
break;
// TID/TEC blind to R
case SiStripDetId::TID:
case SiStripDetId::TEC:
blindToR = true;
break;
default:
break;
}
}
const int level = ali->alignableObjectId();
if ((level == 1) || (level == 2)) {
const align::PositionType gP = ali->globalPosition();
const align::GlobalVector gVec = findSystematicMis(gP, blindToZ, blindToR);
ali->move(gVec);
}
}
align::GlobalVector TrackerSystematicMisalignments::findSystematicMis(const align::PositionType& globalPos,
const bool blindToZ,
const bool blindToR) {
//align::GlobalVector TrackerSystematicMisalignments::findSystematicMis( align::PositionType globalPos ){
// calculates shift for the current alignable
// all corrections are calculated w.r.t. the original geometry
double deltaX = 0.0;
double deltaY = 0.0;
double deltaZ = 0.0;
const double oldX = globalPos.x();
const double oldY = globalPos.y();
const double oldZ = globalPos.z();
const double oldPhi = globalPos.phi();
const double oldR = sqrt(globalPos.x() * globalPos.x() + globalPos.y() * globalPos.y());
if (m_radialEpsilon > -990.0 && !blindToR) {
deltaX += m_radialEpsilon * oldX;
deltaY += m_radialEpsilon * oldY;
}
if (m_telescopeEpsilon > -990.0 && !blindToZ) {
deltaZ += m_telescopeEpsilon * oldR;
}
if (m_layerRotEpsilon > -990.0) {
// The following number was chosen such that the Layer Rotation systematic
// misalignment would not cause an overall rotation of the tracker.
const double Roffset = 57.0;
const double xP = oldR * cos(oldPhi + m_layerRotEpsilon * (oldR - Roffset));
const double yP = oldR * sin(oldPhi + m_layerRotEpsilon * (oldR - Roffset));
deltaX += (xP - oldX);
deltaY += (yP - oldY);
}
if (m_bowingEpsilon > -990.0 && !blindToR) {
const double trackeredgePlusZ = 271.846;
const double bowfactor = m_bowingEpsilon * (trackeredgePlusZ * trackeredgePlusZ - oldZ * oldZ);
deltaX += oldX * bowfactor;
deltaY += oldY * bowfactor;
}
if (m_zExpEpsilon > -990.0 && !blindToZ) {
deltaZ += oldZ * m_zExpEpsilon;
}
if (m_twistEpsilon > -990.0) {
const double xP = oldR * cos(oldPhi + m_twistEpsilon * oldZ);
const double yP = oldR * sin(oldPhi + m_twistEpsilon * oldZ);
deltaX += (xP - oldX);
deltaY += (yP - oldY);
}
if (m_ellipticalEpsilon > -990.0 && !blindToR) {
deltaX += oldX * m_ellipticalEpsilon * cos(2.0 * oldPhi + m_ellipticalDelta);
deltaY += oldY * m_ellipticalEpsilon * cos(2.0 * oldPhi + m_ellipticalDelta);
}
if (m_skewEpsilon > -990.0 && !blindToZ) {
deltaZ += m_skewEpsilon * cos(oldPhi + m_skewDelta);
}
if (m_sagittaEpsilon > -990.0) {
// deltaX += oldX/fabs(oldX)*m_sagittaEpsilon; // old one...
deltaX += oldR * m_sagittaEpsilon * sin(m_sagittaDelta);
deltaY += oldR * m_sagittaEpsilon * cos(m_sagittaDelta); //Delta y is cos so that delta=0 reflects the old behavior
}
// Compatibility with old version <= 1.5
if (oldMinusZconvention)
deltaZ = -deltaZ;
align::GlobalVector gV(deltaX, deltaY, deltaZ);
return gV;
}
// Plug in to framework
#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(TrackerSystematicMisalignments);
|