81 theEstimator(iConfig.getParameter<double>(
"Chi2EstimatorCut")),
82 propagatorWithoutMaterial(0)
91 "MuonSimHitProducer requires the RandomGeneratorService \n"
92 "which is not present in the configuration file. \n"
93 "You must add the service in the configuration file\n"
94 "or remove the module that requires it.";
107 produces<edm::PSimHitContainer>(
"MuonCSCHits");
108 produces<edm::PSimHitContainer>(
"MuonDTHits");
109 produces<edm::PSimHitContainer>(
"MuonRPCHits");
176 std::vector<PSimHit> theCSCHits;
177 std::vector<PSimHit> theDTHits;
178 std::vector<PSimHit> theRPCHits;
184 for (
unsigned int itrk=0; itrk<simMuons->size(); itrk++ ) {
185 const SimTrack &mySimTrack = (*simMuons)[itrk];
194 if (
abs(pid) != 13 )
continue;
200 t0 = (*simVertices)[ivert].position().t();
204 initialPosition = xyzzy;
211 double tof = t0/29.98;
214 std::cout <<
" ===> MuonSimHitProducer::reconstruct() found SIMTRACK - pid = "
217 <<
", eta = " << mySimP4.Eta()
218 <<
", phi = " << mySimP4.Phi() << std::endl;
236 GlobalVector dtracker = startingPosition-initialPosition;
237 tof += dtracker.
mag()/29.98;
240 std::cout <<
" the Muon START position " << startingPosition << std::endl;
241 std::cout <<
" the Muon START momentum " << startingMomentum << std::endl;
259 std::vector<const DetLayer *> navLayers;
260 if ( fabs(startingState.globalMomentum().eta()) > 4.5 ) {
261 navLayers = navigation.compatibleEndcapLayers(*(startingState.freeState()),
265 navLayers = navigation.compatibleLayers(*(startingState.freeState()),
273 if ( navLayers.empty() )
continue;
276 std::cout <<
"Found " << navLayers.size()
277 <<
" compatible DetLayers..." << std::endl;
281 for (
unsigned int ilayer=0; ilayer<navLayers.size(); ilayer++ ) {
284 std::cout <<
"Propagating to layer " << ilayer <<
" "
289 std::vector<DetWithState> comps =
291 if ( comps.empty() )
continue;
294 std::cout <<
"Propagating " << propagatedState << std::endl;
304 std::pair<TrajectoryStateOnSurface,double>
next(shsDest.
getStateOnSurface(navLayers[ilayer]->surface()),
308 if ( !
next.first.isValid() )
continue;
311 double radPath = shsDest.
radPath();
312 double pathLength =
next.second;
316 std::pair<TrajectoryStateOnSurface,double> nextNoMaterial =
320 propagatedState =
next.first;
328 if ( !propagatedState.
isValid() )
continue;
335 double pavg = 0.5*(pi+pf);
336 double m = mySimP4.M();
337 double rbeta =
sqrt(1+m*m/(pavg*pavg))/29.98;
338 double dtof = pathLength*rbeta;
341 std::cout <<
"Propagated to next surface... path length = " << pathLength
342 <<
" cm, dTOF = " << dtof <<
" ns" << std::endl;
347 for (
unsigned int icomp=0; icomp<comps.size(); icomp++ )
349 const GeomDet *gd = comps[icomp].first;
353 std::vector<const DTSuperLayer *> superlayer = chamber->
superLayers();
354 for (
unsigned int isl=0; isl<superlayer.size(); isl++ ) {
355 std::vector<const DTLayer *> layer = superlayer[isl]->layers();
356 for (
unsigned int ilayer=0; ilayer<layer.size(); ilayer++ ) {
360 << lid.
wheel() <<
","
364 << lid.
layer() <<
")" << std::endl;
373 std::pair<bool,double>
path = crossing.pathLength(det->
surface());
374 if ( ! path.first )
continue;
377 const DTTopology& dtTopo = layer[ilayer]->specificTopology();
378 int wire = dtTopo.
channel(lpos);
390 double pmu = lmom.
mag();
395 double pz = fabs(lmom.
z());
398 double dtof = path.second*rbeta;
399 int trkid = mySimTrack.
trackId();
400 unsigned int id = wid.
rawId();
401 short unsigned int processType = 2;
403 tof+dtof,eloss,
pid,
id,trkid,lmom.
theta(),lmom.
phi(),processType);
404 theDTHits.push_back(
hit);
412 std::vector<const CSCLayer *> layers = chamber->
layers();
413 for (
unsigned int ilayer=0; ilayer<layers.size(); ilayer++ ) {
414 CSCDetId lid = layers[ilayer]->id();
421 << lid.
layer() <<
")" << std::endl;
429 std::pair<bool,double>
path = crossing.pathLength(det->
surface());
430 if ( ! path.first )
continue;
436 if ( ! laygeom->
inside( lpos ) )
continue;
444 double pmu = lmom.
mag();
447 if (
id.
station()==1 &&
id.
ring()==1) theCSCHitIneff = theCSCHitIneff*0.442;
451 double pz = fabs(lmom.
z());
454 double dtof = path.second*rbeta;
455 int trkid = mySimTrack.
trackId();
456 unsigned int id = lid.
rawId();
457 short unsigned int processType = 2;
459 tof+dtof,eloss,
pid,
id,trkid,lmom.
theta(),lmom.
phi(),processType);
460 theCSCHits.push_back(
hit);
467 std::vector<const RPCRoll *> roll = chamber->
rolls();
468 for (
unsigned int iroll=0; iroll<roll.size(); iroll++ ) {
477 << rid.
layer() <<
","
478 << rid.
roll() <<
")" << std::endl;
486 std::pair<bool,double>
path = crossing.pathLength(det->
surface());
487 if ( ! path.first )
continue;
494 double pz = fabs(lmom.
z());
497 double dtof = path.second*rbeta;
498 int trkid = mySimTrack.
trackId();
499 unsigned int id = rid.
rawId();
500 short unsigned int processType = 2;
502 tof+dtof,eloss,
pid,
id,trkid,lmom.
theta(),lmom.
phi(),processType);
503 theRPCHits.push_back(
hit);
507 std::cout <<
"Extrapolated to unknown subdetector '" << gd->
subDetector() <<
"'..." << std::endl;
515 for ( std::vector<PSimHit>::const_iterator
i = theCSCHits.begin();
516 i != theCSCHits.end();
i++ ) {
520 iEvent.
put(pcsc,
"MuonCSCHits");
524 for ( std::vector<PSimHit>::const_iterator
i = theDTHits.begin();
525 i != theDTHits.end();
i++ ) {
529 iEvent.
put(pdt,
"MuonDTHits");
533 for ( std::vector<PSimHit>::const_iterator
i = theRPCHits.begin();
534 i != theRPCHits.end();
i++ ) {
538 iEvent.
put(prpc,
"MuonRPCHits");
558 std::vector<double> simHitIneffDT = fastMuons.
getParameter<std::vector<double> >(
"simHitDTIneffParameters");
559 std::vector<double> simHitIneffCSC = fastMuons.
getParameter<std::vector<double> >(
"simHitCSCIneffParameters");
560 kDT = simHitIneffDT[0];
561 fDT = simHitIneffDT[1];
562 kCSC = simHitIneffCSC[0];
563 fCSC = simHitIneffCSC[1];
606 double mu = 0.1056583692;
614 theMuon.
setID(-(
int)charge*13);
624 deltaPos(gPosWithdEdx.
x()-gPos.
x(),gPosWithdEdx.
y()-gPos.
y(),
625 gPosWithdEdx.
z()-gPos.
z(),0.);
627 deltaMom(gMomWithdEdx.
x()-gMom.
x(),gMomWithdEdx.
y()-gMom.
y(),
628 gMomWithdEdx.
z()-gMom.
z(), enWithdEdx -en);
641 fac = (theNewMomentum.E()*theNewMomentum.E()-mu*
mu)/theNewMomentum.Vect().Mag2();
643 theMuon.SetXYZT(theNewMomentum.Px()*fac,theNewMomentum.Py()*fac,
644 theNewMomentum.Pz()*fac,theNewMomentum.E());
650 if ( multipleScattering ) {
659 if ( bremsstrahlung ) {
666 GlobalPoint propagatedPosition(theMuon.
X(),theMuon.
Y(),theMuon.
Z());
667 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
const std::vector< const CSCLayer * > & layers() const
Return all layers.
virtual void beginRun(edm::Run &run, const edm::EventSetup &es)
const DTGeometry * dtGeom
TrackCharge charge() const
std::string dumpLayer(const DetLayer *layer) 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)
FreeTrajectoryState * freeTrajectoryState(bool withErrors=true) const
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.
int layer() const
Return the layer number.
float charge() const
charge
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 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.
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
std::pair< std::string, MonitorElement * > entry
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.
const CSCGeometry * cscGeom
DetId geographicalId() const
The label of this GeomDet.
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
const Bounds & bounds() const
virtual ReferenceCountingPointer< TangentPlane > tangentPlane(const GlobalPoint &) const =0
unsigned int trackId() const
void updateState(ParticlePropagator &myTrack, double radlen)
Compute the material effect (calls the sub class)
const math::XYZTLorentzVectorD & trackerSurfaceMomentum() const
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
const RandomEngine * random
const DTChamber * chamber(DTChamberId id) const
Return a DTChamber given its id.
double flatShoot(double xmin=0.0, double xmax=1.0) const
int sector() const
Sector id: the group of chambers at same phi (and increasing r)
double X() const
x of vertex
MuonServiceProxy * theService
void applyMaterialEffects(TrajectoryStateOnSurface &tsosWithdEdx, TrajectoryStateOnSurface &tsos, double radPath)
Simulate material effects in iron (dE/dx, multiple scattering)
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 &)
virtual void produce(edm::Event &, const edm::EventSetup &)
GlobalVector globalMomentum() const
const BoundPlane & surface() const
The nominal surface of the GeomDet.
std::string theTrkModuleLabel_
const math::XYZTLorentzVectorD & momentum() const
particle info...
static int position[264][3]
TkRotation< float > RotationType
const Surface & surface() 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 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
Chi2MeasurementEstimator theEstimator
double transverseCurvature() const