CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/FastSimulation/TrackingRecHitProducer/interface/SiTrackerGaussianSmearingRecHitConverter.h

Go to the documentation of this file.
00001 #ifndef FastSimulation_TrackingRecHitProducer_SiTrackerGaussianSmearingRecHitConverter_h
00002 #define FastSimulation_TrackingRecHitProducer_SiTrackerGaussianSmearingRecHitConverter_h
00003 
00004 //---------------------------------------------------------------------------
00009 //---------------------------------------------------------------------------
00010 
00011 // Framework
00012 #include "FWCore/Framework/interface/EDProducer.h"
00013 #include "FWCore/Utilities/interface/InputTag.h"
00014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00015 
00016 // PSimHit
00017 #include "SimDataFormats/TrackingHit/interface/PSimHit.h"
00018 #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
00019 
00020 // Data Formats
00021 #include "SimDataFormats/CrossingFrame/interface/MixCollection.h"
00022 #include "FastSimDataFormats/External/interface/FastTrackerClusterCollection.h"
00023 #include "DataFormats/TrackerRecHit2D/interface/SiTrackerGSRecHit2DCollection.h"
00024 #include "DataFormats/TrackerRecHit2D/interface/SiTrackerGSMatchedRecHit2DCollection.h"
00025 #include "DataFormats/GeometryVector/interface/Point3DBase.h"
00026 #include "DataFormats/GeometrySurface/interface/LocalError.h"
00027 
00028 // STL
00029 #include <vector>
00030 #include <map>
00031 #include <string>
00032 
00033 class TFile;
00034 class TH1F;
00035 class TrackerGeometry;
00036 class SiPixelGaussianSmearingRecHitConverterAlgorithm;
00037 class SiStripGaussianSmearingRecHitConverterAlgorithm;
00038 class RandomEngine;
00039 
00040 namespace edm { 
00041   class ParameterSet;
00042   class Event;
00043   class EventSetup;
00044 }
00045 
00046 
00047 class SiTrackerGaussianSmearingRecHitConverter : public edm::EDProducer
00048 {
00049  public:
00050   //--- Constructor, virtual destructor (just in case)
00051   explicit SiTrackerGaussianSmearingRecHitConverter(const edm::ParameterSet& conf);
00052   virtual ~SiTrackerGaussianSmearingRecHitConverter();
00053   
00054   //--- The top-level event method.
00055   virtual void produce(edm::Event& e, const edm::EventSetup& c);
00056   
00057   // Begin Run
00058   virtual void beginRun(edm::Run & run, const edm::EventSetup & es);
00059   
00060   void smearHits(MixCollection<PSimHit>& input,
00061                  std::map<unsigned, edm::OwnVector<SiTrackerGSRecHit2D> >& theRecHits,
00062                  std::map<unsigned, edm::OwnVector<FastTrackerCluster> >& theClusters);
00063 
00064  void  matchHits( std::map<unsigned, edm::OwnVector<SiTrackerGSRecHit2D> >& theRecHits, 
00065                   std::map<unsigned, edm::OwnVector<SiTrackerGSMatchedRecHit2D> >& matchedMap,
00066                   MixCollection<PSimHit>& simhits);
00067 
00068   void loadRecHits(std::map<unsigned,edm::OwnVector<SiTrackerGSRecHit2D> >& theRecHits, 
00069                    SiTrackerGSRecHit2DCollection& theRecHitCollection) const;
00070 
00071   void loadMatchedRecHits(std::map<unsigned,edm::OwnVector<SiTrackerGSMatchedRecHit2D> >& theRecHits, 
00072                    SiTrackerGSMatchedRecHit2DCollection& theRecHitCollection) const;
00073 
00074   void loadClusters(std::map<unsigned,edm::OwnVector<FastTrackerCluster> >& theClusterMap, 
00075                     FastTrackerClusterCollection& theClusterCollection) const;
00076   
00077   
00078   
00079   private:
00080   //
00081   bool gaussianSmearing(const PSimHit& simHit, 
00082                         Local3DPoint& position , 
00083                         LocalError& error, 
00084                         unsigned& alphaMult, 
00085                         unsigned& betaMult);
00086   //
00087   void loadPixelData();
00088   //
00089   void loadPixelData(TFile* pixelDataFile, unsigned int nMultiplicity, std::string histName,
00090                      std::vector<TH1F*>& theMultiplicityCumulativeProbabilities, bool bigPixels = false);
00091   //
00092   //
00093   // parameters
00094   std::vector<edm::InputTag> trackerContainers;
00095   edm::ParameterSet pset_;
00096   double deltaRaysPCut; // GeV/c
00097   bool trackingPSimHits; // in case it is true make RecHit = replica of PSimHit without errors (1 um)
00098   //
00099   bool doMatching;
00100   // Switch between old (ORCA) and new (CMSSW) pixel parameterization
00101   bool useCMSSWPixelParameterization;
00102   double ElectronsPerADC;  
00103   double GevPerElectron;
00104 
00105   const TrackerGeometry* geometry;
00106   const TrackerGeometry* misAlignedGeometry;
00107   //
00108   // Pixel
00109   std::string thePixelMultiplicityFileName;
00110   std::string thePixelBarrelResolutionFileName;
00111   std::string thePixelForwardResolutionFileName;
00112   TFile* thePixelDataFile;
00113   TFile* thePixelBarrelResolutionFile;
00114   TFile* thePixelForwardResolutionFile;
00115   //
00116   // multiplicity bins
00117   unsigned int nAlphaBarrel, nBetaBarrel, nAlphaForward, nBetaForward;
00118   // internal vector: bins ; external vector: multiplicity
00119   std::vector<TH1F*> theBarrelMultiplicityAlphaCumulativeProbabilities;
00120   std::vector<TH1F*> theBarrelMultiplicityBetaCumulativeProbabilities;
00121   std::vector<TH1F*> theForwardMultiplicityAlphaCumulativeProbabilities;
00122   std::vector<TH1F*> theForwardMultiplicityBetaCumulativeProbabilities;
00123    // resolution bins
00124   double resAlphaBarrel_binMin , resAlphaBarrel_binWidth;
00125   unsigned int resAlphaBarrel_binN;
00126   double resBetaBarrel_binMin  , resBetaBarrel_binWidth;
00127   unsigned int resBetaBarrel_binN;
00128   double resAlphaForward_binMin , resAlphaForward_binWidth;
00129   unsigned int resAlphaForward_binN;
00130   double resBetaForward_binMin  , resBetaForward_binWidth;
00131   unsigned int resBetaForward_binN;
00132   //
00133   double theHitFindingProbability_PXB;
00134   double theHitFindingProbability_PXF;
00135   //
00136   // Strips
00137   // TIB
00138   double localPositionResolution_TIB1x; // cm
00139   double localPositionResolution_TIB1y; // cm
00140   double localPositionResolution_TIB2x; // cm
00141   double localPositionResolution_TIB2y; // cm
00142   double localPositionResolution_TIB3x; // cm
00143   double localPositionResolution_TIB3y; // cm
00144   double localPositionResolution_TIB4x; // cm
00145   double localPositionResolution_TIB4y; // cm
00146   //
00147   double theHitFindingProbability_TIB1;
00148   double theHitFindingProbability_TIB2;
00149   double theHitFindingProbability_TIB3;
00150   double theHitFindingProbability_TIB4;
00151   //
00152   // TID
00153   double localPositionResolution_TID1x; // cm
00154   double localPositionResolution_TID1y; // cm
00155   double localPositionResolution_TID2x; // cm
00156   double localPositionResolution_TID2y; // cm
00157   double localPositionResolution_TID3x; // cm
00158   double localPositionResolution_TID3y; // cm
00159   //
00160   double theHitFindingProbability_TID1;
00161   double theHitFindingProbability_TID2;
00162   double theHitFindingProbability_TID3;
00163   //
00164   // TOB
00165   double localPositionResolution_TOB1x; // cm
00166   double localPositionResolution_TOB1y; // cm
00167   double localPositionResolution_TOB2x; // cm
00168   double localPositionResolution_TOB2y; // cm
00169   double localPositionResolution_TOB3x; // cm
00170   double localPositionResolution_TOB3y; // cm
00171   double localPositionResolution_TOB4x; // cm
00172   double localPositionResolution_TOB4y; // cm
00173   double localPositionResolution_TOB5x; // cm
00174   double localPositionResolution_TOB5y; // cm
00175   double localPositionResolution_TOB6x; // cm
00176   double localPositionResolution_TOB6y; // cm
00177   //
00178   double theHitFindingProbability_TOB1;
00179   double theHitFindingProbability_TOB2;
00180   double theHitFindingProbability_TOB3;
00181   double theHitFindingProbability_TOB4;
00182   double theHitFindingProbability_TOB5;
00183   double theHitFindingProbability_TOB6;
00184   //
00185   // TEC
00186   double localPositionResolution_TEC1x; // cm
00187   double localPositionResolution_TEC1y; // cm
00188   double localPositionResolution_TEC2x; // cm
00189   double localPositionResolution_TEC2y; // cm
00190   double localPositionResolution_TEC3x; // cm
00191   double localPositionResolution_TEC3y; // cm
00192   double localPositionResolution_TEC4x; // cm
00193   double localPositionResolution_TEC4y; // cm
00194   double localPositionResolution_TEC5x; // cm
00195   double localPositionResolution_TEC5y; // cm
00196   double localPositionResolution_TEC6x; // cm
00197   double localPositionResolution_TEC6y; // cm
00198   double localPositionResolution_TEC7x; // cm
00199   double localPositionResolution_TEC7y; // cm
00200   //
00201   double theHitFindingProbability_TEC1;
00202   double theHitFindingProbability_TEC2;
00203   double theHitFindingProbability_TEC3;
00204   double theHitFindingProbability_TEC4;
00205   double theHitFindingProbability_TEC5;
00206   double theHitFindingProbability_TEC6;
00207   double theHitFindingProbability_TEC7;
00208   //
00209   // valid for all the detectors
00210   double localPositionResolution_z; // cm
00211   //
00212   //  typedef std::map<unsigned int, std::vector<PSimHit>,std::less<unsigned int> > simhit_map;
00213 
00214   // Pixel Error Parametrization (barrel)
00215   SiPixelGaussianSmearingRecHitConverterAlgorithm* thePixelBarrelParametrization;
00216   // Pixel Error Parametrization (barrel)
00217   SiPixelGaussianSmearingRecHitConverterAlgorithm* thePixelEndcapParametrization;
00218   // Si Strip Error parametrization (generic)
00219   SiStripGaussianSmearingRecHitConverterAlgorithm* theSiStripErrorParametrization;
00220 
00221   // Temporary RecHit map
00222   //  std::map< DetId, edm::OwnVector<SiTrackerGSRecHit2D> > temporaryRecHits;
00223 
00224   // Local correspondence between RecHits and SimHits
00225   typedef MixCollection<PSimHit>::iterator SimHiterator;
00226   std::vector<SimHiterator> correspondingSimHit;
00227 
00228   // The random engine
00229   const RandomEngine* random;
00230   
00231   typedef SiTrackerGSRecHit2D::ClusterRef ClusterRef;
00232   typedef SiTrackerGSRecHit2D::ClusterRefProd ClusterRefProd;
00233   // Added for cluster reference
00234   ClusterRefProd FastTrackerClusterRefProd;
00235 
00236 };
00237 
00238 
00239 #endif