CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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(G4String aSDname, const DDCompactView & cpv,
54  edm::ParameterSet const & p, const SimTrackManager*,
55  int tSlice=1, bool ignoreTkID=false);
56  virtual ~CaloSD();
57  virtual bool ProcessHits(G4Step * step,G4TouchableHistory * tHistory);
58  virtual bool ProcessHits(G4GFlashSpot*aSpot,G4TouchableHistory*);
59  virtual double getEnergyDeposit(G4Step* step);
60  virtual uint32_t setDetUnitId(G4Step* step)=0;
61 
62  virtual void Initialize(G4HCofThisEvent * HCE);
63  virtual void EndOfEvent(G4HCofThisEvent * eventHC);
64  virtual void clear();
65  virtual void DrawAll();
66  virtual void PrintAll();
67 
69 
70 protected:
71 
72  virtual G4bool getStepInfo(G4Step* aStep);
73  G4ThreeVector setToLocal(G4ThreeVector, const G4VTouchable*);
74  G4ThreeVector setToGlobal(G4ThreeVector, const G4VTouchable*);
75  G4bool hitExists();
76  G4bool checkHit();
78  void updateHit(CaloG4Hit*);
79  void resetForNewPrimary(G4ThreeVector, double);
80  double getAttenuation(G4Step* aStep, double birk1, double birk2,
81  double birk3);
82 
83  virtual void update(const BeginOfRun *);
84  virtual void update(const BeginOfEvent *);
85  virtual void update(const BeginOfTrack * trk);
86  virtual void update(const EndOfTrack * trk);
87  virtual void update(const ::EndOfEvent *);
88  virtual void clearHits();
89  virtual void initRun();
90  virtual bool filterHit(CaloG4Hit*, double);
91 
92  virtual int getTrackID(G4Track*);
93  virtual uint16_t getDepth(G4Step*);
94  double getResponseWt(G4Track*);
95  int getNumberOfHits();
96 
97 private:
98 
99  void storeHit(CaloG4Hit*);
100  bool saveHit(CaloG4Hit*);
101  void summarize();
102  void cleanHitCollection();
103 
104 protected:
105 
106  // Data relative to primary particle (the one which triggers a shower)
107  // These data are common to all Hits of a given shower.
108  // One shower is made of several hits which differ by the
109  // unit ID (crystal/fibre/scintillator) and the Time slice ID.
110 
111  G4ThreeVector entrancePoint;
112  G4ThreeVector entranceLocal;
113  G4ThreeVector posGlobal;
115  int primIDSaved; // ID of the last saved primary
116 
118  G4Track* theTrack;
119 
120  G4StepPoint* preStepPoint;
122 
125  bool useMap;
126 
129 // TimerProxy theHitTimer;
130  bool runInit;
131 
133  double correctT;
135 
137  bool forceSave;
138 
139 private:
140 
144  int hcID;
146  std::map<CaloHitID,CaloG4Hit*> hitMap;
147 
148  std::map<int,TrackWithHistory*> tkMap;
150 
153  std::vector<CaloG4Hit*> reusehit;
154  std::vector<CaloG4Hit*> hitvec;
155  std::vector<unsigned int> selIndex;
157 
158 };
159 
160 #endif // SimG4CMS_CaloSD_h
G4ThreeVector setToLocal(G4ThreeVector, const G4VTouchable *)
Definition: CaloSD.cc:293
float edepositEM
Definition: CaloSD.h:121
double energyCut
Definition: CaloSD.h:123
int timeSlice
Definition: CaloSD.h:141
G4ThreeVector setToGlobal(G4ThreeVector, const G4VTouchable *)
Definition: CaloSD.cc:300
virtual uint32_t setDetUnitId(G4Step *step)=0
G4int emPDG
Definition: CaloSD.h:136
std::vector< PCaloHit > PCaloHitContainer
double kmaxNeutron
Definition: CaloSD.h:134
void updateHit(CaloG4Hit *)
Definition: CaloSD.cc:437
virtual void Initialize(G4HCofThisEvent *HCE)
Definition: CaloSD.cc:204
bool corrTOFBeam
Definition: CaloSD.h:132
Definition: CaloSD.h:42
int totalHits
Definition: CaloSD.h:156
virtual void EndOfEvent(G4HCofThisEvent *eventHC)
Definition: CaloSD.cc:219
bool useMap
Definition: CaloSD.h:125
virtual int getTrackID(G4Track *)
Definition: CaloSD.cc:571
int hcID
Definition: CaloSD.h:144
double eminHitD
Definition: CaloSD.h:123
G4ThreeVector posGlobal
Definition: CaloSD.h:113
int primIDSaved
Definition: CaloSD.h:115
int primAncestor
Definition: CaloSD.h:151
void fillHits(edm::PCaloHitContainer &, std::string n)
Definition: CaloSD.cc:242
type of data representation of DDCompactView
Definition: DDCompactView.h:77
double kmaxProton
Definition: CaloSD.h:134
double eminHit
Definition: CaloSD.h:123
std::vector< CaloG4Hit * > reusehit
Definition: CaloSD.h:153
G4bool checkHit()
Definition: CaloSD.cc:328
void cleanHitCollection()
Definition: CaloSD.cc:685
CaloSD(G4String aSDname, const DDCompactView &cpv, SensitiveDetectorCatalog &clg, edm::ParameterSet const &p, const SimTrackManager *, int tSlice=1, bool ignoreTkID=false)
Definition: CaloSD.cc:21
bool forceSave
Definition: CaloSD.h:137
virtual void clearHits()
Definition: CaloSD.cc:553
virtual void DrawAll()
Definition: CaloSD.cc:233
virtual void clear()
Definition: CaloSD.cc:231
double kmaxIon
Definition: CaloSD.h:134
bool suppressHeavy
Definition: CaloSD.h:132
float edepositHAD
Definition: CaloSD.h:121
G4int epPDG
Definition: CaloSD.h:136
CaloSlaveSD * slave
Definition: CaloSD.h:143
G4int gammaPDG
Definition: CaloSD.h:136
virtual void update(const BeginOfRun *)
This routine will be called when the appropriate signal arrives.
Definition: CaloSD.cc:484
std::vector< CaloG4Hit * > hitvec
Definition: CaloSD.h:154
int getNumberOfHits()
Definition: CaloSD.cc:358
CaloHitID previousID
Definition: CaloSD.h:117
virtual void PrintAll()
Definition: CaloSD.cc:235
double getAttenuation(G4Step *aStep, double birk1, double birk2, double birk3)
Definition: CaloSD.cc:462
CaloG4Hit * currentHit
Definition: CaloSD.h:128
std::vector< unsigned int > selIndex
Definition: CaloSD.h:155
CaloMeanResponse * meanResponse
Definition: CaloSD.h:149
void storeHit(CaloG4Hit *)
Definition: CaloSD.cc:613
virtual bool filterHit(CaloG4Hit *, double)
Definition: CaloSD.cc:594
G4Track * theTrack
Definition: CaloSD.h:118
virtual G4bool getStepInfo(G4Step *aStep)
Definition: CaloSD.cc:247
double tmaxHit
Definition: CaloSD.h:123
G4StepPoint * preStepPoint
Definition: CaloSD.h:120
virtual bool ProcessHits(G4Step *step, G4TouchableHistory *tHistory)
Definition: CaloSD.cc:116
void summarize()
Definition: CaloSD.cc:660
CaloHitID currentID
Definition: CaloSD.h:117
virtual void initRun()
Definition: CaloSD.cc:569
double correctT
Definition: CaloSD.h:133
bool runInit
Definition: CaloSD.h:130
std::map< CaloHitID, CaloG4Hit * > hitMap
Definition: CaloSD.h:146
virtual ~CaloSD()
Definition: CaloSD.cc:110
CaloG4HitCollection * theHC
Definition: CaloSD.h:145
float incidentEnergy
Definition: CaloSD.h:114
double getResponseWt(G4Track *)
Definition: CaloSD.cc:604
G4THitsCollection< CaloG4Hit > CaloG4HitCollection
int checkHits
Definition: CaloSD.h:124
G4bool hitExists()
Definition: CaloSD.cc:307
std::map< int, TrackWithHistory * > tkMap
Definition: CaloSD.h:148
void resetForNewPrimary(G4ThreeVector, double)
Definition: CaloSD.cc:451
const SimTrackManager * m_trackManager
Definition: CaloSD.h:127
bool saveHit(CaloG4Hit *)
Definition: CaloSD.cc:624
CaloG4Hit * createNewHit()
Definition: CaloSD.cc:360
virtual uint16_t getDepth(G4Step *)
Definition: CaloSD.cc:592
G4ThreeVector entrancePoint
Definition: CaloSD.h:111
G4ThreeVector entranceLocal
Definition: CaloSD.h:112
int cleanIndex
Definition: CaloSD.h:152
virtual double getEnergyDeposit(G4Step *step)
Definition: CaloSD.cc:200
bool ignoreTrackID
Definition: CaloSD.h:142