CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTLinearDriftFromDBAlgo.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * $Date: 2011/02/22 16:23:00 $
5  * $Revision: 1.8 $
6  * \author S. Bolognesi - INFN Torino
7  */
8 
19 
20 using namespace std;
21 using namespace edm;
22 
24  DTRecHitBaseAlgo(config) {
25 
26  minTime = config.getParameter<double>("minTime");
27 
28  maxTime = config.getParameter<double>("maxTime");
29 
30  doVdriftCorr = config.getParameter<bool>("doVdriftCorr");
31 
32  // Option to force going back to digi time at Step 2
33  stepTwoFromDigi = config.getParameter<bool>("stepTwoFromDigi");
34 
35  // Set verbose output
36  debug = config.getUntrackedParameter<bool>("debug");
37  if(debug)
38  cout<<"[DTLinearDriftFromDBAlgo] Constructor called"<<endl;
39  }
40 
41 
42 
44 
45 
46 
48  if(debug)
49  cout<<"[DTLinearDriftFromDBAlgo] setES called"<<endl;
50  theSync->setES(setup);
51  // Get the map of ttrig from the Setup
52  ESHandle<DTMtime> mTimeHandle;
53  setup.get<DTMtimeRcd>().get(mTimeHandle);
54  mTimeMap = &*mTimeHandle;
55 
56  if(debug)
57  cout << "[DTLinearDriftFromDBAlgo] meanTimer version: " << mTimeMap->version()<<endl;
58 }
59 
60 
61 
62 // First Step
64  const DTDigi& digi,
65  LocalPoint& leftPoint,
66  LocalPoint& rightPoint,
67  LocalError& error) const {
68  // Get the wireId
69  DTLayerId layerId = layer->id();
70  const DTWireId wireId(layerId, digi.wire());
71 
72  // Get Wire position
73  if(!layer->specificTopology().isWireValid(digi.wire())) return false;
74  LocalPoint locWirePos(layer->specificTopology().wirePosition(digi.wire()), 0, 0);
75  const GlobalPoint globWirePos = layer->toGlobal(locWirePos);
76 
77  return compute(layer, wireId, digi.time(), globWirePos, leftPoint, rightPoint, error, 1);
78 }
79 
80 
81 
82 // Second step: the same as 1st step (optionally, redo 1st step starting from digi time)
84  const DTRecHit1D& recHit1D,
85  const float& angle,
86  DTRecHit1D& newHit1D) const {
87 
88  if (!stepTwoFromDigi) {
89  newHit1D.setPositionAndError(recHit1D.localPosition(), recHit1D.localPositionError());
90  return true;
91  }
92 
93  const DTWireId wireId = recHit1D.wireId();
94 
95  // Get Wire position
96  if(!layer->specificTopology().isWireValid(wireId.wire())) return false;
97  LocalPoint locWirePos(layer->specificTopology().wirePosition(wireId.wire()), 0, 0);
98  const GlobalPoint globWirePos = layer->toGlobal(locWirePos);
99 
100  return compute(layer, wireId, recHit1D.digiTime(), globWirePos, newHit1D, 2);
101 
102 }
103 
104 
105 
106 // Third step.
108  const DTRecHit1D& recHit1D,
109  const float& angle,
110  const GlobalPoint& globPos,
111  DTRecHit1D& newHit1D) const {
112  return compute(layer, recHit1D.wireId(), recHit1D.digiTime(), globPos, newHit1D, 3);
113 }
114 
115 
116 
117 // Do the actual work.
119  const DTWireId& wireId,
120  const float digiTime,
121  const GlobalPoint& globPos,
122  LocalPoint& leftPoint,
123  LocalPoint& rightPoint,
124  LocalError& error,
125  int step) const {
126  // Subtract the offset to the digi time accordingly to the DTTTrigBaseSync concrete instance
127  float driftTime = digiTime - theSync->offset(layer, wireId, globPos);
128 
129  // check for out-of-time
130  if (driftTime < minTime || driftTime > maxTime) {
131  if (debug) cout << "[DTLinearDriftFromDBAlgo]*** Drift time out of window for in-time hits "
132  << driftTime << endl;
133 
134  if(step == 1) { //FIXME: protection against failure at 2nd and 3rd steps, must be checked!!!
135  // Hits are interpreted as coming from out-of-time pile-up and recHit
136  // is ignored.
137  return false;
138  }
139  }
140 
141  // Small negative times interpreted as hits close to the wire.
142  if (driftTime<0.) driftTime=0;
143 
144  // Read the vDrift and reso for this wire
145  float vDrift = 0;
146  float hitResolution = 0;//FIXME: should use this!
147  // vdrift is cm/ns , resolution is cm
148  mTimeMap->get(wireId.superlayerId(),
149  vDrift,
150  hitResolution,
152 
153  //only in step 3
154  if(doVdriftCorr && step == 3){
155  if (abs(wireId.wheel()) == 2 &&
156  wireId.station() == 1 &&
157  wireId.superLayer() != 2) {
158  // Variation of vdrift along Y due to B field,
160  // vdrift is lower a negative Y (lower global |Z|)
161  const float k_param = 1.2e-04;
162  LocalPoint local_pos = layer->toLocal(globPos);
163  vDrift = vDrift*(1. - k_param*local_pos.y());
164  }
165  }
166 
167  // Compute the drift distance
168  float drift = driftTime * vDrift;
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 << "[DTLinearDriftFromDBAlgo] Compute drift distance, for digi at wire: " << wireId << endl
185  << " Step: " << step << endl
186  << " Digi time: " << digiTime << endl
187  << " Drift time: " << driftTime << endl
188  << " 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  return true;
196 
197 }
198 
199 
200 // Interface to the method which does the actual work suited for 2nd and 3rd steps
202  const DTWireId& wireId,
203  const float digiTime,
204  const GlobalPoint& globPos,
205  DTRecHit1D& newHit1D,
206  int step) const {
207  LocalPoint leftPoint;
208  LocalPoint rightPoint;
210 
211  if(compute(layer, wireId, digiTime, globPos, leftPoint, rightPoint, error, step)) {
212  // Set the position and the error of the rechit which is being updated
213  switch(newHit1D.lrSide()) {
214 
215  case DTEnums::Left:
216  {
217  // Keep the original y position of newHit1D: for step==3, it's the
218  // position along the wire. Needed for rotation alignment
219  LocalPoint leftPoint3D(leftPoint.x(), newHit1D.localPosition().y(), leftPoint.z());
220  newHit1D.setPositionAndError(leftPoint3D, error);
221  break;
222  }
223 
224  case DTEnums::Right:
225  {
226  // as above: 3d position
227  LocalPoint rightPoint3D(rightPoint.x(), newHit1D.localPosition().y(), rightPoint.z());
228  newHit1D.setPositionAndError(rightPoint3D, error);
229  break;
230  }
231 
232  default:
233  throw cms::Exception("InvalidDTCellSide") << "[DTLinearDriftFromDBAlgo] Compute at Step "
234  << step << ", Hit side "
235  << newHit1D.lrSide()
236  << " is invalid!" << endl;
237  return false;
238  }
239 
240  return true;
241  }else {
242  return false;
243  }
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
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
double offset(const DTLayer *layer, const DTWireId &wireId, const GlobalPoint &globalPos)
virtual bool compute(const DTLayer *layer, const DTDigi &digi, LocalPoint &leftPoint, LocalPoint &rightPoint, LocalError &error) const
LocalVector drift(const StripGeomDetUnit *, const MagneticField &, const SiStripLorentzAngle &)
Definition: ShallowTools.cc:39
T y() const
Definition: PV3DBase.h:62
#define abs(x)
Definition: mlp_lapack.h:159
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:62
int wire() const
Return wire number.
Definition: DTDigi.cc:69
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
Definition: DTLayerId.h:61
virtual void setES(const edm::EventSetup &setup)=0
Pass the Event Setup to the synchronization module at each event.
const DTTopology & specificTopology() const
Definition: DTLayer.cc:44
double time() const
Get time in ns.
Definition: DTDigi.cc:65
T z() const
Definition: PV3DBase.h:63
int superLayer() const
Return the superlayer number.
virtual ~DTLinearDriftFromDBAlgo()
Destructor.
float digiTime() const
Return the time (ns) of the digi used to build the rechit.
Definition: DTRecHit1D.h:115
virtual void setES(const edm::EventSetup &setup)
Pass the Event Setup to the algo at each event.
Definition: DTDigi.h:19
virtual LocalError localPositionError() const
Return the 3-dimensional error on the local position.
Definition: DTRecHit1D.h:68
DTTTrigBaseSync * theSync
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
DTLinearDriftFromDBAlgo(const edm::ParameterSet &config)
Constructor.
const T & get() const
Definition: EventSetup.h:55
const std::string & version() const
access version
Definition: DTMtime.cc:247
int get(int wheelId, int stationId, int sectorId, int slId, float &mTime, float &mTrms, DTTimeUnits::type unit) const
Definition: DTMtime.cc:86
bool isWireValid(const int wireNumber) const
Definition: DTTopology.h:67
Local3DPoint LocalPoint
Definition: LocalPoint.h:11
tuple cout
Definition: gather_cfg.py:121
void setPositionAndError(LocalPoint pos, LocalError err)
Set the local position and its error.
Definition: DTRecHit1D.h:102
int station() const
Return the station number.
Definition: DTChamberId.h:53
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:47
T x() const
Definition: PV3DBase.h:61
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
DTEnums::DTCellSide lrSide() const
The side of the cell.
Definition: DTRecHit1D.h:84
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