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,
53  const SensitiveDetectorCatalog & clg,
54  edm::ParameterSet const & p, const SimTrackManager*,
55  float timeSlice=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(const G4ThreeVector&, const G4VTouchable*);
74  G4ThreeVector setToGlobal(const G4ThreeVector&, const G4VTouchable*);
75  G4bool hitExists();
76  G4bool checkHit();
78  void updateHit(CaloG4Hit*);
79  void resetForNewPrimary(const 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 
141  float timeSlice;
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
float edepositEM
Definition: CaloSD.h:121
double energyCut
Definition: CaloSD.h:123
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:440
virtual void Initialize(G4HCofThisEvent *HCE)
Definition: CaloSD.cc:207
bool corrTOFBeam
Definition: CaloSD.h:132
Definition: CaloSD.h:42
int totalHits
Definition: CaloSD.h:156
virtual void EndOfEvent(G4HCofThisEvent *eventHC)
Definition: CaloSD.cc:222
bool useMap
Definition: CaloSD.h:125
virtual int getTrackID(G4Track *)
Definition: CaloSD.cc:574
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:245
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:331
CaloSD(G4String aSDname, const DDCompactView &cpv, const SensitiveDetectorCatalog &clg, edm::ParameterSet const &p, const SimTrackManager *, float timeSlice=1., bool ignoreTkID=false)
Definition: CaloSD.cc:24
void cleanHitCollection()
Definition: CaloSD.cc:688
bool forceSave
Definition: CaloSD.h:137
virtual void clearHits()
Definition: CaloSD.cc:556
float timeSlice
Definition: CaloSD.h:141
virtual void DrawAll()
Definition: CaloSD.cc:236
void resetForNewPrimary(const G4ThreeVector &, double)
Definition: CaloSD.cc:454
virtual void clear()
Definition: CaloSD.cc:234
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:487
std::vector< CaloG4Hit * > hitvec
Definition: CaloSD.h:154
G4ThreeVector setToGlobal(const G4ThreeVector &, const G4VTouchable *)
Definition: CaloSD.cc:303
int getNumberOfHits()
Definition: CaloSD.cc:361
CaloHitID previousID
Definition: CaloSD.h:117
virtual void PrintAll()
Definition: CaloSD.cc:238
double getAttenuation(G4Step *aStep, double birk1, double birk2, double birk3)
Definition: CaloSD.cc:465
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:616
virtual bool filterHit(CaloG4Hit *, double)
Definition: CaloSD.cc:597
G4Track * theTrack
Definition: CaloSD.h:118
virtual G4bool getStepInfo(G4Step *aStep)
Definition: CaloSD.cc:250
double tmaxHit
Definition: CaloSD.h:123
G4StepPoint * preStepPoint
Definition: CaloSD.h:120
virtual bool ProcessHits(G4Step *step, G4TouchableHistory *tHistory)
Definition: CaloSD.cc:119
void summarize()
Definition: CaloSD.cc:663
CaloHitID currentID
Definition: CaloSD.h:117
virtual void initRun()
Definition: CaloSD.cc:572
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:113
CaloG4HitCollection * theHC
Definition: CaloSD.h:145
float incidentEnergy
Definition: CaloSD.h:114
double getResponseWt(G4Track *)
Definition: CaloSD.cc:607
G4THitsCollection< CaloG4Hit > CaloG4HitCollection
int checkHits
Definition: CaloSD.h:124
G4bool hitExists()
Definition: CaloSD.cc:310
std::map< int, TrackWithHistory * > tkMap
Definition: CaloSD.h:148
const SimTrackManager * m_trackManager
Definition: CaloSD.h:127
bool saveHit(CaloG4Hit *)
Definition: CaloSD.cc:627
CaloG4Hit * createNewHit()
Definition: CaloSD.cc:363
virtual uint16_t getDepth(G4Step *)
Definition: CaloSD.cc:595
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:203
bool ignoreTrackID
Definition: CaloSD.h:142
G4ThreeVector setToLocal(const G4ThreeVector &, const G4VTouchable *)
Definition: CaloSD.cc:296