Skip to content

Commit 1541bba

Browse files
author
Xin Qian
committed
Update the WCSim to be usable for the new event display. We also update the WCSimRunAction.cc to remove the old method of reading in geofile.txt in order to dump the geometry of the WCSim. Now, the WCSimRunAction.cc directly get the geometry file from WCSimdetector
1 parent 9530eb6 commit 1541bba

15 files changed

+365
-87
lines changed

GNUmakefile

+5-5
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,25 @@ EXTRALIBS += $(ROOTLIBS)
4141
EXTRA_LINK_DEPENDENCIES :=
4242

4343
.PHONY: all
44-
all: lib bin
44+
all: rootcint lib bin shared libWCSim.a
4545

4646
# Note dependencies not yet set up right yet
4747

4848
ROOTSO := libWCSimRoot.so
4949

50-
ROOTSRC := ./src/WCSimRootEvent.cc ./include/WCSimRootEvent.hh ./src/WCSimRootGeom.cc ./include/WCSimRootGeom.hh ./include/WCSimRootLinkDef.hh
50+
ROOTSRC := ./src/WCSimRootEvent.cc ./include/WCSimRootEvent.hh ./src/WCSimRootGeom.cc ./include/WCSimRootGeom.hh ./include/WCSimPmtInfo.hh ./include/WCSimRootLinkDef.hh
5151

52-
ROOTOBJS := $(G4WORKDIR)/tmp/Linux-g++/WCSim/WCSimRootEvent.o $(G4WORKDIR)/tmp/Linux-g++/WCSim/WCSimRootGeom.o $(G4WORKDIR)/tmp/Linux-g++/WCSim/WCSimRootDict.o
52+
ROOTOBJS := $(G4WORKDIR)/tmp/Linux-g++/WCSim/WCSimRootEvent.o $(G4WORKDIR)/tmp/Linux-g++/WCSim/WCSimRootGeom.o $(G4WORKDIR)/tmp/Linux-g++/WCSim/WCSimPmtInfo.o $(G4WORKDIR)/tmp/Linux-g++/WCSim/WCSimRootDict.o
5353

5454
shared: $(ROOTSRC) $(ROOTOBJS)
5555
g++ -shared -O $(ROOTOBJS) -o $(ROOTSO)
5656

5757
libWCSim.a : $(ROOTOBJS)
5858
$(RM) $@
5959
ar clq $@ $(ROOTOBJS)
60-
$(RANLIB) $@
60+
# $(RANLIB) $@
6161

6262
rootcint : $(ROOTSRC)
63-
rootcint -f ./src/WCSimRootDict.cc -c -I./include -I$(shell root-config --incdir) WCSimRootEvent.hh WCSimRootGeom.hh WCSimRootLinkDef.hh
63+
rootcint -f ./src/WCSimRootDict.cc -c -I./include -I$(shell root-config --incdir) WCSimRootEvent.hh WCSimRootGeom.hh WCSimPmtInfo.hh WCSimRootLinkDef.hh
6464

6565
include $(G4INSTALL)/config/binmake.gmk

WCSim.cc

+42-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
#include "G4UImanager.hh"
44
#include "G4UIterminal.hh"
55
#include "G4UItcsh.hh"
6+
#include "G4UIGAG.hh"
7+
#include "G4VisExecutive.hh"
8+
#include "G4TrajectoryDrawByParticleID.hh"
69
#include "WCSimDetectorConstruction.hh"
710
#include "WCSimPhysicsList.hh"
811
#include "WCSimPhysicsMessenger.hh"
@@ -54,17 +57,40 @@ int main(int argc,char** argv)
5457
UI->ApplyCommand("/control/execute jobOptions.mac");
5558

5659
// Visualization
57-
G4VisManager* visManager = new WCSimVisManager;
60+
//G4VisManager* visManager = new WCSimVisManager;
61+
G4VisManager* visManager = new G4VisExecutive;
5862
visManager->Initialize();
5963

64+
//create new drawByParticleID model
65+
G4TrajectoryDrawByParticleID* mymodel = new G4TrajectoryDrawByParticleID;
66+
67+
//Configure model
68+
mymodel->SetDefault("cyan");
69+
mymodel->Set("gamma","green");
70+
mymodel->Set("nu_e","yellow");
71+
mymodel->Set("nu_mu","yellow");
72+
mymodel->Set("anti_nu_e","yellow");
73+
mymodel->Set("anti_nu_mu","yellow");
74+
mymodel->Set("e-","blue");
75+
mymodel->Set("mu-","black");
76+
mymodel->Set("e+","red");
77+
mymodel->Set("mu+","white");
78+
mymodel->Set("proton","magenta");
79+
mymodel->Set("neutron","Grey");
80+
81+
82+
83+
84+
visManager->RegisterModel(mymodel);
6085

6186
// Set user action classes
6287
WCSimPrimaryGeneratorAction* myGeneratorAction = new
6388
WCSimPrimaryGeneratorAction(WCSimdetector);
64-
6589
runManager->SetUserAction(myGeneratorAction);
6690

