Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

LCDG4SteppingAction Class Reference

#include <LCDG4SteppingAction.hh>

Inheritance diagram for LCDG4SteppingAction:

Inheritance graph
[legend]
Collaboration diagram for LCDG4SteppingAction:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 LCDG4SteppingAction ()
 LCDG4SteppingAction (LCDG4McPartManager *mcmgr)
virtual ~LCDG4SteppingAction ()
virtual void UserSteppingAction (const G4Step *)
void UserSteppingDebug (const G4Step *)
G4double GetTotalRadlen ()
G4double GetTotalNuclearInterLength ()
void ResetTotals ()

Private Attributes

LCDG4McPartManagerm_mcmgr
double totStepLen
double totRadLen
double totIntLen
G4VPhysicalVolume * pvol
G4LogicalVolume * lvol
bool calEntryNeeded

Constructor & Destructor Documentation

LCDG4SteppingAction::LCDG4SteppingAction  ) 
 

Definition at line 17 of file LCDG4SteppingAction.cc.

00018   : m_mcmgr(0)
00019     , totStepLen(0.0)
00020     , totRadLen(0.0)
00021     , totIntLen(0.0)
00022 {
00023 }

LCDG4SteppingAction::LCDG4SteppingAction LCDG4McPartManager mcmgr  ) 
 

Definition at line 28 of file LCDG4SteppingAction.cc.

00029   : m_mcmgr(mcmgr)
00030     , totStepLen(0.0)
00031     , totRadLen(0.0)
00032     , totIntLen(0.0)
00033 {
00034 }

LCDG4SteppingAction::~LCDG4SteppingAction  )  [virtual]
 

Definition at line 39 of file LCDG4SteppingAction.cc.

00040 {
00041 }


Member Function Documentation

G4double LCDG4SteppingAction::GetTotalNuclearInterLength  )  [inline]
 

Definition at line 24 of file LCDG4SteppingAction.hh.

References totIntLen.

00024 { return totIntLen; };

G4double LCDG4SteppingAction::GetTotalRadlen  )  [inline]
 

Definition at line 23 of file LCDG4SteppingAction.hh.

References totRadLen.

00023 { return totRadLen; };

void LCDG4SteppingAction::ResetTotals  )  [inline]
 

Definition at line 25 of file LCDG4SteppingAction.hh.

References totIntLen, and totRadLen.

00025 { totRadLen = totIntLen = 0.0; };

void LCDG4SteppingAction::UserSteppingAction const G4Step *   )  [virtual]
 

Definition at line 49 of file LCDG4SteppingAction.cc.

References calEntryNeeded, LCDG4McPartManager::GetDetType(), LCDG4Trk2McPart::GetMcPartTag(), LCDG4McPartManager::GetShowerFlag(), LCDG4McPartManager::IsInOutput(), lvol, m_mcmgr, LCDG4McPartManager::MakeLCDMcPart(), pvol, LCDG4McPartManager::SetCalorimeterEntrancePoint(), and LCDG4Trk2McPart::SetParent4Momentum().

