79 theEstimator(iConfig.getParameter<double>(
"Chi2EstimatorCut")),
80 propagatorWithoutMaterial(0)
91 produces<edm::PSimHitContainer>(
"MuonCSCHits");
92 produces<edm::PSimHitContainer>(
"MuonDTHits");
93 produces<edm::PSimHitContainer>(
"MuonRPCHits");
127 SHpropagator->setMaterialMode(
true);
158 std::vector<PSimHit> theCSCHits;
159 std::vector<PSimHit> theDTHits;
160 std::vector<PSimHit> theRPCHits;
166 for (
unsigned int itrk=0; itrk<simMuons->size(); itrk++ ) {
167 const SimTrack &mySimTrack = (*simMuons)[itrk];
176 if (
abs(pid) != 13 )
continue;
182 t0 = (*simVertices)[ivert].position().t();
186 initialPosition = xyzzy;
193 double tof = t0/29.98;
196 std::cout <<
" ===> MuonSimHitProducer::reconstruct() found SIMTRACK - pid = "
199 <<
", eta = " << mySimP4.Eta()
200 <<
", phi = " << mySimP4.Phi() << std::endl;
218 GlobalVector dtracker = startingPosition-initialPosition;
219 tof += dtracker.
mag()/29.98;
222 std::cout <<
" the Muon START position " << startingPosition << std::endl;
223 std::cout <<
" the Muon START momentum " << startingMomentum << std::endl;
241 std::vector<const DetLayer *> navLayers;
242 if ( fabs(startingState.globalMomentum().eta()) > 4.5 ) {
243 navLayers = navigation.compatibleEndcapLayers(*(startingState.freeState()),
247 navLayers = navigation.compatibleLayers(*(startingState.freeState()),
255 if ( navLayers.empty() )
continue;
258 std::cout <<
"Found " << navLayers.size()
259 <<
" compatible DetLayers..." << std::endl;
263 for (
unsigned int ilayer=0; ilayer<navLayers.size(); ilayer++ ) {
266 std::cout <<
"Propagating to layer " << ilayer <<
" "
267 << dumper.dumpLayer(navLayers[ilayer])
271 std::vector<DetWithState> comps =
273 if ( comps.empty() )
continue;
276 std::cout <<
"Propagating " << propagatedState << std::endl;
286 std::pair<TrajectoryStateOnSurface,double>
next(shsDest.
getStateOnSurface(navLayers[ilayer]->surface()),
290 if ( !
next.first.isValid() )
continue;
293 double radPath = shsDest.
radPath();
294 double pathLength =
next.second;
298 std::pair<TrajectoryStateOnSurface,double> nextNoMaterial =
302 propagatedState =
next.first;
310 if ( !propagatedState.
isValid() )
continue;
317 double pavg = 0.5*(pi+pf);
318 double m = mySimP4.M();
319 double rbeta =
sqrt(1+m*m/(pavg*pavg))/29.98;
320 double dtof = pathLength*rbeta;
323 std::cout <<
"Propagated to next surface... path length = " << pathLength
324 <<
" cm, dTOF = " << dtof <<
" ns" << std::endl;
329 for (
unsigned int icomp=0; icomp<comps.size(); icomp++ )
331 const GeomDet *gd = comps[icomp].first;
335 std::vector<const DTSuperLayer *> superlayer = chamber->
superLayers();
336 for (
unsigned int isl=0; isl<superlayer.size(); isl++ ) {
337 std::vector<const DTLayer *> layer = superlayer[isl]->layers();
338 for (
unsigned int ilayer=0; ilayer<layer.size(); ilayer++ ) {
342 << lid.
wheel() <<
","
346 << lid.
layer() <<
")" << std::endl;
355 std::pair<bool,double>
path = crossing.pathLength(det->
surface());
356 if ( ! path.first )
continue;
359 const DTTopology& dtTopo = layer[ilayer]->specificTopology();
360 int wire = dtTopo.
channel(lpos);
372 double pmu = lmom.
mag();
374 if (
random.flatShoot()<theDTHitIneff)
continue;
377 double pz = fabs(lmom.
z());
378 LocalPoint entry = lpos - 0.5*thickness*lmom/pz;
380 double dtof = path.second*rbeta;
381 int trkid = mySimTrack.
trackId();
382 unsigned int id = wid.
rawId();
383 short unsigned int processType = 2;
385 tof+dtof,eloss,
pid,id,trkid,lmom.
theta(),lmom.
phi(),processType);
386 theDTHits.push_back(
hit);
394 std::vector<const CSCLayer *>
layers = chamber->layers();
395 for (
unsigned int ilayer=0; ilayer<layers.size(); ilayer++ ) {
396 CSCDetId lid = layers[ilayer]->id();
403 << lid.
layer() <<
")" << std::endl;
411 std::pair<bool,double>
path = crossing.pathLength(det->
surface());
412 if ( ! path.first )
continue;
418 if ( ! laygeom->
inside( lpos ) )
continue;
426 double pmu = lmom.
mag();
429 if (
id.
station()==1 &&
id.
ring()==1) theCSCHitIneff = theCSCHitIneff*0.442;
430 if (
random.flatShoot()<theCSCHitIneff)
continue;
433 double pz = fabs(lmom.
z());
434 LocalPoint entry = lpos - 0.5*thickness*lmom/pz;
436 double dtof = path.second*rbeta;
437 int trkid = mySimTrack.
trackId();
438 unsigned int id = lid.
rawId();
439 short unsigned int processType = 2;
441 tof+dtof,eloss,
pid,id,trkid,lmom.
theta(),lmom.
phi(),processType);
442 theCSCHits.push_back(
hit);
449 std::vector<const RPCRoll *> roll = chamber->
rolls();
450 for (
unsigned int iroll=0; iroll<roll.size(); iroll++ ) {
459 << rid.
layer() <<
","
460 << rid.
roll() <<
")" << std::endl;
468 std::pair<bool,double>
path = crossing.pathLength(det->
surface());
469 if ( ! path.first )
continue;
476 double pz = fabs(lmom.
z());
477 LocalPoint entry = lpos - 0.5*thickness*lmom/pz;
479 double dtof = path.second*rbeta;
480 int trkid = mySimTrack.
trackId();
481 unsigned int id = rid.
rawId();
482 short unsigned int processType = 2;
484 tof+dtof,eloss,
pid,id,trkid,lmom.
theta(),lmom.
phi(),processType);
485 theRPCHits.push_back(
hit);
489 std::cout <<
"Extrapolated to unknown subdetector '" << gd->
subDetector() <<
"'..." << std::endl;
497 for ( std::vector<PSimHit>::const_iterator
i = theCSCHits.begin();
498 i != theCSCHits.end();
i++ ) {
502 iEvent.
put(pcsc,
"MuonCSCHits");
506 for ( std::vector<PSimHit>::const_iterator
i = theDTHits.begin();
507 i != theDTHits.end();
i++ ) {
511 iEvent.
put(pdt,
"MuonDTHits");
515 for ( std::vector<PSimHit>::const_iterator
i = theRPCHits.begin();
516 i != theRPCHits.end();
i++ ) {
520 iEvent.
put(prpc,
"MuonRPCHits");
532 std::vector<double> simHitIneffDT = fastMuons.
getParameter<std::vector<double> >(
"simHitDTIneffParameters");
533 std::vector<double> simHitIneffCSC = fastMuons.
getParameter<std::vector<double> >(
"simHitCSCIneffParameters");
534 kDT = simHitIneffDT[0];
535 fDT = simHitIneffDT[1];
536 kCSC = simHitIneffCSC[0];
537 fCSC = simHitIneffCSC[1];
580 double mu = 0.1056583692;
588 theMuon.
setID(-(
int)charge*13);
598 deltaPos(gPosWithdEdx.
x()-gPos.
x(),gPosWithdEdx.
y()-gPos.
y(),
599 gPosWithdEdx.
z()-gPos.
z(),0.);
601 deltaMom(gMomWithdEdx.
x()-gMom.
x(),gMomWithdEdx.
y()-gMom.
y(),
602 gMomWithdEdx.
z()-gMom.
z(), enWithdEdx -en);
615 fac = (theNewMomentum.E()*theNewMomentum.E()-mu*
mu)/theNewMomentum.Vect().Mag2();
617 theMuon.SetXYZT(theNewMomentum.Px()*fac,theNewMomentum.Py()*fac,
618 theNewMomentum.Pz()*fac,theNewMomentum.E());
624 if ( multipleScattering ) {
629 multipleScattering->
updateState(theMuon, radPath, random);
633 if ( bremsstrahlung ) {
635 bremsstrahlung->
updateState(theMuon, radPath, random);
640 GlobalPoint propagatedPosition(theMuon.
X(),theMuon.
Y(),theMuon.
Z());
641 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
std::vector< LayerSetAndLayers > layers(const SeedingLayerSetsHits &sets)
const DTGeometry * dtGeom
TrackCharge charge() const
virtual bool inside(const Local3DPoint &) const =0
Determine if the point is inside the bounds.
virtual const GeomDetUnit * idToDetUnit(DetId) const
Return the pointer to the GeomDetUnit corresponding to a given DetId.
void setNormalVector(const GlobalVector &normal)
Sets the vector normal to the surface traversed.
#define DEFINE_FWK_MODULE(type)
int channel(const LocalPoint &p) const
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
virtual SubDetector subDetector() const =0
Which subdetector.
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)
int layer() const
Return the layer number.
float charge() const
charge
const Plane & surface() const
The nominal surface of the GeomDet.
static int position[TOTALCHAMBERS][3]
int firstChannel() const
Returns the wire number of the first wire.
Geom::Theta< T > theta() const
const RPCGeometry * rpcGeom
uint32_t rawId() const
get the raw id
LocalVector localMomentum() const
virtual float thickness() const =0
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
virtual std::pair< TrajectoryStateOnSurface, double > propagateWithPath(const FreeTrajectoryState &, const Surface &) const
MuonBremsstrahlungSimulator * muonBremsstrahlungSimulator() const
Return the Muon Bremsstrahlung engine.
const SurfaceType & surface() const
const XYZTLorentzVector & momentum() const
the momentum fourvector
std::string theSimModuleProcess_
virtual const GeomDetUnit * idToDetUnit(DetId) const
Return the pointer to the GeomDetUnit corresponding to a given DetId.
FreeTrajectoryState const * freeTrajectoryState(bool withErrors=true) const
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
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
Vector3DBase< typename PreciseFloatType< T, U >::Type, FrameTag > cross(const Vector3DBase< U, FrameTag > &v) const
double Y() const
y of vertex
const XYZTLorentzVector & deltaMom() const
Returns the actual energy lost.
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.
virtual void beginRun(edm::Run const &run, const edm::EventSetup &es) override
virtual void produce(edm::Event &, const edm::EventSetup &) override
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
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
virtual ReferenceCountingPointer< TangentPlane > tangentPlane(const GlobalPoint &) const =0
unsigned int trackId() const
const math::XYZTLorentzVectorD & trackerSurfaceMomentum() const
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
const DTChamber * chamber(DTChamberId id) const
Return a DTChamber given its id.
int sector() const
Sector id: the group of chambers at same phi (and increasing r)
double X() const
x of vertex
MuonServiceProxy * theService
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)
std::string theSimModuleLabel_
void readParameters(const edm::ParameterSet &, const edm::ParameterSet &, const edm::ParameterSet &)
GlobalVector globalMomentum() const
std::string theTrkModuleLabel_
const math::XYZTLorentzVectorD & momentum() const
particle info...
TkRotation< float > RotationType
StreamID streamID() const
virtual const GeomDetUnit * idToDetUnit(DetId) const
Return the pointer to the GeomDetUnit corresponding to a given DetId.
bool inside(const Local3DPoint &, const LocalError &, float scale=1.f) const
std::vector< PSimHit > PSimHitContainer
int station() const
Return the station number.
EnergyLossSimulator * energyLossSimulator() const
Return the Energy Loss engine.
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)
void setVertex(const XYZTLorentzVector &vtx)
set the vertex
edm::ESHandle< Propagator > propagator(std::string propagatorName) const
get the propagator
Global3DVector GlobalVector
math::XYZTLorentzVector XYZTLorentzVector
Chi2MeasurementEstimator theEstimator
double transverseCurvature() const