CMS 3D CMS Logo

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