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 
19  DTRecHitBaseAlgo(config),
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 
27 
28 
30 
31 
32 
34  // theSync->setES(setup);
35 }
36 
37 
38 
39 
40 // Build all hits in the range associated to the layerId, at the 1st step.
42  const DTLayerId& layerId,
43  const DTDigiCollection::Range& digiRange) {
45 
46  // Loop over all digis in the given range
47  for (DTDigiCollection::const_iterator digi = digiRange.first;
48  digi != digiRange.second;
49  digi++) {
50  // Get the wireId
51  DTWireId wireId(layerId, (*digi).wire());
52 
53  bool isDouble = false;
54  for (OwnVector<DTRecHit1DPair>::const_iterator doubleWireCheck = result.begin();
55  doubleWireCheck != result.end();
56  doubleWireCheck++) {
57  if( wireId == (*doubleWireCheck).wireId()) {
58  isDouble = true;
59  // std::cout << " Reject this hit with time " << (*digi).time() << std::endl;
60  break;
61  }
62  }
63 
64  if (isDouble) continue;
65 
66  LocalError tmpErr;
67  LocalPoint lpoint, rpoint;
68  // Call the compute method
69  bool OK = compute(layer, *digi, lpoint, rpoint, tmpErr);
70 
71  if (!OK) continue;
72 
73  // Build a new pair of 1D rechit
74  DTRecHit1DPair* recHitPair = new DTRecHit1DPair(wireId, *digi);
75 
76  // Set the position and the error of the 1D rechits
77  recHitPair->setPositionAndError(DTEnums::Left, lpoint, tmpErr);
78  recHitPair->setPositionAndError(DTEnums::Right, rpoint, tmpErr);
79 
80  result.push_back(recHitPair);
81  }
82  return result;
83 }
84 
85 
86 
87 
88 
89 // First Step
90 bool DTNoDriftAlgo::compute(const DTLayer* layer,
91  const DTDigi& digi,
92  LocalPoint& leftPoint,
93  LocalPoint& rightPoint,
94  LocalError& error) const {
95  // Get the wireId
96  DTLayerId layerId = layer->id();
97  const DTWireId wireId(layerId, digi.wire());
98 
99  // Get Wire position
100  if(!layer->specificTopology().isWireValid(digi.wire())) return false;
101  LocalPoint locWirePos(layer->specificTopology().wirePosition(digi.wire()), 0, 0);
102  const GlobalPoint globWirePos = layer->toGlobal(locWirePos);
103 
104  return compute(layer, wireId, digi.time(), globWirePos, leftPoint, rightPoint, error, 1);
105 }
106 
107 
108 
109 // Second step: the same as 1st step
110 bool DTNoDriftAlgo::compute(const DTLayer* layer,
111  const DTRecHit1D& recHit1D,
112  const float& angle,
113  DTRecHit1D& newHit1D) const {
114  newHit1D.setPositionAndError(recHit1D.localPosition(), recHit1D.localPositionError());
115  return true;
116 }
117 
118 
119 
120 // Third step.
121 bool DTNoDriftAlgo::compute(const DTLayer* layer,
122  const DTRecHit1D& recHit1D,
123  const float& angle,
124  const GlobalPoint& globPos,
125  DTRecHit1D& newHit1D) const {
126  return compute(layer, recHit1D.wireId(), recHit1D.digiTime(), globPos, newHit1D, 3);
127 }
128 
129 
130 
131 // Do the actual work.
132 bool DTNoDriftAlgo::compute(const DTLayer* layer,
133  const DTWireId& wireId,
134  const float digiTime,
135  const GlobalPoint& globPos,
136  LocalPoint& leftPoint,
137  LocalPoint& rightPoint,
138  LocalError& error,
139  int step) const {
140  //}
141 
142  // Small negative times interpreted as hits close to the wire.
143  //if (driftTime<0.) driftTime=0;
144 
145 
146  // check for out-of-time
147  if (digiTime < minTime || digiTime > maxTime) {
148  if (debug) cout << "[DTNoDriftAlgo]*** Drift time out of window for in-time hits "
149  << digiTime << endl;
150 
151  if(step == 1) { //FIXME: protection against failure at 2nd and 3rd steps, must be checked!!!
152  // Hits are interpreted as coming from out-of-time pile-up and recHit
153  // is ignored.
154  return false;
155  }
156  }
157 
158 
159  // Compute the drift distance
160  float drift = fixedDrift;
161 
162  // Get Wire position
163  if(!layer->specificTopology().isWireValid(wireId.wire())) return false;
164  LocalPoint locWirePos(layer->specificTopology().wirePosition(wireId.wire()), 0, 0);
165  //Build the two possible points and the error on the position
166  leftPoint = LocalPoint(locWirePos.x()-drift,
167  locWirePos.y(),
168  locWirePos.z());
169  rightPoint = LocalPoint(locWirePos.x()+drift,
170  locWirePos.y(),
171  locWirePos.z());
172  error = LocalError(hitResolution*hitResolution,0.,0.);
173 
174 
175  if(debug) {
176  cout << "[DTNoDriftAlgo] Compute drift distance, for digi at wire: " << wireId << endl
177  << " Step: " << step << endl
178  << " Digi time: " << digiTime << endl
179  // << " Drift time: " << driftTime << endl
180  << " Fixed Drift distance: " << drift << endl
181  << " Hit Resolution: " << hitResolution << endl
182  << " Left point: " << leftPoint << endl
183  << " Right point: " << rightPoint << endl
184  << " Error: " << error << endl;
185  }
186 
187 
188 
189  return true;
190 
191 }
192 
193 
194 // Interface to the method which does the actual work suited for 2nd and 3rd steps
195 bool DTNoDriftAlgo::compute(const DTLayer* layer,
196  const DTWireId& wireId,
197  const float digiTime,
198  const GlobalPoint& globPos,
199  DTRecHit1D& newHit1D,
200  int step) const {
201  LocalPoint leftPoint;
202  LocalPoint rightPoint;
204 
205  if(compute(layer, wireId, digiTime, globPos, leftPoint, rightPoint, error, step)) {
206  // Set the position and the error of the rechit which is being updated
207  switch(newHit1D.lrSide()) {
208 
209  case DTEnums::Left:
210  newHit1D.setPositionAndError(leftPoint, error);
211  break;
212 
213  case DTEnums::Right:
214  newHit1D.setPositionAndError(rightPoint, error);
215  break;
216 
217  default:
218  throw cms::Exception("InvalidDTCellSide") << "[DTNoDriftAlgo] Compute at Step "
219  << step << ", Hit side "
220  << newHit1D.lrSide()
221  << " is invalid!" << endl;
222  return false;
223  }
224 
225  return true;
226  }else {
227  return false;
228  }
229 }
float wirePosition(int wireNumber) const
Returns the x position in the layer of a given wire number.
Definition: DTTopology.cc:86
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:32
const float hitResolution
Definition: DTNoDriftAlgo.h:96
DTLayerId id() const
Return the DetId of this SL.
Definition: DTLayer.cc:46
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:54
LocalVector drift(const StripGeomDetUnit *, const MagneticField &, const SiStripLorentzAngle &)
Definition: ShallowTools.cc:38
T y() const
Definition: PV3DBase.h:63
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
const float fixedDrift
Definition: DTNoDriftAlgo.h:93
Definition: config.py:1
int wire() const
Return wire number.
Definition: DTDigi.cc:67
iterator begin()
Definition: OwnVector.h:244
const DTTopology & specificTopology() const
Definition: DTLayer.cc:42
void push_back(D *&d)
Definition: OwnVector.h:290
double time() const
Get time in ns.
Definition: DTDigi.cc:63
virtual bool compute(const DTLayer *layer, const DTDigi &digi, LocalPoint &leftPoint, LocalPoint &rightPoint, LocalError &error) const
void setPositionAndError(DTEnums::DTCellSide lrside, const LocalPoint &point, const LocalError &err)
T z() const
Definition: PV3DBase.h:64
float digiTime() const
Return the time (ns) of the digi used to build the rechit.
Definition: DTRecHit1D.h:113
virtual edm::OwnVector< DTRecHit1DPair > reconstruct(const DTLayer *layer, const DTLayerId &layerId, const DTDigiCollection::Range &digiRange)
Definition: DTDigi.h:17
virtual LocalError localPositionError() const
Return the 3-dimensional error on the local position.
Definition: DTRecHit1D.h:66
virtual LocalPoint localPosition() const
Return the 3-dimensional local position.
Definition: DTRecHit1D.h:60
int wire() const
Return the wire number.
Definition: DTWireId.h:56
std::pair< int, edm::FunctionWithDict > OK
Definition: findMethod.cc:136
iterator end()
Definition: OwnVector.h:249
#define debug
Definition: HDRShower.cc:19
std::vector< DTDigi >::const_iterator const_iterator
virtual ~DTNoDriftAlgo()
Destructor.
HLT enums.
bool isWireValid(const int wireNumber) const
Definition: DTTopology.h:65
const float maxTime
std::pair< const_iterator, const_iterator > Range
step
void setPositionAndError(LocalPoint pos, LocalError err)
Set the local position and its error.
Definition: DTRecHit1D.h:100
virtual void setES(const edm::EventSetup &setup)
Pass the Event Setup to the algo at each event.
T x() const
Definition: PV3DBase.h:62
DTNoDriftAlgo(const edm::ParameterSet &config)
Constructor.
DTEnums::DTCellSide lrSide() const
The side of the cell.
Definition: DTRecHit1D.h:82
const bool debug
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11
DTWireId wireId() const
Return the wireId.
Definition: DTRecHit1D.h:107