52 mySimEvent(aSimEvent),
55 theMaterialEffects(0),
58 theGeomSearchTracker(0),
60 theNegLayerOffset(27),
75 std::cout <<
"No valid decayer has been selected! No decay performed..." << std::endl;
159 std::list<TrackerLayer>::const_iterator cyliter;
185 PP.setPropagationConditions(*cyliter);
186 if ( PP.inside() && !PP.onSurface() )
break;
198 double ppcos2T = PP.cos2Theta();
199 double ppcos2V = PP.cos2ThetaV();
202 if ( ( ppcos2T > 0.99 && ppcos2T < 0.9998 ) && ( cyl == 0 || ( ppcos2V > 0.99 && ppcos2V < 0.9998 ) ) ){
208 }
else if ( ppcos2T > 0.9998 && ( cyl == 0 || ppcos2V > 0.9998 ) ) {
213 if ( ppcos2T > 0.9998 && ( cyl == 0 || ppcos2V > 0.9998 ) ) {
224 if ( cyliter->surface().mediumProperties().radLen() < 1E-10 ) {
232 bool escapeBarrel = PP.getSuccess() == -1;
233 bool escapeEndcap = (PP.getSuccess() == -2 && success == 1);
235 bool fullPropagation =
236 (PP.getSuccess() <= 0 && success==0) || escapeEndcap;
238 if ( escapeBarrel ) {
241 sign=1; ++cyliter; ++cyl;
245 --cyliter; --cyl; fullPropagation=
true;
251 PP.setPropagationConditions(*cyliter,!fullPropagation);
252 if ( escapeEndcap ) PP.increaseRCyl(0.0005);
255 success = PP.getSuccess();
259 if ( !PP.propagateToBoundSurface(*cyliter) ||
260 PP.getSuccess()<=0) {
278 if( PP.getSuccess() > 0 && PP.onFiducial() ) {
283 cyliter->sensitive() &&
291 saveHit &= PP.E()>1E-6;
295 if ( cyliter->sensitive() ) {
336 if (sign==1) {++cyliter;++cyl;}
337 else {--cyliter;--cyl;}
345 PP.propagateToEcal();
349 if(PP.getSuccess()==0) {
350 --cyliter; --cyl; sign = -sign;
351 PP.setPropagationConditions(*cyliter);
352 PP.propagateToBoundSurface(*cyliter);
355 if(PP.getSuccess()<0) {++cyliter; ++cyl;}
360 if ( PP.hasDecayed() )
439 std::list<TrackerLayer>::const_iterator cyliter;
448 if ( layer != cyliter->layerNumber() )
continue;
481 double magBefore =
std::sqrt(momentumBefore.Vect().mag2());
482 double magAfter =
std::sqrt(momentumAfter.Vect().mag2());
484 XYZVector axis = momentumBefore.Vect().Cross(momentumAfter.Vect());
485 double angle = std::acos(momentumBefore.Vect().Dot(momentumAfter.Vect())/(magAfter*magBefore));
488 double rescale = magAfter/magBefore;
503 if ( daughters.size() ) {
504 double distMin = 1E99;
505 int theClosestChargedDaughterId = -1;
511 if ( ivertex != -1 ) {
512 for ( ; daughter != daughters.end(); ++daughter) {
515 if ( PP.
charge() * daughter->charge() > 1E-10 ) {
516 double dist = (daughter->Vect().Unit().Cross(PP.Vect().Unit())).R();
517 if ( dist <
distCut && dist < distMin ) {
519 theClosestChargedDaughterId = theDaughterId;
525 if ( theClosestChargedDaughterId >=0 )
542 XYZVector newMomentum (r * daughMomentum.Vect());
543 newMomentum *= rescale;
544 double newEnergy =
std::sqrt(newMomentum.mag2() + daughMomentum.mag2());
556 std::map<double,PSimHit>& theHitMap,
581 std::vector<DetWithState> compat
585 std::map<double,PSimHit> theTrackHits;
586 for (std::vector<DetWithState>::const_iterator
i=compat.begin();
i!=compat.end();
i++) {
589 makePSimHits(
i->first,
i->second, theHitMap, trackID, eloss, thickness, partID,tTopo);
609 std::map<double,PSimHit>& theHitMap,
610 int tkID,
float el,
float thick,
int pID,
616 for (std::vector< const GeomDet*>::const_iterator
i = comp.begin();
617 i != comp.end();
i++) {
620 theHitMap.insert(theHitMap.end(),
makeSinglePSimHit( *du, ts, tkID, el, thick, pID,tTopo));
626 theHitMap.insert(theHitMap.end(),
makeSinglePSimHit( *du, ts, tkID, el, thick, pID,tTopo));
631 std::pair<double,PSimHit>
634 int tkID,
float el,
float thick,
int pID,
638 const float onSurfaceTolarance = 0.01;
651 std::pair<bool,double>
path = crossing.pathLength(det.
surface());
654 return std::pair<double,PSimHit>(0.,
PSimHit());
663 float halfThick = 0.5*theDetPlane.bounds().thickness();
670 eloss *= (2.* halfThick - 0.003) / (9.36 * thick);
681 int localTkID = tkID;
692 unsigned subdet =
DetId(
hit.detUnitId()).subdetId();
693 double boundX = theDetPlane.bounds().width()/2.;
694 double boundY = theDetPlane.bounds().length()/2.;
697 if ( subdet == 4 || subdet == 6 )
698 boundX *= 1. -
hit.localPosition().
y()/theDetPlane.position().perp();
703 unsigned theLayer = 0;
704 unsigned theRing = 0;
710 std::cout <<
"\tPixel Barrel Layer " << theLayer << std::endl;
717 theLayer = tTopo->
pxfDisk(detid);
718 std::cout <<
"\tPixel Forward Disk " << theLayer << std::endl;
726 std::cout <<
"\tTIB Layer " << theLayer << std::endl;
734 theRing = tTopo->
tidRing(detid);
735 unsigned int theSide =
module.side();
737 std::cout <<
"\tTID Petal Back " << std::endl;
739 std::cout <<
"\tTID Petal Front" << std::endl;
740 std::cout <<
"\tTID Layer " << theLayer << std::endl;
741 std::cout <<
"\tTID Ring " << theRing << std::endl;
750 std::cout <<
"\tTOB Layer " << theLayer << std::endl;
757 theRing = tTopo->
tecRing(detid);
758 unsigned int theSide =
module.petal()[0];
760 std::cout <<
"\tTEC Petal Back " << std::endl;
762 std::cout <<
"\tTEC Petal Front" << std::endl;
763 std::cout <<
"\tTEC Layer " << theLayer << std::endl;
764 std::cout <<
"\tTEC Ring " << theRing << std::endl;
775 std::cout <<
"Thickness = " << 2.*halfThick-0.003 <<
"; " << thick * 9.36 << std::endl
780 <<
hit.localPosition().
x() <<
" "
781 <<
hit.localPosition().
y() <<
" "
782 <<
hit.localPosition().
z() << std::endl;
795 dist = ( fabs(
hit.localPosition().
x()) > boundX ||
796 fabs(
hit.localPosition().
y()) > boundY ) ?
815 return std::pair<double,PSimHit>(dist,
hit);
834 std::vector< BarrelDetLayer*> barrelLayers =
836 LogDebug(
"FastTracking") <<
"Barrel DetLayer dump: ";
837 for (std::vector< BarrelDetLayer*>::const_iterator bl=barrelLayers.begin();
838 bl != barrelLayers.end(); ++bl) {
839 LogDebug(
"FastTracking")<<
"radius " << (**bl).specificSurface().radius();
842 std::vector< ForwardDetLayer*> posForwardLayers =
844 LogDebug(
"FastTracking") <<
"Positive Forward DetLayer dump: ";
845 for (std::vector< ForwardDetLayer*>::const_iterator fl=posForwardLayers.begin();
846 fl != posForwardLayers.end(); ++fl) {
847 LogDebug(
"FastTracking") <<
"Z pos "
848 << (**fl).surface().position().z()
850 << (**fl).specificSurface().innerRadius()
852 << (**fl).specificSurface().outerRadius();
855 const float rTolerance = 1.5;
856 const float zTolerance = 3.;
858 LogDebug(
"FastTracking")<<
"Dump of TrackerInteractionGeometry cylinders:";
864 LogDebug(
"FastTracking") <<
"Famos Layer no " <<
i->layerNumber()
865 <<
" is sensitive? " <<
i->sensitive()
866 <<
" pos " <<
i->surface().position();
867 if (!
i->sensitive())
continue;
870 LogDebug(
"FastTracking") <<
" cylinder radius " << cyl->radius();
872 for (std::vector< BarrelDetLayer*>::const_iterator
873 bl=barrelLayers.begin(); bl != barrelLayers.end(); ++bl) {
875 if (fabs( cyl->radius() - (**bl).specificSurface().radius()) < rTolerance) {
878 LogDebug(
"FastTracking")<<
"Corresponding DetLayer found with radius "
879 << (**bl).specificSurface().radius();
884 edm::LogWarning(
"FastTracking") <<
" Trajectory manager FAILED to find a corresponding DetLayer!";
888 LogDebug(
"FastTracking") <<
" disk radii " << disk->innerRadius()
889 <<
", " << disk->outerRadius();
891 for (std::vector< ForwardDetLayer*>::const_iterator fl=posForwardLayers.begin();
892 fl != posForwardLayers.end(); ++fl) {
894 if (fabs( disk->position().z() - (**fl).surface().position().z()) < zTolerance) {
897 LogDebug(
"FastTracking") <<
"Corresponding DetLayer found with Z pos "
898 << (**fl).surface().position().z()
900 << (**fl).specificSurface().innerRadius()
902 << (**fl).specificSurface().outerRadius();
907 edm::LogWarning(
"FastTracking") <<
"FAILED to find a corresponding DetLayer!";
914 for (std::vector< ForwardDetLayer*>::const_iterator nl=negForwardLayers.begin();
915 nl != negForwardLayers.end(); ++nl) {
918 if ( fabs( (**nl).surface().position().z() +
theLayerMap[
i]-> surface().position().z()) < zTolerance) {
938 std::map<unsigned,std::map<double,PSimHit> >::const_iterator itrack =
thePSimHits.begin();
939 std::map<unsigned,std::map<double,PSimHit> >::const_iterator itrackEnd =
thePSimHits.end();
940 for ( ; itrack != itrackEnd; ++itrack ) {
941 std::map<double,PSimHit>::const_iterator it = (itrack->second).
begin();
942 std::map<double,PSimHit>::const_iterator itEnd = (itrack->second).
end();
943 for( ; it!= itEnd; ++it) {
954 if ( it->first > 0. ) c.push_back(it->second);
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.
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
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.
uint32_t rawId() const
get the raw id
LocalVector localMomentum() const
std::vector< BarrelDetLayer * > const & barrelLayers() const
void reconstruct(const TrackerTopology *tTopo)
Does the real job.
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 RandomEngine * random
const TrackerInteractionGeometry * _theGeometry
const math::XYZTLorentzVector & position() const
Temporary (until CMSSW moves to Mathcore) - No ! Actually very useful.
MaterialEffects * theMaterialEffects
const DaughterParticleList & particleDaughtersPy8(ParticlePropagator &particle)
void updateWithDaughters(ParticlePropagator &PP, int fsimi)
Decay the particle and update the SimEvent with daughters.
const DaughterParticleList & particleDaughtersPy6(ParticlePropagator &particle)
std::pair< std::string, MonitorElement * > entry
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.
const FSimVertex & vertex() const
Origin vertex.
std::vector< ForwardDetLayer * > const & negForwardLayers() const
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.
void propagateToCalorimeters(ParticlePropagator &PP, int fsimi)
Propagate the particle through the calorimeters.
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.
Vector3DBase unit() const
virtual ReferenceCountingPointer< TangentPlane > tangentPlane(const GlobalPoint &) const =0
std::vector< ForwardDetLayer * > const & posForwardLayers() 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 interact(FSimEvent &simEvent, const TrackerLayer &layer, ParticlePropagator &PP, unsigned i)
void setTkMomentum(const math::XYZTLorentzVectorD &mom)
void setVFcal(const RawParticle &pp, int success)
Set the hcal variables.
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
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 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< 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)