50 mySimEvent(aSimEvent),
53 theMaterialEffects(0),
56 theGeomSearchTracker(0),
58 theNegLayerOffset(27),
72 std::cout <<
"No valid decayer has been selected! No decay performed..." << std::endl;
156 std::list<TrackerLayer>::const_iterator cyliter;
182 PP.setPropagationConditions(*cyliter);
183 if ( PP.inside() && !PP.onSurface() )
break;
195 double ppcos2T = PP.cos2Theta();
196 double ppcos2V = PP.cos2ThetaV();
199 if ( ( ppcos2T > 0.99 && ppcos2T < 0.9998 ) && ( cyl == 0 || ( ppcos2V > 0.99 && ppcos2V < 0.9998 ) ) ){
205 }
else if ( ppcos2T > 0.9998 && ( cyl == 0 || ppcos2V > 0.9998 ) ) {
210 if ( ppcos2T > 0.9998 && ( cyl == 0 || ppcos2V > 0.9998 ) ) {
221 if ( cyliter->surface().mediumProperties().radLen() < 1E-10 ) {
229 bool escapeBarrel = PP.getSuccess() == -1;
230 bool escapeEndcap = (PP.getSuccess() == -2 && success == 1);
232 bool fullPropagation =
233 (PP.getSuccess() <= 0 && success==0) || escapeEndcap;
235 if ( escapeBarrel ) {
238 sign=1; ++cyliter; ++cyl;
242 --cyliter; --cyl; fullPropagation=
true;
248 PP.setPropagationConditions(*cyliter,!fullPropagation);
249 if ( escapeEndcap ) PP.increaseRCyl(0.0005);
252 success = PP.getSuccess();
256 if ( !PP.propagateToBoundSurface(*cyliter) ||
257 PP.getSuccess()<=0) {
275 if( PP.getSuccess() > 0 && PP.onFiducial() ) {
280 cyliter->sensitive() &&
288 saveHit &= PP.E()>1E-6;
292 if ( cyliter->sensitive() ) {
333 if (sign==1) {++cyliter;++cyl;}
334 else {--cyliter;--cyl;}
342 PP.propagateToEcal();
346 if(PP.getSuccess()==0) {
347 --cyliter; --cyl; sign = -sign;
348 PP.setPropagationConditions(*cyliter);
349 PP.propagateToBoundSurface(*cyliter);
352 if(PP.getSuccess()<0) {++cyliter; ++cyl;}
357 if ( PP.hasDecayed() )
436 std::list<TrackerLayer>::const_iterator cyliter;
445 if ( layer != cyliter->layerNumber() )
continue;
478 double magBefore =
std::sqrt(momentumBefore.Vect().mag2());
479 double magAfter =
std::sqrt(momentumAfter.Vect().mag2());
481 XYZVector axis = momentumBefore.Vect().Cross(momentumAfter.Vect());
482 double angle = std::acos(momentumBefore.Vect().Dot(momentumAfter.Vect())/(magAfter*magBefore));
485 double rescale = magAfter/magBefore;
501 if ( daughters.size() ) {
502 double distMin = 1E99;
503 int theClosestChargedDaughterId = -1;
509 if ( ivertex != -1 ) {
510 for ( ; daughter != daughters.end(); ++daughter) {
513 if ( PP.
charge() * daughter->charge() > 1E-10 ) {
514 double dist = (daughter->Vect().Unit().Cross(PP.Vect().Unit())).R();
515 if ( dist <
distCut && dist < distMin ) {
517 theClosestChargedDaughterId = theDaughterId;
523 if ( theClosestChargedDaughterId >=0 )
540 XYZVector newMomentum (r * daughMomentum.Vect());
541 newMomentum *= rescale;
542 double newEnergy =
std::sqrt(newMomentum.mag2() + daughMomentum.mag2());
554 std::map<double,PSimHit>& theHitMap,
579 std::vector<DetWithState> compat
583 std::map<double,PSimHit> theTrackHits;
584 for (std::vector<DetWithState>::const_iterator
i=compat.begin();
i!=compat.end();
i++) {
587 makePSimHits(
i->first,
i->second, theHitMap, trackID, eloss, thickness, partID,tTopo);
607 std::map<double,PSimHit>& theHitMap,
608 int tkID,
float el,
float thick,
int pID,
614 for (std::vector< const GeomDet*>::const_iterator
i = comp.begin();
615 i != comp.end();
i++) {
618 theHitMap.insert(theHitMap.end(),
makeSinglePSimHit( *du, ts, tkID, el, thick, pID,tTopo));
624 theHitMap.insert(theHitMap.end(),
makeSinglePSimHit( *du, ts, tkID, el, thick, pID,tTopo));
629 std::pair<double,PSimHit>
632 int tkID,
float el,
float thick,
int pID,
636 const float onSurfaceTolarance = 0.01;
649 std::pair<bool,double>
path = crossing.pathLength(det.
surface());
652 return std::pair<double,PSimHit>(0.,
PSimHit());
661 float halfThick = 0.5*theDetPlane.bounds().thickness();
668 eloss *= (2.* halfThick - 0.003) / (9.36 * thick);
672 LocalPoint entry = lpos + (-halfThick/pZ) * lmom;
679 int localTkID = tkID;
690 unsigned subdet =
DetId(
hit.detUnitId()).subdetId();
691 double boundX = theDetPlane.bounds().width()/2.;
692 double boundY = theDetPlane.bounds().length()/2.;
695 if ( subdet == 4 || subdet == 6 )
696 boundX *= 1. -
hit.localPosition().
y()/theDetPlane.position().perp();
701 unsigned theLayer = 0;
702 unsigned theRing = 0;
708 std::cout <<
"\tPixel Barrel Layer " << theLayer << std::endl;
715 theLayer = tTopo->
pxfDisk(detid);
716 std::cout <<
"\tPixel Forward Disk " << theLayer << std::endl;
724 std::cout <<
"\tTIB Layer " << theLayer << std::endl;
732 theRing = tTopo->
tidRing(detid);
733 unsigned int theSide =
module.side();
735 std::cout <<
"\tTID Petal Back " << std::endl;
737 std::cout <<
"\tTID Petal Front" << std::endl;
738 std::cout <<
"\tTID Layer " << theLayer << std::endl;
739 std::cout <<
"\tTID Ring " << theRing << std::endl;
748 std::cout <<
"\tTOB Layer " << theLayer << std::endl;
755 theRing = tTopo->
tecRing(detid);
756 unsigned int theSide =
module.petal()[0];
758 std::cout <<
"\tTEC Petal Back " << std::endl;
760 std::cout <<
"\tTEC Petal Front" << std::endl;
761 std::cout <<
"\tTEC Layer " << theLayer << std::endl;
762 std::cout <<
"\tTEC Ring " << theRing << std::endl;
773 std::cout <<
"Thickness = " << 2.*halfThick-0.003 <<
"; " << thick * 9.36 << std::endl
778 <<
hit.localPosition().
x() <<
" "
779 <<
hit.localPosition().
y() <<
" "
780 <<
hit.localPosition().
z() << std::endl;
793 dist = ( fabs(
hit.localPosition().
x()) > boundX ||
794 fabs(
hit.localPosition().
y()) > boundY ) ?
813 return std::pair<double,PSimHit>(dist,
hit);
832 const std::vector< const BarrelDetLayer*>& barrelLayers =
834 LogDebug(
"FastTracking") <<
"Barrel DetLayer dump: ";
835 for (
auto bl=barrelLayers.begin();
836 bl != barrelLayers.end(); ++bl) {
837 LogDebug(
"FastTracking")<<
"radius " << (**bl).specificSurface().radius();
840 const std::vector< const ForwardDetLayer*>& posForwardLayers =
842 LogDebug(
"FastTracking") <<
"Positive Forward DetLayer dump: ";
843 for (
auto fl=posForwardLayers.begin();
844 fl != posForwardLayers.end(); ++fl) {
845 LogDebug(
"FastTracking") <<
"Z pos "
846 << (**fl).surface().position().z()
848 << (**fl).specificSurface().innerRadius()
850 << (**fl).specificSurface().outerRadius();
853 const float rTolerance = 1.5;
854 const float zTolerance = 3.;
856 LogDebug(
"FastTracking")<<
"Dump of TrackerInteractionGeometry cylinders:";
862 LogDebug(
"FastTracking") <<
"Famos Layer no " <<
i->layerNumber()
863 <<
" is sensitive? " <<
i->sensitive()
864 <<
" pos " <<
i->surface().position();
865 if (!
i->sensitive())
continue;
868 LogDebug(
"FastTracking") <<
" cylinder radius " << cyl->radius();
871 bl=barrelLayers.begin(); bl != barrelLayers.end(); ++bl) {
873 if (fabs( cyl->radius() - (**bl).specificSurface().radius()) < rTolerance) {
876 LogDebug(
"FastTracking")<<
"Corresponding DetLayer found with radius "
877 << (**bl).specificSurface().radius();
882 edm::LogWarning(
"FastTracking") <<
" Trajectory manager FAILED to find a corresponding DetLayer!";
886 LogDebug(
"FastTracking") <<
" disk radii " << disk->innerRadius()
887 <<
", " << disk->outerRadius();
889 for (
auto fl=posForwardLayers.begin();
890 fl != posForwardLayers.end(); ++fl) {
892 if (fabs( disk->position().z() - (**fl).surface().position().z()) < zTolerance) {
895 LogDebug(
"FastTracking") <<
"Corresponding DetLayer found with Z pos "
896 << (**fl).surface().position().z()
898 << (**fl).specificSurface().innerRadius()
900 << (**fl).specificSurface().outerRadius();
905 edm::LogWarning(
"FastTracking") <<
"FAILED to find a corresponding DetLayer!";
912 for (
auto nl=negForwardLayers.begin();
913 nl != negForwardLayers.end(); ++nl) {
916 if ( fabs( (**nl).surface().position().z() +
theLayerMap[
i]-> surface().position().z()) < zTolerance) {
936 std::map<unsigned,std::map<double,PSimHit> >::const_iterator itrack =
thePSimHits.begin();
937 std::map<unsigned,std::map<double,PSimHit> >::const_iterator itrackEnd =
thePSimHits.end();
938 for ( ; itrack != itrackEnd; ++itrack ) {
939 std::map<double,PSimHit>::const_iterator it = (itrack->second).
begin();
940 std::map<double,PSimHit>::const_iterator itEnd = (itrack->second).
end();
941 for( ; it!= itEnd; ++it) {
952 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
std::vector< ForwardDetLayer const * > const & posForwardLayers() const
const DaughterParticleList & particleDaughtersPy6(ParticlePropagator &particle, CLHEP::HepRandomEngine *)
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 ?
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.
const DaughterParticleList & particleDaughtersPy8(ParticlePropagator &particle, CLHEP::HepRandomEngine *)
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.
tuple path
else: Piece not in the list, fine.
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.
virtual std::vector< const GeomDet * > components() const =0
Returns direct components, if any.
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
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
virtual ReferenceCountingPointer< TangentPlane > tangentPlane(const GlobalPoint &) const =0
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
tuple AnalyticalPropagator
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)