6 modified files
slic/include
diff -u -r1.9 -r1.10
--- EventSourceManager.hh 27 Apr 2007 01:54:32 -0000 1.9
+++ EventSourceManager.hh 14 May 2008 03:24:11 -0000 1.10
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/EventSourceManager.hh,v 1.9 2007/04/27 01:54:32 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/EventSourceManager.hh,v 1.10 2008/05/14 03:24:11 jeremy Exp $
#ifndef SLIC_EVENTSOURCEMANAGER_HH
#define SLIC_EVENTSOURCEMANAGER_HH 1
@@ -100,6 +100,9 @@
G4GeneralParticleSource* getGPS();
G4ParticleGun* getParticleGun();
+ double getLorentzTransformationAngle() { return m_lorentzTransformationAngle; }
+ void setLorentzTransformationAngle( const G4double lorentzTransformationAngle ) { m_lorentzTransformationAngle = lorentzTransformationAngle; }
+
public:
virtual void GeneratePrimaryVertex(G4Event* evt);
@@ -134,6 +137,8 @@
// source type
ESourceType m_sourceType;
+
+ G4double m_lorentzTransformationAngle;
};
}
slic/include
diff -u -r1.6 -r1.7
--- GeneratorMessenger.hh 5 Sep 2006 23:21:43 -0000 1.6
+++ GeneratorMessenger.hh 14 May 2008 03:24:11 -0000 1.7
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/GeneratorMessenger.hh,v 1.6 2006/09/05 23:21:43 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/GeneratorMessenger.hh,v 1.7 2008/05/14 03:24:11 jeremy Exp $
#ifndef SLIC_GENERATORMESSENGER_HH
#define SLIC_GENERATORMESSENGER_HH 1
@@ -9,6 +9,7 @@
class G4UIcommand;
class G4UIdirectory;
class G4UIcmdWithAnInteger;
+class G4UIcmdWithADouble;
namespace slic
{
@@ -42,6 +43,7 @@
G4UIcommand* m_filenameCmd;
G4UIcommand* m_dumpCurrentEventCmd;
G4UIcommand* m_printNumEventsGeneratedCmd;
+ G4UIcmdWithADouble* m_setLorentzTransformationAngleCmd;
};
}
slic/include
diff -u -r1.21 -r1.22
--- PrimaryGeneratorAction.hh 27 Apr 2007 01:54:32 -0000 1.21
+++ PrimaryGeneratorAction.hh 14 May 2008 03:24:11 -0000 1.22
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/PrimaryGeneratorAction.hh,v 1.21 2007/04/27 01:54:32 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/PrimaryGeneratorAction.hh,v 1.22 2008/05/14 03:24:11 jeremy Exp $
#ifndef SLIC_PRIMARYGENERATORACTION_HH
#define SLIC_PRIMARYGENERATORACTION_HH 1
@@ -29,6 +29,8 @@
public:
virtual void GeneratePrimaries(G4Event *anEvent);
+ // from Mokka 06-06 PrimaryGeneratorAction
+ void applyLorentzTransformation(G4Event *anEvent);
private:
slic/src
diff -u -r1.17 -r1.18
--- EventSourceManager.cc 27 Apr 2007 01:54:34 -0000 1.17
+++ EventSourceManager.cc 14 May 2008 03:24:11 -0000 1.18
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/EventSourceManager.cc,v 1.17 2007/04/27 01:54:34 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/EventSourceManager.cc,v 1.18 2008/05/14 03:24:11 jeremy Exp $
#include "EventSourceManager.hh"
// slic
@@ -23,7 +23,8 @@
m_ngen(0),
m_nskip(0),
m_newSource(true),
- m_sourceType(eGPS)
+ m_sourceType(eGPS),
+ m_lorentzTransformationAngle(0.)
{
// messenger
m_messenger = new GeneratorMessenger();
slic/src
diff -u -r1.9 -r1.10
--- GeneratorMessenger.cc 27 Apr 2007 01:54:34 -0000 1.9
+++ GeneratorMessenger.cc 14 May 2008 03:24:11 -0000 1.10
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/GeneratorMessenger.cc,v 1.9 2007/04/27 01:54:34 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/GeneratorMessenger.cc,v 1.10 2008/05/14 03:24:11 jeremy Exp $
#include "GeneratorMessenger.hh"
// slic
@@ -11,6 +11,7 @@
#include "G4UIcommand.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithAnInteger.hh"
+#include "G4UIcmdWithADouble.hh"
// clhep
#include "CLHEP/Random/Random.h"
@@ -83,6 +84,10 @@
mgr->log() << LOG::okay << "set random seed: " << seed << LOG::done;
}
+ // Lorentz transformation angle
+ else if ( cmd == m_setLorentzTransformationAngleCmd ) {
+ EventSourceManager::instance()->setLorentzTransformationAngle( G4UIcmdWithADouble::GetNewDoubleValue( newVals ) );
+ }
else {
G4Exception("Unknown cmd for this messenger.");
}
@@ -130,5 +135,8 @@
m_randomSeedCmd->SetGuidance( "Set random seed; no argument seeds with current time. [SLIC]" );
p = new G4UIparameter( "seedValue", 'i', true );
m_randomSeedCmd->SetParameter( p );
+
+ // Lorentz transformation
+ m_setLorentzTransformationAngleCmd = new G4UIcmdWithADouble("/generator/setLorentzTransformationAngle",this);
}
}
slic/src
diff -u -r1.30 -r1.31
--- PrimaryGeneratorAction.cc 27 Apr 2007 01:54:35 -0000 1.30
+++ PrimaryGeneratorAction.cc 14 May 2008 03:24:11 -0000 1.31
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/PrimaryGeneratorAction.cc,v 1.30 2007/04/27 01:54:35 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/PrimaryGeneratorAction.cc,v 1.31 2008/05/14 03:24:11 jeremy Exp $
#include "PrimaryGeneratorAction.hh"
@@ -8,43 +8,125 @@
// slic
#include "LcioManager.hh"
#include "SlicApplication.hh"
+#include "LcioMcpManager.hh"
#include "LcioMcpFilter.hh"
#include "EventSourceManager.hh"
+// lcio
+#include "IMPL/MCParticleImpl.h"
+#include "EVENT/LCCollection.h"
+
// geant4
#include "G4StateManager.hh"
namespace slic
{
- PrimaryGeneratorAction::PrimaryGeneratorAction()
- : Module("PrimaryGeneratorAction", false)
- {}
-
- PrimaryGeneratorAction::~PrimaryGeneratorAction()
- {}
-
- void PrimaryGeneratorAction::GeneratePrimaries(G4Event *anEvent)
- {
- EventSourceManager* mgr = EventSourceManager::instance();
+ PrimaryGeneratorAction::PrimaryGeneratorAction()
+ : Module("PrimaryGeneratorAction", false)
+ {}
+
+ PrimaryGeneratorAction::~PrimaryGeneratorAction()
+ {}
+
+ void PrimaryGeneratorAction::GeneratePrimaries(G4Event *anEvent)
+ {
+ EventSourceManager* mgr = EventSourceManager::instance();
- // print begin message
+ // print begin message
#ifdef SLIC_LOG
- printBeginEventMessage( anEvent );
+ printBeginEventMessage( anEvent );
#endif
- // needs to be called here for setup purposes rather than in EventAction
- mgr->beginEvent(anEvent);
+ // needs to be called here for setup purposes rather than in EventAction
+ mgr->beginEvent(anEvent);
+
+ // delegate event generation to the manager
+ mgr->GeneratePrimaryVertex(anEvent);
- // delegate event generation to the manager
- mgr->GeneratePrimaryVertex(anEvent);
+ applyLorentzTransformation(anEvent);
- if ( mgr->isEOF() ) {
- SlicApplication::instance()->setAborting(true);
+ if ( mgr->isEOF() ) {
+ SlicApplication::instance()->setAborting(true);
+ }
}
- }
- void PrimaryGeneratorAction::printBeginEventMessage(G4Event* anEvent)
- {
- log() << LOG::okay << ">>>> BeginEvent <" << StringUtil::toString( anEvent->GetEventID() ) << ">" << LOG::done;
- }
+ void PrimaryGeneratorAction::printBeginEventMessage(G4Event* anEvent)
+ {
+ log() << LOG::okay << ">>>> BeginEvent <" << StringUtil::toString( anEvent->GetEventID() ) << ">" << LOG::done;
+ }
+
+ void PrimaryGeneratorAction::applyLorentzTransformation(G4Event *evt)
+ {
+ //const G4double alpha = Control::LorentzTransformationAngle;
+ const G4double alpha = EventSourceManager::instance()->getLorentzTransformationAngle();
+
+ if (alpha == 0) return; // nothing to do
+
+//#ifdef SLIC_LOG
+// log() << LOG::always << "applying Lorentz Transformation angle <" << alpha << LOG::done;
+//#endif
+
+ // parameters of the Lorentz transformation matrix
+ const G4double gamma = sqrt(1 + sqr(tan(alpha)));
+ const G4double betagamma = tan(alpha);
+
+ // scan through all vertices and all valid primary particles
+ for (int iVertex = 0; iVertex < evt->GetNumberOfPrimaryVertex(); iVertex++)
+ {
+ G4PrimaryVertex *vertex = evt->GetPrimaryVertex(iVertex);
+ for (int iParticle = 0; iParticle < vertex->GetNumberOfParticle(); iParticle++)
+ {
+ G4PrimaryParticle *particle = vertex->GetPrimary(iParticle);
+ // does the particle have a valid particle definition attached?
+ if (particle->GetG4code())
+ {
+ // before the transformation
+ const G4double px = particle->GetPx();
+ const G4double py = particle->GetPy();
+ const G4double pz = particle->GetPz();
+
+ //FG: take generator mass ( not necessarily euqal to PDG mass )
+ const G4double m = particle->GetMass() ;
+
+ // after the transformation (boost in x-direction)
+ const G4double pxPrime = betagamma * sqrt(sqr(px) + sqr(py) + sqr(pz) + sqr(m)) + gamma * px;
+
+ // py and pz remain the same, E changes implicitly with px
+ particle->SetMomentum(pxPrime, py, pz);
+ }
+ }
+ // the position of the vertex is not transformed here
+ }
+
+ //FG: now we need to apply the same transformation to the MCParticles:
+ EVENT::LCCollection* col = LcioMcpManager::instance()->getInitialMcpCollection();
+
+ if( col !=0 )
+ { // if particle gun is used no collection exists ...
+
+ int nMCP = col->getNumberOfElements() ;
+
+ for(int i=0; i < nMCP ; ++i )
+ {
+
+ IMPL::MCParticleImpl* mcp = dynamic_cast<IMPL::MCParticleImpl*>( col->getElementAt(i) ) ;
+
+ const double* p = mcp->getMomentum() ;
+
+ // before the transformation
+ double pPrime[3] ;
+
+ const G4double m = mcp->getMass() ;
+
+ // after the transformation (boost in x-direction)
+ pPrime[0] = betagamma * sqrt(sqr(p[0] ) + sqr(p[1] ) + sqr( p[2]) + sqr(m) ) + gamma * p[0] ;
+
+ pPrime[1] = p[1] ;
+ pPrime[2] = p[2] ;
+
+ // py and pz remain the same, E changes implicitly with px
+ mcp->setMomentum( pPrime );
+ }
+ }
+ }
}
CVSspam 0.2.8