| [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 | // $Id: TiaraTally.cc,v 1.5 2006/06/29 15:45:37 gunter Exp $
|
|---|
| 27 | // GEANT4 tag $Name: $
|
|---|
| 28 | //
|
|---|
| 29 |
|
|---|
| 30 | #include "TiaraTally.hh"
|
|---|
| 31 |
|
|---|
| 32 | TiaraTally::TiaraTally() :
|
|---|
| 33 | fBinEdges(),
|
|---|
| 34 | fLowestEdge(0),
|
|---|
| 35 | fMapHighEdgeToMeasure()
|
|---|
| 36 | {}
|
|---|
| 37 |
|
|---|
| 38 | TiaraTally::~TiaraTally()
|
|---|
| 39 | {}
|
|---|
| 40 |
|
|---|
| 41 | void TiaraTally::setBinEdges(const std::vector<double> & binEdges){
|
|---|
| 42 | fBinEdges = binEdges;
|
|---|
| 43 | if (fBinEdges.size() < 2) {
|
|---|
| 44 | G4Exception("ERROR in TiaraTally::setBinEdges: binEdges.size() < 2");
|
|---|
| 45 | }
|
|---|
| 46 | fLowestEdge = fBinEdges[0];
|
|---|
| 47 | std::vector<double>::iterator binIt = fBinEdges.begin();
|
|---|
| 48 | binIt++;
|
|---|
| 49 | for (;binIt != fBinEdges.end(); ++binIt) {
|
|---|
| 50 | std::vector<double>::iterator testIt = binIt;
|
|---|
| 51 | if (! (*binIt > *(--testIt))) {
|
|---|
| 52 | G4Exception("ERROR in TiaraTally::setBinEdges: binEdges not in ascending order");
|
|---|
| 53 | }
|
|---|
| 54 |
|
|---|
| 55 | std::pair<G4double, TiaraMeasure > myPair(0, TiaraMeasure());
|
|---|
| 56 | fMapHighEdgeToMeasure[*binIt] = myPair;
|
|---|
| 57 | }
|
|---|
| 58 | }
|
|---|
| 59 |
|
|---|
| 60 | void TiaraTally::fill(G4double x, G4double w){
|
|---|
| 61 | if (x>fLowestEdge) {
|
|---|
| 62 | for (TiaraTallyData::iterator dataIt = fMapHighEdgeToMeasure.begin();
|
|---|
| 63 | dataIt != fMapHighEdgeToMeasure.end(); dataIt++) {
|
|---|
| 64 | if (x < dataIt->first) {
|
|---|
| 65 | dataIt->second.first += w;
|
|---|
| 66 | break;
|
|---|
| 67 | }
|
|---|
| 68 | }
|
|---|
| 69 | }
|
|---|
| 70 | }
|
|---|
| 71 |
|
|---|
| 72 | void TiaraTally::EndOfEventAction() {
|
|---|
| 73 | for (TiaraTallyData::iterator dataIt = fMapHighEdgeToMeasure.begin();
|
|---|
| 74 | dataIt != fMapHighEdgeToMeasure.end(); dataIt++) {
|
|---|
| 75 | dataIt->second.second.Xin(dataIt->second.first);
|
|---|
| 76 | dataIt->second.first = 0;
|
|---|
| 77 | }
|
|---|
| 78 | }
|
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 | TiaraMeasure TiaraTally::measure(G4int i){
|
|---|
| 82 | TiaraMeasure m;
|
|---|
| 83 | if (i<0 || i>(G4int)(fMapHighEdgeToMeasure.size()-1)) {
|
|---|
| 84 | G4cout << "ERROR in TiaraTally::measure: argument: " << i
|
|---|
| 85 | << ", out of range!" << G4endl;
|
|---|
| 86 | }
|
|---|
| 87 | else {
|
|---|
| 88 | G4int k(0);
|
|---|
| 89 | for (TiaraTallyData::iterator dataIt = fMapHighEdgeToMeasure.begin();
|
|---|
| 90 | dataIt != fMapHighEdgeToMeasure.end(); dataIt++) {
|
|---|
| 91 | if (i==k++) {
|
|---|
| 92 | m = dataIt->second.second;
|
|---|
| 93 | break;
|
|---|
| 94 | }
|
|---|
| 95 | }
|
|---|
| 96 | }
|
|---|
| 97 | return m;
|
|---|
| 98 | }
|
|---|
| 99 |
|
|---|
| 100 | std::vector<double> TiaraTally::binEdges(){
|
|---|
| 101 | return fBinEdges;
|
|---|
| 102 | }
|
|---|
| 103 |
|
|---|
| 104 | G4int TiaraTally::size() {
|
|---|
| 105 | return fMapHighEdgeToMeasure.size();
|
|---|
| 106 | }
|
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 |
|
|---|