67-
WCSimRunAction* myRunAction = new WCSimRunAction;
91+
92+
93+
WCSimRunAction* myRunAction = new WCSimRunAction(WCSimdetector);
6894
runManager->SetUserAction(myRunAction);
6995

7096
runManager->SetUserAction(new WCSimEventAction(myRunAction, WCSimdetector,
@@ -87,20 +113,33 @@ int main(int argc,char** argv)
87113
// Visualization Macro
88114
UI->ApplyCommand("/control/execute vis.mac");
89115

116+
117+
90118
// Start Interactive Mode
91119
session->SessionStart();
92120

93121
delete session;
94122
}
95123
else // Batch mode
96124
{
125+
126+
// Start UI Session
127+
//G4UIsession* session = new G4UIterminal(new G4UItcsh);
128+
//G4UIsession* session = new G4UIGAG();
129+
97130
G4String command = "/control/execute ";
98131
G4String fileName = argv[1];
99132

100133
// Visualization Macro
101134
// UI->ApplyCommand("/control/execute vis.mac");//K.Z.: dangerous position for such command, has to
102135
//removed.
103136
UI->ApplyCommand(command+fileName);
137+
138+
// Start Interactive Mode
139+
// session->SessionStart();
140+
141+
142+
//delete session;
104143
}
105144

106145
delete visManager;

include/WCSimDetectorConstruction.hh

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef WCSimDetectorConstruction_H
22
#define WCSimDetectorConstruction_H 1
33

4+
#include "WCSimPmtInfo.hh"
5+
46
#include "G4Transform3D.hh"
57
#include "G4VUserDetectorConstruction.hh"
68
#include "G4LogicalVolume.hh"
@@ -10,6 +12,7 @@
1012

1113
#include <fstream>
1214
#include <map>
15+
#include <vector>
1316
//#include <hash_map.h>
1417
// warning : hash_map is not part of the standard
1518
#include <ext/hash_map>
@@ -75,7 +78,13 @@ public:
7578
G4double GetPMTSize() {return WCPMTRadius;}
7679
G4String GetPMTName() {return WCPMTName;}
7780
G4int GetMyConfiguration() {return myConfiguration;}
81+
G4double GetGeo_Dm(G4int);
82+
G4int GetTotalNumPmts() {return totalNumPMTs;}
83+
84+
G4double GetPMTSize1() {return WCPMTSize;}
7885

86+
G4ThreeVector GetWCOffset(){return WCOffset;}
87+
7988
// Related to the WC tube IDs
8089
static G4int GetTubeID(std::string tubeTag){return tubeLocationMap[tubeTag];}
8190
static G4Transform3D GetTubeTransform(int tubeNo){return tubeIDMap[tubeNo];}
@@ -89,6 +98,8 @@ public:
8998
void SetIsMailbox(G4bool choice) {isMailbox = choice;}
9099
G4bool GetIsMailbox() {return isMailbox;}
91100

101+
std::vector<WCSimPmtInfo*>* Get_Pmts() {return &fpmts;}
102+
92103
private:
93104

94105
// Tuning parameters
@@ -220,7 +231,7 @@ private:
220231
std::ofstream geoFile; // File for text output
221232

222233
G4int totalNumPMTs; // The number of PMTs for this configuration
223-
G4double WCCylInfo[2]; // Info for the geometry tree: radius & length
234+
G4double WCCylInfo[3]; // Info for the geometry tree: radius & length or mail box, length, width and depth
224235
G4double WCPMTSize; // Info for the geometry tree: pmt size
225236
G4ThreeVector WCOffset; // Info for the geometry tree: WC center offset
226237

@@ -233,7 +244,10 @@ private:
233244
// Variables related to configuration
234245

235246
G4int myConfiguration; // Detector Config Parameter
236-
247+
G4double innerradius;
248+
249+
std::vector<WCSimPmtInfo*> fpmts;
250+
237251
};
238252

239253
#endif

include/WCSimPmtInfo.hh

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#ifndef WCSim_PmtInfo
2+
#define WCSim_PmtInfo
3+
4+
/////////////////////////////////////////////////////////////////
5+
//
6+
// Save the Pmt info
7+
//
8+
/////////////////////////////////////////////////////////////////
9+
10+
#include "TObject.h"
11+
12+
class TDirectory;
13+
14+
class WCSimPmtInfo : public TObject {
15+
private:
16+
Int_t cylocation;
17+
Double_t trans_x;
18+
Double_t trans_y;
19+
Double_t trans_z;
20+
Double_t orien_x;
21+
Double_t orien_y;
22+
Double_t orien_z;
23+
Int_t tube;
24+
25+
public:
26+
WCSimPmtInfo();
27+
28+
WCSimPmtInfo(Int_t i, Double_t t1, Double_t t2, Double_t t3, Double_t o1, Double_t o2, Double_t o3, Int_t tubeid);
29+
30+
virtual ~WCSimPmtInfo();
31+
32+
Int_t Get_cylocation(){return cylocation;}
33+
Double_t Get_transx() {return trans_x;}
34+
Double_t Get_transy() {return trans_y;}
35+
Double_t Get_transz() {return trans_z;}
36+
Double_t Get_orienx() {return orien_x;}
37+
Double_t Get_orieny() {return orien_y;}
38+
Double_t Get_orienz() {return orien_z;}
39+
Int_t Get_tubeid(){return tube;}
40+
41+
ClassDef(WCSimPmtInfo,1);
42+
};
43+
44+
#endif

