56 mySimEvent(aSimEvent),
59 theMaterialEffects(0),
62 theGeomSearchTracker(0),
64 theNegLayerOffset(27),
160 std::list<TrackerLayer>::const_iterator cyliter;
187 PP.setPropagationConditions(*cyliter);
188 if ( PP.inside() && !PP.onSurface() )
break;
200 double ppcos2T = PP.cos2Theta();
201 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 ) ) {
218 if ( cyliter->surface().mediumProperties()->radLen() < 1E-10 ) {
226 bool escapeBarrel = PP.getSuccess() == -1;
227 bool escapeEndcap = (PP.getSuccess() == -2 && success == 1);
229 bool fullPropagation =
230 (PP.getSuccess() <= 0 && success==0) || escapeEndcap;
232 if ( escapeBarrel ) {
235 sign=1; ++cyliter; ++cyl;
239 --cyliter; --cyl; fullPropagation=
true;
245 PP.setPropagationConditions(*cyliter,!fullPropagation);
246 if ( escapeEndcap ) PP.increaseRCyl(0.0005);
249 success = PP.getSuccess();
253 if ( !PP.propagateToBoundSurface(*cyliter) ||
254 PP.getSuccess()<=0) {
272 if( PP.getSuccess() > 0 && PP.onFiducial() ) {
277 cyliter->sensitive() &&
285 saveHit &= PP.E()>1E-6;
290 if ( cyliter->sensitive() ) {
323 if (sign==1) {++cyliter;++cyl;}
324 else {--cyliter;--cyl;}
332 PP.propagateToEcal();
336 if(PP.getSuccess()==0) {
337 --cyliter; --cyl; sign = -sign;
338 PP.setPropagationConditions(*cyliter);
339 PP.propagateToBoundSurface(*cyliter);
342 if(PP.getSuccess()<0) {++cyliter; ++cyl;}
347 if ( PP.hasDecayed() )
426 std::list<TrackerLayer>::const_iterator cyliter;
435 if ( layer != cyliter->layerNumber() )
continue;
469 double magBefore =
std::sqrt(momentumBefore.Vect().mag2());
470 double magAfter =
std::sqrt(momentumAfter.Vect().mag2());
472 XYZVector axis = momentumBefore.Vect().Cross(momentumAfter.Vect());
473 double angle = std::acos(momentumBefore.Vect().Dot(momentumAfter.Vect())/(magAfter*magBefore));
476 double rescale = magAfter/magBefore;
491 if ( daughters.size() ) {
492 double distMin = 1E99;
493 int theClosestChargedDaughterId = -1;
499 if ( ivertex != -1 ) {
500 for ( ; daughter != daughters.end(); ++daughter) {
503 if ( PP.
charge() * daughter->charge() > 1E-10 ) {
504 double dist = (daughter->Vect().Unit().Cross(PP.Vect().Unit())).R();
505 if ( dist <
distCut && dist < distMin ) {
507 theClosestChargedDaughterId = theDaughterId;
513 if ( theClosestChargedDaughterId >=0 )
530 XYZVector newMomentum (r * daughMomentum.Vect());
531 newMomentum *= rescale;
532 double newEnergy =
std::sqrt(newMomentum.mag2() + daughMomentum.mag2());
544 std::map<double,PSimHit>& theHitMap,
545 int trackID,
int partID) {
565 std::vector<DetWithState> compat
569 std::map<double,PSimHit> theTrackHits;
570 for (std::vector<DetWithState>::const_iterator
i=compat.begin();
i!=compat.end();
i++) {
573 makePSimHits(
i->first,
i->second, theHitMap, trackID, eloss, thickness, partID);
592 std::map<double,PSimHit>& theHitMap,
593 int tkID,
float el,
float thick,
int pID )
596 std::vector< const GeomDet*> comp = det->
components();
598 for (std::vector< const GeomDet*>::const_iterator
i = comp.begin();
599 i != comp.end();
i++) {
602 theHitMap.insert(theHitMap.end(),
makeSinglePSimHit( *du, ts, tkID, el, thick, pID));
608 theHitMap.insert(theHitMap.end(),
makeSinglePSimHit( *du, ts, tkID, el, thick, pID));
614 std::pair<double,PSimHit>
617 int tkID,
float el,
float thick,
int pID)
const
620 const float onSurfaceTolarance = 0.01;
633 std::pair<bool,double>
path = crossing.pathLength(det.
surface());
636 return std::pair<double,PSimHit>(0.,
PSimHit());
652 eloss *= (2.* halfThick - 0.003) / (9.36 * thick);
663 int localTkID = tkID;
674 unsigned subdet =
DetId(
hit.detUnitId()).subdetId();
679 if ( subdet == 4 || subdet == 6 )
685 unsigned theLayer = 0;
686 unsigned theRing = 0;
691 theLayer = module.
layer();
692 std::cout <<
"\tPixel Barrel Layer " << theLayer << std::endl;
699 theLayer = module.
disk();
700 std::cout <<
"\tPixel Forward Disk " << theLayer << std::endl;
707 theLayer = module.
layer();
708 std::cout <<
"\tTIB Layer " << theLayer << std::endl;
715 theLayer = module.
wheel();
716 theRing = module.
ring();
717 unsigned int theSide = module.
side();
719 std::cout <<
"\tTID Petal Back " << std::endl;
721 std::cout <<
"\tTID Petal Front" << std::endl;
722 std::cout <<
"\tTID Layer " << theLayer << std::endl;
723 std::cout <<
"\tTID Ring " << theRing << std::endl;
730 theLayer = module.
layer();
732 std::cout <<
"\tTOB Layer " << theLayer << std::endl;
738 theLayer = module.
wheel();
739 theRing = module.
ring();
740 unsigned int theSide = module.
petal()[0];
742 std::cout <<
"\tTEC Petal Back " << std::endl;
744 std::cout <<
"\tTEC Petal Front" << std::endl;
745 std::cout <<
"\tTEC Layer " << theLayer << std::endl;
746 std::cout <<
"\tTEC Ring " << theRing << std::endl;
757 std::cout <<
"Thickness = " << 2.*halfThick-0.003 <<
"; " << thick * 9.36 << std::endl
762 <<
hit.localPosition().
x() <<
" "
763 <<
hit.localPosition().
y() <<
" "
764 <<
hit.localPosition().
z() << std::endl;
777 dist = ( fabs(
hit.localPosition().
x()) > boundX ||
778 fabs(
hit.localPosition().
y()) > boundY ) ?
795 return std::pair<double,PSimHit>(dist,
hit);
814 std::vector< BarrelDetLayer*> barrelLayers =
816 LogDebug(
"FastTracking") <<
"Barrel DetLayer dump: ";
817 for (std::vector< BarrelDetLayer*>::const_iterator bl=barrelLayers.begin();
818 bl != barrelLayers.end(); ++bl) {
819 LogDebug(
"FastTracking")<<
"radius " << (**bl).specificSurface().radius();
822 std::vector< ForwardDetLayer*> posForwardLayers =
824 LogDebug(
"FastTracking") <<
"Positive Forward DetLayer dump: ";
825 for (std::vector< ForwardDetLayer*>::const_iterator fl=posForwardLayers.begin();
826 fl != posForwardLayers.end(); ++fl) {
827 LogDebug(
"FastTracking") <<
"Z pos "
828 << (**fl).surface().position().z()
830 << (**fl).specificSurface().innerRadius()
832 << (**fl).specificSurface().outerRadius();
835 const float rTolerance = 1.5;
836 const float zTolerance = 3.;
838 LogDebug(
"FastTracking")<<
"Dump of TrackerInteractionGeometry cylinders:";
844 LogDebug(
"FastTracking") <<
"Famos Layer no " <<
i->layerNumber()
845 <<
" is sensitive? " <<
i->sensitive()
846 <<
" pos " <<
i->surface().position();
847 if (!
i->sensitive())
continue;
852 for (std::vector< BarrelDetLayer*>::const_iterator
853 bl=barrelLayers.begin(); bl != barrelLayers.end(); ++bl) {
854 if (fabs( cyl->
radius() - (**bl).specificSurface().radius()) < rTolerance) {
857 LogDebug(
"FastTracking")<<
"Corresponding DetLayer found with radius "
858 << (**bl).specificSurface().radius();
863 edm::LogWarning(
"FastTracking") <<
" Trajectory manager FAILED to find a corresponding DetLayer!";
870 for (std::vector< ForwardDetLayer*>::const_iterator fl=posForwardLayers.begin();
871 fl != posForwardLayers.end(); ++fl) {
872 if (fabs( disk->
position().
z() - (**fl).surface().position().z()) < zTolerance) {
875 LogDebug(
"FastTracking") <<
"Corresponding DetLayer found with Z pos "
876 << (**fl).surface().position().z()
878 << (**fl).specificSurface().innerRadius()
880 << (**fl).specificSurface().outerRadius();
885 edm::LogWarning(
"FastTracking") <<
"FAILED to find a corresponding DetLayer!";
892 for (std::vector< ForwardDetLayer*>::const_iterator nl=negForwardLayers.begin();
893 nl != negForwardLayers.end(); ++nl) {
896 if ( fabs( (**nl).surface().position().z() +
theLayerMap[
i]-> surface().position().z()) < zTolerance) {
916 std::map<unsigned,std::map<double,PSimHit> >::const_iterator itrack =
thePSimHits.begin();
917 std::map<unsigned,std::map<double,PSimHit> >::const_iterator itrackEnd =
thePSimHits.end();
918 for ( ; itrack != itrackEnd; ++itrack ) {
919 std::map<double,PSimHit>::const_iterator it = (itrack->second).
begin();
920 std::map<double,PSimHit>::const_iterator itEnd = (itrack->second).
end();
921 for( ; it!= itEnd; ++it) {
932 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.
void makePSimHits(const GeomDet *det, const TrajectoryStateOnSurface &ts, std::map< double, PSimHit > &theHitMap, int tkID, float el, float thick, int pID)
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)
unsigned int layer() const
layer id
const FSimVertex & endVertex() const
end vertex
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.
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.
void createPSimHits(const TrackerLayer &layer, const ParticlePropagator &P_before, std::map< double, PSimHit > &theHitMap, int trackID, int partID)
Create a vector of PSimHits.
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.
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
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
unsigned int layer() const
layer id
FSimVertex & vertex(int id) const
Return vertex with given Id.
uint32_t rawId() const
get the raw id
LocalVector localMomentum() const
virtual float thickness() const =0
std::vector< BarrelDetLayer * > const & barrelLayers() const
bool propagateToVFcalEntrance(bool first=true)
std::vector< unsigned int > petal() const
petal id
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
Scalar radius() const
Radius of the cylinder.
const TrackerInteractionGeometry * _theGeometry
const DaughterParticleList & particleDaughters(ParticlePropagator &particle)
const math::XYZTLorentzVector & position() const
Temporary (until CMSSW moves to Mathcore) - No ! Actually very useful.
MaterialEffects * theMaterialEffects
std::vector< RawParticle > DaughterParticleList
void updateWithDaughters(ParticlePropagator &PP, int fsimi)
Decay the particle and update the SimEvent with daughters.
std::pair< std::string, MonitorElement * > entry
double Y() const
y of vertex
void reconstruct()
Does the real job.
unsigned int ring() const
ring id
int closestDaughterId() const
Get the index of the closest charged daughter.
double Z() const
z of vertex
void setPropagationConditions(const TrackerLayer &, bool firstLoop=true)
std::pair< double, PSimHit > makeSinglePSimHit(const GeomDetUnit &det, const TrajectoryStateOnSurface &ts, int tkID, float el, float thick, int pID) const
and there
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.
unsigned int disk() const
disk id
DaughterParticleList::const_iterator DaughterParticleIterator
bool propagateToEcalEntrance(bool first=true)
unsigned int nTracks() const
Number of tracks.
std::map< unsigned, std::map< double, PSimHit > > thePSimHits
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
const Bounds & bounds() 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
unsigned int side() const
positive or negative id
std::list< TrackerLayer >::const_iterator cylinderBegin() const
Returns the first pointer in the cylinder list.
void setTkPosition(const math::XYZVectorD &pos)
unsigned int wheel() const
wheel id
const TrackerInteractionGeometry * theGeometry()
Returns the pointer to geometry.
double X() const
x of vertex
unsigned int layer() const
layer id
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 BoundPlane & surface() const
The nominal surface of the GeomDet.
const KineParticleFilter & filter() const
int id() const
the index in FBaseSimEvent and other vectors
unsigned int ring() const
ring id
void interact(FSimEvent &simEvent, const TrackerLayer &layer, ParticlePropagator &PP, unsigned i)
float outerRadius() const
The outer radius of the disk.
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)
float innerRadius() const
The inner radius of the disk.
Pythia6Decays * myDecayEngine
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
const PositionType & position() const
bool propagateToPreshowerLayer2(bool first=true)
const FSimTrack & mother() const
mother
Global3DVector GlobalVector
math::XYZTLorentzVector XYZTLorentzVector
unsigned int wheel() const
wheel id
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)