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());
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);
397 for (
unsigned int ilayer = 0; ilayer <
layers.size(); ilayer++) {
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++) {
456 std::cout <<
" Extrapolated to RPC (" <<
rid.ring() <<
"," <<
rid.station() <<
"," <<
rid.sector() <<
"," 457 <<
rid.subsector() <<
"," <<
rid.layer() <<
"," <<
rid.roll() <<
")" << std::endl;
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;
494 for (std::vector<PSimHit>::const_iterator
i = theCSCHits.begin();
i != theCSCHits.end();
i++) {
500 for (std::vector<PSimHit>::const_iterator
i = theDTHits.begin();
i != theDTHits.end();
i++) {
506 for (std::vector<PSimHit>::const_iterator
i = theRPCHits.begin();
i != theRPCHits.end();
i++) {
521 std::vector<double> simHitIneffDT = fastMuons.
getParameter<std::vector<double> >(
"simHitDTIneffParameters");
522 std::vector<double> simHitIneffCSC = fastMuons.
getParameter<std::vector<double> >(
"simHitCSCIneffParameters");
523 kDT = simHitIneffDT[0];
524 fDT = simHitIneffDT[1];
525 kCSC = simHitIneffCSC[0];
526 fCSC = simHitIneffCSC[1];
565 double mu = 0.1056583692;
582 gPosWithdEdx.
x() - gPos.
x(), gPosWithdEdx.
y() - gPos.
y(), gPosWithdEdx.
z() - gPos.
z(), 0.);
584 gMomWithdEdx.
x() - gMom.
x(), gMomWithdEdx.
y() - gMom.
y(), gMomWithdEdx.
z() - gMom.
z(), enWithdEdx - en);
587 energyLoss->updateState(theMuon, radPath, random);
591 radPath *= -deltaMom.E() /
energyLoss->mostLikelyLoss();
597 fac = (theNewMomentum.E() * theNewMomentum.E() -
mu *
mu) / theNewMomentum.Vect().Mag2();
600 theNewMomentum.Px() * fac, theNewMomentum.Py() * fac, theNewMomentum.Pz() * fac, theNewMomentum.E());
MuonSimHitProducer(const edm::ParameterSet &)
void setMomentum(const XYZTLorentzVector &vtx)
set the momentum
int station() const
Return the station number.
const MagneticField * magfield
T getParameter(std::string const &) const
const edm::ESGetToken< HepPDT::ParticleDataTable, edm::DefaultRecord > particleDataTableESToken_
TrajectoryStateOnSurface getStateOnSurface(const Surface &surf, bool returnTangentPlane=false) const
const DTGeometry * dtGeom
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
double Pz() const
z of the momentum
virtual ConstReferenceCountingPointer< TangentPlane > tangentPlane(const GlobalPoint &) const =0
const math::XYZVectorD & trackerSurfacePosition() const
static const char * normal
std::unique_ptr< Propagator > propagatorWithoutMaterial
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
virtual bool inside(const Local3DPoint &) const =0
Determine if the point is inside the bounds.
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
HepPDT::ParticleDataTable ParticleDataTable
double Z() const
z of vertex
Geom::Phi< T > phi() const
edm::ESHandle< MuonDetLayerGeometry > detLayerGeometry() const
get the detLayer geometry
ReturnType plane(const PositionType &pos, const RotationType &rot) const
Global3DPoint GlobalPoint
virtual Propagator * clone() const =0
const GeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
edm::EDGetTokenT< std::vector< SimVertex > > simVertexToken
const XYZTLorentzVector & momentum() const
the momentum fourvector
RawParticle makeMuon(bool isParticle, const math::XYZTLorentzVector &p, const math::XYZTLorentzVector &xStart)
const SurfaceType & surface() const
void applyMaterialEffects(TrajectoryStateOnSurface &tsosWithdEdx, TrajectoryStateOnSurface &tsos, double radPath, RandomEngineAndDistribution const *, HepPDT::ParticleDataTable const &)
Simulate material effects in iron (dE/dx, multiple scattering)
float charge() const
charge
const math::XYZTLorentzVectorD & momentum() const
const edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeometryESToken_
T getUntrackedParameter(std::string const &, T const &) const
const RPCGeometry * rpcGeom
int firstChannel() const
Returns the wire number of the first wire.
virtual float thickness() const =0
int type() const
particle type (HEP PDT convension)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
int vertIndex() const
index of the vertex in the Event container (-1 if no vertex)
GlobalPoint globalPosition() const
const Propagator * propagatorWithMaterial
double Py() const
y of the momentum
FreeTrajectoryState const * freeTrajectoryState(bool withErrors=true) const
LocalVector localMomentum() const
Abs< T >::type abs(const T &t)
const CSCGeometry * cscGeom
RawParticle const & particle() const
The particle being propagated.
void beginRun(edm::Run const &run, const edm::EventSetup &es) override
void produce(edm::Event &, const edm::EventSetup &) override
#define DEFINE_FWK_MODULE(type)
TrackCharge charge() const
const GeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
DetId geographicalId() const
The label of this GeomDet.
const BasicVectorType & basicVector() const
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
const edm::ESGetToken< RPCGeometry, MuonGeometryRecord > rpcGeometryESToken_
const Plane & surface() const
The nominal surface of the GeomDet.
int superlayer() const
Return the superlayer number (deprecated method name)
const RPCChamber * chamber(RPCDetId id) const
constexpr uint32_t rawId() const
get the raw id
double transverseCurvature() const
virtual SubDetector subDetector() const
Which subdetector.
GlobalVector globalMomentum() const
edm::EDGetTokenT< std::vector< SimTrack > > simMuonToken
MuonServiceProxy * theService
int layer() const
Return the layer number.
double Y() const
y of vertex
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldESToken_
void readParameters(const edm::ParameterSet &, const edm::ParameterSet &, const edm::ParameterSet &)
int wheel() const
Return the wheel number.
static int position[264][3]
int channel(const LocalPoint &p) const override
unsigned int trackId() const
TkRotation< float > RotationType
edm::InputTag simMuonLabel
double X() const
x of vertex
int lastChannel() const
Returns the wire number of the last wire.
edm::ESHandle< Propagator > propagator(std::string propagatorName) const
get the propagator
void update(const edm::EventSetup &setup, bool duringEvent=true)
update the services each event
const math::XYZTLorentzVectorD & trackerSurfaceMomentum() const
std::vector< PSimHit > PSimHitContainer
Vector3DBase unit() const
const edm::ESGetToken< CSCGeometry, MuonGeometryRecord > cscGeometryESToken_
bool inside(const Local3DPoint &, const LocalError &, float scale=1.f) const override
std::unique_ptr< MaterialEffects > theMaterialEffects
const DTChamber * chamber(const DTChamberId &id) const
Return a DTChamber given its id.
void setMaterialMode(bool noMaterial)
Switch for material effects mode: no material effects if true.
void setVertex(const XYZTLorentzVector &vtx)
set the vertex
Global3DVector GlobalVector
Geom::Theta< T > theta() const
math::XYZTLorentzVector XYZTLorentzVector
const XYZTLorentzVector & vertex() const
the vertex fourvector
double Px() const
x of the momentum
const GeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
edm::InputTag simVertexLabel
Chi2MeasurementEstimator theEstimator
const Bounds & bounds() const