Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:26:54

0001 #ifndef TRAJECTORYMANAGER_H
0002 #define TRAJECTORYMANAGER_H
0003 
0004 //DataFormats
0005 #include "SimDataFormats/TrackingHit/interface/PSimHit.h"
0006 #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
0007 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
0008 
0009 //FAMOS Headers
0010 #include "FastSimulation/MaterialEffects/interface/MaterialEffects.h"
0011 
0012 #include "Math/GenVector/AxisAngle.h"
0013 
0014 /**
0015  * This class takes all the particles of a FSimEvent with no end vertex, 
0016  * and propagate them from their parent vertex through the tracker 
0017  * material layers, inside which Material Effects are simulated. The
0018  * propagation is stopped when one of the following configurations is
0019  * is met:
0020  *
0021  *   - the particle has reached the ECAL (possibly after several loops)
0022  *   - the particle does no longer pass the KineParticleFilter 
0023  *   - the propagation lasted for more than 100 loops 
0024  *   - the particle reached an end vertex (e.g., photon conversion)
0025  *
0026  * The FSimEvent is updated after each interaction, and the propagation 
0027  * continues with the updated or the newly created particles. The process
0028  * ends when there is no new particles to propagate.
0029  *
0030  * Charged particles now leave PSimHit's, for later RecHit production 
0031  * with smearing, in a separate producer.
0032  *
0033  * \author: Florian Beaudette, Patrick Janot
0034  * $Date Last modification - 12-Oct-2006 
0035  */
0036 
0037 #include <vector>
0038 #include <map>
0039 
0040 class PythiaDecays;
0041 class TrackerInteractionGeometry;
0042 class TrackerLayer;
0043 class ParticlePropagator;
0044 class FSimEvent;
0045 //class Histos;
0046 class RandomEngineAndDistribution;
0047 class TrajectoryStateOnSurface;
0048 class DetLayer;
0049 class MagneticField;
0050 class MagneticFieldMap;
0051 class GeometricSearchTracker;
0052 class TrackerGeometry;
0053 class TrackerTopology;
0054 
0055 namespace edm {
0056   class ParameterSet;
0057 }
0058 
0059 class TrajectoryManager
0060 
0061 {
0062 public:
0063   typedef ROOT::Math::AxisAngle Rotation;
0064 
0065   /// Default Constructor
0066   TrajectoryManager() { ; }
0067 
0068   /// Constructor from a FSimEvent
0069   TrajectoryManager(FSimEvent* aSimEvent,
0070                     const edm::ParameterSet& matEff,
0071                     const edm::ParameterSet& simHits,
0072                     const edm::ParameterSet& decays);
0073 
0074   /// Default Destructor
0075   ~TrajectoryManager();
0076 
0077   /// Does the real job
0078   void reconstruct(const TrackerTopology* tTopo, RandomEngineAndDistribution const*);
0079 
0080   /// Create a vector of PSimHits
0081   void createPSimHits(const TrackerLayer& layer,
0082                       const ParticlePropagator& P_before,
0083                       std::map<double, PSimHit>& theHitMap,
0084                       int trackID,
0085                       int partID,
0086                       const TrackerTopology* tTopo);
0087 
0088   /// Propagate the particle through the calorimeters
0089   void propagateToCalorimeters(ParticlePropagator& PP, int fsimi, RandomEngineAndDistribution const*);
0090 
0091   /// Propagate a particle to a given tracker layer
0092   /// (for electron pixel matching mostly)
0093   bool propagateToLayer(ParticlePropagator& PP, unsigned layer);
0094 
0095   /// Returns the pointer to geometry
0096   const TrackerInteractionGeometry* theGeometry();
0097 
0098   /// Initialize the Reconstruction Geometry
0099   void initializeRecoGeometry(const GeometricSearchTracker* geomSearchTracker,
0100                               const TrackerInteractionGeometry* interactionGeometry,
0101                               const MagneticFieldMap* aFieldMap);
0102 
0103   /// Initialize the full Tracker Geometry
0104   void initializeTrackerGeometry(const TrackerGeometry* geomTracker);
0105 
0106   // load container from edm::Event
0107   void loadSimHits(edm::PSimHitContainer& c) const;
0108 
0109 private:
0110   /// Decay the particle and update the SimEvent with daughters
0111   void updateWithDaughters(ParticlePropagator& PP, int fsimi, RandomEngineAndDistribution const*);
0112 
0113   /// Move, rescale and rotate all daughters after propagation, material effects and decay of the mother.
0114   void moveAllDaughters(int fsimi, const Rotation& r, double rescale);
0115 
0116   /// Initialize correspondence map between Famos interaction geometry and tracker reco geometry
0117   void initializeLayerMap();
0118 
0119   /// Teddy, you must put comments there
0120   TrajectoryStateOnSurface makeTrajectoryState(const DetLayer* layer,
0121                                                const ParticlePropagator& pp,
0122                                                const MagneticField* field) const;
0123 
0124   /// and there
0125   void makePSimHits(const GeomDet* det,
0126                     const TrajectoryStateOnSurface& ts,
0127                     std::map<double, PSimHit>& theHitMap,
0128                     int tkID,
0129                     float el,
0130                     float thick,
0131                     int pID,
0132                     const TrackerTopology* tTopo);
0133   /// and there
0134   std::pair<double, PSimHit> makeSinglePSimHit(const GeomDetUnit& det,
0135                                                const TrajectoryStateOnSurface& ts,
0136                                                int tkID,
0137                                                float el,
0138                                                float thick,
0139                                                int pID,
0140                                                const TrackerTopology* tTopo) const;
0141 
0142   /// Returns the DetLayer pointer corresponding to the FAMOS layer
0143   const DetLayer* detLayer(const TrackerLayer& layer, float zpos) const;
0144 
0145 private:
0146   FSimEvent* mySimEvent;
0147 
0148   const TrackerInteractionGeometry* _theGeometry;
0149   const MagneticFieldMap* _theFieldMap;
0150 
0151   MaterialEffects* theMaterialEffects;
0152 
0153   PythiaDecays* myDecayEngine;
0154   std::string decayer;
0155   double distCut;
0156 
0157   double pTmin;
0158   bool firstLoop;
0159   std::map<unsigned, std::map<double, PSimHit> > thePSimHits;
0160 
0161   const TrackerGeometry* theGeomTracker;
0162   const GeometricSearchTracker* theGeomSearchTracker;
0163   std::vector<const DetLayer*> theLayerMap;
0164   int theNegLayerOffset;
0165 
0166   //  Histos* myHistos;
0167 
0168   bool use_hardcoded;
0169 };
0170 #endif