78 theEstimator(iConfig.getParameter<double>(
"Chi2EstimatorCut")),
79 propagatorWithoutMaterial(
nullptr)
90 produces<edm::PSimHitContainer>(
"MuonCSCHits");
91 produces<edm::PSimHitContainer>(
"MuonDTHits");
92 produces<edm::PSimHitContainer>(
"MuonRPCHits");
164 std::vector<PSimHit> theCSCHits;
165 std::vector<PSimHit> theDTHits;
166 std::vector<PSimHit> theRPCHits;
172 for (
unsigned int itrk=0; itrk<simMuons->size(); itrk++ ) {
173 const SimTrack &mySimTrack = (*simMuons)[itrk];
182 if (
abs(pid) != 13 )
continue;
188 t0 = (*simVertices)[ivert].position().t();
192 initialPosition = xyzzy;
199 double tof = t0/29.98;
202 std::cout <<
" ===> MuonSimHitProducer::reconstruct() found SIMTRACK - pid = " 205 <<
", eta = " << mySimP4.Eta()
206 <<
", phi = " << mySimP4.Phi() << std::endl;
224 GlobalVector dtracker = startingPosition-initialPosition;
225 tof += dtracker.
mag()/29.98;
228 std::cout <<
" the Muon START position " << startingPosition << std::endl;
229 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()),
253 navLayers = navigation.compatibleLayers(*(startingState.freeState()),
261 if ( navLayers.empty() )
continue;
264 std::cout <<
"Found " << navLayers.size()
265 <<
" compatible DetLayers..." << std::endl;
269 for (
unsigned int ilayer=0; ilayer<navLayers.size(); ilayer++ ) {
272 std::cout <<
"Propagating to layer " << ilayer <<
" " 273 << dumper.dumpLayer(navLayers[ilayer])
277 std::vector<DetWithState> comps =
279 if ( comps.empty() )
continue;
282 std::cout <<
"Propagating " << propagatedState << std::endl;
292 std::pair<TrajectoryStateOnSurface,double>
next(shsDest.
getStateOnSurface(navLayers[ilayer]->surface()),
296 if ( !
next.first.isValid() )
continue;
299 double radPath = shsDest.
radPath();
300 double pathLength =
next.second;
304 std::pair<TrajectoryStateOnSurface,double> nextNoMaterial =
308 propagatedState =
next.first;
316 if ( !propagatedState.
isValid() )
continue;
323 double pavg = 0.5*(pi+
pf);
324 double m = mySimP4.M();
325 double rbeta =
sqrt(1+m*m/(pavg*pavg))/29.98;
326 double dtof = pathLength*rbeta;
329 std::cout <<
"Propagated to next surface... path length = " << pathLength
330 <<
" cm, dTOF = " << dtof <<
" ns" << std::endl;
335 for (
unsigned int icomp=0; icomp<comps.size(); icomp++ )
337 const GeomDet *gd = comps[icomp].first;
341 std::vector<const DTSuperLayer *> superlayer = chamber->
superLayers();
342 for (
unsigned int isl=0; isl<superlayer.size(); isl++ ) {
343 std::vector<const DTLayer *> layer = superlayer[isl]->layers();
344 for (
unsigned int ilayer=0; ilayer<layer.size(); ilayer++ ) {
348 << lid.
wheel() <<
"," 352 << lid.
layer() <<
")" << std::endl;
361 std::pair<bool,double>
path = crossing.pathLength(det->
surface());
362 if ( ! path.first )
continue;
365 const DTTopology& dtTopo = layer[ilayer]->specificTopology();
366 int wire = dtTopo.
channel(lpos);
378 double pmu = lmom.
mag();
380 if (
random.flatShoot()<theDTHitIneff)
continue;
383 double pz = fabs(lmom.
z());
386 double dtof = path.second*rbeta;
387 int trkid = mySimTrack.
trackId();
388 unsigned int id = wid.
rawId();
389 short unsigned int processType = 2;
391 tof+dtof,eloss,
pid,
id,trkid,lmom.
theta(),lmom.
phi(),processType);
392 theDTHits.push_back(
hit);
400 std::vector<const CSCLayer *>
layers = chamber->layers();
401 for (
unsigned int ilayer=0; ilayer<layers.size(); ilayer++ ) {
402 CSCDetId lid = layers[ilayer]->id();
409 << lid.
layer() <<
")" << std::endl;
417 std::pair<bool,double>
path = crossing.pathLength(det->
surface());
418 if ( ! path.first )
continue;
424 if ( ! laygeom->
inside( lpos ) )
continue;
432 double pmu = lmom.
mag();
435 if (
id.
station()==1 &&
id.
ring()==1) theCSCHitIneff = theCSCHitIneff*0.442;
436 if (
random.flatShoot()<theCSCHitIneff)
continue;
439 double pz = fabs(lmom.
z());
442 double dtof = path.second*rbeta;
443 int trkid = mySimTrack.
trackId();
444 unsigned int id = lid.
rawId();
445 short unsigned int processType = 2;
447 tof+dtof,eloss,
pid,
id,trkid,lmom.
theta(),lmom.
phi(),processType);
448 theCSCHits.push_back(
hit);
455 std::vector<const RPCRoll *> roll = chamber->
rolls();
456 for (
unsigned int iroll=0; iroll<roll.size(); iroll++ ) {
465 << rid.
layer() <<
"," 466 << rid.
roll() <<
")" << std::endl;
474 std::pair<bool,double>
path = crossing.pathLength(det->
surface());
475 if ( ! path.first )
continue;
482 double pz = fabs(lmom.
z());
485 double dtof = path.second*rbeta;
486 int trkid = mySimTrack.
trackId();
487 unsigned int id = rid.
rawId();
488 short unsigned int processType = 2;
490 tof+dtof,eloss,
pid,
id,trkid,lmom.
theta(),lmom.
phi(),processType);
491 theRPCHits.push_back(
hit);
495 std::cout <<
"Extrapolated to unknown subdetector '" << gd->
subDetector() <<
"'..." << std::endl;
503 for ( std::vector<PSimHit>::const_iterator
i = theCSCHits.begin();
504 i != theCSCHits.end();
i++ ) {
512 for ( std::vector<PSimHit>::const_iterator
i = theDTHits.begin();
513 i != theDTHits.end();
i++ ) {
521 for ( std::vector<PSimHit>::const_iterator
i = theRPCHits.begin();
522 i != theRPCHits.end();
i++ ) {
540 std::vector<double> simHitIneffDT = fastMuons.
getParameter<std::vector<double> >(
"simHitDTIneffParameters");
541 std::vector<double> simHitIneffCSC = fastMuons.
getParameter<std::vector<double> >(
"simHitCSCIneffParameters");
542 kDT = simHitIneffDT[0];
543 fDT = simHitIneffDT[1];
544 kCSC = simHitIneffCSC[0];
545 fCSC = simHitIneffCSC[1];
589 double mu = 0.1056583692;
606 deltaPos(gPosWithdEdx.
x()-gPos.
x(),gPosWithdEdx.
y()-gPos.
y(),
607 gPosWithdEdx.
z()-gPos.
z(),0.);
609 deltaMom(gMomWithdEdx.
x()-gMom.
x(),gMomWithdEdx.
y()-gMom.
y(),
610 gMomWithdEdx.
z()-gMom.
z(), enWithdEdx -en);
623 fac = (theNewMomentum.E()*theNewMomentum.E()-mu*
mu)/theNewMomentum.Vect().Mag2();
626 theNewMomentum.Pz()*fac,theNewMomentum.E());
632 if ( multipleScattering ) {
637 multipleScattering->
updateState(theMuon, radPath, random);
641 if ( bremsstrahlung ) {
643 bremsstrahlung->
updateState(theMuon, radPath, random);
void update(const edm::EventSetup &setup)
update the services each event
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 getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
const MagneticField * magfield
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
virtual Propagator * clone() const =0
virtual ConstReferenceCountingPointer< TangentPlane > tangentPlane(const GlobalPoint &) const =0
const GeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
std::vector< LayerSetAndLayers > layers(const SeedingLayerSetsHits &sets)
int channel(const LocalPoint &p) const override
const DTGeometry * dtGeom
TrackCharge charge() const
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.
MaterialEffects * theMaterialEffects
Geom::Phi< T > phi() const
MultipleScatteringSimulator * multipleScatteringSimulator() const
Return the Multiple Scattering engine.
ReturnType plane(const PositionType &pos, const RotationType &rot) const
Global3DPoint GlobalPoint
constexpr uint32_t rawId() const
get the raw id
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)
edm::EDGetTokenT< std::vector< SimVertex > > simVertexToken
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)
int firstChannel() const
Returns the wire number of the first wire.
Geom::Theta< T > theta() const
const RPCGeometry * rpcGeom
LocalVector localMomentum() const
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
MuonBremsstrahlungSimulator * muonBremsstrahlungSimulator() const
Return the Muon Bremsstrahlung engine.
virtual bool inside(const Local3DPoint &) const =0
Determine if the point is inside the bounds.
const SurfaceType & surface() const
const XYZTLorentzVector & momentum() const
the momentum fourvector
#define DEFINE_FWK_MODULE(type)
const GeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
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
Propagator * propagatorWithoutMaterial
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
virtual std::pair< TrajectoryStateOnSurface, double > propagateWithPath(const FreeTrajectoryState &, const Surface &) const final
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
bool inside(const Local3DPoint &, const LocalError &, float scale=1.f) const override
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
virtual float thickness() const =0
const math::XYZTLorentzVectorD & trackerSurfaceMomentum() const
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
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 GeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
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 &)
~MuonSimHitProducer() override
GlobalVector globalMomentum() const
const math::XYZTLorentzVectorD & momentum() const
static int position[264][3]
TkRotation< float > RotationType
double Px() const
x of the momentum
edm::InputTag simMuonLabel
StreamID streamID() const
std::vector< PSimHit > PSimHitContainer
int station() const
Return the station number.
EnergyLossSimulator * energyLossSimulator() const
Return the Energy Loss engine.
virtual SubDetector subDetector() const
Which subdetector.
int wheel() const
Return the wheel number.
const BasicVectorType & basicVector() const
void setMaterialMode(bool noMaterial)
Switch for material effects mode: no material effects if true.
void setVertex(const XYZTLorentzVector &vtx)
set the vertex
edm::ESHandle< Propagator > propagator(std::string propagatorName) const
get the propagator
Global3DVector GlobalVector
math::XYZTLorentzVector XYZTLorentzVector
edm::InputTag simVertexLabel
Chi2MeasurementEstimator theEstimator
double transverseCurvature() const