"README" did not exist on "3f1671bc6cc1171a97ae5c750f348a88b12d3078"
Newer
Older
//====================================================================
// DDSim - LC simulation based on DD4hep
//--------------------------------------------------------------------
// F.Gaede, DESY
//====================================================================
#include "IMPL/LCCollectionVec.h"
#include "IMPL/SimTrackerHitImpl.h"
#include "IMPL/SimCalorimeterHitImpl.h"
#include "IMPL/MCParticleImpl.h"
#include "UTIL/Operators.h"
#include "UTIL/ILDConf.h"
//#include "G4lcioSimHit.h"
#include "DDG4/Geant4SensDetAction.h"
#include "DDG4/Geant4Data.h"
#include "DDG4/Geant4StepHandler.h"
#include "DD4hep/Printout.h"
#include "DD4hep/InstanceCount.h"
using namespace DD4hep::Simulation;
using namespace DD4hep;
namespace Tests {
// copied from Geant4SDActions.cpp (why is this not a public class ??????)
/// Deprecated: Simple SensitiveAction class ...
/**
* \deprecated
* \author M.Frank
* \version 1.0
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
*/
template <typename T> class Geant4SensitiveAction : public Geant4Sensitive {
protected:
typedef Geant4Sensitive Base;
/// Collection identifiers
size_t m_collectionID;
// properties:
bool _detailedHitsStoring ;
public:
// typedef SimpleHit::Contribution HitContribution;
// Standard , initializing constructor
Geant4SensitiveAction(Geant4Context* context, const std::string& name, DetElement det, LCDD& lcdd)
: Geant4Sensitive(context,name,det,lcdd), m_collectionID(0) {
declareProperty("detailedHitsStoring", _detailedHitsStoring ) ;
defineCollections();
InstanceCount::increment(this);
}
/// Default destructor
virtual ~Geant4SensitiveAction(){
InstanceCount::decrement(this);
}
/// Define collections created by this sensitivie action object
virtual void defineCollections() {}
/// G4VSensitiveDetector interface: Method invoked at the begining of each event.
virtual void begin(G4HCofThisEvent* hce) {
Base::begin(hce);
}
/// G4VSensitiveDetector interface: Method invoked at the end of each event.
virtual void end(G4HCofThisEvent* hce) {
Base::end(hce);
}
/// G4VSensitiveDetector interface: Method for generating hit(s) using the G4Step object.
virtual bool process(G4Step* step,G4TouchableHistory* history) {
return Base::process(step,history);
}
/// G4VSensitiveDetector interface: Method invoked if the event was aborted.
virtual void clear(G4HCofThisEvent* hce) {
Base::clear(hce);
}
};
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Geant4SensitiveAction<SimpleTracker>
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/// Deprecated: Simple SensitiveAction class ...
/**
* \deprecated
* \author M.Frank
* \version 1.0
*/
class LcioTestTracker {};
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/// Define collections created by this sensitivie action object
template <> void Geant4SensitiveAction<LcioTestTracker>::defineCollections() {
m_collectionID = Base::defineCollection<lcio::SimTrackerHitImpl>(m_sensitive.readout().name());
}
/// Method for generating hit(s) using the information of G4Step object.
template <> bool Geant4SensitiveAction<LcioTestTracker>::process(G4Step* step,G4TouchableHistory* /*hist*/ ) {
StepHandler h(step);
Position prePos = h.prePos();
Position postPos = h.postPos();
Position direction = postPos - prePos;
Position position = mean_direction(prePos,postPos);
double hit_len = direction.R();
if (hit_len > 0) {
double new_len = mean_length(h.preMom(),h.postMom())/hit_len;
direction *= new_len/hit_len;
}
lcio::SimTrackerHitImpl* hit = new lcio::SimTrackerHitImpl;
// (h.track->GetTrackID(),
// h.track->GetDefinition()->GetPDGEncoding(),
// step->GetTotalEnergyDeposit(),
// h.track->GetGlobalTime());
// HitContribution contrib = Hit::extractContribution(step);
VolumeID cellID = volumeID( step ) ;
hit->setCellID0( cellID & 0xffffffff ) ;
hit->setCellID1( ( cellID >> 32 ) & 0xffffffff ) ;
printout(INFO,"LcioTestTracker","%s> Add hit with deposit:%f Pos:%f %f %f - cellID0: 0x%x cellID1: 0x%x",
c_name(),step->GetTotalEnergyDeposit(),position.X(),position.Y(),position.Z() , hit->getCellID0() ,hit->getCellID1() );
double pos[3] = {position.x(), position.y(), position.z()};
hit->setPosition( pos ) ;
// hit->energyDeposit = contrib.deposit ;
// hit->position = position;
// hit->momentum = direction;
// hit->length = hit_len;
collection(m_collectionID)->add(hit);
return hit != 0;
}
typedef Geant4SensitiveAction<LcioTestTracker> LcioTestTrackerAction;
} // namespace
#include "DDG4/Factories.h"
DECLARE_GEANT4SENSITIVE_NS(Tests,LcioTestTrackerAction)