Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-05-10 02:21:14

0001 ///////////////////////////////////////////////////////////////////////////////
0002 // File: CaloG4Hit.cc
0003 // Description: Transient Hit class for the calorimeters
0004 ///////////////////////////////////////////////////////////////////////////////
0005 #include "SimG4CMS/Calo/interface/CaloG4Hit.h"
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 #include <iostream>
0008 
0009 #include <CLHEP/Units/SystemOfUnits.h>
0010 
0011 G4ThreadLocal G4Allocator<CaloG4Hit>* fpCaloG4HitAllocator = nullptr;
0012 
0013 CaloG4Hit::CaloG4Hit() {
0014   setEntry(0., 0., 0.);
0015   setEntryLocal(0., 0., 0.);
0016   elem = 0.;
0017   hadr = 0.;
0018   theIncidentEnergy = 0.;
0019 }
0020 
0021 //CaloG4Hit::~CaloG4Hit() {}
0022 
0023 CaloG4Hit::CaloG4Hit(const CaloG4Hit& right) {
0024   entry = right.entry;
0025   entryLocal = right.entryLocal;
0026   pos = right.pos;
0027   elem = right.elem;
0028   hadr = right.hadr;
0029   theIncidentEnergy = right.theIncidentEnergy;
0030   hitID = right.hitID;
0031 }
0032 
0033 const CaloG4Hit& CaloG4Hit::operator=(const CaloG4Hit& right) {
0034   entry = right.entry;
0035   entryLocal = right.entryLocal;
0036   pos = right.pos;
0037   elem = right.elem;
0038   hadr = right.hadr;
0039   theIncidentEnergy = right.theIncidentEnergy;
0040   hitID = right.hitID;
0041 
0042   return *this;
0043 }
0044 
0045 void CaloG4Hit::addEnergyDeposit(double em, double hd) {
0046   elem += em;
0047   hadr += hd;
0048 }
0049 
0050 void CaloG4Hit::addEnergyDeposit(const CaloG4Hit& aHit) { addEnergyDeposit(aHit.getEM(), aHit.getHadr()); }
0051 
0052 void CaloG4Hit::Print() { edm::LogVerbatim("CaloSim") << (*this); }
0053 
0054 std::ostream& operator<<(std::ostream& os, const CaloG4Hit& hit) {
0055   os << " Data of this CaloG4Hit are:"
0056      << "\n"
0057      << " HitID: " << hit.getID() << "\n"
0058      << " EnergyDeposit of EM particles = " << hit.getEM() << "\n"
0059      << " EnergyDeposit of HD particles = " << hit.getHadr() << "\n"
0060      << " Energy of primary particle    = " << hit.getIncidentEnergy() / CLHEP::MeV << " (MeV)"
0061      << "\n"
0062      << " Entry point in Calorimeter (global) : " << hit.getEntry() << "   (local) " << hit.getEntryLocal() << "\n"
0063      << " Position of Hit (global) : " << hit.getPosition() << "\n"
0064      << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
0065   return os;
0066 }