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