50 mySimEvent(aSimEvent),
53 theMaterialEffects(0),
56 theGeomSearchTracker(0),
58 theNegLayerOffset(27),
154 std::list<TrackerLayer>::const_iterator cyliter;
180 PP.setPropagationConditions(*cyliter);
181 if ( PP.inside() && !PP.onSurface() )
break;
193 double ppcos2T = PP.cos2Theta();
194 double ppcos2V = PP.cos2ThetaV();
197 if ( ( ppcos2T > 0.99 && ppcos2T < 0.9998 ) && ( cyl == 0 || ( ppcos2V > 0.99 && ppcos2V < 0.9998 ) ) ){
203 }
else if ( ppcos2T > 0.9998 && ( cyl == 0 || ppcos2V > 0.9998 ) ) {
208 if ( ppcos2T > 0.9998 && ( cyl == 0 || ppcos2V > 0.9998 ) ) {
219 if ( cyliter->surface().mediumProperties().radLen() < 1E-10 ) {
227 bool escapeBarrel = PP.getSuccess() == -1;
228 bool escapeEndcap = (PP.getSuccess() == -2 && success == 1);
230 bool fullPropagation =
231 (PP.getSuccess() <= 0 && success==0) || escapeEndcap;
233 if ( escapeBarrel ) {
236 sign=1; ++cyliter; ++cyl;
240 --cyliter; --cyl; fullPropagation=
true;
246 PP.setPropagationConditions(*cyliter,!fullPropagation);
247 if ( escapeEndcap ) PP.increaseRCyl(0.0005);
250 success = PP.getSuccess();
254 if ( !PP.propagateToBoundSurface(*cyliter) ||
255 PP.getSuccess()<=0) {
273 if( PP.getSuccess() > 0 && PP.onFiducial() ) {
278 cyliter->sensitive() &&
286 saveHit &= PP.E()>1E-6;
290 if ( cyliter->sensitive() ) {
331 if (sign==1) {++cyliter;++cyl;}
332 else {--cyliter;--cyl;}
340 PP.propagateToEcal();
344 if(PP.getSuccess()==0) {
345 --cyliter; --cyl; sign = -
sign;
346 PP.setPropagationConditions(*cyliter);
347 PP.propagateToBoundSurface(*cyliter);
350 if(PP.getSuccess()<0) {++cyliter; ++cyl;}
355 if ( PP.hasDecayed() )
434 std::list<TrackerLayer>::const_iterator cyliter;
443 if ( layer != cyliter->layerNumber() )
continue;
476 double magBefore =
std::sqrt(momentumBefore.Vect().mag2());
477 double magAfter =
std::sqrt(momentumAfter.Vect().mag2());
479 XYZVector axis = momentumBefore.Vect().Cross(momentumAfter.Vect());
480 double angle = std::acos(momentumBefore.Vect().Dot(momentumAfter.Vect())/(magAfter*magBefore));
483 double rescale = magAfter/magBefore;
498 if ( daughters.size() ) {
499 double distMin = 1E99;
500 int theClosestChargedDaughterId = -1;
506 if ( ivertex != -1 ) {
507 for ( ; daughter != daughters.end(); ++daughter) {
510 if ( PP.
charge() * daughter->charge() > 1E-10 ) {
511 double dist = (daughter->Vect().Unit().Cross(PP.Vect().Unit())).R();
512 if ( dist <
distCut && dist < distMin ) {
514 theClosestChargedDaughterId = theDaughterId;
520 if ( theClosestChargedDaughterId >=0 )
537 XYZVector newMomentum (r * daughMomentum.Vect());
538 newMomentum *= rescale;
539 double newEnergy =
std::sqrt(newMomentum.mag2() + daughMomentum.mag2());
551 std::map<double,PSimHit>& theHitMap,
576 std::vector<DetWithState> compat
580 std::map<double,PSimHit> theTrackHits;
581 for (std::vector<DetWithState>::const_iterator
i=compat.begin();
i!=compat.end();
i++) {
584 makePSimHits(
i->first,
i->second, theHitMap, trackID, eloss, thickness, partID,tTopo);
604 std::map<double,PSimHit>& theHitMap,
605 int tkID,
float el,
float thick,
int pID,
611 for (std::vector< const GeomDet*>::const_iterator
i = comp.begin();
612 i != comp.end();
i++) {
615 theHitMap.insert(theHitMap.end(),
makeSinglePSimHit( *du, ts, tkID, el, thick, pID,tTopo));
620 theHitMap.insert(theHitMap.end(),
makeSinglePSimHit( *du, ts, tkID, el, thick, pID,tTopo));
625 std::pair<double,PSimHit>
628 int tkID,
float el,
float thick,
int pID,
632 const float onSurfaceTolarance = 0.01;
645 std::pair<bool,double>
path = crossing.pathLength(det.
surface());
648 return std::pair<double,PSimHit>(0.,
PSimHit());
657 float halfThick = 0.5*theDetPlane.bounds().thickness();
664 eloss *= (2.* halfThick - 0.003) / (9.36 * thick);
675 int localTkID = tkID;
686 unsigned subdet =
DetId(
hit.detUnitId()).subdetId();
687 double boundX = theDetPlane.bounds().width()/2.;
688 double boundY = theDetPlane.bounds().length()/2.;
691 if ( subdet == 4 || subdet == 6 )
692 boundX *= 1. -
hit.localPosition().
y()/theDetPlane.position().perp();
695 unsigned detid =
DetId(
hit.detUnitId()).rawId();
697 unsigned theLayer = 0;
698 unsigned theRing = 0;
704 std::cout <<
"\tPixel Barrel Layer " << theLayer << std::endl;
711 theLayer = tTopo->
pxfDisk(detid);
712 std::cout <<
"\tPixel Forward Disk " << theLayer << std::endl;
720 std::cout <<
"\tTIB Layer " << theLayer << std::endl;
728 theRing = tTopo->
tidRing(detid);
729 unsigned int theSide =
module.side();
731 std::cout <<
"\tTID Petal Back " << std::endl;
733 std::cout <<
"\tTID Petal Front" << std::endl;
734 std::cout <<
"\tTID Layer " << theLayer << std::endl;
735 std::cout <<
"\tTID Ring " << theRing << std::endl;
744 std::cout <<
"\tTOB Layer " << theLayer << std::endl;
751 theRing = tTopo->
tecRing(detid);
752 unsigned int theSide =
module.petal()[0];
754 std::cout <<
"\tTEC Petal Back " << std::endl;
756 std::cout <<
"\tTEC Petal Front" << std::endl;
757 std::cout <<
"\tTEC Layer " << theLayer << std::endl;
758 std::cout <<
"\tTEC Ring " << theRing << std::endl;
769 std::cout <<
"Thickness = " << 2.*halfThick-0.003 <<
"; " << thick * 9.36 << std::endl
774 <<
hit.localPosition().
x() <<
" "
775 <<
hit.localPosition().
y() <<
" "
776 <<
hit.localPosition().
z() << std::endl;
789 dist = ( fabs(
hit.localPosition().
x()) > boundX ||
790 fabs(
hit.localPosition().
y()) > boundY ) ?
809 return std::pair<double,PSimHit>(dist,
hit);
828 const std::vector< const BarrelDetLayer*>& barrelLayers =
830 LogDebug(
"FastTracking") <<
"Barrel DetLayer dump: ";
831 for (
auto bl=barrelLayers.begin();
832 bl != barrelLayers.end(); ++bl) {
833 LogDebug(
"FastTracking")<<
"radius " << (**bl).specificSurface().radius();
836 const std::vector< const ForwardDetLayer*>& posForwardLayers =
838 LogDebug(
"FastTracking") <<
"Positive Forward DetLayer dump: ";
839 for (
auto fl=posForwardLayers.begin();
840 fl != posForwardLayers.end(); ++fl) {
841 LogDebug(
"FastTracking") <<
"Z pos "
842 << (**fl).surface().position().z()
844 << (**fl).specificSurface().innerRadius()
846 << (**fl).specificSurface().outerRadius();
849 const float rTolerance = 1.5;
850 const float zTolerance = 3.;
852 LogDebug(
"FastTracking")<<
"Dump of TrackerInteractionGeometry cylinders:";
858 LogDebug(
"FastTracking") <<
"Famos Layer no " <<
i->layerNumber()
859 <<
" is sensitive? " <<
i->sensitive()
860 <<
" pos " <<
i->surface().position();
861 if (!
i->sensitive())
continue;
864 LogDebug(
"FastTracking") <<
" cylinder radius " << cyl->radius();
867 bl=barrelLayers.begin(); bl != barrelLayers.end(); ++bl) {
869 if (fabs( cyl->radius() - (**bl).specificSurface().radius()) < rTolerance) {
872 LogDebug(
"FastTracking")<<
"Corresponding DetLayer found with radius "
873 << (**bl).specificSurface().radius();
878 edm::LogWarning(
"FastTracking") <<
" Trajectory manager FAILED to find a corresponding DetLayer!";
882 LogDebug(
"FastTracking") <<
" disk radii " << disk->innerRadius()
883 <<
", " << disk->outerRadius();
885 for (
auto fl=posForwardLayers.begin();
886 fl != posForwardLayers.end(); ++fl) {
888 if (fabs( disk->position().z() - (**fl).surface().position().z()) < zTolerance) {
891 LogDebug(
"FastTracking") <<
"Corresponding DetLayer found with Z pos "
892 << (**fl).surface().position().z()
894 << (**fl).specificSurface().innerRadius()
896 << (**fl).specificSurface().outerRadius();
901 edm::LogWarning(
"FastTracking") <<
"FAILED to find a corresponding DetLayer!";
908 for (
auto nl=negForwardLayers.begin();
909 nl != negForwardLayers.end(); ++nl) {
912 if ( fabs( (**nl).surface().position().z() +
theLayerMap[
i]-> surface().position().z()) < zTolerance) {
932 std::map<unsigned,std::map<double,PSimHit> >::const_iterator itrack =
thePSimHits.begin();
933 std::map<unsigned,std::map<double,PSimHit> >::const_iterator itrackEnd =
thePSimHits.end();
934 for ( ; itrack != itrackEnd; ++itrack ) {
935 std::map<double,PSimHit>::const_iterator it = (itrack->second).
begin();
936 std::map<double,PSimHit>::const_iterator itEnd = (itrack->second).
end();
937 for( ; it!= itEnd; ++it) {
948 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
virtual const BoundSurface & surface() const =0
The surface of the GeometricSearchDet.
const DetLayer * detLayer(const TrackerLayer &layer, float zpos) const
Returns the DetLayer pointer corresponding to the FAMOS layer.
void initializeTrackerGeometry(const TrackerGeometry *geomTracker)
Initialize the full Tracker Geometry.
void propagateToCalorimeters(ParticlePropagator &PP, int fsimi, RandomEngineAndDistribution const *)
Propagate the particle through the calorimeters.
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
virtual float length() 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
unsigned int tidRing(const DetId &id) const
const FSimVertex & endVertex() const
end vertex
virtual ConstReferenceCountingPointer< TangentPlane > tangentPlane(const GlobalPoint &) const =0
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
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
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.
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.
uint32_t rawId() const
get the raw id
LocalVector localMomentum() const
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.
math::XYZVector XYZVector
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
int closestDaughterId() const
Get the index of the closest charged daughter.
double Z() const
z of vertex
void setPropagationConditions(const TrackerLayer &, bool firstLoop=true)
DetId geographicalId() const
The label of this GeomDet.
void save()
Save nuclear interaction information.
CLHEP::HepRandomEngine & theEngine() const
const FSimVertex & vertex() const
Origin vertex.
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.
bool accept(const RawParticle &p) const
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
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.
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.
void setMomentum(const math::XYZTLorentzVector &newMomentum)
Reset the momentum (to be used with care)
virtual float width() const =0
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)