File indexing completed on 2024-04-06 12:29:47
0001 #ifndef SimG4CMS_HCalSD_h
0002 #define SimG4CMS_HCalSD_h
0003
0004
0005
0006
0007
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 void printVolume(const G4VTouchable* touch) const;
0087
0088 std::unique_ptr<HcalNumberingFromDDD> numberingFromDDD;
0089 std::unique_ptr<HcalNumberingScheme> numberingScheme;
0090 std::unique_ptr<HFShowerLibrary> showerLibrary;
0091 std::unique_ptr<HFShower> hfshower;
0092 std::unique_ptr<HFShowerParam> showerParam;
0093 std::unique_ptr<HFShowerPMT> showerPMT;
0094 std::unique_ptr<HFShowerFibreBundle> showerBundle;
0095
0096 const HcalDDDSimConstants* hcalConstants_;
0097 const HcalSimulationConstants* hcalSimConstants_;
0098 const HBHEDarkening* m_HBDarkening;
0099 const HBHEDarkening* m_HEDarkening;
0100 std::unique_ptr<HFDarkening> m_HFDarkening;
0101 std::unique_ptr<HcalTestNS> m_HcalTestNS;
0102
0103 static constexpr double maxZ_ = 10000.0;
0104 static constexpr double minRoff_ = -1500.0;
0105 static constexpr double maxRoff_ = 450.0;
0106 static constexpr double slopeHE_ = 0.4;
0107 bool isHF;
0108 bool agingFlagHB, agingFlagHE;
0109 bool useBirk, useLayerWt, useFibreBundle, usePMTHit;
0110 bool testNumber, neutralDensity, testNS_;
0111 double birk1, birk2, birk3, betaThr;
0112 bool useHF, useShowerLibrary, useParam, applyFidCut;
0113 double eminHitHB, eminHitHE, eminHitHO, eminHitHF;
0114 double deliveredLumi;
0115 double weight_;
0116 int depth_;
0117 bool dd4hep_;
0118 std::vector<double> gpar;
0119 std::vector<int> hfLevels;
0120 std::vector<std::string> hfNames;
0121 std::vector<std::string> fibreNames;
0122 std::vector<std::string> matNames;
0123 std::vector<const G4Material*> materials;
0124 std::vector<const G4LogicalVolume*> hfLV, fibreLV, pmtLV, fibre1LV, fibre2LV;
0125 std::map<uint32_t, double> layerWeights;
0126 TH1F *hit_[9], *time_[9], *dist_[9], *hzvem, *hzvhad;
0127 std::vector<int> detNull_;
0128 };
0129
0130 #endif