CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/SimG4CMS/Calo/interface/CaloG4Hit.h

Go to the documentation of this file.
00001 #ifndef SimG4CMS_CaloG4Hit_h
00002 #define SimG4CMS_CaloG4Hit_h 1
00003 
00004 // File: CaloG4Hit.h
00005 // Date: 10.02 Taken from CMSCaloHit
00006 // 
00007 // Hit class for Calorimeters (Ecal, Hcal, ...)
00008 //
00009 // One Hit object should be created
00010 // -for each new particle entering the calorimeter
00011 // -for each detector unit (= crystal or fibre or scintillator layer)
00012 // -for each nanosecond of the shower development
00013 //
00014 // This implies that all hit objects created for a given shower
00015 // have the same value for
00016 // - Entry (= local coordinates of the entrance point of the particle
00017 //            in the unit where the shower starts) 
00018 // - the TrackID (= Identification number of the incident particle)
00019 // - the IncidentEnergy (= energy of that particle)
00020 //
00021 // Modified: 
00022 //
00024 
00025 #include "SimG4CMS/Calo/interface/CaloHitID.h"
00026 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00027 #include "DataFormats/Math/interface/Point3D.h"
00028 #include <iostream>
00029 
00030 #include "G4Allocator.hh"
00031 #include "G4VHit.hh"
00032 
00033 class CaloG4Hit : public G4VHit {
00034   
00035 public:
00036   
00037   CaloG4Hit();
00038   ~CaloG4Hit();
00039   CaloG4Hit(const CaloG4Hit &right);
00040   const CaloG4Hit& operator=(const CaloG4Hit &right);
00041   bool operator==(const CaloG4Hit &){return false;}
00042   inline void * operator new(size_t);
00043   inline void   operator delete(void * CaloG4Hit);
00044 
00045   void         Draw(){}
00046   void         Print();
00047   
00048 public:
00049   
00050   math::XYZPoint getEntry() const              {return entry;}
00051   void           setEntry(double x, double y, double z)      {entry.SetCoordinates(x,y,z);}
00052   
00053   math::XYZPoint getEntryLocal() const         {return entryLocal;}
00054   void           setEntryLocal(double x, double y, double z) {entryLocal.SetCoordinates(x,y,z);}
00055   
00056   math::XYZPoint getPosition() const           {return pos;}
00057   void           setPosition(double x, double y, double z)   {pos.SetCoordinates(x,y,z);}
00058   
00059   double         getEM() const                 {return elem;}
00060   void           setEM (double e)              {elem = e;}
00061   
00062   double         getHadr() const               {return hadr;}
00063   void           setHadr (double e)            {hadr = e;}
00064   
00065   double         getIncidentEnergy() const     {return theIncidentEnergy;}
00066   void           setIncidentEnergy (double e)  {theIncidentEnergy = e;}
00067   
00068   int            getTrackID() const            {return hitID.trackID();}
00069   uint32_t       getUnitID() const             {return hitID.unitID();}
00070   double         getTimeSlice() const          {return hitID.timeSlice();}
00071   int            getTimeSliceID() const        {return hitID.timeSliceID();}
00072   uint16_t       getDepth() const              {return hitID.depth();}
00073 
00074   CaloHitID      getID() const                 {return hitID;}
00075   void           setID (uint32_t i, double d, int j, uint16_t k=0) { hitID.setID(i,d,j,k);}
00076   void           setID (CaloHitID id)          {hitID = id;}
00077   
00078   void           addEnergyDeposit(double em, double hd);
00079   void           addEnergyDeposit(const CaloG4Hit& aHit);
00080   
00081   double         getEnergyDeposit() const      {return (elem+hadr);}
00082   
00083 private:
00084   
00085   math::XYZPoint   entry;             //Entry point (Global coordinate)
00086   math::XYZPoint   entryLocal;        //Entry point (Local  coordinate)
00087   math::XYZPoint   pos;               //Position    (Global coordinate)
00088   double           elem;              //EnergyDeposit of EM particles
00089   double           hadr;              //EnergyDeposit of HD particles
00090   double           theIncidentEnergy; //Energy of the primary particle
00091   CaloHitID        hitID;             //Identification number of the hit given 
00092                                       //by primary particle, Cell ID, Time of 
00093                                       //the hit
00094 };
00095 
00096 class CaloG4HitLess {
00097 public:
00098   bool operator()( const CaloG4Hit* a, const CaloG4Hit* b) {
00099     if (a->getTrackID() != b->getTrackID()) {
00100       return (a->getTrackID() < b->getTrackID());
00101     } else if (a->getUnitID() != b->getUnitID()) {
00102       return (a->getUnitID() < b->getUnitID());
00103     } else if (a->getDepth() != b->getDepth()) {
00104       return (a->getDepth() < b->getDepth());
00105     } else {
00106       return (a->getTimeSliceID() < b->getTimeSliceID());
00107     }
00108   }
00109 };
00110 
00111 class CaloG4HitEqual {
00112 public:
00113   bool operator()( const CaloG4Hit* a, const CaloG4Hit* b) {
00114     return (a->getTrackID()     == b->getTrackID() && 
00115             a->getUnitID()      == b->getUnitID()  && 
00116             a->getDepth()       == b->getDepth()   &&
00117             a->getTimeSliceID() == b->getTimeSliceID());
00118   }
00119 };
00120 
00121 extern G4Allocator<CaloG4Hit> CaloG4HitAllocator;
00122 
00123 inline void * CaloG4Hit::operator new(size_t) {
00124   void * aHit;
00125   aHit = (void *) CaloG4HitAllocator.MallocSingle();
00126   return aHit;
00127 }
00128 
00129 inline void CaloG4Hit::operator delete(void * aHit) {  
00130   CaloG4HitAllocator.FreeSingle((CaloG4Hit*) aHit); 
00131 }
00132 
00133 std::ostream& operator<<(std::ostream&, const CaloG4Hit&);
00134 
00135 #endif