15 #include <CLHEP/Random/RandFlat.h> 16 #include <CLHEP/Random/RandGaussQ.h> 62 debug = conf_.getUntrackedParameter<
bool>(
"debug");
65 LogPrint(
"DTDigitizer") <<
"Creating a DTDigitizer" << endl;
70 produces<DTDigiCollection>();
72 produces<DTDigiSimLinkCollection>();
77 onlyMuHits = conf_.getParameter<
bool>(
"onlyMuHits");
80 interpolate = conf_.getParameter<
bool>(
"interpolate");
86 vPropWire = conf_.getParameter<
double>(
"vPropWire");
89 deadTime = conf_.getParameter<
double>(
"deadTime");
92 smearing = conf_.getParameter<
double>(
"Smearing");
96 IdealModel = conf_.getParameter<
bool>(
"IdealModel");
100 theConstVDrift = conf_.getParameter<
double>(
"IdealModelConstantDriftVelocity");
107 throw cms::Exception(
"Configuration") <<
"RandomNumberGeneratorService for DTDigitizer missing in cfg file";
132 LogPrint(
"DTDigitizer") <<
"--- Run: " << iEvent.
id().
run() <<
" Event: " << iEvent.
id().
event() << endl;
167 DTWireId wireId((*simHit).detUnitId());
169 wireMap[wireId].push_back(&(*
simHit));
172 pair<float, bool>
time(0.,
false);
178 const vector<const PSimHit *> &vhit = (*wire).second;
190 for (vector<const PSimHit *>::const_iterator
hit = vhit.begin();
hit != vhit.end();
hit++) {
200 tdCont.push_back(make_pair((*
hit), time.first));
203 LogPrint(
"DTDigitizer") <<
"hit discarded" << endl;
213 storeDigis(wireId, tdCont, *output, *outputLinks);
228 CLHEP::HepRandomEngine *engine) {
238 LogPrint(
"DTDigitizer") <<
"Hit local entry point: " << entryP << endl <<
"Hit local exit point: " << exitP << endl;
241 float xEntry = entryP.
x() - xwire;
242 float xExit = exitP.
x() - xwire;
245 LogPrint(
"DTDigitizer") <<
"wire position: " << xwire <<
" x entry in cell rf: " << xEntry
246 <<
" x exit in cell rf: " << xExit << endl;
252 dumpHit(hit, xEntry, xExit, topo);
255 pair<float, bool> driftTime(0.,
false);
263 LogPrint(
"DTDigitizer") <<
" e- hit in gas; discarding " << endl;
276 float cosAlpha = hHat.
dot(pHat);
277 float sinAlpha =
sqrt(1. - cosAlpha * cosAlpha);
278 float radius_P = (d.
mag()) / (2. * cosAlpha);
279 float sagitta_P = radius_P * (1. - sinAlpha);
283 float halfd = d.
mag() / 2.;
284 float BMag = BLoc.
mag();
286 float radius_B = (pT.
mag() / (0.3 * BMag)) * 100.;
288 if (radius_B > halfd) {
289 sagitta_B = radius_B -
sqrt(radius_B * radius_B - halfd * halfd);
291 sagitta_B = radius_B;
298 LogPrint(
"DTDigitizer") <<
" delta = " << delta << endl
299 <<
" cosAlpha = " << cosAlpha << endl
300 <<
" sinAlpha = " << sinAlpha << endl
301 <<
" pMag = " << pT.
mag() << endl
302 <<
" bMag = " << BMag << endl
303 <<
" pT = " << pT << endl
304 <<
" halfd = " << halfd << endl
305 <<
" radius_P (cm) = " << radius_P << endl
306 <<
" sagitta_P (um) = " << sagitta_P * 10000. << endl
307 <<
" radius_B (cm) = " << radius_B << endl
308 <<
" sagitta_B (um) = " << sagitta_B * 10000. << endl;
312 || (entrySide == exitSide)
320 && (noParametrisation ==
false)) {
322 LogPrint(
"DTDigitizer") <<
"*** WARNING: hit is not straight, type = " << partType << endl;
327 if (!noParametrisation) {
330 float theta = atan(dir.
x() / -dir.
z()) * 180 /
M_PI;
341 if (fabs(pt.
z()) < 0.002) {
345 x = xEntry - (entryP.
z() * (xExit - xEntry)) / (exitP.
z() - entryP.
z());
354 if ((driftTime.second) ==
false) {
362 if (driftTime.second) {
371 float x,
float theta,
float By,
float Bz, CLHEP::HepRandomEngine *engine)
const {
379 LogPrint(
"DTDigitizer") <<
"*** WARNING: parametrisation: x out of range = " << x <<
", skipping" << endl;
380 return pair<float, bool>(0.f,
false);
388 float theta_par =
theta;
392 if (fabs(theta_par) > 45.) {
394 LogPrint(
"DTDigitizer") <<
"*** WARNING: extrapolating theta > 45: " << theta << endl;
397 if (fabs(By_par) > 0.75) {
399 LogPrint(
"DTDigitizer") <<
"*** WARNING: extrapolating Bnorm > 0.75: " << By_par << endl;
402 if (fabs(Bz_par) > 0.4) {
404 LogPrint(
"DTDigitizer") <<
"*** WARNING: extrapolating Bwire >0.4: " << Bz_par << endl;
413 LogPrint(
"DTDigitizer") <<
" Parametrisation: x, theta, Bnorm, Bwire = " << x <<
" " << theta_par <<
" " 414 << By_par <<
" " << Bz_par << endl
418 LogPrint(
"DTDigitizer") <<
"*** WARNING: call to parametrisation failed" << endl;
419 return pair<float, bool>(0.f,
false);
427 time =
max(time, 0.
f);
433 double u = CLHEP::RandGaussQ::shoot(engine, 0.,
smearing);
437 LogPrint(
"DTDigitizer") <<
" drift time = " << time << endl;
439 return pair<float, bool>(
time,
true);
445 CLHEP::HepRandomEngine *engine)
const {
446 double f = sigmaLeft / (sigmaLeft + sigmaRight);
449 if (CLHEP::RandFlat::shoot(engine) <=
f) {
450 t = CLHEP::RandGaussQ::shoot(engine, mean, sigmaLeft);
451 t = mean - fabs(t - mean);
453 t = CLHEP::RandGaussQ::shoot(engine, mean, sigmaRight);
454 t = mean + fabs(t - mean);
456 return static_cast<float>(
t);
462 LogPrint(
"DTDigitizer") <<
" TimeMap " << endl;
463 return pair<float, bool>(0.,
false);
473 float propgL = halfL - wireCoord;
478 float tof = hit->
tof();
482 double sync =
theSync->digitizerOffset(&wireId, layer);
485 LogPrint(
"DTDigitizer") <<
" propDelay =" << propDelay <<
"; TOF=" << tof <<
"; sync= " << sync << endl;
488 return propDelay + tof + sync;
500 sort(hits.begin(), hits.end(),
hitLessT());
504 float wakeTime = -999999.0;
505 float resolTime = -999999.0;
510 for (TDContainer::const_iterator
hit = hits.begin();
hit != hits.end();
hit++) {
516 float time = (*hit).second;
517 if (time > wakeTime) {
519 int wireN = wireId.
wire();
521 digi =
DTDigi(wireN, time, digiN);
524 unsigned int SimTrackId = (*hit).first->trackId();
526 DTDigiSimLink digisimLink(wireN, digiN, time, SimTrackId, evId);
529 LogPrint(
"DTDigitizer") << endl <<
"---- DTDigitizer ----" << endl;
530 LogPrint(
"DTDigitizer") <<
"wireId: " << wireId << endl;
531 LogPrint(
"DTDigitizer") <<
"sim. time = " << time << endl;
532 LogPrint(
"DTDigitizer") <<
"digi number = " << digi.
number() <<
", digi time = " << digi.
time()
533 <<
", linked to SimTrack Id = " << SimTrackId << endl;
539 output.insertDigi(layerID, digi);
547 int wireN = wireId.
wire();
548 unsigned int SimTrackId = (*hit).first->trackId();
550 DTDigiSimLink digisimLink(wireN, digiN, time, SimTrackId, evId);
555 LogPrint(
"DTDigitizer") <<
"\nAdded multiple link: \n" 556 <<
"digi number = " << digi.
number() <<
", digi time = " << digi.
time()
557 <<
" (sim. time = " << time <<
")" 558 <<
", linked to SimTrack Id = " << SimTrackId << endl;
573 <<
"------- SimHit: " << endl
575 <<
" process type = " << hit->
processType() << endl
579 <<
" trackId = " << hit->
trackId()
582 <<
" |p| = " << hit->
pabs() << endl
591 <<
" Entry point = " << entryP <<
" cell x = " << xEntry << endl
592 <<
" Exit point = " << exitP <<
" cell x = " << xExit << endl
593 <<
" DR = = " << (exitP - entryP).
mag() << endl
594 <<
" Dx = = " << (exitP - entryP).
x() << endl
597 <<
" DY entry from edge = " << topo.
cellLenght() / 2. - fabs(entryP.
y())
598 <<
" DY exit from edge = " << topo.
cellLenght() / 2. - fabs(exitP.
y())
599 <<
" entrySide = " << (
int)entrySide <<
" ; exitSide = " << (
int)exitSide << endl;
std::pair< float, bool > computeTime(const DTLayer *layer, const DTWireId &wireId, const PSimHit *hit, const LocalVector &BLoc, CLHEP::HepRandomEngine *)
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
T getParameter(std::string const &) const
EventNumber_t event() const
void dumpHit(const PSimHit *hit, float xEntry, float xExit, const DTTopology &topo)
float wirePosition(int wireNumber) const
Returns the x position in the layer of a given wire number.
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
float tof() const
deprecated name for timeOfFlight()
Side onWhichBorder(float x, float y, float z) const
LocalVector momentumAtEntry() const
The momentum of the track that produced the hit, at entry point.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Geom::Theta< T > theta() const
float cellWidth() const
Returns the cell width.
PreciseFloatType< T, U >::Type dot(const Vector3DBase< U, FrameTag > &v) const
void insertDigi(const IndexType &index, const DigiType &digi)
insert a digi for a given DetUnit
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
const Plane & surface() const
The nominal surface of the GeomDet.
const DTTopology & specificTopology() const
double time() const
Get time in ns.
Local3DPoint exitPoint() const
Exit point in the local Det frame.
void storeDigis(DTWireId &wireId, TDContainer &hits, DTDigiCollection &output, DTDigiSimLinkCollection &outputLinks)
Local3DPoint localPosition() const
LocalPoint toLocal(const GlobalPoint &gp) const
Vector3DBase< typename PreciseFloatType< T, U >::Type, FrameTag > cross(const Vector3DBase< U, FrameTag > &v) const
Abs< T >::type abs(const T &t)
edm::EDGetTokenT< CrossingFrame< PSimHit > > cf_token
DTDigitizer(const edm::ParameterSet &)
float cellHeight() const
Returns the cell height.
float pabs() const
fast and more accurate access to momentumAtEntry().mag()
DTWireIdMap::const_iterator DTWireIdMapConstIter
uint32_t countsTDC() const
Get raw TDC count.
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
std::unique_ptr< DTDigiSyncBase > theSync
LocalVector localDirection() const
Obsolete. Same as momentumAtEntry().unit(), for backward compatibility.
int wire() const
Return the wire number.
Vector3DBase unit() const
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.
std::pair< float, bool > driftTimeFromParametrization(float x, float alpha, float By, float Bz, CLHEP::HepRandomEngine *) const
T const * product() const
unsigned short processType() const
std::vector< hitAndT > TDContainer
Structure used to return output values.
void produce(edm::Event &, const edm::EventSetup &) override
DTLayerId layerId() const
Return the corresponding LayerId.
float energyLoss() const
The energy deposit in the PSimHit, in ???.
MuonDigiCollection< DTLayerId, DTDigi > DTDigiCollection
int number() const
Identifies different digis within the same.
StreamID streamID() const
unsigned int trackId() const
float externalDelays(const DTLayer *layer, const DTWireId &wireId, const PSimHit *hit) const
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.
MuonDigiCollection< DTLayerId, DTDigiSimLink > DTDigiSimLinkCollection
std::map< DTWireId, std::vector< const PSimHit * > > DTWireIdMap
std::pair< float, bool > driftTimeFromTimeMap() const
Local3DPoint entryPoint() const
Entry point in the local Det frame.
Power< A, B >::type pow(const A &a, const B &b)
float asymGausSmear(double mean, double sigmaLeft, double sigmaRight, CLHEP::HepRandomEngine *) const
T get(const Candidate &c)
std::string collection_for_XF
A container for a generic type of digis indexed by some index, implemented with a map<IndexType...