Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:11:13

0001 #ifndef CALORIMETRYMANAGER_H
0002 #define CALORIMETRYMANAGER_H
0003 
0004 #include "SimDataFormats/CaloHit/interface/PCaloHitContainer.h"
0005 #include "SimG4CMS/Calo/interface/CaloHitID.h"
0006 
0007 // FastSimulation headers
0008 #include "FastSimulation/Calorimetry/interface/HCALResponse.h"
0009 #include "DataFormats/DetId/interface/DetId.h"
0010 #include "FastSimulation/Utilities/interface/FamosDebug.h"
0011 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
0012 #include "FastSimulation/CaloHitMakers/interface/EcalHitMaker.h"
0013 #include "FastSimulation/CaloHitMakers/interface/HcalHitMaker.h"
0014 #include "FastSimulation/CaloHitMakers/interface/PreshowerHitMaker.h"
0015 
0016 #include "FastSimulation/Calorimetry/interface/KKCorrectionFactors.h"
0017 
0018 #include "FWCore/Framework/interface/FrameworkfwdMostUsed.h"
0019 
0020 // For the uint32_t
0021 //#include <boost/cstdint.hpp>
0022 #include <map>
0023 #include <algorithm>
0024 
0025 class FSimEvent;
0026 class FSimTrack;
0027 class CaloGeometryHelper;
0028 class Histos;
0029 class HSParameters;
0030 class LandauFluctuationGenerator;
0031 class GammaFunctionGenerator;
0032 class MaterialEffects;
0033 class RandomEngineAndDistribution;
0034 //Gflash
0035 class GflashHadronShowerProfile;
0036 class GflashPiKShowerProfile;
0037 class GflashProtonShowerProfile;
0038 class GflashAntiProtonShowerProfile;
0039 // FastHFshowerLibrary
0040 class FastHFShowerLibrary;
0041 
0042 class CalorimetryManager {
0043 public:
0044   CalorimetryManager();
0045   CalorimetryManager(FSimEvent* aSimEvent,
0046                      const edm::ParameterSet& fastCalo,
0047                      const edm::ParameterSet& MuonECALPars,
0048                      const edm::ParameterSet& MuonHCALPars,
0049                      const edm::ParameterSet& fastGflash,
0050                      edm::ConsumesCollector&&);
0051   ~CalorimetryManager();
0052 
0053   // Does the real job
0054   void initialize(RandomEngineAndDistribution const* random);
0055   void reconstructTrack(FSimTrack& myTrack, RandomEngineAndDistribution const*);
0056   void reconstruct(RandomEngineAndDistribution const*);
0057 
0058   // Return the address of the Calorimeter
0059   CaloGeometryHelper* getCalorimeter() const { return myCalorimeter_; }
0060 
0061   // Return the address of the FastHFShowerLibrary
0062   FastHFShowerLibrary* getHFShowerLibrary() const { return theHFShowerLibrary; }
0063 
0064   // load container from edm::Event
0065   void loadFromEcalBarrel(edm::PCaloHitContainer& c) const;
0066 
0067   void loadFromEcalEndcap(edm::PCaloHitContainer& c) const;
0068 
0069   void loadFromHcal(edm::PCaloHitContainer& c) const;
0070 
0071   void loadFromPreshower(edm::PCaloHitContainer& c) const;
0072 
0073   void loadMuonSimTracks(edm::SimTrackContainer& m) const;
0074 
0075   void harvestMuonSimTracks(edm::SimTrackContainer& m) const;
0076 
0077 private:
0078   // Simulation of electromagnetic showers in PS, ECAL, HCAL
0079   void EMShowerSimulation(const FSimTrack& myTrack, RandomEngineAndDistribution const*);
0080 
0081   void reconstructHCAL(const FSimTrack& myTrack, RandomEngineAndDistribution const*);
0082 
0083   void MuonMipSimulation(const FSimTrack& myTrack, RandomEngineAndDistribution const*);
0084 
0085   /// Hadronic Shower Simulation
0086   void HDShowerSimulation(const FSimTrack& myTrack, RandomEngineAndDistribution const*);
0087 
0088   // Read the parameters
0089   void readParameters(const edm::ParameterSet& fastCalo);
0090 
0091   void updateECAL(const std::map<CaloHitID, float>& hitMap, int onEcal, int trackID = 0, float corr = 1.0);
0092   void updateHCAL(const std::map<CaloHitID, float>& hitMap, int trackID = 0, float corr = 1.0);
0093   void updatePreshower(const std::map<CaloHitID, float>& hitMap, int trackID = 0, float corr = 1.0);
0094 
0095   void respCorr(double);
0096 
0097   void clean();
0098 
0099 private:
0100   FSimEvent* mySimEvent;
0101   CaloGeometryHelper* myCalorimeter_;
0102 
0103   Histos* myHistos;
0104 
0105   HCALResponse* myHDResponse_;
0106   HSParameters* myHSParameters_;
0107 
0108   std::vector<std::pair<CaloHitID, float> > EBMapping_;
0109   std::vector<std::pair<CaloHitID, float> > EEMapping_;
0110   std::vector<std::pair<CaloHitID, float> > HMapping_;
0111   std::vector<std::pair<CaloHitID, float> > ESMapping_;
0112 
0113   bool debug_;
0114   std::vector<unsigned int> evtsToDebug_;
0115 
0116   bool unfoldedMode_;
0117 
0118   //Digitizer
0119   bool EcalDigitizer_;
0120   bool HcalDigitizer_;
0121   std::vector<double> samplingHBHE_;
0122   std::vector<double> samplingHF_;
0123   std::vector<double> samplingHO_;
0124   int ietaShiftHB_, ietaShiftHE_, ietaShiftHO_, ietaShiftHF_;
0125   std::vector<double> timeShiftHB_;
0126   std::vector<double> timeShiftHE_;
0127   std::vector<double> timeShiftHF_;
0128   std::vector<double> timeShiftHO_;
0129 
0130   /// A few pointers to save time
0131   RawParticle myElec;
0132   RawParticle myPosi;
0133   RawParticle myPart;
0134 
0135   // Parameters
0136   double pulledPadSurvivalProbability_;
0137   double crackPadSurvivalProbability_;
0138   double spotFraction_;
0139   //  double radiusFactor_;
0140   double radiusFactorEB_, radiusFactorEE_;
0141   std::vector<double> radiusPreshowerCorrections_;
0142   double aTerm, bTerm;
0143   std::vector<double> mipValues_;
0144   int gridSize_;
0145   std::vector<double> theCoreIntervals_, theTailIntervals_;
0146   double RCFactor_, RTFactor_;
0147   //FR
0148   int optionHDSim_, hdGridSize_, hdSimMethod_;
0149   bool simulatePreshower_;
0150   //RF
0151 
0152   const LandauFluctuationGenerator* aLandauGenerator;
0153   GammaFunctionGenerator* aGammaGenerator;
0154 
0155   static std::vector<std::pair<int, float> > myZero_;
0156 
0157   // RespCorrP p, k_e(p), k_h(p) vectors  and evaluated for each p
0158   // ecorr and hcorr
0159   std::vector<double> rsp;
0160   std::vector<double> p_knots;
0161   std::vector<double> k_e;
0162   std::vector<double> k_h;
0163   double ecorr;
0164   double hcorr;
0165 
0166   // Used to check if the calorimeters was initialized
0167   bool initialized_;
0168 
0169   std::vector<FSimTrack> muonSimTracks;
0170   std::vector<FSimTrack> savedMuonSimTracks;
0171   MaterialEffects* theMuonEcalEffects;  // material effects for muons in ECAL
0172   MaterialEffects* theMuonHcalEffects;  // material effects for muons in HCAL
0173 
0174   // If set to true the simulation in ECAL would be done 1X0 by 1X0
0175   // this is slow but more adapted to detailed studies.
0176   // Otherwise roughty 5 steps are used.
0177   // This variable is transferred to EMShower
0178   bool bFixedLength_;
0179 
0180   //Gflash
0181   GflashHadronShowerProfile* theProfile;
0182   GflashPiKShowerProfile* thePiKProfile;
0183   GflashProtonShowerProfile* theProtonProfile;
0184   GflashAntiProtonShowerProfile* theAntiProtonProfile;
0185 
0186   // HFShowerLibrary
0187   bool useShowerLibrary;
0188   bool useCorrectionSL;
0189   FastHFShowerLibrary* theHFShowerLibrary;
0190 
0191   std::unique_ptr<KKCorrectionFactors> ecalCorrection;
0192 };
0193 #endif