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