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 
68  void fillHits(edm::PCaloHitContainer&,std::string n);
69 
70 protected:
71 
72  virtual G4bool getStepInfo(G4Step* aStep);
73  G4ThreeVector setToLocal(G4ThreeVector, const G4VTouchable*);
74  G4bool hitExists();
75  G4bool checkHit();
77  void updateHit(CaloG4Hit*);
78  void resetForNewPrimary(G4ThreeVector, double);
79  double getAttenuation(G4Step* aStep, double birk1, double birk2,
80  double birk3);
81 
82  virtual void update(const BeginOfRun *);
83  virtual void update(const BeginOfEvent *);
84  virtual void update(const BeginOfTrack * trk);
85  virtual void update(const EndOfTrack * trk);
86  virtual void update(const ::EndOfEvent *);
87  virtual void clearHits();
88  virtual void initRun();
89  virtual bool filterHit(CaloG4Hit*, double);
90 
91  virtual int getTrackID(G4Track*);
92  virtual uint16_t getDepth(G4Step*);
93  double getResponseWt(G4Track*);
94  int getNumberOfHits();
95 
96 private:
97 
98  void storeHit(CaloG4Hit*);
99  bool saveHit(CaloG4Hit*);
100  void summarize();
101  void cleanHitCollection();
102 
103 protected:
104 
105  // Data relative to primary particle (the one which triggers a shower)
106  // These data are common to all Hits of a given shower.
107  // One shower is made of several hits which differ by the
108  // unit ID (crystal/fibre/scintillator) and the Time slice ID.
109 
110  G4ThreeVector entrancePoint;
111  G4ThreeVector entranceLocal;
112  G4ThreeVector posGlobal;
114  int primIDSaved; // ID of the last saved primary
115 
117  G4Track* theTrack;
118 
119  G4StepPoint* preStepPoint;
121 
124  bool useMap;
125 
128 // TimerProxy theHitTimer;
129  bool runInit;
130 
132  double correctT;
134 
136  bool forceSave;
137 
138 private:
139 
143  int hcID;
145  std::map<CaloHitID,CaloG4Hit*> hitMap;
146 
147  std::map<int,TrackWithHistory*> tkMap;
149 
152  std::vector<CaloG4Hit*> reusehit;
153  std::vector<CaloG4Hit*> hitvec;
154  std::vector<unsigned int> selIndex;
156 
157 };
158 
159 #endif // SimG4CMS_CaloSD_h
G4ThreeVector setToLocal(G4ThreeVector, const G4VTouchable *)
Definition: CaloSD.cc:292
float edepositEM
Definition: CaloSD.h:120
double energyCut
Definition: CaloSD.h:122
int timeSlice
Definition: CaloSD.h:140
virtual uint32_t setDetUnitId(G4Step *step)=0
G4int emPDG
Definition: CaloSD.h:135
std::vector< PCaloHit > PCaloHitContainer
double kmaxNeutron
Definition: CaloSD.h:133
void updateHit(CaloG4Hit *)
Definition: CaloSD.cc:429
virtual void Initialize(G4HCofThisEvent *HCE)
Definition: CaloSD.cc:204
bool corrTOFBeam
Definition: CaloSD.h:131
Definition: CaloSD.h:42
list step
Definition: launcher.py:15
int totalHits
Definition: CaloSD.h:155
virtual void EndOfEvent(G4HCofThisEvent *eventHC)
Definition: CaloSD.cc:219
bool useMap
Definition: CaloSD.h:124
virtual int getTrackID(G4Track *)
Definition: CaloSD.cc:563
int hcID
Definition: CaloSD.h:143
double eminHitD
Definition: CaloSD.h:122
G4ThreeVector posGlobal
Definition: CaloSD.h:112
int primIDSaved
Definition: CaloSD.h:114
int primAncestor
Definition: CaloSD.h:150
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:133
double eminHit
Definition: CaloSD.h:122
std::vector< CaloG4Hit * > reusehit
Definition: CaloSD.h:152
G4bool checkHit()
Definition: CaloSD.cc:320
void cleanHitCollection()
Definition: CaloSD.cc:677
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:136
virtual void clearHits()
Definition: CaloSD.cc:545
virtual void DrawAll()
Definition: CaloSD.cc:233
virtual void clear()
Definition: CaloSD.cc:231
double kmaxIon
Definition: CaloSD.h:133
bool suppressHeavy
Definition: CaloSD.h:131
float edepositHAD
Definition: CaloSD.h:120
G4int epPDG
Definition: CaloSD.h:135
CaloSlaveSD * slave
Definition: CaloSD.h:142
G4int gammaPDG
Definition: CaloSD.h:135
virtual void update(const BeginOfRun *)
This routine will be called when the appropriate signal arrives.
Definition: CaloSD.cc:476
std::vector< CaloG4Hit * > hitvec
Definition: CaloSD.h:153
int getNumberOfHits()
Definition: CaloSD.cc:350
CaloHitID previousID
Definition: CaloSD.h:116
virtual void PrintAll()
Definition: CaloSD.cc:235
double getAttenuation(G4Step *aStep, double birk1, double birk2, double birk3)
Definition: CaloSD.cc:454
CaloG4Hit * currentHit
Definition: CaloSD.h:127
std::vector< unsigned int > selIndex
Definition: CaloSD.h:154
CaloMeanResponse * meanResponse
Definition: CaloSD.h:148
void storeHit(CaloG4Hit *)
Definition: CaloSD.cc:605
virtual bool filterHit(CaloG4Hit *, double)
Definition: CaloSD.cc:586
G4Track * theTrack
Definition: CaloSD.h:117
virtual G4bool getStepInfo(G4Step *aStep)
Definition: CaloSD.cc:247
double tmaxHit
Definition: CaloSD.h:122
G4StepPoint * preStepPoint
Definition: CaloSD.h:119
virtual bool ProcessHits(G4Step *step, G4TouchableHistory *tHistory)
Definition: CaloSD.cc:116
void summarize()
Definition: CaloSD.cc:652
CaloHitID currentID
Definition: CaloSD.h:116
virtual void initRun()
Definition: CaloSD.cc:561
double correctT
Definition: CaloSD.h:132
bool runInit
Definition: CaloSD.h:129
std::map< CaloHitID, CaloG4Hit * > hitMap
Definition: CaloSD.h:145
virtual ~CaloSD()
Definition: CaloSD.cc:110
CaloG4HitCollection * theHC
Definition: CaloSD.h:144
float incidentEnergy
Definition: CaloSD.h:113
double getResponseWt(G4Track *)
Definition: CaloSD.cc:596
G4THitsCollection< CaloG4Hit > CaloG4HitCollection
int checkHits
Definition: CaloSD.h:123
G4bool hitExists()
Definition: CaloSD.cc:299
std::map< int, TrackWithHistory * > tkMap
Definition: CaloSD.h:147
void resetForNewPrimary(G4ThreeVector, double)
Definition: CaloSD.cc:443
const SimTrackManager * m_trackManager
Definition: CaloSD.h:126
bool saveHit(CaloG4Hit *)
Definition: CaloSD.cc:616
CaloG4Hit * createNewHit()
Definition: CaloSD.cc:352
virtual uint16_t getDepth(G4Step *)
Definition: CaloSD.cc:584
G4ThreeVector entrancePoint
Definition: CaloSD.h:110
G4ThreeVector entranceLocal
Definition: CaloSD.h:111
int cleanIndex
Definition: CaloSD.h:151
virtual double getEnergyDeposit(G4Step *step)
Definition: CaloSD.cc:200
bool ignoreTrackID
Definition: CaloSD.h:141