CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTNoDriftAlgo.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * $Date: 2009/04/30 09:30:06 $
5  * $Revision: 1.2 $
6  * \author Martijn Mulders - CERN (martijn.mulders@cern.ch)
7  * based on DTLinearDriftAlgo
8  */
9 
16 
17 using namespace std;
18 using namespace edm;
19 
21  DTRecHitBaseAlgo(config) {
22 
23  minTime = config.getParameter<double>("minTime");
24 
25  maxTime = config.getParameter<double>("maxTime");
26 
27  fixedDrift = config.getParameter<double>("fixedDrift");
28 
29  hitResolution = config.getParameter<double>("hitResolution"); // Set to size of (half)cell
30  // Set verbose output
31  debug = config.getUntrackedParameter<bool>("debug");
32 
33  }
34 
35 
36 
38 
39 
40 
42  // theSync->setES(setup);
43 }
44 
45 
46 
47 
48 // Build all hits in the range associated to the layerId, at the 1st step.
50  const DTLayerId& layerId,
51  const DTDigiCollection::Range& digiRange) {
53 
54  // Loop over all digis in the given range
55  for (DTDigiCollection::const_iterator digi = digiRange.first;
56  digi != digiRange.second;
57  digi++) {
58  // Get the wireId
59  DTWireId wireId(layerId, (*digi).wire());
60 
61  bool isDouble = false;
62  for (OwnVector<DTRecHit1DPair>::const_iterator doubleWireCheck = result.begin();
63  doubleWireCheck != result.end();
64  doubleWireCheck++) {
65  if( wireId == (*doubleWireCheck).wireId()) {
66  isDouble = true;
67  // std::cout << " Reject this hit with time " << (*digi).time() << std::endl;
68  break;
69  }
70  }
71 
72  if (isDouble) continue;
73 
74  LocalError tmpErr;
75  LocalPoint lpoint, rpoint;
76  // Call the compute method
77  bool OK = compute(layer, *digi, lpoint, rpoint, tmpErr);
78 
79  if (!OK) continue;
80 
81  // Build a new pair of 1D rechit
82  DTRecHit1DPair* recHitPair = new DTRecHit1DPair(wireId, *digi);
83 
84  // Set the position and the error of the 1D rechits
85  recHitPair->setPositionAndError(DTEnums::Left, lpoint, tmpErr);
86  recHitPair->setPositionAndError(DTEnums::Right, rpoint, tmpErr);
87 
88  result.push_back(recHitPair);
89  }
90  return result;
91 }
92 
93 
94 
95 
96 
97 // First Step
98 bool DTNoDriftAlgo::compute(const DTLayer* layer,
99  const DTDigi& digi,
100  LocalPoint& leftPoint,
101  LocalPoint& rightPoint,
102  LocalError& error) const {
103  // Get the wireId
104  DTLayerId layerId = layer->id();
105  const DTWireId wireId(layerId, digi.wire());
106 
107  // Get Wire position
108  if(!layer->specificTopology().isWireValid(digi.wire())) return false;
109  LocalPoint locWirePos(layer->specificTopology().wirePosition(digi.wire()), 0, 0);
110  const GlobalPoint globWirePos = layer->toGlobal(locWirePos);
111 
112  return compute(layer, wireId, digi.time(), globWirePos, leftPoint, rightPoint, error, 1);
113 }
114 
115 
116 
117 // Second step: the same as 1st step
118 bool DTNoDriftAlgo::compute(const DTLayer* layer,
119  const DTRecHit1D& recHit1D,
120  const float& angle,
121  DTRecHit1D& newHit1D) const {
122  newHit1D.setPositionAndError(recHit1D.localPosition(), recHit1D.localPositionError());
123  return true;
124 }
125 
126 
127 
128 // Third step.
129 bool DTNoDriftAlgo::compute(const DTLayer* layer,
130  const DTRecHit1D& recHit1D,
131  const float& angle,
132  const GlobalPoint& globPos,
133  DTRecHit1D& newHit1D) const {
134  return compute(layer, recHit1D.wireId(), recHit1D.digiTime(), globPos, newHit1D, 3);
135 }
136 
137 
138 
139 // Do the actual work.
140 bool DTNoDriftAlgo::compute(const DTLayer* layer,
141  const DTWireId& wireId,
142  const float digiTime,
143  const GlobalPoint& globPos,
144  LocalPoint& leftPoint,
145  LocalPoint& rightPoint,
146  LocalError& error,
147  int step) const {
148  //}
149 
150  // Small negative times interpreted as hits close to the wire.
151  //if (driftTime<0.) driftTime=0;
152 
153 
154  // check for out-of-time
155  if (digiTime < minTime || digiTime > maxTime) {
156  if (debug) cout << "[DTNoDriftAlgo]*** Drift time out of window for in-time hits "
157  << digiTime << endl;
158 
159  if(step == 1) { //FIXME: protection against failure at 2nd and 3rd steps, must be checked!!!
160  // Hits are interpreted as coming from out-of-time pile-up and recHit
161  // is ignored.
162  return false;
163  }
164  }
165 
166 
167  // Compute the drift distance
168  float drift = fixedDrift;
169 
170  // Get Wire position
171  if(!layer->specificTopology().isWireValid(wireId.wire())) return false;
172  LocalPoint locWirePos(layer->specificTopology().wirePosition(wireId.wire()), 0, 0);
173  //Build the two possible points and the error on the position
174  leftPoint = LocalPoint(locWirePos.x()-drift,
175  locWirePos.y(),
176  locWirePos.z());
177  rightPoint = LocalPoint(locWirePos.x()+drift,
178  locWirePos.y(),
179  locWirePos.z());
180  error = LocalError(hitResolution*hitResolution,0.,0.);
181 
182 
183  if(debug) {
184  cout << "[DTNoDriftAlgo] Compute drift distance, for digi at wire: " << wireId << endl
185  << " Step: " << step << endl
186  << " Digi time: " << digiTime << endl
187  // << " Drift time: " << driftTime << endl
188  << " Fixed Drift distance: " << drift << endl
189  << " Hit Resolution: " << hitResolution << endl
190  << " Left point: " << leftPoint << endl
191  << " Right point: " << rightPoint << endl
192  << " Error: " << error << endl;
193  }
194 
195 
196 
197  return true;
198 
199 }
200 
201 
202 // Interface to the method which does the actual work suited for 2nd and 3rd steps
203 bool DTNoDriftAlgo::compute(const DTLayer* layer,
204  const DTWireId& wireId,
205  const float digiTime,
206  const GlobalPoint& globPos,
207  DTRecHit1D& newHit1D,
208  int step) const {
209  LocalPoint leftPoint;
210  LocalPoint rightPoint;
212 
213  if(compute(layer, wireId, digiTime, globPos, leftPoint, rightPoint, error, step)) {
214  // Set the position and the error of the rechit which is being updated
215  switch(newHit1D.lrSide()) {
216 
217  case DTEnums::Left:
218  newHit1D.setPositionAndError(leftPoint, error);
219  break;
220 
221  case DTEnums::Right:
222  newHit1D.setPositionAndError(rightPoint, error);
223  break;
224 
225  default:
226  throw cms::Exception("InvalidDTCellSide") << "[DTNoDriftAlgo] Compute at Step "
227  << step << ", Hit side "
228  << newHit1D.lrSide()
229  << " is invalid!" << endl;
230  return false;
231  }
232 
233  return true;
234  }else {
235  return false;
236  }
237 }
238 
239 
241 
242 
244 
245 
247 
248 
250 
251 
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
float wirePosition(int wireNumber) const
Returns the x position in the layer of a given wire number.
Definition: DTTopology.cc:88
static bool debug
list step
Definition: launcher.py:15
DTLayerId id() const
Return the DetId of this SL.
Definition: DTLayer.cc:48
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:47
LocalVector drift(const StripGeomDetUnit *, const MagneticField &, const SiStripLorentzAngle &)
Definition: ShallowTools.cc:39
T y() const
Definition: PV3DBase.h:62
int wire() const
Return wire number.
Definition: DTDigi.cc:69
iterator begin()
Definition: OwnVector.h:227
const DTTopology & specificTopology() const
Definition: DTLayer.cc:44
static float maxTime
void push_back(D *&d)
Definition: OwnVector.h:273
double time() const
Get time in ns.
Definition: DTDigi.cc:65
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:63
tuple result
Definition: query.py:137
float digiTime() const
Return the time (ns) of the digi used to build the rechit.
Definition: DTRecHit1D.h:115
virtual edm::OwnVector< DTRecHit1DPair > reconstruct(const DTLayer *layer, const DTLayerId &layerId, const DTDigiCollection::Range &digiRange)
Definition: DTDigi.h:19
virtual LocalError localPositionError() const
Return the 3-dimensional error on the local position.
Definition: DTRecHit1D.h:68
virtual LocalPoint localPosition() const
Return the 3-dimensional local position.
Definition: DTRecHit1D.h:62
int wire() const
Return the wire number.
Definition: DTWireId.h:58
iterator end()
Definition: OwnVector.h:232
std::vector< DigiType >::const_iterator const_iterator
virtual ~DTNoDriftAlgo()
Destructor.
bool isWireValid(const int wireNumber) const
Definition: DTTopology.h:67
static float hitResolution
Definition: DTNoDriftAlgo.h:98
Local3DPoint LocalPoint
Definition: LocalPoint.h:11
tuple cout
Definition: gather_cfg.py:121
std::pair< const_iterator, const_iterator > Range
void setPositionAndError(LocalPoint pos, LocalError err)
Set the local position and its error.
Definition: DTRecHit1D.h:102
virtual void setES(const edm::EventSetup &setup)
Pass the Event Setup to the algo at each event.
static float fixedDrift
Definition: DTNoDriftAlgo.h:95
T x() const
Definition: PV3DBase.h:61
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
DTNoDriftAlgo(const edm::ParameterSet &config)
Constructor.
DTEnums::DTCellSide lrSide() const
The side of the cell.
Definition: DTRecHit1D.h:84
static float minTime
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:109