00049                                                                    {
00050 
00051   // this should be uncommented for geantino scanning
00052 //   UserSteppingDebug(theStep);
00053 
00054   G4Track * theTrack = theStep->GetTrack();
00055 
00056   // Check whether one needs cal entrance point for this track
00057   if( theTrack->GetCurrentStepNumber() == 1) {
00058     // reset flag
00059     calEntryNeeded=false;
00060     pvol = theTrack->GetVolume();
00061     lvol = pvol->GetLogicalVolume();
00062 //     G4cout<< "Step1: trkid="<< theTrack->GetTrackID()
00063 //        <<", detType="<< m_mcmgr->GetDetType(lvol)
00064 //        <<", detName="<< pvol->GetName() << G4endl;
00065     G4int dtype = m_mcmgr->GetDetType(lvol);
00066     if( dtype < 10 || dtype > 20 ) {
00067       // if before calorimeters, we might need entrance point
00068 //       G4cout<< "*** calEntryNeeded = true"<< G4endl;
00069       calEntryNeeded=true;
00070     }
00071   }
00072 
00073   if( calEntryNeeded ) {
00074     pvol = theTrack->GetNextVolume();
00075     lvol = 0;
00076     if(pvol) lvol = pvol->GetLogicalVolume();
00077     // look for cal entrance point
00078     G4int detType = m_mcmgr->GetDetType(lvol);
00079     // All calorimeter components go from 10 to 15
00080     if( detType >= 10 && detType <= 15 ) {
00081       // save it
00082       const G4StepPoint* stepPoint = theStep->GetPostStepPoint();
00083       const G4ThreeVector pos = stepPoint->GetPosition();
00084       const Hep3Vector mom = stepPoint->GetMomentum();
00085       m_mcmgr->SetCalorimeterEntrancePoint(pos,mom);
00086       calEntryNeeded = false;
00087     }
00088   }
00089 
00090   // Look at secondaries
00091   G4TrackVector* secVec = fpSteppingManager->GetSecondary();
00092 
00093 //   G4cout<< "# of Secondaries: "<< secVec->size()
00094 //      <<": along,rest,post="<< fpSteppingManager->GetfN2ndariesAtRestDoIt()
00095 //      <<' '<< fpSteppingManager->GetfN2ndariesAlongStepDoIt()
00096 //      <<' '<< fpSteppingManager->GetfN2ndariesPostStepDoIt()
00097 //      << G4endl;
00098 
00099   G4int nSecsInStep
00100     = fpSteppingManager->GetfN2ndariesAtRestDoIt()
00101     + fpSteppingManager->GetfN2ndariesAlongStepDoIt()
00102     + fpSteppingManager->GetfN2ndariesPostStepDoIt();
00103   G4int nSecStart = secVec->size() - nSecsInStep;
00104 
00105   // loop over secondaries generated at this very last step
00106   for(int i=0; i<nSecsInStep; i++) {
00107     if( i+nSecStart<0 ) continue;
00108     G4Track* psec =(*secVec)[i+nSecStart];
00109     G4double energy = 0;
00110     if(psec) {
00111       energy = psec->GetDynamicParticle()->GetKineticEnergy();
00112     }
00113     else {
00114       G4cout <<" psec = NULL, i,nSec(Start,InStep,Rest,Along,Post,size) = "
00115              << i <<' '<< nSecStart 
00116              <<' '<< nSecsInStep 
00117              <<' '<< fpSteppingManager->GetfN2ndariesAtRestDoIt()
00118              <<' '<< fpSteppingManager->GetfN2ndariesAlongStepDoIt()
00119              <<' '<< fpSteppingManager->GetfN2ndariesPostStepDoIt()
00120              <<' '<< secVec->size()
00121              << G4endl;
00122     }
00123     if( energy>1.*MeV ) {
00124       // Get trkInfo from secondary
00125       LCDG4Trk2McPart* secInfo = (LCDG4Trk2McPart*)psec->GetUserInformation();
00126       if(secInfo==0) {
00127         LCDG4Trk2McPart* parInfo
00128           = (LCDG4Trk2McPart*)theTrack->GetUserInformation();
00129         secInfo = new LCDG4Trk2McPart( parInfo->GetMcPartTag() );
00130         psec->SetUserInformation( secInfo );
00131       }
00132       const HepLorentzVector& emom = theTrack->GetDynamicParticle()->Get4Momentum();
00133       secInfo->SetParent4Momentum( emom );
00134     }
00135   }
00136 
00137   // check particles in their first step only
00138   if( theTrack->GetCurrentStepNumber() > 1) return;
00139 
00140 //      G4cout << "Step1: "<< theTrack->GetTrackID() <<' '
00141 //         << theTrack->GetDefinition()->GetParticleName()
00142 //         << ", PreStepPt: "<< theStep->GetPreStepPoint()->GetPosition()
00143 //         << ", PostStepPt: "<< theStep->GetPostStepPoint()->GetPosition()
00144 //         << ", PreVolume: "<< theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName()
00145 //         << ", parent= "<< theTrack->GetParentID()
00146 //         << G4endl;
00147 
00148   if( theTrack->GetParentID() == 0) return;
00149 
00150   G4int parTrkID = theTrack->GetParentID();
00151 
00152   // If decay product, suggest saving it into output file
00153   // Final decision will be made by McPartManager
00154   if( theTrack->GetCreatorProcess()->GetProcessName().contains("Decay") ) {
00155 
00156 //     G4ParticleDefinition* partDef = theTrack->GetDefinition();
00157 //     G4cout << "Decay: suggesting new LCDMcPart: pvol,detType,trkid,name = "
00158 //         <<' '<< theTrack->GetVolume()->GetName()
00159 // //      <<' '<< m_mcmgr->GetDetType(lvol)
00160 //         <<' '<< theTrack->GetTrackID() <<' '<< partDef->GetParticleName()
00161 //         << G4endl;
00162 
00163     m_mcmgr->MakeLCDMcPart(theTrack);
00164     return;
00165   }
00166 
00167   // Require minimum Ekin for interaction prods, but not for decay prods
00168   if( theTrack->GetKineticEnergy() < 1.0*MeV ) return;
00169 
00170   // Require starting point to be before the calorimeters
00171   pvol = theTrack->GetVolume();
00172   lvol = 0;
00173   if(pvol) lvol = pvol->GetLogicalVolume();
00174   if( m_mcmgr->GetDetType(lvol) > 9 )  return;
00175 
00176 //   G4ParticleDefinition* partDef = theTrack->GetDefinition();
00177 //   G4cout << "Create new LCDMcPart? pvol,detType,trkid,name = "
00178 //       <<' '<< pvol->GetName() <<' '<< m_mcmgr->GetDetType(lvol)
00179 //       <<' '<< theTrack->GetTrackID()
00180 //       <<' '<< partDef->GetParticleName() << G4endl;
00181 
00182   // In order to be saved, its parent must also be saved
00183   // Check parent's showerFlag
00184   G4int showerFlag = m_mcmgr->GetShowerFlag(parTrkID);
00185   if( showerFlag==0 ) {
00186     // parent did not shower
00187 //     G4cout <<"Yes, parent has showerFlag=0" << G4endl;
00188     m_mcmgr->MakeLCDMcPart(theTrack);
00189   }
00190 
00191   else if( showerFlag==1 ) {
00192     // parent originated shower, but maybe child was produced
00193     // before parent entered the calorimeters
00194 //     G4cout <<"Maybe, parent has showerFlag==1" << G4endl;
00195     m_mcmgr->MakeLCDMcPart(theTrack);
00196   }
00197 
00198   else {
00199     // child from several generations down the showering, probably
00200     // a backscatter from the calorimeters.  Don't save into output
00201 //     G4cout <<"No, parent has showerFlag = "<< showerFlag << G4endl;
00202   }
00203 
00204   // at this point we know if the track will be saved or not
00205   // if not saved, do not bother with its calorimeter entrance point
00206   if( !m_mcmgr->IsInOutput(theTrack->GetTrackID()) ) {
00207 //     G4cout<< "Track not saved into output, resetting calEntryNeeded=false"
00208 //        << G4endl;
00209     calEntryNeeded=false;
00210   }
00211 }

