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 
15 
19 
23 #include "CLHEP/Random/RandGauss.h"
24 
26 
27 #include "DataFormats/SiStripDetId/interface/SiStripDetId.h" // for enums TID/TIB/etc.
28 
29 // Database
32 
33 // -----------------------------------------------------------------
34 // 2010-05-20 Frank Meier
35 // Changed sign of z-correction, i.e. z-expansion is now an expansion
36 // made some variables constant, removed obviously dead code and comments
37 
39  : theAlignableTracker(0)
40 {
41  // use existing geometry
42  m_fromDBGeom = cfg.getUntrackedParameter< bool > ("fromDBGeom");
43 
44  // constants
45  m_radialEpsilon = cfg.getUntrackedParameter< double > ("radialEpsilon");
46  m_telescopeEpsilon = cfg.getUntrackedParameter< double > ("telescopeEpsilon");
47  m_layerRotEpsilon = cfg.getUntrackedParameter< double > ("layerRotEpsilon");
48  m_bowingEpsilon = cfg.getUntrackedParameter< double > ("bowingEpsilon");
49  m_zExpEpsilon = cfg.getUntrackedParameter< double > ("zExpEpsilon");
50  m_twistEpsilon = cfg.getUntrackedParameter< double > ("twistEpsilon");
51  m_ellipticalEpsilon = cfg.getUntrackedParameter< double > ("ellipticalEpsilon");
52  m_skewEpsilon = cfg.getUntrackedParameter< double > ("skewEpsilon");
53  m_sagittaEpsilon = cfg.getUntrackedParameter< double > ("sagittaEpsilon");
54 
55  m_ellipticalDelta = cfg.getUntrackedParameter< double > ("ellipticalDelta");
56  m_skewDelta = cfg.getUntrackedParameter< double > ("skewDelta");
57  m_sagittaDelta = cfg.getUntrackedParameter< double > ("sagittaDelta");
58 
59  if (m_radialEpsilon > -990.0){
60  edm::LogWarning("MisalignedTracker") << "Applying radial ...";
61  }
62  if (m_telescopeEpsilon > -990.0){
63  edm::LogWarning("MisalignedTracker") << "Applying telescope ...";
64  }
65  if (m_layerRotEpsilon > -990.0){
66  edm::LogWarning("MisalignedTracker") << "Applying layer rotation ...";
67  }
68  if (m_bowingEpsilon > -990.0){
69  edm::LogWarning("MisalignedTracker") << "Applying bowing ...";
70  }
71  if (m_zExpEpsilon > -990.0){
72  edm::LogWarning("MisalignedTracker") << "Applying z-expansion ...";
73  }
74  if (m_twistEpsilon > -990.0){
75  edm::LogWarning("MisalignedTracker") << "Applying twist ...";
76  }
77  if (m_ellipticalEpsilon > -990.0){
78  edm::LogWarning("MisalignedTracker") << "Applying elliptical ...";
79  }
80  if (m_skewEpsilon > -990.0){
81  edm::LogWarning("MisalignedTracker") << "Applying skew ...";
82  }
83  if (m_sagittaEpsilon > -990.0){
84  edm::LogWarning("MisalignedTracker") << "Applying sagitta ...";
85  }
86 
87  // get flag for suppression of blind movements
88  suppressBlindMvmts = cfg.getUntrackedParameter< bool > ("suppressBlindMvmts");
90  {
91  edm::LogWarning("MisalignedTracker") << "Blind movements suppressed (TIB/TOB in z, TID/TEC in r)";
92  }
93 
94  // compatibility with old (weird) z convention
95  oldMinusZconvention = cfg.getUntrackedParameter< bool > ("oldMinusZconvention");
97  {
98  edm::LogWarning("MisalignedTracker") << "Old z convention: dz --> -dz";
99  }
100  else
101  {
102  edm::LogWarning("MisalignedTracker") << "New z convention: dz --> dz";
103  }
104 
105 }
106 
108 {
109 
110 }
111 
112 
114 
115  //Retrieve tracker topology from geometry
116  edm::ESHandle<TrackerTopology> tTopoHandle;
117  setup.get<TrackerTopologyRcd>().get(tTopoHandle);
118  const TrackerTopology* const tTopo = tTopoHandle.product();
119 
121  setup.get<IdealGeometryRecord>().get(geom);
123  setup.get<PTrackerParametersRcd>().get( ptp );
125 
126  //take geometry from DB or randomly generate geometry
127  if (m_fromDBGeom){
128  //build the tracker
129  edm::ESHandle<Alignments> alignments;
131 
132  setup.get<TrackerAlignmentRcd>().get(alignments);
133  setup.get<TrackerAlignmentErrorExtendedRcd>().get(alignmentErrors);
134 
135  //apply the latest alignments
136  GeometryAligner aligner;
137  aligner.applyAlignments<TrackerGeometry>( &(*tracker), &(*alignments), &(*alignmentErrors), AlignTransform() );
138 
139  }
140 
141  theAlignableTracker = new AlignableTracker(&(*tracker), tTopo);
142 
144 
145  // -------------- writing out to alignment record --------------
146  Alignments* myAlignments = theAlignableTracker->alignments() ;
147  AlignmentErrorsExtended* myAlignmentErrorsExtended = theAlignableTracker->alignmentErrors() ;
148 
149  // Store alignment[Error]s to DB
151  std::string theAlignRecordName = "TrackerAlignmentRcd";
152  std::string theErrorRecordName = "TrackerAlignmentErrorExtendedRcd";
153 
154  // Call service
155  if( !poolDbService.isAvailable() ) // Die if not available
156  throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
157 
158  poolDbService->writeOne<Alignments>(&(*myAlignments), poolDbService->beginOfTime(), theAlignRecordName);
159  poolDbService->writeOne<AlignmentErrorsExtended>(&(*myAlignmentErrorsExtended), poolDbService->beginOfTime(), theErrorRecordName);
160 }
161 
163 {
164 
165  const align::Alignables& comp = ali->components();
166  unsigned int nComp = comp.size();
167  //move then do for lower level object
168  //for issue of det vs detunit
169  bool usecomps = true;
170  if ((ali->alignableObjectId()==2)&&(nComp>=1)) usecomps = false;
171  for (unsigned int i = 0; i < nComp; ++i){
172  if (usecomps) applySystematicMisalignment(comp[i]);
173  }
174 
175  // if suppression of blind mvmts: check if subdet is blind to a certain mode
176  bool blindToZ(false), blindToR(false);
177  if (suppressBlindMvmts)
178  {
179  const int subdetid = ali->geomDetId().subdetId();
180  switch(subdetid)
181  {
182  // TIB/TON blind to z
183  case SiStripDetId::TIB:
184  case SiStripDetId::TOB:
185  blindToZ = true;
186  break;
187  // TID/TEC blind to R
188  case SiStripDetId::TID:
189  case SiStripDetId::TEC:
190  blindToR = true;
191  break;
192  default:
193  break;
194  }
195  }
196 
197  const int level = ali->alignableObjectId();
198  if ((level == 1)||(level == 2)){
199  const align::PositionType gP = ali->globalPosition();
200  const align::GlobalVector gVec = findSystematicMis( gP, blindToZ, blindToR);
201  ali->move( gVec );
202  }
203 }
204 
205 align::GlobalVector TrackerSystematicMisalignments::findSystematicMis( const align::PositionType& globalPos, const bool blindToZ, const bool blindToR ){
206 //align::GlobalVector TrackerSystematicMisalignments::findSystematicMis( align::PositionType globalPos ){
207  // calculates shift for the current alignable
208  // all corrections are calculated w.r.t. the original geometry
209  double deltaX = 0.0;
210  double deltaY = 0.0;
211  double deltaZ = 0.0;
212  const double oldX = globalPos.x();
213  const double oldY = globalPos.y();
214  const double oldZ = globalPos.z();
215  const double oldPhi = globalPos.phi();
216  const double oldR = sqrt(globalPos.x()*globalPos.x() + globalPos.y()*globalPos.y());
217 
218  if (m_radialEpsilon > -990.0 && !blindToR){
219  deltaX += m_radialEpsilon*oldX;
220  deltaY += m_radialEpsilon*oldY;
221  }
222  if (m_telescopeEpsilon > -990.0 && !blindToZ){
223  deltaZ += m_telescopeEpsilon*oldR;
224  }
225  if (m_layerRotEpsilon > -990.0){
226  // The following number was chosen such that the Layer Rotation systematic
227  // misalignment would not cause an overall rotation of the tracker.
228  const double Roffset = 57.0;
229  const double xP = oldR*cos(oldPhi+m_layerRotEpsilon*(oldR-Roffset));
230  const double yP = oldR*sin(oldPhi+m_layerRotEpsilon*(oldR-Roffset));
231  deltaX += (xP - oldX);
232  deltaY += (yP - oldY);
233  }
234  if (m_bowingEpsilon > -990.0 && !blindToR){
235  const double trackeredgePlusZ=271.846;
236  const double bowfactor=m_bowingEpsilon*(trackeredgePlusZ*trackeredgePlusZ-oldZ*oldZ);
237  deltaX += oldX*bowfactor;
238  deltaY += oldY*bowfactor;
239  }
240  if (m_zExpEpsilon > -990.0 && !blindToZ){
241  deltaZ += oldZ*m_zExpEpsilon;
242  }
243  if (m_twistEpsilon > -990.0){
244  const double xP = oldR*cos(oldPhi+m_twistEpsilon*oldZ);
245  const double yP = oldR*sin(oldPhi+m_twistEpsilon*oldZ);
246  deltaX += (xP - oldX);
247  deltaY += (yP - oldY);
248  }
249  if (m_ellipticalEpsilon > -990.0 && !blindToR){
250  deltaX += oldX*m_ellipticalEpsilon*cos(2.0*oldPhi + m_ellipticalDelta);
251  deltaY += oldY*m_ellipticalEpsilon*cos(2.0*oldPhi + m_ellipticalDelta);
252  }
253  if (m_skewEpsilon > -990.0 && !blindToZ){
254  deltaZ += m_skewEpsilon*cos(oldPhi + m_skewDelta);
255  }
256  if (m_sagittaEpsilon > -990.0){
257  // deltaX += oldX/fabs(oldX)*m_sagittaEpsilon; // old one...
258  deltaX += oldR*m_sagittaEpsilon*sin(m_sagittaDelta);
259  deltaY += oldR*m_sagittaEpsilon*cos(m_sagittaDelta); //Delta y is cos so that delta=0 reflects the old behavior
260  }
261 
262  // Compatibility with old version <= 1.5
263  if (oldMinusZconvention) deltaZ = -deltaZ;
264 
265  align::GlobalVector gV( deltaX, deltaY, deltaZ );
266  return gV;
267 }
268 
269 // Plug in to framework
270 
272 
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
tuple cfg
Definition: looper.py:259
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
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:48
T z() const
Definition: PV3DBase.h:64
align::GlobalVector findSystematicMis(const align::PositionType &, const bool blindToZ, const bool blindToR)
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.
void applyAlignments(C *geometry, const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates)
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:86
std::vector< Alignable * > Alignables
Definition: Utilities.h:28
TrackerGeometry * build(const GeometricDet *gd, const PTrackerParameters &ptp)
const PositionType & globalPosition() const
Return the global position of the object.
Definition: Alignable.h:129
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:177
virtual void analyze(const edm::Event &, const edm::EventSetup &)