CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  : theAlignableTracker(0)
43 {
44  // use existing geometry
45  m_fromDBGeom = cfg.getUntrackedParameter< bool > ("fromDBGeom");
46 
47  // constants
48  m_radialEpsilon = cfg.getUntrackedParameter< double > ("radialEpsilon");
49  m_telescopeEpsilon = cfg.getUntrackedParameter< double > ("telescopeEpsilon");
50  m_layerRotEpsilon = cfg.getUntrackedParameter< double > ("layerRotEpsilon");
51  m_bowingEpsilon = cfg.getUntrackedParameter< double > ("bowingEpsilon");
52  m_zExpEpsilon = cfg.getUntrackedParameter< double > ("zExpEpsilon");
53  m_twistEpsilon = cfg.getUntrackedParameter< double > ("twistEpsilon");
54  m_ellipticalEpsilon = cfg.getUntrackedParameter< double > ("ellipticalEpsilon");
55  m_skewEpsilon = cfg.getUntrackedParameter< double > ("skewEpsilon");
56  m_sagittaEpsilon = cfg.getUntrackedParameter< double > ("sagittaEpsilon");
57 
58  m_ellipticalDelta = cfg.getUntrackedParameter< double > ("ellipticalDelta");
59  m_skewDelta = cfg.getUntrackedParameter< double > ("skewDelta");
60  m_sagittaDelta = cfg.getUntrackedParameter< double > ("sagittaDelta");
61 
62  if (m_radialEpsilon > -990.0){
63  edm::LogWarning("MisalignedTracker") << "Applying radial ...";
64  }
65  if (m_telescopeEpsilon > -990.0){
66  edm::LogWarning("MisalignedTracker") << "Applying telescope ...";
67  }
68  if (m_layerRotEpsilon > -990.0){
69  edm::LogWarning("MisalignedTracker") << "Applying layer rotation ...";
70  }
71  if (m_bowingEpsilon > -990.0){
72  edm::LogWarning("MisalignedTracker") << "Applying bowing ...";
73  }
74  if (m_zExpEpsilon > -990.0){
75  edm::LogWarning("MisalignedTracker") << "Applying z-expansion ...";
76  }
77  if (m_twistEpsilon > -990.0){
78  edm::LogWarning("MisalignedTracker") << "Applying twist ...";
79  }
80  if (m_ellipticalEpsilon > -990.0){
81  edm::LogWarning("MisalignedTracker") << "Applying elliptical ...";
82  }
83  if (m_skewEpsilon > -990.0){
84  edm::LogWarning("MisalignedTracker") << "Applying skew ...";
85  }
86  if (m_sagittaEpsilon > -990.0){
87  edm::LogWarning("MisalignedTracker") << "Applying sagitta ...";
88  }
89 
90  // get flag for suppression of blind movements
91  suppressBlindMvmts = cfg.getUntrackedParameter< bool > ("suppressBlindMvmts");
93  {
94  edm::LogWarning("MisalignedTracker") << "Blind movements suppressed (TIB/TOB in z, TID/TEC in r)";
95  }
96 
97  // compatibility with old (weird) z convention
98  oldMinusZconvention = cfg.getUntrackedParameter< bool > ("oldMinusZconvention");
100  {
101  edm::LogWarning("MisalignedTracker") << "Old z convention: dz --> -dz";
102  }
103  else
104  {
105  edm::LogWarning("MisalignedTracker") << "New z convention: dz --> dz";
106  }
107 
108 }
109 
111 {
112 
113 }
114 
115 
117 
118  //Retrieve tracker topology from geometry
119  edm::ESHandle<TrackerTopology> tTopoHandle;
120  setup.get<TrackerTopologyRcd>().get(tTopoHandle);
121  const TrackerTopology* const tTopo = tTopoHandle.product();
122 
124  setup.get<IdealGeometryRecord>().get(geom);
126  setup.get<PTrackerParametersRcd>().get( ptp );
128 
129  //take geometry from DB or randomly generate geometry
130  if (m_fromDBGeom){
131  //build the tracker
132  edm::ESHandle<Alignments> alignments;
134 
135  setup.get<TrackerAlignmentRcd>().get(alignments);
136  setup.get<TrackerAlignmentErrorExtendedRcd>().get(alignmentErrors);
137 
138  edm::ESHandle<Alignments> globalPositionRcd;
139  setup.get<TrackerDigiGeometryRecord>().getRecord<GlobalPositionRcd>().get(globalPositionRcd);
140 
141  //apply the latest alignments
142  GeometryAligner aligner;
143  aligner.applyAlignments<TrackerGeometry>( &(*tracker), &(*alignments), &(*alignmentErrors),
144  align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Tracker)));
145 
146  }
147 
148  theAlignableTracker = new AlignableTracker(&(*tracker), tTopo);
149 
151 
152  // -------------- writing out to alignment record --------------
153  Alignments* myAlignments = theAlignableTracker->alignments() ;
154  AlignmentErrorsExtended* myAlignmentErrorsExtended = theAlignableTracker->alignmentErrors() ;
155 
156  // Store alignment[Error]s to DB
158  std::string theAlignRecordName = "TrackerAlignmentRcd";
159  std::string theErrorRecordName = "TrackerAlignmentErrorExtendedRcd";
160 
161  // Call service
162  if( !poolDbService.isAvailable() ) // Die if not available
163  throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
164 
165  poolDbService->writeOne<Alignments>(&(*myAlignments), poolDbService->beginOfTime(), theAlignRecordName);
166  poolDbService->writeOne<AlignmentErrorsExtended>(&(*myAlignmentErrorsExtended), poolDbService->beginOfTime(), theErrorRecordName);
167 }
168 
170 {
171 
172  const align::Alignables& comp = ali->components();
173  unsigned int nComp = comp.size();
174  //move then do for lower level object
175  //for issue of det vs detunit
176  bool usecomps = true;
177  if ((ali->alignableObjectId()==2)&&(nComp>=1)) usecomps = false;
178  for (unsigned int i = 0; i < nComp; ++i){
179  if (usecomps) applySystematicMisalignment(comp[i]);
180  }
181 
182  // if suppression of blind mvmts: check if subdet is blind to a certain mode
183  bool blindToZ(false), blindToR(false);
184  if (suppressBlindMvmts)
185  {
186  const int subdetid = ali->geomDetId().subdetId();
187  switch(subdetid)
188  {
189  // TIB/TON blind to z
190  case SiStripDetId::TIB:
191  case SiStripDetId::TOB:
192  blindToZ = true;
193  break;
194  // TID/TEC blind to R
195  case SiStripDetId::TID:
196  case SiStripDetId::TEC:
197  blindToR = true;
198  break;
199  default:
200  break;
201  }
202  }
203 
204  const int level = ali->alignableObjectId();
205  if ((level == 1)||(level == 2)){
206  const align::PositionType gP = ali->globalPosition();
207  const align::GlobalVector gVec = findSystematicMis( gP, blindToZ, blindToR);
208  ali->move( gVec );
209  }
210 }
211 
212 align::GlobalVector TrackerSystematicMisalignments::findSystematicMis( const align::PositionType& globalPos, const bool blindToZ, const bool blindToR ){
213 //align::GlobalVector TrackerSystematicMisalignments::findSystematicMis( align::PositionType globalPos ){
214  // calculates shift for the current alignable
215  // all corrections are calculated w.r.t. the original geometry
216  double deltaX = 0.0;
217  double deltaY = 0.0;
218  double deltaZ = 0.0;
219  const double oldX = globalPos.x();
220  const double oldY = globalPos.y();
221  const double oldZ = globalPos.z();
222  const double oldPhi = globalPos.phi();
223  const double oldR = sqrt(globalPos.x()*globalPos.x() + globalPos.y()*globalPos.y());
224 
225  if (m_radialEpsilon > -990.0 && !blindToR){
226  deltaX += m_radialEpsilon*oldX;
227  deltaY += m_radialEpsilon*oldY;
228  }
229  if (m_telescopeEpsilon > -990.0 && !blindToZ){
230  deltaZ += m_telescopeEpsilon*oldR;
231  }
232  if (m_layerRotEpsilon > -990.0){
233  // The following number was chosen such that the Layer Rotation systematic
234  // misalignment would not cause an overall rotation of the tracker.
235  const double Roffset = 57.0;
236  const double xP = oldR*cos(oldPhi+m_layerRotEpsilon*(oldR-Roffset));
237  const double yP = oldR*sin(oldPhi+m_layerRotEpsilon*(oldR-Roffset));
238  deltaX += (xP - oldX);
239  deltaY += (yP - oldY);
240  }
241  if (m_bowingEpsilon > -990.0 && !blindToR){
242  const double trackeredgePlusZ=271.846;
243  const double bowfactor=m_bowingEpsilon*(trackeredgePlusZ*trackeredgePlusZ-oldZ*oldZ);
244  deltaX += oldX*bowfactor;
245  deltaY += oldY*bowfactor;
246  }
247  if (m_zExpEpsilon > -990.0 && !blindToZ){
248  deltaZ += oldZ*m_zExpEpsilon;
249  }
250  if (m_twistEpsilon > -990.0){
251  const double xP = oldR*cos(oldPhi+m_twistEpsilon*oldZ);
252  const double yP = oldR*sin(oldPhi+m_twistEpsilon*oldZ);
253  deltaX += (xP - oldX);
254  deltaY += (yP - oldY);
255  }
256  if (m_ellipticalEpsilon > -990.0 && !blindToR){
257  deltaX += oldX*m_ellipticalEpsilon*cos(2.0*oldPhi + m_ellipticalDelta);
258  deltaY += oldY*m_ellipticalEpsilon*cos(2.0*oldPhi + m_ellipticalDelta);
259  }
260  if (m_skewEpsilon > -990.0 && !blindToZ){
261  deltaZ += m_skewEpsilon*cos(oldPhi + m_skewDelta);
262  }
263  if (m_sagittaEpsilon > -990.0){
264  // deltaX += oldX/fabs(oldX)*m_sagittaEpsilon; // old one...
265  deltaX += oldR*m_sagittaEpsilon*sin(m_sagittaDelta);
266  deltaY += oldR*m_sagittaEpsilon*cos(m_sagittaDelta); //Delta y is cos so that delta=0 reflects the old behavior
267  }
268 
269  // Compatibility with old version <= 1.5
270  if (oldMinusZconvention) deltaZ = -deltaZ;
271 
272  align::GlobalVector gV( deltaX, deltaY, deltaZ );
273  return gV;
274 }
275 
276 // Plug in to framework
277 
279 
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
tuple cfg
Definition: looper.py:293
AlignmentErrorsExtended * alignmentErrors() const
Return alignment errors, sorted by DetId.
Class to update a given geometry with a set of alignments.
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
T y() const
Definition: PV3DBase.h:63
TrackerGeometry * build(const GeometricDet *gd, const PTrackerParameters &ptp, const TrackerTopology *tTopo)
virtual void move(const GlobalVector &displacement)=0
Movement with respect to the global reference frame.
virtual Alignables components() const =0
Return vector of all direct components.
T sqrt(T t)
Definition: SSEVec.h:18
T z() const
Definition: PV3DBase.h:64
align::GlobalVector findSystematicMis(const align::PositionType &, const bool blindToZ, const bool blindToR)
void get(HolderT &iHolder) const
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
TrackerSystematicMisalignments(const edm::ParameterSet &)
bool isAvailable() const
Definition: Service.h:46
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
virtual void beginJob()
Read ideal tracker geometry from DB.
Definition: DetId.h:18
void applyAlignments(C *geometry, const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates)
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
std::vector< Alignable * > Alignables
Definition: Utilities.h:28
const AlignTransform & DetectorGlobalPosition(const Alignments &allGlobals, const DetId &id)
const PositionType & globalPosition() const
Return the global position of the object.
Definition: Alignable.h:134
tuple level
Definition: testEve_cfg.py:34
Alignments * alignments() const
Return alignments, sorted by DetId.
T x() const
Definition: PV3DBase.h:62
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
const DetId & geomDetId() const
Definition: Alignable.h:182
virtual void analyze(const edm::Event &, const edm::EventSetup &)