CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends
DTDigitizer Class Reference

#include <DTDigitizer.h>

Inheritance diagram for DTDigitizer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

struct  hitLessT
 

Public Member Functions

 DTDigitizer (const edm::ParameterSet &)
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 
 ~DTDigitizer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Types

typedef std::map< DTWireId,
std::vector< const PSimHit * > > 
DTWireIdMap
 
typedef DTWireIdMap::const_iterator DTWireIdMapConstIter
 
typedef DTWireIdMap::iterator DTWireIdMapIter
 
typedef std::pair< const
PSimHit *, float > 
hitAndT
 
typedef std::vector< hitAndTTDContainer
 

Private Member Functions

float asymGausSmear (double mean, double sigmaLeft, double sigmaRight) const
 
std::pair< float, bool > computeTime (const DTLayer *layer, const DTWireId &wireId, const PSimHit *hit, const LocalVector &BLoc)
 
std::pair< float, bool > driftTimeFromParametrization (float x, float alpha, float By, float Bz) const
 
std::pair< float, bool > driftTimeFromTimeMap () const
 
void dumpHit (const PSimHit *hit, float xEntry, float xExit, const DTTopology &topo)
 
float externalDelays (const DTLayer *layer, const DTWireId &wireId, const PSimHit *hit) const
 
void storeDigis (DTWireId &wireId, TDContainer &hits, DTDigiCollection &output, DTDigiSimLinkCollection &outputLinks)
 

Private Attributes

std::string collection_for_XF
 
float deadTime
 
bool debug
 
std::string geometryType
 
bool IdealModel
 
bool interpolate
 
float LinksTimeWindow
 
std::string mix_
 
bool MultipleLinks
 
bool onlyMuHits
 
float smearing
 
std::string syncName
 
float theConstVDrift
 
CLHEP::RandFlat * theFlatDistribution
 
CLHEP::RandGaussQ * theGaussianDistribution
 
DTDigiSyncBasetheSync
 
double vPropWire
 

Friends

class DTDigitizerAnalysis
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Digitize the muon drift tubes. The parametrisation function in DTDriftTimeParametrization from P.G.Abia, J.Puerta is used in all cases where it is applicable.

Authors
: G. Bevilacqua, N. Amapane, G. Cerminara, R. Bellan

Definition at line 37 of file DTDigitizer.h.

Member Typedef Documentation

typedef std::map<DTWireId, std::vector<const PSimHit*> > DTDigitizer::DTWireIdMap
private

Definition at line 49 of file DTDigitizer.h.

typedef DTWireIdMap::const_iterator DTDigitizer::DTWireIdMapConstIter
private

Definition at line 51 of file DTDigitizer.h.

typedef DTWireIdMap::iterator DTDigitizer::DTWireIdMapIter
private

Definition at line 50 of file DTDigitizer.h.

typedef std::pair<const PSimHit*,float> DTDigitizer::hitAndT
private

Definition at line 46 of file DTDigitizer.h.

typedef std::vector<hitAndT> DTDigitizer::TDContainer
private

Definition at line 47 of file DTDigitizer.h.

Constructor & Destructor Documentation

DTDigitizer::DTDigitizer ( const edm::ParameterSet conf_)
explicit

Definition at line 61 of file DTDigitizer.cc.

References gather_cfg::cout, debug, edm::hlt::Exception, reco::get(), edm::RandomNumberGenerator::getEngine(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), edm::Service< T >::isAvailable(), and AlCaHLTBitMon_QueryRunRegistry::string.

