#include <HFWedgeSD.h>
Public Member Functions | |
virtual void | clear () |
virtual void | DrawAll () |
virtual void | EndOfEvent (G4HCofThisEvent *eventHC) |
HFWedgeSD (std::string name, const DDCompactView &cpv, SensitiveDetectorCatalog &clg, edm::ParameterSet const &p, const SimTrackManager *) | |
virtual void | Initialize (G4HCofThisEvent *HCE) |
virtual void | PrintAll () |
virtual bool | ProcessHits (G4Step *step, G4TouchableHistory *tHistory) |
virtual | ~HFWedgeSD () |
Protected Member Functions | |
virtual void | clearHits () |
HFShowerG4Hit * | createNewHit () |
virtual void | fillHits (edm::PCaloHitContainer &, std::string) |
G4bool | hitExists () |
virtual uint32_t | setDetUnitId (G4Step *) |
void | updateHit (HFShowerG4Hit *) |
Private Attributes | |
HFShowerG4Hit * | currentHit |
int | currentID |
double | edep |
G4ThreeVector | globalPos |
int | hcID |
std::map< int, HFShowerG4Hit * > | hitMap |
G4ThreeVector | localPos |
const SimTrackManager * | m_trackManager |
G4ThreeVector | momDir |
int | previousID |
HFShowerG4HitsCollection * | theHC |
std::string | theName |
double | time |
int | trackID |
Definition at line 22 of file HFWedgeSD.h.
HFWedgeSD::HFWedgeSD | ( | std::string | name, |
const DDCompactView & | cpv, | ||
SensitiveDetectorCatalog & | clg, | ||
edm::ParameterSet const & | p, | ||
const SimTrackManager * | manager | ||
) |
Definition at line 16 of file HFWedgeSD.cc.
References SensitiveDetector::AssignSD(), ecaldqm::collectionName, LogDebug, SensitiveDetectorCatalog::logicalNames(), and SensitiveDetector::Register().
: SensitiveCaloDetector(name, cpv, clg, p), theName(name), m_trackManager(manager), hcID(-1), theHC(0), currentHit(0) { collectionName.insert(name); LogDebug("FiberSim") << "***************************************************" << "\n" << "* *" << "\n" << "* Constructing a HFWedgeSD with name " << GetName() << "\n" << "* *" << "\n" << "***************************************************"; // // Now attach the right detectors (LogicalVolumes) to me // std::vector<std::string> lvNames = clg.logicalNames(name); this->Register(); for (std::vector<std::string>::iterator it=lvNames.begin(); it !=lvNames.end(); it++){ this->AssignSD(*it); LogDebug("FiberSim") << "HFWedgeSD : Assigns SD to LV " << (*it); } }
HFWedgeSD::~HFWedgeSD | ( | ) | [virtual] |
void HFWedgeSD::clear | ( | void | ) | [virtual] |
void HFWedgeSD::clearHits | ( | ) | [protected, virtual] |
Implements SensitiveDetector.
Definition at line 140 of file HFWedgeSD.cc.
References hitMap, and previousID.
Referenced by Initialize().
{ hitMap.erase (hitMap.begin(), hitMap.end()); previousID = -1; }
HFShowerG4Hit * HFWedgeSD::createNewHit | ( | ) | [protected] |
Definition at line 108 of file HFWedgeSD.cc.
References currentID, edep, globalPos, hitMap, localPos, LogDebug, momDir, previousID, HFShowerG4Hit::setGlobalPos(), HFShowerG4Hit::setHitId(), HFShowerG4Hit::setLocalPos(), HFShowerG4Hit::setPrimMomDir(), HFShowerG4Hit::setTime(), HFShowerG4Hit::setTrackId(), theHC, time, trackID, and updateHit().
Referenced by ProcessHits().
{ LogDebug("FiberSim") << "HFWedgeSD::CreateNewHit for ID " << currentID << " Track " << trackID << " Edep: " << edep/MeV << " MeV; Time: " << time << " ns; Position (local) " << localPos << " (global ) " << globalPos << " direction " << momDir; HFShowerG4Hit* aHit = new HFShowerG4Hit; aHit->setHitId(currentID); aHit->setTrackId(trackID); aHit->setTime(time); aHit->setLocalPos(localPos); aHit->setGlobalPos(globalPos); aHit->setPrimMomDir(momDir); updateHit(aHit); theHC->insert(aHit); hitMap.insert(std::pair<int,HFShowerG4Hit*>(previousID,aHit)); return aHit; }
void HFWedgeSD::DrawAll | ( | ) | [virtual] |
Definition at line 87 of file HFWedgeSD.cc.
{}
void HFWedgeSD::EndOfEvent | ( | G4HCofThisEvent * | eventHC | ) | [virtual] |
Reimplemented from SensitiveDetector.
Definition at line 79 of file HFWedgeSD.cc.
void HFWedgeSD::fillHits | ( | edm::PCaloHitContainer & | , |
std::string | |||
) | [protected, virtual] |
G4bool HFWedgeSD::hitExists | ( | ) | [protected] |
Definition at line 91 of file HFWedgeSD.cc.
References currentHit, currentID, hitMap, previousID, and updateHit().
Referenced by ProcessHits().
{ // Update if in the same detector, time-slice and for same track if (currentID == previousID) { updateHit(currentHit); return true; } std::map<int,HFShowerG4Hit*>::const_iterator it = hitMap.find(currentID); if (it != hitMap.end()) { updateHit(currentHit); return true; } return false; }
void HFWedgeSD::Initialize | ( | G4HCofThisEvent * | HCE | ) | [virtual] |
Reimplemented from SensitiveDetector.
Definition at line 48 of file HFWedgeSD.cc.
References clearHits(), ecaldqm::collectionName, hcID, LogDebug, and theHC.
{ LogDebug("FiberSim") << "HFWedgeSD : Initialize called for " << GetName(); theHC = new HFShowerG4HitsCollection(GetName(), collectionName[0]); if (hcID<0) hcID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]); HCE->AddHitsCollection(hcID, theHC); clearHits(); }
void HFWedgeSD::PrintAll | ( | ) | [virtual] |
Definition at line 89 of file HFWedgeSD.cc.
{}
G4bool HFWedgeSD::ProcessHits | ( | G4Step * | step, |
G4TouchableHistory * | tHistory | ||
) | [virtual] |
Implements SensitiveDetector.
Definition at line 59 of file HFWedgeSD.cc.
References createNewHit(), currentHit, currentID, edep, globalPos, hitExists(), localPos, momDir, setDetUnitId(), time, and trackID.
{ G4StepPoint* preStepPoint = aStep->GetPreStepPoint(); const G4VTouchable* touch = preStepPoint->GetTouchable(); currentID = setDetUnitId(aStep); trackID = aStep->GetTrack()->GetTrackID(); edep = aStep->GetTotalEnergyDeposit(); time = (preStepPoint->GetGlobalTime())/ns; globalPos = preStepPoint->GetPosition(); localPos = touch->GetHistory()->GetTopTransform().TransformPoint(globalPos); const G4DynamicParticle* particle = aStep->GetTrack()->GetDynamicParticle(); momDir = particle->GetMomentumDirection(); if (hitExists() == false && edep>0.) currentHit = createNewHit(); return true; }
uint32_t HFWedgeSD::setDetUnitId | ( | G4Step * | aStep | ) | [protected, virtual] |
Implements SensitiveDetector.
Definition at line 145 of file HFWedgeSD.cc.
Referenced by ProcessHits().
{ const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable(); return (touch->GetReplicaNumber(0)); }
void HFWedgeSD::updateHit | ( | HFShowerG4Hit * | aHit | ) | [protected] |
Definition at line 130 of file HFWedgeSD.cc.
References currentID, edep, LogDebug, previousID, and HFShowerG4Hit::updateEnergy().
Referenced by createNewHit(), and hitExists().
{ if (edep != 0) { aHit->updateEnergy(edep); LogDebug("FiberSim") << "HFWedgeSD: Add energy deposit in " << currentID << " edep " << edep/MeV << " MeV"; } previousID = currentID; }
HFShowerG4Hit* HFWedgeSD::currentHit [private] |
Definition at line 61 of file HFWedgeSD.h.
Referenced by hitExists(), and ProcessHits().
int HFWedgeSD::currentID [private] |
Definition at line 58 of file HFWedgeSD.h.
Referenced by createNewHit(), hitExists(), ProcessHits(), and updateHit().
double HFWedgeSD::edep [private] |
Definition at line 59 of file HFWedgeSD.h.
Referenced by createNewHit(), ProcessHits(), and updateHit().
G4ThreeVector HFWedgeSD::globalPos [private] |
Definition at line 60 of file HFWedgeSD.h.
Referenced by createNewHit(), and ProcessHits().
int HFWedgeSD::hcID [private] |
Definition at line 54 of file HFWedgeSD.h.
Referenced by Initialize().
std::map<int,HFShowerG4Hit*> HFWedgeSD::hitMap [private] |
Definition at line 56 of file HFWedgeSD.h.
Referenced by clearHits(), createNewHit(), and hitExists().
G4ThreeVector HFWedgeSD::localPos [private] |
Definition at line 60 of file HFWedgeSD.h.
Referenced by createNewHit(), and ProcessHits().
const SimTrackManager* HFWedgeSD::m_trackManager [private] |
Definition at line 52 of file HFWedgeSD.h.
G4ThreeVector HFWedgeSD::momDir [private] |
Definition at line 60 of file HFWedgeSD.h.
Referenced by createNewHit(), and ProcessHits().
int HFWedgeSD::previousID [private] |
Definition at line 58 of file HFWedgeSD.h.
Referenced by clearHits(), createNewHit(), hitExists(), and updateHit().
HFShowerG4HitsCollection* HFWedgeSD::theHC [private] |
Definition at line 55 of file HFWedgeSD.h.
Referenced by createNewHit(), EndOfEvent(), Initialize(), and ~HFWedgeSD().
std::string HFWedgeSD::theName [private] |
Definition at line 51 of file HFWedgeSD.h.
double HFWedgeSD::time [private] |
Definition at line 59 of file HFWedgeSD.h.
Referenced by createNewHit(), and ProcessHits().
int HFWedgeSD::trackID [private] |
Definition at line 58 of file HFWedgeSD.h.
Referenced by createNewHit(), and ProcessHits().