111 : theEstimator(iConfig.getParameter<double>(
"Chi2EstimatorCut")),
112 propagatorWithoutMaterial(nullptr),
126 produces<edm::PSimHitContainer>(
"MuonCSCHits");
127 produces<edm::PSimHitContainer>(
"MuonDTHits");
128 produces<edm::PSimHitContainer>(
"MuonRPCHits");
146 bool duringEvent =
false;
172 std::vector<PSimHit> theCSCHits;
173 std::vector<PSimHit> theDTHits;
174 std::vector<PSimHit> theRPCHits;
180 for (
unsigned int itrk = 0; itrk < simMuons->size(); itrk++) {
181 const SimTrack& mySimTrack = (*simMuons)[itrk];
187 int pid = mySimTrack.
type();
188 if (
abs(pid) != 13 &&
abs(pid) != 1000024)
194 t0 = (*simVertices)[ivert].position().t();
198 initialPosition = xyzzy;
205 double tof = t0 / 29.98;
208 std::cout <<
" ===> MuonSimHitProducer::reconstruct() found SIMTRACK - pid = " << pid;
209 std::cout <<
" : pT = " << mySimP4.Pt() <<
", eta = " << mySimP4.Eta() <<
", phi = " << mySimP4.Phi() << std::endl;
227 GlobalVector dtracker = startingPosition - initialPosition;
228 tof += dtracker.
mag() / 29.98;
231 std::cout <<
" the Muon START position " << startingPosition << std::endl;
232 std::cout <<
" the Muon START momentum " << startingMomentum << std::endl;
247 std::vector<const DetLayer*> navLayers;
248 if (fabs(startingState.globalMomentum().eta()) > 4.5) {
249 navLayers = navigation.compatibleEndcapLayers(*(startingState.freeState()),
alongMomentum);
251 navLayers = navigation.compatibleLayers(*(startingState.freeState()),
alongMomentum);
258 if (navLayers.empty())
262 std::cout <<
"Found " << navLayers.size() <<
" compatible DetLayers..." << std::endl;
266 for (
unsigned int ilayer = 0; ilayer < navLayers.size(); ilayer++) {
268 std::cout <<
"Propagating to layer " << ilayer <<
" " << dumper.dumpLayer(navLayers[ilayer]) << std::endl;
271 std::vector<DetWithState> comps =
277 std::cout <<
"Propagating " << propagatedState << std::endl;
287 ->propagate(shsStart, navLayers[ilayer]->surface(), shsDest);
288 std::pair<TrajectoryStateOnSurface, double>
next(shsDest.
getStateOnSurface(navLayers[ilayer]->surface()),
292 if (!
next.first.isValid())
296 double radPath = shsDest.
radPath();
297 double pathLength =
next.second;
301 std::pair<TrajectoryStateOnSurface, double> nextNoMaterial =
305 propagatedState =
next.first;
314 if (!propagatedState.
isValid())
322 double pavg = 0.5 * (pi + pf);
323 double m = mySimP4.M();
324 double rbeta =
sqrt(1 + m * m / (pavg * pavg)) / 29.98;
325 double dtof = pathLength * rbeta;
328 std::cout <<
"Propagated to next surface... path length = " << pathLength <<
" cm, dTOF = " << dtof <<
" ns"
334 for (
unsigned int icomp = 0; icomp < comps.size(); icomp++) {
335 const GeomDet* gd = comps[icomp].first;
339 std::vector<const DTSuperLayer*> superlayer = chamber->
superLayers();
340 for (
unsigned int isl = 0; isl < superlayer.size(); isl++) {
341 std::vector<const DTLayer*>
layer = superlayer[isl]->layers();
342 for (
unsigned int ilayer = 0; ilayer < layer.size(); ilayer++) {
355 std::pair<bool, double>
path = crossing.pathLength(det->
surface());
361 const DTTopology& dtTopo = layer[ilayer]->specificTopology();
362 int wire = dtTopo.
channel(lpos);
375 double pmu = lmom.
mag();
376 double theDTHitIneff = pmu > 0 ?
exp(
kDT *
log(pmu) +
fDT) : 0.;
377 if (random.flatShoot() < theDTHitIneff)
381 double pz = fabs(lmom.
z());
384 double dtof = path.second * rbeta;
385 int trkid = mySimTrack.
trackId();
386 unsigned int id = wid.
rawId();
387 short unsigned int processType = 2;
389 entry, exit, lmom.
mag(), tof + dtof, eloss, pid,
id, trkid, lmom.
theta(), lmom.
phi(), processType);
390 theDTHits.push_back(
hit);
396 std::vector<const CSCLayer*>
layers = chamber->layers();
397 for (
unsigned int ilayer = 0; ilayer < layers.size(); ilayer++) {
398 CSCDetId lid = layers[ilayer]->id();
402 << lid.
layer() <<
")" << std::endl;
410 std::pair<bool, double>
path = crossing.pathLength(det->
surface());
418 if (!laygeom->
inside(lpos))
427 double pmu = lmom.
mag();
428 double theCSCHitIneff = pmu > 0 ?
exp(
kCSC *
log(pmu) +
fCSC) : 0.;
431 theCSCHitIneff = theCSCHitIneff * 0.442;
432 if (random.flatShoot() < theCSCHitIneff)
436 double pz = fabs(lmom.
z());
439 double dtof = path.second * rbeta;
440 int trkid = mySimTrack.
trackId();
441 unsigned int id = lid.
rawId();
442 short unsigned int processType = 2;
444 entry, exit, lmom.
mag(), tof + dtof, eloss, pid,
id, trkid, lmom.
theta(), lmom.
phi(), processType);
445 theCSCHits.push_back(
hit);
451 std::vector<const RPCRoll*> roll = chamber->
rolls();
452 for (
unsigned int iroll = 0; iroll < roll.size(); iroll++) {
465 std::pair<bool, double>
path = crossing.pathLength(det->
surface());
475 double pz = fabs(lmom.
z());
478 double dtof = path.second * rbeta;
479 int trkid = mySimTrack.
trackId();
480 unsigned int id = rid.
rawId();
481 short unsigned int processType = 2;
483 entry, exit, lmom.
mag(), tof + dtof, eloss, pid,
id, trkid, lmom.
theta(), lmom.
phi(), processType);
484 theRPCHits.push_back(
hit);
487 std::cout <<
"Extrapolated to unknown subdetector '" << gd->
subDetector() <<
"'..." << std::endl;
495 for (std::vector<PSimHit>::const_iterator
i = theCSCHits.begin();
i != theCSCHits.end();
i++) {
503 for (std::vector<PSimHit>::const_iterator
i = theDTHits.begin();
i != theDTHits.end();
i++) {
511 for (std::vector<PSimHit>::const_iterator
i = theRPCHits.begin();
i != theRPCHits.end();
i++) {
527 std::vector<double> simHitIneffDT = fastMuons.
getParameter<std::vector<double> >(
"simHitDTIneffParameters");
528 std::vector<double> simHitIneffCSC = fastMuons.
getParameter<std::vector<double> >(
"simHitCSCIneffParameters");
529 kDT = simHitIneffDT[0];
530 fDT = simHitIneffDT[1];
531 kCSC = simHitIneffCSC[0];
532 fCSC = simHitIneffCSC[1];
550 theMaterialEffects = std::make_unique<MaterialEffects>(matEff);
571 double mu = 0.1056583692;
588 gPosWithdEdx.
x() - gPos.
x(), gPosWithdEdx.
y() - gPos.
y(), gPosWithdEdx.
z() - gPos.
z(), 0.);
590 gMomWithdEdx.
x() - gMom.
x(), gMomWithdEdx.
y() - gMom.
y(), gMomWithdEdx.
z() - gMom.
z(), enWithdEdx - en);
603 fac = (theNewMomentum.E() * theNewMomentum.E() - mu *
mu) / theNewMomentum.Vect().Mag2();
606 theNewMomentum.Px() * fac, theNewMomentum.Py() * fac, theNewMomentum.Pz() * fac, theNewMomentum.E());
611 if (multipleScattering) {
616 multipleScattering->
updateState(theMuon, radPath, random);
620 if (bremsstrahlung) {
622 bremsstrahlung->
updateState(theMuon, radPath, random);
MuonSimHitProducer(const edm::ParameterSet &)
double mostLikelyLoss() const
Return most probable energy loss.
edm::ESHandle< MuonDetLayerGeometry > detLayerGeometry() const
get the detLayer geometry
void setMomentum(const XYZTLorentzVector &vtx)
set the momentum
const math::XYZVectorD & trackerSurfacePosition() const
T getUntrackedParameter(std::string const &, T const &) const
const MagneticField * magfield
Vector3DBase< typename PreciseFloatType< T, U >::Type, FrameTag > cross(const Vector3DBase< U, FrameTag > &v) const
const edm::ESGetToken< HepPDT::ParticleDataTable, edm::DefaultRecord > particleDataTableESToken_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
static std::vector< std::string > checklist log
std::vector< LayerSetAndLayers > layers(const SeedingLayerSetsHits &sets)
const DTGeometry * dtGeom
TrackCharge charge() const
virtual ConstReferenceCountingPointer< TangentPlane > tangentPlane(const GlobalPoint &) const =0
uint16_t *__restrict__ id
std::unique_ptr< Propagator > propagatorWithoutMaterial
virtual bool inside(const Local3DPoint &) const =0
Determine if the point is inside the bounds.
const DTChamber * chamber(const DTChamberId &id) const
Return a DTChamber given its id.
HepPDT::ParticleDataTable ParticleDataTable
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void setNormalVector(const GlobalVector &normal)
Sets the vector normal to the surface traversed.
#define DEFINE_FWK_MODULE(type)
Geom::Phi< T > phi() const
ReturnType plane(const PositionType &pos, const RotationType &rot) const
Global3DPoint GlobalPoint
constexpr uint32_t rawId() const
get the raw id
virtual Propagator * clone() const =0
GlobalPoint globalPosition() const
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
const Bounds & bounds() const
void updateState(ParticlePropagator &myTrack, double radlen, RandomEngineAndDistribution const *)
Compute the material effect (calls the sub class)
const GeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
edm::EDGetTokenT< std::vector< SimVertex > > simVertexToken
Exp< T >::type exp(const T &t)
RawParticle makeMuon(bool isParticle, const math::XYZTLorentzVector &p, const math::XYZTLorentzVector &xStart)
int layer() const
Return the layer number.
RawParticle const & particle() const
The particle being propagated.
float charge() const
charge
const Plane & surface() const
The nominal surface of the GeomDet.
void applyMaterialEffects(TrajectoryStateOnSurface &tsosWithdEdx, TrajectoryStateOnSurface &tsos, double radPath, RandomEngineAndDistribution const *, HepPDT::ParticleDataTable const &)
Simulate material effects in iron (dE/dx, multiple scattering)
const edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeometryESToken_
constexpr std::array< uint8_t, layerIndexSize > layer
int firstChannel() const
Returns the wire number of the first wire.
Geom::Theta< T > theta() const
const RPCGeometry * rpcGeom
LocalVector localMomentum() const
virtual float thickness() const =0
bool getData(T &iHolder) const
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
int lastChannel() const
Returns the wire number of the last wire.
const RPCChamber * chamber(RPCDetId id) const
const SurfaceType & surface() const
const XYZTLorentzVector & momentum() const
the momentum fourvector
FreeTrajectoryState const * freeTrajectoryState(bool withErrors=true) const
const std::vector< const DTSuperLayer * > & superLayers() const
Return the superlayers in the chamber.
const Propagator * propagatorWithMaterial
TrajectoryStateOnSurface getStateOnSurface(const Surface &surf, bool returnTangentPlane=false) const
edm::ESHandle< Propagator > propagator(std::string propagatorName) const
get the propagator
double Y() const
y of vertex
const XYZTLorentzVector & deltaMom() const
Returns the actual energy lost.
double Py() const
y of the momentum
double Z() const
z of vertex
const std::vector< const RPCRoll * > & rolls() const
Return the Rolls.
Abs< T >::type abs(const T &t)
const CSCGeometry * cscGeom
DetId geographicalId() const
The label of this GeomDet.
void beginRun(edm::Run const &run, const edm::EventSetup &es) override
void produce(edm::Event &, const edm::EventSetup &) override
double Pz() const
z of the momentum
const GeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
const edm::ESGetToken< RPCGeometry, MuonGeometryRecord > rpcGeometryESToken_
int vertIndex() const
index of the vertex in the Event container (-1 if no vertex)
const XYZTLorentzVector & vertex() const
the vertex fourvector
int superlayer() const
Return the superlayer number (deprecated method name)
Vector3DBase unit() const
unsigned int trackId() const
const math::XYZTLorentzVectorD & trackerSurfaceMomentum() const
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
T getParameter(std::string const &) const
edm::EDGetTokenT< std::vector< SimTrack > > simMuonToken
int sector() const
Sector id: the group of chambers at same phi (and increasing r)
double X() const
x of vertex
MuonServiceProxy * theService
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldESToken_
int subsector() const
SubSector id : some sectors are divided along the phi direction in subsectors (from 1 to 4 in Barrel...
int type() const
particle type (HEP PDT convension)
void readParameters(const edm::ParameterSet &, const edm::ParameterSet &, const edm::ParameterSet &)
GlobalVector globalMomentum() const
const math::XYZTLorentzVectorD & momentum() const
static int position[264][3]
int channel(const LocalPoint &p) const override
TkRotation< float > RotationType
double Px() const
x of the momentum
edm::InputTag simMuonLabel
StreamID streamID() const
void update(const edm::EventSetup &setup, bool duringEvent=true)
update the services each event
std::vector< PSimHit > PSimHitContainer
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
const edm::ESGetToken< CSCGeometry, MuonGeometryRecord > cscGeometryESToken_
int station() const
Return the station number.
bool inside(const Local3DPoint &, const LocalError &, float scale=1.f) const override
virtual SubDetector subDetector() const
Which subdetector.
int wheel() const
Return the wheel number.
const BasicVectorType & basicVector() const
std::unique_ptr< MaterialEffects > theMaterialEffects
void setMaterialMode(bool noMaterial)
Switch for material effects mode: no material effects if true.
void setVertex(const XYZTLorentzVector &vtx)
set the vertex
Global3DVector GlobalVector
math::XYZTLorentzVector XYZTLorentzVector
const GeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
edm::InputTag simVertexLabel
Chi2MeasurementEstimator theEstimator
double transverseCurvature() const