61  {
62 
63  // Set verbose output
64  debug=conf_.getUntrackedParameter<bool>("debug");
65 
66  if (debug) cout<<"Creating a DTDigitizer"<<endl;
67 
68  //register the Producer with a label
69  //produces<DTDigiCollection>("MuonDTDigis"); // FIXME: Do I pass it by ParameterSet?
70  produces<DTDigiCollection>(); // FIXME: Do I pass it by ParameterSet?
71  // produces<DTDigiSimLinkCollection>("MuonDTDigiSimLinks");
72  produces<DTDigiSimLinkCollection>();
73 
74  //Parameters:
75 
76  // build digis only for mu hits (for debug purposes)
77  onlyMuHits=conf_.getParameter<bool>("onlyMuHits");
78 
79  // interpolate parametrization function
80  interpolate=conf_.getParameter<bool>("interpolate");
81 
82  // Velocity of signal propagation along the wire (cm/ns)
83  // For the default value
84  // cfr. CMS-IN 2000-021: (2.56+-0.17)x1e8 m/s
85  // CMS NOTE 2003-17: (0.244) m/ns
86  vPropWire=conf_.getParameter<double>("vPropWire"); //24.4
87 
88  // Dead time for signals on the same wire (number from M. Pegoraro)
89  deadTime=conf_.getParameter<double>("deadTime"); //150
90 
91  // further configurable smearing
92  smearing=conf_.getParameter<double>("Smearing"); // 3.
93 
94  // Sync Algo
95  syncName = conf_.getParameter<string>("SyncName");
96  theSync = DTDigiSyncFactory::get()->create(syncName,conf_.getParameter<ParameterSet>("pset"));
97 
98  // Debug flag to switch to the Ideal model
99  // it uses a constant drift velocity and doesn't set any external delay
100  IdealModel = conf_.getParameter<bool>("IdealModel");
101 
102  // Constant drift velocity needed by the above flag
103  if(IdealModel)
104  theConstVDrift = conf_.getParameter<double>("IdealModelConstantDriftVelocity"); // 55 um/ns
105  else theConstVDrift = 55.;
106 
107  // get random engine
109  if ( ! rng.isAvailable()) {
110  throw cms::Exception("Configuration")
111  << "RandomNumberGeneratorService for DTDigitizer missing in cfg file";
112  }
113  theGaussianDistribution = new CLHEP::RandGaussQ(rng->getEngine());
114  theFlatDistribution = new CLHEP::RandFlat(rng->getEngine(), 0, 1);
115 
116  // MultipleLinks=false ==> one-to-one correspondence between digis and SimHits
117  MultipleLinks = conf_.getParameter<bool>("MultipleLinks");
118  // MultipleLinks=true ==> association of SimHits within a time window LinksTimeWindow
119  // (of the order of the resolution)
120  LinksTimeWindow = conf_.getParameter<double>("LinksTimeWindow"); // (10 ns)
121 
122  //Name of Collection used for create the XF
123  mix_ = conf_.getParameter<std::string>("mixLabel");
124  collection_for_XF = conf_.getParameter<std::string>("InputCollection");
125 
126  //String to choice between ideal (the deafult) and (mis)aligned geometry for the digitization step
127  geometryType = conf_.getParameter<std::string>("GeometryType");
128 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
bool onlyMuHits
Definition: DTDigitizer.h:104
float theConstVDrift
Definition: DTDigitizer.h:113
CLHEP::RandGaussQ * theGaussianDistribution
Definition: DTDigitizer.h:116
float LinksTimeWindow
Definition: DTDigitizer.h:121
DTDigiSyncBase * theSync
Definition: DTDigitizer.h:107
bool isAvailable() const
Definition: Service.h:46
float smearing
Definition: DTDigitizer.h:101
virtual CLHEP::HepRandomEngine & getEngine() const =0
Use this to get the random number engine, this is the only function most users should call...
bool interpolate
Definition: DTDigitizer.h:103
bool IdealModel
Definition: DTDigitizer.h:112
std::string mix_
Definition: DTDigitizer.h:124
std::string geometryType
Definition: DTDigitizer.h:109
std::string syncName
Definition: DTDigitizer.h:106
double vPropWire
Definition: DTDigitizer.h:99
tuple cout
Definition: gather_cfg.py:121
float deadTime
Definition: DTDigitizer.h:100
CLHEP::RandFlat * theFlatDistribution
Definition: DTDigitizer.h:117
T get(const Candidate &c)
Definition: component.h:55
bool MultipleLinks
Definition: DTDigitizer.h:120
std::string collection_for_XF
Definition: DTDigitizer.h:125
DTDigitizer::~DTDigitizer ( )

Definition at line 131 of file DTDigitizer.cc.

131  {
133  delete theFlatDistribution;
134 }
CLHEP::RandGaussQ * theGaussianDistribution
Definition: DTDigitizer.h:116
CLHEP::RandFlat * theFlatDistribution
Definition: DTDigitizer.h:117

Member Function Documentation

float DTDigitizer::asymGausSmear ( double  mean,
double  sigmaLeft,
double  sigmaRight 
) const
private

Definition at line 446 of file DTDigitizer.cc.

References f, and lumiQTWidget::t.

446  {
447 
448  double f = sigmaLeft/(sigmaLeft+sigmaRight);
449  double t;
450 
451  if (theFlatDistribution->fire() <= f) {
452  t = theGaussianDistribution->fire(mean,sigmaLeft);
453  t = mean - fabs(t - mean);
454  } else {
455  t = theGaussianDistribution->fire(mean,sigmaRight);
456  t = mean + fabs(t - mean);
457  }
458  return static_cast<float>(t);
459 }
CLHEP::RandGaussQ * theGaussianDistribution
Definition: DTDigitizer.h:116
double f[11][100]
CLHEP::RandFlat * theFlatDistribution
Definition: DTDigitizer.h:117
pair< float, bool > DTDigitizer::computeTime ( const DTLayer layer,
const DTWireId wireId,
const PSimHit hit,
const LocalVector BLoc 
)
private

Definition at line 235 of file DTDigitizer.cc.

References gather_cfg::cout, Vector3DBase< T, FrameTag >::cross(), debug, delta, dir, Vector3DBase< T, FrameTag >::dot(), PSimHit::entryPoint(), PSimHit::exitPoint(), PSimHit::localDirection(), PSimHit::localPosition(), M_PI, PV3DBase< T, PVType, FrameType >::mag(), PSimHit::momentumAtEntry(), DTTopology::none, DTTopology::onWhichBorder(), PSimHit::pabs(), PSimHit::particleType(), RecoTauCleanerPlugins::pt, DTLayer::specificTopology(), mathSSE::sqrt(), theta(), Vector3DBase< T, FrameTag >::unit(), DTWireId::wire(), DTTopology::wirePosition(), x, PV3DBase< T, PVType, FrameType >::x(), DTTopology::xMax, DTTopology::xMin, PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

236  {
237 
238  LocalPoint entryP = hit->entryPoint();
239  LocalPoint exitP = hit->exitPoint();
240  int partType = hit->particleType();
241 
242  const DTTopology &topo = layer->specificTopology();
243 
244  // Pay attention: in CMSSW the rf of the SimHit is in the layer's rf
245 
246  if(debug) cout<<"Hit local entry point: "<<entryP<<endl
247  <<"Hit local exit point: "<<exitP<<endl;
248 
249  float xwire = topo.wirePosition(wireId.wire());
250  float xEntry = entryP.x() - xwire;
251  float xExit = exitP.x() - xwire;
252 
253  if(debug) cout<<"wire position: "<<xwire
254  <<" x entry in cell rf: "<<xEntry
255  <<" x exit in cell rf: "<<xExit<<endl;
256 
257  DTTopology::Side entrySide = topo.onWhichBorder(xEntry,entryP.y(),entryP.z());
258  DTTopology::Side exitSide = topo.onWhichBorder(xExit,exitP.y(),exitP.z());
259 
260  if (debug) dumpHit(hit, xEntry, xExit,topo);
261 
262  // The bolean is used to flag the drift time computation
263  pair<float,bool> driftTime(0.,false);
264 
265  // if delta in gas->ignore, since it is included in the parametrisation.
266  // FIXME: should check that it is actually a delta ray produced by a nearby
267  // muon hit.
268 
269  if (partType == 11 && entrySide == DTTopology::none) {
270  if (debug) cout << " e- hit in gas; discarding " << endl;
271  return driftTime;
272  }
273 
274  float By = BLoc.y();
275  float Bz = BLoc.z();
276 
277  // Radius and sagitta according to direction of momentum
278  // (just for printing)
279  // NOTE: in cmsim, d is always taken // pHat!
280  LocalVector d = (exitP-entryP);
281  LocalVector pHat = hit->localDirection().unit();
282  LocalVector hHat = (d.cross(pHat.cross(d))).unit();
283  float cosAlpha = hHat.dot(pHat);
284  float sinAlpha = sqrt(1.-cosAlpha*cosAlpha);
285  float radius_P = (d.mag())/(2.*cosAlpha);
286  float sagitta_P = radius_P*(1.-sinAlpha);
287 
288  // Radius, sagitta according to field bending
289  // (just for printing)
290  float halfd = d.mag()/2.;
291  float BMag = BLoc.mag();
292  LocalVector pT = (pHat - (BLoc.unit()*pHat.dot(BLoc.unit())))*(hit->pabs());
293  float radius_B = (pT.mag()/(0.3*BMag))*100.;
294  float sagitta_B;
295  if (radius_B > halfd) {
296  sagitta_B = radius_B - sqrt(radius_B*radius_B - halfd*halfd);
297  } else {
298  sagitta_B = radius_B;
299  }
300 
301  // cos(delta), delta= angle between direction at entry and hit segment
302  // (just for printing)
303  float delta = pHat.dot(d.unit());
304  if (debug) cout << " delta = " << delta << endl
305  << " cosAlpha = " << cosAlpha << endl
306  << " sinAlpha = " << sinAlpha << endl
307  << " pMag = " << pT.mag() << endl
308  << " bMag = " << BMag << endl
309  << " pT = " << pT << endl
310  << " halfd = " << halfd << endl
311  << " radius_P (cm) = " << radius_P << endl
312  << " sagitta_P (um) = " << sagitta_P*10000. << endl
313  << " radius_B (cm) = " << radius_B << endl
314  << " sagitta_B (um) = " << sagitta_B*10000. << endl;
315 
316  // Select cases where parametrization can not be used.
317  bool noParametrisation =
318  ( ( entrySide == DTTopology::none || exitSide == DTTopology::none ) // case # 2,3,8,9 or 11
319  || (entrySide == exitSide) // case # 4 or 10
320  || ((entrySide == DTTopology::xMin && exitSide == DTTopology::xMax) ||
321  (entrySide == DTTopology::xMax && exitSide == DTTopology::xMin)) // Hit is case # 7
322  );
323 
324  // FIXME: now, debug warning only; consider treating those
325  // with TM algo.
326  if ( delta < 0.99996 // Track is not straight. FIXME: use sagitta?
327  && (noParametrisation == false)) {
328  if (debug) cout << "*** WARNING: hit is not straight, type = " << partType << endl;
329  }
330 
331  //************ 5A ***************
332 
333  if (!noParametrisation) {
334 
335  LocalVector dir = hit->momentumAtEntry(); // ex Measurement3DVector dir = hit->measurementDirection(); //FIXME?
336  float theta = atan(dir.x()/-dir.z())*180/M_PI;
337 
338  // FIXME: use dir if M.S. is included as GARFIELD option...
339  // otherwise use hit segment dirction.
340  // LocalVector dir0 = (exitP-entryP).unit();
341  // float theta = atan(dir0.x()/-dir0.z())*180/M_PI;
342  float x;
343 
344  Local3DPoint pt = hit->localPosition(); //ex Measurement3DPoint pt = hit->measurementPosition(); // FIXME?
345 
346  if(fabs(pt.z()) < 0.002) {
347  // hit center within 20 um from z=0, no need to extrapolate.
348  x = pt.x() - xwire;
349  } else {
350  x = xEntry - (entryP.z()*(xExit-xEntry))/(exitP.z()-entryP.z());
351  }
352 
353  if(IdealModel) return make_pair(fabs(x)/theConstVDrift,true);
354  else driftTime = driftTimeFromParametrization(x, theta, By, Bz);
355 
356  }
357 
358 
359  if ((driftTime.second)==false) {
360  // Parametrisation not applicable, or failed. Use time map.
361  driftTime = driftTimeFromTimeMap();
362  }
363 
364  //************ 5B ***************
365 
366  // Signal propagation, TOF etc.
367  if (driftTime.second) {
368  driftTime.first += externalDelays(layer,wireId,hit);
369  }
370  return driftTime;
371 }
dbl * delta
Definition: mlp_gen.cc:36
void dumpHit(const PSimHit *hit, float xEntry, float xExit, const DTTopology &topo)
Definition: DTDigitizer.cc:576
float wirePosition(int wireNumber) const
Returns the x position in the layer of a given wire number.
Definition: DTTopology.cc:86
Side onWhichBorder(float x, float y, float z) const
Definition: DTTopology.cc:109
LocalVector momentumAtEntry() const
The momentum of the track that produced the hit, at entry point.
Definition: PSimHit.h:47
float theConstVDrift
Definition: DTDigitizer.h:113
Geom::Theta< T > theta() const
T y() const
Definition: PV3DBase.h:63
PreciseFloatType< T, U >::Type dot(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:107
std::pair< float, bool > driftTimeFromParametrization(float x, float alpha, float By, float Bz) const
Definition: DTDigitizer.cc:375
const DTTopology & specificTopology() const
Definition: DTLayer.cc:42
Local3DPoint exitPoint() const
Exit point in the local Det frame.
Definition: PSimHit.h:38
T mag() const
Definition: PV3DBase.h:67
Local3DPoint localPosition() const
Definition: PSimHit.h:44
T sqrt(T t)
Definition: SSEVec.h:48
Vector3DBase< typename PreciseFloatType< T, U >::Type, FrameTag > cross(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:119
T z() const
Definition: PV3DBase.h:64
float pabs() const
fast and more accurate access to momentumAtEntry().mag()
Definition: PSimHit.h:63
Side
Sides of the cell.
Definition: DTTopology.h:88
bool IdealModel
Definition: DTDigitizer.h:112
LocalVector localDirection() const
Obsolete. Same as momentumAtEntry().unit(), for backward compatibility.
Definition: PSimHit.h:52
int wire() const
Return the wire number.
Definition: DTWireId.h:56
Vector3DBase unit() const
Definition: Vector3DBase.h:57
#define M_PI
Definition: BFit3D.cc:3
int particleType() const
Definition: PSimHit.h:85
float externalDelays(const DTLayer *layer, const DTWireId &wireId, const PSimHit *hit) const
Definition: DTDigitizer.cc:469
tuple cout
Definition: gather_cfg.py:121
dbl *** dir
Definition: mlp_gen.cc:35
Definition: DDAxes.h:10
T x() const
Definition: PV3DBase.h:62
std::pair< float, bool > driftTimeFromTimeMap() const
Definition: DTDigitizer.cc:461
Local3DPoint entryPoint() const
Entry point in the local Det frame.
Definition: PSimHit.h:35
pair< float, bool > DTDigitizer::driftTimeFromParametrization ( float  x,
float  alpha,
float  By,
float  Bz 
) const
private

Definition at line 375 of file DTDigitizer.cc.

References gather_cfg::cout, debug, GeomDetEnumerators::DT, f, edm::max(), DTDriftTimeParametrization::MB_DT_drift_time(), DTDriftTimeParametrization::drift_time::t_drift, DTDriftTimeParametrization::drift_time::t_width_m, DTDriftTimeParametrization::drift_time::t_width_p, theta(), and cond::rpcobgas::time.

375  {
376 
377  // Convert from CMSSW frame/units r.f. to parametrization ones.
378  x *= 10.; //cm -> mm
379 
380  // FIXME: Current parametrisation can extrapolate above 21 mm,
381  // however a detailed study is needed before using this.
382  if (fabs(x) > 21.) {
383  if (debug) cout << "*** WARNING: parametrisation: x out of range = "
384  << x << ", skipping" << endl;
385  return pair<float,bool>(0.f,false);
386  }
387 
388  // Different r.f. of the parametrization:
389  // X_par = X_ORCA; Y_par=Z_ORCA; Z_par = -Y_ORCA
390 
391  float By_par = Bz; // Bnorm
392  float Bz_par = -By; // Bwire
393  float theta_par = theta;
394 
395  // Parametrisation uses interpolation up to |theta|=45 deg,
396  // |Bwire|=0.4, |Bnorm|=0.75; extrapolation above.
397  if (fabs(theta_par)>45.) {
398  if (debug) cout << "*** WARNING: extrapolating theta > 45: "
399  << theta << endl;
400  // theta_par = min(fabs(theta_par),45.f)*((theta_par<0.)?-1.:1.);
401  }
402  if (fabs(By_par)>0.75) {
403  if (debug) cout << "*** WARNING: extrapolating Bnorm > 0.75: "
404  << By_par << endl;
405  // By_par = min(fabs(By_par),0.75f)*((By_par<0.)?-1.:1.);
406  }
407  if (fabs(Bz_par)>0.4) {
408  if (debug) cout << "*** WARNING: extrapolating Bwire >0.4: "
409  << Bz_par << endl;
410  // Bz_par = min(fabs(Bz_par),0.4)*((Bz_par<0.)?-1.:1.);
411  }
412 
414  static const DTDriftTimeParametrization par;
415  unsigned short flag = par.MB_DT_drift_time (x, theta_par, By_par, Bz_par, 0, &DT, interpolate);
416 
417  if (debug) {
418  cout << " Parametrisation: x, theta, Bnorm, Bwire = "
419  << x << " " << theta_par << " " << By_par << " " << Bz_par << endl
420  << " time=" << DT.t_drift
421  << " sigma_m=" << DT.t_width_m
422  << " sigma_p=" << DT.t_width_p << endl;
423  if (flag!=1) {
424  cout << "*** WARNING: call to parametrisation failed" << endl;
425  return pair<float,bool>(0.f,false);
426  }
427  }
428 
429  // Double half-gaussian smearing
430  float time = asymGausSmear(DT.t_drift, DT.t_width_m, DT.t_width_p);
431 
432  // Do not allow the smearing to lead to negative values
433  time = max(time,0.f);
434 
435  // Apply a Gaussian smearing to account for electronic effects (cf. 2004 TB analysis)
436  // The width of the Gaussian can be configured with the "Smearing" parameter
437 
438  double u = theGaussianDistribution->fire(0.,smearing);
439  time += u;
440 
441  if (debug) cout << " drift time = " << time << endl;
442 
443  return pair<float,bool>(time,true);
444 }
float asymGausSmear(double mean, double sigmaLeft, double sigmaRight) const
Definition: DTDigitizer.cc:446
CLHEP::RandGaussQ * theGaussianDistribution
Definition: DTDigitizer.h:116
Geom::Theta< T > theta() const
const T & max(const T &a, const T &b)
double f[11][100]
float smearing
Definition: DTDigitizer.h:101
bool interpolate
Definition: DTDigitizer.h:103
unsigned short MB_DT_drift_time(double x, double alpha, double by, double bz, short ifl, drift_time *DT, short interpolate) const
Calculate drift time and spread.
Structure used to return output values.
tuple cout
Definition: gather_cfg.py:121
Definition: DDAxes.h:10
pair< float, bool > DTDigitizer::driftTimeFromTimeMap ( ) const
private

Definition at line 461 of file DTDigitizer.cc.

References gather_cfg::cout, and debug.

461  {
462  // FIXME: not yet implemented.
463  if (debug) cout << " TimeMap " << endl;
464  return pair<float,bool>(0.,false);
465 }
tuple cout
Definition: gather_cfg.py:121
void DTDigitizer::dumpHit ( const PSimHit hit,
float  xEntry,
float  xExit,
const DTTopology topo 
)
private

Definition at line 576 of file DTDigitizer.cc.

References DTTopology::cellHeight(), DTTopology::cellLenght(), DTTopology::cellWidth(), gather_cfg::cout, PSimHit::energyLoss(), PSimHit::entryPoint(), PSimHit::exitPoint(), mag(), PSimHit::momentumAtEntry(), DTTopology::onWhichBorder(), PSimHit::pabs(), PSimHit::particleType(), PSimHit::processType(), PSimHit::trackId(), Vector3DBase< T, FrameTag >::unit(), x, PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

578  {
579 
580  LocalPoint entryP = hit->entryPoint();
581  LocalPoint exitP = hit->exitPoint();
582 
583  DTTopology::Side entrySide = topo.onWhichBorder(xEntry,entryP.y(),entryP.z());
584  DTTopology::Side exitSide = topo.onWhichBorder(xExit,exitP.y(),exitP.z());
585  // ProcessTypeEnumerator pTypes;
586 
587  cout << endl
588  << "------- SimHit: " << endl
589  << " Particle type = " << hit->particleType() << endl
590  << " process type = " << hit->processType() << endl
591  << " process type = " << hit->processType() << endl
592  // << " packedTrackId = " << hit->packedTrackId() << endl
593  << " trackId = " << hit->trackId() << endl // new,is the same as the
594  // previous?? FIXME-Check
595  << " |p| = " << hit->pabs() << endl
596  << " Energy loss = " << hit->energyLoss() << endl
597  // << " timeOffset = " << hit->timeOffset() << endl
598  // << " measurementPosition = " << hit->measurementPosition() << endl
599  // << " measurementDirection = " << hit->measurementDirection() << endl //FIXME
600  << " localDirection = " << hit->momentumAtEntry().unit() << endl //FIXME is it a versor?
601  << " Entry point = " << entryP << " cell x = " << xEntry << endl
602  << " Exit point = " << exitP << " cell x = " << xExit << endl
603  << " DR = = " << (exitP-entryP).mag() << endl
604  << " Dx = = " << (exitP-entryP).x() << endl
605  << " Cell w,h,l = (" << topo.cellWidth()
606  << " , " << topo.cellHeight()
607  << " , " << topo.cellLenght() << ") cm" << endl
608  << " DY entry from edge = " << topo.cellLenght()/2.-fabs(entryP.y())
609  << " DY exit from edge = " << topo.cellLenght()/2.-fabs(exitP.y())
610  << " entrySide = " << (int)entrySide
611  << " ; exitSide = " << (int)exitSide << endl;
612 
613 }
Side onWhichBorder(float x, float y, float z) const
Definition: DTTopology.cc:109
LocalVector momentumAtEntry() const
The momentum of the track that produced the hit, at entry point.
Definition: PSimHit.h:47
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
T y() const
Definition: PV3DBase.h:63
float cellWidth() const
Returns the cell width.
Definition: DTTopology.h:68
Local3DPoint exitPoint() const
Exit point in the local Det frame.
Definition: PSimHit.h:38
T z() const
Definition: PV3DBase.h:64
float cellHeight() const
Returns the cell height.
Definition: DTTopology.h:70
float pabs() const
fast and more accurate access to momentumAtEntry().mag()
Definition: PSimHit.h:63
Side
Sides of the cell.
Definition: DTTopology.h:88
Vector3DBase unit() const
Definition: Vector3DBase.h:57
unsigned short processType() const
Definition: PSimHit.h:118
float energyLoss() const
The energy deposit in the PSimHit, in ???.
Definition: PSimHit.h:75
int particleType() const
Definition: PSimHit.h:85
unsigned int trackId() const
Definition: PSimHit.h:102
tuple cout
Definition: gather_cfg.py:121
Definition: DDAxes.h:10
float cellLenght() const
Definition: DTTopology.h:73
Local3DPoint entryPoint() const
Entry point in the local Det frame.
Definition: PSimHit.h:35
float DTDigitizer::externalDelays ( const DTLayer layer,
const DTWireId wireId,
const PSimHit hit 
) const
private

Definition at line 469 of file DTDigitizer.cc.

References DTTopology::cellLenght(), gather_cfg::cout, debug, PSimHit::localPosition(), DTLayer::specificTopology(), PSimHit::tof(), and PV3DBase< T, PVType, FrameType >::y().

471  {
472 
473  // Time of signal propagation along wire.
474 
475  float wireCoord = hit->localPosition().y();
476  float halfL = (layer->specificTopology().cellLenght())/2.;
477  float propgL = halfL - wireCoord; // the FE is always located at the pos coord.
478 
479  float propDelay = propgL/vPropWire;
480 
481  // Real TOF.
482  float tof = hit->tof();
483 
484  // Delays and t0 according to theSync
485 
486  double sync= theSync->digitizerOffset(&wireId,layer);
487 
488 
489  if (debug) {
490  cout << " propDelay =" << propDelay
491  << "; TOF=" << tof
492  << "; sync= " << sync
493  << endl;
494  }
495 
496  return propDelay + tof + sync;
497 }
float tof() const
deprecated name for timeOfFlight()
Definition: PSimHit.h:72
T y() const
Definition: PV3DBase.h:63
DTDigiSyncBase * theSync
Definition: DTDigitizer.h:107
const DTTopology & specificTopology() const
Definition: DTLayer.cc:42
Local3DPoint localPosition() const
Definition: PSimHit.h:44
virtual double digitizerOffset(const DTWireId *id, const DTLayer *layer) const =0
Delays to be added to digi times during digitization, in ns.
double vPropWire
Definition: DTDigitizer.h:99
tuple cout
Definition: gather_cfg.py:121
float cellLenght() const
Definition: DTTopology.h:73
void DTDigitizer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDProducer.

Definition at line 137 of file DTDigitizer.cc.

References gather_cfg::cout, debug, edm::EventID::event(), edm::EventSetup::get(), edm::Event::getByLabel(), edm::EventBase::id(), DTWireId::layerId(), convertSQLitetoXML_cfg::output, edm::Handle< T >::product(), edm::Event::put(), edm::EventID::run(), trackerHits::simHits, GeomDet::surface(), cond::rpcobgas::time, Surface::toGlobal(), and GloballyPositioned< T >::toLocal().

137  {
138  if(debug)
139  cout << "--- Run: " << iEvent.id().run()
140  << " Event: " << iEvent.id().event() << endl;
141 
142  //************ 1 ***************
143  // create the container for the SimHits
144  // Handle<PSimHitContainer> simHits;
145  // iEvent.getByLabel("g4SimHits","MuonDTHits",simHits);
146 
147  // use MixCollection instead of the previous
149  iEvent.getByLabel(mix_,collection_for_XF,xFrame);
150 
151  auto_ptr<MixCollection<PSimHit> >
152  simHits( new MixCollection<PSimHit>(xFrame.product()) );
153 
154  // create the pointer to the Digi container
155  auto_ptr<DTDigiCollection> output(new DTDigiCollection());
156  // pointer to the DigiSimLink container
157  auto_ptr<DTDigiSimLinkCollection> outputLinks(new DTDigiSimLinkCollection());
158 
159  // Muon Geometry
160  ESHandle<DTGeometry> muonGeom;
161  iSetup.get<MuonGeometryRecord>().get(geometryType,muonGeom);
162 
163  // Magnetic Field
164  ESHandle<MagneticField> magnField;
165  iSetup.get<IdealMagneticFieldRecord>().get(magnField);
166 
167  //************ 2 ***************
168 
169  // These are sorted by DetId, i.e. by layer and then by wire #
170  // map<DTDetId, vector<const PSimHit*> > wireMap;
171  DTWireIdMap wireMap;
172 
173  for(MixCollection<PSimHit>::MixItr simHit = simHits->begin();
174  simHit != simHits->end(); simHit++){
175 
176  // Create the id of the wire, the simHits in the DT known also the wireId
177 
178  DTWireId wireId( (*simHit).detUnitId() );
179  // Fill the map
180  wireMap[wireId].push_back(&(*simHit));
181  }
182 
183  pair<float,bool> time(0.,false);
184 
185  //************ 3 ***************
186  // Loop over the wires
187  for(DTWireIdMapConstIter wire = wireMap.begin(); wire!=wireMap.end(); wire++){
188  // SimHit Container associated to the wire
189  const vector<const PSimHit*> & vhit = (*wire).second;
190  if(vhit.size()!=0) {
191  TDContainer tdCont; // It is a vector<pair<const PSimHit*,float> >;
192 
193  //************ 4 ***************
194  DTWireId wireId = (*wire).first;
195 
196  //const DTLayer* layer = dynamic_cast< const DTLayer* > (muonGeom->idToDet(wireId.layerId()));
197  const DTLayer* layer = muonGeom->layer(wireId.layerId());
198 
199  // Loop on the hits of this wire
200  for (vector<const PSimHit*>::const_iterator hit=vhit.begin();
201  hit != vhit.end(); hit++){
202  //************ 5 ***************
203  LocalPoint locPos = (*hit)->localPosition();
204 
205  const LocalVector BLoc=layer->surface().toLocal(magnField->inTesla(layer->surface().toGlobal(locPos)));
206 
207  time = computeTime(layer, wireId, *hit, BLoc);
208 
209  //************ 6 ***************
210  if (time.second) {
211  tdCont.push_back(make_pair((*hit),time.first));
212  } else {
213  if (debug) cout << "hit discarded" << endl;
214  }
215  }
216 
217  //************ 7 ***************
218 
219  // the loading must be done by layer but
220  // the digitization must be done by wire (in order to take into account the dead time)
221 
222  storeDigis(wireId,tdCont,*output,*outputLinks);
223  }
224 
225  }
226 
227  //************ 8 ***************
228  // Load the Digi Container in the Event
229  //iEvent.put(output,"MuonDTDigis");
230  iEvent.put(output);
231  iEvent.put(outputLinks);
232 
233 }
RunNumber_t run() const
Definition: EventID.h:42
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:114
EventNumber_t event() const
Definition: EventID.h:44
std::pair< float, bool > computeTime(const DTLayer *layer, const DTWireId &wireId, const PSimHit *hit, const LocalVector &BLoc)
Definition: DTDigitizer.cc:235
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
void storeDigis(DTWireId &wireId, TDContainer &hits, DTDigiCollection &output, DTDigiSimLinkCollection &outputLinks)
Definition: DTDigitizer.cc:502
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
LocalPoint toLocal(const GlobalPoint &gp) const
DTWireIdMap::const_iterator DTWireIdMapConstIter
Definition: DTDigitizer.h:51
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
std::string mix_
Definition: DTDigitizer.h:124
std::string geometryType
Definition: DTDigitizer.h:109
const T & get() const
Definition: EventSetup.h:55
tuple simHits
Definition: trackerHits.py:16
T const * product() const
Definition: Handle.h:81
std::vector< hitAndT > TDContainer
Definition: DTDigitizer.h:47
DTLayerId layerId() const
Return the corresponding LayerId.
Definition: DTWireId.h:62
edm::EventID id() const
Definition: EventBase.h:56
MuonDigiCollection< DTLayerId, DTDigi > DTDigiCollection
tuple cout
Definition: gather_cfg.py:121
MuonDigiCollection< DTLayerId, DTDigiSimLink > DTDigiSimLinkCollection
std::map< DTWireId, std::vector< const PSimHit * > > DTWireIdMap
Definition: DTDigitizer.h:49
std::string collection_for_XF
Definition: DTDigitizer.h:125
void DTDigitizer::storeDigis ( DTWireId wireId,
TDContainer hits,
DTDigiCollection output,
DTDigiSimLinkCollection outputLinks 
)
private

Definition at line 502 of file DTDigitizer.cc.

References funct::abs(), DTDigi::countsTDC(), gather_cfg::cout, debug, MuonDigiCollection< IndexType, DigiType >::insertDigi(), DTWireId::layerId(), DTDigi::number(), funct::pow(), python.multivaluedict::sort(), DTDigi::time(), cond::rpcobgas::time, and DTWireId::wire().

504  {
505 
506  //************ 7A ***************
507 
508  // sort signal times
509  sort(hits.begin(),hits.end(),hitLessT());
510 
511  //************ 7B ***************
512 
513  float wakeTime = -999999.0;
514  float resolTime = -999999.0;
515  int digiN = -1; // Digi identifier within the cell (for multiple digis)
516  DTDigi digi;
517 
518  // loop over signal times and drop signals inside dead time
519  for ( TDContainer::const_iterator hit = hits.begin() ; hit != hits.end() ;
520  hit++ ) {
521 
522  if (onlyMuHits && abs((*hit).first->particleType())!=13) continue;
523 
524  //************ 7C ***************
525 
526  float time = (*hit).second;
527  if ( time > wakeTime ) {
528  // Note that digi is constructed with a float value (in ns)
529  int wireN = wireId.wire();
530  digiN++;
531  digi = DTDigi(wireN, time, digiN);
532 
533  // Add association between THIS digi and the corresponding SimTrack
534  unsigned int SimTrackId = (*hit).first->trackId();
535  EncodedEventId evId = (*hit).first->eventId();
536  DTDigiSimLink digisimLink(wireN, digiN, time, SimTrackId, evId);
537 
538  if(debug) {
539  cout<<endl<<"---- DTDigitizer ----"<<endl;
540  cout<<"wireId: "<<wireId<<endl;
541  cout<<"sim. time = "<<time<<endl;
542  cout<<"digi number = "<< digi.number()<<", digi time = "<<digi.time()
543  <<", linked to SimTrack Id = "<<SimTrackId<<endl;
544  }
545 
546  //************ 7D ***************
547  if(digi.countsTDC() < pow(2.,16)){
548  DTLayerId layerID = wireId.layerId(); //taking the layer in which reside the wire
549  output.insertDigi(layerID, digi); // ordering Digis by layer
550  outputLinks.insertDigi(layerID, digisimLink);
551  wakeTime = time + deadTime;
552  resolTime = time + LinksTimeWindow;
553  }
554  else {
555  digiN--;
556  }
557  }
558  else if (MultipleLinks && time < resolTime){
559  int wireN = wireId.wire();
560  unsigned int SimTrackId = (*hit).first->trackId();
561  EncodedEventId evId = (*hit).first->eventId();
562  DTDigiSimLink digisimLink(wireN, digiN, time, SimTrackId, evId);
563  DTLayerId layerID = wireId.layerId();
564  outputLinks.insertDigi(layerID, digisimLink);
565 
566  if(debug) {
567  cout<<"\nAdded multiple link: \n"
568  <<"digi number = "<<digi.number()<<", digi time = "<<digi.time()<<" (sim. time = "<<time<<")"
569  <<", linked to SimTrack Id = "<<SimTrackId<<endl;
570  }
571  }
572  }
573 
574 }
bool onlyMuHits
Definition: DTDigitizer.h:104
float LinksTimeWindow
Definition: DTDigitizer.h:121
void insertDigi(const IndexType &index, const DigiType &digi)
insert a digi for a given DetUnit
double time() const
Get time in ns.
Definition: DTDigi.cc:63
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Definition: DTDigi.h:17
uint32_t countsTDC() const
Get raw TDC count.
Definition: DTDigi.cc:65
int wire() const
Return the wire number.
Definition: DTWireId.h:56
DTLayerId layerId() const
Return the corresponding LayerId.
Definition: DTWireId.h:62
int number() const
Identifies different digis within the same.
Definition: DTDigi.cc:69
tuple cout
Definition: gather_cfg.py:121
float deadTime
Definition: DTDigitizer.h:100
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
bool MultipleLinks
Definition: DTDigitizer.h:120

Friends And Related Function Documentation

friend class DTDigitizerAnalysis
friend

Definition at line 96 of file DTDigitizer.h.

Member Data Documentation

std::string DTDigitizer::collection_for_XF
private

Definition at line 125 of file DTDigitizer.h.

float DTDigitizer::deadTime
private

Definition at line 100 of file DTDigitizer.h.

bool DTDigitizer::debug
private

Definition at line 102 of file DTDigitizer.h.

std::string DTDigitizer::geometryType
private

Definition at line 109 of file DTDigitizer.h.

bool DTDigitizer::IdealModel
private

Definition at line 112 of file DTDigitizer.h.

bool DTDigitizer::interpolate
private

Definition at line 103 of file DTDigitizer.h.

float DTDigitizer::LinksTimeWindow
private

Definition at line 121 of file DTDigitizer.h.

std::string DTDigitizer::mix_
private

Definition at line 124 of file DTDigitizer.h.

bool DTDigitizer::MultipleLinks
private

Definition at line 120 of file DTDigitizer.h.

bool DTDigitizer::onlyMuHits
private

Definition at line 104 of file DTDigitizer.h.

float DTDigitizer::smearing
private

Definition at line 101 of file DTDigitizer.h.

std::string DTDigitizer::syncName
private

Definition at line 106 of file DTDigitizer.h.

float DTDigitizer::theConstVDrift
private

Definition at line 113 of file DTDigitizer.h.

CLHEP::RandFlat* DTDigitizer::theFlatDistribution
private

Definition at line 117 of file DTDigitizer.h.

CLHEP::RandGaussQ* DTDigitizer::theGaussianDistribution
private

Definition at line 116 of file DTDigitizer.h.

DTDigiSyncBase* DTDigitizer::theSync
private

Definition at line 107 of file DTDigitizer.h.

double DTDigitizer::vPropWire
private

Definition at line 99 of file DTDigitizer.h.