Author: [log in to unmask] Date: Tue Apr 7 16:34:46 2015 New Revision: 3585 Log: committing first version of the ScintillatorCalorimeterHitProcessor Added: projects/lcdd/branches/scintillatorHCAL/include/lcdd/detectors/ScintillatorCalorimeterHitProcessor.hh projects/lcdd/branches/scintillatorHCAL/src/lcdd/detectors/ScintillatorCalorimeterHitProcessor.cc Modified: projects/lcdd/branches/scintillatorHCAL/src/lcdd/detectors/HitProcessorManager.cc Added: projects/lcdd/branches/scintillatorHCAL/include/lcdd/detectors/ScintillatorCalorimeterHitProcessor.hh ============================================================================= --- projects/lcdd/branches/scintillatorHCAL/include/lcdd/detectors/ScintillatorCalorimeterHitProcessor.hh (added) +++ projects/lcdd/branches/scintillatorHCAL/include/lcdd/detectors/ScintillatorCalorimeterHitProcessor.hh Tue Apr 7 16:34:46 2015 @@ -0,0 +1,55 @@ +#ifndef LCDD_DETECTORS_SCINTILLATORCALORIMETERHITPROCESSOR_HH_ +#define LCDD_DETECTORS_SCINTILLATORCALORIMETERHITPROCESSOR_HH_ 1 + +// LCDD +#include "lcdd/detectors/CalorimeterHitProcessor.hh" +#include "lcdd/detectors/CalorimeterSD.hh" +#include "lcdd/detectors/HitProcessorFactory.hh" +#include "G4EmSaturation.hh" + +/** + * @brief + * Implementation of hit processing behavior for CalorimeterSD objects with Segmentation. + */ +class ScintillatorCalorimeterHitProcessor: public CalorimeterHitProcessor { +private: + G4EmSaturation* m_emSaturation; + +public: + + /** + * Class constructor. + */ + ScintillatorCalorimeterHitProcessor(); + + /** + * Class destructor. + */ + virtual ~ScintillatorCalorimeterHitProcessor(); + + /** + * Process steps to produce hits. + * @param[in] step A G4Step object. + */ + bool processHits(G4Step* step); +}; + +/** + * @brief + * The factory for creating new BasicCalorimeterHitProcessor objects + */ +class ScintillatorCalorimeterHitProcessorFactory: public HitProcessorFactory { + +public: + + HitProcessor* createHitProcessor() { + return new ScintillatorCalorimeterHitProcessor(); + } + + const std::string& handlesType() { + static std::string typeName = "ScintillatorCalorimeterHitProcessor"; + return typeName; + } +}; + +#endif Modified: projects/lcdd/branches/scintillatorHCAL/src/lcdd/detectors/HitProcessorManager.cc ============================================================================= --- projects/lcdd/branches/scintillatorHCAL/src/lcdd/detectors/HitProcessorManager.cc (original) +++ projects/lcdd/branches/scintillatorHCAL/src/lcdd/detectors/HitProcessorManager.cc Tue Apr 7 16:34:46 2015 @@ -2,6 +2,7 @@ // LCDD #include "lcdd/detectors/BasicCalorimeterHitProcessor.hh" +#include "lcdd/detectors/ScintillatorCalorimeterHitProcessor.hh" #include "lcdd/detectors/BasicTrackerHitProcessor.hh" #include "lcdd/detectors/ScoringTrackerHitProcessor.hh" #include "lcdd/detectors/DDSegmentationCalorimeterHitProcessor.hh" @@ -24,6 +25,7 @@ void HitProcessorManager::registerDefaultFactories() { registerFactory(new BasicCalorimeterHitProcessorFactory()); + registerFactory(new ScintillatorCalorimeterHitProcessorFactory()); registerFactory(new ScoringTrackerHitProcessorFactory()); registerFactory(new BasicTrackerHitProcessorFactory()); Added: projects/lcdd/branches/scintillatorHCAL/src/lcdd/detectors/ScintillatorCalorimeterHitProcessor.cc ============================================================================= --- projects/lcdd/branches/scintillatorHCAL/src/lcdd/detectors/ScintillatorCalorimeterHitProcessor.cc (added) +++ projects/lcdd/branches/scintillatorHCAL/src/lcdd/detectors/ScintillatorCalorimeterHitProcessor.cc Tue Apr 7 16:34:46 2015 @@ -0,0 +1,88 @@ +#include "lcdd/detectors/ScintillatorCalorimeterHitProcessor.hh" + +// LCDD +#include "lcdd/detectors/CurrentTrackState.hh" +#include "lcdd/util/TimerUtil.hh" + +// Geant4 +#include "G4Geantino.hh" +#include "G4ChargedGeantino.hh" + +ScintillatorCalorimeterHitProcessor::ScintillatorCalorimeterHitProcessor() { + m_emSaturation = new G4EmSaturation(0); +} + +ScintillatorCalorimeterHitProcessor::~ScintillatorCalorimeterHitProcessor() { +} + +bool ScintillatorCalorimeterHitProcessor::processHits(G4Step* step) { + + // Get the energy deposition. + // G4double edep = step->GetTotalEnergyDeposit(); + // edep with Birks' law: + G4double edep = m_emSaturation->VisibleEnergyDeposition(step); + + + // Mokka code: + // G4double energyDeposition = aStep->GetTotalEnergyDeposit(); + // G4double length = aStep->GetStepLength(); + // G4double niel = 0.; //aStep->GetNonIonisingEnergyDeposit(); //FIXME + // const G4Track* track = aStep->GetTrack(); + // const G4ParticleDefinition* particle = track->GetDefinition(); + // const G4MaterialCutsCouple* couple = track->GetMaterialCutsCouple(); + // + // G4double engyVis = emSaturation->VisibleEnergyDeposition(particle, + // couple, + // length, + // energyDeposition, + // niel); + + // Check for Geantino particle type. + G4ParticleDefinition* def = step->GetTrack()->GetDefinition(); + bool isGeantino = false; + if (def == G4Geantino::Definition() || def == G4ChargedGeantino::Definition()) { + isGeantino = true; + } + + // Cut on energy deposition <= cut but allow Geantinos. + if (edep <= _calorimeter->getEnergyCut() && isGeantino == false) { + return false; + } + + // Get the Segmentation from the CalorimeterSD. + Segmentation* segmentation = _calorimeter->getSegmentation(); + + // Get the global cell position from the Segmentation. + G4ThreeVector globalCellPosition = segmentation->getGlobalHitPosition(step); + + // Set the segmentation bin values from the step. + segmentation->setBins(step); + + // Create a 64-bit ID from the step information. + Id64bit id = _calorimeter->makeIdentifier(step); + + // Check for an existing hit with this identifier. + CalorimeterHit* hit = _calorimeter->findHit(id); + + // Was there a hit found with this identifier? + if (hit == NULL) { + + // No hit was found, so a new one is created. + hit = new CalorimeterHit(id, edep, globalCellPosition); + + // Add the new hit to the calorimeter. + _calorimeter->addHit(hit, _collectionIndex); + + } else { + + // Add energy deposition to an existing hit. + hit->addEdep(edep); + } + + // Add hit contribution to the hit. + // FIXME: This should pass a pointer to a new object. It is copied, which is inefficient. + hit->addHitContribution(HitContribution(CurrentTrackState::getCurrentTrackID(), step)); + + // Return true, indicating that a hit was added or modified. + return true; +} ######################################################################## Use REPLY-ALL to reply to list To unsubscribe from the LCDET-SVN list, click the following link: https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCDET-SVN&A=1