CMS 3D CMS Logo

DTTTrigSyncFromDB.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * \author G. Cerminara - INFN Torino
5  */
6 
7 #include "DTTTrigSyncFromDB.h"
8 
9 
20 
21 #include <iostream>
22 
23 using namespace std;
24 using namespace edm;
25 
26 
28 : debug(config.getUntrackedParameter<bool>("debug")),
29  // The velocity of signal propagation along the wire (cm/ns)
30  theVPropWire(config.getParameter<double>("vPropWire")),
31  // Switch on/off the T0 correction from pulses
32  doT0Correction(config.getParameter<bool>("doT0Correction")),
33  // Switch on/off the TOF correction for particles from IP
34  doTOFCorrection(config.getParameter<bool>("doTOFCorrection")),
35  theTOFCorrType(config.getParameter<int>("tofCorrType")),
36  // Switch on/off the correction for the signal propagation along the wire
37  doWirePropCorrection(config.getParameter<bool>("doWirePropCorrection")),
38  theWirePropCorrType(config.getParameter<int>("wirePropCorrType")),
39  // spacing of BX in ns
40  theBXspace(config.getUntrackedParameter<double>("bxSpace", 25.)),
41  thetTrigLabel(config.getParameter<string>("tTrigLabel"))
42 {
43 }
44 
45 
46 
48 
49 
50 
52  if(doT0Correction)
53  {
54  // Get the map of t0 from pulses from the Setup
55  ESHandle<DTT0> t0Handle;
56  setup.get<DTT0Rcd>().get(t0Handle);
57  tZeroMap = &*t0Handle;
58  if(debug) {
59  cout << "[DTTTrigSyncFromDB] t0 version: " << tZeroMap->version()<<endl;
60  }
61  }
62 
63  // Get the map of ttrig from the Setup
64  ESHandle<DTTtrig> ttrigHandle;
65  setup.get<DTTtrigRcd>().get(thetTrigLabel,ttrigHandle);
66  tTrigMap = &*ttrigHandle;
67  if(debug) {
68  cout << "[DTTTrigSyncFromDB] ttrig version: " << tTrigMap->version() << endl;
69  }
70 }
71 
72 
73 double DTTTrigSyncFromDB::offset(const DTLayer* layer,
74  const DTWireId& wireId,
75  const GlobalPoint& globPos,
76  double& tTrig,
77  double& wirePropCorr,
78  double& tofCorr) {
79  // Correction for the float to int conversion while writeing the ttrig in ns into an int variable
80  // (half a bin on average)
81  // FIXME: this should disappear as soon as the ttrig object will become a float
82  // static const float f2i_convCorr = (25./64.); // ns //FIXME: check how the conversion is performed
83 
84  tTrig = offset(wireId);
85 
86  // Compute the time spent in signal propagation along wire.
87  // NOTE: the FE is always at y>0
88  wirePropCorr = 0;
90  switch(theWirePropCorrType){
91  // The ttrig computed from the timebox accounts on average for the signal propagation time
92  // from the center of the wire to the frontend. Here we just have to correct for
93  // the distance of the hit from the wire center.
94  case 0: {
95  float wireCoord = layer->toLocal(globPos).y();
96  wirePropCorr = -wireCoord/theVPropWire;
97  break;
98  // FIXME: What if hits used for the time box are not distributed uniformly along the wire?
99  }
100  //On simulated data you need to subtract the total propagation time
101  case 1: {
102  float halfL = layer->specificTopology().cellLenght()/2;
103  float wireCoord = layer->toLocal(globPos).y();
104  float propgL = halfL - wireCoord;
105  wirePropCorr = propgL/theVPropWire;
106  break;
107  }
108  default: {
109  throw
110  cms::Exception("[DTTTrigSyncFromDB]") << " Invalid parameter: wirePropCorrType = "
112  << std::endl;
113  break;
114  }
115  }
116  }
117 
118  // Compute TOF correction:
119  tofCorr = 0.;
120  // TOF Correction can be switched off with appropriate parameter
121  if(doTOFCorrection) {
122  float flightToHit = globPos.mag();
123  static const float cSpeed = 29.9792458; // cm/ns
124  switch(theTOFCorrType) {
125  case 0: {
126  // The ttrig computed from the real data accounts on average for the TOF correction
127  // Depending on the granularity used for the ttrig computation we just have to correct for the
128  // TOF from the center of the chamber, SL, layer or wire to the hit position.
129  // At the moment only SL granularity is considered
130  // Correction for TOF from the center of the SL to hit position
131  const DTSuperLayer *sl = layer->superLayer();
132  double flightToSL = sl->surface().position().mag();
133  tofCorr = (flightToSL-flightToHit)/cSpeed;
134  break;
135  }
136  case 1: {
137  // On simulated data you need to consider only the TOF from 3D center of the wire to hit position
138  // (because the TOF from the IP to the wire has been already subtracted in the digitization:
139  // SimMuon/DTDigitizer/DTDigiSyncTOFCorr.cc corrType=2)
140  float flightToWire =
141  layer->toGlobal(LocalPoint(layer->specificTopology().wirePosition(wireId.wire()), 0., 0.)).mag();
142  tofCorr = (flightToWire-flightToHit)/cSpeed;
143  break;
144  }
145  default: {
146  throw
147  cms::Exception("[DTTTrigSyncFromDB]") << " Invalid parameter: tofCorrType = "
148  << theTOFCorrType
149  << std::endl;
150  break;
151  }
152  }
153  }
154 
155 
156  if(debug) {
157  cout << "[DTTTrigSyncFromDB] Channel: " << wireId << endl
158  << " Offset (ns): " << tTrig + wirePropCorr - tofCorr << endl
159  << " various contributions are: " << endl
160  << " tTrig + t0 (ns): " << tTrig << endl
161  //<< " tZero (ns): " << t0 << endl
162  << " Propagation along wire delay (ns): " << wirePropCorr << endl
163  << " TOF correction (ns): " << tofCorr << endl
164  << endl;
165  }
166  //The global offset is the sum of various contributions
167  return tTrig + wirePropCorr - tofCorr;
168 }
169 
170 double DTTTrigSyncFromDB::offset(const DTWireId& wireId) {
171  float t0 = 0;
172  float t0rms = 0;
173  if(doT0Correction)
174  {
175  // Read the t0 from pulses for this wire (ns)
176  tZeroMap->get(wireId,
177  t0,
178  t0rms,
180 
181  }
182 
183  // Read the ttrig for this wire
184  float ttrigMean = 0;
185  float ttrigSigma = 0;
186  float kFactor = 0;
187  // FIXME: should check the return value of the DTTtrigRcd::get(..) method
188  if(tTrigMap->get(wireId.superlayerId(),
189  ttrigMean,
190  ttrigSigma,
191  kFactor,
192  DTTimeUnits::ns) != 0) {
193  cout << "[DTTTrigSyncFromDB]*Error: ttrig not found for SL: " << wireId.superlayerId() << endl;
194 // FIXME: LogError.....
195  }
196 
197  return t0 + ttrigMean + kFactor * ttrigSigma;
198 
199 }
200 
202  double &tTrig,
203  double &t0cell) {
204  float t0 = 0;
205  float t0rms = 0;
206  if(doT0Correction)
207  {
208  // Read the t0 from pulses for this wire (ns)
209  tZeroMap->get(wireId,
210  t0,
211  t0rms,
213 
214  }
215 
216  // Read the ttrig for this wire
217  float ttrigMean = 0;
218  float ttrigSigma = 0;
219  float kFactor = 0;
220  // FIXME: should check the return value of the DTTtrigRcd::get(..) method
221  if(tTrigMap->get(wireId.superlayerId(),
222  ttrigMean,
223  ttrigSigma,
224  kFactor,
225  DTTimeUnits::ns) != 0) {
226  cout << "[DTTTrigSyncFromDB]*Error: ttrig not found for SL: " << wireId.superlayerId() << endl;
227 // FIXME: LogError.....
228  }
229 
230  tTrig = ttrigMean + kFactor * ttrigSigma;
231  t0cell = t0;
232 
233  return int(tTrig/theBXspace)*theBXspace + t0cell;
234 }
const DTTtrig * tTrigMap
float wirePosition(int wireNumber) const
Returns the x position in the layer of a given wire number.
Definition: DTTopology.cc:86
const DTT0 * tZeroMap
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:32
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:54
T y() const
Definition: PV3DBase.h:63
const std::string & version() const
access version
Definition: DTTtrig.cc:231
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:69
Definition: config.py:1
void setES(const edm::EventSetup &setup) override
Pass the Event Setup to the algo at each event.
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
Definition: DTLayerId.h:59
~DTTTrigSyncFromDB() override
Destructor.
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
int get(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, float &t0mean, float &t0rms, DTTimeUnits::type unit) const
Definition: DTT0.cc:67
const DTTopology & specificTopology() const
Definition: DTLayer.cc:42
T mag() const
Definition: PV3DBase.h:67
int wire() const
Return the wire number.
Definition: DTWireId.h:56
std::string thetTrigLabel
int get(int wheelId, int stationId, int sectorId, int slId, float &tTrig, float &tTrms, float &kFact, DTTimeUnits::type unit) const
get content
Definition: DTTtrig.cc:85
#define debug
Definition: HDRShower.cc:19
const T & get() const
Definition: EventSetup.h:59
double emulatorOffset(const DTWireId &wireId, double &tTrig, double &t0cell) override
const DTSuperLayer * superLayer() const
Definition: DTLayer.cc:54
Definition: DTT0Rcd.h:9
HLT enums.
DTTTrigSyncFromDB(const edm::ParameterSet &config)
Constructor.
const std::string & version() const
access version
Definition: DTT0.cc:118
float cellLenght() const
Definition: DTTopology.h:73
const PositionType & position() const
double offset(const DTLayer *layer, const DTWireId &wireId, const GlobalPoint &globPos, double &tTrig, double &wirePropCorr, double &tofCorr) override