Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-11-12 00:43:13

0001 #ifndef SimG4CMS_HCalSD_h
0002 #define SimG4CMS_HCalSD_h
0003 ///////////////////////////////////////////////////////////////////////////////
0004 // File: HCalSD.h
0005 // Description: Stores hits of Hadron calorimeter in appropriate container
0006 // Use in your sensitive detector builder:
0007 //    HCalSD* hcalSD = new HCalSD(SDname, new CaloNumberingScheme());
0008 ///////////////////////////////////////////////////////////////////////////////
0009 
0010 #include "SimG4CMS/Calo/interface/CaloSD.h"
0011 #include "SimG4CMS/Calo/interface/HFShower.h"
0012 #include "SimG4CMS/Calo/interface/HFShowerLibrary.h"
0013 #include "SimG4CMS/Calo/interface/HFShowerParam.h"
0014 #include "SimG4CMS/Calo/interface/HFShowerPMT.h"
0015 #include "SimG4CMS/Calo/interface/HFShowerFibreBundle.h"
0016 #include "SimG4CMS/Calo/interface/HcalNumberingScheme.h"
0017 #include "SimG4CMS/Calo/interface/HcalTestNS.h"
0018 #include "CondFormats/HcalObjects/interface/HBHEDarkening.h"
0019 #include "SimG4CMS/Calo/interface/HFDarkening.h"
0020 #include "SimG4Core/Notification/interface/BeginOfJob.h"
0021 #include "Geometry/HcalCommonData/interface/HcalNumberingFromDDD.h"
0022 #include "Geometry/HcalCommonData/interface/HcalDDDSimConstants.h"
0023 #include "Geometry/HcalCommonData/interface/HcalDDDRecConstants.h"
0024 #include "Geometry/HcalCommonData/interface/HcalSimulationConstants.h"
0025 #include "Geometry/Records/interface/HcalParametersRcd.h"
0026 
0027 #include "G4String.hh"
0028 #include <map>
0029 #include <string>
0030 
0031 class DDFilteredView;
0032 class G4LogicalVolume;
0033 class G4Material;
0034 class G4Step;
0035 class HcalTestNS;
0036 class TH1F;
0037 
0038 class HCalSD : public CaloSD, public Observer<const BeginOfJob*> {
0039 public:
0040   HCalSD(const std::string&,
0041          const HcalDDDSimConstants*,
0042          const HcalDDDRecConstants*,
0043          const HcalSimulationConstants*,
0044          const HBHEDarkening*,
0045          const HBHEDarkening*,
0046          const SensitiveDetectorCatalog&,
0047          edm::ParameterSet const&,
0048          const SimTrackManager*);
0049   ~HCalSD() override = default;
0050   uint32_t setDetUnitId(const G4Step* step) override;
0051   void setNumberingScheme(HcalNumberingScheme*);
0052 
0053 protected:
0054   double getEnergyDeposit(const G4Step*) override;
0055   bool getFromLibrary(const G4Step*) override;
0056   using CaloSD::update;
0057   void update(const BeginOfJob*) override;
0058   void initRun() override;
0059   bool filterHit(CaloG4Hit*, double) override;
0060   void initEvent(const BeginOfEvent*) override;
0061   void endEvent() override;
0062 
0063 private:
0064   void fillLogVolumeVector(const std::string&, const std::vector<std::string>&, std::vector<const G4LogicalVolume*>&);
0065   uint32_t setDetUnitId(int, const G4ThreeVector&, int, int);
0066   uint32_t setDetUnitId(HcalNumberingFromDDD::HcalID& tmp);
0067   bool isItHF(const G4Step*);
0068   bool isItHF(const G4String&);
0069   bool isItFibre(const G4LogicalVolume*);
0070   bool isItFibre(const G4String&);
0071   bool isItPMT(const G4LogicalVolume*);
0072   bool isItStraightBundle(const G4LogicalVolume*);
0073   bool isItConicalBundle(const G4LogicalVolume*);
0074   bool isItScintillator(const G4Material*);
0075   bool isItinFidVolume(const G4ThreeVector&);
0076   void getFromHFLibrary(const G4Step* step, bool& isKilled);
0077   void hitForFibre(const G4Step* step);
0078   void getFromParam(const G4Step* step, bool& isKilled);
0079   void getHitPMT(const G4Step* step);
0080   void getHitFibreBundle(const G4Step* step, bool type);
0081   void readWeightFromFile(const std::string&);
0082   double layerWeight(int, const G4ThreeVector&, int, int);
0083   void plotProfile(const G4Step* step, const G4ThreeVector& pos, double edep, double time, int id);
0084   void plotHF(const G4ThreeVector& pos, bool emType);
0085   void modifyDepth(HcalNumberingFromDDD::HcalID& id);
0086 
0087   std::unique_ptr<HcalNumberingFromDDD> numberingFromDDD;
0088   std::unique_ptr<HcalNumberingScheme> numberingScheme;
0089   std::unique_ptr<HFShowerLibrary> showerLibrary;
0090   std::unique_ptr<HFShower> hfshower;
0091   std::unique_ptr<HFShowerParam> showerParam;
0092   std::unique_ptr<HFShowerPMT> showerPMT;
0093   std::unique_ptr<HFShowerFibreBundle> showerBundle;
0094 
0095   const HcalDDDSimConstants* hcalConstants_;
0096   const HcalSimulationConstants* hcalSimConstants_;
0097   const HBHEDarkening* m_HBDarkening;
0098   const HBHEDarkening* m_HEDarkening;
0099   std::unique_ptr<HFDarkening> m_HFDarkening;
0100   std::unique_ptr<HcalTestNS> m_HcalTestNS;
0101 
0102   static constexpr double maxZ_ = 10000.0;
0103   static constexpr double minRoff_ = -1500.0;
0104   static constexpr double maxRoff_ = 450.0;
0105   static constexpr double slopeHE_ = 0.4;
0106   bool isHF;
0107   bool agingFlagHB, agingFlagHE;
0108   bool useBirk, useLayerWt, useFibreBundle, usePMTHit;
0109   bool testNumber, neutralDensity, testNS_;
0110   double birk1, birk2, birk3, betaThr;
0111   bool useHF, useShowerLibrary, useParam, applyFidCut;
0112   double eminHitHB, eminHitHE, eminHitHO, eminHitHF;
0113   double deliveredLumi;
0114   double weight_;
0115   int depth_;
0116   std::vector<double> gpar;
0117   std::vector<int> hfLevels;
0118   std::vector<std::string> hfNames;
0119   std::vector<std::string> fibreNames;
0120   std::vector<std::string> matNames;
0121   std::vector<const G4Material*> materials;
0122   std::vector<const G4LogicalVolume*> hfLV, fibreLV, pmtLV, fibre1LV, fibre2LV;
0123   std::map<uint32_t, double> layerWeights;
0124   TH1F *hit_[9], *time_[9], *dist_[9], *hzvem, *hzvhad;
0125   std::vector<int> detNull_;
0126 };
0127 
0128 #endif  // HCalSD_h