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 {
38  // use existing geometry
39  m_fromDBGeom = cfg.getUntrackedParameter< bool > ("fromDBGeom");
40 
41  // constants
42  m_radialEpsilon = cfg.getUntrackedParameter< double > ("radialEpsilon");
43  m_telescopeEpsilon = cfg.getUntrackedParameter< double > ("telescopeEpsilon");
44  m_layerRotEpsilon = cfg.getUntrackedParameter< double > ("layerRotEpsilon");
45  m_bowingEpsilon = cfg.getUntrackedParameter< double > ("bowingEpsilon");
46  m_zExpEpsilon = cfg.getUntrackedParameter< double > ("zExpEpsilon");
47  m_twistEpsilon = cfg.getUntrackedParameter< double > ("twistEpsilon");
48  m_ellipticalEpsilon = cfg.getUntrackedParameter< double > ("ellipticalEpsilon");
49  m_skewEpsilon = cfg.getUntrackedParameter< double > ("skewEpsilon");
50  m_saggitaEpsilon = cfg.getUntrackedParameter< double > ("saggitaEpsilon");
51 
52  if (m_radialEpsilon > -990.0){
53  edm::LogWarning("MisalignedTracker") << "Applying radial ...";
54  }
55  if (m_telescopeEpsilon > -990.0){
56  edm::LogWarning("MisalignedTracker") << "Applying telescope ...";
57  }
58  if (m_layerRotEpsilon > -990.0){
59  edm::LogWarning("MisalignedTracker") << "Applying layer rotation ...";
60  }
61  if (m_bowingEpsilon > -990.0){
62  edm::LogWarning("MisalignedTracker") << "Applying bowing ...";
63  }
64  if (m_zExpEpsilon > -990.0){
65  edm::LogWarning("MisalignedTracker") << "Applying z-expansion ...";
66  }
67  if (m_twistEpsilon > -990.0){
68  edm::LogWarning("MisalignedTracker") << "Applying twist ...";
69  }
70  if (m_ellipticalEpsilon > -990.0){
71  edm::LogWarning("MisalignedTracker") << "Applying elliptical ...";
72  }
73  if (m_skewEpsilon > -990.0){
74  edm::LogWarning("MisalignedTracker") << "Applying skew ...";
75  }
76  if (m_saggitaEpsilon > -990.0){
77  edm::LogWarning("MisalignedTracker") << "Applying saggita ...";
78  }
79 
80  // get flag for suppression of blind movements
81  suppressBlindMvmts = cfg.getUntrackedParameter< bool > ("suppressBlindMvmts");
83  {
84  edm::LogWarning("MisalignedTracker") << "Blind movements suppressed (TIB/TOB in z, TID/TEC in r)";
85  }
86 
87  // compatibility with old (weird) z convention
88  oldMinusZconvention = cfg.getUntrackedParameter< bool > ("oldMinusZconvention");
90  {
91  edm::LogWarning("MisalignedTracker") << "Old z convention: dz --> -dz";
92  }
93  else
94  {
95  edm::LogWarning("MisalignedTracker") << "New z convention: dz --> dz";
96  }
97 
98 }
99 
101 {
102 
103 }
104 
105 
107 
108 
110  setup.get<IdealGeometryRecord>().get(geom);
112 
113  //take geometry from DB or randomly generate geometry
114  if (m_fromDBGeom){
115  //build the tracker
116  edm::ESHandle<Alignments> alignments;
117  edm::ESHandle<AlignmentErrors> alignmentErrors;
118 
119  setup.get<TrackerAlignmentRcd>().get(alignments);
120  setup.get<TrackerAlignmentErrorRcd>().get(alignmentErrors);
121 
122  //apply the latest alignments
123  GeometryAligner aligner;
124  aligner.applyAlignments<TrackerGeometry>( &(*tracker), &(*alignments), &(*alignmentErrors), AlignTransform() );
125 
126  }
127 
128  theAlignableTracker = new AlignableTracker(&(*tracker));
129 
131 
132  // -------------- writing out to alignment record --------------
133  Alignments* myAlignments = theAlignableTracker->alignments() ;
134  AlignmentErrors* myAlignmentErrors = theAlignableTracker->alignmentErrors() ;
135 
136  // Store alignment[Error]s to DB
138  std::string theAlignRecordName = "TrackerAlignmentRcd";
139  std::string theErrorRecordName = "TrackerAlignmentErrorRcd";
140 
141  // Call service
142  if( !poolDbService.isAvailable() ) // Die if not available
143  throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
144 
145  poolDbService->writeOne<Alignments>(&(*myAlignments), poolDbService->beginOfTime(), theAlignRecordName);
146  poolDbService->writeOne<AlignmentErrors>(&(*myAlignmentErrors), poolDbService->beginOfTime(), theErrorRecordName);
147 }
148 
150 {
151 
152  const align::Alignables& comp = ali->components();
153  unsigned int nComp = comp.size();
154  //move then do for lower level object
155  //for issue of det vs detunit
156  bool usecomps = true;
157  if ((ali->alignableObjectId()==2)&&(nComp>=1)) usecomps = false;
158  for (unsigned int i = 0; i < nComp; ++i){
159  if (usecomps) applySystematicMisalignment(comp[i]);
160  }
161 
162  // if suppression of blind mvmts: check if subdet is blind to a certain mode
163  bool blindToZ(false), blindToR(false);
164  if (suppressBlindMvmts)
165  {
166  const int subdetid = ali->geomDetId().subdetId();
167  switch(subdetid)
168  {
169  // TIB/TON blind to z
170  case SiStripDetId::TIB:
171  case SiStripDetId::TOB:
172  blindToZ = true;
173  break;
174  // TID/TEC blind to R
175  case SiStripDetId::TID:
176  case SiStripDetId::TEC:
177  blindToR = true;
178  break;
179  default:
180  break;
181  }
182  }
183 
184  const int level = ali->alignableObjectId();
185  if ((level == 1)||(level == 2)){
186  const align::PositionType gP = ali->globalPosition();
187  const align::GlobalVector gVec = findSystematicMis( gP, blindToZ, blindToR);
188  ali->move( gVec );
189  }
190 }
191 
193 //align::GlobalVector TrackerSystematicMisalignments::findSystematicMis( align::PositionType globalPos ){
194  // calculates shift for the current alignable
195  // all corrections are calculated w.r.t. the original geometry
196  double deltaX = 0.0;
197  double deltaY = 0.0;
198  double deltaZ = 0.0;
199  const double oldX = globalPos.x();
200  const double oldY = globalPos.y();
201  const double oldZ = globalPos.z();
202  const double oldPhi = globalPos.phi();
203  const double oldR = sqrt(globalPos.x()*globalPos.x() + globalPos.y()*globalPos.y());
204 
205  if (m_radialEpsilon > -990.0 && !blindToR){
206  deltaX += m_radialEpsilon*oldX;
207  deltaY += m_radialEpsilon*oldY;
208  }
209  if (m_telescopeEpsilon > -990.0 && !blindToZ){
210  deltaZ += m_telescopeEpsilon*oldR;
211  }
212  if (m_layerRotEpsilon > -990.0){
213  // The following number was chosen such that the Layer Rotation systematic
214  // misalignment would not cause an overall rotation of the tracker.
215  const double Roffset = 57.0;
216  const double xP = oldR*cos(oldPhi+m_layerRotEpsilon*(oldR-Roffset));
217  const double yP = oldR*sin(oldPhi+m_layerRotEpsilon*(oldR-Roffset));
218  deltaX += (xP - oldX);
219  deltaY += (yP - oldY);
220  }
221  if (m_bowingEpsilon > -990.0 && !blindToR){
222  const double trackeredgePlusZ=271.846;
223  const double bowfactor=m_bowingEpsilon*(trackeredgePlusZ*trackeredgePlusZ-oldZ*oldZ);
224  deltaX += oldX*bowfactor;
225  deltaY += oldY*bowfactor;
226  }
227  if (m_zExpEpsilon > -990.0 && !blindToZ){
228  deltaZ += oldZ*m_zExpEpsilon;
229  }
230  if (m_twistEpsilon > -990.0){
231  const double xP = oldR*cos(oldPhi+m_twistEpsilon*oldZ);
232  const double yP = oldR*sin(oldPhi+m_twistEpsilon*oldZ);
233  deltaX += (xP - oldX);
234  deltaY += (yP - oldY);
235  }
236  if (m_ellipticalEpsilon > -990.0 && !blindToR){
237  deltaX += oldX*m_ellipticalEpsilon*cos(2.0*oldPhi);
238  deltaY += oldY*m_ellipticalEpsilon*cos(2.0*oldPhi);
239  }
240  if (m_skewEpsilon > -990.0 && !blindToZ){
241  deltaZ += m_skewEpsilon*cos(oldPhi);
242  }
243  if (m_saggitaEpsilon > -990.0){
244  // deltaX += oldX/fabs(oldX)*m_saggitaEpsilon; // old one...
245  deltaY += oldR*m_saggitaEpsilon;
246  }
247 
248  // Compatibility with old version <= 1.5
249  if (oldMinusZconvention) deltaZ = -deltaZ;
250 
251  align::GlobalVector gV( deltaX, deltaY, deltaZ );
252  return gV;
253 }
254 
255 // Plug in to framework
256 
258 
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
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:68
T y() const
Definition: PV3DBase.h:62
align::GlobalVector findSystematicMis(align::PositionType, const bool blindToZ, const bool blindToR)
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:46
T z() const
Definition: PV3DBase.h:63
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
TrackerSystematicMisalignments(const edm::ParameterSet &)
bool isAvailable() const
Definition: Service.h:47
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
AlignmentErrors * alignmentErrors() const
Return alignment errors, sorted by DetId.
void applyAlignments(C *geometry, const Alignments *alignments, const AlignmentErrors *alignmentErrors, const AlignTransform &globalCoordinates)
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:39
virtual void beginJob()
Read ideal tracker geometry from DB.
const T & get() const
Definition: EventSetup.h:55
TrackerGeometry * build(const GeometricDet *gd)
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:61
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 &)