diff --git a/.grutrc b/.grutrc index 7f34eba1..8b53eb6b 100644 --- a/.grutrc +++ b/.grutrc @@ -15,6 +15,7 @@ GRUT.HistLib: $(GRUTSYS)/lib/libMakeHistos.so #GRUT.HistLib: $(GRUTSYS)/lib/libFastScintHists.so #GRUT.HistLib: $(GRUTSYS)/lib/libPolarHists3.so #GRUT.HistLib: $(GRUTSYS)/lib/libMakeSegaJanusHistos.so +#GRUT.HistLib: $(GRUTSYS)/libraries/libRCNPsav.so GRUT.GuiSetup: $(GRUTSYS)/gui_params.hist @@ -27,6 +28,7 @@ GRUT.SnapshotDir: #files to load at log in: Rint.Logon: $(GRUTSYS)/.grut_logon +#Rint.Logon: $(GRUTSYS)/logon.C Rint.History $(GRUTSYS)/.grut_history Rint.HistSize: 1000000 diff --git a/config/CAGRA_positions.txt b/config/CAGRA_positions.txt new file mode 100644 index 00000000..f504e1f8 --- /dev/null +++ b/config/CAGRA_positions.txt @@ -0,0 +1,208 @@ +clover.01.A.0.vec: 6.408151878 9.561848122 14.4461915396 +clover.01.A.1.vec: 5.877635401 9.0313316451 15.1964551364 +clover.01.A.2.vec: 6.9386683549 10.092364599 13.6959279428 +clover.01.B.0.vec: 8.638151878 11.791848122 11.2924952955 +clover.01.B.1.vec: 8.107635401 11.2613316451 12.0427588923 +clover.01.B.2.vec: 9.1686683549 12.322364599 10.5422316988 +clover.01.C.0.vec: 9.561848122 6.408151878 14.4461915396 +clover.01.C.1.vec: 9.0313316451 5.877635401 15.1964551364 +clover.01.C.2.vec: 10.092364599 6.9386683549 13.6959279428 +clover.01.D.0.vec: 11.791848122 8.638151878 11.2924952955 +clover.01.D.1.vec: 11.2613316451 8.107635401 12.0427588923 +clover.01.D.2.vec: 12.322364599 9.1686683549 10.5422316988 + +clover.02.A.0.vec: -9.561848122 6.408151878 14.4461915396 +clover.02.A.1.vec: -9.0313316451 5.877635401 15.1964551364 +clover.02.A.2.vec: -10.092364599 6.9386683549 13.6959279428 +clover.02.B.0.vec: -11.791848122 8.638151878 11.2924952955 +clover.02.B.1.vec: -11.2613316451 8.107635401 12.0427588923 +clover.02.B.2.vec: -12.322364599 9.1686683549 10.5422316988 +clover.02.C.0.vec: -6.408151878 9.561848122 14.4461915396 +clover.02.C.1.vec: -5.877635401 9.0313316451 15.1964551364 +clover.02.C.2.vec: -6.9386683549 10.092364599 13.6959279428 +clover.02.D.0.vec: -8.638151878 11.791848122 11.2924952955 +clover.02.D.1.vec: -8.107635401 11.2613316451 12.0427588923 +clover.02.D.2.vec: -9.1686683549 12.322364599 10.5422316988 + +clover.03.A.0.vec: -6.408151878 -9.561848122 14.4461915396 +clover.03.A.1.vec: -5.877635401 -9.0313316451 15.1964551364 +clover.03.A.2.vec: -6.9386683549 -10.092364599 13.6959279428 +clover.03.B.0.vec: -8.638151878 -11.791848122 11.2924952955 +clover.03.B.1.vec: -8.107635401 -11.2613316451 12.0427588923 +clover.03.B.2.vec: -9.1686683549 -12.322364599 10.5422316988 +clover.03.C.0.vec: -9.561848122 -6.408151878 14.4461915396 +clover.03.C.1.vec: -9.0313316451 -5.877635401 15.1964551364 +clover.03.C.2.vec: -10.092364599 -6.9386683549 13.6959279428 +clover.03.D.0.vec: -11.791848122 -8.638151878 11.2924952955 +clover.03.D.1.vec: -11.2613316451 -8.107635401 12.0427588923 +clover.03.D.2.vec: -12.322364599 -9.1686683549 10.5422316988 + +clover.04.A.0.vec: 9.561848122 -6.408151878 14.4461915396 +clover.04.A.1.vec: 9.0313316451 -5.877635401 15.1964551364 +clover.04.A.2.vec: 10.092364599 -6.9386683549 13.6959279428 +clover.04.B.0.vec: 11.791848122 -8.638151878 11.2924952955 +clover.04.B.1.vec: 11.2613316451 -8.107635401 12.0427588923 +clover.04.B.2.vec: 12.322364599 -9.1686683549 10.5422316988 +clover.04.C.0.vec: 6.408151878 -9.561848122 14.4461915396 +clover.04.C.1.vec: 5.877635401 -9.0313316451 15.1964551364 +clover.04.C.2.vec: 6.9386683549 -10.092364599 13.6959279428 +clover.04.D.0.vec: 8.638151878 -11.791848122 11.2924952955 +clover.04.D.1.vec: 8.107635401 -11.2613316451 12.0427588923 +clover.04.D.2.vec: 9.1686683549 -12.322364599 10.5422316988 + +clover.05.A.0.vec: 18.2 2.23 2.23 +clover.05.A.1.vec: 18.2 2.23 3.2910329539 +clover.05.A.2.vec: 18.2 2.23 1.1689670461 +clover.05.B.0.vec: 18.2 2.23 -2.23 +clover.05.B.1.vec: 18.2 2.23 -1.1689670461 +clover.05.B.2.vec: 18.2 2.23 -3.2910329539 +clover.05.C.0.vec: 18.2 -2.23 2.23 +clover.05.C.1.vec: 18.2 -2.23 3.2910329539 +clover.05.C.2.vec: 18.2 -2.23 1.1689670461 +clover.05.D.0.vec: 18.2 -2.23 -2.23 +clover.05.D.1.vec: 18.2 -2.23 -1.1689670461 +clover.05.D.2.vec: 18.2 -2.23 -3.2910329539 + +clover.06.A.0.vec: 11.2924952955 14.4461915396 2.23 +clover.06.A.1.vec: 11.2924952955 14.4461915396 3.2910329539 +clover.06.A.2.vec: 11.2924952955 14.4461915396 1.1689670461 +clover.06.B.0.vec: 11.2924952955 14.4461915396 -2.23 +clover.06.B.1.vec: 11.2924952955 14.4461915396 -1.1689670461 +clover.06.B.2.vec: 11.2924952955 14.4461915396 -3.2910329539 +clover.06.C.0.vec: 14.4461915396 11.2924952955 2.23 +clover.06.C.1.vec: 14.4461915396 11.2924952955 3.2910329539 +clover.06.C.2.vec: 14.4461915396 11.2924952955 1.1689670461 +clover.06.D.0.vec: 14.4461915396 11.2924952955 -2.23 +clover.06.D.1.vec: 14.4461915396 11.2924952955 -1.1689670461 +clover.06.D.2.vec: 14.4461915396 11.2924952955 -3.2910329539 + +clover.07.A.0.vec: -2.23 18.2 2.23 +clover.07.A.1.vec: -2.23 18.2 3.2910329539 +clover.07.A.2.vec: -2.23 18.2 1.1689670461 +clover.07.B.0.vec: -2.23 18.2 -2.23 +clover.07.B.1.vec: -2.23 18.2 -1.1689670461 +clover.07.B.2.vec: -2.23 18.2 -3.2910329539 +clover.07.C.0.vec: 2.23 18.2 2.23 +clover.07.C.1.vec: 2.23 18.2 3.2910329539 +clover.07.C.2.vec: 2.23 18.2 1.1689670461 +clover.07.D.0.vec: 2.23 18.2 -2.23 +clover.07.D.1.vec: 2.23 18.2 -1.1689670461 +clover.07.D.2.vec: 2.23 18.2 -3.2910329539 + +clover.08.A.0.vec: -14.4461915396 11.2924952955 2.23 +clover.08.A.1.vec: -14.4461915396 11.2924952955 3.2910329539 +clover.08.A.2.vec: -14.4461915396 11.2924952955 1.1689670461 +clover.08.B.0.vec: -14.4461915396 11.2924952955 -2.23 +clover.08.B.1.vec: -14.4461915396 11.2924952955 -1.1689670461 +clover.08.B.2.vec: -14.4461915396 11.2924952955 -3.2910329539 +clover.08.C.0.vec: -11.2924952955 14.4461915396 2.23 +clover.08.C.1.vec: -11.2924952955 14.4461915396 3.2910329539 +clover.08.C.2.vec: -11.2924952955 14.4461915396 1.1689670461 +clover.08.D.0.vec: -11.2924952955 14.4461915396 -2.23 +clover.08.D.1.vec: -11.2924952955 14.4461915396 -1.1689670461 +clover.08.D.2.vec: -11.2924952955 14.4461915396 -3.2910329539 + +clover.09.A.0.vec: -18.2 -2.23 2.23 +clover.09.A.1.vec: -18.2 -2.23 3.2910329539 +clover.09.A.2.vec: -18.2 -2.23 1.1689670461 +clover.09.B.0.vec: -18.2 -2.23 -2.23 +clover.09.B.1.vec: -18.2 -2.23 -1.1689670461 +clover.09.B.2.vec: -18.2 -2.23 -3.2910329539 +clover.09.C.0.vec: -18.2 2.23 2.23 +clover.09.C.1.vec: -18.2 2.23 3.2910329539 +clover.09.C.2.vec: -18.2 2.23 1.1689670461 +clover.09.D.0.vec: -18.2 2.23 -2.23 +clover.09.D.1.vec: -18.2 2.23 -1.1689670461 +clover.09.D.2.vec: -18.2 2.23 -3.2910329539 + +clover.10.A.0.vec: -11.2924952955 -14.4461915396 2.23 +clover.10.A.1.vec: -11.2924952955 -14.4461915396 3.2910329539 +clover.10.A.2.vec: -11.2924952955 -14.4461915396 1.1689670461 +clover.10.B.0.vec: -11.2924952955 -14.4461915396 -2.23 +clover.10.B.1.vec: -11.2924952955 -14.4461915396 -1.1689670461 +clover.10.B.2.vec: -11.2924952955 -14.4461915396 -3.2910329539 +clover.10.C.0.vec: -14.4461915396 -11.2924952955 2.23 +clover.10.C.1.vec: -14.4461915396 -11.2924952955 3.2910329539 +clover.10.C.2.vec: -14.4461915396 -11.2924952955 1.1689670461 +clover.10.D.0.vec: -14.4461915396 -11.2924952955 -2.23 +clover.10.D.1.vec: -14.4461915396 -11.2924952955 -1.1689670461 +clover.10.D.2.vec: -14.4461915396 -11.2924952955 -3.2910329539 + +clover.11.A.0.vec: 2.23 -18.2 2.23 +clover.11.A.1.vec: 2.23 -18.2 3.2910329539 +clover.11.A.2.vec: 2.23 -18.2 1.1689670461 +clover.11.B.0.vec: 2.23 -18.2 -2.23 +clover.11.B.1.vec: 2.23 -18.2 -1.1689670461 +clover.11.B.2.vec: 2.23 -18.2 -3.2910329539 +clover.11.C.0.vec: -2.23 -18.2 2.23 +clover.11.C.1.vec: -2.23 -18.2 3.2910329539 +clover.11.C.2.vec: -2.23 -18.2 1.1689670461 +clover.11.D.0.vec: -2.23 -18.2 -2.23 +clover.11.D.1.vec: -2.23 -18.2 -1.1689670461 +clover.11.D.2.vec: -2.23 -18.2 -3.2910329539 + +clover.12.A.0.vec: 14.4461915396 -11.2924952955 2.23 +clover.12.A.1.vec: 14.4461915396 -11.2924952955 3.2910329539 +clover.12.A.2.vec: 14.4461915396 -11.2924952955 1.1689670461 +clover.12.B.0.vec: 14.4461915396 -11.2924952955 -2.23 +clover.12.B.1.vec: 14.4461915396 -11.2924952955 -1.1689670461 +clover.12.B.2.vec: 14.4461915396 -11.2924952955 -3.2910329539 +clover.12.C.0.vec: 11.2924952955 -14.4461915396 2.23 +clover.12.C.1.vec: 11.2924952955 -14.4461915396 3.2910329539 +clover.12.C.2.vec: 11.2924952955 -14.4461915396 1.1689670461 +clover.12.D.0.vec: 11.2924952955 -14.4461915396 -2.23 +clover.12.D.1.vec: 11.2924952955 -14.4461915396 -1.1689670461 +clover.12.D.2.vec: 11.2924952955 -14.4461915396 -3.2910329539 + +clover.13.A.0.vec: 8.638151878 11.791848122 -11.2924952955 +clover.13.A.1.vec: 9.1686683549 12.322364599 -10.5422316988 +clover.13.A.2.vec: 8.107635401 11.2613316451 -12.0427588923 +clover.13.B.0.vec: 6.408151878 9.561848122 -14.4461915396 +clover.13.B.1.vec: 6.9386683549 10.092364599 -13.6959279428 +clover.13.B.2.vec: 5.877635401 9.0313316451 -15.1964551364 +clover.13.C.0.vec: 11.791848122 8.638151878 -11.2924952955 +clover.13.C.1.vec: 12.322364599 9.1686683549 -10.5422316988 +clover.13.C.2.vec: 11.2613316451 8.107635401 -12.0427588923 +clover.13.D.0.vec: 9.561848122 6.408151878 -14.4461915396 +clover.13.D.1.vec: 10.092364599 6.9386683549 -13.6959279428 +clover.13.D.2.vec: 9.0313316451 5.877635401 -15.1964551364 + +clover.14.A.0.vec: -11.791848122 8.638151878 -11.2924952955 +clover.14.A.1.vec: -12.322364599 9.1686683549 -10.5422316988 +clover.14.A.2.vec: -11.2613316451 8.107635401 -12.0427588923 +clover.14.B.0.vec: -9.561848122 6.408151878 -14.4461915396 +clover.14.B.1.vec: -10.092364599 6.9386683549 -13.6959279428 +clover.14.B.2.vec: -9.0313316451 5.877635401 -15.1964551364 +clover.14.C.0.vec: -8.638151878 11.791848122 -11.2924952955 +clover.14.C.1.vec: -9.1686683549 12.322364599 -10.5422316988 +clover.14.C.2.vec: -8.107635401 11.2613316451 -12.0427588923 +clover.14.D.0.vec: -6.408151878 9.561848122 -14.4461915396 +clover.14.D.1.vec: -6.9386683549 10.092364599 -13.6959279428 +clover.14.D.2.vec: -5.877635401 9.0313316451 -15.1964551364 + +clover.15.A.0.vec: -8.638151878 -11.791848122 -11.2924952955 +clover.15.A.1.vec: -9.1686683549 -12.322364599 -10.5422316988 +clover.15.A.2.vec: -8.107635401 -11.2613316451 -12.0427588923 +clover.15.B.0.vec: -6.408151878 -9.561848122 -14.4461915396 +clover.15.B.1.vec: -6.9386683549 -10.092364599 -13.6959279428 +clover.15.B.2.vec: -5.877635401 -9.0313316451 -15.1964551364 +clover.15.C.0.vec: -11.791848122 -8.638151878 -11.2924952955 +clover.15.C.1.vec: -12.322364599 -9.1686683549 -10.5422316988 +clover.15.C.2.vec: -11.2613316451 -8.107635401 -12.0427588923 +clover.15.D.0.vec: -9.561848122 -6.408151878 -14.4461915396 +clover.15.D.1.vec: -10.092364599 -6.9386683549 -13.6959279428 +clover.15.D.2.vec: -9.0313316451 -5.877635401 -15.1964551364 + +clover.16.A.0.vec: 11.791848122 -8.638151878 -11.2924952955 +clover.16.A.1.vec: 12.322364599 -9.1686683549 -10.5422316988 +clover.16.A.2.vec: 11.2613316451 -8.107635401 -12.0427588923 +clover.16.B.0.vec: 9.561848122 -6.408151878 -14.4461915396 +clover.16.B.1.vec: 10.092364599 -6.9386683549 -13.6959279428 +clover.16.B.2.vec: 9.0313316451 -5.877635401 -15.1964551364 +clover.16.C.0.vec: 8.638151878 -11.791848122 -11.2924952955 +clover.16.C.1.vec: 9.1686683549 -12.322364599 -10.5422316988 +clover.16.C.2.vec: 8.107635401 -11.2613316451 -12.0427588923 +clover.16.D.0.vec: 6.408151878 -9.561848122 -14.4461915396 +clover.16.D.1.vec: 6.9386683549 -10.092364599 -13.6959279428 +clover.16.D.2.vec: 5.877635401 -9.0313316451 -15.1964551364 + diff --git a/config/rcnp_constants.val b/config/rcnp_constants.val new file mode 100644 index 00000000..c403f10f --- /dev/null +++ b/config/rcnp_constants.val @@ -0,0 +1,3 @@ +ShapingTime { + Value: 350.0 +} \ No newline at end of file diff --git a/config/rcnp_peter.cal b/config/rcnp_peter.cal new file mode 100644 index 00000000..85e7133d --- /dev/null +++ b/config/rcnp_peter.cal @@ -0,0 +1,330 @@ +// Other channels +EXT00AP00 { + Address: 0x01006500 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT01AP00 { + Address: 0x01006501 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT02AP00 { + Address: 0x01006502 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT03AP00 { + Address: 0x01006503 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT04AP00 { + Address: 0x01006504 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT05AP00 { + Address: 0x01006505 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT06AP00 { + Address: 0x01006506 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT07AP00 { + Address: 0x01006507 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT08AP00 { + Address: 0x01006508 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT09AP00 { + Address: 0x01006509 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT10AP00 { + Address: 0x01006600 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT11AP00 { + Address: 0x01006601 + EnergyCoeff: 0 1 + Pol o: 1 +} +EXT12AP00 { + Address: 0x01006602 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT13AP00 { + Address: 0x01006603 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT14AP00 { + Address: 0x01006604 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT15AP00 { + Address: 0x01006605 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT16AP00 { + Address: 0x01006606 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT17AP00 { + Address: 0x01006607 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT18AP00 { + Address: 0x01006608 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT19AP00 { + Address: 0x01006609 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT20AP00 { + Address: 0x01006700 + EnergyCoeff: -55.898 2.2208 + PoleZero: 0.911 +} +EXT21AP00 { + Address: 0x01006701 + EnergyCoeff: -53.9224 1.1362 + PoleZero: 0.911 +} +EXT22AP00 { + Address: 0x01006702 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT23AP00 { + Address: 0x01006703 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT24AP00 { + Address: 0x01006704 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT25AP00 { + Address: 0x01006705 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT26AP00 { + Address: 0x01006706 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT27AP00 { + Address: 0x01006707 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT28AP00 { + Address: 0x01006708 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT29AP00 { + Address: 0x01006709 + EnergyCoeff: 0 1 + Pol o: 1 +} +EXT30AP00 { + Address: 0x01006800 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT31AP00 { + Address: 0x01006801 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT32AP00 { + Address: 0x01006802 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT33AP00 { + Address: 0x01006803 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT34AP00 { + Address: 0x01006804 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT35AP00 { + Address: 0x01006805 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT36AP00 { + Address: 0x01006806 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT37AP00 { + Address: 0x01006807 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT38AP00 { + Address: 0x01006808 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT39AP00 { + Address: 0x01006809 + EnergyCoeff: 0 1 + PoleZero: 1 +} + + +// // Central contacts + +// CLO01AP00 { +// Address: 0x01006500 +// EnergyCoeff: 0 1 +// } + +// CLO01BP00 { +// Address: 0x01006501 +// EnergyCoeff: 0 1 +// } + +// CLO01CP00 { +// Address: 0x01006502 +// EnergyCoeff: 0 1 +// } + +// CLO01DP00 { +// Address: 0x01006503 +// EnergyCoeff: 0 1 +// } + +// CLO01EP00 { +// Address: 0x01006504 +// EnergyCoeff: 0 1 +// } + +// // left +// CLO01AN01 { +// Address: 0x01006505 +// EnergyCoeff: 0 1 +// } + +// // center +// CLO01AN02 { +// Address: 0x01006506 +// EnergyCoeff: 0 1 +// } + +// //right +// CLO01AN03 { +// Address: 0x01006507 +// EnergyCoeff: 0 1 +// } + +// EXT11AP00 { +// Address: 0x01607200 +// EnergyCoeff: 0 1 +// } +// EXT02AP00 { +// Address: 0x01007201 +// EnergyCoeff: 0 1 +// } +// EXT03AP00 { +// Address: 0x01007202 +// EnergyCoeff: 0 1 +// } +// EXT04AP00 { +// Address: 0x01007203 +// EnergyCoeff: 0 1 +// } + +// EXT05AP00 { +// Address: 0x01007300 +// EnergyCoeff: 0 1 +// } +// EXT06AP00 { +// Address: 0x01007301 +// EnergyCoeff: 0 1 +// } +// EXT07AP00 { +// Address: 0x01007302 +// EnergyCoeff: 0 1 +// } +// EXT08AP00 { +// Address: 0x01007303 +// EnergyCoeff: 0 1 +// } +// EXT09AP00 { +// Address: 0x01007304 +// EnergyCoeff: 0 1 +// } + + + + +// // Segments + +// CLO01AN01 { +// Address: 0x010071xx +// EnergyCoeff: 0 1 +// } + +// CLO01AN02 { +// Address: 0x010071xx +// EnergyCoeff: 0 1 +// } + +// CLO01BN01 { +// Address: 0x010071xx +// EnergyCoeff: 0 1 +// } + +// CLO01BN02 { +// Address: 0x010071xx +// EnergyCoeff: 0 1 +// } + +// CLO01CN01 { +// Address: 0x010071xx +// EnergyCoeff: 0 1 +// } + +// CLO01CN02 { +// Address: 0x010071xx +// EnergyCoeff: 0 1 +// } + +// CLO01DN01 { +// Address: 0x010071xx +// EnergyCoeff: 0 1 +// } + +// CLO01DN02 { +// Address: 0x010071xx +// EnergyCoeff: 0 1 +// } diff --git a/config/rcnpchannels.cal b/config/rcnpchannels.cal new file mode 100644 index 00000000..f23ce0bf --- /dev/null +++ b/config/rcnpchannels.cal @@ -0,0 +1,331 @@ + +// Other channels +EXT00AP00 { + Address: 0x01006500 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT01AP00 { + Address: 0x01006501 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT02AP00 { + Address: 0x01006502 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT03AP00 { + Address: 0x01006503 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT04AP00 { + Address: 0x01006504 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT05AP00 { + Address: 0x01006505 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT06AP00 { + Address: 0x01006506 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT07AP00 { + Address: 0x01006507 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT08AP00 { + Address: 0x01006508 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT09AP00 { + Address: 0x01006509 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT10AP00 { + Address: 0x01006600 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT11AP00 { + Address: 0x01006601 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT12AP00 { + Address: 0x01006602 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT13AP00 { + Address: 0x01006603 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT14AP00 { + Address: 0x01006604 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT15AP00 { + Address: 0x01006605 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT16AP00 { + Address: 0x01006606 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT17AP00 { + Address: 0x01006607 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT18AP00 { + Address: 0x01006608 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT19AP00 { + Address: 0x01006609 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT20AP00 { + Address: 0x01006700 + EnergyCoeff: -23.996 1.5685 + PoleZero: 0.89123 +} +EXT21AP00 { + Address: 0x01006701 + EnergyCoeff: -7.5781 1.5026 + PoleZero: 1 +} +EXT22AP00 { + Address: 0x01006702 + EnergyCoeff: -31.6613 1.5664 + PoleZero: 1 +} +EXT23AP00 { + Address: 0x01006703 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT24AP00 { + Address: 0x01006704 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT25AP00 { + Address: 0x01006705 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT26AP00 { + Address: 0x01006706 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT27AP00 { + Address: 0x01006707 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT28AP00 { + Address: 0x01006708 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT29AP00 { + Address: 0x01006709 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT30AP00 { + Address: 0x01006800 + EnergyCoeff: -18.3471 0.8697 + PoleZero: 0.89123 +} +EXT31AP00 { + Address: 0x01006801 + EnergyCoeff: -7.7967 0.8227 + PoleZero: 1 +} +EXT32AP00 { + Address: 0x01006802 + EnergyCoeff: -23.9436 0.8553 + PoleZero: 1 +} +EXT33AP00 { + Address: 0x01006803 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT34AP00 { + Address: 0x01006804 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT35AP00 { + Address: 0x01006805 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT36AP00 { + Address: 0x01006806 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT37AP00 { + Address: 0x01006807 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT38AP00 { + Address: 0x01006808 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT39AP00 { + Address: 0x01006809 + EnergyCoeff: 0 1 + PoleZero: 1 +} + + +// // Central contacts + +// CLO01AP00 { +// Address: 0x01006500 +// EnergyCoeff: 0 1 +// } + +// CLO01BP00 { +// Address: 0x01006501 +// EnergyCoeff: 0 1 +// } + +// CLO01CP00 { +// Address: 0x01006502 +// EnergyCoeff: 0 1 +// } + +// CLO01DP00 { +// Address: 0x01006503 +// EnergyCoeff: 0 1 +// } + +// CLO01EP00 { +// Address: 0x01006504 +// EnergyCoeff: 0 1 +// } + +// // left +// CLO01AN01 { +// Address: 0x01006505 +// EnergyCoeff: 0 1 +// } + +// // center +// CLO01AN02 { +// Address: 0x01006506 +// EnergyCoeff: 0 1 +// } + +// //right +// CLO01AN03 { +// Address: 0x01006507 +// EnergyCoeff: 0 1 +// } + +// EXT11AP00 { +// Address: 0x01607200 +// EnergyCoeff: 0 1 +// } +// EXT02AP00 { +// Address: 0x01007201 +// EnergyCoeff: 0 1 +// } +// EXT03AP00 { +// Address: 0x01007202 +// EnergyCoeff: 0 1 +// } +// EXT04AP00 { +// Address: 0x01007203 +// EnergyCoeff: 0 1 +// } + +// EXT05AP00 { +// Address: 0x01007300 +// EnergyCoeff: 0 1 +// } +// EXT06AP00 { +// Address: 0x01007301 +// EnergyCoeff: 0 1 +// } +// EXT07AP00 { +// Address: 0x01007302 +// EnergyCoeff: 0 1 +// } +// EXT08AP00 { +// Address: 0x01007303 +// EnergyCoeff: 0 1 +// } +// EXT09AP00 { +// Address: 0x01007304 +// EnergyCoeff: 0 1 +// } + + + + +// // Segments + +// CLO01AN01 { +// Address: 0x010071xx +// EnergyCoeff: 0 1 +// } + +// CLO01AN02 { +// Address: 0x010071xx +// EnergyCoeff: 0 1 +// } + +// CLO01BN01 { +// Address: 0x010071xx +// EnergyCoeff: 0 1 +// } + +// CLO01BN02 { +// Address: 0x010071xx +// EnergyCoeff: 0 1 +// } + +// CLO01CN01 { +// Address: 0x010071xx +// EnergyCoeff: 0 1 +// } + +// CLO01CN02 { +// Address: 0x010071xx +// EnergyCoeff: 0 1 +// } + +// CLO01DN01 { +// Address: 0x010071xx +// EnergyCoeff: 0 1 +// } + +// CLO01DN02 { +// Address: 0x010071xx +// EnergyCoeff: 0 1 +// } diff --git a/include/TANLEvent.h b/include/TANLEvent.h new file mode 100644 index 00000000..c152e8da --- /dev/null +++ b/include/TANLEvent.h @@ -0,0 +1,90 @@ +#ifndef TANLEVENT_H +#define TANLEVENT_H + +#include "TObject.h" + +#include "TSmartBuffer.h" + +#include + +#include "GValue.h" + + + +class TANLEvent : public TObject { + public: + TANLEvent(TSmartBuffer& buf); + ~TANLEvent(); + + Long_t GetDiscriminator() const { return discriminator; } + Int_t GetPreE() const { return prerise_energy; } + Int_t GetPostE() const { return postrise_energy; } + UShort_t GetBoardID() const { return board_id; } + UShort_t GetChannel() const { return channel; } + Long_t GetPrevDisc() const { return disc_prev; } + UShort_t GetPostBegin() const { return postrise_begin_sample; } + UShort_t GetPostEnd() const { return postrise_end_sample; } + UShort_t GetPreBegin() const { return prerise_begin_sample; } + UShort_t GetPreEnd() const { return prerise_end_sample; } + UShort_t GetFlags() const { return flags; } + UShort_t GetBaseSample() const { return base_sample; } + static Float_t& GetShapingTime() { + if (std::isnan(shaping_time)) { shaping_time = GValue::Value("ShapingTime"); } + return shaping_time; + } + + + // Parse flags + UShort_t ExternalDiscFlag() const { return ((flags & 0x100)>>8); } + UShort_t PeakValidFlag() const { return ((flags & 0x200)>>9); } + UShort_t OffsetFlag() const { return ((flags & 0x400)>>10); } + UShort_t SyncErrorFlag() const { return ((flags & 0x1000)>>12); } + UShort_t GeneralErrorFlag() const { return ((flags & 0x2000)>>13); } + UShort_t PileUpOnlyFlag() const { return ((flags & 0x4000)>>14); } + UShort_t PileUpFlag() const { return ((flags & 0x8000)>>15); } + static UShort_t WriteFlag(const UShort_t& flags) { return ((flags & 0x20)>>5); } + static UShort_t VetoFlag(const UShort_t& flags) { return ((flags & 0x40)>>6); } + static UShort_t TSMatchFlag(const UShort_t& flags) { return ((flags & 0x80)>>7); } + static UShort_t ExternalDiscFlag(const UShort_t& flags) { return ((flags & 0x100)>>8); } + static UShort_t PeakValidFlag(const UShort_t& flags) { return ((flags & 0x200)>>9); } + static UShort_t OffsetFlag(const UShort_t& flags) { return ((flags & 0x400)>>10); } + static UShort_t CFDValidFlag(const UShort_t& flags) { return ((flags & 0x800)>>11); } + static UShort_t SyncErrorFlag(const UShort_t& flags) { return ((flags & 0x1000)>>12); } + static UShort_t GeneralErrorFlag(const UShort_t& flags) { return ((flags & 0x2000)>>13); } + static UShort_t PileUpOnlyFlag(const UShort_t& flags) { return ((flags & 0x4000)>>14); } + static UShort_t PileUpFlag(const UShort_t& flags) { return ((flags & 0x8000)>>15); } + + + double GetEnergy() const { return ((GetPostE() - GetPreE())/GetShapingTime()); } + Double_t GetCFD() const { return (Double_t)discriminator + d_cfd; } + std::vector& GetTrace() { return wave_data; } + + private: + static Float_t shaping_time; + + UShort_t global_addr; + UShort_t board_id; + UShort_t channel; + ULong_t discriminator; + + Double_t d_cfd; + + ULong_t disc_prev; + UShort_t flags; + //UInt_t sampled_baseline; + UInt_t prerise_energy; + UInt_t postrise_energy; + //ULong_t peak_timestamp; + UShort_t postrise_end_sample; + UShort_t postrise_begin_sample; + UShort_t prerise_end_sample; + UShort_t prerise_begin_sample; + UShort_t base_sample; + //UShort_t peak_sample; + std::vector wave_data; + + ClassDef(TANLEvent,0); +}; + + +#endif diff --git a/include/TCagra.h b/include/TCagra.h new file mode 100644 index 00000000..1f920aa0 --- /dev/null +++ b/include/TCagra.h @@ -0,0 +1,49 @@ +#ifndef TCagra_H +#define TCagra_H + +#include +#include + +#include "TDetector.h" +#include "TCagraHit.h" + +#include "TVector3.h" + +#include + +class TCagra : public TDetector { + +public: + TCagra(); + ~TCagra(); + + virtual void Copy(TObject& obj) const; + virtual void Print(Option_t *opt = "") const; + virtual void Clear(Option_t *opt = ""); + + virtual void InsertHit(const TDetectorHit& hit); + virtual TDetectorHit& GetHit(int i) { return cagra_hits.at(i); } + + const TCagraHit& GetCagraHit(int i) { return cagra_hits.at(i); } + void PrintHit(int i){ cagra_hits.at(i).Print(); } + + static TVector3 GetSegmentPosition(int detnum, char subpos, int segnum); + // Allows for looping over all hits with for(auto& hit : cagra) { } + std::vector::iterator begin() { return cagra_hits.begin(); } + std::vector::iterator end() { return cagra_hits.end(); } + +private: + virtual int BuildHits(std::vector& raw_data); + static void LoadDetectorPositions(); + + std::vector cagra_hits; + static std::map detector_positions; + + ClassDef(TCagra,1); +}; + + + + + +#endif diff --git a/include/TCagraHit.h b/include/TCagraHit.h new file mode 100644 index 00000000..f952c102 --- /dev/null +++ b/include/TCagraHit.h @@ -0,0 +1,79 @@ +#ifndef TCagraHIT_H +#define TCagraHIT_H + +#include "TDetectorHit.h" +#include "TCagraSegmentHit.h" + +class TCagraHit : public TDetectorHit { + public: + TCagraHit(); + ~TCagraHit(); + + virtual void Copy(TObject& obj) const; + virtual void Print(Option_t *opt = "") const; + virtual void Clear(Option_t *opt = ""); + //virtual void Draw(Option_t* opt = ""); + + virtual Int_t Charge() const; + + int GetDetnum() const; + char GetLeaf() const; + int GetMainSegnum() const; + + bool HasCore() const; + + unsigned int GetNumSegments() const { return fSegments.size(); } + TCagraSegmentHit& GetSegment(int i) { return fSegments.at(i); } + unsigned long GetSegmentTimestamp() { + if(fSegments.size()){ + return fSegments[0].Timestamp(); + } else { + return -1; + } + } + + TCagraSegmentHit& MakeSegmentByAddress(unsigned int address); + + int GetBoardID() const; + int GetChannel() const; + + TVector3 GetPosition(bool apply_array_offset = false) const; // modified from true + + double GetDoppler(double beta, + const TVector3& particle_vec = TVector3(0,0,1), + const TVector3& cagra_offset = TVector3(0,0,0)) const; + + void SetDiscTime(const Double_t t) { time = t; } + Double_t GetDiscTime() { return time; } + Double_t GetCorrectedEnergy(Double_t asym_bl=0.); + void SetPreRise(Double_t prerise) { prerise_energy = prerise; } + void SetPostRise(Double_t postrise) { postrise_energy = postrise; } + Double_t GetPreRise() { return prerise_energy; } + Double_t GetPostRise() { return postrise_energy; } + void SetFlags(UShort_t fl) { flags = fl; } + const UShort_t& GetFlags() const { return flags; } + void SetBaseSample(UShort_t base) { base_sample = base; } + const UShort_t& GetBaseSample() const { return base_sample; } + std::vector* GetTrace(int segnum=0); + void SetTrace(std::vector& trace); + void DrawTrace(int segnum); + double GetTraceHeight() const; + double GetTraceHeightDoppler(double beta,const TVector3& vec = TVector3(0,0,1)) const; + Double_t GetTraceEnergy(const UShort_t& a,const UShort_t& b,const UShort_t& x,const UShort_t& y) const; + Double_t GetTraceBaseline(); + + private: + std::vector fTrace; + std::vector fSegments; + Double_t time; + UShort_t flags; + Double_t prerise_energy; + Double_t postrise_energy; + UShort_t base_sample; + //Double_t fPZEnergy; + + ClassDef(TCagraHit,1); +}; + + +#endif diff --git a/include/TCagraSegmentHit.h b/include/TCagraSegmentHit.h new file mode 100644 index 00000000..6de792c1 --- /dev/null +++ b/include/TCagraSegmentHit.h @@ -0,0 +1,32 @@ +#ifndef _TCagraSEGMENTHIT_H_ +#define _TCagraSEGMENTHIT_H_ + +#include "TDetectorHit.h" + +class TCagraSegmentHit : public TDetectorHit { +public: + TCagraSegmentHit() { } + + virtual void Copy(TObject&) const; + virtual void Clear(Option_t *opt = ""); + virtual void Print(Option_t *opt = "") const; + + virtual Int_t Charge() const; + + int GetDetnum() const; + char GetLeaf() const; + int GetSegnum() const; + + int GetBoardID() const; + int GetChannel() const; + + std::vector& GetTrace() { return fTrace; } + void SetTrace(std::vector& trace); + + +private: + std::vector fTrace; + ClassDef(TCagraSegmentHit,1); +}; + +#endif /* _TCagraSEGMENTHIT_H_ */ diff --git a/include/TChannel.h b/include/TChannel.h index 44b8c046..e1aaf0e0 100644 --- a/include/TChannel.h +++ b/include/TChannel.h @@ -65,6 +65,17 @@ class TChannel : public TNamed { double CalEnergy(int charge, double timestamp=-DBL_MAX) const; double CalEnergy(double charge, double timestamp=-DBL_MAX) const; + void SetPoleZeroCoeff(std::vector coeff, double timestamp); + const std::vector& GetPoleZeroCoeff(double timestamp) const; + void ClearPoleZeroCoeff(); + double PoleZeroCorrection(const double& prerise, const double& postrise, const double& shaping_time, double timestamp=-DBL_MAX) const; + + void SetBaselineCoeff(std::vector coeff, double timestamp); + const std::vector& GetBaselineCoeff(double timestamp) const; + void ClearBaselineCoeff(); + double BaselineCorrection(const double& charge, double asym_bl=0, double timestamp=-DBL_MAX) const; + + void SetTimeCoeff(std::vector tmp, double timestamp=-DBL_MAX); const std::vector& GetTimeCoeff(double timestamp=-DBL_MAX) const; void ClearTimeCoeff(); @@ -124,6 +135,8 @@ class TChannel : public TNamed { std::vector energy_coeff; std::vector time_coeff; + std::vector polezero_corrections; + std::vector baseline_corrections; std::vector efficiency_coeff; int pedestal; //name and title held by TNamed. diff --git a/include/TDetector.h b/include/TDetector.h index 09d32e70..6f146695 100644 --- a/include/TDetector.h +++ b/include/TDetector.h @@ -36,12 +36,12 @@ class TDetector : public TNamed { void SetTimestamp(Long_t timestamp) { fTimestamp = timestamp; } enum EDetectorStatus { kUnbuilt = BIT(15) }; - + unsigned int RunStart() const { return fRunStart; } virtual void SetRunStart(unsigned int unix_time) { fRunStart = unix_time; } - - + + void AddRawData(TRawEvent *event) { fRawData.push_back(event); } int Build(); // build from transient data member. @@ -56,7 +56,7 @@ class TDetector : public TNamed { It is the number of seconds since January 1, 1970. If unavailable, will be 0. **/ - unsigned int fRunStart; + unsigned int fRunStart; private: diff --git a/include/TGRUTOptions.h b/include/TGRUTOptions.h index 6a71f413..3f5e6104 100644 --- a/include/TGRUTOptions.h +++ b/include/TGRUTOptions.h @@ -48,6 +48,11 @@ class TGRUTOptions : public TObject { bool StartGUI() const { return fStartGui; } bool MakeHistos() const { return fMakeHistos; } bool SortMultiple() const { return fSortMultiple; } + std::string SortMultipleGlob() const { return fGlobRaw; } + bool SaveRCNPTree() const { return fSaveRCNPTree; } + bool FastForwardRawFile() const { return fFastForwardRaw; } + bool GRSingles() const { return fGRSingles; } + bool IsOnline() const { return fIsOnline; } @@ -106,15 +111,15 @@ class TGRUTOptions : public TObject { bool fStartGui; bool fMakeHistos; bool fSortMultiple; - bool fTimeSortInput; int fTimeSortDepth; - int fBuildWindow; - bool fShouldExit; - bool fLongFileDescription; + bool fFastForwardRaw; + bool fSaveRCNPTree; + std::string fGlobRaw; + bool fGRSingles; ClassDef(TGRUTOptions,0); }; diff --git a/include/TGRUTTypes.h b/include/TGRUTTypes.h index a018448a..dd050b20 100644 --- a/include/TGRUTTypes.h +++ b/include/TGRUTTypes.h @@ -24,6 +24,8 @@ enum kDetectorSystems { CAESAR = 80, PHOSWALL = 17, + ANL = 14, + GRAND_RAIDEN = 50, NSCLSCALERS = 100 }; @@ -35,6 +37,8 @@ enum kFileType { NSCL_EVT = 1, GRETINA_MODE2 = 2, GRETINA_MODE3 = 3, + ANL_RAW = 4, + RCNP_BLD = 50, ROOT_DATA = 256, ROOT_MACRO = 257, CALIBRATED = 512, diff --git a/include/TGlobRawFile.h b/include/TGlobRawFile.h new file mode 100644 index 00000000..40c1d93a --- /dev/null +++ b/include/TGlobRawFile.h @@ -0,0 +1,54 @@ +#ifndef _TGLOBRAWFILE_H_ +#define _TGLOBRAWFILE_H_ + +#ifndef __CINT__ +#include +#endif + +#include + +#include "TRawSource.h" +#include "TMultiRawFile.h" + +class TGlobRawFile : public TRawEventSource { +public: + TGlobRawFile(std::string pattern); + virtual ~TGlobRawFile(){;} + + + virtual std::string SourceDescription(bool long_description) const { + return fWrapped.SourceDescription(long_description); + } + virtual std::string Status(bool long_description) const { + return fWrapped.Status(long_description); + } + + virtual int GetLastErrno() const { return fWrapped.GetLastErrno(); } + virtual std::string GetLastError() const { return fWrapped.GetLastError(); } + + virtual void Reset() { + TRawEventSource::Reset(); + fWrapped.Reset(); + } + + +private: + virtual int GetEvent(TRawEvent& outevent) { + CheckForFiles(); + return fWrapped.Read(outevent); + } + + void CheckForFiles(); + + std::string fPattern; + std::set fFilesAdded; +#ifndef __CINT__ + std::chrono::system_clock::time_point fPreviousCheck; +#endif + + TMultiRawFile fWrapped; + + ClassDef(TGlobRawFile, 0); +}; + +#endif /* _TGLOBRAWFILE_H_ */ diff --git a/include/TGrandRaiden.h b/include/TGrandRaiden.h new file mode 100644 index 00000000..a1f74432 --- /dev/null +++ b/include/TGrandRaiden.h @@ -0,0 +1,44 @@ +#ifndef TGRANDRAIDEN_H +#define TGRANDRAIDEN_H + +#include +#include + +#include + +#include "TDetector.h" +#include "TGrandRaidenHit.h" + +class TGrandRaiden : public TDetector { + +public: + TGrandRaiden(); + ~TGrandRaiden(); + + virtual void Copy(TObject& obj) const; + virtual void Print(Option_t *opt = "") const; + virtual void Clear(Option_t *opt = ""); + + virtual void InsertHit(const TDetectorHit& hit); + virtual TDetectorHit& GetHit(int i) { return GRHits.at(i); } + + const TGrandRaidenHit& GetGrandRaidenHit(int i) { return GRHits.at(i); } + void PrintHit(int i){ GRHits.at(i).Print(); } + // Allows for looping over all hits with for(auto& hit : gr) { } + std::vector::iterator begin() { return GRHits.begin(); } + std::vector::iterator end() { return GRHits.end(); } + + + + bool CheckHit(UInt_t i) { return (i < GRHits.size()) ? true : false; } + RCNPEvent& GetGRHit(UInt_t i) { return GRHits.at(i).GR(); } + +private: + virtual int BuildHits(std::vector& raw_data); + + std::vector GRHits; + + ClassDef(TGrandRaiden,1); +}; + +#endif diff --git a/include/TGrandRaidenHit.h b/include/TGrandRaidenHit.h new file mode 100644 index 00000000..f03eb3c4 --- /dev/null +++ b/include/TGrandRaidenHit.h @@ -0,0 +1,68 @@ +#ifndef TGRANDRAIDENHIT_H +#define TGRANDRAIDENHIT_H + +#include "TDetector.h" +#include "TDetectorHit.h" +#include + +#ifdef RCNP +#include "RCNPEvent.h" +#else +// --------------------- +class RCNPEvent : public TObject { }; +// --------------------- +#endif + +struct LaBrHit; + +class TGrandRaidenHit : public TDetectorHit { + public: + TGrandRaidenHit(); // TODO: move to private + TGrandRaidenHit(RCNPEvent& rcnpevent); + TGrandRaidenHit(const TGrandRaidenHit& gr); + ~TGrandRaidenHit(); + + virtual void Copy(TObject& obj) const; + //virtual void Compare(TObject &obj) const; + virtual void Print(Option_t *opt = "") const; + virtual void Clear(Option_t *opt = ""); + + void BuildFrom(); + + + + const std::vector& GetLaBr() { return labr_hits; } + const Double_t& GetMeanPlastE1() { return madc1; } + const Double_t& GetMeanPlastE2() { return madc2; } + const Double_t& GetMeanPlastPos1() { return tpos1; } + const Double_t& GetMeanPlastPos2() { return tpos2; } + const Long_t& GetTimestamp() { return Timestamp; } + RCNPEvent& GR() { return rcnp; } +private: + // Double_t ADC[4]; + // Double_t RF; + // Double_t QTCLead; + + std::vector labr_hits; + Double_t madc1; + Double_t madc2; + Double_t tpos1; + Double_t tpos2; + Long_t Timestamp; + RCNPEvent rcnp; + + + + ClassDef(TGrandRaidenHit,1); +}; + +struct LaBrHit { + Int_t channel; + Double_t qtc_le; + Double_t qtc_tr; + Double_t width; + //Double_t width() { return qtc_tr - qtc_le; } +}; + + +#endif diff --git a/include/TRCNPSource.h b/include/TRCNPSource.h new file mode 100644 index 00000000..fcdeb040 --- /dev/null +++ b/include/TRCNPSource.h @@ -0,0 +1,106 @@ +#ifdef RCNP +#ifndef _TRCNPSOURCE_H_ +#define _TRCNPSOURCE_H_ + +#include +#include +#include +#include +#include +#include + +#ifndef __CINT__ +#include +#include +#include +#endif + +#include "TObject.h" +#include "TRawEvent.h" +#include "TRawSource.h" +#include "TChain.h" +#include "TFile.h" + +#include "RCNPEvent.h" +#include "ThreadsafeQueue.h" + +class TRCNPSource : public TRawEventSource { +public: + + TRCNPSource(const char* Command, kFileType file_type); + TRCNPSource(const TRCNPSource& source) { } + ~TRCNPSource() {;} + + virtual std::string Status(bool long_description) const; + virtual std::string SourceDescription(bool long_description) const; + kFileType GetFileType() const { return fFileType; } + long GetFileSize() const { return fFileSize; } + virtual void Reset() {;} + +protected: + void SetFileSize(long file_size) { fFileSize = file_size; } + //void LoadFakeTimestamps(); + +private: + TRCNPSource() {;} + virtual int GetEvent(TRawEvent& event); + + const std::string fCommand; + kFileType fFileType; + long fFileSize; + #ifndef __CINT__ + std::future fFuture; + #endif + ThreadsafeQueue rcnp_queue; + + //std::queue timestamps; + + ClassDef(TRCNPSource,0); +}; + + +#endif + + + + + + + + + + + + + +#else // if RCNP is not defined + + +#ifndef _TRCNPSOURCE_H_ +#define _TRCNPSOURCE_H_ +#include "TObject.h" +#include "TRawEvent.h" +#include "TRawSource.h" +class TRCNPSource : public TRawEventSource { +public: + TRCNPSource(const char* Command, kFileType file_type) { + throw std::runtime_error("RCNP GRAnalyzer submodule is required when utilizing TRCNPSource."); + } + TRCNPSource(const TRCNPSource& source) { } + ~TRCNPSource() {;} + virtual std::string Status(bool long_description) const { return ""; } + virtual std::string SourceDescription(bool long_description) const { return ""; } + kFileType GetFileType() const { return kFileType::UNKNOWN_FILETYPE; } + long GetFileSize() const { return 0; } + virtual void Reset() {;} +protected: + void SetFileSize(long file_size) { ; } +private: + TRCNPSource() {;} + virtual int GetEvent(TRawEvent& event) { event.SetFragmentTimestamp(0); return -1; } + ClassDef(TRCNPSource,0); +}; +#endif + + +#endif // RCNP diff --git a/include/TRawBanks.h b/include/TRawBanks.h index 0b4cbe18..6fb57ed0 100644 --- a/include/TRawBanks.h +++ b/include/TRawBanks.h @@ -235,6 +235,7 @@ typedef struct { // Decomposed GRETINA Data friend std::ostream& operator<<(std::ostream& os, const GEBBankType1 &bank); static UShort_t SwapShort(UShort_t datum); +static UInt_t SwapInt(UInt_t datum); struct GEBMode3Head { UShort_t a2; @@ -281,6 +282,172 @@ struct GEBMode3Data { friend std::ostream& operator<<(std::ostream& os, const GEBMode3Data &data); static void SwapMode3Data(GEBMode3Data &data); +enum ArgonneType { LEDv10, LEDv11, CFDv11, LEDv18, CFDv18 }; + +struct GEBArgonneHead { + UShort_t GA_packetlength; + UShort_t ud_channel; + UInt_t disc_low; + UShort_t hdrlength_evttype_hdrtype; + UShort_t disc_high; + UShort_t GetGA() const; + UShort_t GetLength() const; + UShort_t GetBoardID() const; + UShort_t GetChannel() const; + UInt_t GetHeaderType() const; + UShort_t GetEventType() const; + UShort_t GetHeaderLength() const; + ULong_t GetDisc() const; +}__attribute__((__packed__)); + +friend std::ostream& operator<<(std::ostream& os, const GEBArgonneHead &header); +static void SwapArgonneHead(TRawEvent::GEBArgonneHead& header); + +struct GEBArgonneLEDv11 { + UShort_t led_low_prev; + UShort_t flags; + UInt_t led_high_prev; + UInt_t sampled_baseline; + UInt_t _blank_; + UInt_t postrise_sum_low_prerise_sum; + UShort_t timestamp_peak_low; + UShort_t postrise_sum_high; + UInt_t timestamp_peak_high; + UShort_t postrise_end_sample; + UShort_t postrise_begin_sample; + UShort_t prerise_end_sample; + UShort_t prerise_begin_sample; + UShort_t base_sample; + UShort_t peak_sample; + ULong_t GetPreviousLED() const; + UInt_t GetBaseline() const; + UInt_t GetPreRiseE() const; + UInt_t GetPostRiseE() const; + ULong_t GetPeakTimestamp() const; + UShort_t GetPostRiseSampleBegin() const; + UShort_t GetPostRiseSampleEnd() const; + UShort_t GetPreRiseSampleBegin() const; + UShort_t GetPreRiseSampleEnd() const; + UShort_t GetBaseSample() const; + UShort_t GetPeakSample() const; + UShort_t ExternalDiscFlag() const; + UShort_t PeakValidFlag() const; + UShort_t OffsetFlag() const; + UShort_t SyncErrorFlag() const; + UShort_t GeneralErrorFlag() const; + UShort_t PileUpOnlyFlag() const; + UShort_t PileUpFlag() const; +}__attribute__((__packed__)); + +struct GEBArgonneLEDv18 { + UShort_t led_low_prev; + UShort_t flags; + UInt_t led_high_prev; + UInt_t sampled_baseline; + UInt_t _blank_; + UInt_t postrise_sum_low_prerise_sum; + UShort_t timestamp_peak_low; + UShort_t postrise_sum_high; + // begin differences from v11 // + UShort_t timestamp_trigger_low; + UShort_t last_postrise_enter_sample; + // old: UInt_t timestamp_peak_high; + UShort_t last_postrise_leave_sample; + UShort_t postrise_leave_sample; + // old: UShort_t postrise_end_sample; + // old: UShort_t postrise_begin_sample; + UShort_t prerise_enter_sample; + UShort_t prerise_leave_sample; + // old: UShort_t prerise_end_sample; + // old: UShort_t prerise_begin_sample; + UShort_t base_sample; + UShort_t peak_sample; + ULong_t GetPreviousLED() const; + UInt_t GetBaseline() const; + UInt_t GetPreRiseE() const; + UInt_t GetPostRiseE() const; + // need changes + ULong_t GetTrigTimestamp() const; + UShort_t GetLastPostRiseEnterSample() const; + UShort_t GetLastPostRiseLeaveSample() const; + UShort_t GetPostRiseLeaveSample() const; + UShort_t GetPreRiseEnterSample() const; + UShort_t GetPreRiseLeaveSample() const; + // no change needed + UShort_t GetBaseSample() const; + UShort_t GetPeakSample() const; + + UShort_t WriteFlag() const; + UShort_t VetoFlag() const; + UShort_t ExternalDiscFlag() const; + UShort_t PeakValidFlag() const; + UShort_t OffsetFlag() const; + UShort_t SyncErrorFlag() const; + UShort_t GeneralErrorFlag() const; + UShort_t PileUpOnlyFlag() const; + UShort_t PileUpFlag() const; +}__attribute__((__packed__)); + +struct GEBArgonneCFDv18 { + UShort_t cfd_low_prev; + UShort_t flags; + UShort_t cfd_sample0; // signed + UShort_t cfd_mid_prev; // bits 16:29 + UInt_t sampled_baseline; + UShort_t cfd_sample2; + UShort_t cfd_sample1; + UInt_t postrise_sum_low_prerise_sum; + UShort_t timestamp_peak_low; + UShort_t postrise_sum_high; + UShort_t timestamp_trigger_low; + UShort_t last_postrise_enter_sample; + UShort_t postrise_end_sample; + UShort_t postrise_begin_sample; + UShort_t prerise_end_sample; + UShort_t prerise_begin_sample; + UShort_t base_sample; + UShort_t peak_sample; + Double_t GetCFD() const; + Short_t GetCFD0() const; + Short_t GetCFD1() const; + Short_t GetCFD2() const; + ULong_t GetPrevCFD(const GEBArgonneHead*) const; + UInt_t GetBaseline() const; + UInt_t GetPreRiseE() const; + UInt_t GetPostRiseE() const; + ULong_t GetTrigTimestamp() const; + UShort_t GetLastPostRiseEnterSample() const; + UShort_t GetPostRiseSampleBegin() const; + UShort_t GetPostRiseSampleEnd() const; + UShort_t GetPreRiseSampleBegin() const; + UShort_t GetPreRiseSampleEnd() const; + UShort_t GetBaseSample() const; + UShort_t GetPeakSample() const; + UShort_t WriteFlag() const; + UShort_t VetoFlag() const; + UShort_t TSMatchFlag() const; + UShort_t CFDValidFlag() const; + UShort_t ExternalDiscFlag() const; + UShort_t PeakValidFlag() const; + UShort_t OffsetFlag() const; + UShort_t SyncErrorFlag() const; + UShort_t GeneralErrorFlag() const; + UShort_t PileUpOnlyFlag() const; + UShort_t PileUpFlag() const; + +}__attribute__((__packed__)); + +static Short_t GetSigned14BitFromUShort(UShort_t ushort); + +friend std::ostream& operator<<(std::ostream& os, const GEBArgonneLEDv11& data); +static void SwapArgonneLEDv11(TRawEvent::GEBArgonneLEDv11& data); + +friend std::ostream& operator<<(std::ostream& os, const GEBArgonneLEDv18& data); +static void SwapArgonneLEDv18(TRawEvent::GEBArgonneLEDv18& data); + +friend std::ostream& operator<<(std::ostream& os, const GEBArgonneCFDv18& data); +static void SwapArgonneCFDv18(TRawEvent::GEBArgonneCFDv18& data); + struct GEBS800Header { Int_t total_size; UShort_t total_size2; diff --git a/include/TRawEvent.h b/include/TRawEvent.h index 522ac07e..332a671f 100644 --- a/include/TRawEvent.h +++ b/include/TRawEvent.h @@ -50,11 +50,15 @@ class TRawEvent : public TObject { void SetFragmentTimestamp(long timestamp) { fTimestamp = timestamp; } + void SetDataPtr(void* ptr) { fDataPtr = ptr; } + void* GetDataPtr() { return fDataPtr; } + protected: RawHeader fEventHeader; kFileType fFileType; long fTimestamp; TSmartBuffer fBody; + void* fDataPtr; ClassDef(TRawEvent,0) diff --git a/include/ThreadsafeQueue.h b/include/ThreadsafeQueue.h index 9b45c6e8..c67ec4d6 100644 --- a/include/ThreadsafeQueue.h +++ b/include/ThreadsafeQueue.h @@ -20,6 +20,7 @@ template class ThreadsafeQueue { public: ThreadsafeQueue(); + ThreadsafeQueue(size_t maxsize); ~ThreadsafeQueue(); int Push(T obj); int Pop(T& output, int millisecond_wait = 1000); @@ -59,6 +60,11 @@ ThreadsafeQueue::ThreadsafeQueue() items_in_queue(0), items_pushed(0), items_popped(0), is_finished(false) { } +template +ThreadsafeQueue::ThreadsafeQueue(size_t maxsize) + : max_queue_size(maxsize), + items_in_queue(0), items_pushed(0), items_popped(0) { } + template ThreadsafeQueue::~ThreadsafeQueue() { } diff --git a/libraries/TDetSystems/TCagra/LinkDef.h b/libraries/TDetSystems/TCagra/LinkDef.h new file mode 100644 index 00000000..21054148 --- /dev/null +++ b/libraries/TDetSystems/TCagra/LinkDef.h @@ -0,0 +1,17 @@ +// TCagra.h TCagraHit.h TCagraSegmentHit.h TANLEvent.h + +#ifdef __CINT__ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; +#pragma link C++ nestedclasses; + +#pragma link C++ class TANLEvent+; +#pragma link C++ class TCagraHit+; +#pragma link C++ class TCagraSegmentHit+; +#pragma link C++ class std::vector+; +#pragma link C++ class std::vector+; +#pragma link C++ class TCagra+; + +#endif diff --git a/libraries/TDetSystems/TCagra/TANLEvent.cxx b/libraries/TDetSystems/TCagra/TANLEvent.cxx new file mode 100644 index 00000000..9540f852 --- /dev/null +++ b/libraries/TDetSystems/TCagra/TANLEvent.cxx @@ -0,0 +1,152 @@ +#include "TANLEvent.h" + +#include "TGEBEvent.h" +#include "TGRUTOptions.h" + +ClassImp(TANLEvent) + +//bool TANLEvent::fExtractWaves = true; +Float_t TANLEvent::shaping_time = std::sqrt(-1); + +TANLEvent::TANLEvent(TSmartBuffer& buf) : d_cfd(0.) { + + bool read_waveform = TGRUTOptions::Get()->ExtractWaves(); + if (read_waveform) { + throw std::invalid_argument( + "void TANLEvent::BuildFrom(TSmartBuffer& buf) :: Waveforms not supported in GEBArgonne data."); + } + + // Extract header data. Header format should stay constant pending FW updates + auto header = (TRawEvent::GEBArgonneHead*)buf.GetData(); + buf.Advance(sizeof(TRawEvent::GEBArgonneHead)); + // Swap big endian for little endian + TRawEvent::SwapArgonneHead(*header); + // Extract header data + global_addr = header->GetGA(); + board_id = header->GetBoardID(); + channel = header->GetChannel(); + discriminator = header->GetDisc(); + + // Extract payload data. Two versions LED and CFD, with small changes for different FW versions + switch( static_cast(header->GetHeaderType()) ) { + case TRawEvent::ArgonneType::LEDv10: { + throw std::invalid_argument( + "void TANLEvent::BuildFrom(TSmartBuffer& buf) :: ArgonneType::LEDv10 is not implemented."); + break; + } + case TRawEvent::ArgonneType::LEDv11: { + auto data = (TRawEvent::GEBArgonneLEDv11*)buf.GetData(); + buf.Advance(sizeof(TRawEvent::GEBArgonneLEDv11)); + // Swap big endian for little endian + TRawEvent::SwapArgonneLEDv11(*data); + // Extract data from payload + disc_prev = data->GetPreviousLED(); + flags = data->flags; + prerise_energy = data->GetPreRiseE(); + postrise_energy = data->GetPostRiseE(); + postrise_begin_sample = data->GetPostRiseSampleBegin(); + prerise_begin_sample = data->GetPreRiseSampleBegin(); + postrise_end_sample = data->GetPostRiseSampleEnd(); + prerise_end_sample = data->GetPreRiseSampleEnd(); + + // ignore waveform data + size_t wave_bytes = header->GetLength()*4 - sizeof(*header) - sizeof(*data); + buf.Advance(wave_bytes); + + break; + } + case TRawEvent::ArgonneType::CFDv11: { + throw std::invalid_argument( + "void TANLEvent::BuildFrom(TSmartBuffer buf) :: ArgonneType::CFDv11 is not implemented."); + break; + } + case TRawEvent::ArgonneType::LEDv18: { + throw std::invalid_argument( + "void TANLEvent::BuildFrom(TSmartBuffer buf) :: ArgonneType::LEDv18 is not implemented."); + break; + // auto data = (TRawEvent::GEBArgonneLEDv11*)buf.GetData(); + // buf.Advance(sizeof(TRawEvent::GEBArgonneLEDv11)); + // // Swap big endian for little endian + // TRawEvent::SwapArgonneLEDv11(*data); + // // Extract data from payload + // disc_prev = data->GetPreviousLED(); + // flags = data->flags; + // prerise_energy = data->GetPreRiseE(); + // postrise_energy = data->GetPostRiseE(); + // postrise_begin_sample = data->GetPostRiseSampleBegin(); + // prerise_begin_sample = data->GetPreRiseSampleBegin(); + // postrise_end_sample = data->GetPostRiseSampleEnd(); + // prerise_end_sample = data->GetPreRiseSampleEnd(); + + // // ignore waveform data + // size_t wave_bytes = header->GetLength()*4 - sizeof(*header) - sizeof(*data); + // buf.Advance(wave_bytes); + + break; + } + case TRawEvent::ArgonneType::CFDv18: { + auto data = (TRawEvent::GEBArgonneCFDv18*)buf.GetData(); + buf.Advance(sizeof(TRawEvent::GEBArgonneCFDv18)); + // Swap big endian for little endian + TRawEvent::SwapArgonneCFDv18(*data); + // Extract data from payload + d_cfd = data->GetCFD(); // TODO: use a fit + // std::cout << cfd << std::endl; + // std::cin.get(); + disc_prev = data->GetPrevCFD(header); + flags = data->flags; + prerise_energy = data->GetPreRiseE(); + postrise_energy = data->GetPostRiseE(); + postrise_begin_sample = data->GetPostRiseSampleBegin(); + prerise_begin_sample = data->GetPreRiseSampleBegin(); + postrise_end_sample = data->GetPostRiseSampleEnd(); + prerise_end_sample = data->GetPreRiseSampleEnd(); + base_sample = data->GetBaseSample(); + + + size_t wave_bytes = header->GetLength()*4 - sizeof(*header) - sizeof(*data); // labr 1.52us + // // trace analysis here + for (auto i=0u; i +#include + +#include "TANLEvent.h" +#include "TChannel.h" + +#include "TGEBEvent.h" + + +std::map TCagra::detector_positions; + + +TCagra::TCagra(){ + Clear(); +} + +TCagra::~TCagra() { + +} + +void TCagra::Copy(TObject& obj) const { + TDetector::Copy(obj); + + TCagra& detector = (TCagra&)obj; + detector.cagra_hits = cagra_hits; +} + +void TCagra::InsertHit(const TDetectorHit& hit){ + cagra_hits.emplace_back((TCagraHit&)hit); + fSize++; +} + +int TCagra::BuildHits(std::vector& raw_data){ + for (auto& event : raw_data) { + SetTimestamp(event.GetTimestamp()); + + auto buf = event.GetPayloadBuffer(); + TANLEvent anl(buf); + + unsigned int address = ( (1<<24) + + (anl.GetBoardID() << 8) + + anl.GetChannel() ); + + TChannel* chan = TChannel::GetChannel(address); + + static int lines_displayed = 0; + if(!chan){ + if(lines_displayed < 10) { + std::cout << "Unknown (board id, channel): (" + << anl.GetBoardID() << ", " << anl.GetChannel() + << ")" << std::endl; + } else if(lines_displayed==1000){ + std::cout << "I'm going to stop telling you that the channel was unknown," + << " you should probably stop the program." << std::endl; + } + lines_displayed++; + + continue; + } + + int detnum = chan->GetArrayPosition(); // clover number + char leaf = *chan->GetArraySubposition(); // clover number + int segnum = chan->GetSegment(); // segment number + + // Get a hit, make it if it does not exist + TCagraHit* hit = NULL; + for(auto& ihit : cagra_hits){ + if(ihit.GetDetnum() == detnum && ihit.GetLeaf() == leaf){ + hit = &ihit; + break; + } + } + if(hit == NULL){ + cagra_hits.emplace_back(); + hit = &cagra_hits.back(); + fSize++; + } + + if(segnum==0){ + hit->SetAddress(address); + hit->SetTimestamp(event.GetTimestamp()); + hit->SetDiscTime(anl.GetCFD()); + hit->SetCharge(anl.GetEnergy()); + hit->SetTrace(anl.GetTrace()); + hit->SetPreRise(anl.GetPreE()); + hit->SetPostRise(anl.GetPostE()); + hit->SetFlags(anl.GetFlags()); + hit->SetBaseSample(anl.GetBaseSample()); + } else { + TCagraSegmentHit& seg = hit->MakeSegmentByAddress(address); + seg.SetCharge(anl.GetEnergy()); + seg.SetTimestamp(event.GetTimestamp()); + // TODO: the following need implementation + //seg.SetDiscTime(anl.GetCFD()); + //seg->SetPreRise(anl.GetPreE()); + //seg->SetPostRise(anl.GetPostE()); + //seg->SetFlags(anl.GetFlags()); + //seg->SetBaseSample(anl.GetBaseSample()); + seg.SetTrace(anl.GetTrace()); + } + } + + + + //TCagraHit hit; + //hit.BuildFrom(buf); + //hit.SetTimestamp(event.GetTimestamp()); + //InsertHit(hit); + return Size(); +} +TVector3 TCagra::GetSegmentPosition(int detnum, char subpos, int segnum) { + if(detnum < 1 || detnum > 16 || segnum < 0 || segnum > 2 || + subpos < 0x41 || subpos > 0x44){ + return TVector3(std::sqrt(-1),std::sqrt(-1),std::sqrt(-1)); + } + LoadDetectorPositions(); + + int index = (detnum << 16) + (((int)subpos) << 8) + segnum; + + if (detector_positions.count(index)>0) { + return detector_positions.at(index); + } else { + return TVector3(0.,0.,0.); + } + + // double segment_height = 1.0; + // double perp_distance = 1.5; + + // // Middle of the segment + // double segment_phi = 3.1415926535/4.0; + // double segment_z = segment_height/2.0; + + // double crystal_phi = segment_phi + (segnum-2)*3.1415926/2.0; + // double crystal_z = segment_z + ((segnum-1)/4)*segment_height; + + // TVector3 crystal_pos(1,0,0); + // crystal_pos.SetZ(crystal_z); + // crystal_pos.SetPhi(crystal_phi); + // crystal_pos.SetPerp(perp_distance); + + // TVector3 global_pos = CrystalToGlobal(detnum, crystal_pos); + + + // return global_pos; +} + +void TCagra::LoadDetectorPositions() { + static bool loaded = false; + if(loaded){ + return; + } + loaded = true; + + //std::string filename = std::string(getenv("GRUTSYS")) + "/../config/SeGA_rotations.txt"; + std::string filename = std::string(getenv("GRUTSYS")) + "/config/CAGRA_positions.txt"; + + //Read the locations from file. + std::ifstream infile(filename); + + if(!infile){ + std::cout << "Cagra positions file \"" << filename << "\"" + << " does not exist, skipping" << std::endl; + return; + } + + std::string line; + while (std::getline(infile,line)) { + //Parse the line + int nclover, nsegment; + char ncrystal; + double x,y,z; + int extracted = sscanf(line.c_str(),"clover.%02d.%c.%01d.vec: %lf %lf %lf", + &nclover,&ncrystal,&nsegment,&x,&y,&z); + if (extracted!=6) { + continue; + } + + int index = (nclover << 16) + (((int)ncrystal) << 8) + nsegment; + + + //Pack into the vector of transformations. + TVector3 vec = TVector3(x,y,z); + detector_positions[index] = vec; + } +} + +void TCagra::Print(Option_t *opt) const { } + +void TCagra::Clear(Option_t *opt) { + cagra_hits.clear(); +} diff --git a/libraries/TDetSystems/TCagra/TCagraHit.cxx b/libraries/TDetSystems/TCagra/TCagraHit.cxx new file mode 100644 index 00000000..81c3c687 --- /dev/null +++ b/libraries/TDetSystems/TCagra/TCagraHit.cxx @@ -0,0 +1,253 @@ +#include "TCagraHit.h" + +#include "TCagra.h" + +#include +#include + +#include "TString.h" +#include "TRandom.h" +#include "TANLEvent.h" + +#include "GCanvas.h" +#include "GValue.h" + +#include "TGRUTOptions.h" + +ClassImp(TCagraHit) + +TCagraHit::TCagraHit() : prerise_energy(0), postrise_energy(0) { +} + +TCagraHit::~TCagraHit() { + +} +void TCagraHit::Copy(TObject& obj) const { + TDetectorHit::Copy(obj); +} +void TCagraHit::Print(Option_t *opt) const { +} +void TCagraHit::Clear(Option_t *opt) { + TDetectorHit::Clear(opt); + fTrace.clear(); +} +bool TCagraHit::HasCore() const { + return fCharge != -1; +} + +int TCagraHit::GetDetnum() const { + TChannel* chan = TChannel::GetChannel(fAddress); + int output = -1; + if(chan && fAddress!=-1){ + output = chan->GetArrayPosition(); + } else if(fSegments.size()) { + output = fSegments[0].GetDetnum(); + } else { + // std::cout << "Unknown address: " << std::hex << fAddress << std::dec + // << std::endl; + output = -1; + } + + if(output == -1 && chan){ + // std::cout << "Chan with det=-1: " << chan->GetName() << std::endl; + // std::cout << "address: " << fAddress << std::endl; + } + + return output; +} +char TCagraHit::GetLeaf() const { + TChannel* chan = TChannel::GetChannel(fAddress); + char output = (char)-1; + if(chan && fAddress!=-1){ + output = *chan->GetArraySubposition(); + } else if(fSegments.size()) { + output = fSegments[0].GetLeaf(); + } else { + // std::cout << "Unknown address: " << std::hex << fAddress << std::dec + // << std::endl; + output = (char)-1; + } + + if(output == -1 && chan){ + // std::cout << "Chan with det=-1: " << chan->GetName() << std::endl; + // std::cout << "address: " << fAddress << std::endl; + } + + return output; +} +// int TCagraHit::GetCrate() const { +// return (fAddress&0x00ff0000)>>16; +// } + +int TCagraHit::GetBoardID() const { + return (fAddress&0x0000ff00)>>8; +} + +int TCagraHit::GetChannel() const { + return (fAddress&0x000000ff)>>0; +} + +TCagraSegmentHit& TCagraHit::MakeSegmentByAddress(unsigned int address){ + // for(auto& segment : fSegments){ + // if(segment.Address() == address){ + // return segment; + // } + // } + + fSegments.emplace_back(); + TCagraSegmentHit& output = fSegments.back(); + output.SetAddress(address); + return output; +} + +int TCagraHit::GetMainSegnum() const { + int output = 0; + double max_energy = -9e99; + for(auto& segment : fSegments){ + if(segment.GetEnergy() > max_energy){ + output = segment.GetSegnum(); + max_energy = segment.GetEnergy(); + } + } + return output; +} + +TVector3 TCagraHit::GetPosition(bool apply_array_offset) const { + TVector3 array_pos = TCagra::GetSegmentPosition(GetDetnum(), GetLeaf(), GetMainSegnum()); + if(apply_array_offset){ + array_pos += TVector3(GValue::Value("Cagra_X_offset"), + GValue::Value("Cagra_Y_offset"), + GValue::Value("Cagra_Z_offset")); + } + return array_pos; +} + +double TCagraHit::GetDoppler(double beta,const TVector3& particle_vec, const TVector3& offset) const { + if(GetNumSegments()<1) { + return std::sqrt(-1); + } + + double gamma = 1/(sqrt(1-pow(beta,2))); + TVector3 pos = GetPosition() + offset; + double cos_angle = TMath::Cos(pos.Angle(particle_vec)); + double dc_en = GetEnergy()*gamma *(1 - beta*cos_angle); + return dc_en; +} + +Int_t TCagraHit::Charge() const { + if(fCharge > 30000) { + return fCharge - 32768; + } else { + return fCharge; + } +} + +Double_t TCagraHit::GetCorrectedEnergy(Double_t asym_bl) { + TChannel* chan = TChannel::GetChannel(fAddress); + Double_t Energy = 0; + if(!chan){ + std::cout << std::hex << "Channel 0x" << fAddress << " not defined in calibrations file, no corrections are applied." << std::endl; + } else { + auto pzE = chan->PoleZeroCorrection(prerise_energy,postrise_energy,TANLEvent::GetShapingTime()); + pzE = chan->BaselineCorrection(pzE,asym_bl); + Energy = chan->CalEnergy(pzE, fTimestamp); + } + return Energy; +} +Double_t TCagraHit:: GetTraceBaseline() { + std::vector* trace = GetTrace(); + if (trace) { + int length = std::min(6,trace->size()); + Double_t bl = 0; + for (int i=0; i* trace = GetTrace(segnum); + if(!trace){ + std::cout << "No segment trace found for segment " << segnum << std::endl; + return; + } + + TH1I hist("hist", "", trace->size(), 0, 10*trace->size()); + hist.SetStats(false); + + if(segnum==0){ + hist.SetTitle(Form("CAGRA Detector %d at %ld ns", GetDetnum(), Timestamp())); + hist.GetXaxis()->SetTitle("Time (ns)"); + hist.GetYaxis()->SetTitle("ADC units"); + } + + for(size_t i=0; isize(); i++) { + hist.SetBinContent(i+1,(*trace)[i]); + } + hist.DrawCopy(); +} + +void TCagraHit::SetTrace(std::vector& trace) { + fTrace.clear(); + fTrace.swap(trace); +} + +std::vector* TCagraHit::GetTrace(int segnum) { + if(segnum == 0){ + return &fTrace; + } + for(auto& seg : fSegments) { + if(seg.GetSegnum() == segnum) { + return &seg.GetTrace(); + } + } + return NULL; +} + +double TCagraHit::GetTraceHeight() const { + if(fTrace.size() < 20){ + return std::sqrt(-1); + } + + double low = 0; + double high = 0; + for(unsigned int i=0; i<10; i++){ + low += fTrace[i]; + high += fTrace[fTrace.size()-i-1]; + } + + return (high-low)/10; +} + +double TCagraHit::GetTraceHeightDoppler(double beta,const TVector3& vec) const { + if(GetNumSegments()<1) { + return std::sqrt(-1); + } + + double gamma = 1/(sqrt(1-pow(beta,2))); + TVector3 pos = GetPosition(); + double cos_angle = TMath::Cos(pos.Angle(vec)); + double dc_en = GetTraceHeight()*gamma *(1 - beta*cos_angle); + return dc_en; +} + +Double_t TCagraHit::GetTraceEnergy(const UShort_t& a,const UShort_t& b,const UShort_t& x,const UShort_t& y) const { + if (!fTrace.size()) { return 0; } + + if (fTrace.size() < y) { + static int nprint = 0; + if (nprint < 10) { + std::cout << "Warning: Trace length less than requested sampling window: " << fTrace.size() < +#include + +void TCagraSegmentHit::Copy(TObject& obj) const{ + TDetectorHit::Copy(obj); + + TCagraSegmentHit& cagra = (TCagraSegmentHit&)obj; + cagra.fTrace = fTrace; +} + +void TCagraSegmentHit::Clear(Option_t *opt) { + TDetectorHit::Clear(opt); + fTrace.clear(); +} + +void TCagraSegmentHit::SetTrace(std::vector& trace) { + fTrace.clear(); + fTrace.swap(trace); +} + +void TCagraSegmentHit::Print(Option_t *opt) const { + std::cout << "TCagraSegmentHit:\n" + << "\tCharge: " << Charge() << "\n" + << std::flush; +} + +int TCagraSegmentHit::GetDetnum() const { + TChannel* chan = TChannel::GetChannel(fAddress); + if(chan){ + return chan->GetArrayPosition(); + } else { + std::cout << "Unknown address: " << std::hex << fAddress << std::dec + << std::endl; + return -1; + } +} +char TCagraSegmentHit::GetLeaf() const { + TChannel* chan = TChannel::GetChannel(fAddress); + if(chan){ + return *chan->GetArraySubposition(); + } else { + std::cout << "Unknown address: " << std::hex << fAddress << std::dec + << std::endl; + return (char)-1; + } +} + +int TCagraSegmentHit::GetSegnum() const { + TChannel* chan = TChannel::GetChannel(fAddress); + if(chan){ + return chan->GetSegment(); + } else { + return -1; + } +} + +// int TCagraSegmentHit::GetCrate() const { +// return (fAddress&0x00ff0000)>>16; +// } + +int TCagraSegmentHit::GetBoardID() const { + return (fAddress&0x0000ff00)>>8; +} + +int TCagraSegmentHit::GetChannel() const { + return (fAddress&0x000000ff)>>0; +} + +Int_t TCagraSegmentHit::Charge() const { + if(fCharge > 30000) { + return fCharge - 32768; + } else { + return fCharge; + } +} diff --git a/libraries/TDetSystems/TDetector/TDetectorEnv.cxx b/libraries/TDetSystems/TDetector/TDetectorEnv.cxx index a3eb7a77..18c7709a 100644 --- a/libraries/TDetSystems/TDetector/TDetectorEnv.cxx +++ b/libraries/TDetSystems/TDetector/TDetectorEnv.cxx @@ -156,6 +156,7 @@ kDetectorSystems TDetectorEnv::DetermineSystem(TRawEvent& event) const { } break; + case ANL_RAW: case GRETINA_MODE2: case GRETINA_MODE3: { diff --git a/libraries/TDetSystems/TGrandRaiden/LinkDef.h b/libraries/TDetSystems/TGrandRaiden/LinkDef.h new file mode 100644 index 00000000..b404a2c8 --- /dev/null +++ b/libraries/TDetSystems/TGrandRaiden/LinkDef.h @@ -0,0 +1,14 @@ +// TGrandRaiden.h TGrandRaidenHit.h + +#ifdef __CINT__ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; +#pragma link C++ nestedclasses; + +#pragma link C++ class TGrandRaidenHit+; +#pragma link C++ class std::vector+; +#pragma link C++ class TGrandRaiden+; + +#endif diff --git a/libraries/TDetSystems/TGrandRaiden/TGrandRaiden.cxx b/libraries/TDetSystems/TGrandRaiden/TGrandRaiden.cxx new file mode 100644 index 00000000..102aaeec --- /dev/null +++ b/libraries/TDetSystems/TGrandRaiden/TGrandRaiden.cxx @@ -0,0 +1,42 @@ +#include "TGrandRaiden.h" +#include "TRawEvent.h" + +TGrandRaiden::TGrandRaiden(){ + Clear(); +} + +TGrandRaiden::~TGrandRaiden() { + +} + +void TGrandRaiden::Copy(TObject& obj) const { + TDetector::Copy(obj); + + TGrandRaiden& detector = (TGrandRaiden&)obj; + detector.GRHits = GRHits; +} + +void TGrandRaiden::InsertHit(const TDetectorHit& hit){ + GRHits.emplace_back((TGrandRaidenHit&)hit); + fSize++; +} + +int TGrandRaiden::BuildHits(std::vector& raw_data){ + + for(auto& event : raw_data){ + SetTimestamp(event.GetTimestamp()); + auto rcnp = reinterpret_cast(event.GetDataPtr()); + TGrandRaidenHit hit(*rcnp); + hit.BuildFrom(); + hit.SetTimestamp(event.GetTimestamp()); + InsertHit(hit); + delete rcnp; + } + return Size(); +} + +void TGrandRaiden::Print(Option_t *opt) const { } + +void TGrandRaiden::Clear(Option_t *opt) { + GRHits.clear(); +} diff --git a/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx b/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx new file mode 100644 index 00000000..7ce4bf47 --- /dev/null +++ b/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx @@ -0,0 +1,108 @@ + +#include "TGrandRaidenHit.h" +#include "TGRUTOptions.h" +#include "TSmartBuffer.h" +#include "TMath.h" + +ClassImp(TGrandRaidenHit) + +TGrandRaidenHit::TGrandRaidenHit() { + madc1=0; madc2=0; tpos1=0; tpos2=0; +} +TGrandRaidenHit::TGrandRaidenHit(const TGrandRaidenHit& gr) { + labr_hits = gr.labr_hits; + madc1 = gr.madc1; + madc2 = gr.madc2; + tpos1 = gr.tpos1; + tpos2 = gr.tpos2; + Timestamp = gr.Timestamp; + rcnp = gr.rcnp; +} +TGrandRaidenHit::TGrandRaidenHit(RCNPEvent& rcnpevent) : + rcnp(rcnpevent) { + madc1=0; madc2=0; tpos1=0; tpos2=0; +} +TGrandRaidenHit::~TGrandRaidenHit() { +} + +void TGrandRaidenHit::BuildFrom(){ +#ifdef RCNP + static bool once = true; + if (once) { + RCNPEvent::HistDefCheckSum(); + once = false; + } + Clear(); + + Timestamp = rcnp.GetTimestamp(); + + auto adc = rcnp.GR_ADC(); + auto tdc = rcnp.GR_TDC(); + + auto qtc_le_tdc = rcnp.QTC_LEADING_TDC(); + auto qtc_le_chan = rcnp.QTC_LEADING_CH(); + auto qtc_tr_tdc = rcnp.QTC_TRAILING_TDC(); + auto qtc_tr_chan = rcnp.QTC_TRAILING_CH(); + + if (qtc_le_tdc && qtc_tr_tdc) { + + for (auto i=0u; isize(); i++) { + for (auto j=0u; jsize(); j++) { + if ((*qtc_le_chan)[i]==(*qtc_tr_chan)[j]) { + + LaBrHit temphit; + temphit.channel = (*qtc_le_chan)[i]; + temphit.width = (*qtc_tr_tdc)[j] - (*qtc_le_tdc)[i]; + temphit.qtc_le =(*qtc_le_tdc)[i]; + temphit.qtc_tr = (*qtc_tr_tdc)[j]; + + labr_hits.push_back(temphit); + + } + } + } + + } + + if (adc) { + madc1 = TMath::Sqrt((*adc)[0]*(*adc)[1]); + madc2 = TMath::Sqrt((*adc)[2]*(*adc)[3]); + } + if (tdc) { + tpos1 = TMath::Sqrt((*tdc)[0]*(*tdc)[1]); + tpos2 = TMath::Sqrt((*tdc)[2]*(*tdc)[3]); + } + +#endif +} + + + + + +void TGrandRaidenHit::Copy(TObject& obj) const { + TDetectorHit::Copy(obj); + + + +} + + +void TGrandRaidenHit::Print(Option_t *opt) const { } + +void TGrandRaidenHit::Clear(Option_t *opt) { + TDetectorHit::Clear(opt); +} + + + + + + + + + + + + + diff --git a/libraries/TGRUTUtil/TChannel.cxx b/libraries/TGRUTUtil/TChannel.cxx index d5a23a17..65e05297 100644 --- a/libraries/TGRUTUtil/TChannel.cxx +++ b/libraries/TGRUTUtil/TChannel.cxx @@ -7,6 +7,7 @@ #include #include #include +#include #include "TRandom.h" @@ -69,6 +70,32 @@ std::ostream& operator<<(std::ostream& out, const TChannel& chan) { out << "\n"; } + // Print out each PoleZero correction coeff + for(auto& start_coeff : chan.polezero_corrections) { + out << " PoleZero"; + if(start_coeff.start_time != -DBL_MAX) { + out << "[" << start_coeff.start_time << "]"; + } + out << ":"; + for(double coef : start_coeff.coefficients) { + out << "\t" << coef; + } + out << "\n"; + } + + // Print out each Baseline correction coeff + for(auto& start_coeff : chan.baseline_corrections) { + out << " Baseline"; + if(start_coeff.start_time != -DBL_MAX) { + out << "[" << start_coeff.start_time << "]"; + } + out << ":"; + for(double coef : start_coeff.coefficients) { + out << "\t" << coef; + } + out << "\n"; + } + // Print out each time coefficient for(auto& start_coeff : chan.time_coeff) { out << " TimeCoeff"; @@ -116,6 +143,8 @@ void TChannel::Copy(TObject &rhs) const { ((TChannel&)rhs).collected_charge = collected_charge; ((TChannel&)rhs).segment = segment; ((TChannel&)rhs).energy_coeff = energy_coeff; + ((TChannel&)rhs).polezero_corrections = polezero_corrections; + ((TChannel&)rhs).baseline_corrections = baseline_corrections; ((TChannel&)rhs).time_coeff = time_coeff; ((TChannel&)rhs).efficiency_coeff = efficiency_coeff; ((TChannel&)rhs).pedestal = pedestal; @@ -264,6 +293,8 @@ void TChannel::ClearCalibrations() { ClearEnergyCoeff(); ClearEfficiencyCoeff(); ClearTimeCoeff(); + ClearPoleZeroCoeff(); + ClearBaselineCoeff(); } const std::vector& TChannel::GetEnergyCoeff(double timestamp) const { @@ -305,10 +336,98 @@ double TChannel::CalEnergy(double charge, double timestamp) const { return Calibrate(charge-pedestal, GetEnergyCoeff(timestamp)); } +const std::vector& TChannel::GetPoleZeroCoeff(double timestamp) const { + for(auto& coeff_time : polezero_corrections){ + if(timestamp >= coeff_time.start_time) { + return coeff_time.coefficients; + } + } + // Should never reach here, but just in case. + return empty_vec; +} + double TChannel::CalEfficiency(double energy) const { return Efficiency(energy,GetEfficiencyCoeff()); } +void TChannel::ClearPoleZeroCoeff() { + polezero_corrections.clear(); + polezero_corrections.push_back({std::vector(), -DBL_MAX}); +} + +void TChannel::SetPoleZeroCoeff(std::vector coeff, double timestamp) { + std::vector* found = NULL; + for(auto& pz : polezero_corrections) { + if(pz.start_time == timestamp){ + found = &pz.coefficients; + } + } + + if(found){ + *found = std::move(coeff); + } else { + polezero_corrections.push_back({std::move(coeff), timestamp}); + std::sort(polezero_corrections.begin(), polezero_corrections.end()); + } +} + +double TChannel::PoleZeroCorrection(const double& prerise, const double& postrise, const double& shaping_time, double timestamp) const { + auto pz = GetPoleZeroCoeff(timestamp); + if (!pz.size()) { + static UShort_t nprint = 0; + if (nprint < 5) { + std::cout <<"No pole-zero in calibrations file found for address: 0x"; + std::cout << std::hex << address << std::endl; + nprint++; + } else if (nprint == 5){ + std::cout << "Void pole-zero warning is being suppressed." << std::endl; + nprint++; + } + pz.push_back(1); + } + return (postrise-prerise*pz[0])/shaping_time; +} + +const std::vector& TChannel::GetBaselineCoeff(double timestamp) const { + for(auto& coeff_time : baseline_corrections){ + if(timestamp >= coeff_time.start_time) { + return coeff_time.coefficients; + } + } + // Should never reach here, but just in case. + return empty_vec; +} + +void TChannel::ClearBaselineCoeff() { + baseline_corrections.clear(); + baseline_corrections.push_back({std::vector(), -DBL_MAX}); +} + +void TChannel::SetBaselineCoeff(std::vector coeff, double timestamp) { + std::vector* found = NULL; + for(auto& pz : baseline_corrections) { + if(pz.start_time == timestamp){ + found = &pz.coefficients; + } + } + + if(found){ + *found = std::move(coeff); + } else { + baseline_corrections.push_back({std::move(coeff), timestamp}); + std::sort(baseline_corrections.begin(), baseline_corrections.end()); + } +} + +double TChannel::BaselineCorrection(const double& charge, double asym_bl, double timestamp) const { + auto pz = GetPoleZeroCoeff(timestamp); + if (!asym_bl) { + auto bl = GetBaselineCoeff(timestamp); + asym_bl = (bl.size()) ? bl[0] : 0; + } + if (!pz.size()) { pz.push_back(1); } + return charge - asym_bl*(1. - pz[0]); +} const std::vector& TChannel::GetTimeCoeff(double timestamp) const { for(auto& tc : time_coeff) { @@ -437,7 +556,7 @@ int TChannel::WriteCalFile(std::string outfilename,Option_t *opt) { //} int count =0; if(outfilename.length()>0) { - std::ofstream calout; + ofstream calout; calout.open(outfilename.c_str()); for(auto &iter : chanvec) { calout << iter.PrintToString(opt); @@ -565,6 +684,14 @@ int TChannel::ParseInputData(std::string &input,Option_t *opt) { channel->SetEnergyCoeff(ParseListOfDoubles(ss), ParseStartTime(type)); + } else if(type.find("POLEZERO")==0) { + channel->SetPoleZeroCoeff(ParseListOfDoubles(ss), + ParseStartTime(type)); + + } else if(type.find("BASELINE")==0) { + channel->SetBaselineCoeff(ParseListOfDoubles(ss), + ParseStartTime(type)); + } else if(type == "PEDESTAL") { int val = 0; ss >> val; channel->SetPedestal(val); diff --git a/libraries/TGRUTint/TGRUTOptions.cxx b/libraries/TGRUTint/TGRUTOptions.cxx index 055621d4..cfc9720d 100644 --- a/libraries/TGRUTint/TGRUTOptions.cxx +++ b/libraries/TGRUTint/TGRUTOptions.cxx @@ -92,6 +92,12 @@ void TGRUTOptions::Load(int argc, char** argv) { .description("Root output file"); parser.option("f filter-output",&output_filtered_file) .description("Output file for raw filtered data"); + parser.option("R save-rcnp-tree", &fSaveRCNPTree) + .description("Save ROOT tree from raw RCNP analyzer data.") + .default_value(false); + parser.option("S gr-singles", &fGRSingles) + .description("Ignore RCNP Grand Raiden timestamps and take singles.") + .default_value(false); parser.option("hist-output",&output_histogram_file) .description("Output file for histograms"); parser.option("r ring",&input_ring) @@ -128,6 +134,12 @@ void TGRUTOptions::Load(int argc, char** argv) { parser.option("g start-gui",&fStartGui) .description("Start the GUI") .default_value(false); + parser.option("G glob-raw",&fGlobRaw) + .description("Open files according to a pattern and continuously look for new files.") + .default_value(""); + parser.option("F fast-forward",&fFastForwardRaw) + .description("Seek to the end of all raw files that are added so as to read freshly saved data in online mode.") + .default_value(false); parser.option("w gretina-waves",&fExtractWaves) .description("Extract wave forms to data class when available.") .default_value(false); @@ -255,6 +267,10 @@ kFileType TGRUTOptions::DetermineFileType(const std::string& filename) const{ return kFileType::PRESETWINDOW; } else if (ext == "cuts") { return kFileType::CUTS_FILE; + } else if (ext == "bld") { + return kFileType::RCNP_BLD; + } else if (ext.find("gtd")!=std::string::npos) { + return kFileType::ANL_RAW; } else { return kFileType::UNKNOWN_FILETYPE; } @@ -263,6 +279,8 @@ kFileType TGRUTOptions::DetermineFileType(const std::string& filename) const{ bool TGRUTOptions::FileAutoDetect(const std::string& filename) { switch(DetermineFileType(filename)){ case kFileType::NSCL_EVT: + case kFileType::ANL_RAW: + case kFileType::RCNP_BLD: case kFileType::GRETINA_MODE2: case kFileType::GRETINA_MODE3: input_raw_files.push_back(filename); diff --git a/libraries/TGRUTint/TGRUTint.cxx b/libraries/TGRUTint/TGRUTint.cxx index cda275e7..70987249 100644 --- a/libraries/TGRUTint/TGRUTint.cxx +++ b/libraries/TGRUTint/TGRUTint.cxx @@ -38,6 +38,7 @@ #include "TMultiRawFile.h" #include "TOrderedRawFile.h" #include "TRawSource.h" +#include "TGlobRawFile.h" #include "TSequentialRawFile.h" #include "TTerminalLoop.h" #include "TUnpackingLoop.h" @@ -148,7 +149,6 @@ void TGRUTint::ApplyOptions() { if(opt->S800InverseMapFile().length()) { TInverseMap::Get(opt->S800InverseMapFile().c_str()); } - for(auto filename : opt->RootInputFiles()) { // this will populate gChain if able. // TChannels from the root file will be loaded as file is opened. @@ -488,6 +488,8 @@ TRawEventSource* TGRUTint::OpenRawSource() { bool has_input_ring = opt->InputRing().length(); bool has_raw_file = opt->RawInputFiles().size(); + bool is_glob_source = opt->SortMultipleGlob().length(); + bool is_multi_sort = opt->SortMultiple(); TRawEventSource* source = NULL; @@ -497,7 +499,7 @@ TRawEventSource* TGRUTint::OpenRawSource() { true, true, opt->DefaultFileType()); - } else if(has_raw_file && opt->SortMultiple()){ + } else if(is_multi_sort && has_raw_file ){ // Open multiple files, read from all at the same time. TMultiRawFile* multi_source = new TMultiRawFile(); for(auto& filename : opt->RawInputFiles()){ @@ -505,7 +507,11 @@ TRawEventSource* TGRUTint::OpenRawSource() { } source = multi_source; - } else if(opt->RawInputFiles().size() > 1 && !opt->SortMultiple()){ + } else if(is_glob_source) { + // Open multiple files, read from all at the same time. + TGlobRawFile* glob_multi_source = new TGlobRawFile(opt->SortMultipleGlob()); + source = glob_multi_source; + } else if(!is_multi_sort && opt->RawInputFiles().size() > 1){ // Open multiple files, read from each one at a a time. TSequentialRawFile* seq_source = new TSequentialRawFile(); for(auto& filename : opt->RawInputFiles()){ @@ -515,9 +521,17 @@ TRawEventSource* TGRUTint::OpenRawSource() { } else { // Open a single file. - std::string filename = opt->RawInputFiles().at(0); - if(file_exists(filename.c_str())){ - source = new TRawFileIn(filename.c_str()); + if (opt->RawInputFiles().size()) { + std::string filename = opt->RawInputFiles().at(0); + if(file_exists(filename.c_str())){ + source = new TRawFileIn(filename.c_str()); + } + } + else if (opt->RootInputFiles().size()) { + std::string filename = opt->RootInputFiles().at(0); + if(file_exists(filename.c_str())){ + source = TRawEventSource::EventSource(filename.c_str()); + } } } diff --git a/libraries/TLoops/StoppableThread.cxx b/libraries/TLoops/StoppableThread.cxx index 780d4061..98547ab4 100644 --- a/libraries/TLoops/StoppableThread.cxx +++ b/libraries/TLoops/StoppableThread.cxx @@ -3,6 +3,7 @@ #include #include #include +#include #include @@ -13,6 +14,7 @@ std::map StoppableThread::fthreadmap; bool StoppableThread::status_thread_on = false; std::thread StoppableThread::status_thread; +std::atomic stop_rcnp_signal(0); int StoppableThread::GetNThreads() { return fthreadmap.size(); } @@ -65,6 +67,7 @@ std::string StoppableThread::Status() { } void StoppableThread::StopAll() { + stop_rcnp_signal = 1; std::this_thread::sleep_for(std::chrono::milliseconds(500)); for(auto& elem : fthreadmap){ TDataLoop* data_loop = dynamic_cast(elem.second); TChainLoop* chain_loop = dynamic_cast(elem.second); diff --git a/libraries/TLoops/TUnpackedEvent.cxx b/libraries/TLoops/TUnpackedEvent.cxx index 5c96fc17..5a99f944 100644 --- a/libraries/TLoops/TUnpackedEvent.cxx +++ b/libraries/TLoops/TUnpackedEvent.cxx @@ -15,6 +15,8 @@ #include "TS800Scaler.h" #include "TSega.h" #include "TFastScint.h" +#include "TCagra.h" +#include "TGrandRaiden.h" TUnpackedEvent::TUnpackedEvent() { } @@ -82,6 +84,14 @@ void TUnpackedEvent::Build() { GetDetector(true)->Build(raw_data); break; + case kDetectorSystems::ANL: + GetDetector(true)->Build(raw_data); + break; + + case kDetectorSystems::GRAND_RAIDEN: + GetDetector(true)->Build(raw_data); + break; + default: break; } diff --git a/libraries/TLoops/TUnpackingLoop.cxx b/libraries/TLoops/TUnpackingLoop.cxx index 648aae78..0b5d297e 100644 --- a/libraries/TLoops/TUnpackingLoop.cxx +++ b/libraries/TLoops/TUnpackingLoop.cxx @@ -59,16 +59,23 @@ bool TUnpackingLoop::Iteration(){ TNSCLEvent nscl_event(raw_event); HandleNSCLData(nscl_event); } - break; + break; + case kFileType::ANL_RAW: case kFileType::GRETINA_MODE2: case kFileType::GRETINA_MODE3: { TGEBEvent geb_event(raw_event); HandleGEBData(geb_event); } - break; - + break; + case kFileType::RCNP_BLD: + { + // Consider adding HandleRCNPData to check for LAS or GR detector systems + fOutputEvent->AddRawData(raw_event, kDetectorSystems::GRAND_RAIDEN); + } + break; + break; default: break; } @@ -209,6 +216,9 @@ void TUnpackingLoop::HandleGEBData(TGEBEvent& event){ //event.Print("all"); //exit(1); break; + case 14: + fOutputEvent->AddRawData(event, kDetectorSystems::ANL); + break; case 17: //PWall Mode2 equivlant. fOutputEvent->AddRawData(event, kDetectorSystems::PHOSWALL); break; diff --git a/libraries/TRawFormat/LinkDef.h b/libraries/TRawFormat/LinkDef.h index aa202c30..3839d139 100644 --- a/libraries/TRawFormat/LinkDef.h +++ b/libraries/TRawFormat/LinkDef.h @@ -1,4 +1,4 @@ -// TRawSource.h TByteSource.h TRawEvent.h TSmartBuffer.h TMultiRawFile.h TOrderedRawFile.h TSequentialRawFile.h TRawFileOut.h +// TRawSource.h TRawEvent.h TSmartBuffer.h TMultiRawFile.h TGlobRawFile.h TOrderedRawFile.h TSequentialRawFile.h TRawFileOut.h TRCNPSource.h #ifdef __CINT__ @@ -27,10 +27,13 @@ #pragma link C++ class TRawFileIn+; #pragma link C++ class TMultiRawFile+; +#pragma link C++ class TGlobRawFile+; #pragma link C++ class TOrderedRawFile+; #pragma link C++ class TSequentialRawFile+; - #pragma link C++ class TRawFileOut+; +#pragma link C++ class TRCNPSource+; + +#pragma link C++ enum TRawEvent::ArgonneType; #endif diff --git a/libraries/TRawFormat/TGlobRawFile.cxx b/libraries/TRawFormat/TGlobRawFile.cxx new file mode 100644 index 00000000..fab894b2 --- /dev/null +++ b/libraries/TRawFormat/TGlobRawFile.cxx @@ -0,0 +1,45 @@ +#include "TGlobRawFile.h" + +#include + +namespace { + // From http://stackoverflow.com/a/8615450/2689797 + std::vector glob(const std::string& pattern) { + glob_t glob_result; + glob(pattern.c_str(), GLOB_TILDE, NULL, &glob_result); + + std::vector output; + for(unsigned int i=0; i time_between_checks) { + return; + } + + for(auto& filename : glob(fPattern)) { + if(fFilesAdded.count(filename) == 0) { + auto new_file = TRawEventSource::EventSource(filename.c_str()); + fWrapped.AddFile(new_file); + fFilesAdded.insert(filename); + } + } + + + fPreviousCheck = now; +} diff --git a/libraries/TRawFormat/TRCNPSource.cxx b/libraries/TRawFormat/TRCNPSource.cxx new file mode 100644 index 00000000..0f9ee4a8 --- /dev/null +++ b/libraries/TRawFormat/TRCNPSource.cxx @@ -0,0 +1,123 @@ +#include "TRCNPSource.h" +#include + +extern std::atomic stop_rcnp_signal; + +#ifdef RCNP +#include "GRUTinizerInterface.h" + + +TRCNPSource::TRCNPSource(const char* Command, kFileType file_type) + : fCommand(Command), fFileType(file_type) { + + assert(file_type == kFileType::RCNP_BLD); + + fFuture = std::async(std::launch::async, + StartGRAnalyzer, + Command, + &stop_rcnp_signal, + [&](RCNPEvent* event) { + rcnp_queue.Push(event); + }, + TGRUTOptions::Get()->SaveRCNPTree(), + !TGRUTOptions::Get()->StartGUI() + ); + + //LoadFakeTimestamps(); + std::this_thread::sleep_for(std::chrono::seconds(4)); +} + +int TRCNPSource::GetEvent(TRawEvent& event) { + event.SetFileType(fFileType); + + // TRCNPEvent* rcnp_evt = new TRCNPEvent; + RCNPEvent* rcnp;// = new RCNPEvent; + + // Try to get event from RCNP event queue + if (rcnp_queue.Pop(rcnp,200) == -1 ){ +#ifndef __CINT__ + // if offline + if (TGRUTOptions::Get()->ExitAfterSorting()) { + auto status = fFuture.wait_for(std::chrono::milliseconds(0)); + // check if RCNP analyzer is done + if (status == std::future_status::ready) { + std::cout << "RCNP analyzer thread finished ##" << std::endl; + return -1; + } else { + std::cout << "RCNP analyzer still running, awaiting data.." << std::endl; + // try again to pop an event + if (rcnp_queue.Pop(rcnp,1000) == -1) { + // if it failed again check if the RCNP analyzer is done now + status = fFuture.wait_for(std::chrono::milliseconds(1000)); + if (status == std::future_status::ready) { + return -1; + } else { + throw std::runtime_error("TRCNPSource::GetEvent GRAnalyzer loop is hung."); + } + } + } + } else { + return -1; + } +#endif + } + + + //char* ptrbytes = (char*)calloc(1,sizeof(rcnp)); + //*reinterpret_cast(ptrbytes) = rcnp; + //TSmartBuffer eventbuffer(ptrbytes,sizeof(rcnp)); + //event.SetData(eventbuffer); + + double time = 0; + event.SetDataPtr((void*)rcnp); + if (TGRUTOptions::Get()->GRSingles()) { + // singles (ignoring myriad timestamp) + static ULong_t counter = 0; + counter += TGRUTOptions::Get()->BuildWindow()*1.5; + time = counter; + } + else { + // normal, use the GR myriad timestamp and if it's not present set the time to a random constant + time = rcnp->GR_MYRIAD(0); + if (time == -441441) { + + static int not_found = 0; + if (not_found < 100) { + std::cout << "GR Myriad timestamp not found!!!" << std::endl; + if (not_found == 99) { + std::cout << "More than 100 GR events are missing a timestamp. This warning is being supressed, but you should probably investigate this." << std::endl; + } + } + + time = 2112; + } + } + + rcnp->SetTimestamp(time); + event.SetFragmentTimestamp(time); + + return sizeof(rcnp); +} + +std::string TRCNPSource::Status(bool long_description) const { + return Form("%s: %s %8.2f MB given %s / %s Unknown MB total %s => %s %3.02f MB/s processed %s", + SourceDescription(long_description).c_str(), + DCYAN, GetBytesGiven()/1e6, RESET_COLOR, + BLUE, RESET_COLOR, + GREEN, GetAverageRate()/1e6, RESET_COLOR); +} +std::string TRCNPSource::SourceDescription(bool long_description) const {return "File: "+std::string("RCNP_BLD: ")+fCommand;} + + +// template<> +// int ThreadsafeQueue::ObjectSize(RCNPEvent& event) { +// return event.data.size(); +// } + +template<> +int ThreadsafeQueue::ObjectSize(RCNPEvent*& event) const { + return event->data.size(); +} + + +#endif diff --git a/libraries/TRawFormat/TRawBanks.cxx b/libraries/TRawFormat/TRawBanks.cxx index ee8f9d00..ad8fc915 100644 --- a/libraries/TRawFormat/TRawBanks.cxx +++ b/libraries/TRawFormat/TRawBanks.cxx @@ -70,9 +70,16 @@ std::ostream& operator<<(std::ostream& os, const TRawEvent::G4SimPacket &packet) UShort_t TRawEvent:: SwapShort(UShort_t datum) { - UShort_t temp = 0; - temp = (datum&0x00ff); - return (temp<<8) + (datum>>8); + UShort_t temp = 0; + temp = (datum&0x00ff); + return (temp<<8) + (datum>>8); +} +UInt_t TRawEvent::SwapInt(UInt_t datum) { + UInt_t t1 = 0, t2 = 0, t3 = 0; + t1 = (datum&0x000000ff); + t2 = (datum&0x0000ff00); + t3 = (datum&0x00ff0000); + return (t1<<24) + (t2<<8) + (t3>>8) + (datum>>24); } void TRawEvent::SwapMode3Head(TRawEvent::GEBMode3Head &head) { @@ -122,6 +129,256 @@ std::ostream& operator<<(std ::ostream& os, const TRawEvent::GEBMode3Data &data) return os; } +UShort_t TRawEvent::GEBArgonneHead::GetGA() const { return ((GA_packetlength & 0xf800) >> 11); } +UShort_t TRawEvent::GEBArgonneHead::GetLength() const { return (GA_packetlength & 0x7ff); } +UShort_t TRawEvent::GEBArgonneHead::GetBoardID() const { return ((ud_channel & 0xfff0) >> 4); } +UShort_t TRawEvent::GEBArgonneHead::GetChannel() const { return (ud_channel & 0xf); } +UInt_t TRawEvent::GEBArgonneHead::GetHeaderType() const { return (hdrlength_evttype_hdrtype & 0xf); } +UShort_t TRawEvent::GEBArgonneHead::GetEventType() const { return ((hdrlength_evttype_hdrtype & 0x380) >> 7); } +UShort_t TRawEvent::GEBArgonneHead::GetHeaderLength() const { return ((hdrlength_evttype_hdrtype & 0xfc00) >> 10); } +ULong_t TRawEvent::GEBArgonneHead::GetDisc() const { return (((ULong_t)disc_high) << 32) + ((ULong_t)disc_low); } + +ULong_t TRawEvent::GEBArgonneLEDv11::GetPreviousLED() const { return (((ULong_t)led_high_prev) << 16) + ((ULong_t)led_low_prev); } +UInt_t TRawEvent::GEBArgonneLEDv11::GetBaseline() const { return ((sampled_baseline & 0x00FFFFFF) >> 0); } +UInt_t TRawEvent::GEBArgonneLEDv11::GetPreRiseE() const { return (postrise_sum_low_prerise_sum & 0xffffff); } +UInt_t TRawEvent::GEBArgonneLEDv11::GetPostRiseE() const { return ((postrise_sum_low_prerise_sum & 0xff000000)>>24) + (((UInt_t)postrise_sum_high) << 8); } +ULong_t TRawEvent::GEBArgonneLEDv11::GetPeakTimestamp() const { return ((ULong_t)timestamp_peak_low) + (((ULong_t)timestamp_peak_high)<<16); } +UShort_t TRawEvent::GEBArgonneLEDv11::GetPostRiseSampleBegin() const { return (postrise_begin_sample & 0x3fff); } +UShort_t TRawEvent::GEBArgonneLEDv11::GetPostRiseSampleEnd() const { return (postrise_end_sample & 0x3fff); } +UShort_t TRawEvent::GEBArgonneLEDv11::GetPreRiseSampleBegin() const { return (prerise_begin_sample & 0x3fff); } +UShort_t TRawEvent::GEBArgonneLEDv11::GetPreRiseSampleEnd() const { return (prerise_end_sample & 0x3fff); } +UShort_t TRawEvent::GEBArgonneLEDv11::GetBaseSample() const { return (base_sample & 0x3fff); } +UShort_t TRawEvent::GEBArgonneLEDv11::GetPeakSample() const { return (peak_sample & 0x3fff); } +UShort_t TRawEvent::GEBArgonneLEDv11::ExternalDiscFlag() const { return ((flags & 0x100)>>8); } +UShort_t TRawEvent::GEBArgonneLEDv11::PeakValidFlag() const { return ((flags & 0x200)>>9); } +UShort_t TRawEvent::GEBArgonneLEDv11::OffsetFlag() const { return ((flags & 0x400)>>10); } +UShort_t TRawEvent::GEBArgonneLEDv11::SyncErrorFlag() const { return ((flags & 0x1000)>>12); } +UShort_t TRawEvent::GEBArgonneLEDv11::GeneralErrorFlag() const { return ((flags & 0x2000)>>13); } +UShort_t TRawEvent::GEBArgonneLEDv11::PileUpOnlyFlag() const { return ((flags & 0x4000)>>14); } +UShort_t TRawEvent::GEBArgonneLEDv11::PileUpFlag() const { return ((flags & 0x8000)>>15); } + +ULong_t TRawEvent::GEBArgonneLEDv18::GetPreviousLED() const { return (((ULong_t)led_high_prev) << 16) + ((ULong_t)led_low_prev); } +UInt_t TRawEvent::GEBArgonneLEDv18::GetBaseline() const { return ((sampled_baseline & 0x00FFFFFF) >> 0); } +UInt_t TRawEvent::GEBArgonneLEDv18::GetPreRiseE() const { return (postrise_sum_low_prerise_sum & 0xffffff); } +UInt_t TRawEvent::GEBArgonneLEDv18::GetPostRiseE() const { return ((postrise_sum_low_prerise_sum & 0xff000000)>>24) + (((UInt_t)postrise_sum_high) << 8); } +ULong_t TRawEvent::GEBArgonneLEDv18::GetTrigTimestamp() const { return ((ULong_t)timestamp_trigger_low) /*+ (((ULong_t)timestamp_trigger_high)<<16)*/; } // not fully implemented +UShort_t TRawEvent::GEBArgonneLEDv18::GetLastPostRiseEnterSample() const { return (last_postrise_enter_sample & 0x3fff); } +UShort_t TRawEvent::GEBArgonneLEDv18::GetLastPostRiseLeaveSample() const { return (last_postrise_leave_sample & 0x3fff); } +UShort_t TRawEvent::GEBArgonneLEDv18::GetPostRiseLeaveSample() const { return (postrise_leave_sample & 0x3fff); } +UShort_t TRawEvent::GEBArgonneLEDv18::GetPreRiseEnterSample() const { return (prerise_enter_sample & 0x3fff); } +UShort_t TRawEvent::GEBArgonneLEDv18::GetPreRiseLeaveSample() const { return (prerise_leave_sample & 0x3fff); } +UShort_t TRawEvent::GEBArgonneLEDv18::GetBaseSample() const { return (base_sample & 0x3fff); } +UShort_t TRawEvent::GEBArgonneLEDv18::GetPeakSample() const { return (peak_sample & 0x3fff); } +UShort_t TRawEvent::GEBArgonneLEDv18::WriteFlag() const { return ((flags & 0x20)>>5); } +UShort_t TRawEvent::GEBArgonneLEDv18::VetoFlag() const { return ((flags & 0x40)>>6); } +UShort_t TRawEvent::GEBArgonneLEDv18::ExternalDiscFlag() const { return ((flags & 0x100)>>8); } +UShort_t TRawEvent::GEBArgonneLEDv18::PeakValidFlag() const { return ((flags & 0x200)>>9); } +UShort_t TRawEvent::GEBArgonneLEDv18::OffsetFlag() const { return ((flags & 0x400)>>10); } +UShort_t TRawEvent::GEBArgonneLEDv18::SyncErrorFlag() const { return ((flags & 0x1000)>>12); } +UShort_t TRawEvent::GEBArgonneLEDv18::GeneralErrorFlag() const { return ((flags & 0x2000)>>13); } +UShort_t TRawEvent::GEBArgonneLEDv18::PileUpOnlyFlag() const { return ((flags & 0x4000)>>14); } +UShort_t TRawEvent::GEBArgonneLEDv18::PileUpFlag() const { return ((flags & 0x8000)>>15); } + + +//ULong_t TRawEvent::GEBArgonneCFDv18::GetPreviousCFD() const { return (((ULong_t)cfd_high_prev) << 16) + ((ULong_t)cfd_low_prev); } +ULong_t TRawEvent::GEBArgonneCFDv18::GetPrevCFD(const GEBArgonneHead* header) const { + if (TSMatchFlag() == 1) { + ULong_t current_cfd= header->GetDisc(); + return ((current_cfd & 0x00ffffc0000000) + (((ULong_t)(cfd_mid_prev & 0x3fff)) << 16) + (ULong_t)cfd_low_prev); + } else { + return 0xffffffffffffffff; + } +} +#define STR(x) #x << ": " << x +Double_t TRawEvent::GEBArgonneCFDv18::GetCFD() const { + // std::cout << STR(CFDValidFlag()) << std::endl; + // std::cout << STR(cfd_sample0) << std::endl; + // std::cout << STR(cfd_sample1) << std::endl; + // std::cout << STR(cfd_sample2) << std::endl; + // std::cout << STR(GetCFD0()) << std::endl; + // std::cout << STR(GetCFD1()) << std::endl; + // std::cout << STR(GetCFD2()) << std::endl; + // std::cout << std::endl; + // std::cin.get(); + return 0. - GetCFD2()*2./(GetCFD2()-GetCFD0()); +} +#undef STR + +Short_t TRawEvent::GetSigned14BitFromUShort(UShort_t ushort) { + return ((Short_t)((ushort & 0x3fff) << 2))/4; +} + +Short_t TRawEvent::GEBArgonneCFDv18::GetCFD0() const { return GetSigned14BitFromUShort(cfd_sample0); } +Short_t TRawEvent::GEBArgonneCFDv18::GetCFD1() const { return GetSigned14BitFromUShort(cfd_sample1); } +Short_t TRawEvent::GEBArgonneCFDv18::GetCFD2() const { return GetSigned14BitFromUShort(cfd_sample2); } + +UInt_t TRawEvent::GEBArgonneCFDv18::GetBaseline() const { return ((sampled_baseline & 0x00FFFFFF) >> 0); } +UInt_t TRawEvent::GEBArgonneCFDv18::GetPreRiseE() const { return (postrise_sum_low_prerise_sum & 0xffffff); } +UInt_t TRawEvent::GEBArgonneCFDv18::GetPostRiseE() const { return ((postrise_sum_low_prerise_sum & 0xff000000)>>24) + (((UInt_t)postrise_sum_high) << 8); } +ULong_t TRawEvent::GEBArgonneCFDv18::GetTrigTimestamp() const { return ((ULong_t)timestamp_trigger_low) /*+ (((ULong_t)timestamp_trigger_high)<<16)*/; } // not fully implemented +UShort_t TRawEvent::GEBArgonneCFDv18::GetLastPostRiseEnterSample() const { return (last_postrise_enter_sample & 0x3fff); } +UShort_t TRawEvent::GEBArgonneCFDv18::GetPostRiseSampleBegin() const { return (postrise_begin_sample & 0x3fff); } +UShort_t TRawEvent::GEBArgonneCFDv18::GetPostRiseSampleEnd() const { return (postrise_end_sample & 0x3fff); } +UShort_t TRawEvent::GEBArgonneCFDv18::GetPreRiseSampleBegin() const { return (prerise_begin_sample & 0x3fff); } +UShort_t TRawEvent::GEBArgonneCFDv18::GetPreRiseSampleEnd() const { return (prerise_end_sample & 0x3fff); } +UShort_t TRawEvent::GEBArgonneCFDv18::GetBaseSample() const { return (base_sample & 0x3fff); } +UShort_t TRawEvent::GEBArgonneCFDv18::GetPeakSample() const { return (peak_sample & 0x3fff); } +UShort_t TRawEvent::GEBArgonneCFDv18::WriteFlag() const { return ((flags & 0x20)>>5); } +UShort_t TRawEvent::GEBArgonneCFDv18::VetoFlag() const { return ((flags & 0x40)>>6); } +UShort_t TRawEvent::GEBArgonneCFDv18::TSMatchFlag() const { return ((flags & 0x80)>>7); } +UShort_t TRawEvent::GEBArgonneCFDv18::ExternalDiscFlag() const { return ((flags & 0x100)>>8); } +UShort_t TRawEvent::GEBArgonneCFDv18::PeakValidFlag() const { return ((flags & 0x200)>>9); } +UShort_t TRawEvent::GEBArgonneCFDv18::OffsetFlag() const { return ((flags & 0x400)>>10); } +UShort_t TRawEvent::GEBArgonneCFDv18::CFDValidFlag() const { return ((flags & 0x800)>>11); } +UShort_t TRawEvent::GEBArgonneCFDv18::SyncErrorFlag() const { return ((flags & 0x1000)>>12); } +UShort_t TRawEvent::GEBArgonneCFDv18::GeneralErrorFlag() const { return ((flags & 0x2000)>>13); } +UShort_t TRawEvent::GEBArgonneCFDv18::PileUpOnlyFlag() const { return ((flags & 0x4000)>>14); } +UShort_t TRawEvent::GEBArgonneCFDv18::PileUpFlag() const { return ((flags & 0x8000)>>15); } + +void TRawEvent::SwapArgonneHead(TRawEvent::GEBArgonneHead& header) { + header.GA_packetlength = SwapShort(header.GA_packetlength); + header.ud_channel = SwapShort(header.ud_channel); + header.disc_low = SwapInt(header.disc_low); + header.hdrlength_evttype_hdrtype = SwapShort(header.hdrlength_evttype_hdrtype); + header.disc_high = SwapShort(header.disc_high); +} +void TRawEvent::SwapArgonneLEDv11(TRawEvent::GEBArgonneLEDv11& data) { + data.led_low_prev = SwapShort(data.led_low_prev); + data.flags = SwapShort(data.flags); + data.led_high_prev = SwapInt(data.led_high_prev); + data.sampled_baseline = SwapInt(data.sampled_baseline); + data.postrise_sum_low_prerise_sum = SwapInt(data.postrise_sum_low_prerise_sum); + data.timestamp_peak_low = SwapShort(data.timestamp_peak_low); + data.postrise_sum_high = SwapShort(data.postrise_sum_high); + data.timestamp_peak_high = SwapInt(data.timestamp_peak_high); + data.postrise_end_sample = SwapShort(data.postrise_end_sample); + data.postrise_begin_sample = SwapShort(data.postrise_begin_sample); + data.prerise_end_sample = SwapShort(data.prerise_end_sample); + data.prerise_begin_sample = SwapShort(data.prerise_begin_sample); + data.base_sample = SwapShort(data.base_sample); + data.peak_sample = SwapShort(data.peak_sample); +} +void TRawEvent::SwapArgonneLEDv18(TRawEvent::GEBArgonneLEDv18& data) { + data.led_low_prev = SwapShort(data.led_low_prev); + data.flags = SwapShort(data.flags); + data.led_high_prev = SwapInt(data.led_high_prev); + data.sampled_baseline = SwapInt(data.sampled_baseline); + data.postrise_sum_low_prerise_sum = SwapInt(data.postrise_sum_low_prerise_sum); + data.timestamp_peak_low = SwapShort(data.timestamp_peak_low); + data.postrise_sum_high = SwapShort(data.postrise_sum_high); + //data.timestamp_peak_high = SwapInt(data.timestamp_peak_high); + data.timestamp_trigger_low = SwapShort(data.timestamp_trigger_low); // not fully implemented + data.last_postrise_enter_sample = SwapShort(data.last_postrise_enter_sample); + data.last_postrise_leave_sample = SwapShort(data.last_postrise_leave_sample); + data.postrise_leave_sample = SwapShort(data.postrise_leave_sample); + data.prerise_enter_sample = SwapShort(data.prerise_enter_sample); + data.prerise_leave_sample = SwapShort(data.prerise_leave_sample); + data.base_sample = SwapShort(data.base_sample); + data.peak_sample = SwapShort(data.peak_sample); +} + +void TRawEvent::SwapArgonneCFDv18(TRawEvent::GEBArgonneCFDv18& data) { + data.cfd_low_prev = SwapShort(data.cfd_low_prev); + data.flags = SwapShort(data.flags); + data.cfd_sample0 = SwapShort(data.cfd_sample0); + data.cfd_mid_prev = SwapShort(data.cfd_mid_prev); + data.sampled_baseline = SwapInt(data.sampled_baseline); + data.cfd_sample2 = SwapShort(data.cfd_sample2); + data.cfd_sample1 = SwapShort(data.cfd_sample1); + data.postrise_sum_low_prerise_sum = SwapInt(data.postrise_sum_low_prerise_sum); + data.timestamp_peak_low = SwapShort(data.timestamp_peak_low); + data.postrise_sum_high = SwapShort(data.postrise_sum_high); + data.timestamp_trigger_low = SwapShort(data.timestamp_trigger_low); + data.last_postrise_enter_sample = SwapShort(data.last_postrise_enter_sample); + data.postrise_end_sample = SwapShort(data.postrise_end_sample); + data.postrise_begin_sample = SwapShort(data.postrise_begin_sample); + data.prerise_end_sample = SwapShort(data.prerise_end_sample); + data.prerise_begin_sample = SwapShort(data.prerise_begin_sample); + data.base_sample = SwapShort(data.base_sample); + data.peak_sample = SwapShort(data.peak_sample); +} + +#define STR(x) "\t GEBArgonne "<< #x <<": " << x +std::ostream& operator<<(std::ostream& os, const TRawEvent::GEBArgonneHead& header) { + return os << "-- Argonne header packet -- \n" + << STR(header.GA_packetlength) << "\n" + << STR(header.ud_channel) << "\n" + << STR(header.disc_low) << "\n" + << STR(header.hdrlength_evttype_hdrtype) << "\n" + << STR(header.disc_high) << std::endl; +} +std::ostream& operator<<(std::ostream& os, const TRawEvent::GEBArgonneLEDv11& data) { + return os << "-- Argonne LEDv11 data packet --" + << STR(data.led_low_prev) << "\n" + << STR(data.flags) << "\n" + << STR(data.led_high_prev) << "\n" + << STR(data.sampled_baseline) << "\n" + << STR(data._blank_) << "\n" + << STR(data.postrise_sum_low_prerise_sum) << "\n" + << STR(data.timestamp_peak_low) << "\n" + << STR(data.postrise_sum_high) << "\n" + << STR(data.timestamp_peak_high) << "\n" + << STR(data.postrise_end_sample) << "\n" + << STR(data.postrise_begin_sample) << "\n" + << STR(data.prerise_end_sample) << "\n" + << STR(data.prerise_begin_sample) << "\n" + << STR(data.base_sample) << "\n" + << STR(data.peak_sample) << std::endl; +} +std::ostream& operator<<(std::ostream& os, const TRawEvent::GEBArgonneLEDv18& data) { + return os << "-- Argonne LEDv18 data packet --" + << STR(data.led_low_prev) << "\n" + << STR(data.flags) << "\n" + << STR(data.led_high_prev) << "\n" + << STR(data.sampled_baseline) << "\n" + << STR(data._blank_) << "\n" + << STR(data.postrise_sum_low_prerise_sum) << "\n" + << STR(data.timestamp_peak_low) << "\n" + << STR(data.postrise_sum_high) << "\n" + << STR(data.timestamp_trigger_low) << "\n" + << STR(data.last_postrise_enter_sample) << "\n" + << STR(data.last_postrise_leave_sample) << "\n" + << STR(data.postrise_leave_sample) << "\n" + << STR(data.prerise_enter_sample) << "\n" + << STR(data.prerise_leave_sample) << "\n" + << STR(data.base_sample) << "\n" + << STR(data.peak_sample) << std::endl; +} +std::ostream& operator<<(std::ostream& os, const TRawEvent::GEBArgonneCFDv18& data) { + return os << "-- Argonne CFDv18 data packet --" + + << STR(data.cfd_low_prev) << "\n" + << STR(data.flags) << "\n" + << STR(data.cfd_sample0) << "\n" + << STR(data.cfd_mid_prev) << "\n" + << STR(data.sampled_baseline) << "\n" + << STR(data.cfd_sample2) << "\n" + << STR(data.cfd_sample1) << "\n" + << STR(data.postrise_sum_low_prerise_sum) << "\n" + << STR(data.timestamp_peak_low) << "\n" + << STR(data.postrise_sum_high) << "\n" + << STR(data.timestamp_trigger_low) << "\n" + << STR(data.last_postrise_enter_sample) << "\n" + << STR(data.postrise_end_sample) << "\n" + << STR(data.postrise_begin_sample) << "\n" + << STR(data.prerise_end_sample) << "\n" + << STR(data.prerise_begin_sample) << "\n" + << STR(data.base_sample) << "\n" + << STR(data.peak_sample) << "\n" + << STR(data.WriteFlag()) << "\n" + << STR(data.VetoFlag()) << "\n" + << STR(data.TSMatchFlag()) << "\n" + << STR(data.ExternalDiscFlag()) << "\n" + << STR(data.PeakValidFlag()) << "\n" + << STR(data.OffsetFlag()) << "\n" + << STR(data.CFDValidFlag()) << "\n" + << STR(data.SyncErrorFlag()) << "\n" + << STR(data.GeneralErrorFlag()) << "\n" + << STR(data.PileUpOnlyFlag()) << "\n" + << STR(data.PileUpFlag()) << std::endl; +} +#undef STR + std::ostream& operator<<(std::ostream& os,const TRawEvent::GEBS800Header &head) { return os << "-- S800 Header \"packet\" -- \n" << "\t S800 timestamp: " << head.S800_timestamp << "\n" diff --git a/libraries/TRawFormat/TRawEvent.cxx b/libraries/TRawFormat/TRawEvent.cxx index d91f5331..659d29df 100644 --- a/libraries/TRawFormat/TRawEvent.cxx +++ b/libraries/TRawFormat/TRawEvent.cxx @@ -18,6 +18,7 @@ TRawEvent::TRawEvent() { fEventHeader.datum2 = 0; fFileType = kFileType::UNKNOWN_FILETYPE; fTimestamp = -1; + fDataPtr = nullptr; } void TRawEvent::Copy(TObject &rhs) const { @@ -25,7 +26,8 @@ void TRawEvent::Copy(TObject &rhs) const { ((TRawEvent&)rhs).fEventHeader = fEventHeader; ((TRawEvent&)rhs).fBody = fBody; ((TRawEvent&)rhs).fFileType = fFileType; - ((TRawEvent&)rhs).fTimestamp = fTimestamp; + ((TRawEvent&)rhs).fTimestamp = fTimestamp; + ((TRawEvent&)rhs).fDataPtr = fDataPtr; } TRawEvent::TRawEvent(const TRawEvent &rhs) @@ -46,6 +48,7 @@ TRawEvent &TRawEvent::operator=(const TRawEvent &rhs) { fBody = rhs.fBody; fFileType = rhs.fFileType; fTimestamp = rhs.fTimestamp; + fDataPtr = rhs.fDataPtr; return *this; } @@ -66,7 +69,8 @@ Int_t TRawEvent::GetEventType() const { switch(fFileType){ case NSCL_EVT: return ((EVTHeader*)(&fEventHeader))->type(); - + + case ANL_RAW: case GRETINA_MODE2: case GRETINA_MODE3: return ((GEBHeader*)(&fEventHeader))->type(); @@ -83,9 +87,12 @@ Int_t TRawEvent::GetBodySize() const { case NSCL_EVT: return ((EVTHeader*)(&fEventHeader))->size() - sizeof(RawHeader); //Size in nscldaq is inclusive + case ANL_RAW: case GRETINA_MODE2: case GRETINA_MODE3: return ((GEBHeader*)(&fEventHeader))->size() + sizeof(Long_t); //Size in gretinadaq is exclusive, plus timestamp + case RCNP_BLD: + return sizeof(void*); default: return 0; @@ -111,6 +118,7 @@ Long_t TRawEvent::GetTimestamp() const { case NSCL_EVT: return ((TNSCLEvent*)this)->GetTimestamp(); + case ANL_RAW: case GRETINA_MODE2: case GRETINA_MODE3: return ((TGEBEvent*)this)->GetTimestamp(); @@ -135,6 +143,7 @@ const char* TRawEvent::GetPayload() const { case NSCL_EVT: return ((TNSCLEvent*)this)->GetPayload(); + case ANL_RAW: case GRETINA_MODE2: case GRETINA_MODE3: return ((TGEBEvent*)this)->GetPayload(); @@ -159,6 +168,7 @@ TSmartBuffer TRawEvent::GetPayloadBuffer() const { case NSCL_EVT: return ((TNSCLEvent*)this)->GetPayloadBuffer(); + case ANL_RAW: case GRETINA_MODE2: case GRETINA_MODE3: return ((TGEBEvent*)this)->GetPayloadBuffer(); diff --git a/libraries/TRawFormat/TRawSource.cxx b/libraries/TRawFormat/TRawSource.cxx index 0b7e8733..02831df9 100644 --- a/libraries/TRawFormat/TRawSource.cxx +++ b/libraries/TRawFormat/TRawSource.cxx @@ -1,10 +1,8 @@ #include "TRawSource.h" - #include - #include "TString.h" - #include "TGRUTOptions.h" +#include "TRCNPSource.h" ClassImp(TRawEventSource) @@ -79,6 +77,20 @@ TRawEventSource* TRawEventSource::EventSource(const char* filename, file_type = TGRUTOptions::Get()->DetermineFileType(filename); } + TRawEventSource* source; + + if (hasSuffix(filename,".bld")){ + std::string command; + if (std::string(filename) == "online.bld") { + std::cout << "Going online with TRCNPSource..." < 180: + phi -= 360 + placed = clover(r,theta,phi,CloverType.Yale) + #placed.print_clover_placement(i+1,coord="Spherical") + #placed.print_clover_placement(i+1) + #placed.print_crystal_placement(i+1) + placed.print_segment_placement(i+1) + #placed.print_crystal_placement(i+1,coord="Spherical") + + + # 90 degree detectors (yale) + for i in range(0,8): + r = 17.70 + theta = 90.0 + phi = 45*i + placed = clover(r,theta,phi,CloverType.Yale) + #placed.print_clover_placement(i+4+1,coord="Spherical") + #placed.print_clover_placement(i+4+1) + #placed.print_crystal_placement(i+4+1) + placed.print_segment_placement(i+4+1) + #placed.print_crystal_placement(i+4+1,coord="Spherical") + + # 135 degree detectors (Tohoku) + for i in range(0,4): + r = 17.70 + theta = 135.0 + phi = 45+90.0*i + if phi > 180: + phi -= 360 + placed = clover(r,theta,phi,CloverType.Yale) + #placed.print_clover_placement(i+12+1,coord="Spherical") + #placed.print_clover_placement(i+12+1) + #placed.print_crystal_placement(i+12+1) + placed.print_segment_placement(i+12+1) + #placed.print_crystal_placement(i+12+1,coord="Spherical")