6 #include <boost/tuple/tuple.hpp>
23 #include "G4VSolid.hh"
24 #include "G4LogicalVolumeStore.hh"
25 #include "G4TouchableHistory.hh"
26 #include "G4VPhysicalVolume.hh"
27 #include "G4AffineTransform.hh"
34 const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
36 for (G4LogicalVolumeStore::const_iterator volume = lvs->begin(); volume != lvs->end(); ++volume) {
46 const G4AffineTransform&
GetTransform(
const G4TouchableHistory* touchable,
int depth)
48 return touchable->GetHistory()->GetTransform( touchable->GetHistory()->GetDepth() - depth );
59 int depth = touchable->GetHistoryDepth();
61 const G4VPhysicalVolume* volume = touchable->GetVolume(
level);
62 if (volume->GetLogicalVolume()->GetSensitiveDetector() != 0) {
63 return boost::make_tuple(volume,
level);
66 return boost::tuple<const G4VPhysicalVolume*, int>(0, 0);
77 produces< std::vector<MaterialAccountingTrack> >();
89 std::cout <<
"TrackingMaterialProducer: List of the selected volumes: " << std::endl;
91 const G4LogicalVolume* volume =
GetVolume(*volume_name);
93 std::cout <<
'\t' << *volume_name << std::endl;
97 std::cerr <<
"TrackingMaterialProducer::update(const BeginOfJob*): WARNING: selected volume \"" << *volume_name <<
"\" not found in geometry " << std::endl;
107 m_tracks =
new std::vector<MaterialAccountingTrack>();
117 G4Track* track =
const_cast<G4Track*
>((*event)());
119 track->SetTrackStatus(fStopAndKill);
127 const G4TouchableHistory* touchable = (G4TouchableHistory*)(step->GetTrack()->GetTouchable());
134 const G4Material* material = touchable->GetVolume()->GetLogicalVolume()->GetMaterial();
135 double length = step->GetStepLength() / cm;
136 double X0 = material->GetRadlen() / cm;
137 double Ne = material->GetElectronDensity() * cm3;
138 double Xi = Ne / 6.0221415e23 * 0.307075 / 2.;
139 double radiationLengths = length /
X0;
140 double energyLoss = length * Xi;
143 G4ThreeVector globalPosPre = step->GetPreStepPoint()->GetPosition();
144 G4ThreeVector globalPosPost = step->GetPostStepPoint()->GetPosition();
145 GlobalPoint globalPositionIn( globalPosPre.x() / cm, globalPosPre.y() / cm, globalPosPre.z() / cm );
146 GlobalPoint globalPositionOut( globalPosPost.x() / cm, globalPosPost.y() / cm, globalPosPost.z() / cm );
149 bool enter_sensitive =
false;
150 bool leave_sensitive =
false;
151 double cosThetaPre = 0.0;
152 double cosThetaPost = 0.0;
154 const G4VPhysicalVolume* sensitive = 0;
158 const G4VSolid & solid = *touchable->GetSolid( level );
160 G4ThreeVector
pos = transform.Inverse().TransformPoint( G4ThreeVector( 0., 0., 0. ) );
161 position =
GlobalPoint( pos.x() / cm, pos.y() / cm, pos.z() / cm );
163 G4ThreeVector localPosPre = transform.TransformPoint( globalPosPre );
164 EInside statusPre = solid.Inside( localPosPre );
165 if (statusPre == kSurface) {
166 enter_sensitive =
true;
167 G4ThreeVector globalDirPre = step->GetPreStepPoint()->GetMomentumDirection();
168 G4ThreeVector localDirPre = transform.TransformAxis( globalDirPre );
169 G4ThreeVector normalPre = solid.SurfaceNormal( localPosPre );
170 cosThetaPre = normalPre.cosTheta( -localDirPre );
173 G4ThreeVector localPosPost = transform.TransformPoint( globalPosPost );
174 EInside statusPost = solid.Inside( localPosPost );
175 if (statusPost == kSurface) {
176 leave_sensitive =
true;
177 G4ThreeVector globalDirPost = step->GetPostStepPoint()->GetMomentumDirection();
178 G4ThreeVector localDirPost = transform.TransformAxis( globalDirPost );
179 G4ThreeVector normalPost = solid.SurfaceNormal( localPosPost );
180 cosThetaPost = normalPost.cosTheta( localDirPost );
215 const G4Track * track = (*event)();
244 std::auto_ptr<std::vector<MaterialAccountingTrack> >
tracks(
m_tracks );
245 iEvent.
put( tracks );
T getParameter(std::string const &) const
#define DEFINE_SIMWATCHER(type)
const MaterialAccountingStep & summary(void)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
void produce(edm::Event &, const edm::EventSetup &)
MaterialAccountingTrack m_track
double length(void) const
Global3DPoint GlobalPoint
double radiationLengths(void) const
TrackingMaterialProducer(const edm::ParameterSet &)
double energyLoss(void) const
void step(const MaterialAccountingStep &step)
static int position[TOTALCHAMBERS][3]
std::vector< MaterialAccountingTrack > * m_tracks
std::vector< const G4LogicalVolume * > m_selectedVolumes
static const G4AffineTransform & GetTransform(const G4TouchableHistory *touchable, int depth)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
boost::tuple< const G4VPhysicalVolume *, int > GetSensitiveVolume(const G4VTouchable *touchable)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
const std::vector< MaterialAccountingDetector > & detectors()
static const G4LogicalVolume * GetVolume(const std::string &name)
void enterDetector(const G4VPhysicalVolume *volume, const GlobalPoint &position, double cosTheta)
std::vector< std::string > m_selectedNames
virtual ~TrackingMaterialProducer()
void update(const BeginOfJob *)
This routine will be called when the appropriate signal arrives.
const std::vector< MaterialAccountingStep > & steps()
void leaveDetector(const G4VPhysicalVolume *volume, double cosTheta)
bool isSelected(const G4VTouchable *touch)