CMS 3D CMS Logo

DTLinearDriftAlgo.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 
15 
16 using namespace std;
17 using namespace edm;
18 
20  : DTRecHitBaseAlgo(config, cc),
21  // Get the Drift Velocity from parameter set.
22  vDrift(config.getParameter<double>("driftVelocity")), // FIXME: Default was 0.00543 cm/ns
23  hitResolution(config.getParameter<double>("hitResolution")), // FIXME: Default is
24  // vDriftMB1W1(config.getParameter<double>("driftVelocityMB1W1")), // FIXME: Default was 0.00543 cm/ns
25  minTime(config.getParameter<double>("minTime")), // FIXME: Default was -3 ns
26  maxTime(config.getParameter<double>("maxTime")), // FIXME: Default was 415 ns
27  // Set verbose output
28  debug(config.getUntrackedParameter<bool>("debug")) {}
29 
31 
33 
34 // First Step
36  const DTLayer* layer, const DTDigi& digi, LocalPoint& leftPoint, LocalPoint& rightPoint, LocalError& error) const {
37  // Get the wireId
38  DTLayerId layerId = layer->id();
39  const DTWireId wireId(layerId, digi.wire());
40 
41  // Get Wire position
42  if (!layer->specificTopology().isWireValid(digi.wire()))
43  return false;
44  LocalPoint locWirePos(layer->specificTopology().wirePosition(digi.wire()), 0, 0);
45  const GlobalPoint globWirePos = layer->toGlobal(locWirePos);
46 
47  return compute(layer, wireId, digi.time(), globWirePos, leftPoint, rightPoint, error, 1);
48 }
49 
50 // Second step: the same as 1st step
52  const DTRecHit1D& recHit1D,
53  const float& angle,
54  DTRecHit1D& newHit1D) const {
55  newHit1D.setPositionAndError(recHit1D.localPosition(), recHit1D.localPositionError());
56  return true;
57 }
58 
59 // Third step.
61  const DTRecHit1D& recHit1D,
62  const float& angle,
63  const GlobalPoint& globPos,
64  DTRecHit1D& newHit1D) const {
65  return compute(layer, recHit1D.wireId(), recHit1D.digiTime(), globPos, newHit1D, 3);
66 }
67 
68 // Do the actual work.
70  const DTWireId& wireId,
71  const float digiTime,
72  const GlobalPoint& globPos,
73  LocalPoint& leftPoint,
74  LocalPoint& rightPoint,
76  int step) const {
77  // Subtract the offset to the digi time accordingly to the DTTTrigBaseSync concrete instance
78  float driftTime = digiTime - theSync->offset(layer, wireId, globPos);
79 
80  // check for out-of-time
81  if (driftTime < minTime || driftTime > maxTime) {
82  if (debug)
83  cout << "[DTLinearDriftAlgo]*** Drift time out of window for in-time hits " << driftTime << endl;
84 
85  if (step == 1) { //FIXME: protection against failure at 2nd and 3rd steps, must be checked!!!
86  // Hits are interpreted as coming from out-of-time pile-up and recHit
87  // is ignored.
88  return false;
89  }
90  }
91 
92  // Small negative times interpreted as hits close to the wire.
93  if (driftTime < 0.)
94  driftTime = 0;
95 
96  // Compute the drift distance
97  // SL 21-Dec-2006: Use specific Drift for MB1W1 (non fluxed chamber)
98  float vd = vDrift;
99  // if (wireId.wheel()==1 && wireId.station()==1) {
100  // vd=vDriftMB1W1;
101  // //cout << "Using Vd " << vd<< endl;
102  // }
103 
104  float drift = driftTime * vd;
105 
106  // Get Wire position
107  if (!layer->specificTopology().isWireValid(wireId.wire()))
108  return false;
109  LocalPoint locWirePos(layer->specificTopology().wirePosition(wireId.wire()), 0, 0);
110  //Build the two possible points and the error on the position
111  leftPoint = LocalPoint(locWirePos.x() - drift, locWirePos.y(), locWirePos.z());
112  rightPoint = LocalPoint(locWirePos.x() + drift, locWirePos.y(), locWirePos.z());
114 
115  if (debug) {
116  cout << "[DTLinearDriftAlgo] Compute drift distance, for digi at wire: " << wireId << endl
117  << " Step: " << step << endl
118  << " Digi time: " << digiTime << endl
119  << " Drift time: " << driftTime << endl
120  << " Drift distance: " << drift << endl
121  << " Hit Resolution: " << hitResolution << endl
122  << " Left point: " << leftPoint << endl
123  << " Right point: " << rightPoint << endl
124  << " Error: " << error << endl;
125  }
126 
127  return true;
128 }
129 
130 // Interface to the method which does the actual work suited for 2nd and 3rd steps
132  const DTWireId& wireId,
133  const float digiTime,
134  const GlobalPoint& globPos,
135  DTRecHit1D& newHit1D,
136  int step) const {
137  LocalPoint leftPoint;
138  LocalPoint rightPoint;
140 
141  if (compute(layer, wireId, digiTime, globPos, leftPoint, rightPoint, error, step)) {
142  // Set the position and the error of the rechit which is being updated
143  switch (newHit1D.lrSide()) {
144  case DTEnums::Left: {
145  // Keep the original y position of newHit1D: for step==3, it's the
146  // position along the wire. Needed for rotation alignment
147  LocalPoint leftPoint3D(leftPoint.x(), newHit1D.localPosition().y(), leftPoint.z());
148  newHit1D.setPositionAndError(leftPoint3D, error);
149  break;
150  }
151 
152  case DTEnums::Right: {
153  // as above: 3d position
154  LocalPoint rightPoint3D(rightPoint.x(), newHit1D.localPosition().y(), rightPoint.z());
155  newHit1D.setPositionAndError(rightPoint3D, error);
156  break;
157  }
158 
159  default:
160  throw cms::Exception("InvalidDTCellSide") << "[DTLinearDriftAlgo] Compute at Step " << step << ", Hit side "
161  << newHit1D.lrSide() << " is invalid!" << endl;
162  return false;
163  }
164 
165  return true;
166  } else {
167  return false;
168  }
169 }
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
void setES(const edm::EventSetup &setup) override
Pass the Event Setup to the algo at each event.
int wire() const
Return the wire number.
Definition: DTWireId.h:42
T z() const
Definition: PV3DBase.h:61
LocalVector drift(const StripGeomDetUnit *, const MagneticField &, const SiStripLorentzAngle &)
Definition: ShallowTools.cc:36
Definition: config.py:1
int wire() const
Return wire number.
Definition: DTDigi.cc:41
float digiTime() const
Return the time (ns) of the digi used to build the rechit.
Definition: DTRecHit1D.h:79
constexpr std::array< uint8_t, layerIndexSize > layer
double time() const
Get time in ns.
Definition: DTDigi.cc:37
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
~DTLinearDriftAlgo() override
Destructor.
DTEnums::DTCellSide lrSide() const
The side of the cell.
Definition: DTRecHit1D.h:61
Definition: DTDigi.h:17
std::vector< DeviationSensor2D * > vd
const float hitResolution
#define debug
Definition: HDRShower.cc:19
std::unique_ptr< DTTTrigBaseSync > theSync
DTLinearDriftAlgo(const edm::ParameterSet &config, edm::ConsumesCollector)
Constructor.
LocalError localPositionError() const override
Return the 3-dimensional error on the local position.
Definition: DTRecHit1D.h:50
HLT enums.
DTWireId wireId() const
Return the wireId.
Definition: DTRecHit1D.h:76
bool compute(const DTLayer *layer, const DTDigi &digi, LocalPoint &leftPoint, LocalPoint &rightPoint, LocalError &error) const override
step
Definition: StallMonitor.cc:98
void setPositionAndError(LocalPoint pos, LocalError err)
Set the local position and its error.
Definition: DTRecHit1D.h:70
LocalPoint localPosition() const override
Return the 3-dimensional local position.
Definition: DTRecHit1D.h:47
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11