CMS 3D CMS Logo

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::stream::EDProducer<>

Classes

struct  hitLessT
 

Public Member Functions

 DTDigitizer (const edm::ParameterSet &)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

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, CLHEP::HepRandomEngine *) const
 
std::pair< float, bool > computeTime (const DTLayer *layer, const DTWireId &wireId, const PSimHit *hit, const LocalVector &BLoc, CLHEP::HepRandomEngine *)
 
std::pair< float, bool > driftTimeFromParametrization (float x, float alpha, float By, float Bz, CLHEP::HepRandomEngine *) 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

int base
 
edm::EDGetTokenT< CrossingFrame< PSimHit > > cf_token
 
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
 
std::unique_ptr< DTDigiSyncBasetheSync
 
double vPropWire
 

Friends

class DTDigitizerAnalysis
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

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 46 of file DTDigitizer.h.

Member Typedef Documentation

◆ DTWireIdMap

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

Definition at line 56 of file DTDigitizer.h.

◆ DTWireIdMapConstIter

typedef DTWireIdMap::const_iterator DTDigitizer::DTWireIdMapConstIter
private

Definition at line 58 of file DTDigitizer.h.

◆ DTWireIdMapIter

typedef DTWireIdMap::iterator DTDigitizer::DTWireIdMapIter
private

Definition at line 57 of file DTDigitizer.h.

◆ hitAndT

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

Definition at line 53 of file DTDigitizer.h.

◆ TDContainer

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

Definition at line 54 of file DTDigitizer.h.

Constructor & Destructor Documentation

◆ DTDigitizer()

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

Definition at line 57 of file DTDigitizer.cc.

58  : // Sync Algo
59  theSync{DTDigiSyncFactory::get()->create(conf_.getParameter<string>("SyncName"),
60  conf_.getParameter<ParameterSet>("pset"))} {
61  // Set verbose output
62  debug = conf_.getUntrackedParameter<bool>("debug");
63 
64  if (debug)
65  LogPrint("DTDigitizer") << "Creating a DTDigitizer" << endl;
66 
67  // register the Producer with a label
68  // produces<DTDigiCollection>("MuonDTDigis"); // FIXME: Do I pass it by
69  // 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  // Debug flag to switch to the Ideal model
95  // it uses a constant drift velocity and doesn't set any external delay
96  IdealModel = conf_.getParameter<bool>("IdealModel");
97 
98  // Flag to specify that we want digis in phase-2 units (25./30. ns)
99  // instead that the old units (25./32.)
100  if (conf_.getParameter<bool>("phase2Digis"))
101  base = 30;
102  else
103  base = 32;
104 
105  // Constant drift velocity needed by the above flag
106  if (IdealModel)
107  theConstVDrift = conf_.getParameter<double>("IdealModelConstantDriftVelocity"); // 55 um/ns
108  else
109  theConstVDrift = 55.;
110 
111  // get random engine
113  if (!rng.isAvailable()) {
114  throw cms::Exception("Configuration") << "RandomNumberGeneratorService for DTDigitizer missing in cfg file";
115  }
116 
117  // MultipleLinks=false ==> one-to-one correspondence between digis and SimHits
118  MultipleLinks = conf_.getParameter<bool>("MultipleLinks");
119  // MultipleLinks=true ==> association of SimHits within a time window
120  // LinksTimeWindow (of the order of the resolution)
121  LinksTimeWindow = conf_.getParameter<double>("LinksTimeWindow"); // (10 ns)
122 
123  // Name of Collection used for create the XF
124  mix_ = conf_.getParameter<std::string>("mixLabel");
125  collection_for_XF = conf_.getParameter<std::string>("InputCollection");
126  cf_token = consumes<CrossingFrame<PSimHit>>(edm::InputTag(mix_, collection_for_XF));
127 
128  // String to choice between ideal (the deafult) and (mis)aligned geometry for
129  // the digitization step
130  geometryType = conf_.getParameter<std::string>("GeometryType");
131 }

References get, and edm::ParameterSet::getParameter().

Member Function Documentation

◆ asymGausSmear()

float DTDigitizer::asymGausSmear ( double  mean,
double  sigmaLeft,
double  sigmaRight,
CLHEP::HepRandomEngine *  engine 
) const
private

