File indexing completed on 2024-04-06 12:31:04
0001 #ifndef TrackingMaterialProducer_h
0002 #define TrackingMaterialProducer_h
0003 #include <string>
0004 #include <vector>
0005 #include <fstream>
0006 #include <G4VTouchable.hh>
0007
0008 #include "SimG4Core/Watcher/interface/SimProducer.h"
0009 #include "SimG4Core/Notification/interface/Observer.h"
0010
0011 #include "G4LogicalVolume.hh"
0012
0013 #include "SimDataFormats/ValidationFormats/interface/MaterialAccountingTrack.h"
0014
0015 #include "TProfile.h"
0016 #include "TFile.h"
0017
0018 class BeginOfJob;
0019 class EndOfJob;
0020 class BeginOfEvent;
0021 class BeginOfTrack;
0022 class EndOfTrack;
0023 class G4Step;
0024
0025 class G4StepPoint;
0026 class G4VPhysicalVolume;
0027 class G4LogicalVolume;
0028 class G4TouchableHistory;
0029 namespace edm {
0030 class ParameterSet;
0031 }
0032
0033 class TrackingMaterialProducer : public SimProducer,
0034 public Observer<const BeginOfJob*>,
0035 public Observer<const EndOfJob*>,
0036 public Observer<const BeginOfEvent*>,
0037 public Observer<const BeginOfTrack*>,
0038 public Observer<const G4Step*>,
0039 public Observer<const EndOfTrack*> {
0040 public:
0041 TrackingMaterialProducer(const edm::ParameterSet&);
0042 ~TrackingMaterialProducer() override;
0043
0044 private:
0045 void update(const BeginOfJob*) override;
0046 void update(const BeginOfEvent*) override;
0047 void update(const BeginOfTrack*) override;
0048 void update(const G4Step*) override;
0049 void update(const EndOfTrack*) override;
0050 void update(const EndOfJob*) override;
0051 void produce(edm::Event&, const edm::EventSetup&) override;
0052
0053 bool isSelected(const G4VTouchable* touch);
0054 bool isSelectedFast(const G4TouchableHistory* touch);
0055
0056 private:
0057 bool m_primaryTracks;
0058 std::vector<std::string> m_selectedNames;
0059 std::vector<const G4LogicalVolume*> m_selectedVolumes;
0060 std::string m_txtOutFile;
0061 double m_hgcalzfront;
0062 MaterialAccountingTrack m_track;
0063 const G4VPhysicalVolume* m_track_volume;
0064 std::vector<MaterialAccountingTrack>* m_tracks;
0065 TFile* output_file_;
0066 TProfile* radLen_vs_eta_;
0067 bool isHGCal;
0068 bool isHFNose;
0069 static constexpr float innerHGCalEta = 2.4;
0070 static constexpr float outerHGCalEta = 2.0;
0071 static constexpr float innerHFnoseEta = 4.;
0072 static constexpr float outerHFnoseEta = 3.3;
0073 std::ofstream outVolumeZpositionTxt;
0074 };
0075
0076 #endif