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