Project

General

Profile

Documentation of libsbsdig » History » Version 28

Eric Fuchey, 07/09/2020 02:13 PM

1 1 Eric Fuchey
h1. Documentation of libsbsdig
2
3
h2. Overview
4
5
This page is maintained by the UConn group (Eric Fuchey + Andrew Puckett) and as of February 14, 2020 is specific to the '''''master''''' branch of libsbsdig on github.
6
7
h2. Purpose
8
9
This page documents the libsbsdig code, which purpose is to transform the output data from [https://hallaweb.jlab.org/wiki/index.php/Documentation_of_g4sbs G4SBS] to digital values such as ADCs or TDCs.
10
These produce files which can be analyzed with [https://hallaweb.jlab.org/wiki/index.php/Documentation_of_SBS-offline SBS-offline].
11
12
h2. Getting the code and building the program
13
14
h3. Prerequisites
15
16
*Working [https://root.cern.ch/drupal/ ROOT] installation. '''libsbsdig is compatible with ROOT version 5 and ROOT version 6'''. '''''ROOT 6 is strongly recommended'''''
17
*Working [https://redmine.jlab.org/projects/podd/wiki analyzer] installation. '''libsbsdig is compatible with analyzer versions 1.6 and beyond'''.
18
*Working [https://hallaweb.jlab.org/wiki/index.php/Documentation_of_SBS-offline SBS-offline] installation.
19
20
h3. Downloading the repository
21
22
The code is hosted on a github repository owned by JLab. To clone via ssh (preferred method on JLab batch farm), do: 
23
24 5 Eric Fuchey
bq. git clone git@github.com:JeffersonLab/libsbsdig.git
25 1 Eric Fuchey
26
For this method to work, the ssh public key on the machine where you want to get the code must be added to your github account (see [https://help.github.com/articles/generating-ssh-keys/ Guide] to generating ssh keys and adding to your github.com account.)
27
28
Cloning the repository defaults to the "master" branch.
29
30
h3. Building and installing the library
31
32 2 Eric Fuchey
Create a "build" directory that is parallel to the "libsbsdig" source directory (this is not strictly required, but the build directory must be separate from the "SBS-offline" directory in any case). 
33
You also need to have setup an installation path e.g. /path/to/libsbsdig-install
34
*NB*: similarly to the build directory, the /path/to/libsbsdig-install directory shall '''not''' be the same as the source directory!
35
_The following instructions assume that "build" is parallel to "libsbsdig":_
36 9 Eric Fuchey
If successful, the libsbsdig library and several other files and folders will be created in the "build" and the "install" directory.
37 1 Eric Fuchey
38 2 Eric Fuchey
To build and install, the procedure needs to be completed. From scratch:
39
40
bq. mkdir build
41
cd build
42
cmake -DCMAKE_INSTALL_PREFIX=/path/to/libsbsdig-install ../libsbsdig
43
make install
44 1 Eric Fuchey
45 3 Eric Fuchey
Then, the following line should be added in the OS login configuration file to take advantage of this functionality:
46
* source /path/to/libsbsdig-install/bin/sbsdigenv.sh (or source /path/to/g4sbs_install/bin/sbsdigenv.csh on the batch farm)
47 1 Eric Fuchey
48 13 Eric Fuchey
h2. digitization library use
49 1 Eric Fuchey
50 13 Eric Fuchey
h3. how to use the digitization library
51
52 9 Eric Fuchey
A working example script of using the digitization library is available in the libsbsdig repository at
53
example/digi_gmn.C 
54
The input arguments for this scripts are explained in the script comments. 
55
It has to be executed with the Hall A analyzer:
56 10 Eric Fuchey
> analyzer
57
> > .L digi_gmn.C
58
> > digi_gmn("simdig_outfile.root", 1000, "gmn13.5_elastic_prod.txt")
59 1 Eric Fuchey
60 13 Eric Fuchey
h3. Root output documentation
61 1 Eric Fuchey
62 15 Eric Fuchey
For each detector, several structures are stored under the form of an ensemble of vectors of integers and doubles.
63
There are three types of structures:
64 24 Eric Fuchey
* the "trackmchits" storing the information of the Monte Carlo track intercepting the detector; 
65
* the "simhits" storing the true energy deposits and corresponding number of photoelectrons for each g4sbs hit processed by libsbsdig;
66
* the "hits", storing the adc and tdc information;
67 15 Eric Fuchey
68 17 Eric Fuchey
h4. "trackmchit" structure
69 16 Eric Fuchey
70 26 Eric Fuchey
* nhits (int): number of entries stored for this structure and this detector
71 23 Eric Fuchey
* source (std::vector<short>): type of file where the MC track comes from (0 if signal, >0 if background)
72
* trid (std::vector<short>): track ID in G4SBS (mostly useful to distinguish primary tracks)
73
* pid  (std::vector<int>): track PDG PID
74 26 Eric Fuchey
* xhit (std::vector<double>) estimated point of intercept of the track at the detector surface, projected in the dispersive direction x (transport coordinates)
75
* yhit (std::vector<double>) estimated point of intercept of the track at the detector surface, projected in the non-dispersive direction y (transport coordinate)
76 1 Eric Fuchey
* thit (std::vector<double>) estimated time of intercept of the track at the detector surface
77
* e (std::vector<double>) track total energy
78
* weight (std::vector<double>) weight of the event from which the track is issued (not implemented yet)
79 26 Eric Fuchey
80
For the GEMs, the full track info is stored, but the intersect points with each of the points aren't:
81
82
mctrack_ntracks (int) number of tracks stored
83
* source (std::vector<short>): type of file where the MC track comes from (0 if signal, >0 if background)
84
* trid (std::vector<short>): track ID in G4SBS (mostly useful to distinguish primary tracks)
85
* pid  (std::vector<int>): track PDG PID
86
* x (std::vector<double>): track position x at z = 0 (transport coordinates)
87
* y (std::vector<double>): track position y at z = 0 (transport coordinates)
88
* t (std::vector<double>): track time  at z = 0
89
* p (std::vector<double>): track momentum
90
* dx (std::vector<double>): track slope projected in the dispersive direction x (transport coordinates)
91
* dy (std::vector<double>): track slope projected in the non-dispersive direction y (transport coordinates)
92
* xv (std::vector<double>): track vertex x at target (if applicable)
93
* yv (std::vector<double>): track vertex y at target (if applicable)
94
* zv (std::vector<double>): track vertex z at target (if applicable)
95
* pxv (std::vector<double>): track momentum x at target (if applicable)
96
* pyv (std::vector<double>): track momentum y at target (if applicable)
97
* pzv (std::vector<double>): track momentum z at target (if applicable)
98
* weight (std::vector<double>) weight of the event from which the track is issued (not implemented yet)
99
100 18 Eric Fuchey
h4. "simhit" structure
101 1 Eric Fuchey
102 27 Eric Fuchey
* nhits (int) number of entries stored for this structure and this detector
103 24 Eric Fuchey
* src (std::vector<short>): type of file where the sim hit comes from (0 if signal, >0 if background)
104
* trid (std::vector<short>): ID of track responsible of hit in G4SBS (n. i. y.)
105
* pid (std::vector<int>): PDG PID of track responsible of hit in G4SBS (n. i. y.)
106
* chan (std::vector<short>): channel number in which the hit is recorded
107 1 Eric Fuchey
* edep (std::vector<double>): energy deposit recorded in g4sbs (in GeV)
108 24 Eric Fuchey
* npe (std::vector<int>): recorded or estimated number of photoelectrons detected
109 27 Eric Fuchey
* time (std::vector<double>): time of hit as recorded by g4sbs
110 24 Eric Fuchey
* t_lead(std::vector<double>): estimated time when the pulse rises over threshold (for detectors with TDCs) 
111
* t_trail(std::vector<double>): estimated time when the pulse falls under threshold (for detectors with TDCs) 
112 18 Eric Fuchey
113 1 Eric Fuchey
Note: 
114
for calorimeters without TDCs, t_lead and t_trail are not applicable and will not be stored;
115
for cherenkov detectors, edep is not applicable and will not be stored;
116 27 Eric Fuchey
117
The structure above is valid for all detectors except GEMs. The structure for GEMs sim hits is:
118
119
* nhits (UInt_t) number of entries stored for this structure and this detector
120
* src (std::vector<short>): type of file where the sim hit comes from (0 if signal, >0 if background)
121
* trid (std::vector<short>): ID of track responsible of hit in G4SBS (n. i. y.)
122
* pid (std::vector<int>): PDG PID of track responsible of hit in G4SBS (n. i. y.)
123
* plane (std::vector<short>): layer number of the GEM in which the hit is recorded
124
* module (std::vector<short>): module number of the GEM in whcih the hit is recorded
125
* edep (std::vector<double>): energy deposit recorded in g4sbs (in GeV)
126
* time (std::vector<double>): time of hit as recorded by g4sbs
127 28 Eric Fuchey
* xpos (std::vector<double>): x position of hit in GEM module (transport coordinates)
128
* ypos (std::vector<double>): y position of hit in GEM module (transport coordinates)
129
* px (std::vector<double>): x momentum of the track in transport coordinates
130
* py (std::vector<double>): y momentum of the track in transport coordinates
131
* pz (std::vector<double>): z momentum of the track in transport coordinates
132
* sizex (std::vector<short>): number of strips on the x readout that receive *any* signal from the GEM avalanche
133
* sizey (std::vector<short>): number of strips on the y readout that receive *any* signal from the GEM avalanche
134
* startx (std::vector<short>): lowest x strip number that receive *any* signal from the GEM avalanche
135
* starty (std::vector<short>): lowest y strip number that receive *any* signal from the GEM avalanche
136 27 Eric Fuchey
137 28 Eric Fuchey
Note: the 4 last variables should be interpreted as such: the GEM avalanche will spread from strip #startx(y) to strip #startx(y)+sizex(y)
138 27 Eric Fuchey
139
   vector<short>   *bb_gem_simhit_startx;
140
   vector<short>   *bb_gem_simhit_starty;
141 18 Eric Fuchey
142
h4. "hit" structure
143 20 Eric Fuchey
144 25 Eric Fuchey
* nhits (int) number of entries for this structure and this detector
145
* chan (std::vector<short>) channel number in which the hit is recorded
146
* dataword (std::vector<unsigned int>) encoded data word containing the ADC/TDC; may also store headers (useful for simulation decoding)
147
* adc (std::vector<int>) unencoded pedestal subtracted ADC value
148
* tdc_l (std::vector<int>) unencoded leading TDC value
149
* tdc_t (std::vector<int>) unencoded trailing TDC value
150 19 Eric Fuchey
151 25 Eric Fuchey
*Particular case of detector read out by sampling ADCs (GEMs MPDs, HCal FADCs):*
152
In this case, storing each sample with the structure about would be too inefficient in terms of disk space. Hence, for this very specific case, we use vectors of evectors
153
 
154
* nsamps (std::vector<unsigned int>) number of ADC samples (number of elements in vector samps_adc, see note below)
155
* samps_adc (std::vector<vector<int> >) unencoded pedestal subtracted ADC values (samps_adc[i][j] = sample j for hit i)
156
* datawords (std::vector<vector<unsigned int> >) datawords containing the encoded GEMs. 
157
158
_Note_: for both MPDs and FADCs, two ADC values are encoded in a single 32 bits words. that means the actual number of ADC samples (nsamps) is twice the number elements in vector datawords. The number of elements in vector datawords is stored in variable dataword.