CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_6/src/FastSimulation/Calorimetry/interface/CalorimetryManager.h

Go to the documentation of this file.
00001 #ifndef CALORIMETRYMANAGER_H
00002 #define CALORIMETRYMANAGER_H
00003 
00004 #include "SimDataFormats/CaloHit/interface/PCaloHitContainer.h"
00005 
00006 // FastSimulation headers
00007 #include "FastSimulation/Particle/interface/RawParticle.h"
00008 #include "FastSimulation/Calorimetry/interface/HCALResponse.h"
00009 #include "DataFormats/DetId/interface/DetId.h"
00010 #include "FastSimulation/Utilities/interface/FamosDebug.h"
00011 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
00012 
00013 // For the uint32_t
00014 //#include <boost/cstdint.hpp>
00015 #include <map>
00016 #include <algorithm>
00017 
00018 class FSimEvent;
00019 class FSimTrack;
00020 class RawParticle;
00021 class CaloGeometryHelper;
00022 class Histos;
00023 class HSParameters;
00024 class RandomEngine;
00025 class LandauFluctuationGenerator;
00026 class GammaFunctionGenerator;
00027 class MaterialEffects;
00028 //Gflash
00029 class GflashHadronShowerProfile;
00030 class GflashPiKShowerProfile;
00031 class GflashProtonShowerProfile;
00032 class GflashAntiProtonShowerProfile;
00033 
00034 class DQMStore;
00035 
00036 namespace edm { 
00037   class ParameterSet;
00038 }
00039 
00040 class CalorimetryManager{
00041 
00042  public:
00043   CalorimetryManager();
00044   CalorimetryManager(FSimEvent* aSimEvent, 
00045                      const edm::ParameterSet& fastCalo,
00046                      const edm::ParameterSet& MuonECALPars,
00047                      const edm::ParameterSet& MuonHCALPars,
00048                      const edm::ParameterSet& fastGflash,
00049                      const RandomEngine* engine);
00050   ~CalorimetryManager();
00051 
00052   // Does the real job
00053   void reconstruct();
00054 
00055     // Return the address of the Calorimeter 
00056   CaloGeometryHelper * getCalorimeter() const {return myCalorimeter_;}
00057 
00058   // load container from edm::Event
00059   void loadFromEcalBarrel(edm::PCaloHitContainer & c) const;
00060 
00061   void loadFromEcalEndcap(edm::PCaloHitContainer & c) const;
00062 
00063   void loadFromHcal(edm::PCaloHitContainer & c) const;
00064 
00065   void loadFromPreshower(edm::PCaloHitContainer & c) const;
00066 
00067   void loadMuonSimTracks(edm::SimTrackContainer & m) const;
00068 
00069  private:
00070   // Simulation of electromagnetic showers in PS, ECAL, HCAL
00071   void EMShowerSimulation(const FSimTrack& myTrack);
00072   
00073   // Simulation of electromagnetic showers in VFCAL
00074   void reconstructECAL(const FSimTrack& track) ;
00075 
00076   void reconstructHCAL(const FSimTrack& myTrack);
00077 
00078   void MuonMipSimulation(const FSimTrack & myTrack);
00079  
00081   void HDShowerSimulation(const FSimTrack& myTrack);
00082 
00083   // Read the parameters 
00084   void readParameters(const edm::ParameterSet& fastCalo);
00085 
00086   void updateMap(uint32_t cellid,float energy,int id,std::map<uint32_t,std::vector<std::pair<int,float> > >& mymap);
00087 
00088   void updateMap(int hi,float energy,int id,std::vector<std::vector<std::pair<int,float> > > & mymap,std::vector<int> & firedCells);
00089 
00090   void respCorr(double);
00091 
00092   void clean(); 
00093 
00094  private:
00095 
00096   FSimEvent* mySimEvent;
00097   CaloGeometryHelper* myCalorimeter_;
00098 
00099   Histos * myHistos;
00100   DQMStore * dbe;
00101 
00102 
00103   HCALResponse* myHDResponse_;
00104   HSParameters * myHSParameters_;
00105 
00106   // In the not unfolded case (standard) the most inner vector will be of size = 1 
00107   // the preshower does not have hashed_indices, hence the map 
00108   std::vector<std::vector<std::pair<int,float> > > EBMapping_;
00109   std::vector<std::vector<std::pair<int,float> > > EEMapping_;
00110   std::vector<std::vector<std::pair<int,float> > > HMapping_;
00111   std::map<uint32_t,std::vector<std::pair<int,float> > > ESMapping_;
00112 
00113   std::vector<int> firedCellsEB_;
00114   std::vector<int> firedCellsEE_;
00115   std::vector<int> firedCellsHCAL_;
00116 
00117   // this is bad, the same information already exists in CaloRecHitsProducers
00118   // should make a es_producer of CaloGeometryTools 
00119   std::vector<DetId> theDetIds_;
00120   bool debug_;
00121   bool useDQM_;
00122   std::vector<unsigned int> evtsToDebug_;
00123 
00124 
00125 
00126   bool unfoldedMode_;
00127 
00129   RawParticle myElec;
00130   RawParticle myPosi;
00131   RawParticle myPart;
00132 
00133   // Parameters 
00134   double pulledPadSurvivalProbability_;
00135   double crackPadSurvivalProbability_;
00136   double spotFraction_;
00137   //  double radiusFactor_;
00138   double radiusFactorEB_ , radiusFactorEE_;
00139   std::vector<double> radiusPreshowerCorrections_;
00140   double aTerm, bTerm;
00141   std::vector<double> mipValues_;
00142   int gridSize_;
00143   std::vector<double> theCoreIntervals_,theTailIntervals_;
00144   double RCFactor_,RTFactor_;
00145   //FR
00146   int optionHDSim_, hdGridSize_, hdSimMethod_;
00147   bool simulatePreshower_;
00148   //RF 
00149 
00150   // Famos Random Engine
00151   const RandomEngine* random;
00152   const LandauFluctuationGenerator* aLandauGenerator;
00153   GammaFunctionGenerator* aGammaGenerator;
00154 
00155   static std::vector<std::pair<int, float> > myZero_;
00156 
00157   // RespCorrP p, k_e(p), k_h(p) vectors  and evaluated for each p
00158   // ecorr and hcorr  
00159   std::vector<double> rsp;
00160   std::vector<double> p_knots;
00161   std::vector<double> k_e;
00162   std::vector<double> k_h;
00163   double ecorr;
00164   double hcorr;
00165 
00166   // Used to check if the calorimeters was initialized
00167   bool initialized_;
00168 
00169   std::vector<FSimTrack> muonSimTracks;
00170   MaterialEffects* theMuonEcalEffects; // material effects for muons in ECAL
00171   MaterialEffects* theMuonHcalEffects; // material effects for muons in HCAL
00172 
00173 
00174   // If set to true the simulation in ECAL would be done 1X0 by 1X0
00175   // this is slow but more adapted to detailed studies.
00176   // Otherwise roughty 5 steps are used.
00177   // This variable is transferred to EMShower
00178   bool bFixedLength_;
00179 
00180   //Gflash
00181   GflashHadronShowerProfile *theProfile;
00182   GflashPiKShowerProfile *thePiKProfile;
00183   GflashProtonShowerProfile *theProtonProfile;
00184   GflashAntiProtonShowerProfile *theAntiProtonProfile;
00185 };
00186 #endif