Module physics_hist_mod
module physics_hist_mod
! Uses
use calibrations_mod
use det_geom_mod, ONLY: zmuscint,tmuscint
use track_mod
use precision_mod
use pattern_mod
use windowstat_mod
use skim_mod
use classify_mod
use trackrange_mod
use unp_mod, only: nWordsFBC
use unpmc_mod
use unpderiv_mod
use namelist_mod, ONLY: unpackmc,enablewindowingbj
use hists_mod, ONLY: FirstPCADC, LastPCADC
! Variables
integer (kind=i4), private, PARAMETER :: IDH_HELIX_NTUPLE = 8888
integer (kind=i4), private, PARAMETER, dimension (8) :: kNumNTColumns = (/ 47, 50, 40, 12, 50, 20, 50, 50 /)
integer (kind=i4), private :: nttype = 2
integer (kind=i4), private, PARAMETER :: kRowsTimesColumns = 1861200
integer (kind=i4), private :: NumHelixNTFiles
! Subroutines and functions
private function V3mag (a)
private function finite (x)
private function realfinite (x)
private function makeFinite (x, y)
private function realmakeFinite (x, y)
public subroutine FillPhysicsHists ()
private function get_mc_vertex (itrack, start)
private function find_matching_positron (muStopVertex)
end module physics_hist_mod
====================================================================
Author: B. Jamieson
Initial Revision: 5 Sept 2001
Last Updated: 7 Nov 2002
--------------------------------------------------------------------
Description: Fills Physics histos.
Description of Variables
IDH_HELIX_NTUPLE
integer (kind=i4), private, PARAMETER :: IDH_HELIX_NTUPLE = 8888
kNumNTColumns
integer (kind=i4), private, PARAMETER, dimension (8) :: kNumNTColumns = (/ 47, 50, 40, 12, 50, 20, 50, 50 /)
nttype
integer (kind=i4), private :: nttype = 2
kRowsTimesColumns
integer (kind=i4), private, PARAMETER :: kRowsTimesColumns = 1861200
NumHelixNTFiles
integer (kind=i4), private :: NumHelixNTFiles
Description of Subroutines and Functions
V3mag
private function V3mag (a)
real (kind=R8), INTENT(in), dimension (3) :: a
real (kind=R8) :: v3mag
end function V3mag
SUBROUTINE FillHelixNtuple
------------------------------------------------------------------------------
FillHelixNtuple is the main steering subroutine for filling the
helix ntuple. It handles deciding which type of ntuple has been
requested, and decides when a new ntuple file needs to be opened.
SUBROUTINE FillFatRealNT
-----------------------------------------------------------------------------
This subroutine fills an ntuple with information from data runs including
PACT data. This version has substantial differences from version 9. This Ntuple
adds MCTR values if unpackmc is set to true. For values that are li
HelixNtupleType 2, Version 11 : Variable Descriptions
----------------------------------------------------
Variable in Code Ntuple Variable Description
------------------------- --------------- --------------------------------------------
integer:: NTHrunum2 runum ! run number
integer:: NTHeventnum2 eventnum ! event number
integer:: NTHversion2 version ! ntuple version number (11)
integer:: NTHeventType2 eventType ! event type 1=simple clean, 2=time clean, ...
real :: NTHcptime2 cptime ! capacitive probe time
integer:: NTHnMuScHits2 nMuScHits ! number of muon scintillator hits
real :: NTHminMuScTime2 minMuScTime ! minimum time for a muon scintillator hit
real :: NTHdMuScTime2 dMuScTime ! difference in time between first two mu scint hits
real :: NTHm12width2 m12width ! PACT width for muon scintillator (Analog M1+M2)
real :: NTHpcelost2(4) pcelost(4) ! PACT energy loss sum for PC planes 5-8
integer:: NTHnwindows2 nwindows ! number of windows in event
integer:: NTHwindow2(2) window(2) ! window for mu+, e+ fit
integer:: NTHwinnumDC2(2) winnumDC(2) ! number of DC hits in window
integer:: NTHwinnumPC2(2) winnumPC(2) ! number of PC hits in window
integer:: NTHwinDCmin2(2) winDCmin(2) ! minimum plane number for DC hit in window
integer:: NTHwinDCmax2(2) winDCmax(2) ! maximum plane number for DC hit in window
integer:: NTHwinPCmin2(2) winPCmin(2) ! minimum plane number for pc hit in window
integer:: NTHwinPCmax2(2) winPCmax(2) ! maximum plane number for PC hit in window
real :: NTHRmax(2) winRmax(2) ! maximum radius from center of a hit in window
real :: NTHwintime2(2) wintime(2) ! window time for mu+, e+ window
real :: NTHpc5uv2(2) winpc5uv(2) ! coordinate of pc cluster hit in pc 5
real :: NTHpc6uv2(2) winpc6uv(2) ! coordinate of pc cluster hit in pc 6
real :: NTHpc7uv2(2) winpc7uv(2) ! coordinate of pc cluster hit in pc 7
real :: NTHpc8uv2(2) winpc8uv(2) ! coordinate of pc cluster hit in pc 8
integer:: NTHfitnumU2(2) fitnumU(2) ! number of DC u hits used in mu+ fgfit, e+ fit
integer:: NTHfitnumV2(2) fitnumV(2) ! number of DC v hits used in mu+ fgfit, e+ fit
integer:: NTHfitDCmin2(2) fitDCmin(2) ! minimum plane number for DC hit for mu+ fgfit, e+ fit
integer:: NTHfitDCmax2(2) fitDCmax(2) ! maximum plane number for DC hit for mu+ fgfit, e+ fit
real :: NTHfittgtu2(2) fittgtu(2) ! u coordinate of fit projected to target for e+ fit,
! circle centre for mu+
real :: NTHfittgtv2(2) fittgtv(2) ! v coordinate of fit projected to target for e+ fit,
! circle centre for mu+
real :: NTHptot2(2) ptot(2) ! total momentum for mu+ fgfit, e+ fit
real :: NTHcosth2(2) costh(2) ! cosine theta for mu+ fgfit, e+ fit
real :: NTHphi2(2) phi(2) ! phi(of momentum) for mu+ fgfit, e+ fit
real :: NTHtime2(2) time(2) ! time for mu+ fgfit, e+ fit
real :: NTHchi22(2) chi2(2) ! chi-squared for mu+ fgfit, e+ fit
integer:: NTHndof2(2) ndof(2) ! number of degrees of freedom for mu+ fgfit, e+ fit
real :: NTHconlev2(2) conlev(2) ! confidence level for mu+ fgfit, e+ fit
integer:: NTHq2(2) q(2) ! charge for mu+ fgfit, e+ fit
integer:: NTHierror2(2) ierror(2) ! status code for mu+ fgfit, e+ fit
If unpackmc is true then the following variables are added to the ntuple, if space points are available
then they are used to get values at the points indicated in the description. Otherwise the parameters
from the generator (MC True bank).
real :: NTHmcptot2(2) MCptot(2) ! MC total momentum for mu+(after M scint),e+(at first SP)
real :: NTHmccosth2(2) MCcosth(2) ! MC cos theta for mu+(after M scint),e+(at first SP)
real :: NTHmcphi2(2) MCphi(2) ! MC phi for mu+(after M scint),e+(at first SP)
real :: NTHmctime2(2) MCtime(2) ! MC time for mu+(after M scint),e+(at first SP)
real :: NTHmcvx2(2) MCvx(2) ! MC starting x vertex for mu+(after M scint),e+(at first SP)
real :: NTHmcvy2(2) MCvy(2) ! MC starting y vertex for mu+(after M scint),e+(at first SP)
real :: NTHmcvz2(2) MCvz(2) ! MC starting z vertex for mu+(after M scint),e+(at first SP)
integer:: NTHmcpid2(2) MCpid(2) ! MC particle type for mu+(5 or 65),e+(2)
SUBROUTINE FillAllTestNT
-----------------------------------------------------------------------------
This subroutine fills an ntuple with information from data runs including
PACT data. This version adds info from each even window with a track.
This Ntuple adds MCTR values if unpackmc is set to true. For values that are li
HelixNtupleType 7, Version 2 : Variable Descriptions
----------------------------------------------------
This ntuple version has a big difference from previous versions.
Instead of having one track per window, this ntuple can have
multiple tracks per window. This has required some careful thought
about how to index tracks and information. To avoid having too
much duplicate information in the ntuple, there are two sets of
arrays. The window arrays, and the track arrays. The window
array has one entry per non-empty window, and contains all the
windowing information. The track array has information about
muon, beam positron, and decay positron fits. Muons have
just FG fits, beam positrons have up to three fits, and decay
positrons have up to two fits.
Window array Number of entries: NTHNwin7 (Nwin)
Track array Number of entries: NTHNTr7 (NTr)
Indices into the track array:
NTHmuTr
Variable in Code Ntuple Variable Description
------------------------- --------------- --------------------------------------------
REAL ::NTHinfo7(6) ! run number,eventnumber,version,
! event type, m12width, capacitive probe time
INTEGER::NTHnMuScHits7 ! number of muon scintillator hits
REAL ::NTHMuScTimes7 ! times for muon scintillator hits
REAL ::NTHpcelost7(4) ! PACT energy loss sum for PC planes 5-8
INTEGER::NTHnwin7 ! number of entries in event (number of tracks)
INTEGER::NTHwindow7((MaxWindows-1)/2) ! Window for this track/fit
REAL ::NTHwintime7((MaxTracks) ! window time for track
INTEGER::NTHwintype7((MaxWindows-1)/2) ! window type
INTEGER::NTHwinnumDC7((MaxWindows-1)/2) ! number of DC hits in window
INTEGER::NTHwinnumPC7((MaxWindows-1)/2) ! number of PC hits in window
INTEGER::NTHwinDCmin7((MaxWindows-1)/2) ! minimum plane number for DC hit in window
INTEGER::NTHwinDCmax7((MaxWindows-1)/2) ! maximum plane number for DC hit in window
INTEGER::NTHwinPCmin7((MaxWindows-1)/2) ! minimum plane number for pc hit in window
INTEGER::NTHwinPCmax7((MaxWindows-1)/2) ! maximum plane number for PC hit in window
REAL ::NTHpc5uv7((MaxWindows-1)/2) ! coordinate of pc cluster hit in pc 5
REAL ::NTHpc6uv7((MaxWindows-1)/2) ! coordinate of pc cluster hit in pc 6
REAL ::NTHpc7uv7((MaxWindows-1)/2) ! coordinate of pc cluster hit in pc 7
REAL ::NTHpc8uv7((MaxWindows-1)/2) ! coordinate of pc cluster hit in pc 8
REAL ::NTHRmax7((MaxWindows-1)/2) ! maximum radius from center of a hit in window
INTEGER::NTHnTr7
INTEGER::NTHmuidx7(MaxTracks) ! Index into ntuple for muons
INTEGER::NTHdkidx7(MaxTracks) ! Index into ntuple for decay positrons
INTEGER::NTHeidx7(MaxTracks) ! Index into ntuple for beam positrons
INTEGER::NTHWinIdx7(MaxTracks) ! Window for this track/fit
INTEGER::NTHstream7(MaxTracks) ! Stream for this track/fit
INTEGER::NTHfitnumU7(MaxTracks) ! number of DC u hits used in track fit
INTEGER::NTHfitnumV7(MaxTracks) ! number of DC v hits used in track fit
INTEGER::NTHfitDCmin7(MaxTracks) ! minimum plane number for DC hit for track fit
INTEGER::NTHfitDCmax7(MaxTracks) ! maximum plane number for DC hit for track fit
REAL ::NTHfittgtu7(MaxTracks) ! u coordinate of fit projected to target for track fit
REAL ::NTHfittgtv7(MaxTracks) ! v coordinate of fit projected to target for track fit
REAL ::NTHptot7(MaxTracks) ! total momentum for track fit
REAL ::NTHcosth7(MaxTracks) ! cosine theta for track fit
REAL ::NTHphi7(MaxTracks) ! phi(of momentum) for track fit
REAL ::NTHtime7(MaxTracks) ! time for track fit
REAL ::NTHchi27(MaxTracks) ! chi-squared for track fit
INTEGER::NTHndof7(MaxTracks) ! number of degrees of freedom for track fit
REAL ::NTHconlev7(MaxTracks) ! confidence level for track fit
INTEGER::NTHq7(MaxTracks) ! charge for track fit
INTEGER::NTHierror7(MaxTracks) ! status code for track fit
REAL ::NTHuser7(20) ! user bank
Variable in Code Ntuple Variable Description
------------------------- --------------- --------------------------------------------
real :: NTHmcptot7((MaxWindows-1)/2) ! MC total momentum at first SP for track
real :: NTHmccosth7((MaxWindows-1)/2) ! MC cos theta at first SP for track
real :: NTHmcphi7((MaxWindows-1)/2) ! MC phi for mu+ at first SP for track
real :: NTHmctime7((MaxWindows-1)/2) ! MC time for mu+ at first SP for track
real :: NTHmcvx7((MaxWindows-1)/2) ! MC starting x vertex at first SP for track
real :: NTHmcvy7((MaxWindows-1)/2) ! MC starting y vertex at first SP for track
real :: NTHmcvz7((MaxWindows-1)/2) ! MC starting z vertex at first SP for track
integer:: NTHmcpid7((MaxWindows-1)/2) ! MC particle type for track!!
If unpackmc is true then the following variables are added to the ntuple, if space points are available
then they are used to get values at the points indicated in the description. Otherwise the parameters
from the generator (MC True bank).
SUBROUTINE FillRobNT
-----------------------------------------------------------------------------
This subroutine fills an ntuple with information from data runs including
PACT data. This version adds info about a muon track, and a positron track
(info from each stream -1, then 1).
This Ntuple adds MCTR values if unpackmc is set to true.
This ntuple contains 3 entries.
Track 1 is a muon
Track 2 is an upstream fit (dk if decay requested)
Track 3 is a downstream fit (beame if beame requested)
This ntuple also contains info on all non-empty windows.
The index into the non-empty window, for track 2 for example,
is winidx(2).
HelixNtupleType 8, Version 1 : Variable Descriptions
----------------------------------------------------
Variable in Code Ntuple Variable Description
------------------------- --------------- --------------------------------------------
REAL ::NTHinfo8(6) ! run number,eventnumber,version,
! event type, m12width, capacitive probe time
INTEGER::NTHnMuScHits8 ! number of muon scintillator hits
REAL ::NTHMuScTimes8(15) ! times for muon scintillator hits
REAL ::NTHpcelost8(4) ! PACT energy loss sum for PC planes 5-8
INTEGER::NTHnwin8 ! number of non-empty windows
INTEGER::NTHwindow8(MaxWindows) ! Window for this track/fit
REAL ::NTHwintime8(MaxWindows) ! window time for track
INTEGER::NTHwintype8(MaxWindows) ! window type
INTEGER::NTHwinnumDC8(MaxWindows) ! number of DC hits in window
INTEGER::NTHwinnumPC8(MaxWindows) ! number of PC hits in window
INTEGER::NTHwinDCmin8(MaxWindows) ! minimum plane number for DC hit in window
INTEGER::NTHwinDCmax8(MaxWindows) ! maximum plane number for DC hit in window
INTEGER::NTHwinPCmin8(MaxWindows) ! minimum plane number for pc hit in window
INTEGER::NTHwinPCmax8(MaxWindows) ! maximum plane number for PC hit in window
REAL ::NTHpc5uv8(MaxWindows) ! coordinate of pc cluster hit in pc 5
REAL ::NTHpc6uv8(MaxWindows) ! coordinate of pc cluster hit in pc 6
REAL ::NTHpc7uv8(MaxWindows) ! coordinate of pc cluster hit in pc 7
REAL ::NTHpc8uv8(MaxWindows) ! coordinate of pc cluster hit in pc 8
REAL ::NTHRmax8(MaxWindows) ! maximum radius from center of a hit in window
INTEGER::NTHWinIdx8(3) ! Index into nwin8 for this track/fit
INTEGER::NTHfitnumU8(3) ! number of DC u hits used in track fit
INTEGER::NTHfitnumV8(3) ! number of DC v hits used in track fit
INTEGER::NTHfitDCmin8(3) ! minimum plane number for DC hit for track fit
INTEGER::NTHfitDCmax8(3) ! maximum plane number for DC hit for track fit
REAL ::NTHfittgtu8(3) ! u coordinate of fit projected to target for track fit
REAL ::NTHfittgtv8(3) ! v coordinate of fit projected to target for track fit
REAL ::NTHptot8(3) ! total momentum for track fit
REAL ::NTHcosth8(3) ! cosine theta for track fit
REAL ::NTHphi8(3) ! phi(of momentum) for track fit
REAL ::NTHtime8(3) ! time for track fit
REAL ::NTHchi28(3) ! chi-squared for track fit
INTEGER::NTHndof8(3) ! number of degrees of freedom for track fit
REAL ::NTHconlev8(3) ! confidence level for track fit
INTEGER::NTHq8(3) ! charge for track fit
INTEGER::NTHierror8(3) ! status code for track fit
REAL ::NTHuser8(20) ! user bank
Variable in Code Ntuple Variable Description
------------------------- --------------- --------------------------------------------
real :: NTHmcptot7(3) ! MC total momentum at first SP for track
real :: NTHmccosth7(3) ! MC cos theta at first SP for track
real :: NTHmcphi7(3) ! MC phi for mu+ at first SP for track
real :: NTHmctime7(3) ! MC time for mu+ at first SP for track
real :: NTHmcvx7(3) ! MC starting x vertex at first SP for track
real :: NTHmcvy7(3) ! MC starting y vertex at first SP for track
real :: NTHmcvz7(3) ! MC starting z vertex at first SP for track
integer:: NTHmcpid7(3) ! MC particle type for track!!
If unpackmc is true then the preceding variables are added to the ntuple, if space points are available
then they are used to get values at the points indicated in the description. Otherwise the parameters
from the generator (MC True bank).
SUBROUTINE DefineHelixNtuple
------------------------------------------------------------------------------
This subroutine names, opens and closes the helix ntuple files. Every time
that a new ntuple file needs to be started, this subroutine is called. The
name for the helix ntuples is set here to be
[RunNumber]helixnt[FileNumber].hbook.
The helix ntuples can be written to a different directory by setting the
environment variable HELIXNT_DIR (or MHIST).
finite
private function finite (x)
real (kind=R8), INTENT(in) :: x
logical :: finite
end function finite
realfinite
private function realfinite (x)
real (kind=R4), INTENT(in) :: x
logical :: realfinite
end function realfinite
makeFinite
private function makeFinite (x, y)
real (kind=R8), INTENT(in) :: x
real (kind=R8), INTENT(in) :: y
real (kind=R8) :: makeFinite
end function makeFinite
realmakeFinite
private function realmakeFinite (x, y)
real (kind=R4), INTENT(in) :: x
real (kind=R4), INTENT(in) :: y
real (kind=R4) :: realmakeFinite
end function realmakeFinite
FillPhysicsHists
public subroutine FillPhysicsHists ()
! Calls: ConvertFGZtoVPQ, HF1, hf1, hf2
end subroutine FillPhysicsHists
get_mc_vertex
private function get_mc_vertex (itrack, start)
integer :: itrack
logical :: start
integer :: get_mc_vertex
type(mctrack_type):: get_mc_vertex
end function get_mc_vertex
Returns index into fMcTracks() of the
start (start==0) or stop (start!=0) vertex
of mc track itrack.
find_matching_positron
private function find_matching_positron (muStopVertex)
type (mctrack_type) :: muStopVertex
integer :: find_matching_positron
end function find_matching_positron
Returns index into fMcTracks() of the decay positron vertex
matching the given muon stop vertex.