void LCDG4SteppingAction::UserSteppingDebug const G4Step *   ) 
 

Definition at line 214 of file LCDG4SteppingAction.cc.

References lvol, pvol, totIntLen, totRadLen, and totStepLen.

00214                                                                   {
00215 
00216   G4Track * theTrack = theStep->GetTrack();
00217   G4VPhysicalVolume*pvol = theTrack->GetVolume();
00218   G4LogicalVolume  *lvol = pvol->GetLogicalVolume();
00219 
00220   //
00221   //  printf("%s tid=%d det=%d copyID=%d edep=%f mat(from,to)=%s %s\n"
00222   G4String matPreStep("Empty");
00223   G4Material* matAux = theStep->GetPreStepPoint()->GetMaterial();
00224   if(matAux) matPreStep = matAux->GetName();
00225 
00226   G4String matPostStep("Empty");
00227   matAux = theStep->GetPostStepPoint()->GetMaterial();
00228   if(matAux) matPostStep = matAux->GetName();
00229 
00230   printf("%s tid=%d det=%s, mat=%s %s\n"
00231           ,theTrack->GetDefinition()->GetParticleName().data()
00232           ,theTrack->GetTrackID()
00233           ,pvol->GetName().data()
00234 //      ,theStep->GetTotalEnergyDeposit()/GeV
00235 //    ,lvol->GetMaterial()->GetName().data()
00236     ,matPreStep.data()
00237     ,matPostStep.data()
00238     );
00239 
00240   G4Material* pMat = lvol->GetMaterial();
00241   printf("Mat=%s, RadLen=%12.6e, IntLen=%12.6e\n", pMat->GetName().data()
00242          ,pMat->GetRadlen(), pMat->GetNuclearInterLength());
00243 
00244   G4ThreeVector pos1 = theStep->GetPreStepPoint()->GetPosition();
00245   G4ThreeVector diff = theStep->GetPostStepPoint()->GetPosition() - pos1;
00246   G4double stepLength = diff.mag();
00247 
00248   totStepLen += stepLength;
00249   totRadLen += stepLength / pMat->GetRadlen();
00250   totIntLen += stepLength / pMat->GetNuclearInterLength();
00251 
00252   printf("Radlen(r): %12.6f %12.6f %12.6f\n\n", totStepLen, totRadLen, totIntLen);
00253 }


Member Data Documentation

bool LCDG4SteppingAction::calEntryNeeded [private]
 

Definition at line 34 of file LCDG4SteppingAction.hh.

Referenced by UserSteppingAction().

G4LogicalVolume* LCDG4SteppingAction::lvol [private]
 

Definition at line 33 of file LCDG4SteppingAction.hh.

Referenced by UserSteppingAction(), and UserSteppingDebug().

LCDG4McPartManager* LCDG4SteppingAction::m_mcmgr [private]
 

Definition at line 28 of file LCDG4SteppingAction.hh.

Referenced by UserSteppingAction().

G4VPhysicalVolume* LCDG4SteppingAction::pvol [private]
 

Definition at line 32 of file LCDG4SteppingAction.hh.

Referenced by UserSteppingAction(), and UserSteppingDebug().

double LCDG4SteppingAction::totIntLen [private]
 

Definition at line 31 of file LCDG4SteppingAction.hh.

Referenced by GetTotalNuclearInterLength(), ResetTotals(), and UserSteppingDebug().

double LCDG4SteppingAction::totRadLen [private]
 

Definition at line 30 of file LCDG4SteppingAction.hh.

Referenced by GetTotalRadlen(), ResetTotals(), and UserSteppingDebug().

double LCDG4SteppingAction::totStepLen [private]
 

Definition at line 29 of file LCDG4SteppingAction.hh.

Referenced by UserSteppingDebug().


The documentation for this class was generated from the following files:
Generated on Thu Oct 7 18:45:07 2004 for LCDG4 by doxygen 1.3.4