[807] | 1 | // |
---|
| 2 | // ******************************************************************** |
---|
| 3 | // * License and Disclaimer * |
---|
| 4 | // * * |
---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
| 7 | // * conditions of the Geant4 Software License, included in the file * |
---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
| 9 | // * include a list of copyright holders. * |
---|
| 10 | // * * |
---|
| 11 | // * Neither the authors of this software system, nor their employing * |
---|
| 12 | // * institutes,nor the agencies providing financial support for this * |
---|
| 13 | // * work make any representation or warranty, express or implied, * |
---|
| 14 | // * regarding this software system or assume any liability for its * |
---|
| 15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
| 16 | // * for the full disclaimer and the limitation of liability. * |
---|
| 17 | // * * |
---|
| 18 | // * This code implementation is the result of the scientific and * |
---|
| 19 | // * technical work of the GEANT4 collaboration. * |
---|
| 20 | // * By using, copying, modifying or distributing the software (or * |
---|
| 21 | // * any work based on the software) you agree to acknowledge its * |
---|
| 22 | // * use in resulting scientific publications, and indicate your * |
---|
| 23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
| 24 | // ******************************************************************** |
---|
| 25 | // |
---|
| 26 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 27 | // File: CCalSeppingAction.cc |
---|
| 28 | // Description: Study profiling during the steps |
---|
| 29 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 30 | #include "CCalSteppingAction.hh" |
---|
| 31 | |
---|
| 32 | #include "G4SDManager.hh" |
---|
| 33 | #include "G4StepPoint.hh" |
---|
| 34 | #include <iostream> |
---|
| 35 | #include "G4ThreeVector.hh" |
---|
| 36 | #include <cmath> |
---|
| 37 | |
---|
| 38 | #ifdef G4ANALYSIS_USE |
---|
| 39 | #include "CCalAnalysis.hh" |
---|
| 40 | #endif |
---|
| 41 | |
---|
| 42 | |
---|
| 43 | CCalSteppingAction::CCalSteppingAction(){ |
---|
| 44 | |
---|
| 45 | #ifdef G4ANALYSIS_USE |
---|
| 46 | CCalAnalysis* analysis = CCalAnalysis::getInstance(); |
---|
| 47 | timeHistoMaxBin=analysis->maxbin(); |
---|
| 48 | #else |
---|
| 49 | timeHistoMaxBin=1; |
---|
| 50 | #endif |
---|
| 51 | |
---|
| 52 | int i; |
---|
| 53 | for (i=0; i<200; i++) {timeDeposit[i] = 0.;} |
---|
| 54 | for (i=0; i<70; i++) {LateralProfile[i] = 0.;} |
---|
| 55 | |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | |
---|
| 59 | CCalSteppingAction::~CCalSteppingAction(){ |
---|
| 60 | G4cout << "CCalSteppingAction deleted" << G4endl; |
---|
| 61 | } |
---|
| 62 | |
---|
| 63 | |
---|
| 64 | void CCalSteppingAction::UserSteppingAction(const G4Step* aStep){ |
---|
| 65 | |
---|
| 66 | G4StepPoint* PostStepPoint= aStep->GetPostStepPoint(); |
---|
| 67 | G4StepPoint* PreStepPoint= aStep->GetPreStepPoint(); |
---|
| 68 | int TSliceID; |
---|
| 69 | |
---|
| 70 | TSliceID = static_cast<int>( (PostStepPoint->GetGlobalTime() ) / nanosecond); |
---|
| 71 | TSliceID = TSliceID<timeHistoMaxBin ? TSliceID : timeHistoMaxBin-1; |
---|
| 72 | timeDeposit[TSliceID] += aStep->GetTotalEnergyDeposit() / GeV; |
---|
| 73 | |
---|
| 74 | G4ThreeVector HitPoint = 0.5*(PostStepPoint->GetPosition()+ |
---|
| 75 | PreStepPoint->GetPosition()); |
---|
| 76 | // Because the beam axis has been defined as the x-axis, |
---|
| 77 | // the lateral displacement is given in terms of the y and z positions. |
---|
| 78 | double perp = std::sqrt(HitPoint.y()*HitPoint.y()+HitPoint.z()*HitPoint.z()); |
---|
| 79 | int radialPosition = std::min(69,int(perp/cm)); |
---|
| 80 | LateralProfile[radialPosition] += aStep->GetTotalEnergyDeposit() / GeV; |
---|
| 81 | |
---|
| 82 | } |
---|
| 83 | |
---|
| 84 | |
---|
| 85 | void CCalSteppingAction::endOfEvent(){ |
---|
| 86 | |
---|
| 87 | #ifdef G4ANALYSIS_USE |
---|
| 88 | CCalAnalysis* analysis = CCalAnalysis::getInstance(); |
---|
| 89 | analysis->InsertLateralProfile(LateralProfile); |
---|
| 90 | analysis->InsertTime(timeDeposit); |
---|
| 91 | #endif |
---|
| 92 | |
---|
| 93 | int i=0; |
---|
| 94 | for (i=0; i<70; i++){LateralProfile[i] = 0.;} |
---|
| 95 | for (i=0; i<200; i++){timeDeposit[i] = 0.;} |
---|
| 96 | |
---|
| 97 | } |
---|