81 theEstimator(iConfig.getParameter<double>(
"Chi2EstimatorCut")),
82 propagatorWithoutMaterial(
nullptr)
93 produces<edm::PSimHitContainer>(
"MuonCSCHits");
94 produces<edm::PSimHitContainer>(
"MuonDTHits");
95 produces<edm::PSimHitContainer>(
"MuonRPCHits");
168 std::vector<PSimHit> theCSCHits;
169 std::vector<PSimHit> theDTHits;
170 std::vector<PSimHit> theRPCHits;
176 for (
unsigned int itrk=0; itrk<simMuons->size(); itrk++ ) {
177 const SimTrack &mySimTrack = (*simMuons)[itrk];
186 if (
abs(pid) != 13 )
continue;
192 t0 = (*simVertices)[ivert].position().t();
196 initialPosition = xyzzy;
203 double tof = t0/29.98;
206 std::cout <<
" ===> MuonSimHitProducer::reconstruct() found SIMTRACK - pid = " 209 <<
", eta = " << mySimP4.Eta()
210 <<
", phi = " << mySimP4.Phi() << std::endl;
228 GlobalVector dtracker = startingPosition-initialPosition;
229 tof += dtracker.
mag()/29.98;
232 std::cout <<
" the Muon START position " << startingPosition << std::endl;
233 std::cout <<
" the Muon START momentum " << startingMomentum << std::endl;
251 std::vector<const DetLayer *> navLayers;
252 if ( fabs(startingState.globalMomentum().eta()) > 4.5 ) {
253 navLayers = navigation.compatibleEndcapLayers(*(startingState.freeState()),
257 navLayers = navigation.compatibleLayers(*(startingState.freeState()),
265 if ( navLayers.empty() )
continue;
268 std::cout <<
"Found " << navLayers.size()
269 <<
" compatible DetLayers..." << std::endl;
273 for (
unsigned int ilayer=0; ilayer<navLayers.size(); ilayer++ ) {
276 std::cout <<
"Propagating to layer " << ilayer <<
" " 277 << dumper.dumpLayer(navLayers[ilayer])
281 std::vector<DetWithState> comps =
283 if ( comps.empty() )
continue;
286 std::cout <<
"Propagating " << propagatedState << std::endl;
296 std::pair<TrajectoryStateOnSurface,double>
next(shsDest.
getStateOnSurface(navLayers[ilayer]->surface()),
300 if ( !
next.first.isValid() )
continue;
303 double radPath = shsDest.
radPath();
304 double pathLength =
next.second;
308 std::pair<TrajectoryStateOnSurface,double> nextNoMaterial =
312 propagatedState =
next.first;
320 if ( !propagatedState.
isValid() )
continue;
327 double pavg = 0.5*(pi+
pf);
328 double m = mySimP4.M();
329 double rbeta =
sqrt(1+m*m/(pavg*pavg))/29.98;
330 double dtof = pathLength*rbeta;
333 std::cout <<
"Propagated to next surface... path length = " << pathLength
334 <<
" cm, dTOF = " << dtof <<
" ns" << std::endl;
339 for (
unsigned int icomp=0; icomp<comps.size(); icomp++ )
341 const GeomDet *gd = comps[icomp].first;
345 std::vector<const DTSuperLayer *> superlayer = chamber->
superLayers();
346 for (
unsigned int isl=0; isl<superlayer.size(); isl++ ) {
347 std::vector<const DTLayer *> layer = superlayer[isl]->layers();
348 for (
unsigned int ilayer=0; ilayer<layer.size(); ilayer++ ) {
352 << lid.
wheel() <<
"," 356 << lid.
layer() <<
")" << std::endl;
365 std::pair<bool,double>
path = crossing.pathLength(det->
surface());
366 if ( ! path.first )
continue;
369 const DTTopology& dtTopo = layer[ilayer]->specificTopology();
382 double pmu = lmom.
mag();
384 if (
random.flatShoot()<theDTHitIneff)
continue;
387 double pz = fabs(lmom.
z());
390 double dtof = path.second*rbeta;
391 int trkid = mySimTrack.
trackId();
392 unsigned int id = wid.
rawId();
393 short unsigned int processType = 2;
395 tof+dtof,eloss,
pid,
id,trkid,lmom.
theta(),lmom.
phi(),processType);
396 theDTHits.push_back(
hit);
404 std::vector<const CSCLayer *>
layers = chamber->layers();
405 for (
unsigned int ilayer=0; ilayer<layers.size(); ilayer++ ) {
406 CSCDetId lid = layers[ilayer]->id();
413 << lid.
layer() <<
")" << std::endl;
421 std::pair<bool,double>
path = crossing.pathLength(det->
surface());
422 if ( ! path.first )
continue;
428 if ( ! laygeom->
inside( lpos ) )
continue;
436 double pmu = lmom.
mag();
439 if (
id.
station()==1 &&
id.
ring()==1) theCSCHitIneff = theCSCHitIneff*0.442;
440 if (
random.flatShoot()<theCSCHitIneff)
continue;
443 double pz = fabs(lmom.
z());
446 double dtof = path.second*rbeta;
447 int trkid = mySimTrack.
trackId();
448 unsigned int id = lid.
rawId();
449 short unsigned int processType = 2;
451 tof+dtof,eloss,
pid,
id,trkid,lmom.
theta(),lmom.
phi(),processType);
452 theCSCHits.push_back(
hit);
459 std::vector<const RPCRoll *> roll = chamber->
rolls();
460 for (
unsigned int iroll=0; iroll<roll.size(); iroll++ ) {
469 << rid.
layer() <<
"," 470 << rid.
roll() <<
")" << std::endl;
478 std::pair<bool,double>
path = crossing.pathLength(det->
surface());
479 if ( ! path.first )
continue;
486 double pz = fabs(lmom.
z());
489 double dtof = path.second*rbeta;
490 int trkid = mySimTrack.
trackId();
491 unsigned int id = rid.
rawId();
492 short unsigned int processType = 2;
494 tof+dtof,eloss,
pid,
id,trkid,lmom.
theta(),lmom.
phi(),processType);
495 theRPCHits.push_back(
hit);
499 std::cout <<
"Extrapolated to unknown subdetector '" << gd->
subDetector() <<
"'..." << std::endl;
507 for ( std::vector<PSimHit>::const_iterator
i = theCSCHits.begin();
508 i != theCSCHits.end();
i++ ) {
516 for ( std::vector<PSimHit>::const_iterator
i = theDTHits.begin();
517 i != theDTHits.end();
i++ ) {
525 for ( std::vector<PSimHit>::const_iterator
i = theRPCHits.begin();
526 i != theRPCHits.end();
i++ ) {
544 std::vector<double> simHitIneffDT = fastMuons.
getParameter<std::vector<double> >(
"simHitDTIneffParameters");
545 std::vector<double> simHitIneffCSC = fastMuons.
getParameter<std::vector<double> >(
"simHitCSCIneffParameters");
546 kDT = simHitIneffDT[0];
547 fDT = simHitIneffDT[1];
548 kCSC = simHitIneffCSC[0];
549 fCSC = simHitIneffCSC[1];
592 double mu = 0.1056583692;
600 theMuon.
setID(-(
int)charge*13);
610 deltaPos(gPosWithdEdx.
x()-gPos.
x(),gPosWithdEdx.
y()-gPos.
y(),
611 gPosWithdEdx.
z()-gPos.
z(),0.);
613 deltaMom(gMomWithdEdx.
x()-gMom.
x(),gMomWithdEdx.
y()-gMom.
y(),
614 gMomWithdEdx.
z()-gMom.
z(), enWithdEdx -en);
627 fac = (theNewMomentum.E()*theNewMomentum.E()-mu*
mu)/theNewMomentum.Vect().Mag2();
629 theMuon.SetXYZT(theNewMomentum.Px()*fac,theNewMomentum.Py()*fac,
630 theNewMomentum.Pz()*fac,theNewMomentum.E());
636 if ( multipleScattering ) {
641 multipleScattering->
updateState(theMuon, radPath, random);
645 if ( bremsstrahlung ) {
647 bremsstrahlung->
updateState(theMuon, radPath, random);
652 GlobalPoint propagatedPosition(theMuon.
X(),theMuon.
Y(),theMuon.
Z());
653 GlobalVector propagatedMomentum(theMuon.Px(),theMuon.Py(),theMuon.Pz());
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
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.
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)
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
int layer() const
Return the layer number.
float charge() const
charge
const Plane & surface() const
The nominal surface of the GeomDet.
void getData(T &iHolder) const
int firstChannel() const
Returns the wire number of the first wire.
Geom::Theta< T > theta() const
const RPCGeometry * rpcGeom
LocalVector localMomentum() 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
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 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
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
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 applyMaterialEffects(TrajectoryStateOnSurface &tsosWithdEdx, TrajectoryStateOnSurface &tsos, double radPath, RandomEngineAndDistribution const *)
Simulate material effects in iron (dE/dx, multiple scattering)
T const * product() 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