Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:17:01

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // Please cite the following paper if you use this software
0027 // Nucl.Instrum.Meth.B260:20-27, 2007
0028 
0029 #include "SteppingAction.hh"
0030 #include "G4AnalysisManager.hh"
0031 #include "G4SystemOfUnits.hh"
0032 
0033 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0034 
0035 SteppingAction::SteppingAction(RunAction* run,DetectorConstruction* det)
0036 :fRun(run),fDetector(det)
0037 {}
0038 
0039 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0040 
0041 SteppingAction::~SteppingAction()
0042 {}
0043 
0044 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0045 
0046 void SteppingAction::UserSteppingAction(const G4Step* step)
0047   
0048 { 
0049 
0050 G4AnalysisManager* man = G4AnalysisManager::Instance();
0051 
0052 
0053 if  ( (step->GetTrack()->GetDynamicParticle()->GetDefinition() == 
0054        G4Proton::ProtonDefinition())
0055 
0056 /*
0057 // for doublet
0058 
0059     && (step->GetPostStepPoint()->GetPosition().z()/mm>-3230.2)
0060          && (step->GetPostStepPoint()->GetPosition().z()/mm<-3229.8) 
0061 */
0062 
0063 // for triplet and whole line
0064 
0065          && (step->GetPostStepPoint()->GetPosition().z()/mm>249.99999)
0066          && (step->GetPostStepPoint()->GetPosition().z()/mm<250.00001) 
0067          && (step->GetPreStepPoint()->GetTouchableHandle()->GetVolume()->
0068                    GetLogicalVolume()->GetName()  == fDetector->GetLogicalVol()->GetName())
0069          && (step->GetPostStepPoint()->GetTouchableHandle()->GetVolume()->
0070                   GetLogicalVolume()->GetName() == fDetector->GetLogicalWorld()->GetName())
0071     )
0072       
0073      {
0074          fXIn = step->GetPostStepPoint()->GetPosition().x();
0075          fYIn = step->GetPostStepPoint()->GetPosition().y();
0076          fZIn = step->GetPostStepPoint()->GetPosition().z();
0077          fE   = step->GetTrack()->GetKineticEnergy();
0078 
0079          G4ThreeVector angleIn;
0080          angleIn = step->GetTrack()->GetMomentumDirection();
0081 
0082          fThetaIn = std::asin(angleIn[0]/std::sqrt(angleIn[0]
0083                    *angleIn[0]+angleIn[1]*angleIn[1]+angleIn[2]*angleIn[2]));
0084          fPhiIn = std::asin(angleIn[1]/std::sqrt(angleIn[0]
0085                    *angleIn[0]+angleIn[1]*angleIn[1]+angleIn[2]*angleIn[2]));
0086 
0087          G4cout << "    =>IMAGE : X(microns)=" << fXIn/micrometer
0088                 <<" Y(microns)="<< fYIn/micrometer << " THETA(mrad)="
0089                 << (fThetaIn/mrad) << " PHI(mrad)=" << (fPhiIn/mrad) << G4endl;
0090          G4cout << G4endl;
0091 
0092          if (fDetector->GetCoef()==1) 
0093      {
0094            fRun->AddRow();
0095            fRun->AddToXVector(fXIn/um);
0096            fRun->AddToYVector(fYIn/um);
0097            fRun->AddToThetaVector(fThetaIn/mrad);
0098            fRun->AddToPhiVector(fPhiIn/mrad);
0099          }
0100 
0101      //Fill ntuple 3
0102      man->FillNtupleDColumn(3,0,fXIn/um);
0103      man->FillNtupleDColumn(3,1,fYIn/um);
0104      man->FillNtupleDColumn(3,2,fThetaIn/mrad);
0105      man->FillNtupleDColumn(3,3,fPhiIn/mrad);
0106      man->AddNtupleRow(3);
0107 
0108      }
0109 
0110 if (fDetector->GetProfile()==1) 
0111 {
0112 
0113    if  (
0114             (step->GetTrack()->GetDynamicParticle()->GetDefinition()== G4Proton::ProtonDefinition())
0115          && (step->GetPreStepPoint()->GetTouchableHandle()
0116              ->GetVolume()->GetLogicalVolume()->GetName()  == fDetector->GetLogicalVol()->GetName())
0117          && (step->GetPostStepPoint()->GetTouchableHandle()
0118             ->GetVolume()->GetLogicalVolume()->GetName() == fDetector->GetLogicalVol()->GetName()) 
0119        )
0120    {
0121          fXIn = step->GetPostStepPoint()->GetPosition().x();
0122          fYIn = step->GetPostStepPoint()->GetPosition().y();
0123          fZIn = step->GetPostStepPoint()->GetPosition().z();
0124 
0125          //Fill ntuple 1
0126      man->FillNtupleDColumn(1,0,fXIn/um);
0127      man->FillNtupleDColumn(1,1,fYIn/um);
0128      man->FillNtupleDColumn(1,2,fZIn/um);
0129      man->AddNtupleRow(1);
0130    }
0131 }
0132    
0133 if (fDetector->GetGrid()==1) 
0134 {
0135 
0136    if  (
0137             (step->GetTrack()->GetDynamicParticle()->GetDefinition()== G4Proton::ProtonDefinition())
0138          && (step->GetPreStepPoint()->GetTouchableHandle()
0139              ->GetVolume()->GetLogicalVolume()->GetName()  == fDetector->GetLogicalGrid()->GetName())
0140          && (step->GetPostStepPoint()->GetTouchableHandle()
0141              ->GetVolume()->GetLogicalVolume()->GetName() == fDetector->GetLogicalWorld()->GetName()) 
0142        )
0143    {
0144          fXIn = step->GetPostStepPoint()->GetPosition().x();
0145          fYIn = step->GetPostStepPoint()->GetPosition().y();
0146          fE   = step->GetTrack()->GetKineticEnergy();
0147 
0148      //Fill ntuple 2
0149      man->FillNtupleDColumn(2,0,fXIn/um);
0150      man->FillNtupleDColumn(2,1,fYIn/um);
0151      man->FillNtupleDColumn(2,2,fE/MeV);
0152      man->AddNtupleRow(2);
0153    }
0154  }
0155 
0156 // end
0157 }