CMS 3D CMS Logo

DTNoDriftAlgo.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * \author Martijn Mulders - CERN (martijn.mulders@cern.ch)
5  * based on DTLinearDriftAlgo
6  */
7 
15 
16 using namespace std;
17 using namespace edm;
18 
21  fixedDrift(config.getParameter<double>("fixedDrift")),
22  hitResolution(config.getParameter<double>("hitResolution")), // Set to size of (half)cell
23  minTime(config.getParameter<double>("minTime")),
24  maxTime(config.getParameter<double>("maxTime")),
25  debug(config.getUntrackedParameter<bool>("debug")) // Set verbose output
26 {}
27 
29 
31  // theSync->setES(setup);
32 }
33 
34 // Build all hits in the range associated to the layerId, at the 1st step.
36  const DTLayerId& layerId,
37  const DTDigiCollection::Range& digiRange) {
39 
40  // Loop over all digis in the given range
41  for (DTDigiCollection::const_iterator digi = digiRange.first; digi != digiRange.second; digi++) {
42  // Get the wireId
43  DTWireId wireId(layerId, (*digi).wire());
44 
45  bool isDouble = false;
46  for (OwnVector<DTRecHit1DPair>::const_iterator doubleWireCheck = result.begin(); doubleWireCheck != result.end();
47  doubleWireCheck++) {
48  if (wireId == (*doubleWireCheck).wireId()) {
49  isDouble = true;
50  // std::cout << " Reject this hit with time " << (*digi).time() << std::endl;
51  break;
52  }
53  }
54 
55  if (isDouble)
56  continue;
57 
58  LocalError tmpErr;
59  LocalPoint lpoint, rpoint;
60  // Call the compute method
61  bool OK = compute(layer, *digi, lpoint, rpoint, tmpErr);
62 
63  if (!OK)
64  continue;
65 
66  // Build a new pair of 1D rechit
67  DTRecHit1DPair* recHitPair = new DTRecHit1DPair(wireId, *digi);
68 
69  // Set the position and the error of the 1D rechits
70  recHitPair->setPositionAndError(DTEnums::Left, lpoint, tmpErr);
71  recHitPair->setPositionAndError(DTEnums::Right, rpoint, tmpErr);
72 
73  result.push_back(recHitPair);
74  }
75  return result;
76 }
77 
78 // First Step
80  const DTLayer* layer, const DTDigi& digi, LocalPoint& leftPoint, LocalPoint& rightPoint, LocalError& error) const {
81  // Get the wireId
82  DTLayerId layerId = layer->id();
83  const DTWireId wireId(layerId, digi.wire());
84 
85  // Get Wire position
86  if (!layer->specificTopology().isWireValid(digi.wire()))
87  return false;
88  LocalPoint locWirePos(layer->specificTopology().wirePosition(digi.wire()), 0, 0);
89  const GlobalPoint globWirePos = layer->toGlobal(locWirePos);
90 
91  return compute(layer, wireId, digi.time(), globWirePos, leftPoint, rightPoint, error, 1);
92 }
93 
94 // Second step: the same as 1st step
96  const DTRecHit1D& recHit1D,
97  const float& angle,
98  DTRecHit1D& newHit1D) const {
99  newHit1D.setPositionAndError(recHit1D.localPosition(), recHit1D.localPositionError());
100  return true;
101 }
102 
103 // Third step.
105  const DTRecHit1D& recHit1D,
106  const float& angle,
107  const GlobalPoint& globPos,
108  DTRecHit1D& newHit1D) const {
109  return compute(layer, recHit1D.wireId(), recHit1D.digiTime(), globPos, newHit1D, 3);
110 }
111 
112 // Do the actual work.
114  const DTWireId& wireId,
115  const float digiTime,
116  const GlobalPoint& globPos,
117  LocalPoint& leftPoint,
118  LocalPoint& rightPoint,
119  LocalError& error,
120  int step) const {
121  //}
122 
123  // Small negative times interpreted as hits close to the wire.
124  //if (driftTime<0.) driftTime=0;
125 
126  // check for out-of-time
127  if (digiTime < minTime || digiTime > maxTime) {
128  if (debug)
129  cout << "[DTNoDriftAlgo]*** Drift time out of window for in-time hits " << digiTime << endl;
130 
131  if (step == 1) { //FIXME: protection against failure at 2nd and 3rd steps, must be checked!!!
132  // Hits are interpreted as coming from out-of-time pile-up and recHit
133  // is ignored.
134  return false;
135  }
136  }
137 
138  // Compute the drift distance
139  float drift = fixedDrift;
140 
141  // Get Wire position
142  if (!layer->specificTopology().isWireValid(wireId.wire()))
143  return false;
144  LocalPoint locWirePos(layer->specificTopology().wirePosition(wireId.wire()), 0, 0);
145  //Build the two possible points and the error on the position
146  leftPoint = LocalPoint(locWirePos.x() - drift, locWirePos.y(), locWirePos.z());
147  rightPoint = LocalPoint(locWirePos.x() + drift, locWirePos.y(), locWirePos.z());
149 
150  if (debug) {
151  cout << "[DTNoDriftAlgo] Compute drift distance, for digi at wire: " << wireId << endl
152  << " Step: " << step << endl
153  << " Digi time: " << digiTime
154  << endl
155  // << " Drift time: " << driftTime << endl
156  << " Fixed Drift distance: " << drift << endl
157  << " Hit Resolution: " << hitResolution << endl
158  << " Left point: " << leftPoint << endl
159  << " Right point: " << rightPoint << endl
160  << " Error: " << error << endl;
161  }
162 
163  return true;
164 }
165 
166 // Interface to the method which does the actual work suited for 2nd and 3rd steps
168  const DTWireId& wireId,
169  const float digiTime,
170  const GlobalPoint& globPos,
171  DTRecHit1D& newHit1D,
172  int step) const {
173  LocalPoint leftPoint;
174  LocalPoint rightPoint;
176 
177  if (compute(layer, wireId, digiTime, globPos, leftPoint, rightPoint, error, step)) {
178  // Set the position and the error of the rechit which is being updated
179  switch (newHit1D.lrSide()) {
180  case DTEnums::Left:
181  newHit1D.setPositionAndError(leftPoint, error);
182  break;
183 
184  case DTEnums::Right:
185  newHit1D.setPositionAndError(rightPoint, error);
186  break;
187 
188  default:
189  throw cms::Exception("InvalidDTCellSide") << "[DTNoDriftAlgo] Compute at Step " << step << ", Hit side "
190  << newHit1D.lrSide() << " is invalid!" << endl;
191  return false;
192  }
193 
194  return true;
195  } else {
196  return false;
197  }
198 }
void setES(const edm::EventSetup &setup) override
Pass the Event Setup to the algo at each event.
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
const float hitResolution
Definition: DTNoDriftAlgo.h:87
int wire() const
Return the wire number.
Definition: DTWireId.h:45
T z() const
Definition: PV3DBase.h:61
edm::OwnVector< DTRecHit1DPair > reconstruct(const DTLayer *layer, const DTLayerId &layerId, const DTDigiCollection::Range &digiRange) override
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
LocalVector drift(const StripGeomDetUnit *, const MagneticField &, const SiStripLorentzAngle &)
Definition: ShallowTools.cc:36
const float fixedDrift
Definition: DTNoDriftAlgo.h:84
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
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
void setPositionAndError(DTEnums::DTCellSide lrside, const LocalPoint &point, const LocalError &err)
DTEnums::DTCellSide lrSide() const
The side of the cell.
Definition: DTRecHit1D.h:61
Definition: DTDigi.h:17
~DTNoDriftAlgo() override
Destructor.
std::pair< int, edm::FunctionWithDict > OK
Definition: findMethod.cc:126
#define debug
Definition: HDRShower.cc:19
std::pair< const_iterator, const_iterator > Range
std::vector< DigiType >::const_iterator const_iterator
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
const float maxTime
Definition: DTNoDriftAlgo.h:93
DTNoDriftAlgo(const edm::ParameterSet &config, edm::ConsumesCollector)
Constructor.
step
Definition: StallMonitor.cc:83
void setPositionAndError(LocalPoint pos, LocalError err)
Set the local position and its error.
Definition: DTRecHit1D.h:70
bool compute(const DTLayer *layer, const DTDigi &digi, LocalPoint &leftPoint, LocalPoint &rightPoint, LocalError &error) const override
LocalPoint localPosition() const override
Return the 3-dimensional local position.
Definition: DTRecHit1D.h:47
const bool debug
Definition: DTNoDriftAlgo.h:96
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11