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 | // $Id: OlapRunAction.cc,v 1.5 2006/06/29 17:23:10 gunter Exp $ |
---|
28 | // GEANT4 tag $Name: geant4-09-04-beta-01 $ |
---|
29 | // |
---|
30 | // |
---|
31 | // -------------------------------------------------------------- |
---|
32 | // OlapRunAction |
---|
33 | // |
---|
34 | // Author: Martin Liendl - Martin.Liendl@cern.ch |
---|
35 | // |
---|
36 | // -------------------------------------------------------------- |
---|
37 | // |
---|
38 | #include "OlapRunAction.hh" |
---|
39 | #include "G4UImanager.hh" |
---|
40 | #include "G4VVisManager.hh" |
---|
41 | |
---|
42 | #include "OlapManager.hh" |
---|
43 | |
---|
44 | #include "G4Run.hh" |
---|
45 | |
---|
46 | #include "globals.hh" |
---|
47 | #include <fstream> |
---|
48 | |
---|
49 | OlapRunAction::OlapRunAction() |
---|
50 | { |
---|
51 | } |
---|
52 | |
---|
53 | |
---|
54 | OlapRunAction::~OlapRunAction() |
---|
55 | { |
---|
56 | } |
---|
57 | |
---|
58 | |
---|
59 | void OlapRunAction::BeginOfRunAction(const G4Run*) |
---|
60 | { |
---|
61 | while ( !theOlaps.empty() ) |
---|
62 | { |
---|
63 | delete theOlaps.back(); |
---|
64 | theOlaps.pop_back(); |
---|
65 | } |
---|
66 | } |
---|
67 | |
---|
68 | |
---|
69 | void OlapRunAction::EndOfRunAction(const G4Run* aRun) |
---|
70 | { |
---|
71 | if (!theOlaps.size()) |
---|
72 | return; |
---|
73 | |
---|
74 | //output to screen |
---|
75 | G4cerr << "===== collected overlaps of run [" << aRun->GetRunID() << "] " |
---|
76 | << "(ol=" << theOlaps.size() << ")"<< G4endl; |
---|
77 | |
---|
78 | OlapManager::GetOlapManager()->notifyOlaps(theOlaps); |
---|
79 | |
---|
80 | std::vector<OlapInfo*>::iterator it = theOlaps.begin(); |
---|
81 | G4int i=1; |
---|
82 | while (it!=theOlaps.end()) |
---|
83 | { |
---|
84 | G4cerr << "--[" << i << "]--------------------------" << G4endl; |
---|
85 | G4cerr << "delta=" << ((*it)->v1 - (*it)->v2).mag() << G4endl; |
---|
86 | G4cerr << *(*it) << G4endl; |
---|
87 | |
---|
88 | it++; i++; |
---|
89 | } |
---|
90 | |
---|
91 | //output to file |
---|
92 | |
---|
93 | OlapLogManager * logManager = OlapLogManager::GetOlapLogManager(); |
---|
94 | if (logManager->areWeLogging || logManager->areWeLoggingByVolume) |
---|
95 | { |
---|
96 | it = theOlaps.begin(); |
---|
97 | i=1; |
---|
98 | G4String fname; |
---|
99 | |
---|
100 | if(logManager->areWeLogging) |
---|
101 | fname = logManager->filename; |
---|
102 | |
---|
103 | else if(logManager->areWeLoggingByVolume) |
---|
104 | { |
---|
105 | G4String volume; |
---|
106 | if((*it)->hist1.GetDepth() >= 1) |
---|
107 | volume = (*it)->hist1.GetVolume(1)->GetName(); |
---|
108 | else if((*it)->hist2.GetDepth() >= 1) |
---|
109 | volume = (*it)->hist2.GetVolume(1)->GetName(); |
---|
110 | else |
---|
111 | G4cerr << "error: did not get the filename" << G4endl; |
---|
112 | |
---|
113 | fname = logManager->logPath + volume + ".log"; |
---|
114 | } |
---|
115 | |
---|
116 | FILE.open(fname, std::ios::app); |
---|
117 | FILE << "===== collected overlaps of run [" << aRun->GetRunID() << "] " |
---|
118 | << "(ol=" << theOlaps.size() << ")"<< G4endl; |
---|
119 | |
---|
120 | while (it!=theOlaps.end()) { |
---|
121 | |
---|
122 | FILE << "--[" << i << "]--------------------------" << G4endl; |
---|
123 | FILE << "delta=" << ((*it)->v1 - (*it)->v2).mag() << G4endl; |
---|
124 | FILE << *(*it) << G4endl; |
---|
125 | |
---|
126 | it++; i++; |
---|
127 | } |
---|
128 | FILE << "-------------------------------------" << G4endl; |
---|
129 | FILE.close(); |
---|
130 | |
---|
131 | G4cerr << "Output has also been put into "<< fname << G4endl; |
---|
132 | }//end if |
---|
133 | |
---|
134 | G4cerr << "-------------------------------------" << G4endl; |
---|
135 | DrawOlaps(); |
---|
136 | |
---|
137 | } |
---|
138 | |
---|
139 | #include <vector> |
---|
140 | #include "G4Circle.hh" |
---|
141 | #include "G4Polyline.hh" |
---|
142 | #include "G4VisAttributes.hh" |
---|
143 | #include "G4Colour.hh" |
---|
144 | #include "G4VSolid.hh" |
---|
145 | #include "G4Box.hh" |
---|
146 | #include "G4LogicalVolume.hh" |
---|
147 | #include "OlapManager.hh" |
---|
148 | |
---|
149 | void OlapRunAction::DrawOlaps() |
---|
150 | { |
---|
151 | // iguana takes over ... |
---|
152 | } |
---|