CMS 3D CMS Logo

DTParametrizedDriftAlgo.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * \author G. Cerminara - INFN Torino
5  */
6 
10 
13 
16 
20 
21 #include <iostream>
22 #include <iomanip>
23 
24 using namespace std;
25 using namespace edm;
26 
29  interpolate(config.getParameter<bool>("interpolate")),
30  minTime(config.getParameter<double>("minTime")), // FIXME: Default was -3 ns
31  maxTime(config.getParameter<double>("maxTime")), // FIXME: Default was 415 ns
32  // Set verbose output
33  debug(config.getUntrackedParameter<bool>("debug", "false")) {}
34 
36 
38  theSync->setES(setup);
39  // Access the magnetic field
42  magField = &*magneticField;
43 }
44 
45 // First Step
47  const DTLayer* layer, const DTDigi& digi, LocalPoint& leftPoint, LocalPoint& rightPoint, LocalError& error) const {
48  // Get the layerId
49  DTLayerId layerId = layer->id(); //FIXME: pass it instead of get it from layer
50  const DTWireId wireId(layerId, digi.wire());
51 
52  // Get Wire position
53  if (!layer->specificTopology().isWireValid(wireId.wire()))
54  return false;
55  LocalPoint locWirePos(layer->specificTopology().wirePosition(wireId.wire()), 0, 0);
56  const GlobalPoint globWirePos = layer->toGlobal(locWirePos);
57 
58  // impact angle on DT chamber
59  // compute the impact angle using the centre of the wire,
60  // only for RZ superlayer (eta). In the other cases theta is very close to 0.
61  float angle = 0.0;
62 
63  if (layerId.superlayer() == 2) {
64  //GlobalPoint lPos=layer->position();
65  GlobalVector lDir = (GlobalPoint() - globWirePos).unit();
66  LocalVector lDirLoc = layer->toLocal(lDir);
67 
68  angle = atan(lDirLoc.x() / -lDirLoc.z());
69  }
70 
71  return compute(layer, wireId, digi.time(), angle, globWirePos, leftPoint, rightPoint, error, 1);
72 }
73 
74 // Second step
76  const DTRecHit1D& recHit1D,
77  const float& angle,
78  DTRecHit1D& newHit1D) const {
79  const DTWireId wireId = recHit1D.wireId();
80 
81  // Get Wire position
82  if (!layer->specificTopology().isWireValid(wireId.wire()))
83  return false;
84  LocalPoint locWirePos(layer->specificTopology().wirePosition(wireId.wire()), 0, 0);
85  const GlobalPoint globWirePos = layer->toGlobal(locWirePos);
86 
87  return compute(layer, wireId, recHit1D.digiTime(), angle, globWirePos, newHit1D, 2);
88 }
89 
90 // Third step
92  const DTRecHit1D& recHit1D,
93  const float& angle,
94  const GlobalPoint& globPos,
95  DTRecHit1D& newHit1D) const {
96  return compute(layer, recHit1D.wireId(), recHit1D.digiTime(), angle, globPos, newHit1D, 3);
97 }
98 
99 // Do the actual work.
101  const DTWireId& wireId,
102  const float digiTime,
103  const float& angle,
104  const GlobalPoint& globPos,
105  LocalPoint& leftPoint,
106  LocalPoint& rightPoint,
107  LocalError& error,
108  int step) const {
109  // Subtract Offset according to DTTTrigBaseSync concrete instance
110  // chosen with the 'tZeroMode' parameter
111  float driftTime = digiTime - theSync->offset(layer, wireId, globPos);
112 
113  // check for out-of-time only at step 1
114  if (step == 1 && (driftTime < minTime || driftTime > maxTime)) {
115  if (debug)
116  cout << "*** Drift time out of window for in-time hits " << driftTime << endl;
117 
118  if (step == 1) { //FIXME: protection against failure at 2nd and 3rd steps, must be checked!!!
119  // Hits are interpreted as coming from out-of-time pile-up and recHit
120  // is ignored.
121  return false;
122  }
123  }
124 
125  // Small negative times interpreted as hits close to the wire.
126  if (driftTime < 0.)
127  driftTime = 0;
128 
129  //----------------------------------------------------------------------
130  // Magnetic Field in layer frame
131  const LocalVector BLoc = layer->toLocal(magField->inTesla(globPos));
132 
133  float By = BLoc.y();
134  float Bz = BLoc.z();
135 
136  //--------------------------------------------------------------------
137  // Calculate the drift distance and the resolution from the parametrization
138 
140  static const DTTime2DriftParametrization par;
141 
142  bool parStatus = par.computeDriftDistance_mean(driftTime, angle, By, Bz, interpolate, &DX);
143 
144  if (!parStatus) {
145  if (debug)
146  cout << "[DTParametrizedDriftAlgo]*** WARNING: call to parametrization failed" << endl;
147  return false;
148  }
149 
150  float sigma_l = DX.x_width_m;
151  float sigma_r = DX.x_width_p;
152  float drift = DX.x_drift;
153 
154  float reso = 0;
155 
156  bool variableSigma = false;
157  // By defualt the errors are obtained from a fit of the residuals in the various
158  // stations/SL.
159  // The error returned by DTTime2DriftParametrization can not be used easily
160  // to determine the hit error due to the way the parametrization of the error
161  // is done (please contcat the authors for details).
162  // Anyhow changing variableSigma==true, an attempt is done to set a variable error
163  // according to the sigma calculated by DTTime2DriftParametrization.
164  // Additionally, contributions from uncertaionties in TOF and signal propagation
165  // corrections are added.
166  // Uncertainty in the determination of incident angle and hit position
167  // (ie B value) are NOT accounted.
168  // This is not the default since it does not give good results...
169 
170  int wheel = abs(wireId.wheel());
171  if (variableSigma) {
172  float sTDelays = 0;
173  if (step == 1) { // 1. step
174  reso = (sigma_l + sigma_r) / 2.; // FIXME: theta/B are not yet known...
175  if (wireId.superlayer() == 2) { // RZ
176  sTDelays = 2.92;
177  } else { // RPhi
178  if (wheel == 0) {
179  sTDelays = 2.74;
180  } else if (wheel == 1) {
181  sTDelays = 1.83;
182  } else if (wheel == 2) {
183  sTDelays = 1.25;
184  }
185  }
186  } else if (step == 2) { // 2. step
187  reso = (sigma_l + sigma_r) / 2.; // FIXME: B is not yet known...
188  if (wireId.superlayer() == 2) { // RZ
189  sTDelays = 0.096;
190  } else { // RPhi
191  if (wheel == 0) {
192  sTDelays = 0.022;
193  } else if (wheel == 1) {
194  sTDelays = 0.079;
195  } else if (wheel == 2) {
196  sTDelays = 0.124;
197  }
198  }
199  } else if (step == 3) { // 3. step
200  reso = (sigma_l + sigma_r) / 2.;
201  if (wireId.superlayer() == 2) { // RZ
202  sTDelays = 0.096;
203  } else { // RPhi
204  if (wheel == 0) {
205  sTDelays = 0.022;
206  } else if (wheel == 1) {
207  sTDelays = 0.079;
208  } else if (wheel == 2) {
209  sTDelays = 0.124;
210  }
211  }
212  }
213  float sXDelays = sTDelays * DX.v_drift / 10.;
214  reso = sqrt(reso * reso + sXDelays * sXDelays);
215  } else { // Use a fixed sigma, from fit of residuals.
216  if (step == 1) { // 1. step
217  if (wireId.superlayer() == 2) {
218  if (wheel == 0) {
219  reso = 0.0250;
220  } else if (wheel == 1) {
221  reso = 0.0271;
222  } else if (wheel == 2) {
223  reso = 0.0308;
224  }
225  } else {
226  reso = 0.0237;
227  }
228  } else if (step == 2) { // 2. step //FIXME
229  if (wireId.superlayer() == 2) {
230  if (wheel == 0) {
231  reso = 0.0250;
232  } else if (wheel == 1) {
233  reso = 0.0271;
234  } else if (wheel == 2) {
235  reso = 0.0305;
236  }
237  } else {
238  reso = 0.0231;
239  }
240  } else if (step == 3) { // 3. step
241  if (wireId.superlayer() == 2) {
242  if (wheel == 0) {
243  reso = 0.0196;
244  } else if (wheel == 1) {
245  reso = 0.0210;
246  } else if (wheel == 2) {
247  reso = 0.0228;
248  }
249  } else {
250  reso = 0.0207;
251  }
252  }
253  }
254  //--------------------------------------------------------------------
255 
256  error = LocalError(reso * reso, 0., 0.);
257 
258  // Get Wire position
259  if (!layer->specificTopology().isWireValid(wireId.wire()))
260  return false;
261  LocalPoint locWirePos(layer->specificTopology().wirePosition(wireId.wire()), 0, 0);
262 
263  //Build the two possible points and the error on the position
264  leftPoint = LocalPoint(locWirePos.x() - drift, locWirePos.y(), locWirePos.z());
265  rightPoint = LocalPoint(locWirePos.x() + drift, locWirePos.y(), locWirePos.z());
266 
267  if (debug) {
268  int prevW = cout.width();
269  cout << setiosflags(ios::showpoint | ios::fixed) << setw(3) << "[DTParametrizedDriftAlgo]: step " << step << endl
270  << " Global Position " << globPos << endl
271  << " Local Position " << layer->toLocal(globPos)
272  << endl
273  // << " y along Wire " << wireCoord << endl
274  << " Digi time " << digiTime
275  << endl
276  // << " dpropDelay " << propDelay << endl
277  // << " deltaTOF " << deltaTOF << endl
278  << " >Drif time " << driftTime << endl
279  << " >Angle " << angle * 180. / M_PI << endl
280  << " <Drift distance " << drift << endl
281  << " <sigma_l " << sigma_l << endl
282  << " <sigma_r " << sigma_r << endl
283  << " reso " << reso << endl
284  << " leftPoint " << leftPoint << endl
285  << " rightPoint " << rightPoint << endl
286  << " error " << error << resetiosflags(ios::showpoint | ios::fixed) << setw(prevW) << endl
287  << endl;
288  }
289 
290  return true;
291 }
292 
293 // Interface to the method which does the actual work suited for 2nd and 3rd steps
295  const DTWireId& wireId,
296  const float digiTime,
297  const float& angle,
298  const GlobalPoint& globPos,
299  DTRecHit1D& newHit1D,
300  int step) const {
301  LocalPoint leftPoint;
302  LocalPoint rightPoint;
304 
305  if (compute(layer, wireId, digiTime, angle, globPos, leftPoint, rightPoint, error, step)) {
306  // Set the position and the error of the rechit which is being updated
307  switch (newHit1D.lrSide()) {
308  case DTEnums::Left: {
309  // Keep the original y position of newHit1D: for step==3, it's the
310  // position along the wire. Needed for rotation alignment
311  LocalPoint leftPoint3D(leftPoint.x(), newHit1D.localPosition().y(), leftPoint.z());
312  newHit1D.setPositionAndError(leftPoint3D, error);
313  break;
314  }
315 
316  case DTEnums::Right: {
317  // as above: 3d position
318  LocalPoint rightPoint3D(rightPoint.x(), newHit1D.localPosition().y(), rightPoint.z());
319  newHit1D.setPositionAndError(rightPoint3D, error);
320  break;
321  }
322 
323  default:
324  throw cms::Exception("InvalidDTCellSide") << "[DTParametrizedDriftAlgo] Compute at Step " << step
325  << ", Hit side " << newHit1D.lrSide() << " is invalid!" << endl;
326  return false;
327  }
328 
329  return true;
330  } else {
331  return false;
332  }
333 }
Vector3DBase
Definition: Vector3DBase.h:8
alignBH_cfg.fixed
fixed
Definition: alignBH_cfg.py:54
DTWireId::wire
int wire() const
Return the wire number.
Definition: DTWireId.h:42
electrons_cff.bool
bool
Definition: electrons_cff.py:366
ESHandle.h
DTParametrizedDriftAlgo::compute
bool compute(const DTLayer *layer, const DTDigi &digi, LocalPoint &leftPoint, LocalPoint &rightPoint, LocalError &error) const override
step
step
Definition: StallMonitor.cc:94
DTParametrizedDriftAlgo::setES
void setES(const edm::EventSetup &setup) override
Pass the Event Setup to the algo at each event.
Definition: DTParametrizedDriftAlgo.cc:37
HLT_FULL_cff.minTime
minTime
Definition: HLT_FULL_cff.py:8976
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
DTRecHit1D::lrSide
DTEnums::DTCellSide lrSide() const
The side of the cell.
Definition: DTRecHit1D.h:61
edm
HLT enums.
Definition: AlignableModifier.h:19
DTRecHitBaseAlgo
Definition: DTRecHitBaseAlgo.h:29
gather_cfg.cout
cout
Definition: gather_cfg.py:144
DTRecHit1D
Definition: DTRecHit1D.h:25
bookConverter.compute
def compute(min, max)
Definition: bookConverter.py:106
DTSuperLayerId::superlayer
int superlayer() const
Return the superlayer number (deprecated method name)
Definition: DTSuperLayerId.h:42
align::LocalPoint
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
HLT_FULL_cff.magneticField
magneticField
Definition: HLT_FULL_cff.py:348
relativeConstraints.error
error
Definition: relativeConstraints.py:53
DTDigi::time
double time() const
Get time in ns.
Definition: DTDigi.cc:37
HLT_FULL_cff.maxTime
maxTime
Definition: HLT_FULL_cff.py:8960
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
DTTime2DriftParametrization
Definition: DTTime2DriftParametrization.h:18
DTRecHit1D::setPositionAndError
void setPositionAndError(LocalPoint pos, LocalError err)
Set the local position and its error.
Definition: DTRecHit1D.h:70
DTParametrizedDriftAlgo::~DTParametrizedDriftAlgo
~DTParametrizedDriftAlgo() override
Destructor.
Definition: DTParametrizedDriftAlgo.cc:35
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
DTTime2DriftParametrization::drift_distance::x_drift
double x_drift
Definition: DTTime2DriftParametrization.h:28
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
config
Definition: config.py:1
DTRecHit1D::wireId
DTWireId wireId() const
Return the wireId.
Definition: DTRecHit1D.h:76
DTEnums::Left
Definition: DTEnums.h:15
debug
#define debug
Definition: HDRShower.cc:19
shallow::drift
LocalVector drift(const StripGeomDetUnit *, const MagneticField &, const SiStripLorentzAngle &)
Definition: ShallowTools.cc:36
DTDigi::wire
int wire() const
Return wire number.
Definition: DTDigi.cc:41
DTWireId
Definition: DTWireId.h:12
DTTime2DriftParametrization::drift_distance::x_width_p
double x_width_p
Definition: DTTime2DriftParametrization.h:28
DTParametrizedDriftAlgo.h
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
IdealMagneticFieldRecord.h
edm::ESHandle< MagneticField >
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Point3DBase< float, LocalTag >
DTLayerId
Definition: DTLayerId.h:12
DTLayer.h
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
DTRecHit1D::localPosition
LocalPoint localPosition() const override
Return the 3-dimensional local position.
Definition: DTRecHit1D.h:47
edm::ParameterSet
Definition: ParameterSet.h:47
DTParametrizedDriftAlgo::DTParametrizedDriftAlgo
DTParametrizedDriftAlgo(const edm::ParameterSet &config)
Constructor.
Definition: DTParametrizedDriftAlgo.cc:27
LocalError
Definition: LocalError.h:12
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
makeMuonMisalignmentScenario.wheel
wheel
Definition: makeMuonMisalignmentScenario.py:319
DTTTrigBaseSync.h
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
HiCaloJetParameters_cff.interpolate
interpolate
Definition: HiCaloJetParameters_cff.py:34
MagneticField.h
edm::EventSetup
Definition: EventSetup.h:58
get
#define get
DTLayer
Definition: DTLayer.h:25
unit
Basic3DVector unit() const
Definition: Basic3DVectorLD.h:162
DTRecHit1D::digiTime
float digiTime() const
Return the time (ns) of the digi used to build the rechit.
Definition: DTRecHit1D.h:79
DTEnums::Right
Definition: DTEnums.h:15
DTTime2DriftParametrization::drift_distance
Structure used to return output values.
Definition: DTTime2DriftParametrization.h:27
std
Definition: JetResolutionObject.h:76
DTWireId.h
Exception
Definition: hltDiff.cc:245
angle
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11
DTDigi
Definition: DTDigi.h:17
EventSetup.h
DTTime2DriftParametrization.h
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterSet.h
DTTime2DriftParametrization::computeDriftDistance_mean
bool computeDriftDistance_mean(double time, double alpha, double by, double bz, short interpolate, drift_distance *dx) const
Definition: DTTime2DriftParametrization.cc:52
DTTime2DriftParametrization::drift_distance::v_drift
double v_drift
Definition: DTTime2DriftParametrization.h:28
DTChamberId::wheel
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
DTTime2DriftParametrization::drift_distance::x_width_m
double x_width_m
Definition: DTTime2DriftParametrization.h:28