diff --git a/.gitmodules b/.gitmodules
index 929fa390..1d229c40 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,6 @@
[submodule "GRAnalyzer"]
path = GRAnalyzer
- url = https://github.com/CAGRA-GrandRaiden/GRAnalyzer
+ url = git@github.com:CAGRA-GrandRaiden/GRAnalyzer.git
+[submodule "MPIEventLoop"]
+ path = MPIEventLoop
+ url = git@github.com:CAGRA-GrandRaiden/MPIEventLoop.git
diff --git a/.grutrc b/.grutrc
index 2d699de4..4bb9edae 100644
--- a/.grutrc
+++ b/.grutrc
@@ -2,14 +2,11 @@ Unix.*.Root.MacroPath: .:$(GRUTSYS)/util:$(ROOTSYS)/macros
#Unix.*.Root.DynamicPath: .:~/rootlibs:$(ROOTSYS)/lib:$/home/tiguser/packages/SharcAnalysis
#default MakeHistos library
-#GRUT.HistLib: $(GRUTSYS)/libraries/libMakeHistos.so
-GRUT.HistLib: $(GRUTSYS)/libraries/libFastScintHists.so
-#GRUT.HistLib: $(GRUTSYS)/libraries/libPolarHists.so
-#GRUT.HistLib: $(GRUTSYS)/libraries/libMakeSegaJanusHistos.so
+GRUT.HistLib: $(GRUTSYS)/libraries/libRCNPsav.so
GRUT.GuiSetup: $(GRUTSYS)/gui_params.hist
#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/GRAnalyzer b/GRAnalyzer
index 57a0a3a5..54c6c041 160000
--- a/GRAnalyzer
+++ b/GRAnalyzer
@@ -1 +1 @@
-Subproject commit 57a0a3a5de3fc2c86a2b90f2364bf737c4dab2af
+Subproject commit 54c6c0414dcdd93579c44a6ab5220b15b1e9bcad
diff --git a/MPIEventLoop b/MPIEventLoop
new file mode 160000
index 00000000..27f2e4c2
--- /dev/null
+++ b/MPIEventLoop
@@ -0,0 +1 @@
+Subproject commit 27f2e4c266423c9143acef01643ee8dc27f0107c
diff --git a/Readme.md b/Readme.md
index c40c14aa..c6b2f225 100644
--- a/Readme.md
+++ b/Readme.md
@@ -5,6 +5,148 @@ A generic unpacker and analysis package for gamma-ray spectroscopy.
The doxygen documentation can be found [here](https://pcbend.github.io/GRUTinizer).
+Tutorial for July RCNP Test Experiment 2016:
+--
+The most important thing to know is that in order to use GRUTinizer, you must *first* run the ```grutsh``` command in your shell session. (e.g. after you have logged in to cagragr@miho-1 or aino-1, you type ```grutsh```. This will source a number of need scripts and directories to correctly setup your environment to compile and run GRUTinizer.
-generic comments.
+Next, copy the ```~/ana/template/``` directory to your own analysis space. Compile it with
+
+``` make -j15 ```
+
+Note, you do not need to ```make clean``` unless except in rare instances. Make should handle the dependencies for you.
+
+
+
+Key program options (flags) for running GRUTinizer:
+
+Options:
+
+arg Input file(s)
+
+**-H [ --histos ] attempt to run events through MakeHisto lib.**
+
+**-m [ --sort-multiple ] If passed multiple raw data files, treat them as one file.**
+
+**-s [ --sort ] Attempt to loop through root files.**
+
+**--build-window arg Build window, timestamp units**
+
+**-g [ --start-gui ] Start the GUI**
+
+**-o [ --output ] arg Root output file**
+
+**-S [ --gr-singles ] Ignore GR timestamps and take singles.**
+
+**--hist-output arg Output file for histograms**
+
+**-q [ --quit ] Run in batch mode**
+
+**-h -? [ --help ] Show this help message**
+
+
+Online CAGRA example:
+--
+``` ./bin/grutinizer -Hmg config/rcnpchannels.cal libraries/libRCNPhistos.so cagra_data/data1/run_1018.gtd01_000_010* -o /dev/null ```
+* Above, -H specifies that a histogram library will be used. For each built event, the function MakeHistograms in ```./histos/RCNPhistos.cxx ``` will be called. Any new *.cxx files put in ./histos will be automatically compiled into a corresponding library and put in ./libraries.
+
+* Above -m indicates that multiple raw files will be sorted simultaneously and attempted to event correlated. This flag should almost always be present when multiple raw files to be sorted.
+
+* -g launches the graphical user interface. Some helper functions and key commands are described in the Interactive Analysis section below.
+
+* -o /dev/null indicates that the output root tree will not be created, and only histograms will be made for online monitoring
+
+Online Grand Raiden example:
+--
+``` ./bin/grutinizer -Hg config/rcnpchannels.cal libraries/libRCNPhistos.so online.bld -o /dev/null ```
+* All options here are similar to those found above, but now we are using a special online.bld file to indicate that GRUTinizer should utilize the online functionality of the GRAnalyzer to retrieve GR event data. Note that online mode only works when you are running GRUTinizer from *aino-1*, since this is the computer on which the Grand Raiden DAQ is run.
+
+
+Offline CAGRA example:
+--
+``` ./bin/grutinizer -Hmq config/rcnpchannels.cal libraries/libRCNPhistos.so cagra_data/data1/run_1018.gtd01_000_010* -o run1018.root ```
+
+* The only difference here is that a -o specifies the name of the rootfile that will contain the built root tree from the raw data (ie, we are not skipping this step as in the previous example). This can be nice for calibrations as this root tree can be read in just like any other raw file and analyzed, without needing to resort all the data.
+
+* -q specifies that we want to close GRUTinizer when analysis and sorting is done. Note that in this mode, the GUI is not opened.
+
+
+Offline Grand Raiden example:
+--
+``` ./bin/grutinizer -SHg config/rcnpchannels.cal libraries/libRCNPhistos.so ~/data/run1016.bld ```
+
+* In this case, we are running the graphical interface in offline mode, while sorting data from a file that was produced at some point in the past. Since we did not specify an output filename, the file should detect the run number and name it appropriately (note that this doesnt yet work CAGRA, I think).
+
+* -S here is a special flag to indicate GR singles mode. This is necessarry if for some reason, the MYRIAD timestamp module is not functioning, but looking at the raw singles data is still desired. This flag can be used in offline or online mode.
+
+
+Coincident CAGRA + GR example:
+
+``` ./bin/grutinizer -Hmg config/rcnpchannels.cal libraries/libRCNPhistos.so online.bld cagra_data/data1/run_1018.gtd01_000_010* -o /dev/null ```
+
+* Here we attach online to both GR and to raw CAGRA data
+
+* In this setting -m is critical as it indicates that the different raw sources should be built together.
+
+
+
+
+**INTERACTIVE ANALYSIS**
+--
+
+
+In addition to the many libraries in TGRUTAnalysis to make analysis easier, GRUTinizer also takes control of some of the behind the scene functions of ROOT to make analysis a bit easier.
+
+To take advantage of these features all one has to do is start GRUTinizer! They are implemented when examining and natural root classes, whether the where draw from a tree, made fresh or load from a file.
+
+* **GlobalFunctions**
+
+* **GCanvas**
The most notable difference, is the replacement of the TCanvas with GCanvas. This replacement is done naturally - no changes from either existing ROOT scripts or GRUTinizer scripts are needed to take advantage of the GCanvas default behavior.
+
+## Universal Commands
+
+| Key | Action |
+|:-----|:------|
+| **F2** | Show/Hide Editor Tab |
+
+## TH1 Commands
+| Key | Action |
+|:------|:------|
+| | All normal root commands/interactions.|
+| **m** | Toggle on/off marker mode; when on, the histogram will remember and display the last four clicks as marks on the histogram.|
+| **p** | If the 1d hist was made using the global ProjectionX/ProjectionY; gating the original 2D matrix this histogram came from is possible by placing markers around the gate and pressing p. The gates spectra is immediately drawn. |
+| **B** | Cycle through types of automatic background subtraction used when projecting with **p**. Current types include: No subtraction, Fraction of the total, subtract gate from the 3rd marker (gate size set to the distance between marker 1 and 2). |
+| **b** | Set the background, how it is set depends on **B**.|
+| **n** | Remove all markers / functions drawn on the histogram (not gates!).|
+| **e** | Expand the x-axis range between the last two markers.|
+| **E** | Bring up dialogue box used to set desired x-axis range.|
+| **o** | Unzoom the entire histogram.|
+| **Arrow Left/Right** | When zoomed in, mover the display region to the left/right by one half of the region currently displayed.|
+| **Arrow Up/Down** | Quickly display the next histogram stored in memory, especially useful when gating to go back and forth between gates and the total projection. (currently only available in GH1D) |
+| **f** | Ryan D's TPeak Fit (proper skewd gaus for gamma-rays with automatic bg) with minimum output. |
+| **g** | Gaus fit with linear background, displays results of the fit **RESULTS STILL NEED TO BE VERIFIED** |
+| **i** | Raw integral of counts between the two markers |
+| **s** | Show peak values. |
+| **S** | Remove peak values. |
+| **l** | Toggle y-axis linear. |
+
+
+## GH2I Commands
+| Key | Action |
+|:------|:------|
+| | All normal root commands/interactions.|
+| middle-click | Select the current pad, current pad is outlined by a red border. |
+| **e** | Expand the x-axis range between the two markers.|
+| **g** | Create a TCuG on the canvas, name scheme is _cut# where # is tracked from the start of the program.|
+| **o** | Unzoom the entire histogram, x and y.|
+| **x** | Make and display a total projection of the x-axis.|
+| **X** | Make and display a one bin projection of the x-axis, arrow up/down will cycle through all bins.|
+| **y** | Make and display a total projection of the y-axis.|
+| **Y** | Make and display a one bin projection of the y-axis, arrow up/down will cycle through all bins.|
+
+
+## TGraph/TGraphErrors Commands
+| Key | Action |:
+|:------|:------|
+| | All normal root commands/interactions.|
+| **p** | Print the graph to the terminal.
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
index 77103536..f23ce0bf 100644
--- a/config/rcnpchannels.cal
+++ b/config/rcnpchannels.cal
@@ -1,66 +1,289 @@
-// Central contacts
-
-CLO01AP00 {
- Address: 0x01007100
- EnergyCoeff: -11.571 1.38547587
-}
-
-CLO01BP00 {
- Address: 0x01007101
- EnergyCoeff: -15.376 1.16580939
-}
-
-CLO01CP00 {
- Address: 0x01007102
- EnergyCoeff: -17.096 1.20797241
-}
-
-CLO01DP00 {
- Address: 0x01007103
- EnergyCoeff: -16.151 1.06947565
-}
-
-
// Other channels
-
+EXT00AP00 {
+ Address: 0x01006500
+ EnergyCoeff: 0 1
+ PoleZero: 1
+}
EXT01AP00 {
- Address: 0x01007200
+ Address: 0x01006501
EnergyCoeff: 0 1
+ PoleZero: 1
}
EXT02AP00 {
- Address: 0x01007201
+ Address: 0x01006502
EnergyCoeff: 0 1
+ PoleZero: 1
}
EXT03AP00 {
- Address: 0x01007202
+ Address: 0x01006503
EnergyCoeff: 0 1
+ PoleZero: 1
}
EXT04AP00 {
- Address: 0x01007203
+ Address: 0x01006504
EnergyCoeff: 0 1
+ PoleZero: 1
}
-
EXT05AP00 {
- Address: 0x01007300
+ Address: 0x01006505
EnergyCoeff: 0 1
+ PoleZero: 1
}
EXT06AP00 {
- Address: 0x01007301
+ Address: 0x01006506
EnergyCoeff: 0 1
+ PoleZero: 1
}
EXT07AP00 {
- Address: 0x01007302
+ Address: 0x01006507
EnergyCoeff: 0 1
+ PoleZero: 1
}
EXT08AP00 {
- Address: 0x01007303
+ Address: 0x01006508
EnergyCoeff: 0 1
+ PoleZero: 1
}
EXT09AP00 {
- Address: 0x01007304
+ 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
+// }
diff --git a/histos/CAGRA.cxx b/histos/CAGRA.cxx
new file mode 100644
index 00000000..b0d6ae9d
--- /dev/null
+++ b/histos/CAGRA.cxx
@@ -0,0 +1,279 @@
+
+#include "TRuntimeObjects.h"
+
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+#include "TCagra.h"
+#include "TGrandRaiden.h"
+#include "TANLEvent.h"
+
+#define BAD_NUM -441441
+
+//#include "TChannel.h"
+//#include "GValue.h"
+
+#define PRINT(x) std::cout << #x" = " << x << std::endl
+#define STR(x) #x << " = " <<() x
+
+using namespace std;
+
+
+string name;
+stringstream stream;
+ULong_t nevent = 0;
+
+// extern "C" is needed to prevent name mangling.
+// The function signature must be exactly as shown here,
+// or else bad things will happen.
+extern "C"
+void MakeHistograms(TRuntimeObjects& obj) {
+
+
+
+ TCagra* cagra = obj.GetDetector();
+ TGrandRaiden* gr = obj.GetDetector();
+
+ TList *list = &(obj.GetObjects());
+ int numobj = list->GetSize();
+
+ if (cagra && gr) {
+ for (auto& hit : *gr) {
+
+ auto& rcnp = hit.GR();
+ auto grtime = hit.GetTimestamp();
+
+ // coincidence rate
+ static ULong_t first_timestamp = grtime;
+ if (first_timestamp) {
+ auto rate = (grtime-first_timestamp)/1e8;
+ //cout << grtime << " " << first_timestamp << endl;
+ obj.FillHistogram("CoinRate",1000,0,10000, rate);
+ }
+
+ // coincidence time difference
+ for (auto& caghit : *cagra) {
+
+ ULong_t cagratime = caghit.Timestamp();
+ Double_t cagra_cfd = caghit.GetDiscTime();
+
+ ULong_t ts_diff = cagratime-grtime;
+ Double_t cfd_diff = cagra_cfd-(Double_t)grtime;
+
+ obj.FillHistogram("CoinDiff",2000,-1000,1000,ts_diff);
+ stream.str("");
+ stream << "CoinDiff_" << caghit.GetBoardID() << "_" < 238 && cagratime -grtime < 246) {
+ stream.str(""); stream << caghit.GetBoardID() << "Cal" << caghit.GetChannel() << "_CoinGated";
+ obj.FillHistogram(stream.str().c_str(),10000,0,10000,caghit.GetEnergy());
+ obj.FillHistogram("GATETEST_CoinDiff",2000,-1000,1000,ts_diff);
+ }
+ obj.FillHistogram("CoinDiff_CFD",2000,-1000,1000,cfd_diff);
+ stream.str("");
+ stream << "CoinDiff_CFD_" << caghit.GetBoardID() << "_" < 238 && cagra_cfd -grtime < 246) {
+ stream.str(""); stream << caghit.GetBoardID() << "Cal" << caghit.GetChannel() << "_CoinGated";
+ obj.FillHistogram(stream.str().c_str(),10000,0,10000,caghit.GetEnergy());
+ obj.FillHistogram("GATETEST_CoinDiff_CFD",2000,-1000,1000,cfd_diff);
+ }
+
+
+ }
+
+
+
+ }
+
+ }
+
+
+ if (gr) {
+
+ for (auto& hit : *gr) {
+
+ auto& rcnp = hit.GR();
+ auto adc = rcnp.GR_ADC();
+
+
+ if (rcnp.GR_MYRIAD(0) != BAD_NUM) {
+ obj.FillHistogram("MyriadTimestamp",10000,1e9,5e12,hit.GetTimestamp());
+ }
+
+ static ULong_t prev_ts = 0;
+ if (prev_ts) {
+ obj.FillHistogram("GR_EventPeriod",5000,100,50000,hit.GetTimestamp()-prev_ts);
+ }
+ prev_ts = hit.GetTimestamp();
+
+
+ if (rcnp.GR_ADC()) {
+ auto& adc = *rcnp.GR_ADC();
+ for (int i=0; i<4; i++) {
+ stream.str(""); stream << "GR_ADC" << i;
+ obj.FillHistogram(stream.str().c_str(), 1000,0,2000, adc[i]);
+ }
+ obj.FillHistogram("MeanPlastE1", 2000,0,2000, hit.GetMeanPlastE1());
+ obj.FillHistogram("MeanPlastE2", 2000,0,2000, hit.GetMeanPlastE2());
+ }
+ if (rcnp.GR_TDC()) {
+ auto& tdc = *rcnp.GR_TDC();
+ for (int i=0; i<4; i++) {
+ stream.str(""); stream << "GR_TDC" << i;
+ obj.FillHistogram(stream.str().c_str(), 1000,-40000,40000, tdc[i]);
+ }
+ obj.FillHistogram("MeanPlastPos1", 1000, 0, 40000, hit.GetMeanPlastPos1());
+ obj.FillHistogram("MeanPlastPos2", 1000, 0, 40000, hit.GetMeanPlastPos2());
+ }
+ if (rcnp.QTC_LEADING_TDC()) {
+ auto& qtc_leading = *rcnp.QTC_LEADING_TDC();
+ auto& qtc_leading_chan = *rcnp.QTC_LEADING_CH();
+ auto x = rcnp.GR_X(0);
+
+ for (int i=0; i< qtc_leading_chan.size(); i++) {
+ int channum = qtc_leading_chan[i];
+ stream.str(""); stream << "LaBrLeading" << channum;
+ obj.FillHistogram(stream.str().c_str(), 10000,-40000, 40000, qtc_leading[i]);
+ // gate on gr_x
+ if (x < 100 && x > 0) {
+ stream.str(""); stream << "LaBrLead"<< channum << "_GateX";
+ obj.FillHistogram(stream.str().c_str(), 10000,-40000, 40000, qtc_leading[i]);
+ }
+
+
+
+ if (qtc_leading[i]>=-5100 && qtc_leading[i] <=-4400) {
+
+
+ obj.FillHistogram("RayID_LEGate",64,-16,48, rcnp.GR_RAYID(0));
+ if (rcnp.GR_RAYID(0) == 0) { // if track reconstruction successfull
+ obj.FillHistogram("GR_X_LEGate",1200,-600,600, rcnp.GR_X(0));
+ obj.FillHistogram("GR_Y_LEGate",200,-100,100, rcnp.GR_Y(0));
+ obj.FillHistogram("GR_Theta_LEGate",100,-1,1, rcnp.GR_TH(0)); // need to learn
+ obj.FillHistogram("GR_Phi_LEGate",100,-1,1, rcnp.GR_PH(0)); // from hist.def
+ obj.FillHistogram("X_TH_LEGate",1200,-600,600,rcnp.GR_X(0),1000,-1,1,rcnp.GR_TH(0));
+ }
+
+ for (auto const& labr_hit : hit.GetLaBr()) {
+ int channum = labr_hit.channel;
+ stream.str(""); stream << "LaBrWidth_LEGate" << channum;
+ obj.FillHistogram(stream.str().c_str(), 10000, -5000, 15000, labr_hit.width);
+
+ if (rcnp.GR_X(0) != BAD_NUM) {
+ obj.FillHistogram("X_LaBr_LEGate",1200,-600,600,rcnp.GR_X(0),10000,-5000,15000,labr_hit.width);
+ }
+ }
+
+
+ }
+
+
+ }
+ }
+ for (auto const& labr_hit : hit.GetLaBr()) {
+ int channum = labr_hit.channel;
+ stream.str(""); stream << "LaBrWidth" << channum;
+ obj.FillHistogram(stream.str().c_str(), 10000, -5000, 15000, labr_hit.width);
+
+ if (rcnp.GR_X(0) != BAD_NUM) {
+ obj.FillHistogram("X_LaBr",1200,-600,600,rcnp.GR_X(0),10000,-5000,15000,labr_hit.width);
+ }
+
+ }
+ obj.FillHistogram("RayID",64,-16,48, rcnp.GR_RAYID(0));
+ if (rcnp.GR_RAYID(0) == 0) { // if track reconstruction successfull
+ obj.FillHistogram("GR_X",1200,-600,600, rcnp.GR_X(0));
+ obj.FillHistogram("GR_Y",200,-100,100, rcnp.GR_Y(0));
+ obj.FillHistogram("GR_Theta",100,-1,1, rcnp.GR_TH(0)); // need to learn
+ obj.FillHistogram("GR_Phi",100,-1,1, rcnp.GR_PH(0)); // from hist.def
+ obj.FillHistogram("X_TH",1200,-600,600,rcnp.GR_X(0),1000,-1,1,rcnp.GR_TH(0));
+ }
+ auto rf = rcnp.GR_RF(0);
+ if (rf != BAD_NUM) {
+ obj.FillHistogram("GR_RF",1000,0,0,rf);
+ }
+
+ //GR timestamps check - sometimes the myriad timestamp is missing...
+ //static int n_gr = 0;
+ auto time = rcnp.GR_MYRIAD(0);
+ if (time != BAD_NUM) {
+ obj.FillHistogram("GR_LiveTimestamps",10,0,11,7);
+ } else {
+ obj.FillHistogram("GR_LiveTimestamps",10,0,11,3);
+ }
+
+ // obj.FillHistogram("GR_RF",1000,0,0,rf);
+ // auto first = TMath::Sqrt(adc[0]*adc[1]);
+ // auto second = TMath::Sqrt(adc[2]*adc[3]);
+ // obj.FillHistogram("pid_1",500,0,0,rf,500,0,0,first);
+ // obj.FillHistogram("pid_2",500,0,0,rf,500,0,0,second);
+ // }
+ }
+ }
+
+ if(cagra) {
+
+ for (auto& hit : *cagra) {
+
+ auto boardid = hit.GetBoardID();
+ auto chan = hit.GetChannel();
+
+ stream.str("");
+ stream << "Ge_" << boardid << "_" << chan;
+ obj.FillHistogram("Raw", stream.str().c_str(),10000,0,10000,hit.Charge());
+
+ stream.str("");
+ stream << "Ge_" << boardid << "_" << chan;
+ if (boardid == 102) {
+ auto labr_E = hit.GetTraceEnergy(0,57,60,60+57);
+ //if (nevent % 10000 == 0) { cout << labr_E << endl; }
+ obj.FillHistogram("Calibrated",stream.str().c_str(),10000,0,10000,labr_E);
+ } else {
+ obj.FillHistogram("Calibrated",stream.str().c_str(),10000,0,10000,hit.GetEnergy());
+ }
+
+ stream.str("");
+ stream << "Ge_PZ_" << boardid << "_" << chan;
+ obj.FillHistogram("Corrected", stream.str().c_str(),10000,0,10000,hit.GetCorrectedEnergy(0));
+ stream.str("");
+ stream << "Ge_PZ_AsymBL_" << boardid << "Cal" << chan;
+ obj.FillHistogram("Corrected", stream.str().c_str(),10000,0,10000,hit.GetCorrectedEnergy(hit.GetBaseSample()));
+
+ Double_t prerise_base = hit.GetPreRise()/TANLEvent::GetShapingTime();
+
+ stream.str("");
+ stream << "E_BL" << boardid << "_" << chan;
+ obj.FillHistogram("Baseline", stream.str().c_str(),1000,0,10000,hit.Charge(),1000,0,3000,prerise_base);
+
+ stream.str("");
+ stream << "E_BL_scale" << boardid << "_" << chan;
+ obj.FillHistogram("Baseline", stream.str().c_str(),1000,0,10000,hit.Charge()-(1.0/-11.21)*prerise_base,1000,0,3000,prerise_base);
+
+ stream.str("");
+ stream << "E_cor_BL" << boardid << "_" << chan;
+ obj.FillHistogram("Baseline", stream.str().c_str(),1000,0,10000,hit.GetCorrectedEnergy(hit.GetBaseSample()),1000,0,3000,prerise_base);
+
+
+
+ }
+
+ }
+
+
+ if(numobj!=list->GetSize())
+ list->Sort();
+
+ nevent++;
+}
diff --git a/histos/MakeANLHistos.cxx b/histos/MakeANLHistos.cxx
index 17fc34eb..735183d2 100644
--- a/histos/MakeANLHistos.cxx
+++ b/histos/MakeANLHistos.cxx
@@ -56,9 +56,9 @@ void MakeHistograms(TRuntimeObjects& obj) {
ncoin+=totalhits;
//cout << "Coin: " << ncoin << endl;
} else if (gr) {
- for (auto& hit : *gr) {
+ //for (auto& hit : *gr) {
//cout <<"Single GR: " << hit.Timestamp << endl;
- }
+ //}
}
@@ -72,22 +72,72 @@ void MakeHistograms(TRuntimeObjects& obj) {
if (gr) {
for (auto& hit : *gr) {
- auto adc = hit.GetADC();
- if (adc) {
+
+ auto& rcnp = hit.GR();
+
+
+ auto adc = rcnp.GR_ADC();
+
+
+
+
+ if (rcnp.GR_ADC()) {
+ auto& adc = *rcnp.GR_ADC();
for (int i=0; i<4; i++) {
stream.str(""); stream << "GR_ADC" << i;
obj.FillHistogram(stream.str().c_str(), 1000,0,1000, adc[i]);
}
- auto rf = hit.GetRF();
- if (rf != BAD_NUM) {
- obj.FillHistogram("GR_RF",1000,0,0,rf);
-
- auto first = TMath::Sqrt(adc[0]*adc[1]);
- auto second = TMath::Sqrt(adc[2]*adc[3]);
- obj.FillHistogram("pid_1",500,0,0,rf,500,0,0,first);
- obj.FillHistogram("pid_2",500,0,0,rf,500,0,0,second);
+ obj.FillHistogram("MeanPlastE1", 2000,0,2000, hit.GetMeanPlastE1());
+ obj.FillHistogram("MeanPlastE2", 2000,0,2000, hit.GetMeanPlastE2());
+ }
+ if (rcnp.GR_TDC()) {
+ auto& tdc = *rcnp.GR_TDC();
+ for (int i=0; i<4; i++) {
+ stream.str(""); stream << "GR_TDC" << i;
+ obj.FillHistogram(stream.str().c_str(), 1000,-40000,40000, tdc[i]);
+ }
+ obj.FillHistogram("MeanPlastPos1", 1000, 0, 40000, hit.GetMeanPlastPos1());
+ obj.FillHistogram("MeanPlastPos2", 1000, 0, 40000, hit.GetMeanPlastPos2());
+ }
+ if (rcnp.QTC_LEADING_TDC()) {
+ auto& qtc_leading = *rcnp.QTC_LEADING_TDC();
+ auto& qtc_leading_chan = *rcnp.QTC_LEADING_CH();
+ auto x = rcnp.GR_X(0);
+
+ for (int i=0; i< qtc_leading_chan.size(); i++) {
+ int channum = qtc_leading_chan[i];
+ stream.str(""); stream << "LaBrLeading" << channum;
+ obj.FillHistogram(stream.str().c_str(), 10000,-40000, 40000, qtc_leading[i]);
+ // gate on gr_x
+ if (x < 100 && x > 0) {
+ stream.str(""); stream << "LaBrLead"<< channum << "_GateX";
+ obj.FillHistogram(stream.str().c_str(), 10000,-40000, 40000, qtc_leading[i]);
+ }
}
}
+ for (auto const& labr_hit : hit.GetLaBr()) {
+ int channum = labr_hit.channel;
+ stream.str(""); stream << "LaBrWidth" << channum;
+ obj.FillHistogram(stream.str().c_str(), 10000, -5000, 15000, labr_hit.width);
+ }
+ obj.FillHistogram("RayID",64,-16,48, rcnp.GR_RAYID(0));
+ if (rcnp.GR_RAYID(0) == 0) { // if track reconstruction successfull
+ obj.FillHistogram("GR_X",1200,-600,600, rcnp.GR_RAYID(0));
+ obj.FillHistogram("GR_Y",200,-100,100, rcnp.GR_RAYID(0));
+ obj.FillHistogram("GR_Theta",100,-1,1, rcnp.GR_RAYID(0)); // need to learn
+ obj.FillHistogram("GR_Phi",100,-1,1, rcnp.GR_RAYID(0)); // from hist.def
+ }
+ auto rf = rcnp.GR_RF(0);
+ if (rf != BAD_NUM) {
+ obj.FillHistogram("GR_RF",1000,0,0,rf);
+ }
+
+ // obj.FillHistogram("GR_RF",1000,0,0,rf);
+ // auto first = TMath::Sqrt(adc[0]*adc[1]);
+ // auto second = TMath::Sqrt(adc[2]*adc[3]);
+ // obj.FillHistogram("pid_1",500,0,0,rf,500,0,0,first);
+ // obj.FillHistogram("pid_2",500,0,0,rf,500,0,0,second);
+ // }
}
}
@@ -96,12 +146,16 @@ void MakeHistograms(TRuntimeObjects& obj) {
//cout << "Size: " << cagra->Size() << endl;
for (auto& hit : *cagra) {
- //cout << hit.Timestamp() << endl;
+ //cout << hit.Timestamp() << " " << hit.GetDiscTime() << endl;
+
stream.str("");
stream << "PostE_BoardID" << hit.GetBoardID() << "_Chan" << hit.GetChannel();
obj.FillHistogram(stream.str(),10000,0,0,hit.Charge());
- if (hit.GetBoardID() == 0x71) {
+ obj.FillHistogram("DigitizerHits",12,97,109,hit.GetBoardID(),12,-1,11,hit.GetChannel());
+ //cout << hit.GetBoardID() << " " << hit.GetChannel() << endl;
+
+ if (hit.GetBoardID() == 0x65) {
stream.str("");
stream << "Leaf" << hit.GetChannel();
@@ -117,4 +171,5 @@ void MakeHistograms(TRuntimeObjects& obj) {
if(numobj!=list->GetSize())
list->Sort();
+
}
diff --git a/histos/RCNPAna.cxx b/histos/RCNPAna.cxx
new file mode 100644
index 00000000..d01ad85c
--- /dev/null
+++ b/histos/RCNPAna.cxx
@@ -0,0 +1,324 @@
+
+#include "TRuntimeObjects.h"
+
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+#include "TCagra.h"
+#include "TGrandRaiden.h"
+
+#define BAD_NUM -441441
+
+#include "TANLEvent.h"
+//#include "GValue.h"
+
+#define PRINT(x) std::cout << #x" = " << x << std::endl
+#define STR(x) #x << " = " <<() x
+
+using namespace std;
+
+
+string name;
+stringstream stream;
+
+
+// extern "C" is needed to prevent name mangling.
+// The function signature must be exactly as shown here,
+// or else bad things will happen.
+extern "C"
+void MakeHistograms(TRuntimeObjects& obj) {
+
+
+
+ TCagra* cagra = obj.GetDetector();
+ TGrandRaiden* gr = obj.GetDetector();
+
+ TList *list = &(obj.GetObjects());
+ int numobj = list->GetSize();
+
+ if (cagra && gr) {
+ for (auto& hit : *gr) {
+
+ auto& rcnp = hit.GR();
+ auto grtime = hit.GetTimestamp();
+
+ auto x = rcnp.GR_X(0);
+ auto Ex = x*0.0109738+7.65621;
+
+ // coincidence rate
+ static ULong_t first_timestamp = grtime;
+ if (first_timestamp) {
+ auto rate = (grtime-first_timestamp)/1e8;
+ //cout << grtime << " " << first_timestamp << endl;
+ obj.FillHistogram("COIN","Rate",3000,0,30000, rate);
+ }
+
+ // coincidence time difference
+ for (auto& caghit : *cagra) {
+
+ auto cagratime = caghit.Timestamp();
+ auto tdiff = cagratime-grtime;
+ obj.FillHistogram("COIN","Diff",1000,-1000,1000,cagratime-grtime);
+ stream.str("");
+ stream << "TimeDiff_" << caghit.GetBoardID() << "_" < 235) && (tdiff < 245) ){
+
+ stream.str("");
+ stream << "Ge_"<< caghit.GetBoardID() << "_" << caghit.GetChannel();
+ obj.FillHistogram("COIN_Raw",stream.str(),10000,0,10000,caghit.Charge());
+ stream.str("");
+ stream << "Ge_" << caghit.GetBoardID() << "_" << caghit.GetChannel();
+ obj.FillHistogram("COIN_Calibrated",stream.str(),10000,0,10000,caghit.GetEnergy());
+
+ stream.str("");
+ stream << "Ex_Ge_" << caghit.GetBoardID() << "_" << caghit.GetChannel();
+ obj.FillHistogram("COIN_Calibrated",stream.str(),1000,0,20,Ex,2500,0,10,caghit.GetEnergy()*0.0010552+0.0636885);
+
+ stream.str("");
+ stream << "Ex_CAGRACorrected_" << caghit.GetBoardID() << "_" << caghit.GetChannel();
+ obj.FillHistogram("COIN_Calibrated", stream.str().c_str(),1000,0,20,Ex,2500,0,10000,caghit.GetCorrectedEnergy(caghit.GetBaseSample()));
+ }
+
+ }
+
+
+ }
+
+
+ // int totalhits = 0;
+ // for (auto& hit : *gr) { totalhits++; }
+ // for (int i=0; i < totalhits; i++) {
+ // obj.FillHistogram("nCoin",4,0,1,0);
+ // }
+
+ // static int ncoin = 0;
+ // ncoin+=totalhits;
+ }
+
+
+ if (gr) {
+
+ for (auto& hit : *gr) {
+
+ auto& rcnp = hit.GR();
+ auto adc = rcnp.GR_ADC();
+
+
+ if (rcnp.GR_MYRIAD(0) != BAD_NUM) {
+ obj.FillHistogram("Timing","MyriadTimestamp",10000,1e9,5e12,hit.GetTimestamp());
+ }
+
+ static ULong_t prev_ts = 0;
+ if (prev_ts) {
+ obj.FillHistogram("Timing","GR_EventPeriod",5000,100,50000,hit.GetTimestamp()-prev_ts);
+ }
+ prev_ts = hit.GetTimestamp();
+
+ auto rf = rcnp.GR_RF(0);
+ if (rf != BAD_NUM) {
+
+ obj.FillHistogram("GR","GR_RF",1000,0,0,rf);
+ }
+
+ if (rcnp.GR_ADC()) {
+ auto& adc = *rcnp.GR_ADC();
+ for (int i=0; i<4; i++) {
+ stream.str(""); stream << "GR_ADC" << i;
+ obj.FillHistogram("GR",stream.str().c_str(), 1000,0,2000, adc[i]);
+ }
+ obj.FillHistogram("GR","MeanPlastE1", 2000,0,2000, hit.GetMeanPlastE1());
+ obj.FillHistogram("GR","MeanPlastE2", 2000,0,2000, hit.GetMeanPlastE2());
+ if (rf != BAD_NUM) {
+ obj.FillHistogram("GR","dE1_RF",1000,0,0,rf,2000,0,2000, hit.GetMeanPlastE1());
+ obj.FillHistogram("GR","dE2_RF",1000,0,0,rf,2000,0,2000, hit.GetMeanPlastE2());
+ obj.FillHistogram("GR","dE2_dE1",2000,0,2000, hit.GetMeanPlastE2(),2000,0,2000, hit.GetMeanPlastE1());
+
+ }
+ }
+ if (rcnp.GR_TDC()) {
+ auto& tdc = *rcnp.GR_TDC();
+ for (int i=0; i<4; i++) {
+ stream.str(""); stream << "GR_TDC" << i;
+ obj.FillHistogram("GR",stream.str().c_str(), 1000,-40000,40000, tdc[i]);
+ }
+ obj.FillHistogram("GR","MeanPlastPos1", 1000, 0, 40000, hit.GetMeanPlastPos1());
+ obj.FillHistogram("GR","MeanPlastPos2", 1000, 0, 40000, hit.GetMeanPlastPos2());
+ }
+ if (rcnp.QTC_LEADING_TDC()) {
+ auto& qtc_leading = *rcnp.QTC_LEADING_TDC();
+ auto& qtc_leading_chan = *rcnp.QTC_LEADING_CH();
+ auto x = rcnp.GR_X(0);
+ auto Ex = x*0.0109738+7.65621;
+ double Egamma;
+
+ for (int i=0; i< qtc_leading_chan.size(); i++) {
+ int channum = qtc_leading_chan[i];
+ stream.str(""); stream << "LaBrLeading" << channum;
+ obj.FillHistogram("GR",stream.str().c_str(), 10000,-40000, 40000, qtc_leading[i]);
+
+ /* cut on prompt timing peak */
+
+ if (qtc_leading[i]>=-5100 && qtc_leading[i] <=-4300) {
+
+ obj.FillHistogram("GR_Prompt","RayID",64,-16,48, rcnp.GR_RAYID(0));
+ if (rcnp.GR_RAYID(0) == 0) { // if track reconstruction successfull
+ obj.FillHistogram("GR_Prompt","GR_X",1200,-600,600, rcnp.GR_X(0));
+ obj.FillHistogram("GR_Prompt","GR_Y",200,-100,100, rcnp.GR_Y(0));
+ obj.FillHistogram("GR_Prompt","GR_Theta",100,-1,1, rcnp.GR_TH(0)); // need to learn
+ obj.FillHistogram("GR_Prompt","GR_Phi",100,-1,1, rcnp.GR_PH(0)); // from hist.def
+ obj.FillHistogram("GR_Prompt","X_TH",1200,-600,600,rcnp.GR_X(0),1000,-1,1,rcnp.GR_TH(0));
+
+ obj.FillHistogram("GR_Prompt","GR_Theta_Phi",100,-1,1, rcnp.GR_TH(0),100,-1,1, rcnp.GR_PH(0)); // need to learn
+ obj.FillHistogram("GR_Prompt","GR_X_Y",1200,-600,600, rcnp.GR_X(0),200,-100,100, rcnp.GR_Y(0));
+ obj.FillHistogram("GR_Prompt","GR_X_cal",1000,0,20, Ex);
+
+ }
+
+ // this needs to be moved out of the loop over qtc_chan I think - Chris
+ for (auto const& labr_hit : hit.GetLaBr()) {
+ int channum = labr_hit.channel;
+ stream.str(""); stream << "LaBrWidth_LEGate" << channum;
+ obj.FillHistogram("GR_Prompt",stream.str().c_str(), 10000, -5000, 15000, labr_hit.width);
+ if (channum == 1) {
+ Egamma = labr_hit.width*0.00190458-1.27177;
+ obj.FillHistogram("GR_Prompt","X_LaBrWidth1",1200,-600,600,rcnp.GR_X(0),10000,-5000,15000,labr_hit.width);
+ obj.FillHistogram("GR_Prompt","LaBr1_cal", 1000,0,20,Egamma);
+ if ((Ex > Egamma-0.150)&&(Ex < Egamma+0.150)) {
+ obj.FillHistogram("GR_Prompt","LaBr1_cal_GS", 1000,0,20,labr_hit.width*0.00181-1.0887);
+ }
+ obj.FillHistogram("GR_Prompt","x_LaBr1_cal",1200,-600,600,x,1000,0,20,Egamma);
+ obj.FillHistogram("GR_Prompt","Ex_LaBr1_cal",1000,-0,20,Ex,1000,0,20,Egamma);
+ obj.FillHistogram("GR_Prompt","Ex",1000,-0,20,Ex);
+ obj.FillHistogram("GR_Prompt","LaBr1_cal_rf", 1000,0,20,Egamma,1000,-5500,4000,qtc_leading[i]-rf);
+
+ }
+
+ if (channum == 3) {
+ Egamma = labr_hit.width*0.00168037-0.931571;
+ obj.FillHistogram("GR_Prompt","LaBr2_cal", 1000,0,20,Egamma);
+ obj.FillHistogram("GR_Prompt","X_LaBrWidth2",1200,-600,600,rcnp.GR_X(0),10000,-5000,15000,labr_hit.width);
+ obj.FillHistogram("GR_Prompt","Ex_LaBr2_cal",1000,-0,20,Ex,1000,0,20,Egamma);
+ obj.FillHistogram("GR_Prompt","LaBr2_cal_rf", 1000,0,20,Egamma,1000,-5500,4000,qtc_leading[i]-rf);
+ if ((Ex > Egamma-0.150)&&(Ex < Egamma+0.150)) {
+ obj.FillHistogram("GR_Prompt","LaBr2_cal_GS", 1000,0,20,labr_hit.width*0.00181-1.0887);
+ }
+ }
+
+ if (rcnp.GR_TH(0)<0.04){
+ obj.FillHistogram("GR_Prompt","Gamma_cal_cutTheta", 1000,0,20,Egamma);
+ if ((Ex > Egamma-0.150)&&(Ex < Egamma+0.150)) {
+ obj.FillHistogram("GR_Prompt","Gamma_cal_cutTheta_GS", 1000,0,20,labr_hit.width*0.00181-1.0887);
+ }
+ //if (Ex > 9. && Ex < 10.) {
+ //obj.FillHistogram("Gamma_cal_Ex_9650", 1000,0,10,labr_hit.width*0.00181-1.0887);
+ //}
+ // obj.FillHistogram("x_Egamma_prompt",1200,-600,600,x,1000,0,20,Egamma);
+ // obj.FillHistogram("Ex_Egamma_prompt",1000,-0,20,Ex,1000,0,20,Egamma);
+ obj.FillHistogram("GR_Prompt","Ex_TH_cutTheta",1000,0,20,Ex,1000,-1,1,rcnp.GR_TH(0));
+ }
+
+ }
+ }
+
+ }
+ }
+
+ for (auto const& labr_hit : hit.GetLaBr()) {
+ int channum = labr_hit.channel;
+ stream.str(""); stream << "LaBrWidth" << channum;
+ obj.FillHistogram("GR",stream.str().c_str(), 10000, -5000, 15000, labr_hit.width);
+ stream.str(""); stream << "LaBrWidth_cal" << channum;
+ obj.FillHistogram("GR",stream.str().c_str(), 1000,0,20,labr_hit.width*0.00181-1.0887);
+
+ if (rcnp.GR_X(0) != BAD_NUM) {
+ obj.FillHistogram("GR","X_LaBr",1200,-600,600,rcnp.GR_X(0),10000,-5000,15000,labr_hit.width);
+ if (channum == 1){
+ obj.FillHistogram("GR","X_LaBr_cal",1000,-0,20,rcnp.GR_X(0)*0.0109+7.6324,1000,0,20,labr_hit.width*0.00181-1.0887);
+ }
+ }
+
+ }
+ obj.FillHistogram("GR","RayID",64,-16,48, rcnp.GR_RAYID(0));
+ if (rcnp.GR_RAYID(0) == 0) { // if track reconstruction successfull
+ obj.FillHistogram("GR","GR_X",1200,-600,600, rcnp.GR_X(0));
+ obj.FillHistogram("GR","GR_X_cal",1000,0,20, rcnp.GR_X(0)*0.0109+7.6324);
+ obj.FillHistogram("GR","GR_Y",200,-100,100, rcnp.GR_Y(0));
+ obj.FillHistogram("GR","GR_Theta",100,-1,1, rcnp.GR_TH(0)); // need to learn
+ obj.FillHistogram("GR","GR_Phi",100,-1,1, rcnp.GR_PH(0)); // from hist.def
+ obj.FillHistogram("GR","X_TH",1200,-600,600,rcnp.GR_X(0),1000,-1,1,rcnp.GR_TH(0));
+ }
+
+ // obj.FillHistogram("GR_RF",1000,0,0,rf);
+ // auto first = TMath::Sqrt(adc[0]*adc[1]);
+ // auto second = TMath::Sqrt(adc[2]*adc[3]);
+ // obj.FillHistogram("pid_1",500,0,0,rf,500,0,0,first);
+ // obj.FillHistogram("pid_2",500,0,0,rf,500,0,0,second);
+ // }
+ }
+ }
+
+ if(cagra) {
+
+ for (auto& hit : *cagra) {
+
+ auto boardid = hit.GetBoardID();
+ auto chan = hit.GetChannel();
+
+ stream.str("");
+ stream << "Ge_" << boardid << "_" << chan;
+ obj.FillHistogram("CAGRA_Raw", stream.str().c_str(),10000,0,10000,hit.Charge());
+
+ stream.str("");
+ stream << "Ge_" << boardid << "_" << chan;
+ if (boardid == 102) {
+ auto labr_E = hit.GetTraceEnergy(0,57,60,60+57);
+ //if (nevent % 10000 == 0) { cout << labr_E << endl; }
+ obj.FillHistogram("CAGRA_Calibrated",stream.str().c_str(),10000,0,10000,labr_E);
+ } else {
+ obj.FillHistogram("CAGRA_Calibrated",stream.str().c_str(),10000,0,10000,hit.GetEnergy());
+ }
+
+ stream.str("");
+ stream << "Ge_PZ_" << boardid << "_" << chan;
+ obj.FillHistogram("CAGRA_Corrected", stream.str().c_str(),10000,0,10000,hit.GetCorrectedEnergy(0));
+ stream.str("");
+ stream << "Ge_PZ_AsymBL_" << boardid << "Cal" << chan;
+ obj.FillHistogram("CAGRA_Corrected", stream.str().c_str(),10000,0,10000,hit.GetCorrectedEnergy(hit.GetBaseSample()));
+
+ Double_t prerise_base = hit.GetPreRise()/TANLEvent::GetShapingTime();
+
+ stream.str("");
+ stream << "E_BL" << boardid << "_" << chan;
+ obj.FillHistogram("CAGRA_Baseline", stream.str().c_str(),1000,0,10000,hit.Charge(),1000,0,3000,prerise_base);
+
+ stream.str("");
+ stream << "E_BL_scale" << boardid << "_" << chan;
+ obj.FillHistogram("CAGRA_Baseline", stream.str().c_str(),1000,0,10000,hit.Charge()-(1.0/-11.21)*prerise_base,1000,0,3000,prerise_base);
+
+ stream.str("");
+ stream << "E_cor_BL" << boardid << "_" << chan;
+ obj.FillHistogram("CAGRA_Baseline", stream.str().c_str(),1000,0,10000,hit.GetCorrectedEnergy(hit.GetBaseSample()),1000,0,3000,prerise_base);
+
+
+
+ }
+
+ }
+
+
+
+ if(numobj!=list->GetSize())
+ list->Sort();
+
+
+}
diff --git a/histos/RCNPHistos.cxx b/histos/RCNPHistos.cxx
deleted file mode 100644
index b9b14ed3..00000000
--- a/histos/RCNPHistos.cxx
+++ /dev/null
@@ -1,88 +0,0 @@
-
-#include "TRuntimeObjects.h"
-
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-
-#include "TCagra.h"
-#include "TGrandRaiden.h"
-
-//#include "TChannel.h"
-//#include "GValue.h"
-
-#define PRINT(x) std::cout << #x" = " << x << std::endl
-#define STR(x) #x << " = " << x
-
-using namespace std;
-
-
-string name;
-stringstream stream;
-
-// extern "C" is needed to prevent name mangling.
-// The function signature must be exactly as shown here,
-// or else bad things will happen.
-extern "C"
-void MakeHistograms(TRuntimeObjects& obj) {
- auto cagra = obj.GetDetector();
- auto gr = obj.GetDetector();
-
- TList *list = &(obj.GetObjects());
- int numobj = list->GetSize();
-
- // if(!gr) { cout << "NO GR" << endl; return; }
- // for(int y=0;ySize();y++) {
- // auto grhit = gr->GetGrandRaidenHit(y);
- // cout << grhit.Timestamp << endl;
- // }
-
-
-
- //if(!cagra) { return; }
-
- // if (cagra) { cout << "yay" << endl; }
- // return;
-
-
- if(!cagra || !gr) { return; }
- //cout << "Coincidence!!!" << endl;
-
- /*
- for(int y=0;ySize();y++) {
- TCagraHit hit = cagra->GetCagraHit(y);
-
- if(hit.GetBoardID() == 113) {
-
- stream.str("");
- stream << "Crystal" << hit.GetChannel();
- float Energy = ((hit.GetPostE() - hit.GetPreE())/350.0);
- obj.FillHistogram(stream.str(),10000,0,20000,Energy);
- }
-
-
-
-
- // PRINT(hit.GetBoardID());
- // if (hit.GetChannel() > 2) PRINT(hit.GetChannel());
- // PRINT(hit.GetLED());
- // PRINT(hit.GetPostE());
- // PRINT(hit.GetPreE());
- // PRINT((hit.GetPostE() - hit.GetPreE())/350.0);
- //std::this_thread::sleep_for(std::chrono::milliseconds(1000));
-
- }
- */
-
- if(numobj!=list->GetSize())
- list->Sort();
-
-}
diff --git a/histos/RCNPhistos.cxx b/histos/RCNPhistos.cxx
new file mode 100644
index 00000000..f524b2e7
--- /dev/null
+++ b/histos/RCNPhistos.cxx
@@ -0,0 +1,318 @@
+
+#include "TRuntimeObjects.h"
+
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+#include "TCagra.h"
+#include "TGrandRaiden.h"
+#include "TANLEvent.h"
+
+#define BAD_NUM -441441
+
+//#include "TChannel.h"
+//#include "GValue.h"
+
+#define PRINT(x) std::cout << #x" = " << x << std::endl
+#define STR(x) #x << " = " <<() x
+
+using namespace std;
+
+
+string name;
+stringstream stream;
+ULong_t nevent = 0;
+
+// extern "C" is needed to prevent name mangling.
+// The function signature must be exactly as shown here,
+// or else bad things will happen.
+extern "C"
+void MakeHistograms(TRuntimeObjects& obj) {
+
+
+
+ TCagra* cagra = obj.GetDetector();
+ TGrandRaiden* gr = obj.GetDetector();
+
+ TList *list = &(obj.GetObjects());
+ int numobj = list->GetSize();
+
+ if (cagra && gr) {
+ for (auto& hit : *gr) {
+
+ auto& rcnp = hit.GR();
+ auto grtime = hit.GetTimestamp();
+
+ // coincidence rate
+ static ULong_t first_timestamp = grtime;
+ if (first_timestamp) {
+ auto rate = (grtime-first_timestamp)/1e8;
+ //cout << grtime << " " << first_timestamp << endl;
+ obj.FillHistogram("CoinRate",1000,0,10000, rate);
+ }
+
+ // coincidence time difference
+ for (auto& caghit : *cagra) {
+
+ ULong_t cagratime = caghit.Timestamp();
+ Double_t cagra_cfd = caghit.GetDiscTime();
+
+ ULong_t ts_diff = cagratime-grtime;
+ Double_t cfd_diff = cagra_cfd-(Double_t)grtime;
+
+ obj.FillHistogram("CoinDiff",2000,-1000,1000,ts_diff);
+ stream.str("");
+ stream << "CoinDiff_" << caghit.GetBoardID() << "_" < 238 && cagratime -grtime < 246) {
+ stream.str(""); stream << caghit.GetBoardID() << "Cal" << caghit.GetChannel() << "_CoinGated";
+ obj.FillHistogram(stream.str().c_str(),10000,0,10000,caghit.GetEnergy());
+ obj.FillHistogram("GATETEST_CoinDiff",2000,-1000,1000,ts_diff);
+ }
+ obj.FillHistogram("CoinDiff_CFD",2000,-1000,1000,cfd_diff);
+ stream.str("");
+ stream << "CoinDiff_CFD_" << caghit.GetBoardID() << "_" < 238 && cagra_cfd -grtime < 246) {
+ stream.str(""); stream << caghit.GetBoardID() << "Cal" << caghit.GetChannel() << "_CoinGated";
+ obj.FillHistogram(stream.str().c_str(),10000,0,10000,caghit.GetEnergy());
+ obj.FillHistogram("GATETEST_CoinDiff_CFD",2000,-1000,1000,cfd_diff);
+ }
+
+
+ }
+
+
+
+ }
+
+ }
+
+
+ if (gr) {
+
+ for (auto& hit : *gr) {
+
+ auto& rcnp = hit.GR();
+ auto adc = rcnp.GR_ADC();
+
+
+ if (rcnp.GR_MYRIAD(0) != BAD_NUM) {
+ obj.FillHistogram("MyriadTimestamp",10000,1e9,5e12,hit.GetTimestamp());
+ }
+
+ static ULong_t prev_ts = 0;
+ if (prev_ts) {
+ obj.FillHistogram("GR_EventPeriod",5000,100,50000,hit.GetTimestamp()-prev_ts);
+ }
+ prev_ts = hit.GetTimestamp();
+
+
+ if (rcnp.GR_ADC()) {
+ auto& adc = *rcnp.GR_ADC();
+ for (int i=0; i<4; i++) {
+ stream.str(""); stream << "GR_ADC" << i;
+ obj.FillHistogram(stream.str().c_str(), 1000,0,2000, adc[i]);
+ }
+ obj.FillHistogram("MeanPlastE1", 2000,0,2000, hit.GetMeanPlastE1());
+ obj.FillHistogram("MeanPlastE2", 2000,0,2000, hit.GetMeanPlastE2());
+ }
+ if (rcnp.GR_TDC()) {
+ auto& tdc = *rcnp.GR_TDC();
+ for (int i=0; i<4; i++) {
+ stream.str(""); stream << "GR_TDC" << i;
+ obj.FillHistogram(stream.str().c_str(), 1000,-40000,40000, tdc[i]);
+ }
+ obj.FillHistogram("MeanPlastPos1", 1000, 0, 40000, hit.GetMeanPlastPos1());
+ obj.FillHistogram("MeanPlastPos2", 1000, 0, 40000, hit.GetMeanPlastPos2());
+ }
+ if (rcnp.QTC_LEADING_TDC()) {
+ auto& qtc_leading = *rcnp.QTC_LEADING_TDC();
+ auto& qtc_leading_chan = *rcnp.QTC_LEADING_CH();
+ auto x = rcnp.GR_X(0);
+
+ for (int i=0; i< qtc_leading_chan.size(); i++) {
+ int channum = qtc_leading_chan[i];
+ stream.str(""); stream << "LaBrLeading" << channum;
+ obj.FillHistogram(stream.str().c_str(), 10000,-40000, 40000, qtc_leading[i]);
+ // gate on gr_x
+ if (x < 100 && x > 0) {
+ stream.str(""); stream << "LaBrLead"<< channum << "_GateX";
+ obj.FillHistogram(stream.str().c_str(), 10000,-40000, 40000, qtc_leading[i]);
+ }
+
+
+
+ if (qtc_leading[i]>=-5100 && qtc_leading[i] <=-4400) {
+
+
+ obj.FillHistogram("RayID_LEGate",64,-16,48, rcnp.GR_RAYID(0));
+ if (rcnp.GR_RAYID(0) == 0) { // if track reconstruction successfull
+ obj.FillHistogram("GR_X_LEGate",1200,-600,600, rcnp.GR_X(0));
+ obj.FillHistogram("GR_Y_LEGate",200,-100,100, rcnp.GR_Y(0));
+ obj.FillHistogram("GR_Theta_LEGate",100,-1,1, rcnp.GR_TH(0)); // need to learn
+ obj.FillHistogram("GR_Phi_LEGate",100,-1,1, rcnp.GR_PH(0)); // from hist.def
+ obj.FillHistogram("X_TH_LEGate",1200,-600,600,rcnp.GR_X(0),1000,-1,1,rcnp.GR_TH(0));
+ }
+
+ for (auto const& labr_hit : hit.GetLaBr()) {
+ int channum = labr_hit.channel;
+ stream.str(""); stream << "LaBrWidth_LEGate" << channum;
+ obj.FillHistogram(stream.str().c_str(), 10000, -5000, 15000, labr_hit.width);
+
+ if (rcnp.GR_X(0) != BAD_NUM) {
+ obj.FillHistogram("X_LaBr_LEGate",1200,-600,600,rcnp.GR_X(0),10000,-5000,15000,labr_hit.width);
+ }
+ }
+
+
+ }
+
+
+ }
+ }
+ for (auto const& labr_hit : hit.GetLaBr()) {
+ int channum = labr_hit.channel;
+ stream.str(""); stream << "LaBrWidth" << channum;
+ obj.FillHistogram(stream.str().c_str(), 10000, -5000, 15000, labr_hit.width);
+
+ if (rcnp.GR_X(0) != BAD_NUM) {
+ obj.FillHistogram("X_LaBr",1200,-600,600,rcnp.GR_X(0),10000,-5000,15000,labr_hit.width);
+ }
+
+ }
+ obj.FillHistogram("RayID",64,-16,48, rcnp.GR_RAYID(0));
+ if (rcnp.GR_RAYID(0) == 0) { // if track reconstruction successfull
+ obj.FillHistogram("GR_X",1200,-600,600, rcnp.GR_X(0));
+ obj.FillHistogram("GR_Y",200,-100,100, rcnp.GR_Y(0));
+ obj.FillHistogram("GR_Theta",100,-1,1, rcnp.GR_TH(0)); // need to learn
+ obj.FillHistogram("GR_Phi",100,-1,1, rcnp.GR_PH(0)); // from hist.def
+ obj.FillHistogram("X_TH",1200,-600,600,rcnp.GR_X(0),1000,-1,1,rcnp.GR_TH(0));
+ }
+ auto rf = rcnp.GR_RF(0);
+ if (rf != BAD_NUM) {
+ obj.FillHistogram("GR_RF",1000,0,0,rf);
+ }
+
+ //GR timestamps check - sometimes the myriad timestamp is missing...
+ //static int n_gr = 0;
+ auto time = rcnp.GR_MYRIAD(0);
+ if (time != BAD_NUM) {
+ obj.FillHistogram("GR_LiveTimestamps",10,0,11,7);
+ } else {
+ obj.FillHistogram("GR_LiveTimestamps",10,0,11,3);
+ }
+
+ // obj.FillHistogram("GR_RF",1000,0,0,rf);
+ // auto first = TMath::Sqrt(adc[0]*adc[1]);
+ // auto second = TMath::Sqrt(adc[2]*adc[3]);
+ // obj.FillHistogram("pid_1",500,0,0,rf,500,0,0,first);
+ // obj.FillHistogram("pid_2",500,0,0,rf,500,0,0,second);
+ // }
+ }
+ }
+
+ if(cagra) {
+
+ static ULong_t ts_prev = 0;
+
+ ULong_t current_time = cagra->Timestamp();
+ if (ts_prev) {
+ auto diff = current_time - ts_prev;
+ if (diff < 0) {
+ obj.FillHistogram("TimeOrdering",10,0,11,3);
+ } else {
+ obj.FillHistogram("TimeOrdering",10,0,11,7);
+ }
+ }
+ ts_prev = current_time;
+
+
+ //cout << "Size: " << cagra->Size() << endl;
+ for (auto& hit : *cagra) {
+
+ stream.str("");
+ stream << "PostE_BoardID" << hit.GetBoardID() << "_Chan" << hit.GetChannel();
+ obj.FillHistogram(stream.str().c_str(),10000,0,0,hit.Charge());
+ obj.FillHistogram("DigitizerHits",12,97,109,hit.GetBoardID(),12,-1,11,hit.GetChannel());
+
+ stream.str("");
+ stream << "Ge_" << hit.GetBoardID() << "Raw" << hit.GetChannel();
+ obj.FillHistogram(stream.str().c_str(),10000,0,10000,hit.Charge());
+ stream.str("");
+ stream << "Ge_" << hit.GetBoardID() << "Cal" << hit.GetChannel();
+ if (hit.GetBoardID() == 102) {
+ auto labr_E = hit.GetTraceEnergy(0,57,60,60+57);
+ //if (nevent % 10000 == 0) { cout << labr_E << endl; }
+ obj.FillHistogram(stream.str().c_str(),10000,0,10000,labr_E);
+ } else {
+ obj.FillHistogram(stream.str().c_str(),10000,0,10000,hit.GetEnergy());
+ }
+ stream.str("");
+ stream << "Ge_PZ_" << hit.GetBoardID() << "Cal" << hit.GetChannel();
+ //Double_t baseline = 180;
+ Double_t baseline = hit.GetBaseSample();
+ //auto baseline = hit.GetTraceBaseline();
+ obj.FillHistogram(stream.str().c_str(),10000,0,10000,hit.GetCorrectedEnergy(0));
+ stream.str("");
+ stream << "Ge_PZ_AsymBL_" << hit.GetBoardID() << "Cal" << hit.GetChannel();
+ obj.FillHistogram(stream.str().c_str(),10000,0,10000,hit.GetCorrectedEnergy(baseline));
+
+ stream.str("");
+ stream << "E_BL" << hit.GetBoardID() << "_" << hit.GetChannel();
+ obj.FillHistogram(stream.str().c_str(),1000,0,10000,hit.GetEnergy(),1000,0,3000,baseline);
+ stream.str("");
+ stream << "E_cor_BL" << hit.GetBoardID() << "_" << hit.GetChannel();
+ obj.FillHistogram(stream.str().c_str(),1000,0,10000,hit.GetCorrectedEnergy(baseline),1000,0,3000,baseline);
+
+ if (!TANLEvent::PileUpFlag(hit.GetFlags())) {
+ stream.str("");
+ stream << "Ge_NoPileUp_" << hit.GetBoardID() << "Raw" << hit.GetChannel();
+ obj.FillHistogram(stream.str().c_str(),10000,0,10000,hit.Charge());
+ stream.str("");
+ stream << "Ge_NoPileUp_" << hit.GetBoardID() << "Cal" << hit.GetChannel();
+ if (hit.GetBoardID() == 102) {
+ auto labr_E = hit.GetTraceEnergy(0,57,60,60+57);
+ //if (nevent % 10000 == 0) { cout << labr_E << endl; }
+ obj.FillHistogram(stream.str().c_str(),10000,0,10000,labr_E);
+ } else {
+ obj.FillHistogram(stream.str().c_str(),10000,0,10000,hit.GetEnergy());
+ }
+ }
+ else {
+ stream.str("");
+ stream << "Ge_PileUp_" << hit.GetBoardID() << "Raw" << hit.GetChannel();
+ obj.FillHistogram(stream.str().c_str(),10000,0,10000,hit.Charge());
+ stream.str("");
+ stream << "Ge_PileUp_" << hit.GetBoardID() << "Cal" << hit.GetChannel();
+ if (hit.GetBoardID() == 102) {
+ auto labr_E = hit.GetTraceEnergy(0,57,60,60+57);
+ //if (nevent % 10000 == 0) { cout << labr_E << endl; }
+ obj.FillHistogram(stream.str().c_str(),10000,0,10000,labr_E);
+ } else {
+ obj.FillHistogram(stream.str().c_str(),10000,0,10000,hit.GetEnergy());
+ }
+
+
+ }
+ }
+
+ }
+
+
+ if(numobj!=list->GetSize())
+ list->Sort();
+
+ nevent++;
+}
diff --git a/include/TANLEvent.h b/include/TANLEvent.h
index 43fabdb0..c152e8da 100644
--- a/include/TANLEvent.h
+++ b/include/TANLEvent.h
@@ -5,25 +5,34 @@
#include "TSmartBuffer.h"
+#include
+
+#include "GValue.h"
+
+
class TANLEvent : public TObject {
public:
TANLEvent(TSmartBuffer& buf);
~TANLEvent();
-
-
- Long_t GetLED() const { return led; }
- Long_t GetCFD() const { return cfd; }
+ 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 GetPrevLED() const { return led_prev; }
+ 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); }
@@ -33,22 +42,35 @@ class TANLEvent : public TObject {
UShort_t GeneralErrorFlag() const { return ((flags & 0x2000)>>13); }
UShort_t PileUpOnlyFlag() const { return ((flags & 0x4000)>>14); }
UShort_t PileUpFlag() const { return ((flags & 0x8000)>>15); }
-
- // TODO: add to input calibrations file for second order corrections
- // e.g. pole zero etc.
- double GetEnergy() const { return ((GetPostE() - GetPreE())/350.0); }
+ 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 led;
- ULong_t cfd;
+ ULong_t discriminator;
+ Double_t d_cfd;
- ULong_t led_prev;
- UInt_t flags;
+ ULong_t disc_prev;
+ UShort_t flags;
//UInt_t sampled_baseline;
UInt_t prerise_energy;
UInt_t postrise_energy;
@@ -57,8 +79,9 @@ class TANLEvent : public TObject {
UShort_t postrise_begin_sample;
UShort_t prerise_end_sample;
UShort_t prerise_begin_sample;
- //UShort_t base_sample;
+ UShort_t base_sample;
//UShort_t peak_sample;
+ std::vector wave_data;
ClassDef(TANLEvent,0);
};
diff --git a/include/TCaesar.h b/include/TCaesar.h
index ad5f39f2..d35b3d1a 100644
--- a/include/TCaesar.h
+++ b/include/TCaesar.h
@@ -16,6 +16,7 @@
#include "TEnv.h"
//For easy parsing of detector positions
#include
+#include
class TCaesar : public TDetector {
diff --git a/include/TCagra.h b/include/TCagra.h
index 118bcbae..1f920aa0 100644
--- a/include/TCagra.h
+++ b/include/TCagra.h
@@ -9,6 +9,8 @@
#include "TVector3.h"
+#include
+
class TCagra : public TDetector {
public:
@@ -30,7 +32,6 @@ class TCagra : public TDetector {
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();
diff --git a/include/TCagraHit.h b/include/TCagraHit.h
index 3333173b..f952c102 100644
--- a/include/TCagraHit.h
+++ b/include/TCagraHit.h
@@ -43,10 +43,34 @@ class TCagraHit : public TDetectorHit {
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);
};
diff --git a/include/TCagraSegmentHit.h b/include/TCagraSegmentHit.h
index cfd3ae7b..6de792c1 100644
--- a/include/TCagraSegmentHit.h
+++ b/include/TCagraSegmentHit.h
@@ -20,8 +20,12 @@ class TCagraSegmentHit : public TDetectorHit {
int GetBoardID() const;
int GetChannel() const;
-private:
+ std::vector& GetTrace() { return fTrace; }
+ void SetTrace(std::vector& trace);
+
+private:
+ std::vector fTrace;
ClassDef(TCagraSegmentHit,1);
};
diff --git a/include/TChannel.h b/include/TChannel.h
index 6894744f..e3bb5082 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();
@@ -120,6 +131,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/TGRUTOptions.h b/include/TGRUTOptions.h
index e53c845c..cd4b9d12 100644
--- a/include/TGRUTOptions.h
+++ b/include/TGRUTOptions.h
@@ -45,8 +45,12 @@ 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 TreeSource() const { return fTreeSource; }
bool SaveRCNPTree() const { return fSaveRCNPTree; }
+ bool FastForwardRawFile() const { return fFastForwardRaw; }
+ bool GRSingles() const { return fGRSingles; }
+
bool IsOnline() const { return fIsOnline; }
@@ -105,8 +109,10 @@ class TGRUTOptions : public TObject {
int fBuildWindow;
bool fShouldExit;
-
+ bool fFastForwardRaw;
bool fSaveRCNPTree;
+ std::string fGlobRaw;
+ bool fGRSingles;
ClassDef(TGRUTOptions,0);
};
diff --git a/include/TGlobRawFile.h b/include/TGlobRawFile.h
new file mode 100644
index 00000000..d2be5a78
--- /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() const {
+ return fWrapped.SourceDescription();
+ }
+ virtual std::string Status() const {
+ return fWrapped.Status();
+ }
+
+ 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
index a45cc379..a1f74432 100644
--- a/include/TGrandRaiden.h
+++ b/include/TGrandRaiden.h
@@ -28,6 +28,11 @@ class TGrandRaiden : public TDetector {
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);
diff --git a/include/TGrandRaidenHit.h b/include/TGrandRaidenHit.h
index 6a8c6c04..ce7a6a37 100644
--- a/include/TGrandRaidenHit.h
+++ b/include/TGrandRaidenHit.h
@@ -3,10 +3,17 @@
#include "TDetector.h"
#include "TDetectorHit.h"
+#include "RCNPEvent.h"
+
+#include
+
+struct LaBrHit;
class TGrandRaidenHit : public TDetectorHit {
public:
- TGrandRaidenHit();
+ TGrandRaidenHit(); // TODO: move to private
+ TGrandRaidenHit(RCNPEvent& rcnpevent);
+ TGrandRaidenHit(const TGrandRaidenHit& gr);
~TGrandRaidenHit();
virtual void Copy(TObject& obj) const;
@@ -14,22 +21,38 @@ class TGrandRaidenHit : public TDetectorHit {
virtual void Print(Option_t *opt = "") const;
virtual void Clear(Option_t *opt = "");
- void BuildFrom(TSmartBuffer& buf);
+ void BuildFrom();
+
- Double_t* GetADC() { return &ADC[0]; }
- Double_t GetADC(const Int_t& i) const { return ADC[i]; }
- const Double_t& GetRF() { return RF; }
- //void SetADC(Int_t chan, const Double_t& val) { ADC[chan] = val; }
+ 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;
- private:
- Double_t ADC[4];
- Double_t RF;
- ClassDef(TGrandRaidenHit,1);
+ ClassDef(TGrandRaidenHit,1);
};
+struct LaBrHit {
+ Int_t channel;
+ Double_t width;
+};
#endif
diff --git a/include/TRCNPSource.h b/include/TRCNPSource.h
index c39c3a83..7668de44 100644
--- a/include/TRCNPSource.h
+++ b/include/TRCNPSource.h
@@ -39,7 +39,7 @@ class TRCNPSource : public TRawEventSource {
protected:
void SetFileSize(long file_size) { fFileSize = file_size; }
- void LoadFakeTimestamps();
+ //void LoadFakeTimestamps();
private:
TRCNPSource() {;}
@@ -53,7 +53,7 @@ class TRCNPSource : public TRawEventSource {
#endif
ThreadsafeQueue rcnp_queue;
- std::queue timestamps;
+ //std::queue timestamps;
ClassDef(TRCNPSource,0);
};
diff --git a/include/TRawBanks.h b/include/TRawBanks.h
index bf383e86..b83186e0 100644
--- a/include/TRawBanks.h
+++ b/include/TRawBanks.h
@@ -276,14 +276,14 @@ struct GEBMode3Data {
friend std::ostream& operator<<(std::ostream& os, const GEBMode3Data &data);
static void SwapMode3Data(GEBMode3Data &data);
-enum ArgonneType { LEDv10, LEDv11, CFDv11 };
+enum ArgonneType { LEDv10, LEDv11, CFDv11, LEDv18, CFDv18 };
struct GEBArgonneHead {
UShort_t GA_packetlength;
UShort_t ud_channel;
- UInt_t led_low;
+ UInt_t disc_low;
UShort_t hdrlength_evttype_hdrtype;
- UShort_t led_high;
+ UShort_t disc_high;
UShort_t GetGA() const;
UShort_t GetLength() const;
UShort_t GetBoardID() const;
@@ -291,7 +291,7 @@ struct GEBArgonneHead {
UInt_t GetHeaderType() const;
UShort_t GetEventType() const;
UShort_t GetHeaderLength() const;
- ULong_t GetLED() const;
+ ULong_t GetDisc() const;
}__attribute__((__packed__));
friend std::ostream& operator<<(std::ostream& os, const GEBArgonneHead &header);
@@ -333,9 +333,115 @@ struct GEBArgonneLEDv11 {
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/TRawSource.h b/include/TRawSource.h
index 5746ea9d..bc277c2f 100644
--- a/include/TRawSource.h
+++ b/include/TRawSource.h
@@ -193,7 +193,10 @@ class TRawEventFileSource : public TRawEventByteSource {
virtual void Reset();
virtual std::string SourceDescription() const;
+
private:
+ void FastForward();
+
std::string fFilename;
FILE* fFile;
diff --git a/libraries/TDetSystems/TArgonne/TANLEvent.cxx b/libraries/TDetSystems/TArgonne/TANLEvent.cxx
index 2f6b2747..9540f852 100644
--- a/libraries/TDetSystems/TArgonne/TANLEvent.cxx
+++ b/libraries/TDetSystems/TArgonne/TANLEvent.cxx
@@ -6,8 +6,9 @@
ClassImp(TANLEvent)
//bool TANLEvent::fExtractWaves = true;
+Float_t TANLEvent::shaping_time = std::sqrt(-1);
-TANLEvent::TANLEvent(TSmartBuffer& buf) {
+TANLEvent::TANLEvent(TSmartBuffer& buf) : d_cfd(0.) {
bool read_waveform = TGRUTOptions::Get()->ExtractWaves();
if (read_waveform) {
@@ -24,8 +25,7 @@ TANLEvent::TANLEvent(TSmartBuffer& buf) {
global_addr = header->GetGA();
board_id = header->GetBoardID();
channel = header->GetChannel();
- led = header->GetLED();
- cfd = 0;
+ discriminator = header->GetDisc();
// Extract payload data. Two versions LED and CFD, with small changes for different FW versions
switch( static_cast(header->GetHeaderType()) ) {
@@ -40,7 +40,7 @@ TANLEvent::TANLEvent(TSmartBuffer& buf) {
// Swap big endian for little endian
TRawEvent::SwapArgonneLEDv11(*data);
// Extract data from payload
- led_prev = data->GetPreviousLED();
+ disc_prev = data->GetPreviousLED();
flags = data->flags;
prerise_energy = data->GetPreRiseE();
postrise_energy = data->GetPostRiseE();
@@ -60,6 +60,81 @@ TANLEvent::TANLEvent(TSmartBuffer& buf) {
"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& raw_data){
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());
}
}
diff --git a/libraries/TDetSystems/TArgonne/TCagraHit.cxx b/libraries/TDetSystems/TArgonne/TCagraHit.cxx
index 75403ceb..81c3c687 100644
--- a/libraries/TDetSystems/TArgonne/TCagraHit.cxx
+++ b/libraries/TDetSystems/TArgonne/TCagraHit.cxx
@@ -6,6 +6,8 @@
#include
#include "TString.h"
+#include "TRandom.h"
+#include "TANLEvent.h"
#include "GCanvas.h"
#include "GValue.h"
@@ -14,8 +16,7 @@
ClassImp(TCagraHit)
-TCagraHit::TCagraHit(){
-
+TCagraHit::TCagraHit() : prerise_energy(0), postrise_energy(0) {
}
TCagraHit::~TCagraHit() {
@@ -28,6 +29,7 @@ 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;
@@ -139,3 +141,113 @@ Int_t TCagraHit::Charge() const {
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() <& trace) {
+ fTrace.clear();
+ fTrace.swap(trace);
}
void TCagraSegmentHit::Print(Option_t *opt) const {
diff --git a/libraries/TDetSystems/TGrandRaiden/TGrandRaiden.cxx b/libraries/TDetSystems/TGrandRaiden/TGrandRaiden.cxx
index e9b1ad1f..f4508739 100644
--- a/libraries/TDetSystems/TGrandRaiden/TGrandRaiden.cxx
+++ b/libraries/TDetSystems/TGrandRaiden/TGrandRaiden.cxx
@@ -24,21 +24,12 @@ void TGrandRaiden::InsertHit(const TDetectorHit& hit){
int TGrandRaiden::BuildHits(std::vector& raw_data){
for(auto& event : raw_data){
SetTimestamp(event.GetTimestamp());
- TGrandRaidenHit hit;
- auto buf = event.GetBuffer();
- hit.BuildFrom(buf);
+ auto rcnp = reinterpret_cast(event.GetDataPtr());
+ TGrandRaidenHit hit(*rcnp);
+ hit.BuildFrom();
hit.SetTimestamp(event.GetTimestamp());
InsertHit(hit);
-
- //auto rcnp_evt = (TRCNPEvent&)event;
- //std::cout << std::hex << (long)rcnp_evt.event << std::endl;
- //std::cin.get();
- // SetTimestamp(rcnp_evt.GetTimestamp());
- // TGrandRaidenHit hit;
- // //auto buf = rcnp_evt.GetBuffer();
- // //hit.BuildFrom(buf);
- // hit.SetTimestamp(rcnp_evt.GetTimestamp());
- // InsertHit(hit);
+ delete rcnp;
}
return Size();
}
diff --git a/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx b/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx
index 9929bcea..67aebf27 100644
--- a/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx
+++ b/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx
@@ -1,47 +1,76 @@
-#ifdef RCNP
#include "TGrandRaidenHit.h"
#include "TGRUTOptions.h"
#include "RCNPEvent.h"
#include "TSmartBuffer.h"
+#include "TMath.h"
ClassImp(TGrandRaidenHit)
TGrandRaidenHit::TGrandRaidenHit() {
- memset(&ADC[0],0,sizeof(Double_t));
+ 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(TSmartBuffer& buf){
+void TGrandRaidenHit::BuildFrom(){
+ 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) {
- // auto event = *reinterpret_cast(const_cast(buf.GetData()));
- // auto adc = event->GR_ADC();
- // if (adc != nullptr) {
- // std::copy(adc->begin(),adc->end(),&ADC[0]);
- // }
- // Timestamp = event->GetTimestamp();
- // RF = event->GR_RF(0);
+ for (auto i=0u; isize(); i++) {
+ for (auto j=0u; jsize(); j++) {
+ if ((*qtc_le_chan)[i]==(*qtc_tr_chan)[j]) {
- // buf.Advance(sizeof(event));
- // if (event) delete event;
+ LaBrHit temphit;
+ temphit.channel = (*qtc_le_chan)[i];
+ temphit.width = (*qtc_tr_tdc)[i] - (*qtc_le_tdc)[j];
+ labr_hits.push_back(temphit);
+ //labr_hits.emplace_back({(*qtc_le_chan)[i],(*qtc_le_tdc)[i] - (*qtc_tr_tdc)[j]}); // =(
+ }
+ }
+ }
- auto event = *reinterpret_cast(const_cast(buf.GetData()));
- auto adc = event->GR_ADC();
- if (adc != nullptr) {
- std::copy(adc->begin(),adc->end(),&ADC[0]);
}
- Timestamp = event->GetTimestamp();
- RF = event->GR_RF(0);
- buf.Advance(sizeof(event));
- if (event) delete event;
+ 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]);
+ }
+
}
@@ -75,33 +104,3 @@ void TGrandRaidenHit::Clear(Option_t *opt) {
-
-
-#else
-
-
-#include "TGrandRaidenHit.h"
-
-ClassImp(TGrandRaidenHit)
-
-TGrandRaidenHit::TGrandRaidenHit() {
- memset(&ADC[0],0,sizeof(Double_t));
-}
-
-TGrandRaidenHit::~TGrandRaidenHit() { ; }
-
-void TGrandRaidenHit::BuildFrom(TSmartBuffer& buf){
- Clear();
-}
-
-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);
-}
-
-#endif
diff --git a/libraries/TGRUTUtil/TChannel.cxx b/libraries/TGRUTUtil/TChannel.cxx
index 5916a717..2e99a06c 100644
--- a/libraries/TGRUTUtil/TChannel.cxx
+++ b/libraries/TGRUTUtil/TChannel.cxx
@@ -7,6 +7,7 @@
#include
#include
#include
+#include
#include "TRandom.h"
@@ -67,6 +68,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";
@@ -262,6 +289,8 @@ void TChannel::ClearCalibrations() {
ClearEnergyCoeff();
ClearEfficiencyCoeff();
ClearTimeCoeff();
+ ClearPoleZeroCoeff();
+ ClearBaselineCoeff();
}
const std::vector& TChannel::GetEnergyCoeff(double timestamp) const {
@@ -303,6 +332,90 @@ 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;
+}
+
+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()) {
+ std::cout <& 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()) {
+ std::cout <& TChannel::GetTimeCoeff(double timestamp) const {
for(auto& tc : time_coeff) {
if(timestamp >= tc.start_time) {
@@ -545,6 +658,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 89dd3760..e2f6de83 100644
--- a/libraries/TGRUTint/TGRUTOptions.cxx
+++ b/libraries/TGRUTint/TGRUTOptions.cxx
@@ -95,6 +95,9 @@ void TGRUTOptions::Load(int argc, char** argv) {
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 GR timestamps and take singles.")
+ .default_value(false);
parser.option("hist-output",&output_histogram_file)
@@ -130,6 +133,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);
diff --git a/libraries/TGRUTint/TGRUTint.cxx b/libraries/TGRUTint/TGRUTint.cxx
index 26af2278..9e4ce89b 100644
--- a/libraries/TGRUTint/TGRUTint.cxx
+++ b/libraries/TGRUTint/TGRUTint.cxx
@@ -32,6 +32,7 @@
#include "TOrderedRawFile.h"
#include "TRawSource.h"
#include "TMultiRawFile.h"
+#include "TGlobRawFile.h"
#include "TSequentialRawFile.h"
#include "GrutNotifier.h"
@@ -216,6 +217,7 @@ void TGRUTint::ApplyOptions() {
//next most important thing, if given a raw file && NOT told to not sort!
if((opt->InputRing().length() || opt->RawInputFiles().size()
+ || opt->SortMultipleGlob().length()
|| (opt->RootInputFiles().size() && opt->TreeSource()))
&& !missing_file && opt->SortRaw()) {
@@ -241,6 +243,11 @@ void TGRUTint::ApplyOptions() {
}
source = multi_source;
+ } else if(opt->SortMultipleGlob().length()) {
+ // Open multiple files, read from all at the same time.
+ TGlobRawFile* glob_multi_source = new TGlobRawFile(opt->SortMultipleGlob());
+ source = glob_multi_source;
+
} else if(!opt->SortMultiple() && (
opt->RawInputFiles().size() > 1 ||
opt->RootInputFiles().size() > 1 ||
diff --git a/libraries/TRawFormat/LinkDef.h b/libraries/TRawFormat/LinkDef.h
index 6ba2550b..e2be2d1b 100644
--- a/libraries/TRawFormat/LinkDef.h
+++ b/libraries/TRawFormat/LinkDef.h
@@ -1,4 +1,4 @@
-// TRawSource.h TRawEvent.h TSmartBuffer.h TMultiRawFile.h TOrderedRawFile.h TSequentialRawFile.h TTreeSource.h TRCNPSource.h
+// TRawSource.h TRawEvent.h TSmartBuffer.h TMultiRawFile.h TGlobRawFile.h TOrderedRawFile.h TSequentialRawFile.h TTreeSource.h TRCNPSource.h
#ifdef __CINT__
@@ -26,6 +26,7 @@
#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+;
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/TMultiRawFile.cxx b/libraries/TRawFormat/TMultiRawFile.cxx
index c19c7190..5cfa81cd 100644
--- a/libraries/TRawFormat/TMultiRawFile.cxx
+++ b/libraries/TRawFormat/TMultiRawFile.cxx
@@ -67,12 +67,32 @@ int TMultiRawFile::GetEvent(TRawEvent& outevent){
// If another event exists, put it back into the list
FileEvent next;
next.file = output.file;
+
int bytes_read = next.file->Read(next.next_event);
if(bytes_read > 0){
fFileEvents.insert(next);
} else if (!TGRUTOptions::Get()->ExitAfterSorting()) {
+ // // // if in online mode and the current source is at its end, delete it
+ // // std::cout << next.file->Status() << std::endl;
+ // // TRawEventFileSource* filein = dynamic_cast(next.file);
+ // // if (filein) {
+ // // std::cout << filein->SourceDescription() << " : " << (filein->GetFileSize() - filein->GetBytesGiven()) << std::endl;
+ // // if ((filein->GetFileSize() - filein->GetBytesGiven()) == 0) {
+ // // std::lock_guard lock(fFileListMutex);
+ // // delete output.file;
+ // // fFileList.erase(output.file);
+ // // }
+ // // } else { // otherwise it is a stalled source and we should wait until data is available for coincidence building
+ // // stalled_source = next.file;
+ // // }
stalled_source = next.file;
- } else { // otherwise delete the source from the file list
+ }
+ else { // otherwise delete the source from the file list
+ std::cout << "######################################\n";
+ std::cout << std::endl << "Deleting source: " << next.file->SourceDescription() << std::endl;
+ std::cout << next.file->Status() << std::endl << std::endl;
+ std::cout << "######################################\n";
+
std::lock_guard lock(fFileListMutex);
delete output.file;
fFileList.erase(output.file);
diff --git a/libraries/TRawFormat/TRCNPSource.cxx b/libraries/TRawFormat/TRCNPSource.cxx
index 6d5da10f..bc5b93e6 100644
--- a/libraries/TRawFormat/TRCNPSource.cxx
+++ b/libraries/TRawFormat/TRCNPSource.cxx
@@ -17,10 +17,12 @@ TRCNPSource::TRCNPSource(const char* Command, kFileType file_type)
},
TGRUTOptions::Get()->SaveRCNPTree());
- LoadFakeTimestamps();
+ //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;
@@ -55,22 +57,38 @@ int TRCNPSource::GetEvent(TRawEvent& event) {
}
- // event = *rcnp_evt;
- event.SetFileType(fFileType);
+ //char* ptrbytes = (char*)calloc(1,sizeof(rcnp));
+ //*reinterpret_cast(ptrbytes) = rcnp;
+ //TSmartBuffer eventbuffer(ptrbytes,sizeof(rcnp));
+ //event.SetData(eventbuffer);
- char* ptrbytes = (char*)calloc(1,sizeof(rcnp));
- *reinterpret_cast(ptrbytes) = rcnp;
- auto eventbuffer = new TSmartBuffer(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;
+ }
+ }
- // set the timestamp of the ttree event
- if (timestamps.size()==0) {
- std::cout << "End of time stamps" << std::endl;
- return -1;
+ time = 2112;
+ }
}
- rcnp->SetTimestamp(timestamps.front());
- event.SetFragmentTimestamp(timestamps.front());
- timestamps.pop();
+
+ rcnp->SetTimestamp(time);
+ event.SetFragmentTimestamp(time);
return sizeof(rcnp);
}
@@ -85,30 +103,10 @@ std::string TRCNPSource::Status() const {
std::string TRCNPSource::SourceDescription() const {return "File: "+std::string("RCNP_BLD: ")+fCommand;}
-void TRCNPSource::LoadFakeTimestamps() {
-
- std::string line; std::stringstream stream; ULong_t ts;
- ifstream file ("/projects/ceclub/sullivan/cagragr/GRUTinizer/timestamps.dat");
- if (file.is_open())
- {
- while ( getline (file,line) )
- {
- stream << line;
- stream >> ts;
- timestamps.push(ts);
- stream.str("");
- stream.clear();
- //std::cout << ts << std::endl;
- }
- file.close();
- }
-}
-
-
-template<>
-int ThreadsafeQueue::ObjectSize(RCNPEvent& event) {
- return event.data.size();
-}
+// template<>
+// int ThreadsafeQueue::ObjectSize(RCNPEvent& event) {
+// return event.data.size();
+// }
template<>
int ThreadsafeQueue::ObjectSize(RCNPEvent*& event) {
diff --git a/libraries/TRawFormat/TRawBanks.cxx b/libraries/TRawFormat/TRawBanks.cxx
index ebcdb6b0..7d6eae23 100644
--- a/libraries/TRawFormat/TRawBanks.cxx
+++ b/libraries/TRawFormat/TRawBanks.cxx
@@ -136,7 +136,7 @@ UShort_t TRawEvent::GEBArgonneHead::GetChannel() const { return (ud_channel & 0x
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::GetLED() const { return (((ULong_t)led_high) << 32) + ((ULong_t)led_low); }
+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); }
@@ -157,12 +157,90 @@ UShort_t TRawEvent::GEBArgonneLEDv11::GeneralErrorFlag() const { return ((flags
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.led_low = SwapInt(header.led_low);
+ header.disc_low = SwapInt(header.disc_low);
header.hdrlength_evttype_hdrtype = SwapShort(header.hdrlength_evttype_hdrtype);
- header.led_high = SwapShort(header.led_high);
+ header.disc_high = SwapShort(header.disc_high);
}
void TRawEvent::SwapArgonneLEDv11(TRawEvent::GEBArgonneLEDv11& data) {
data.led_low_prev = SwapShort(data.led_low_prev);
@@ -180,33 +258,124 @@ void TRawEvent::SwapArgonneLEDv11(TRawEvent::GEBArgonneLEDv11& data) {
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.led_low) << "\n"
+ << STR(header.disc_low) << "\n"
<< STR(header.hdrlength_evttype_hdrtype) << "\n"
- << STR(header.led_high) << std::endl;
+ << 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;
+ << 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
diff --git a/libraries/TRawFormat/TRawEvent.cxx b/libraries/TRawFormat/TRawEvent.cxx
index fd455894..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;
}
@@ -88,6 +91,8 @@ Int_t TRawEvent::GetBodySize() const {
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;
diff --git a/libraries/TRawFormat/TRawEventFileSource.cxx b/libraries/TRawFormat/TRawEventFileSource.cxx
index 009ee059..cda7dc8d 100644
--- a/libraries/TRawFormat/TRawEventFileSource.cxx
+++ b/libraries/TRawFormat/TRawEventFileSource.cxx
@@ -6,6 +6,10 @@ TRawEventFileSource::TRawEventFileSource(const std::string& filename, kFileType
: TRawEventByteSource(file_type), fFilename(filename) {
fFile = fopen(filename.c_str(),"rb");
SetFileSize(FindFileSize(filename.c_str()));
+
+ if (TGRUTOptions::Get()->FastForwardRawFile() && TGRUTOptions::Get()->StartGUI()) {
+ FastForward();
+ }
}
TRawEventFileSource::~TRawEventFileSource() {
@@ -17,6 +21,10 @@ void TRawEventFileSource::Reset() {
fseek(fFile, 0, SEEK_SET);
}
+void TRawEventFileSource::FastForward() {
+ fseek(fFile, 0, SEEK_END);
+}
+
int TRawEventFileSource::ReadBytes(char* buf, size_t size){
size_t output = fread(buf, 1, size, fFile);
if(output != size){
diff --git a/libraries/TRawFormat/TRawEventSource.cxx b/libraries/TRawFormat/TRawEventSource.cxx
index c7330de4..4c5c81d9 100644
--- a/libraries/TRawFormat/TRawEventSource.cxx
+++ b/libraries/TRawFormat/TRawEventSource.cxx
@@ -95,7 +95,8 @@ TRawEventSource* TRawEventSource::EventSource(const char* filename,
source = new TTreeSource(filename,"rcnptree","rcnpevent", file_type);
} else if (hasSuffix(filename,".bld")){
std::string command;
- if (is_online) {
+ if (string(filename) == "online.bld") {
+ std::cout << "Going online with TRCNPSource..." < gr_queue(500000);
+ const char* filename = "~/data/run1006.bld";
+ ThreadsafeQueue gr_queue(500000);
atomic sig(0);
stringstream stream; stream.str(""); stream << "cat " << filename;
std::thread grloop(StartGRAnalyzer,stream.str().c_str(),&sig,[&](RCNPEvent* event){
- gr_queue.Push(*event);
+ gr_queue.Push(event);
},false);
- RCNPEvent data;
+ RCNPEvent* data;
static int count = 0;
while (gr_queue.Pop(data,0)) {
count++;
diff --git a/util/simpleread_anl.cxx b/util/simpleread_anl.cxx
index eb57d8c2..6aa7c2fb 100644
--- a/util/simpleread_anl.cxx
+++ b/util/simpleread_anl.cxx
@@ -73,6 +73,40 @@ struct ANL_LED_v11 {
uint16_t peak_sample;
}__attribute__((__packed__));
+struct ANL_LED_v18 {
+ uint32_t type;
+ uint32_t length;
+ uint64_t timestamp;
+ uint16_t ga_packetlength;
+ uint16_t ud_channel;
+ uint32_t led_low;
+ uint16_t hdrlength_evttype_hdrtype;
+
+ uint16_t led_high;
+ uint16_t led_low_prev;
+ uint16_t flags;
+ uint32_t led_high_prev;
+ uint32_t sampled_baseline;
+ uint32_t blank;
+ uint32_t postrise_sum_low_prerise_sum;
+ uint16_t timestamp_peak_low;
+ uint16_t postrise_sum_high;
+
+ uint16_t timestamp_trigger_low; // not fully implemented yet
+ uint16_t last_postrise_enter_sample;
+ // old: uint32_t timestamp_peak_high;
+
+ uint16_t last_postrise_leave_sample;
+ uint16_t postrise_leave_sample;
+ // old: uint16_t postrise_end_sample;
+ // old: uint16_t postrise_begin_sample;
+ uint16_t prerise_enter_sample;
+ uint16_t prereise_leave_sample;
+ // old: uint16_t prerise_end_sample;
+ // old: uint16_t prerise_begin_sample;
+ uint16_t base_sample;
+ uint16_t peak_sample;
+}__attribute__((__packed__));
int main (int argc, char **argv) {
@@ -114,8 +148,8 @@ int main (int argc, char **argv) {
//if (nevents>10) break;
auto head = (GEB_HEADER*)header;
- //cout << head->length << endl;
- //cin.get();
+ cout << head->length << endl;
+ cin.get();
datasize = head->length;
if (fread(payload,datasize,1,fd) == 1) {