9#include <beast/csi/simulation/SensitiveDetector.h>
10#include <beast/csi/dataobjects/CsiSimHit.h>
11#include <beast/csi/dataobjects/CsiHit.h>
12#include <framework/dataobjects/EventMetaData.h>
13#include <beast/csi/geometry/CsiGeometryPar.h>
14#include <framework/datastore/StoreArray.h>
15#include <framework/datastore/RelationArray.h>
16#include <framework/datastore/StoreObjPtr.h>
30 Simulation::SensitiveDetectorBase(
"CsiSensitiveDetector",
Const::invalidDetector)
53 for (
int i = 0; i < 18; i++) {
for (
int j = 0; j < 80; j++) {
CsiHitIndex[i][j] = 0;}}
88 const G4StepPoint& preStep = *aStep->GetPreStepPoint();
89 const G4StepPoint& postStep = * aStep->GetPostStepPoint();
91 G4Track& track = * aStep->GetTrack();
118 m_WightedPos += position * (aStep->GetTotalEnergyDeposit());
121 if (track.GetNextVolume() != track.GetVolume() || track.GetTrackStatus() >= fStopAndKill) {
122 int pdgCode = track.GetDefinition()->GetPDGEncoding();
124 const G4VPhysicalVolume& v = * track.GetVolume();
128 G4RotationMatrix rotCell = * v.GetObjectRotation();
130 G4ThreeVector vecCell = rotCell.colZ();
131 G4ThreeVector posCell = v.GetTranslation();
134 if (v.GetName().find(
"Crystal") != std::string::npos) {
161 G4ThreeVector PosCell,
162 G4ThreeVector VecCell)
172 ROOT::Math::XYZVector momentum(mom.getX(), mom.getY(), mom.getZ());
173 ROOT::Math::XYZVector position(pos.getX(), pos.getY(), pos.getZ());
176 simHits.
appendNew(cellId, trackID, pid, tof / CLHEP::ns, edep / CLHEP::GeV,
177 momentum * (1.0 / CLHEP::GeV), position * (1.0 / CLHEP::cm));
180 simHitRel.
add(trackID, simhitNumber);
181 B2DEBUG(150,
"Saving CsiSimHit Number: " << simhitNumber);
199 int m_currentEvnetNumber = eventMetaDataPtr->getEvent();
204 for (
int iCSICell = 0; iCSICell < 18; iCSICell++) {
205 for (
int TimeInd = 0; TimeInd < 80; TimeInd++) {
214 if ((tof / CLHEP::ns) < 8000) {
215 TimeIndex = (int)((tof / CLHEP::ns) / 100);
218 local_pos = (15. - (pos - PosCell) * VecCell);
228 double E_cell = (edep / CLHEP::GeV);
235 csiHits[
m_hitNum]->setCellId(cellId);
236 csiHits[
m_hitNum]->setEnergyDep(E_cell);
243 double old_edep = csiHits[
m_hitNum]->getEnergyDep();
244 double old_TimeAve = csiHits[
m_hitNum]->getTimeAve();
245 double old_TimeVar = csiHits[
m_hitNum]->getTimeVar();
250 double temp = E_cell + old_edep;
251 double delta =
T_ave - old_TimeAve;
252 double R = delta * E_cell / temp;
253 double new_TimeAve = old_TimeAve +
R;
254 double new_TimeVar = old_TimeVar + old_edep * delta *
R;
255 double new_edep = temp;
270 csiHits[
m_hitNum]->setEnergyDep(new_edep);
271 csiHits[
m_hitNum]->setTimeAve(new_TimeAve);
272 csiHits[
m_hitNum]->setTimeVar(new_TimeVar);
277 }
else { B2ERROR(
"m_currentEvnetNumber ERROR: m_oldEvnetNumber==m_oldEvnetNumber"); }
279 return (simhitNumber);
This class provides a set of constants for the framework.
Low-level class to create/modify relations between StoreArrays.
void add(index_type from, index_type to, weight_type weight=1.0)
Add a new element to the relation.
static void registerMCParticleRelation(const std::string &name, RelationArray::EConsolidationAction ignoreAction=RelationArray::c_negativeWeight)
Register an relation involving MCParticles.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
Accessor to arrays stored in the data store.
T * appendNew()
Construct a new T object at the end of the array.
int getEntries() const
Get the number of objects in the array.
Type-safe access to single objects in the data store.
The Class for CSI Geometry Parameters.
static CsiGeometryPar * Instance()
Static method to get a reference to the CsiGeometryPar instance.
int CsiVolNameToCellID(const G4String VolumeName)
Get Cell Id.
bool step(G4Step *aStep, G4TouchableHistory *) override
Step processing method.
int m_thetaID
The current phi ID in an event.
double m_energyDeposit
particle energy at the entrance in volume
int m_EvnetNumber
The current number of created hits in an event.
int TimeIndex
Hit Energy of StoreArray.
int m_trackID
The current number of created hits in an event.
int m_hitNum
members of SensitiveDetector
int firstcall
flight time to diode sensor
double m_endTime
global time
double T_ave
position alongthe vector of crystal axis
double local_pos
Hit Time of StoreArray.
double m_WightedTime
global time
G4ThreeVector m_momentum
Wighted step Position.
int m_cellID
The current theta ID in an event.
double m_startEnergy
global time
double m_startTime
momentum of track
int CsiHitIndex[18][80]
length of the track in the volume
int iECLCell
Hit index of StoreArray.
double m_trackLength
energy deposited in volume
G4ThreeVector m_WightedPos
Position of poststep.
int m_oldEvnetNumber
The current number of created hits in an event.
G4ThreeVector m_startPos
track id
int saveSimHit(const G4int cellId, const G4int trackID, const G4int pid, const G4double tof, const G4double edep, G4ThreeVector mom, G4ThreeVector pos, G4ThreeVector PosCell, G4ThreeVector VecCell)
Save ECLSimHits of the event into datastore.
~SensitiveDetector()
Destructor.
G4ThreeVector m_endPos
Position of prestep.
SensitiveDetector()
Constructor.
int m_phiID
flag of first call
Abstract base class for different kinds of events.