51 : mySimEvent(aSimEvent),
52 _theGeometry(nullptr),
53 _theFieldMap(nullptr),
54 theMaterialEffects(nullptr),
55 myDecayEngine(nullptr),
56 theGeomTracker(nullptr),
57 theGeomSearchTracker(nullptr),
59 theNegLayerOffset(27),
68 if (
decays.getParameter<
bool>(
"ActivateDecays")) {
82 pTmin =
simHits.getUntrackedParameter<
double>(
"pTmin", 0.5);
137 std::list<TrackerLayer>::const_iterator cyliter;
163 PP.setPropagationConditions(*cyliter);
164 if (PP.inside() && !PP.onSurface())
176 double ppcos2T = PP.particle().cos2Theta();
177 double ppcos2V = PP.particle().cos2ThetaV();
180 if ((ppcos2T > 0.99 && ppcos2T < 0.9998) && (cyl == 0 || (ppcos2V > 0.99 && ppcos2V < 0.9998))) {
186 }
else if (ppcos2T > 0.9998 && (cyl == 0 || ppcos2V > 0.9998)) {
190 if (ppcos2T > 0.9998 && (cyl == 0 || ppcos2V > 0.9998)) {
200 if (cyliter->surface().mediumProperties().radLen() < 1E-10) {
209 bool escapeBarrel = PP.getSuccess() == -1;
210 bool escapeEndcap = (PP.getSuccess() == -2 &&
success == 1);
212 bool fullPropagation = (PP.getSuccess() <= 0 &&
success == 0) || escapeEndcap;
226 fullPropagation =
true;
231 PP.setPropagationConditions(*cyliter, !fullPropagation);
233 PP.increaseRCyl(0.0005);
240 if (!PP.propagateToBoundSurface(*cyliter) || PP.getSuccess() <= 0) {
247 if (PP.hasDecayed() ||
259 if (PP.getSuccess() > 0 && PP.onFiducial()) {
261 PP.particle().charge() != 0. &&
262 cyliter->sensitive() &&
270 saveHit &= PP.particle().E() > 1E-6;
274 if (cyliter->sensitive()) {
325 PP.propagateToEcal();
329 if (PP.getSuccess() == 0) {
333 PP.setPropagationConditions(*cyliter);
334 PP.propagateToBoundSurface(*cyliter);
337 if (PP.getSuccess() < 0) {
417 std::list<TrackerLayer>::const_iterator cyliter;
425 if (
layer != cyliter->layerNumber())
453 double magBefore =
std::sqrt(momentumBefore.Vect().mag2());
454 double magAfter =
std::sqrt(momentumAfter.Vect().mag2());
456 XYZVector axis = momentumBefore.Vect().Cross(momentumAfter.Vect());
457 double angle = std::acos(momentumBefore.Vect().Dot(momentumAfter.Vect()) / (magAfter * magBefore));
460 double rescale = magAfter / magBefore;
477 int theClosestChargedDaughterId = -1;
483 for (; daughter !=
daughters.end(); ++daughter) {
487 double dist = (daughter->Vect().Unit().Cross(PP.
particle().
Vect().Unit())).R();
490 theClosestChargedDaughterId = theDaughterId;
496 if (theClosestChargedDaughterId >= 0)
508 XYZVector newMomentum(
r * daughMomentum.Vect());
510 double newEnergy =
std::sqrt(newMomentum.mag2() + daughMomentum.mag2());
513 XYZTLorentzVector(newMomentum.X(), newMomentum.Y(), newMomentum.Z(), newEnergy));
522 std::map<double, PSimHit>& theHitMap,
548 std::vector<DetWithState> compat = tkLayer->
compatibleDets(trajState, alongProp, est);
551 std::map<double, PSimHit> theTrackHits;
552 for (std::vector<DetWithState>::const_iterator
i = compat.begin();
i != compat.end();
i++) {
564 auto plane =
layer->surface().tangentPlane(
pos);
571 std::map<double, PSimHit>& theHitMap,
579 for (std::vector<const GeomDet*>::const_iterator
i =
comp.begin();
i !=
comp.end();
i++) {
582 theHitMap.insert(theHitMap.end(),
makeSinglePSimHit(*du, ts, tkID, el, thick, pID, tTopo));
586 theHitMap.insert(theHitMap.end(),
makeSinglePSimHit(*du, ts, tkID, el, thick, pID, tTopo));
597 const float onSurfaceTolarance = 0.01;
607 std::pair<bool, double>
path = crossing.pathLength(det.
surface());
610 return std::pair<double, PSimHit>(0.,
PSimHit());
619 float halfThick = 0.5 * theDetPlane.bounds().thickness();
626 eloss *= (2. * halfThick - 0.003) / (9.36 * thick);
637 int localTkID = tkID;
646 unsigned subdet =
DetId(
hit.detUnitId()).subdetId();
647 double boundX = theDetPlane.bounds().width() / 2.;
648 double boundY = theDetPlane.bounds().length() / 2.;
651 if (subdet == 4 || subdet == 6)
652 boundX *= 1. -
hit.localPosition().
y() / theDetPlane.position().perp();
655 unsigned detid =
DetId(
hit.detUnitId()).rawId();
657 unsigned theLayer = 0;
658 unsigned theRing = 0;
662 std::cout <<
"\tPixel Barrel Layer " << theLayer << std::endl;
667 theLayer = tTopo->
pxfDisk(detid);
668 std::cout <<
"\tPixel Forward Disk " << theLayer << std::endl;
674 std::cout <<
"\tTIB Layer " << theLayer << std::endl;
680 theRing = tTopo->
tidRing(detid);
681 unsigned int theSide =
module.side();
683 std::cout <<
"\tTID Petal Back " << std::endl;
685 std::cout <<
"\tTID Petal Front" << std::endl;
686 std::cout <<
"\tTID Layer " << theLayer << std::endl;
687 std::cout <<
"\tTID Ring " << theRing << std::endl;
694 std::cout <<
"\tTOB Layer " << theLayer << std::endl;
699 theRing = tTopo->
tecRing(detid);
700 unsigned int theSide =
module.petal()[0];
702 std::cout <<
"\tTEC Petal Back " << std::endl;
704 std::cout <<
"\tTEC Petal Front" << std::endl;
705 std::cout <<
"\tTEC Layer " << theLayer << std::endl;
706 std::cout <<
"\tTEC Ring " << theRing << std::endl;
716 std::cout <<
"Thickness = " << 2. * halfThick - 0.003 <<
"; " << thick * 9.36 << std::endl
720 std::cout <<
"Hit position = " <<
hit.localPosition().
x() <<
" " <<
hit.localPosition().
y() <<
" " 721 <<
hit.localPosition().
z() << std::endl;
734 dist = (fabs(
hit.localPosition().
x()) > boundX || fabs(
hit.localPosition().
y()) > boundY)
754 return std::pair<double, PSimHit>(dist,
hit);
770 LogDebug(
"FastTracking") <<
"Barrel DetLayer dump: ";
771 for (
auto bl = barrelLayers.begin(); bl != barrelLayers.end(); ++bl) {
772 LogDebug(
"FastTracking") <<
"radius " << (**bl).specificSurface().radius();
776 LogDebug(
"FastTracking") <<
"Positive Forward DetLayer dump: ";
777 for (
auto fl = posForwardLayers.begin(); fl != posForwardLayers.end(); ++fl) {
778 LogDebug(
"FastTracking") <<
"Z pos " << (**fl).surface().position().z() <<
" radii " 779 << (**fl).specificSurface().innerRadius() <<
", " 780 << (**fl).specificSurface().outerRadius();
783 const float rTolerance = 1.5;
784 const float zTolerance = 3.;
786 LogDebug(
"FastTracking") <<
"Dump of TrackerInteractionGeometry cylinders:";
792 LogDebug(
"FastTracking") <<
"Famos Layer no " <<
i->layerNumber() <<
" is sensitive? " <<
i->sensitive() <<
" pos " 793 <<
i->surface().position();
797 if (cyl !=
nullptr) {
798 LogDebug(
"FastTracking") <<
" cylinder radius " << cyl->radius();
800 for (
auto bl = barrelLayers.begin(); bl != barrelLayers.end(); ++bl) {
801 if (fabs(cyl->radius() - (**bl).specificSurface().radius()) < rTolerance) {
804 LogDebug(
"FastTracking") <<
"Corresponding DetLayer found with radius " << (**bl).specificSurface().radius();
809 edm::LogWarning(
"FastTracking") <<
" Trajectory manager FAILED to find a corresponding DetLayer!";
812 LogDebug(
"FastTracking") <<
" disk radii " << disk->innerRadius() <<
", " << disk->outerRadius();
814 for (
auto fl = posForwardLayers.begin(); fl != posForwardLayers.end(); ++fl) {
815 if (fabs(disk->position().z() - (**fl).surface().position().z()) < zTolerance) {
818 LogDebug(
"FastTracking") <<
"Corresponding DetLayer found with Z pos " << (**fl).surface().position().z()
819 <<
" and radii " << (**fl).specificSurface().innerRadius() <<
", " 820 << (**fl).specificSurface().outerRadius();
825 edm::LogWarning(
"FastTracking") <<
"FAILED to find a corresponding DetLayer!";
832 for (
auto nl = negForwardLayers.begin(); nl != negForwardLayers.end(); ++nl) {
836 if (fabs((**nl).surface().position().z() +
theLayerMap[
i]->surface().position().z()) < zTolerance) {
845 if (zpos > 0 || !
layer.forward())
852 std::map<unsigned, std::map<double, PSimHit> >::const_iterator itrack =
thePSimHits.begin();
853 std::map<unsigned, std::map<double, PSimHit> >::const_iterator itrackEnd =
thePSimHits.end();
854 for (; itrack != itrackEnd; ++itrack) {
855 std::map<double, PSimHit>::const_iterator it = (itrack->second).begin();
856 std::map<double, PSimHit>::const_iterator itEnd = (itrack->second).
end();
857 for (; it != itEnd; ++it) {
869 c.push_back(it->second);
virtual std::vector< const GeomDet * > components() const
Returns direct components, if any.
void reconstruct(const TrackerTopology *tTopo, RandomEngineAndDistribution const *)
Does the real job.
bool noMother() const
no mother particle
void initializeLayerMap()
Initialize correspondence map between Famos interaction geometry and tracker reco geometry...
std::vector< ForwardDetLayer const * > const & negForwardLayers() const
int addSimVertex(const XYZTLorentzVector &decayVertex, int im=-1, FSimVertexType::VertexType type=FSimVertexType::ANY)
Add a new vertex to the Event and to the various lists.
FSimTrack & track(int id) const
Return track with given Id.
T getParameter(std::string const &) const
unsigned int tobLayer(const DetId &id) const
void initializeTrackerGeometry(const TrackerGeometry *geomTracker)
Initialize the full Tracker Geometry.
void propagateToCalorimeters(ParticlePropagator &PP, int fsimi, RandomEngineAndDistribution const *)
Propagate the particle through the calorimeters.
unsigned int pxbLayer(const DetId &id) const
PythiaDecays * myDecayEngine
virtual std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
virtual float length() const =0
bool propagateToPreshowerLayer1(bool first=true)
void makePSimHits(const GeomDet *det, const TrajectoryStateOnSurface &ts, std::map< double, PSimHit > &theHitMap, int tkID, float el, float thick, int pID, const TrackerTopology *tTopo)
and there
double cTau(int pdgID, const HepPDT::ParticleDataTable *pdt)
LocalPoint localPosition() const
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
void createPSimHits(const TrackerLayer &layer, const ParticlePropagator &P_before, std::map< double, PSimHit > &theHitMap, int trackID, int partID, const TrackerTopology *tTopo)
Create a vector of PSimHits.
const MagneticFieldMap * _theFieldMap
void setPosition(const math::XYZTLorentzVector &newPosition)
Reset the position (to be used with care)
const DetLayer * detLayer(const TrackerLayer &layer, float zpos) const
Returns the DetLayer pointer corresponding to the FAMOS layer.
const TrackerGeometry * theGeomTracker
void initializeRecoGeometry(const GeometricSearchTracker *geomSearchTracker, const TrackerInteractionGeometry *interactionGeometry, const MagneticFieldMap *aFieldMap)
Initialize the Reconstruction Geometry.
double Z() const
z of vertex
unsigned int tidWheel(const DetId &id) const
unsigned int tecWheel(const DetId &id) const
int addSimTrack(const RawParticle *p, int iv, int ig=-1, const HepMC::GenVertex *ev=nullptr)
Add a new track to the Event and to the various lists.
void moveAllDaughters(int fsimi, const Rotation &r, double rescale)
Move, rescale and rotate all daughters after propagation, material effects and decay of the mother...
Global3DPoint GlobalPoint
const GeometricSearchTracker * theGeomSearchTracker
void setEcal(const RawParticle &pp, int success)
Set the ecal variables.
const DaughterParticleList & particleDaughters(ParticlePropagator &particle, CLHEP::HepRandomEngine *)
void setPropagate()
The particle has been propgated through the tracker.
bool acceptParticle(const RawParticle &p) const
bool propagateToBoundSurface(const TrackerLayer &)
DaughterParticleList::const_iterator DaughterParticleIterator
void setClosestDaughterId(int id)
Set the index of the closest charged daughter.
void setLayer2(const RawParticle &pp, int success)
Set the preshower layer2 variables.
const XYZTLorentzVector & momentum() const
the momentum fourvector
unsigned int nTracks() const
Number of tracks.
const FSimVertex vertex() const
Origin vertex.
ROOT::Math::AxisAngle Rotation
unsigned int tecRing(const DetId &id) const
ring id
double charge() const
get the MEASURED charge
const FSimVertex & endVertex() const
end vertex
constexpr std::array< uint8_t, layerIndexSize > layer
bool onFiducial() const
Is the vertex on some material ?
const HepPDT::ParticleDataTable * theTable() const
Get the pointer to the particle data table.
const FSimTrack & daughter(int i) const
Ith daughter.
int type() const
particle type (HEP PDT convension)
bool propagateToVFcalEntrance(bool first=true)
void setLayer1(const RawParticle &pp, int success)
Set the preshower layer1 variables.
~TrajectoryManager()
Default Destructor.
uint32_t tobStereo(const DetId &id) const
GlobalPoint globalPosition() const
const XYZTLorentzVector & momentum() const
Temporary (until move of SimTrack to Mathcore) - No! Actually very useful.
double energyLoss() const
Return the energy loss by ionization in the current layer.
const TrackerInteractionGeometry * _theGeometry
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
CLHEP::HepRandomEngine & theEngine() const
int id() const
the index in FBaseSimEvent
MaterialEffects * theMaterialEffects
std::pair< double, PSimHit > makeSinglePSimHit(const GeomDetUnit &det, const TrajectoryStateOnSurface &ts, int tkID, float el, float thick, int pID, const TrackerTopology *tTopo) const
and there
unsigned int pxfDisk(const DetId &id) const
LocalVector localMomentum() const
void setPropagationConditions(const TrackerLayer &, bool firstLoop=true)
bool hasDecayed() const
Has the particle decayed while propagated ?
RawParticle const & particle() const
The particle being propagated.
void save()
Save nuclear interaction information.
std::list< TrackerLayer >::const_iterator cylinderEnd() const
Returns the last pointer in the cylinder list.
std::vector< ForwardDetLayer const * > const & posForwardLayers() const
bool notYetToEndVertex(const XYZTLorentzVector &pos) const
Compare the end vertex position with another position.
TrajectoryManager()
Default Constructor.
DetId geographicalId() const
The label of this GeomDet.
const BasicVectorType & basicVector() const
std::map< unsigned, std::map< double, PSimHit > > thePSimHits
bool propagateToEcalEntrance(bool first=true)
int nDaughters() const
Number of daughters.
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
void interact(FSimEvent &simEvent, const TrackerLayer &layer, ParticlePropagator &PP, unsigned i, RandomEngineAndDistribution const *)
XYZVector Vect() const
the momentum threevector
double thickness() const
Return the thickness of the current layer.
int closestDaughterId() const
Get the index of the closest charged daughter.
const Plane & surface() const
The nominal surface of the GeomDet.
std::list< TrackerLayer >::const_iterator cylinderBegin() const
Returns the first pointer in the cylinder list.
int getSuccess() const
Has propagation been performed and was barrel or endcap reached ?
TrajectoryStateOnSurface makeTrajectoryState(const DetLayer *layer, const ParticlePropagator &pp, const MagneticField *field) const
Teddy, you must put comments there.
constexpr uint32_t rawId() const
get the raw id
std::vector< BarrelDetLayer const * > const & barrelLayers() const
const math::XYZTLorentzVector & position() const
Temporary (until CMSSW moves to Mathcore) - No ! Actually very useful.
double transverseCurvature() const
void setTkPosition(const math::XYZVectorD &pos)
GlobalVector globalMomentum() const
const TrackerInteractionGeometry * theGeometry()
Returns the pointer to geometry.
std::vector< const DetLayer * > theLayerMap
bool propagateToHcalEntrance(bool first=true)
void loadSimHits(edm::PSimHitContainer &c) const
FSimVertex & vertex(int id) const
Return vertex with given Id.
const KineParticleFilter & filter() const
unsigned int tidRing(const DetId &id) const
void setTkMomentum(const math::XYZTLorentzVectorD &mom)
void setVFcal(const RawParticle &pp, int success)
Set the hcal variables.
bool propagateToLayer(ParticlePropagator &PP, unsigned layer)
std::vector< PSimHit > PSimHitContainer
void setHcal(const RawParticle &pp, int success)
Set the hcal variables.
unsigned int tibLayer(const DetId &id) const
double getMagneticField() const
Get the magnetic field.
Vector3DBase unit() const
void updateWithDaughters(ParticlePropagator &PP, int fsimi, RandomEngineAndDistribution const *)
Decay the particle and update the SimEvent with daughters.
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
Log< level::Warning, false > LogWarning
math::XYZVector XYZVector
void setMomentum(const math::XYZTLorentzVector &newMomentum)
Reset the momentum (to be used with care)
virtual float width() const =0
bool propagateToPreshowerLayer2(bool first=true)
int id() const
the index in FBaseSimEvent and other vectors
const FSimTrack & mother() const
mother
Global3DVector GlobalVector
math::XYZTLorentzVector XYZTLorentzVector
std::vector< RawParticle > DaughterParticleList
const XYZTLorentzVector & vertex() const
the vertex fourvector
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
const Bounds & bounds() const