source: trunk/source/digits_hits/utils/src/G4ScoringBoxParameterisation.cc @ 814

Last change on this file since 814 was 814, checked in by garnier, 16 years ago

import all except CVS

File size: 3.3 KB
Line 
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#include "G4ScoringBoxParameterisation.hh"
28
29#include "G4VPhysicalVolume.hh"
30#include "G4ThreeVector.hh"
31#include "G4Box.hh"
32
33G4ScoringBoxParameterisation::G4ScoringBoxParameterisation(EAxis segaxis,
34                                                           G4double motherDimension[3],
35                                                           std::vector<G4double> & segpos)
36  : fSegmentAxis(segaxis), fSegmentPositions(segpos) {
37
38  for(int i = 0; i < 3; i++) fMotherDimensions[i] = motherDimension[i];
39}
40
41G4ScoringBoxParameterisation::~G4ScoringBoxParameterisation() {
42  ;
43}
44
45void G4ScoringBoxParameterisation::ComputeTransformation(const G4int copyNo,
46                                                        G4VPhysicalVolume *physVol) const {
47  G4ThreeVector trans;
48
49  G4double pos;
50  if(copyNo == 0)
51    pos = fSegmentPositions[copyNo]/2.;
52  else
53    pos = (fSegmentPositions[copyNo-1] + fSegmentPositions[copyNo])/2.;
54
55  if(fSegmentAxis == kXAxis) {
56    trans[0] = pos - fMotherDimensions[0];
57  }
58  if(fSegmentAxis == kYAxis) {
59    trans[1] = pos - fMotherDimensions[1];
60  }
61  if(fSegmentAxis == kZAxis) {
62    trans[2] = pos - fMotherDimensions[2];
63  }
64
65  physVol->SetTranslation(trans);
66
67}
68
69void G4ScoringBoxParameterisation::ComputeDimensions(G4Box & meshElement,
70                                                    const G4int copyNo,
71                                                    const G4VPhysicalVolume*) const {
72
73  G4double dims[3] = {fMotherDimensions[0],fMotherDimensions[1],fMotherDimensions[2]};
74
75  G4double dim;
76  if(copyNo == 0) 
77    dim = fSegmentPositions[copyNo]/2.;
78  else
79    dim = (fSegmentPositions[copyNo] - fSegmentPositions[copyNo-1])/2.;
80
81  if(fSegmentAxis == kXAxis) {
82    dims[0] = dim;
83  }
84  if(fSegmentAxis == kYAxis) {
85    dims[1] = dim;
86  }
87  if(fSegmentAxis == kZAxis) {
88    dims[2] = dim;
89  }
90
91  meshElement.SetXHalfLength(dims[0]);
92  meshElement.SetYHalfLength(dims[1]);
93  meshElement.SetZHalfLength(dims[2]);
94}
Note: See TracBrowser for help on using the repository browser.