include/WCSimRootEvent.hh

+4-2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ private:
3838
Float_t fStart[3];
3939
Int_t fParenttype;
4040
Float_t fTime;
41+
Int_t fId;
4142

4243
public:
4344
WCSimRootTrack() {}
@@ -53,7 +54,7 @@ public:
5354
Float_t stop[3],
5455
Float_t start[3],
5556
Int_t parenttype,
56-
Float_t time);
57+
Float_t time,Int_t id);
5758

5859
virtual ~WCSimRootTrack() { }
5960

@@ -69,6 +70,7 @@ public:
6970
Float_t GetStart(Int_t i=0) {return (i<3) ? fStart[i] : 0;}
7071
Int_t GetParenttype(Int_t i=0) {return fParenttype;}
7172
Float_t GetTime() { return fTime;}
73+
Int_t GetId(){return fId;}
7274

7375
ClassDef(WCSimRootTrack,1)
7476
};
@@ -285,7 +287,7 @@ public:
285287
Float_t stop[3],
286288
Float_t start[3],
287289
Int_t parenttype,
288-
Float_t time);
290+
Float_t time,Int_t id);
289291

290292
TClonesArray *GetTracks() const {return fTracks;}
291293

include/WCSimRootGeom.hh

+20
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ private:
5353
static const Int_t maxNumPMT = 40000;
5454
Float_t fWCCylRadius; // Radius of WC tank
5555
Float_t fWCCylLength; // Length of WC tank
56+
57+
Float_t fMailBox_x; //mailbox x
58+
Float_t fMailBox_y; //mailbox y
59+
Float_t fMailBox_z; //mailbox z
60+
Int_t fgeo_type; // mailbox or cylinder?
61+
5662
Float_t fWCPMTRadius; // Radius of PMT
5763
Int_t fWCNumPMT; // Number of PMTs
5864
Float_t fWCOffset[3]; // Offset of barrel center in global coords
@@ -72,6 +78,13 @@ public:
7278

7379
void SetWCCylRadius(Float_t f) {fWCCylRadius=f;}
7480
void SetWCCylLength(Float_t f) {fWCCylLength=f;}
81+
82+
void SetMailBox_x(Float_t f){fMailBox_x = f;}
83+
void SetMailBox_y(Float_t f){fMailBox_y = f;}
84+
void SetMailBox_z(Float_t f){fMailBox_z = f;}
85+
86+
void SetGeo_Type(Int_t f){fgeo_type = f;}
87+
7588
void SetWCNumPMT(Int_t i) {fWCNumPMT= i;}
7689
void SetWCPMTRadius(Float_t f) {fWCPMTRadius = f;}
7790
void SetWCOffset(Float_t x, Float_t y, Float_t z)
@@ -81,6 +94,13 @@ public:
8194

8295
Float_t GetWCCylRadius() const {return fWCCylRadius;}
8396
Float_t GetWCCylLength() const {return fWCCylLength;}
97+
98+
Float_t GetMailBox_x() const {return fMailBox_x;}
99+
Float_t GetMailBox_y() const {return fMailBox_y;}
100+
Float_t GetMailBox_z() const {return fMailBox_z;}
101+
Int_t GetGeo_Type() const {return fgeo_type;}
102+
103+
84104
Int_t GetWCNumPMT() const {return fWCNumPMT;}
85105
Float_t GetWCPMTRadius() const {return fWCPMTRadius;}
86106
Float_t GetWCOffset(Int_t i) const {return (i<3) ? fWCOffset[i] : 0.;}

include/WCSimRootLinkDef.hh

+1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
#pragma link C++ class WCSimRootPi0+;
1515
#pragma link C++ class WCSimRootGeom+;
1616
#pragma link C++ class WCSimRootPMT+;
17+
#pragma link C++ class WCSimPmtInfo+;
1718

1819
#endif

include/WCSimRunAction.hh

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@
99
#include "TTree.h"
1010
#include "WCSimRootEvent.hh"
1111
#include "WCSimRootGeom.hh"
12+
#include "WCSimDetectorConstruction.hh"
1213

1314
class G4Run;
1415
class WCSimRunActionMessenger;
1516

1617
class WCSimRunAction : public G4UserRunAction
1718
{
1819
public:
19-
WCSimRunAction();
20+
WCSimRunAction(WCSimDetectorConstruction*);
2021
~WCSimRunAction();
2122

2223
public:
@@ -51,6 +52,7 @@ private:
5152
TTree* geoTree;
5253
WCSimRootEvent* wcsimrootsuperevent;
5354
WCSimRootGeom* wcsimrootgeom;
55+
WCSimDetectorConstruction* wcsimdetector;
5456

5557
int numberOfEventsGenerated;
5658
int numberOfTimesWaterTubeHit;

0 commit comments

Comments
 (0)