CMS 3D CMS Logo

CaloSD.h

Go to the documentation of this file.
00001 #ifndef SimG4CMS_CaloSD_h
00002 #define SimG4CMS_CaloSD_h
00004 // File: CaloSD.h
00005 // Description: Stores hits of calorimetric type in appropriate container
00006 // Use in your sensitive detector builder:
00007 //    CaloSD* caloSD = new CaloSD(SDname, new CaloNumberingScheme());
00009 
00010 #include "SimG4CMS/Calo/interface/CaloG4Hit.h"
00011 #include "SimG4CMS/Calo/interface/CaloG4HitCollection.h"
00012 #include "SimG4Core/Notification/interface/Observer.h"
00013 #include "SimG4Core/Notification/interface/BeginOfRun.h"
00014 #include "SimG4Core/Notification/interface/BeginOfEvent.h"
00015 #include "SimG4Core/Notification/interface/EndOfTrack.h"
00016 #include "SimG4Core/Notification/interface/EndOfEvent.h"
00017 #include "SimG4Core/Notification/interface/TrackWithHistory.h"
00018 #include "SimG4Core/SensitiveDetector/interface/SensitiveCaloDetector.h"
00019 #include "SimG4Core/Application/interface/SimTrackManager.h"
00020 
00021 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00022 
00023 // To be replaced by something else 
00024 /* #include "Utilities/Notification/interface/TimerProxy.h" */
00025  
00026 #include "G4VPhysicalVolume.hh"
00027 #include "G4Track.hh"
00028 #include "G4VGFlashSensitiveDetector.hh"
00029 
00030 #include <iostream>
00031 #include <fstream>
00032 #include <vector>
00033 #include <map>
00034 
00035 class G4Step;
00036 class G4HCofThisEvent;
00037 class CaloSlaveSD;
00038 class G4GFlashSpot;
00039 
00040 class CaloSD : public SensitiveCaloDetector, 
00041                public G4VGFlashSensitiveDetector,
00042                public Observer<const BeginOfRun *>,    
00043                public Observer<const BeginOfEvent *>,
00044                public Observer<const EndOfTrack *>,
00045                public Observer<const EndOfEvent *> {
00046 
00047 public:    
00048   
00049   CaloSD(G4String  aSDname, const DDCompactView & cpv,
00050          SensitiveDetectorCatalog & clg, 
00051          edm::ParameterSet const & p, const SimTrackManager*);
00052   virtual ~CaloSD();
00053   virtual bool   ProcessHits(G4Step * step,G4TouchableHistory * tHistory);
00054   virtual bool   ProcessHits(G4GFlashSpot*aSpot,G4TouchableHistory*);
00055   virtual double getEnergyDeposit(G4Step* step); 
00056   virtual uint32_t setDetUnitId(G4Step* step)=0;
00057   
00058   virtual void   Initialize(G4HCofThisEvent * HCE);
00059   virtual void   EndOfEvent(G4HCofThisEvent * eventHC);
00060   virtual void   clear();
00061   virtual void   DrawAll();
00062   virtual void   PrintAll();
00063 
00064   void           fillHits(edm::PCaloHitContainer&,std::string n);
00065 
00066 protected:
00067 
00068   virtual G4bool getStepInfo(G4Step* aStep);
00069   G4ThreeVector  setToLocal(G4ThreeVector, const G4VTouchable*);
00070   G4bool         hitExists();
00071   G4bool         checkHit();
00072   CaloG4Hit*     createNewHit();
00073   void           updateHit(CaloG4Hit*);
00074   void           resetForNewPrimary(G4ThreeVector, double);
00075   double         getAttenuation(G4Step* aStep, double birk1, double birk2,
00076                                 double birk3);
00077 
00078   virtual void   update(const BeginOfRun *);
00079   virtual void   update(const BeginOfEvent *);
00080   virtual void   update(const EndOfTrack * trk);
00081   virtual void   update(const ::EndOfEvent *);
00082   virtual void   clearHits();
00083   virtual void   initRun();
00084 
00085 private:
00086 
00087   void                 storeHit(CaloG4Hit*);
00088   std::pair<bool,bool> saveHit(CaloG4Hit*);
00089   void                 summarize();
00090 
00091 protected:
00092   
00093   // Data relative to primary particle (the one which triggers a shower)
00094   // These data are common to all Hits of a given shower.
00095   // One shower is made of several hits which differ by the
00096   // unit ID (crystal/fibre/scintillator) and the Time slice ID.
00097 
00098   G4ThreeVector          entrancePoint;
00099   G4ThreeVector          entranceLocal;
00100   G4ThreeVector          posGlobal;
00101   float                  incidentEnergy;
00102   int                    primIDSaved; //   ID of the last saved primary
00103 
00104   CaloHitID              currentID, previousID; 
00105   G4Track*               theTrack;
00106 
00107   G4StepPoint*           preStepPoint; 
00108   float                  edepositEM, edepositHAD;
00109 
00110   double                 energyCut, tmaxHit;
00111   int                    checkHits;
00112   bool                   useMap;
00113 
00114   const SimTrackManager* m_trackManager;
00115   CaloG4Hit*             currentHit;
00116 //  TimerProxy           theHitTimer;
00117 
00118   bool                   corrTOFBeam, suppressHeavy;
00119   double                 correctT;
00120   double                 kmaxIon, kmaxNeutron, kmaxProton;
00121 
00122   G4int                  emPDG, epPDG, gammaPDG;
00123 
00124 private:
00125 
00126   CaloSlaveSD*           slave;
00127   int                    hcID;
00128   CaloG4HitCollection*   theHC; 
00129   std::map<CaloHitID,CaloG4Hit*>  hitMap;
00130 
00131   std::vector<CaloG4Hit*>         hitvec;
00132   std::map<int,TrackWithHistory*> tkMap;
00133 
00134 };
00135 
00136 #endif // SimG4CMS_CaloSD_h

Generated on Tue Jun 9 17:46:48 2009 for CMSSW by  doxygen 1.5.4