51 mySimEvent(aSimEvent),
59 theNegLayerOffset(27),
155 std::list<TrackerLayer>::const_iterator cyliter;
181 PP.setPropagationConditions(*cyliter);
182 if ( PP.inside() && !PP.onSurface() )
break;
194 double ppcos2T = PP.particle().cos2Theta();
195 double ppcos2V = PP.particle().cos2ThetaV();
198 if ( ( ppcos2T > 0.99 && ppcos2T < 0.9998 ) && ( cyl == 0 || ( ppcos2V > 0.99 && ppcos2V < 0.9998 ) ) ){
204 }
else if ( ppcos2T > 0.9998 && ( cyl == 0 || ppcos2V > 0.9998 ) ) {
209 if ( ppcos2T > 0.9998 && ( cyl == 0 || ppcos2V > 0.9998 ) ) {
220 if ( cyliter->surface().mediumProperties().radLen() < 1E-10 ) {
228 bool escapeBarrel = PP.getSuccess() == -1;
229 bool escapeEndcap = (PP.getSuccess() == -2 && success == 1);
231 bool fullPropagation =
232 (PP.getSuccess() <= 0 && success==0) || escapeEndcap;
234 if ( escapeBarrel ) {
237 sign=1; ++cyliter; ++cyl;
241 --cyliter; --cyl; fullPropagation=
true;
247 PP.setPropagationConditions(*cyliter,!fullPropagation);
248 if ( escapeEndcap ) PP.increaseRCyl(0.0005);
251 success = PP.getSuccess();
255 if ( !PP.propagateToBoundSurface(*cyliter) ||
256 PP.getSuccess()<=0) {
274 if( PP.getSuccess() > 0 && PP.onFiducial() ) {
278 PP.particle().charge()!=0. &&
279 cyliter->sensitive() &&
287 saveHit &= PP.particle().E()>1E-6;
291 if ( cyliter->sensitive() ) {
332 if (sign==1) {++cyliter;++cyl;}
333 else {--cyliter;--cyl;}
341 PP.propagateToEcal();
345 if(PP.getSuccess()==0) {
346 --cyliter; --cyl; sign = -
sign;
347 PP.setPropagationConditions(*cyliter);
348 PP.propagateToBoundSurface(*cyliter);
351 if(PP.getSuccess()<0) {++cyliter; ++cyl;}
356 if ( PP.hasDecayed() )
435 std::list<TrackerLayer>::const_iterator cyliter;
444 if ( layer != cyliter->layerNumber() )
continue;
477 double magBefore =
std::sqrt(momentumBefore.Vect().mag2());
478 double magAfter =
std::sqrt(momentumAfter.Vect().mag2());
480 XYZVector axis = momentumBefore.Vect().Cross(momentumAfter.Vect());
481 double angle = std::acos(momentumBefore.Vect().Dot(momentumAfter.Vect())/(magAfter*magBefore));
484 double rescale = magAfter/magBefore;
499 if ( !daughters.empty() ) {
500 double distMin = 1E99;
501 int theClosestChargedDaughterId = -1;
507 if ( ivertex != -1 ) {
508 for ( ; daughter != daughters.end(); ++daughter) {
512 double dist = (daughter->Vect().Unit().Cross(PP.
particle().
Vect().Unit())).R();
513 if ( dist <
distCut && dist < distMin ) {
515 theClosestChargedDaughterId = theDaughterId;
521 if ( theClosestChargedDaughterId >=0 )
538 XYZVector newMomentum (r * daughMomentum.Vect());
540 double newEnergy =
std::sqrt(newMomentum.mag2() + daughMomentum.mag2());
552 std::map<double,PSimHit>& theHitMap,
577 std::vector<DetWithState> compat
581 std::map<double,PSimHit> theTrackHits;
582 for (std::vector<DetWithState>::const_iterator
i=compat.begin();
i!=compat.end();
i++) {
585 makePSimHits(
i->first,
i->second, theHitMap, trackID, eloss, thickness, partID,tTopo);
605 std::map<double,PSimHit>& theHitMap,
606 int tkID,
float el,
float thick,
int pID,
612 for (std::vector< const GeomDet*>::const_iterator
i = comp.begin();
613 i != comp.end();
i++) {
616 theHitMap.insert(theHitMap.end(),
makeSinglePSimHit( *du, ts, tkID, el, thick, pID,tTopo));
621 theHitMap.insert(theHitMap.end(),
makeSinglePSimHit( *du, ts, tkID, el, thick, pID,tTopo));
626 std::pair<double,PSimHit>
629 int tkID,
float el,
float thick,
int pID,
633 const float onSurfaceTolarance = 0.01;
646 std::pair<bool,double>
path = crossing.pathLength(det.
surface());
649 return std::pair<double,PSimHit>(0.,
PSimHit());
658 float halfThick = 0.5*theDetPlane.bounds().thickness();
665 eloss *= (2.* halfThick - 0.003) / (9.36 * thick);
676 int localTkID = tkID;
687 unsigned subdet =
DetId(
hit.detUnitId()).subdetId();
688 double boundX = theDetPlane.bounds().width()/2.;
689 double boundY = theDetPlane.bounds().length()/2.;
692 if ( subdet == 4 || subdet == 6 )
693 boundX *= 1. -
hit.localPosition().
y()/theDetPlane.position().perp();
696 unsigned detid =
DetId(
hit.detUnitId()).rawId();
698 unsigned theLayer = 0;
699 unsigned theRing = 0;
705 std::cout <<
"\tPixel Barrel Layer " << theLayer << std::endl;
712 theLayer = tTopo->
pxfDisk(detid);
713 std::cout <<
"\tPixel Forward Disk " << theLayer << std::endl;
721 std::cout <<
"\tTIB Layer " << theLayer << std::endl;
729 theRing = tTopo->
tidRing(detid);
730 unsigned int theSide =
module.side();
732 std::cout <<
"\tTID Petal Back " << std::endl;
734 std::cout <<
"\tTID Petal Front" << std::endl;
735 std::cout <<
"\tTID Layer " << theLayer << std::endl;
736 std::cout <<
"\tTID Ring " << theRing << std::endl;
745 std::cout <<
"\tTOB Layer " << theLayer << std::endl;
752 theRing = tTopo->
tecRing(detid);
753 unsigned int theSide =
module.petal()[0];
755 std::cout <<
"\tTEC Petal Back " << std::endl;
757 std::cout <<
"\tTEC Petal Front" << std::endl;
758 std::cout <<
"\tTEC Layer " << theLayer << std::endl;
759 std::cout <<
"\tTEC Ring " << theRing << std::endl;
770 std::cout <<
"Thickness = " << 2.*halfThick-0.003 <<
"; " << thick * 9.36 << std::endl
775 <<
hit.localPosition().
x() <<
" " 776 <<
hit.localPosition().
y() <<
" " 777 <<
hit.localPosition().
z() << std::endl;
790 dist = ( fabs(
hit.localPosition().
x()) > boundX ||
791 fabs(
hit.localPosition().
y()) > boundY ) ?
810 return std::pair<double,PSimHit>(dist,
hit);
829 const std::vector< const BarrelDetLayer*>& barrelLayers =
831 LogDebug(
"FastTracking") <<
"Barrel DetLayer dump: ";
832 for (
auto bl=barrelLayers.begin();
833 bl != barrelLayers.end(); ++bl) {
834 LogDebug(
"FastTracking")<<
"radius " << (**bl).specificSurface().radius();
837 const std::vector< const ForwardDetLayer*>& posForwardLayers =
839 LogDebug(
"FastTracking") <<
"Positive Forward DetLayer dump: ";
840 for (
auto fl=posForwardLayers.begin();
841 fl != posForwardLayers.end(); ++fl) {
842 LogDebug(
"FastTracking") <<
"Z pos " 843 << (**fl).surface().position().z()
845 << (**fl).specificSurface().innerRadius()
847 << (**fl).specificSurface().outerRadius();
850 const float rTolerance = 1.5;
851 const float zTolerance = 3.;
853 LogDebug(
"FastTracking")<<
"Dump of TrackerInteractionGeometry cylinders:";
859 LogDebug(
"FastTracking") <<
"Famos Layer no " <<
i->layerNumber()
860 <<
" is sensitive? " <<
i->sensitive()
861 <<
" pos " <<
i->surface().position();
862 if (!
i->sensitive())
continue;
864 if (cyl !=
nullptr) {
865 LogDebug(
"FastTracking") <<
" cylinder radius " << cyl->radius();
868 bl=barrelLayers.begin(); bl != barrelLayers.end(); ++bl) {
870 if (fabs( cyl->radius() - (**bl).specificSurface().radius()) < rTolerance) {
873 LogDebug(
"FastTracking")<<
"Corresponding DetLayer found with radius " 874 << (**bl).specificSurface().radius();
879 edm::LogWarning(
"FastTracking") <<
" Trajectory manager FAILED to find a corresponding DetLayer!";
883 LogDebug(
"FastTracking") <<
" disk radii " << disk->innerRadius()
884 <<
", " << disk->outerRadius();
886 for (
auto fl=posForwardLayers.begin();
887 fl != posForwardLayers.end(); ++fl) {
889 if (fabs( disk->position().z() - (**fl).surface().position().z()) < zTolerance) {
892 LogDebug(
"FastTracking") <<
"Corresponding DetLayer found with Z pos " 893 << (**fl).surface().position().z()
895 << (**fl).specificSurface().innerRadius()
897 << (**fl).specificSurface().outerRadius();
902 edm::LogWarning(
"FastTracking") <<
"FAILED to find a corresponding DetLayer!";
909 for (
auto nl=negForwardLayers.begin();
910 nl != negForwardLayers.end(); ++nl) {
913 if ( fabs( (**nl).surface().position().z() +
theLayerMap[
i]-> surface().position().z()) < zTolerance) {
933 std::map<unsigned,std::map<double,PSimHit> >::const_iterator itrack =
thePSimHits.begin();
934 std::map<unsigned,std::map<double,PSimHit> >::const_iterator itrackEnd =
thePSimHits.end();
935 for ( ; itrack != itrackEnd; ++itrack ) {
936 std::map<double,PSimHit>::const_iterator it = (itrack->second).
begin();
937 std::map<double,PSimHit>::const_iterator itEnd = (itrack->second).
end();
938 for( ; it!= itEnd; ++it) {
949 if ( it->first > 0. ) c.push_back(it->second);
void reconstruct(const TrackerTopology *tTopo, RandomEngineAndDistribution const *)
Does the real job.
bool hasDecayed() const
Has the particle decayed while propagated ?
int id() const
the index in FBaseSimEvent
void initializeLayerMap()
Initialize correspondence map between Famos interaction geometry and tracker reco geometry...
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
T getParameter(std::string const &) 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.
T getUntrackedParameter(std::string const &, T const &) const
const DetLayer * detLayer(const TrackerLayer &layer, float zpos) const
Returns the DetLayer pointer corresponding to the FAMOS layer.
virtual float length() const =0
void initializeTrackerGeometry(const TrackerGeometry *geomTracker)
Initialize the full Tracker Geometry.
void propagateToCalorimeters(ParticlePropagator &PP, int fsimi, RandomEngineAndDistribution const *)
Propagate the particle through the calorimeters.
XYZVector Vect() const
the momentum threevector
PythiaDecays * myDecayEngine
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
bool acceptParticle(const RawParticle &p) const
virtual ConstReferenceCountingPointer< TangentPlane > tangentPlane(const GlobalPoint &) const =0
int addSimTrack(const RawParticle *p, int iv, int ig=-1, const HepMC::GenVertex *ev=0)
Add a new track to the Event and to the various lists.
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
unsigned int tibLayer(const DetId &id) const
double cTau(int pdgID, const HepPDT::ParticleDataTable *pdt)
unsigned int tidRing(const DetId &id) const
const FSimVertex & endVertex() const
end vertex
std::vector< ForwardDetLayer const * > const & posForwardLayers() const
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
unsigned int layerNumber() const
Returns the layer number.
bool forward() const
Is the layer forward ?
void setPosition(const math::XYZTLorentzVector &newPosition)
Reset the position (to be used with care)
const TrackerGeometry * theGeomTracker
void initializeRecoGeometry(const GeometricSearchTracker *geomSearchTracker, const TrackerInteractionGeometry *interactionGeometry, const MagneticFieldMap *aFieldMap)
Initialize the Reconstruction Geometry.
unsigned int pxfDisk(const DetId &id) const
LocalPoint localPosition() const
const XYZTLorentzVector & momentum() const
Temporary (until move of SimTrack to Mathcore) - No! Actually very useful.
TrajectoryStateOnSurface makeTrajectoryState(const DetLayer *layer, const ParticlePropagator &pp, const MagneticField *field) const
Teddy, you must put comments there.
unsigned int tecRing(const DetId &id) const
ring id
const HepPDT::ParticleDataTable * theTable() const
Get the pointer to the particle data table.
uint32_t tobStereo(const DetId &id) const
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
constexpr uint32_t rawId() const
get the raw id
const FSimTrack & daughter(int i) const
Ith daughter.
const GeometricSearchTracker * theGeomSearchTracker
void setEcal(const RawParticle &pp, int success)
Set the ecal variables.
std::list< TrackerLayer >::const_iterator cylinderEnd() const
Returns the last pointer in the cylinder list.
int getSuccess() const
Has propagation been performed and was barrel or endcap reached ?
const DaughterParticleList & particleDaughters(ParticlePropagator &particle, CLHEP::HepRandomEngine *)
void setPropagate()
The particle has been propgated through the tracker.
GlobalPoint globalPosition() const
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
bool propagateToBoundSurface(const TrackerLayer &)
int nDaughters() const
Number of daughters.
const Bounds & bounds() const
DaughterParticleList::const_iterator DaughterParticleIterator
unsigned int tidWheel(const DetId &id) const
void setClosestDaughterId(int id)
Set the index of the closest charged daughter.
void setLayer2(const RawParticle &pp, int success)
Set the preshower layer2 variables.
RawParticle const & particle() const
The particle being propagated.
ROOT::Math::AxisAngle Rotation
const Plane & surface() const
The nominal surface of the GeomDet.
bool notYetToEndVertex(const XYZTLorentzVector &pos) const
Compare the end vertex position with another position.
virtual std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
FSimVertex & vertex(int id) const
Return vertex with given Id.
LocalVector localMomentum() const
virtual float width() const =0
bool propagateToVFcalEntrance(bool first=true)
void setLayer1(const RawParticle &pp, int success)
Set the preshower layer1 variables.
const XYZTLorentzVector & momentum() const
the momentum fourvector
~TrajectoryManager()
Default Destructor.
const TrackerInteractionGeometry * _theGeometry
const math::XYZTLorentzVector & position() const
Temporary (until CMSSW moves to Mathcore) - No ! Actually very useful.
MaterialEffects * theMaterialEffects
std::vector< ForwardDetLayer const * > const & negForwardLayers() const
double Y() const
y of vertex
double Py() const
y of the momentum
int closestDaughterId() const
Get the index of the closest charged daughter.
double Z() const
z of vertex
void setPropagationConditions(const TrackerLayer &, bool firstLoop=true)
virtual const BoundSurface & surface() const =0
The surface of the GeometricSearchDet.
DetId geographicalId() const
The label of this GeomDet.
void save()
Save nuclear interaction information.
CLHEP::HepRandomEngine & theEngine() const
double Pz() const
z of the momentum
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
double charge() const
get the MEASURED charge
TrajectoryManager()
Default Constructor.
bool propagateToEcalEntrance(bool first=true)
unsigned int nTracks() const
Number of tracks.
std::map< unsigned, std::map< double, PSimHit > > thePSimHits
unsigned int pxbLayer(const DetId &id) const
virtual std::vector< const GeomDet * > components() const
Returns direct components, if any.
const XYZTLorentzVector & vertex() const
the vertex fourvector
double energyLoss() const
Return the energy loss by ionization in the current layer.
void interact(FSimEvent &simEvent, const TrackerLayer &layer, ParticlePropagator &PP, unsigned i, RandomEngineAndDistribution const *)
Vector3DBase unit() const
double thickness() const
Return the thickness of the current layer.
void loadSimHits(edm::PSimHitContainer &c) const
std::list< TrackerLayer >::const_iterator cylinderBegin() const
Returns the first pointer in the cylinder list.
void setTkPosition(const math::XYZVectorD &pos)
const TrackerInteractionGeometry * theGeometry()
Returns the pointer to geometry.
double X() const
x of vertex
double getMagneticField() const
Get the magnetic field.
int type() const
particle type (HEP PDT convension)
std::vector< const DetLayer * > theLayerMap
bool propagateToHcalEntrance(bool first=true)
GlobalVector globalMomentum() const
const KineParticleFilter & filter() const
int id() const
the index in FBaseSimEvent and other vectors
double Px() const
x of the momentum
void setTkMomentum(const math::XYZTLorentzVectorD &mom)
void setVFcal(const RawParticle &pp, int success)
Set the hcal variables.
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
bool noMother() const
no mother particle
bool propagateToLayer(ParticlePropagator &PP, unsigned layer)
std::vector< PSimHit > PSimHitContainer
void setHcal(const RawParticle &pp, int success)
Set the hcal variables.
const FSimVertex vertex() const
Origin vertex.
bool onFiducial() const
Is the vertex on some material ?
void updateWithDaughters(ParticlePropagator &PP, int fsimi, RandomEngineAndDistribution const *)
Decay the particle and update the SimEvent with daughters.
math::XYZVector XYZVector
void setMomentum(const math::XYZTLorentzVector &newMomentum)
Reset the momentum (to be used with care)
const BasicVectorType & basicVector() const
unsigned int tecWheel(const DetId &id) const
bool propagateToPreshowerLayer2(bool first=true)
const FSimTrack & mother() const
mother
unsigned int tobLayer(const DetId &id) const
Global3DVector GlobalVector
math::XYZTLorentzVector XYZTLorentzVector
std::vector< BarrelDetLayer const * > const & barrelLayers() const
std::vector< RawParticle > DaughterParticleList
FSimTrack & track(int id) const
Return track with given Id.
double transverseCurvature() const
T angle(T x1, T y1, T z1, T x2, T y2, T z2)