Go to the documentation of this file.00001 #ifndef SimG4CMS_CaloSD_h
00002 #define SimG4CMS_CaloSD_h
00003
00004
00005
00006
00007
00009
00010 #include "SimG4CMS/Calo/interface/CaloG4Hit.h"
00011 #include "SimG4CMS/Calo/interface/CaloG4HitCollection.h"
00012 #include "SimG4CMS/Calo/interface/CaloMeanResponse.h"
00013 #include "SimG4Core/Notification/interface/Observer.h"
00014 #include "SimG4Core/Notification/interface/BeginOfRun.h"
00015 #include "SimG4Core/Notification/interface/BeginOfEvent.h"
00016 #include "SimG4Core/Notification/interface/BeginOfTrack.h"
00017 #include "SimG4Core/Notification/interface/EndOfTrack.h"
00018 #include "SimG4Core/Notification/interface/EndOfEvent.h"
00019 #include "SimG4Core/Notification/interface/TrackWithHistory.h"
00020 #include "SimG4Core/SensitiveDetector/interface/SensitiveCaloDetector.h"
00021 #include "SimG4Core/Application/interface/SimTrackManager.h"
00022
00023 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00024
00025
00026
00027
00028 #include "G4VPhysicalVolume.hh"
00029 #include "G4Track.hh"
00030 #include "G4VGFlashSensitiveDetector.hh"
00031
00032 #include <iostream>
00033 #include <fstream>
00034 #include <vector>
00035 #include <map>
00036
00037 class G4Step;
00038 class G4HCofThisEvent;
00039 class CaloSlaveSD;
00040 class G4GFlashSpot;
00041
00042 class CaloSD : public SensitiveCaloDetector,
00043 public G4VGFlashSensitiveDetector,
00044 public Observer<const BeginOfRun *>,
00045 public Observer<const BeginOfEvent *>,
00046 public Observer<const BeginOfTrack *>,
00047 public Observer<const EndOfTrack *>,
00048 public Observer<const EndOfEvent *> {
00049
00050 public:
00051
00052 CaloSD(G4String aSDname, const DDCompactView & cpv,
00053 SensitiveDetectorCatalog & clg,
00054 edm::ParameterSet const & p, const SimTrackManager*,
00055 int tSlice=1, bool ignoreTkID=false);
00056 virtual ~CaloSD();
00057 virtual bool ProcessHits(G4Step * step,G4TouchableHistory * tHistory);
00058 virtual bool ProcessHits(G4GFlashSpot*aSpot,G4TouchableHistory*);
00059 virtual double getEnergyDeposit(G4Step* step);
00060 virtual uint32_t setDetUnitId(G4Step* step)=0;
00061
00062 virtual void Initialize(G4HCofThisEvent * HCE);
00063 virtual void EndOfEvent(G4HCofThisEvent * eventHC);
00064 virtual void clear();
00065 virtual void DrawAll();
00066 virtual void PrintAll();
00067
00068 void fillHits(edm::PCaloHitContainer&,std::string n);
00069
00070 protected:
00071
00072 virtual G4bool getStepInfo(G4Step* aStep);
00073 G4ThreeVector setToLocal(G4ThreeVector, const G4VTouchable*);
00074 G4bool hitExists();
00075 G4bool checkHit();
00076 CaloG4Hit* createNewHit();
00077 void updateHit(CaloG4Hit*);
00078 void resetForNewPrimary(G4ThreeVector, double);
00079 double getAttenuation(G4Step* aStep, double birk1, double birk2,
00080 double birk3);
00081
00082 virtual void update(const BeginOfRun *);
00083 virtual void update(const BeginOfEvent *);
00084 virtual void update(const BeginOfTrack * trk);
00085 virtual void update(const EndOfTrack * trk);
00086 virtual void update(const ::EndOfEvent *);
00087 virtual void clearHits();
00088 virtual void initRun();
00089 virtual bool filterHit(CaloG4Hit*, double);
00090
00091 virtual int getTrackID(G4Track*);
00092 virtual uint16_t getDepth(G4Step*);
00093 double getResponseWt(G4Track*);
00094 int getNumberOfHits();
00095
00096 private:
00097
00098 void storeHit(CaloG4Hit*);
00099 bool saveHit(CaloG4Hit*);
00100 void summarize();
00101 void cleanHitCollection();
00102
00103 protected:
00104
00105
00106
00107
00108
00109
00110 G4ThreeVector entrancePoint;
00111 G4ThreeVector entranceLocal;
00112 G4ThreeVector posGlobal;
00113 float incidentEnergy;
00114 int primIDSaved;
00115
00116 CaloHitID currentID, previousID;
00117 G4Track* theTrack;
00118
00119 G4StepPoint* preStepPoint;
00120 float edepositEM, edepositHAD;
00121
00122 double energyCut, tmaxHit, eminHit, eminHitD;
00123 int checkHits;
00124 bool useMap;
00125
00126 const SimTrackManager* m_trackManager;
00127 CaloG4Hit* currentHit;
00128
00129 bool runInit;
00130
00131 bool corrTOFBeam, suppressHeavy;
00132 double correctT;
00133 double kmaxIon, kmaxNeutron, kmaxProton;
00134
00135 G4int emPDG, epPDG, gammaPDG;
00136 bool forceSave;
00137
00138 private:
00139
00140 int timeSlice;
00141 bool ignoreTrackID;
00142 CaloSlaveSD* slave;
00143 int hcID;
00144 CaloG4HitCollection* theHC;
00145 std::map<CaloHitID,CaloG4Hit*> hitMap;
00146
00147 std::map<int,TrackWithHistory*> tkMap;
00148 CaloMeanResponse* meanResponse;
00149
00150 int primAncestor;
00151 int cleanIndex;
00152 std::vector<CaloG4Hit*> reusehit;
00153 std::vector<CaloG4Hit*> hitvec;
00154 std::vector<unsigned int> selIndex;
00155 int totalHits;
00156
00157 };
00158
00159 #endif // SimG4CMS_CaloSD_h