Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-22 04:08:42

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 
0061 private:
0062   void fillLogVolumeVector(const std::string&, const std::vector<std::string>&, std::vector<const G4LogicalVolume*>&);
0063   uint32_t setDetUnitId(int, const G4ThreeVector&, int, int);
0064   uint32_t setDetUnitId(HcalNumberingFromDDD::HcalID& tmp);
0065   bool isItHF(const G4Step*);
0066   bool isItHF(const G4String&);
0067   bool isItFibre(const G4LogicalVolume*);
0068   bool isItFibre(const G4String&);
0069   bool isItPMT(const G4LogicalVolume*);
0070   bool isItStraightBundle(const G4LogicalVolume*);
0071   bool isItConicalBundle(const G4LogicalVolume*);
0072   bool isItScintillator(const G4Material*);
0073   bool isItinFidVolume(const G4ThreeVector&);
0074   void getFromHFLibrary(const G4Step* step, bool& isKilled);
0075   void hitForFibre(const G4Step* step);
0076   void getFromParam(const G4Step* step, bool& isKilled);
0077   void getHitPMT(const G4Step* step);
0078   void getHitFibreBundle(const G4Step* step, bool type);
0079   void readWeightFromFile(const std::string&);
0080   double layerWeight(int, const G4ThreeVector&, int, int);
0081   void plotProfile(const G4Step* step, const G4ThreeVector& pos, double edep, double time, int id);
0082   void plotHF(const G4ThreeVector& pos, bool emType);
0083   void modifyDepth(HcalNumberingFromDDD::HcalID& id);
0084 
0085   std::unique_ptr<HcalNumberingFromDDD> numberingFromDDD;
0086   std::unique_ptr<HcalNumberingScheme> numberingScheme;
0087   std::unique_ptr<HFShowerLibrary> showerLibrary;
0088   std::unique_ptr<HFShower> hfshower;
0089   std::unique_ptr<HFShowerParam> showerParam;
0090   std::unique_ptr<HFShowerPMT> showerPMT;
0091   std::unique_ptr<HFShowerFibreBundle> showerBundle;
0092 
0093   const HcalDDDSimConstants* hcalConstants_;
0094   const HcalSimulationConstants* hcalSimConstants_;
0095   const HBHEDarkening* m_HBDarkening;
0096   const HBHEDarkening* m_HEDarkening;
0097   std::unique_ptr<HFDarkening> m_HFDarkening;
0098   std::unique_ptr<HcalTestNS> m_HcalTestNS;
0099 
0100   bool isHF;
0101   bool agingFlagHB, agingFlagHE;
0102   bool useBirk, useLayerWt, useFibreBundle, usePMTHit;
0103   bool testNumber, neutralDensity, testNS_;
0104   double birk1, birk2, birk3, betaThr;
0105   bool useHF, useShowerLibrary, useParam, applyFidCut;
0106   double eminHitHB, eminHitHE, eminHitHO, eminHitHF;
0107   double deliveredLumi;
0108   double weight_;
0109   int depth_;
0110   std::vector<double> gpar;
0111   std::vector<int> hfLevels;
0112   std::vector<std::string> hfNames;
0113   std::vector<std::string> fibreNames;
0114   std::vector<std::string> matNames;
0115   std::vector<const G4Material*> materials;
0116   std::vector<const G4LogicalVolume*> hfLV, fibreLV, pmtLV, fibre1LV, fibre2LV;
0117   std::map<uint32_t, double> layerWeights;
0118   TH1F *hit_[9], *time_[9], *dist_[9], *hzvem, *hzvhad;
0119 };
0120 
0121 #endif  // HCalSD_h