CMS 3D CMS Logo

CaloSD.h
Go to the documentation of this file.
1 #ifndef SimG4CMS_CaloSD_h
2 #define SimG4CMS_CaloSD_h
3 // File: CaloSD.h
5 // Description: Stores hits of calorimetric type in appropriate container
6 // Use in your sensitive detector builder:
7 // CaloSD* caloSD = new CaloSD(SDname, new CaloNumberingScheme());
9 
22 
24 
25 // To be replaced by something else
26 /* #include "Utilities/Notification/interface/TimerProxy.h" */
27 
28 #include "G4VPhysicalVolume.hh"
29 #include "G4Track.hh"
30 #include "G4VGFlashSensitiveDetector.hh"
31 
32 #include <iostream>
33 #include <fstream>
34 #include <vector>
35 #include <map>
36 
37 class G4Step;
38 class G4HCofThisEvent;
39 class CaloSlaveSD;
40 class G4GFlashSpot;
41 
42 class CaloSD : public SensitiveCaloDetector,
43  public G4VGFlashSensitiveDetector,
44  public Observer<const BeginOfRun *>,
45  public Observer<const BeginOfEvent *>,
46  public Observer<const BeginOfTrack *>,
47  public Observer<const EndOfTrack *>,
48  public Observer<const EndOfEvent *> {
49 
50 public:
51 
52  CaloSD(const std::string& aSDname, const DDCompactView & cpv,
53  const SensitiveDetectorCatalog & clg,
54  edm::ParameterSet const & p, const SimTrackManager*,
55  float timeSlice=1., bool ignoreTkID=false);
56  ~CaloSD() override;
57  bool ProcessHits(G4Step * step,G4TouchableHistory * tHistory) override;
58  bool ProcessHits(G4GFlashSpot*aSpot,G4TouchableHistory*) override;
59 
60  virtual double getEnergyDeposit(G4Step* step);
61  uint32_t setDetUnitId(const G4Step* step) override =0;
62 
63  void Initialize(G4HCofThisEvent * HCE) override;
64  void EndOfEvent(G4HCofThisEvent * eventHC) override;
65  void clear() override;
66  void DrawAll() override;
67  void PrintAll() override;
68 
69  void clearHits() override;
70  void fillHits(edm::PCaloHitContainer&, const std::string&) override;
71 
72 protected:
73 
74  virtual G4bool getStepInfo(G4Step* aStep);
75  G4ThreeVector setToLocal(const G4ThreeVector&, const G4VTouchable*);
76  G4ThreeVector setToGlobal(const G4ThreeVector&, const G4VTouchable*);
77  G4bool hitExists();
78  G4bool checkHit();
80  void updateHit(CaloG4Hit*);
81  void resetForNewPrimary(const G4ThreeVector&, double);
82  double getAttenuation(const G4Step* aStep, double birk1, double birk2,
83  double birk3);
84 
85  void update(const BeginOfRun *) override;
86  void update(const BeginOfEvent *) override;
87  void update(const BeginOfTrack * trk) override;
88  void update(const EndOfTrack * trk) override;
89  void update(const ::EndOfEvent *) override;
90  virtual void initRun();
91  virtual bool filterHit(CaloG4Hit*, double);
92 
93  virtual int getTrackID(const G4Track*);
94  virtual uint16_t getDepth(const G4Step*);
95  double getResponseWt(const G4Track*);
96  int getNumberOfHits();
97 
98 private:
99 
100  void storeHit(CaloG4Hit*);
101  bool saveHit(CaloG4Hit*);
102  void summarize();
103  void cleanHitCollection();
104 
105 protected:
106 
107  // Data relative to primary particle (the one which triggers a shower)
108  // These data are common to all Hits of a given shower.
109  // One shower is made of several hits which differ by the
110  // unit ID (crystal/fibre/scintillator) and the Time slice ID.
111 
112  G4ThreeVector entrancePoint;
113  G4ThreeVector entranceLocal;
114  G4ThreeVector posGlobal;
116  int primIDSaved; // ID of the last saved primary
117 
119  G4Track* theTrack;
120 
121  G4StepPoint* preStepPoint;
123 
126  bool useMap;
127 
130 
131  bool runInit;
132 
134  double correctT;
136 
138  bool forceSave;
139 
140 private:
141 
142  float timeSlice;
145  int hcID;
147  std::map<CaloHitID,CaloG4Hit*> hitMap;
148 
149  std::map<int,TrackWithHistory*> tkMap;
151 
154  std::vector<CaloG4Hit*> reusehit;
155  std::vector<CaloG4Hit*> hitvec;
156  std::vector<unsigned int> selIndex;
158 
159 };
160 
161 #endif // SimG4CMS_CaloSD_h
float edepositEM
Definition: CaloSD.h:122
double energyCut
Definition: CaloSD.h:124
double getAttenuation(const G4Step *aStep, double birk1, double birk2, double birk3)
Definition: CaloSD.cc:439
G4int emPDG
Definition: CaloSD.h:137
std::vector< PCaloHit > PCaloHitContainer
double kmaxNeutron
Definition: CaloSD.h:135
void updateHit(CaloG4Hit *)
Definition: CaloSD.cc:414
virtual uint16_t getDepth(const G4Step *)
Definition: CaloSD.cc:569
bool corrTOFBeam
Definition: CaloSD.h:133
Definition: CaloSD.h:42
int totalHits
Definition: CaloSD.h:157
void DrawAll() override
Definition: CaloSD.cc:210
void clear() override
Definition: CaloSD.cc:208
uint32_t setDetUnitId(const G4Step *step) override=0
bool useMap
Definition: CaloSD.h:126
int hcID
Definition: CaloSD.h:145
double eminHitD
Definition: CaloSD.h:124
G4ThreeVector posGlobal
Definition: CaloSD.h:114
virtual int getTrackID(const G4Track *)
Definition: CaloSD.cc:548
int primIDSaved
Definition: CaloSD.h:116
void Initialize(G4HCofThisEvent *HCE) override
Definition: CaloSD.cc:181
int primAncestor
Definition: CaloSD.h:152
type of data representation of DDCompactView
Definition: DDCompactView.h:90
double kmaxProton
Definition: CaloSD.h:135
void fillHits(edm::PCaloHitContainer &, const std::string &) override
Definition: CaloSD.cc:219
double eminHit
Definition: CaloSD.h:124
std::vector< CaloG4Hit * > reusehit
Definition: CaloSD.h:154
G4bool checkHit()
Definition: CaloSD.cc:305
void cleanHitCollection()
Definition: CaloSD.cc:662
bool forceSave
Definition: CaloSD.h:138
float timeSlice
Definition: CaloSD.h:142
void resetForNewPrimary(const G4ThreeVector &, double)
Definition: CaloSD.cc:428
double kmaxIon
Definition: CaloSD.h:135
bool suppressHeavy
Definition: CaloSD.h:133
float edepositHAD
Definition: CaloSD.h:122
G4int epPDG
Definition: CaloSD.h:137
CaloSlaveSD * slave
Definition: CaloSD.h:144
G4int gammaPDG
Definition: CaloSD.h:137
std::vector< CaloG4Hit * > hitvec
Definition: CaloSD.h:155
G4ThreeVector setToGlobal(const G4ThreeVector &, const G4VTouchable *)
Definition: CaloSD.cc:277
int getNumberOfHits()
Definition: CaloSD.cc:335
CaloSD(const std::string &aSDname, const DDCompactView &cpv, const SensitiveDetectorCatalog &clg, edm::ParameterSet const &p, const SimTrackManager *, float timeSlice=1., bool ignoreTkID=false)
Definition: CaloSD.cc:24
CaloHitID previousID
Definition: CaloSD.h:118
~CaloSD() override
Definition: CaloSD.cc:87
CaloG4Hit * currentHit
Definition: CaloSD.h:129
std::vector< unsigned int > selIndex
Definition: CaloSD.h:156
CaloMeanResponse * meanResponse
Definition: CaloSD.h:150
void storeHit(CaloG4Hit *)
Definition: CaloSD.cc:590
virtual bool filterHit(CaloG4Hit *, double)
Definition: CaloSD.cc:571
G4Track * theTrack
Definition: CaloSD.h:119
virtual G4bool getStepInfo(G4Step *aStep)
Definition: CaloSD.cc:224
double tmaxHit
Definition: CaloSD.h:124
G4StepPoint * preStepPoint
Definition: CaloSD.h:121
void summarize()
Definition: CaloSD.cc:637
CaloHitID currentID
Definition: CaloSD.h:118
virtual void initRun()
Definition: CaloSD.cc:546
double correctT
Definition: CaloSD.h:134
bool runInit
Definition: CaloSD.h:131
void EndOfEvent(G4HCofThisEvent *eventHC) override
Definition: CaloSD.cc:196
std::map< CaloHitID, CaloG4Hit * > hitMap
Definition: CaloSD.h:147
CaloG4HitCollection * theHC
Definition: CaloSD.h:146
float incidentEnergy
Definition: CaloSD.h:115
G4THitsCollection< CaloG4Hit > CaloG4HitCollection
int checkHits
Definition: CaloSD.h:125
G4bool hitExists()
Definition: CaloSD.cc:284
bool ProcessHits(G4Step *step, G4TouchableHistory *tHistory) override
Definition: CaloSD.cc:93
std::map< int, TrackWithHistory * > tkMap
Definition: CaloSD.h:149
step
const SimTrackManager * m_trackManager
Definition: CaloSD.h:128
void clearHits() override
Definition: CaloSD.cc:530
double getResponseWt(const G4Track *)
Definition: CaloSD.cc:581
bool saveHit(CaloG4Hit *)
Definition: CaloSD.cc:601
void PrintAll() override
Definition: CaloSD.cc:212
CaloG4Hit * createNewHit()
Definition: CaloSD.cc:337
G4ThreeVector entrancePoint
Definition: CaloSD.h:112
G4ThreeVector entranceLocal
Definition: CaloSD.h:113
void update(const BeginOfRun *) override
This routine will be called when the appropriate signal arrives.
Definition: CaloSD.cc:461
int cleanIndex
Definition: CaloSD.h:153
virtual double getEnergyDeposit(G4Step *step)
Definition: CaloSD.cc:177
bool ignoreTrackID
Definition: CaloSD.h:143
G4ThreeVector setToLocal(const G4ThreeVector &, const G4VTouchable *)
Definition: CaloSD.cc:270