Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
CCalRunAction.cc
이 파일의 문서화 페이지로 가기
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 //
27 // File: CCalRunAction.cc
28 // Description: A class for providing user actions at begin and end of run
30 #include "CCalRunAction.hh"
31 
32 #include "globals.hh"
33 #include "G4Run.hh"
34 
35 #include "G4UImanager.hh"
36 #include "G4VVisManager.hh"
37 #include "G4ios.hh"
38 
39 #include "CCalAnalysis.hh"
40 
41 
43 {
44 
45  G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
46  numberOfTimeSlices = 200;
47 
48  // A.R. Added for visualization of events.
51  UI->ApplyCommand("/vis/scene/notifyHandlers");
52  }
53 
54  if (aRun->GetRunID() == 0) //first run
55  Book();
56 
57 
58  G4AnalysisManager* analysis = G4AnalysisManager::Instance();
59  //cleanup
60  G4int timeHist = analysis->GetH1Id("h300");
61  for (int i=0; i<numberOfTimeSlices; i++)
62  analysis->GetH1(timeHist+i)->reset();
63 
64 }
65 
66 
68 {
69  G4cout << "### Run " << aRun->GetRunID() << " end." << G4endl;
70 
71  // A.R. Added for visualization of events.
73  G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/update");
74  }
75 }
76 
78 {
79  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
80  analysisManager->SetVerboseLevel(1);
81  analysisManager->SetFirstHistoId(1);
82  analysisManager->SetFirstNtupleId(1);
83 
84  // Open an output file
85  analysisManager->OpenFile("ccal");
86  G4cout << "********************************************" << G4endl
87  << "* o/p file ccal" << G4endl
88  << "********************************************" << G4endl
89  << G4endl;
90 
91 
92  // Create a tuple :
93  // Create ntuple
94  analysisManager->CreateNtuple("ntuple1", "Event info");
95  for (int i=0;i<28;i++) {
96  G4String tupleidString = "hcal" + std::to_string( i );
97  analysisManager->CreateNtupleFColumn( tupleidString.c_str() );
98  }
99  for (int i=0; i<49; i++) {
100  G4String tupleidString = "ecal" + std::to_string( i );
101  analysisManager->CreateNtupleFColumn( tupleidString.c_str() );
102  }
103  analysisManager->CreateNtupleFColumn("ELAB");
104  analysisManager->CreateNtupleFColumn("XPOS");
105  analysisManager->CreateNtupleFColumn("YPOS");
106  analysisManager->CreateNtupleFColumn("ZPOS");
107  analysisManager->CreateNtupleFColumn("EDEP");
108  analysisManager->CreateNtupleFColumn("EDEC");
109  analysisManager->CreateNtupleFColumn("EHDC");
110  analysisManager->FinishNtuple();
111 
112  //
113  //Create histograms. Save the ID of the first histogram in each block
114  //
115  //Energy deposit in Hcal layers
116  for (int i = 0; i<28; i++) {
117  G4String idString = "h" + std::to_string( i+100 );
118  G4String ntupletagString = "Energy Deposit in Hcal Layer" + std::to_string( i ) + " in GeV";
119  analysisManager->CreateH1( idString.c_str(), ntupletagString.c_str(), 100, 0., 1.0 );
120  }
121  // Energy deposits in Ecal towers
122  for (int i = 0; i<49; i++) {
123  G4String idString = "h" + std::to_string( i+200 );
124  G4String ntupletagString = "Energy Deposit in Ecal Tower" + std::to_string( i ) + " in GeV";
125  analysisManager->CreateH1( idString.c_str(), ntupletagString.c_str(), 100, 0., 1.0 );
126  }
127  // Total energy deposit
128  analysisManager->CreateH1( "h4000", "Total energy deposited in GeV", 100, 0., 100.0 );
129 
130  // Time slices
131  for (int i=0; i<numberOfTimeSlices; i++){
132  G4String idString = "h" + std::to_string( i+300 );
133  G4String ntupletagString = "Time slice " + std::to_string( i ) + " nsec energy profile in GeV";
134  analysisManager->CreateH1( idString.c_str(), ntupletagString.c_str(), 100, 0., 100.0 );
135  }
136 
137  // Profile of lateral energy deposit in Hcal
138  for (int i = 0; i<70; i++) {
139  G4String idString = "h" + std::to_string( i+500 );
140  G4String ntupletagString = "Lateral energy profile at " + std::to_string( i ) + " cm in GeV";
141  analysisManager->CreateH1( idString.c_str(), ntupletagString.c_str(), 100, 0., 10.0 );
142  }
143 
144  // Time profile
145  analysisManager->CreateH1( "h901", "Time Profile in Sensitive Detector", 200, 0., 200. );
146  analysisManager->CreateH1( "h902", "Time Profile in Sensitive+Passive", 200, 0., 200. );
147 
148  return;
149 }
virtual void EndOfRunAction(const G4Run *aRun)
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:466
#define G4endl
Definition: G4ios.hh:61
G4bool SetFirstHistoId(G4int firstId)
G4bool OpenFile(const G4String &fileName="")
G4int GetH1Id(const G4String &name, G4bool warn=true) const
G4int CreateH1(const G4String &name, const G4String &title, G4int nbins, G4double xmin, G4double xmax, const G4String &unitName="none", const G4String &fcnName="none", const G4String &binSchemeName="linear")
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:73
static G4VVisManager * GetConcreteInstance()
G4int GetRunID() const
Definition: G4Run.hh:76
G4int numberOfTimeSlices
Definition: G4Run.hh:46
void SetVerboseLevel(G4int verboseLevel)
int G4int
Definition: G4Types.hh:78
virtual void BeginOfRunAction(const G4Run *aRun)
tools::histo::h1d * GetH1(G4int id, G4bool warn=true, G4bool onlyIfActive=true) const
G4GLOB_DLL std::ostream G4cout
G4int CreateNtuple(const G4String &name, const G4String &title)
G4int CreateNtupleFColumn(const G4String &name)
G4bool SetFirstNtupleId(G4int firstId)