Commit in projects/slic/branches/v00-00-01_SLIC-218-dev on MAIN
include/MCParticleManager.hh+1-12893 -> 2894
src/MCParticleManager.cc+16-362893 -> 2894
+17-37
2 modified files
correction to Z smearing which was not working

projects/slic/branches/v00-00-01_SLIC-218-dev/include
MCParticleManager.hh 2893 -> 2894
--- projects/slic/branches/v00-00-01_SLIC-218-dev/include/MCParticleManager.hh	2014-01-17 20:12:04 UTC (rev 2893)
+++ projects/slic/branches/v00-00-01_SLIC-218-dev/include/MCParticleManager.hh	2014-01-17 23:01:15 UTC (rev 2894)
@@ -98,7 +98,7 @@
 
     void applyLorentzTransformation(LCCollection*, const G4double);
 
-    void applyZSmearing(LCCollection*, const G4double);
+    G4double smearZPosition(const G4double);
 
 private:
 

projects/slic/branches/v00-00-01_SLIC-218-dev/src
MCParticleManager.cc 2893 -> 2894
--- projects/slic/branches/v00-00-01_SLIC-218-dev/src/MCParticleManager.cc	2014-01-17 20:12:04 UTC (rev 2893)
+++ projects/slic/branches/v00-00-01_SLIC-218-dev/src/MCParticleManager.cc	2014-01-17 23:01:15 UTC (rev 2894)
@@ -11,16 +11,16 @@
 
 void MCParticleManager::generateEvent(LCCollectionVec* particles, G4Event* event) {
 
+    /* Apply Z smearing to input particles. */
+    G4double z = smearZPosition(EventSourceManager::instance()->getZSmearing());
+
     /* Apply the Lorentz Transformation to input particles. */
     applyLorentzTransformation(particles, EventSourceManager::instance()->getLorentzTransformationAngle());
 
-    /* Apply Z smearing to input particles. */
-    applyZSmearing(particles, EventSourceManager::instance()->getZSmearing());
-
     /*
      * Process particles and add them to the primary vertex of the event.
      */
-    G4ThreeVector particlePosition;
+    G4ThreeVector particlePosition(0, 0, z);
     G4double particleTime;
     G4PrimaryVertex* vertex = new G4PrimaryVertex(particlePosition, particleTime);
     for(size_t i=0; i < particles->size(); i++) {
@@ -181,9 +181,7 @@
     if (alpha == 0)
         return; // nothing to do
 
-#ifdef SLIC_LOG
-        log() << LOG::name << LOG::always << "Applying Lorentz Transformation angle " << alpha << " to MCParticles." << LOG::done;
-#endif
+    G4cout << "Applying Lorentz Transformation angle: " << alpha << G4endl;
 
     // parameters of the Lorentz transformation matrix
     const G4double gamma = sqrt(1 + sqr(tan(alpha)));
@@ -204,48 +202,30 @@
 
             const G4double m = mcp->getMass();
 
+            //G4cout << "pre pX: " << p[0] << G4endl;
+
             // 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];
 
+            //G4cout << "transformed pX: " << pPrime[0] << G4endl;
+
             // py and pz remain the same, E changes implicitly with px
             mcp->setMomentum(pPrime);
         }
     }
 }
 
-void MCParticleManager::applyZSmearing(LCCollection* particles, const G4double z) {
-
-    //G4cout << "zsmear" << G4endl;
-
-    //G4cout << "got zParam = " << zParam << G4endl;
-
-    if (z == 0)
-        return;
-
-    // Generate smeared Z position.
-    double zspread = (z == 0.0 ? 0.0 : G4RandGauss::shoot(0, z/mm));
-
-    // Apply Z smearing to MCParticle collection.
-    if (particles != 0) {
-        int nMCP = particles->getNumberOfElements();
-        //G4cout << "nMCP = " << nMCP << G4endl;
-        for (int i = 0; i < nMCP; ++i) {
-            IMPL::MCParticleImpl* mcp = dynamic_cast<IMPL::MCParticleImpl*>(particles->getElementAt(i));
-            if (z != 0) {
-                const double* v = mcp->getVertex();
-                double vPrime[3];
-                vPrime[0] = v[0];
-                vPrime[1] = v[1];
-                vPrime[2] = v[2] + zspread;
-                //G4cout << "MCP.preZSmear = " << mcp->getVertex()[2] << G4endl;
-                mcp->setVertex(vPrime);
-                //G4cout << "MCP.postZSmear = " << mcp->getVertex()[2] << G4endl;
-            }
-        }
+G4double MCParticleManager::smearZPosition(const G4double rms) {
+    G4double z = 0;
+    if (rms != 0) {
+        // Generate smeared Z position.
+        z = G4RandGauss::shoot(0, rms/mm);
+        G4cout << "Smeared Z position: " << z << G4endl;
     }
+    return z;
 }
 
 };
SVNspam 0.1


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