105 : theEstimator(iConfig.getParameter<double>(
"Chi2EstimatorCut")), propagatorWithoutMaterial(nullptr) {
114 produces<edm::PSimHitContainer>(
"MuonCSCHits");
115 produces<edm::PSimHitContainer>(
"MuonDTHits");
116 produces<edm::PSimHitContainer>(
"MuonRPCHits");
145 bool duringEvent =
false;
174 std::vector<PSimHit> theCSCHits;
175 std::vector<PSimHit> theDTHits;
176 std::vector<PSimHit> theRPCHits;
182 for (
unsigned int itrk = 0; itrk < simMuons->size(); itrk++) {
183 const SimTrack& mySimTrack = (*simMuons)[itrk];
189 int pid = mySimTrack.
type();
190 if (
abs(pid) != 13 &&
abs(pid) != 1000024)
196 t0 = (*simVertices)[ivert].position().t();
200 initialPosition = xyzzy;
207 double tof =
t0 / 29.98;
210 std::cout <<
" ===> MuonSimHitProducer::reconstruct() found SIMTRACK - pid = " << pid;
211 std::cout <<
" : pT = " << mySimP4.Pt() <<
", eta = " << mySimP4.Eta() <<
", phi = " << mySimP4.Phi() << std::endl;
229 GlobalVector dtracker = startingPosition - initialPosition;
230 tof += dtracker.
mag() / 29.98;
233 std::cout <<
" the Muon START position " << startingPosition << std::endl;
234 std::cout <<
" the Muon START momentum " << startingMomentum << std::endl;
249 std::vector<const DetLayer*> navLayers;
250 if (fabs(startingState.globalMomentum().eta()) > 4.5) {
251 navLayers = navigation.compatibleEndcapLayers(*(startingState.freeState()),
alongMomentum);
253 navLayers = navigation.compatibleLayers(*(startingState.freeState()),
alongMomentum);
260 if (navLayers.empty())
264 std::cout <<
"Found " << navLayers.size() <<
" compatible DetLayers..." << std::endl;
268 for (
unsigned int ilayer = 0; ilayer < navLayers.size(); ilayer++) {
270 std::cout <<
"Propagating to layer " << ilayer <<
" " << dumper.dumpLayer(navLayers[ilayer]) << std::endl;
273 std::vector<DetWithState> comps =
279 std::cout <<
"Propagating " << propagatedState << std::endl;
289 ->propagate(shsStart, navLayers[ilayer]->surface(), shsDest);
290 std::pair<TrajectoryStateOnSurface, double>
next(shsDest.
getStateOnSurface(navLayers[ilayer]->surface()),
294 if (!
next.first.isValid())
298 double radPath = shsDest.
radPath();
299 double pathLength =
next.second;
303 std::pair<TrajectoryStateOnSurface, double> nextNoMaterial =
307 propagatedState =
next.first;
316 if (!propagatedState.
isValid())
324 double pavg = 0.5 * (
pi +
pf);
325 double m = mySimP4.M();
326 double rbeta =
sqrt(1 +
m *
m / (pavg * pavg)) / 29.98;
327 double dtof = pathLength * rbeta;
330 std::cout <<
"Propagated to next surface... path length = " << pathLength <<
" cm, dTOF = " << dtof <<
" ns"
336 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++) {
357 std::pair<bool, double>
path = crossing.pathLength(det->
surface());
364 int wire = dtTopo.
channel(lpos);
377 double pmu = lmom.
mag();
378 double theDTHitIneff = pmu > 0 ?
exp(
kDT *
log(pmu) +
fDT) : 0.;
379 if (random.flatShoot() < theDTHitIneff)
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 entry,
exit, lmom.
mag(), tof + dtof, eloss, pid,
id, trkid, lmom.
theta(), lmom.
phi(), processType);
392 theDTHits.push_back(
hit);
399 for (
unsigned int ilayer = 0; ilayer <
layers.size(); ilayer++) {
404 << lid.
layer() <<
")" << std::endl;
412 std::pair<bool, double>
path = crossing.pathLength(det->
surface());
420 if (!laygeom->
inside(lpos))
429 double pmu = lmom.
mag();
430 double theCSCHitIneff = pmu > 0 ?
exp(
kCSC *
log(pmu) +
fCSC) : 0.;
433 theCSCHitIneff = theCSCHitIneff * 0.442;
434 if (random.flatShoot() < theCSCHitIneff)
438 double pz = fabs(lmom.
z());
441 double dtof =
path.second * rbeta;
442 int trkid = mySimTrack.
trackId();
443 unsigned int id = lid.
rawId();
444 short unsigned int processType = 2;
446 entry,
exit, lmom.
mag(), tof + dtof, eloss, pid,
id, trkid, lmom.
theta(), lmom.
phi(), processType);
447 theCSCHits.push_back(
hit);
453 std::vector<const RPCRoll*> roll =
chamber->rolls();
454 for (
unsigned int iroll = 0; iroll < roll.size(); iroll++) {
458 std::cout <<
" Extrapolated to RPC (" <<
rid.ring() <<
"," <<
rid.station() <<
"," <<
rid.sector() <<
","
459 <<
rid.subsector() <<
"," <<
rid.layer() <<
"," <<
rid.roll() <<
")" << std::endl;
467 std::pair<bool, double>
path = crossing.pathLength(det->
surface());
477 double pz = fabs(lmom.
z());
480 double dtof =
path.second * rbeta;
481 int trkid = mySimTrack.
trackId();
482 unsigned int id =
rid.rawId();
483 short unsigned int processType = 2;
485 entry,
exit, lmom.
mag(), tof + dtof, eloss, pid,
id, trkid, lmom.
theta(), lmom.
phi(), processType);
486 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();
i != theCSCHits.end();
i++) {
505 for (std::vector<PSimHit>::const_iterator
i = theDTHits.begin();
i != theDTHits.end();
i++) {
513 for (std::vector<PSimHit>::const_iterator
i = theRPCHits.begin();
i != theRPCHits.end();
i++) {
529 std::vector<double> simHitIneffDT = fastMuons.
getParameter<std::vector<double> >(
"simHitDTIneffParameters");
530 std::vector<double> simHitIneffCSC = fastMuons.
getParameter<std::vector<double> >(
"simHitCSCIneffParameters");
531 kDT = simHitIneffDT[0];
532 fDT = simHitIneffDT[1];
533 kCSC = simHitIneffCSC[0];
534 fCSC = simHitIneffCSC[1];
573 double mu = 0.1056583692;
590 gPosWithdEdx.
x() - gPos.
x(), gPosWithdEdx.
y() - gPos.
y(), gPosWithdEdx.
z() - gPos.
z(), 0.);
592 gMomWithdEdx.
x() - gMom.
x(), gMomWithdEdx.
y() - gMom.
y(), gMomWithdEdx.
z() - gMom.
z(), enWithdEdx - en);
595 energyLoss->updateState(theMuon, radPath, random);
599 radPath *= -deltaMom.E() /
energyLoss->mostLikelyLoss();
605 fac = (theNewMomentum.E() * theNewMomentum.E() -
mu *
mu) / theNewMomentum.Vect().Mag2();
608 theNewMomentum.Px() * fac, theNewMomentum.Py() * fac, theNewMomentum.Pz() * fac, theNewMomentum.E());