Definition at line 449 of file DTDigitizer.cc.

452  {
453  double f = sigmaLeft / (sigmaLeft + sigmaRight);
454  double t;
455 
456  if (CLHEP::RandFlat::shoot(engine) <= f) {
457  t = CLHEP::RandGaussQ::shoot(engine, mean, sigmaLeft);
458  t = mean - fabs(t - mean);
459  } else {
460  t = CLHEP::RandGaussQ::shoot(engine, mean, sigmaRight);
461  t = mean + fabs(t - mean);
462  }
463  return static_cast<float>(t);
464 }

References f, SiStripPI::mean, and OrderedSet::t.

Referenced by driftTimeFromParametrization().

◆ computeTime()

pair< float, bool > DTDigitizer::computeTime ( const DTLayer layer,
const DTWireId wireId,
const PSimHit hit,
const LocalVector BLoc,
CLHEP::HepRandomEngine *  engine 
)
private

Definition at line 231 of file DTDigitizer.cc.

235  {
236  LocalPoint entryP = hit->entryPoint();
237  LocalPoint exitP = hit->exitPoint();
238  int partType = hit->particleType();
239 
240  const DTTopology &topo = layer->specificTopology();
241 
242  // Pay attention: in CMSSW the rf of the SimHit is in the layer's rf
243 
244  if (debug)
245  LogPrint("DTDigitizer") << "Hit local entry point: " << entryP << endl << "Hit local exit point: " << exitP << endl;
246 
247  float xwire = topo.wirePosition(wireId.wire());
248  float xEntry = entryP.x() - xwire;
249  float xExit = exitP.x() - xwire;
250 
251  if (debug)
252  LogPrint("DTDigitizer") << "wire position: " << xwire << " x entry in cell rf: " << xEntry
253  << " x exit in cell rf: " << xExit << endl;
254 
255  DTTopology::Side entrySide = topo.onWhichBorder(xEntry, entryP.y(), entryP.z());
256  DTTopology::Side exitSide = topo.onWhichBorder(xExit, exitP.y(), exitP.z());
257 
258  if (debug)
259  dumpHit(hit, xEntry, xExit, topo);
260 
261  // The bolean is used to flag the drift time computation
262  pair<float, bool> driftTime(0., false);
263 
264  // if delta in gas->ignore, since it is included in the parametrisation.
265  // FIXME: should check that it is actually a delta ray produced by a nearby
266  // muon hit.
267 
268  if (partType == 11 && entrySide == DTTopology::none) {
269  if (debug)
270  LogPrint("DTDigitizer") << " 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)
305  LogPrint("DTDigitizer") << " delta = " << delta << endl
306  << " cosAlpha = " << cosAlpha << endl
307  << " sinAlpha = " << sinAlpha << endl
308  << " pMag = " << pT.mag() << endl
309  << " bMag = " << BMag << endl
310  << " pT = " << pT << endl
311  << " halfd = " << halfd << endl
312  << " radius_P (cm) = " << radius_P << endl
313  << " sagitta_P (um) = " << sagitta_P * 10000. << endl
314  << " radius_B (cm) = " << radius_B << endl
315  << " sagitta_B (um) = " << sagitta_B * 10000. << endl;
316 
317  // Select cases where parametrization can not be used.
318  bool noParametrisation = ((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)
329  LogPrint("DTDigitizer") << "*** WARNING: hit is not straight, type = " << partType << endl;
330  }
331 
332  //************ 5A ***************
333 
334  if (!noParametrisation) {
335  LocalVector dir = hit->momentumAtEntry(); // ex Measurement3DVector dir =
336  // hit->measurementDirection(); //FIXME?
337  float theta = atan(dir.x() / -dir.z()) * 180 / M_PI;
338 
339  // FIXME: use dir if M.S. is included as GARFIELD option...
340  // otherwise use hit segment dirction.
341  // LocalVector dir0 = (exitP-entryP).unit();
342  // float theta = atan(dir0.x()/-dir0.z())*180/M_PI;
343  float x;
344 
345  Local3DPoint pt = hit->localPosition(); // ex Measurement3DPoint pt =
346  // hit->measurementPosition(); // FIXME?
347 
348  if (fabs(pt.z()) < 0.002) {
349  // hit center within 20 um from z=0, no need to extrapolate.
350  x = pt.x() - xwire;
351  } else {
352  x = xEntry - (entryP.z() * (xExit - xEntry)) / (exitP.z() - entryP.z());
353  }
354 
355  if (IdealModel)
356  return make_pair(fabs(x) / theConstVDrift, true);
357  else
358  driftTime = driftTimeFromParametrization(x, theta, By, Bz, engine);
359  }
360 
361  if ((driftTime.second) == false) {
362  // Parametrisation not applicable, or failed. Use time map.
363  driftTime = driftTimeFromTimeMap();
364  }
365 
366  //************ 5B ***************
367 
368  // Signal propagation, TOF etc.
369  if (driftTime.second) {
370  driftTime.first += externalDelays(layer, wireId, hit);
371  }
372  return driftTime;
373 }

References Vector3DBase< T, FrameTag >::cross(), ztail::d, debug, dumpMFGeometry_cfg::delta, DeadROC_duringRun::dir, Vector3DBase< T, FrameTag >::dot(), driftTimeFromParametrization(), driftTimeFromTimeMap(), dumpHit(), externalDelays(), IdealModel, M_PI, PV3DBase< T, PVType, FrameType >::mag(), DTTopology::none, DTTopology::onWhichBorder(), DiDispStaMuonMonitor_cfi::pt, PVValHelper::pT, DTLayer::specificTopology(), mathSSE::sqrt(), theConstVDrift, 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().

Referenced by produce().

◆ driftTimeFromParametrization()

pair< float, bool > DTDigitizer::driftTimeFromParametrization ( float  x,
float  alpha,
float  By,
float  Bz,
CLHEP::HepRandomEngine *  engine 
) const
private

Definition at line 377 of file DTDigitizer.cc.

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

References asymGausSmear(), debug, GeomDetEnumerators::DT, f, RemoveAddSevLevel::flag, interpolate, SiStripPI::max, DTDriftTimeParametrization::MB_DT_drift_time(), smearing, theta(), ntuplemaker::time, and x.

Referenced by computeTime().

◆ driftTimeFromTimeMap()

pair< float, bool > DTDigitizer::driftTimeFromTimeMap ( ) const
private

Definition at line 466 of file DTDigitizer.cc.

466  {
467  // FIXME: not yet implemented.
468  if (debug)
469  LogPrint("DTDigitizer") << " TimeMap " << endl;
470  return pair<float, bool>(0., false);
471 }

References debug.

Referenced by computeTime().

◆ dumpHit()

void DTDigitizer::dumpHit ( const PSimHit hit,
float  xEntry,
float  xExit,
const DTTopology topo 
)
private

Definition at line 567 of file DTDigitizer.cc.

567  {
568  LocalPoint entryP = hit->entryPoint();
569  LocalPoint exitP = hit->exitPoint();
570 
571  DTTopology::Side entrySide = topo.onWhichBorder(xEntry, entryP.y(), entryP.z());
572  DTTopology::Side exitSide = topo.onWhichBorder(xExit, exitP.y(), exitP.z());
573  // ProcessTypeEnumerator pTypes;
574 
575  LogPrint("DTDigitizer") << endl
576  << "------- SimHit: " << endl
577  << " Particle type = " << hit->particleType() << endl
578  << " process type = " << hit->processType() << endl
579  << " process type = " << hit->processType()
580  << endl
581  // << " packedTrackId = " << hit->packedTrackId() << endl
582  << " trackId = " << hit->trackId()
583  << endl // new,is the same as the
584  // previous?? FIXME-Check
585  << " |p| = " << hit->pabs() << endl
586  << " Energy loss = " << hit->energyLoss()
587  << endl
588  // << " timeOffset = " << hit->timeOffset() << endl
589  // << " measurementPosition = " << hit->measurementPosition() << endl
590  // << " measurementDirection = " << hit->measurementDirection() << endl
591  // //FIXME
592  << " localDirection = " << hit->momentumAtEntry().unit()
593  << endl // FIXME is it a versor?
594  << " Entry point = " << entryP << " cell x = " << xEntry << endl
595  << " Exit point = " << exitP << " cell x = " << xExit << endl
596  << " DR = = " << (exitP - entryP).mag() << endl
597  << " Dx = = " << (exitP - entryP).x() << endl
598  << " Cell w,h,l = (" << topo.cellWidth() << " , " << topo.cellHeight() << " , "
599  << topo.cellLenght() << ") cm" << endl
600  << " DY entry from edge = " << topo.cellLenght() / 2. - fabs(entryP.y())
601  << " DY exit from edge = " << topo.cellLenght() / 2. - fabs(exitP.y())
602  << " entrySide = " << (int)entrySide << " ; exitSide = " << (int)exitSide << endl;
603 }

References DTTopology::cellHeight(), DTTopology::cellLenght(), DTTopology::cellWidth(), createfilelist::int, mag(), DTTopology::onWhichBorder(), x, PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by computeTime().

◆ externalDelays()

float DTDigitizer::externalDelays ( const DTLayer layer,
const DTWireId wireId,
const PSimHit hit 
) const
private

Definition at line 475 of file DTDigitizer.cc.

475  {
476  // Time of signal propagation along wire.
477 
478  float wireCoord = hit->localPosition().y();
479  float halfL = (layer->specificTopology().cellLenght()) / 2.;
480  float propgL = halfL - wireCoord; // the FE is always located at the pos coord.
481 
482  float propDelay = propgL / vPropWire;
483 
484  // Real TOF.
485  float tof = hit->tof();
486 
487  // Delays and t0 according to theSync
488 
489  double sync = theSync->digitizerOffset(&wireId, layer);
490 
491  if (debug) {
492  LogPrint("DTDigitizer") << " propDelay =" << propDelay << "; TOF=" << tof << "; sync= " << sync << endl;
493  }
494 
495  return propDelay + tof + sync;
496 }

References DTTopology::cellLenght(), debug, DTLayer::specificTopology(), theSync, vPropWire, and hit::y.

Referenced by computeTime().

◆ produce()

void DTDigitizer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 134 of file DTDigitizer.cc.

134  {
136  CLHEP::HepRandomEngine *engine = &rng->getEngine(iEvent.streamID());
137 
138  if (debug)
139  LogPrint("DTDigitizer") << "--- Run: " << iEvent.id().run() << " Event: " << iEvent.id().event() << endl;
140 
141  //************ 1 ***************
142  // create the container for the SimHits
143  // Handle<PSimHitContainer> simHits;
144  // iEvent.getByLabel("g4SimHits","MuonDTHits",simHits);
145 
146  // use MixCollection instead of the previous
148  iEvent.getByToken(cf_token, xFrame);
149 
150  unique_ptr<MixCollection<PSimHit>> simHits(new MixCollection<PSimHit>(xFrame.product()));
151 
152  // create the pointer to the Digi container
153  unique_ptr<DTDigiCollection> output(new DTDigiCollection());
154  // pointer to the DigiSimLink container
155  unique_ptr<DTDigiSimLinkCollection> outputLinks(new DTDigiSimLinkCollection());
156 
157  // Muon Geometry
158  ESHandle<DTGeometry> muonGeom;
159  iSetup.get<MuonGeometryRecord>().get(geometryType, muonGeom);
160 
161  // Magnetic Field
162  ESHandle<MagneticField> magnField;
163  iSetup.get<IdealMagneticFieldRecord>().get(magnField);
164 
165  //************ 2 ***************
166 
167  // These are sorted by DetId, i.e. by layer and then by wire #
168  // map<DTDetId, vector<const PSimHit*> > wireMap;
169  DTWireIdMap wireMap;
170 
171  for (MixCollection<PSimHit>::MixItr simHit = simHits->begin(); simHit != simHits->end(); simHit++) {
172  // Create the id of the wire, the simHits in the DT known also the wireId
173 
174  DTWireId wireId((*simHit).detUnitId());
175  // Fill the map
176  wireMap[wireId].push_back(&(*simHit));
177  }
178 
179  pair<float, bool> time(0., false);
180 
181  //************ 3 ***************
182  // Loop over the wires
183  for (DTWireIdMapConstIter wire = wireMap.begin(); wire != wireMap.end(); wire++) {
184  // SimHit Container associated to the wire
185  const vector<const PSimHit *> &vhit = (*wire).second;
186  if (!vhit.empty()) {
187  TDContainer tdCont; // It is a vector<pair<const PSimHit*,float> >;
188 
189  //************ 4 ***************
190  DTWireId wireId = (*wire).first;
191 
192  // const DTLayer* layer = dynamic_cast< const DTLayer* >
193  // (muonGeom->idToDet(wireId.layerId()));
194  const DTLayer *layer = muonGeom->layer(wireId.layerId());
195 
196  // Loop on the hits of this wire
197  for (vector<const PSimHit *>::const_iterator hit = vhit.begin(); hit != vhit.end(); hit++) {
198  //************ 5 ***************
199  LocalPoint locPos = (*hit)->localPosition();
200 
201  const LocalVector BLoc = layer->surface().toLocal(magnField->inTesla(layer->surface().toGlobal(locPos)));
202 
203  time = computeTime(layer, wireId, *hit, BLoc, engine);
204 
205  //************ 6 ***************
206  if (time.second) {
207  tdCont.push_back(make_pair((*hit), time.first));
208  } else {
209  if (debug)
210  LogPrint("DTDigitizer") << "hit discarded" << endl;
211  }
212  }
213 
214  //************ 7 ***************
215 
216  // the loading must be done by layer but
217  // the digitization must be done by wire (in order to take into account
218  // the dead time)
219 
220  storeDigis(wireId, tdCont, *output, *outputLinks);
221  }
222  }
223 
224  //************ 8 ***************
225  // Load the Digi Container in the Event
226  // iEvent.put(std::move(output),"MuonDTDigis");
227  iEvent.put(std::move(output));
228  iEvent.put(std::move(outputLinks));
229 }

References cf_token, computeTime(), debug, geometryType, edm::EventSetup::get(), get, edm::RandomNumberGenerator::getEngine(), iEvent, MagneticField::inTesla(), DTGeometry::layer(), DTWireId::layerId(), eostools::move(), convertSQLitetoXML_cfg::output, edm::Handle< T >::product(), rpcPointValidation_cfi::simHit, FastTrackerRecHitCombiner_cfi::simHits, storeDigis(), GeomDet::surface(), ntuplemaker::time, Surface::toGlobal(), and GloballyPositioned< T >::toLocal().

◆ storeDigis()

void DTDigitizer::storeDigis ( DTWireId wireId,
TDContainer hits,
DTDigiCollection output,
DTDigiSimLinkCollection outputLinks 
)
private

Definition at line 500 of file DTDigitizer.cc.

503  {
504  //************ 7A ***************
505 
506  // sort signal times
507  sort(hits.begin(), hits.end(), hitLessT());
508 
509  //************ 7B ***************
510 
511  float wakeTime = -999999.0;
512  float resolTime = -999999.0;
513  int digiN = -1; // Digi identifier within the cell (for multiple digis)
514  DTDigi digi;
515 
516  // loop over signal times and drop signals inside dead time
517  for (TDContainer::const_iterator hit = hits.begin(); hit != hits.end(); hit++) {
518  if (onlyMuHits && abs((*hit).first->particleType()) != 13)
519  continue;
520 
521  //************ 7C ***************
522 
523  float time = (*hit).second;
524  if (time > wakeTime) {
525  // Note that digi is constructed with a float value (in ns)
526  int wireN = wireId.wire();
527  digiN++;
528  digi = DTDigi(wireN, time, digiN, base);
529 
530  // Add association between THIS digi and the corresponding SimTrack
531  unsigned int SimTrackId = (*hit).first->trackId();
532  EncodedEventId evId = (*hit).first->eventId();
533  DTDigiSimLink digisimLink(wireN, digiN, time, SimTrackId, evId, base);
534 
535  if (debug) {
536  LogPrint("DTDigitizer") << endl << "---- DTDigitizer ----" << endl;
537  LogPrint("DTDigitizer") << "wireId: " << wireId << endl;
538  LogPrint("DTDigitizer") << "sim. time = " << time << endl;
539  LogPrint("DTDigitizer") << "digi number = " << digi.number() << ", digi time = " << digi.time()
540  << ", linked to SimTrack Id = " << SimTrackId << endl;
541  }
542 
543  //************ 7D ***************
544  DTLayerId layerID = wireId.layerId(); // taking the layer of the wire
545  output.insertDigi(layerID, digi); // ordering Digis by layer
546  outputLinks.insertDigi(layerID, digisimLink);
547  wakeTime = time + deadTime;
548  resolTime = time + LinksTimeWindow;
549  } else if (MultipleLinks && time < resolTime) {
550  int wireN = wireId.wire();
551  unsigned int SimTrackId = (*hit).first->trackId();
552  EncodedEventId evId = (*hit).first->eventId();
553  DTDigiSimLink digisimLink(wireN, digiN, time, SimTrackId, evId, base);
554  DTLayerId layerID = wireId.layerId();
555  outputLinks.insertDigi(layerID, digisimLink);
556 
557  if (debug) {
558  LogPrint("DTDigitizer") << "\nAdded multiple link: \n"
559  << "digi number = " << digi.number() << ", digi time = " << digi.time()
560  << " (sim. time = " << time << ")"
561  << ", linked to SimTrack Id = " << SimTrackId << endl;
562  }
563  }
564  }
565 }

References funct::abs(), base, deadTime, debug, hfClusterShapes_cfi::hits, MuonDigiCollection< IndexType, DigiType >::insertDigi(), DTWireId::layerId(), LinksTimeWindow, MultipleLinks, DTDigi::number(), onlyMuHits, convertSQLitetoXML_cfg::output, DTDigi::time(), ntuplemaker::time, and DTWireId::wire().

Referenced by produce().

Friends And Related Function Documentation

◆ DTDigitizerAnalysis

friend class DTDigitizerAnalysis
friend

Definition at line 102 of file DTDigitizer.h.

Member Data Documentation

◆ base

int DTDigitizer::base
private

Definition at line 111 of file DTDigitizer.h.

Referenced by storeDigis().

◆ cf_token

edm::EDGetTokenT<CrossingFrame<PSimHit> > DTDigitizer::cf_token
private

Definition at line 130 of file DTDigitizer.h.

Referenced by produce().

◆ collection_for_XF

std::string DTDigitizer::collection_for_XF
private

Definition at line 128 of file DTDigitizer.h.

◆ deadTime

float DTDigitizer::deadTime
private

Definition at line 106 of file DTDigitizer.h.

Referenced by storeDigis().

◆ debug

bool DTDigitizer::debug
private

◆ geometryType

std::string DTDigitizer::geometryType
private

Definition at line 116 of file DTDigitizer.h.

Referenced by produce().

◆ IdealModel

bool DTDigitizer::IdealModel
private

Definition at line 119 of file DTDigitizer.h.

Referenced by computeTime().

◆ interpolate

bool DTDigitizer::interpolate
private

Definition at line 109 of file DTDigitizer.h.

Referenced by driftTimeFromParametrization().

◆ LinksTimeWindow

float DTDigitizer::LinksTimeWindow
private

Definition at line 124 of file DTDigitizer.h.

Referenced by storeDigis().

◆ mix_

std::string DTDigitizer::mix_
private

Definition at line 127 of file DTDigitizer.h.

◆ MultipleLinks

bool DTDigitizer::MultipleLinks
private

Definition at line 123 of file DTDigitizer.h.

Referenced by storeDigis().

◆ onlyMuHits

bool DTDigitizer::onlyMuHits
private

Definition at line 110 of file DTDigitizer.h.

Referenced by storeDigis().

◆ smearing

float DTDigitizer::smearing
private

Definition at line 107 of file DTDigitizer.h.

Referenced by driftTimeFromParametrization().

◆ syncName

std::string DTDigitizer::syncName
private

Definition at line 113 of file DTDigitizer.h.

◆ theConstVDrift

float DTDigitizer::theConstVDrift
private

Definition at line 120 of file DTDigitizer.h.

Referenced by computeTime().

◆ theSync

std::unique_ptr<DTDigiSyncBase> DTDigitizer::theSync
private

Definition at line 114 of file DTDigitizer.h.

Referenced by externalDelays().

◆ vPropWire

double DTDigitizer::vPropWire
private

Definition at line 105 of file DTDigitizer.h.

Referenced by externalDelays().

Vector3DBase< float, LocalTag >
DTDriftTimeParametrization::MB_DT_drift_time
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.
Definition: DTDriftTimeParametrization.cc:32
DTDigitizer::MultipleLinks
bool MultipleLinks
Definition: DTDigitizer.h:123
DTDigitizer::theConstVDrift
float theConstVDrift
Definition: DTDigitizer.h:120
edm::RandomNumberGenerator::getEngine
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
DTWireId::wire
int wire() const
Return the wire number.
Definition: DTWireId.h:42
MagneticField::inTesla
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
DTTopology::xMax
Definition: DTTopology.h:89
DTDigitizer::DTWireIdMap
std::map< DTWireId, std::vector< const PSimHit * > > DTWireIdMap
Definition: DTDigitizer.h:56
SiStripPI::mean
Definition: SiStripPayloadInspectorHelper.h:169
edm::Handle::product
T const * product() const
Definition: Handle.h:70
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
hit::y
double y
Definition: SiStripHitEffFromCalibTree.cc:90
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:32
DTDigi::number
int number() const
Identifies different digis within the same cell.
Definition: DTDigi.cc:43
DTDigitizer::dumpHit
void dumpHit(const PSimHit *hit, float xEntry, float xExit, const DTTopology &topo)
Definition: DTDigitizer.cc:567
DTDigitizer::driftTimeFromParametrization
std::pair< float, bool > driftTimeFromParametrization(float x, float alpha, float By, float Bz, CLHEP::HepRandomEngine *) const
Definition: DTDigitizer.cc:377
FastTrackerRecHitCombiner_cfi.simHits
simHits
Definition: FastTrackerRecHitCombiner_cfi.py:5
DTDigiCollection
MuonDigiCollection< DTLayerId, DTDigi > DTDigiCollection
Definition: DTDigiCollection.h:15
DTDriftTimeParametrization
Definition: DTDriftTimeParametrization.h:25
DTTopology::Side
Side
Sides of the cell.
Definition: DTTopology.h:89
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
DDAxes::x
edm::Handle
Definition: AssociativeIterator.h:50
DTDigi::time
double time() const
Get time in ns.
Definition: DTDigi.cc:37
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
MixCollection::MixItr
Definition: MixCollection.h:62
DTDigitizer::LinksTimeWindow
float LinksTimeWindow
Definition: DTDigitizer.h:124
DTTopology::cellWidth
float cellWidth() const
Returns the cell width.
Definition: DTTopology.h:69
DTTopology
Definition: DTTopology.h:28
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
EncodedEventId
Definition: EncodedEventId.h:11
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
GeomDet::surface
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
DTTopology::wirePosition
float wirePosition(int wireNumber) const
Returns the x position in the layer of a given wire number.
Definition: DTTopology.cc:59
Vector3DBase::unit
Vector3DBase unit() const
Definition: Vector3DBase.h:54
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
DTWireId
Definition: DTWireId.h:12
MixCollection
Definition: MixCollection.h:11
DTDriftTimeParametrization::drift_time
Structure used to return output values.
Definition: DTDriftTimeParametrization.h:34
rpcPointValidation_cfi.simHit
simHit
Definition: rpcPointValidation_cfi.py:24
PVValHelper::pT
Definition: PVValidationHelpers.h:70
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
DTDigitizer::IdealModel
bool IdealModel
Definition: DTDigitizer.h:119
Surface::toGlobal
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
edm::ESHandle< DTGeometry >
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
Point3DBase< float, LocalTag >
DTDigitizer::base
int base
Definition: DTDigitizer.h:111
OrderedSet.t
t
Definition: OrderedSet.py:90
DTDigitizer::cf_token
edm::EDGetTokenT< CrossingFrame< PSimHit > > cf_token
Definition: DTDigitizer.h:130
DTTopology::onWhichBorder
Side onWhichBorder(float x, float y, float z) const
Definition: DTTopology.cc:78
DTLayerId
Definition: DTLayerId.h:12
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DTTopology::cellLenght
float cellLenght() const
Definition: DTTopology.h:74
DTDigitizer::interpolate
bool interpolate
Definition: DTDigitizer.h:109
GeomDetEnumerators::DT
Definition: GeomDetEnumerators.h:18
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
DTGeometry::layer
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.
Definition: DTGeometry.cc:96
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
DTDigitizer::storeDigis
void storeDigis(DTWireId &wireId, TDContainer &hits, DTDigiCollection &output, DTDigiSimLinkCollection &outputLinks)
Definition: DTDigitizer.cc:500
dumpMFGeometry_cfg.delta
delta
Definition: dumpMFGeometry_cfg.py:25
DTDigitizer::debug
bool debug
Definition: DTDigitizer.h:108
DTDigitizer::smearing
float smearing
Definition: DTDigitizer.h:107
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
DTDigitizer::asymGausSmear
float asymGausSmear(double mean, double sigmaLeft, double sigmaRight, CLHEP::HepRandomEngine *) const
Definition: DTDigitizer.cc:449
edm::Service< edm::RandomNumberGenerator >
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
DTDigitizer::DTWireIdMapConstIter
DTWireIdMap::const_iterator DTWireIdMapConstIter
Definition: DTDigitizer.h:58
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:50
Vector3DBase::cross
Vector3DBase< typename PreciseFloatType< T, U >::Type, FrameTag > cross(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:110
edm::LogPrint
Definition: MessageLogger.h:342
DTDigitizer::vPropWire
double vPropWire
Definition: DTDigitizer.h:105
get
#define get
DTTopology::none
Definition: DTTopology.h:89
DTDigitizer::theSync
std::unique_ptr< DTDigiSyncBase > theSync
Definition: DTDigitizer.h:114
Vector3DBase::dot
PreciseFloatType< T, U >::Type dot(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:99
DTLayer
Definition: DTLayer.h:25
DTTopology::cellHeight
float cellHeight() const
Returns the cell height.
Definition: DTTopology.h:71
PV3DBase::mag
T mag() const
Definition: PV3DBase.h:64
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
DTDigitizer::deadTime
float deadTime
Definition: DTDigitizer.h:106
mag
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Definition: Basic3DVectorLD.h:127
DTDigitizer::mix_
std::string mix_
Definition: DTDigitizer.h:127
eostools.move
def move(src, dest)
Definition: eostools.py:511
DTDigiSimLinkCollection
MuonDigiCollection< DTLayerId, DTDigiSimLink > DTDigiSimLinkCollection
Definition: DTDigiSimLinkCollection.h:8
GloballyPositioned::toLocal
LocalPoint toLocal(const GlobalPoint &gp) const
Definition: GloballyPositioned.h:98
Exception
Definition: hltDiff.cc:246
DTDigitizer::TDContainer
std::vector< hitAndT > TDContainer
Definition: DTDigitizer.h:54
DTDigitizer::collection_for_XF
std::string collection_for_XF
Definition: DTDigitizer.h:128
MuonDigiCollection::insertDigi
void insertDigi(const IndexType &index, const DigiType &digi)
insert a digi for a given DetUnit
Definition: MuonDigiCollection.h:98
DTDigi
Definition: DTDigi.h:17
DTDigitizer::driftTimeFromTimeMap
std::pair< float, bool > driftTimeFromTimeMap() const
Definition: DTDigitizer.cc:466
DTLayer::specificTopology
const DTTopology & specificTopology() const
Definition: DTLayer.cc:37
DTDigitizer::computeTime
std::pair< float, bool > computeTime(const DTLayer *layer, const DTWireId &wireId, const PSimHit *hit, const LocalVector &BLoc, CLHEP::HepRandomEngine *)
Definition: DTDigitizer.cc:231
DTDigitizer::geometryType
std::string geometryType
Definition: DTDigitizer.h:116
DTWireId::layerId
DTLayerId layerId() const
Return the corresponding LayerId.
Definition: DTWireId.h:45
ztail.d
d
Definition: ztail.py:151
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
DTDigitizer::onlyMuHits
bool onlyMuHits
Definition: DTDigitizer.h:110
ntuplemaker.time
time
Definition: ntuplemaker.py:310
DTTopology::xMin
Definition: DTTopology.h:89
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
hit
Definition: SiStripHitEffFromCalibTree.cc:88
RemoveAddSevLevel.flag
flag
Definition: RemoveAddSevLevel.py:116
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23
DTDigitizer::externalDelays
float externalDelays(const DTLayer *layer, const DTWireId &wireId, const PSimHit *hit) const
Definition: DTDigitizer.cc:475