NTagEventInfo

class NTagEventInfo

Subclassed by NTagIO

Public Functions

NTagEventInfo(Verbosity verbose)

Constructor of class NTagEventInfo.

Default search settings for capture candidates, i.e., the range of NHits and T0, are set in this constructor. You can always change the settings using the setter functions provided with this class, but only if you use them before NTagIO::ReadFile is called. Cuts in calculating TMVA classifier output can also be set using NTagTMVA::SetReaderCutRange method.

Parameters

verbose – The verbosity of NTagEventInfo and all of its daughter classes.

virtual ~NTagEventInfo()

Destructor of class NTagEventInfo.

virtual void SetEventHeader()

Saves basic event information to member variables.

Saved variables: runNo, subrunNo, eventNo, qismsk, nhitac, trgOffset

virtual void SetPromptVertex()

Saves prompt vertex (neutron creation vertex).

Saved variables: pvx, pvy, pvz

virtual void SetAPFitInfo()

Saves variables generated by APFit.

Saved variables: evis, apNRings, vAPRingPID, vAPMom, vAPMomE, vAPMomMu, apNMuE, apNDecays

virtual void SetLowFitInfo()

Saves prompt-related variables generated by BONSAI.

Saved variables: evis

virtual void SetTDiff()

Saves tDiff, the time passed since the previous trigger.

virtual void AppendRawHitInfo()

Extracts TQ hit arrays from input file and append it to the raw hit vectors.

Saved variables: vTISKZ, vQISKZ, vCABIZ

virtual void SetToFSubtractedTQ()

Subtracts ToF from each raw hit time in vTISKZ and sort.

Saved variables: vUnsortedT_ToF, vSortedT_ToF, vSortedPMTID, vSortedQ

virtual void DumpEventVariables()

Dump event variables and statistics.

virtual void SetMCInfo()

Saves true variables extractable only from MC.

Saved variables: nVec, vecx, vecy, vecz, vVecPID, vVecPX, vVecPY, vVecPZ, vVecMom, neutIntMode, nVecInNeut, nNInNeutVec, neutIntMom, nSavedSec, nTrueCaptures, vSecPID, vSecIntID, vParentPID, vSecVX, vSecVY, vSecVZ, vSecDWall, vSecPX, vSecPY, vSecPZ, vSecMom, vSecT, vCapID vTrueCT, vCapVX, vCapVY, vCapVZ, vNGamma, vTotGammaE, vCapID

virtual void ReadSecondaries()

Reads secondary bank from input file and fills secndprt common. Called inside NTagEventInfo::SetMCInfo.

virtual void SearchCaptureCandidates()

The main search function for candidate selection before applying neural network.

NTagEventInfo::SavePeakFromHit is called to save peaks that match the primary selection conditions as neutron capture candidates. See the source code for the details.

See also

: Tristan’s ntag technote for the description of Neut-fit.

virtual void SavePeakFromHit(int hitID)

Saves the peak from the input index of the sorted ToF-subtracted hit-time vector vSortedT_ToF.

Saved variables: vFirstHitID, #vBeta14_10, nCandidates

Parameters

hitID – The index of the first hit of the peak to save.

virtual void SetCandidateVariables()

Function for setting candidate variables.

Extract candidate variables from the candidate vector vCandidates.

void InitializeCandidateVariableVectors()

Initialize STL maps iCandidateVarMap and fCandidateVarMap with feature variable names declared in NTagCandidate::SetVariables.

void ExtractCandidateVariables()

Extract variable values from each candidates in vCandidates and save those in iCandidateVarMap and fCandidateVarMap.

void DumpCandidateVariables()

Dump all saved candidates’ hit information and feature variables.

float GetToF(float vertex[3], int pmtID)

Gets ToF from a vertex specified by vertex to a PMT with cable ID pmtID.

Parameters
  • vertex – A size-3 float array of x, y, and z-coordinates of some point in the SK coordinate system.

  • pmtID – Cable ID of a PMT.

Returns

The time-of-flight (ToF) of a photon from the given vertex to the specified PMT.

std::vector<float> GetToFSubtracted(const std::vector<float> &T, const std::vector<int> &PMTID, float vertex[3], bool doSort = false)

Gets the ToF-subtracted version of an input hit-time vector T.

Note

The input hit-time vector must not have ToF subtracted as ToF will be subtracted inside this function.

Parameters
  • T – A vector of PMT hit times. [ns]

  • PMTID – A vector of PMT cable IDs corresponding to each hit in T.

  • vertex – A size-3 array of vertex coordinates to calculate ToF from.

  • doSort – If true, the returned vector is sorted in ascending order.

Returns

The ToF-subtracted version of an input hit-time vector T. If doSort is set to true, the returned vector is sorted in ascending order.

void SortToFSubtractedTQ()

Sort ToF-subtracted hit vector vUnsortedT_ToF.

Saved variables: vSortedT_ToF, vSortedQ, vSortedPMTID.

virtual void Clear()

Clears all member vectors and sets all member variables to a default value (which is mostly 0).

virtual void SaveSecondary(int secID)

Saves the secondary of the given index. Called inside NTagEventInfo::SetMCInfo.

Saved variables: vSecPID, vSecIntID, vParentPID, vSecVX, vSecVY, vSecVZ, vSecDWall, vSecPX, vSecPY, vSecPZ, vSecMom, vSecT, vCapID, nSavedSec

Parameters

secID – The index of the secondary particle saved in the secndprt common block.

inline bool IsRawHitVectorEmpty()

Checks if the raw hit vector vTISKZ is empty.

This function is used as a flag for an SHE event. If this function is false, the previous event must have been an SHE event.

Returns

true if vTISKZ is empty, otherwise false.

inline void SetNHitsWidth(float w)

Set width of NHits.

Parameters

w – Time width of TWIDTH. [ns]

inline void SetNHitsLimits(int low, int high = NTagDefault::NHITSMX)

Set limits NHITSTH and NHITSMX for NHits.

Parameters
  • low – Lower limit for NHits.

  • high – Upper limit for NHits.

inline void SetN200Max(int max)

Set upper limit N200MX for N200.

Parameters

max – Upper limit for N200.

inline void SetT0Limits(float low, float high = NTagDefault::T0MX)

Set limits T0TH and T0MX for T0.

Note

Both T0TH and T0MX should be in the form of global recorded hit time. Please take into account that tthe rigger offset is ~1,000 ns in this format.

Parameters
  • low – Lower limit for T0. [ns]

  • high – Upper limit for T0. [ns]

inline void SetDistanceCut(float cut)

Set vertex search range VTXSRCRANGE in NTagEventInfo::MinimizeTRMS. Use this function to cut T0 of the capture candidates.

Parameters

cut – Vertex search range to be used in NTagEventInfo::MinimizeTRMS

inline void SetMinGridWidth(float w)

Set vertex search range MINGRIDWIDTH in NTagEventInfo::MinimizeTRMS.

Parameters

w – Vertex search grid width [cm] to be used in NTagCandidate::MinimizeTRMS.

inline void SetTMatchWindow(float t)

Set the width TMATCHWINDOW of the time window used in true-to-reconstructed capture mapping.

Parameters

t – Width of the time window for capture mapping. [ns]

inline void SetTPeakSeparation(float t)

Set the minimum peak separation TMINPEAKSEP.

Parameters

t – Width of minimum peak separation. [ns]

inline void SetMaxODHitThreshold(float q)

Set the upper limit ODHITMX for the number of OD hits.

Note

The parameter ODHITMX is not used at the moment.

Parameters

q – Upper limit for the number of OD hits.

inline void SetTRBNWidth(float t)

Set the dead time width TRBNWIDTH for RBN reduction.

See also

Mochizuki-san’s Master’s thesis for the details of RBN (i.e., repetitive burst noise).

Parameters

t – The dead time width for RBN reduction.

inline void SetVertexMode(VertexMode m)

Sets #VertexMode fVertexMode.

See also

#VertexMode

Parameters

m – Vertex mode to use in NTagEventInfo.

inline void SetVertexResolution(float s)

Sets NTagEventInfo::PVXRES.

Parameters

s – Prompt vertex resolution. [cm]

inline void UseTMVA(bool b)

Chooses whether to use TMVA or not. Sets bUseTMVA.

Parameters

b – If true, TMVA is used to produce classifier output. (#vTMVAOutput)

inline void SetCustomVertex(float x, float y, float z)

Sets custom vertex to start searching for candidates. Sets customvx, customvy, customvz.

See also

#VertexMode

Parameters
  • x – X coordinate in SK coordinate system [cm]

  • y – Y coordinate in SK coordinate system [cm]

  • z – Z coordinate in SK coordinate system [cm]

inline void SetSaveTQFlagAs(bool b)

Choose whether to save residual TQ vectors (vSortedT_ToF, vSortedQ, vSortedPMTID) or not. Sets bSaveTQ.

Parameters

b – If true, NTagIO::restqTree is written to the output file filled with residual TQ vectors.

inline void ForceFlatMode(bool b)

Set true to force flat (MC-like flat event structure) mode for data files.

Parameters

b – If true, NTagIO::ReadFlatEvent will be called instead of NTagIO::ReadDataEvent.

inline void UseResidual(bool b)

Set false to not subtract ToF from each PMT hit times. Raw hit times will replace vUnsortedT_ToF.

Parameters

b – If false, neutron candidates will be searched for from raw hit times rather than residual.

inline void UseBONSAI(bool b)

Set false to not extract BONSAI-related variables. (by default true)

Parameters

b – If false, NTag will not use BONSAI to extract relevant variables.

inline void UseNeutFit(bool b)

Set false to not go through Neut-fit for all candidates, which sometimes takes ages to complete.

Especially useful when finding primary selection efficiency.

Parameters

b – If false, NTag will not use Neut-fit and therefore no related variables will be saved.

inline virtual void SetRefRunNo(int d)

Set reference run for dark noise, waterT, and Bad ch. it is needed for calibration and lowe data.

Public Members

NTagTMVA TMVATools

All input variables to TMVA are controlled by this class!

Protected Attributes

NTagMessage msg

NTag Message printer.

Verbosity fVerbosity

Verbosity.

int nProcessedEvents

of processed events

int preRawTrigTime[3]

Raw trigger time (skhead_.nt48sk)

std::vector<int> vCABIZ

A vector of PMT cable IDs of all recorded hits from an event. Forms a triplet with vTISKZ and vQISKZ.

std::vector<float> vTISKZ

A vector of hit times [ns] of all recorded hits from an event. Forms a triplet with vCABIZ and vQISKZ.

std::vector<float> vQISKZ

A vector of deposited charge [p.e.] of all recorded hits from an event. Forms a triplet with vCABIZ and vTISKZ.

std::vector<int> vISIGZ

A vector of signal flags (0: bkg, 1: sig) of all recorded hits from an event. If #fSigTQFile is not NULL, it is saved in NTagEventInfo::AppendRawHitInfo.

std::vector<float> *vSIGT

A vector to save signal hit times from #fSigTQTree temporarily. Not included in output.

std::vector<int> *vSIGI

A vector to save signal hit PMT IDs from #fSigTQTree temporarily. Not included in output.

std::array<float, MAXPM + 1> vPMTHitTime

An array to save hit times for each PMT. Used for RBN reduction.

std::vector<int> vSortedPMTID

A vector of PMT cable IDs corresponding to each hit sorted by ToF-subtracted hit time in ascending order. Forms a triplet with vSortedT_ToF and vSortedQ.

std::vector<float> vSortedT_ToF

A vector of ToF-subtracted hit times [ns] sorted in ascending order. Forms a triplet with vSortedPMTID and vSortedQ.

std::vector<float> vUnsortedT_ToF

A vector of unsorted ToF-subtracted hit times [ns], in the order as in vTISKZ.

std::vector<float> vSortedQ

A vector of deposited charge [p.e.] corresponding to each hit sorted by ToF-subtracted hit time in ascending order. Forms a triplet with vSortedT_ToF and vSortedPMTID.

std::vector<int> vSortedSigFlag

A vector of signal flags (0: bkg, 1: sig) corresponding to each hit in vSortedT_ToF.

std::vector<int> reverseIndex

Inverse map from indices of vSortedT_ToF to indices of vTISKZ.

bool bData

Set true for data events, false for MC events. Automatically determined by the run number at NTagIO::CheckMC.

bool bUseTMVA

Set true if using TMVA, otherwise false. Can be set to false from command line with option -noMVA.

bool bSaveTQ

Set true if saving the ToF-subtracted TQ vectors, otherwise false. Can be set to true from command line with option -saveTQ.

bool bForceFlat

Set true if forcing MC mode, otherwise false. Can be set to true from command line with option -forceFlat.

bool bUseResidual

Set false if not using ToF-subtracted hit times, otherwise false. Can be set to false from command line with option -noTOF.

bool bUseBONSAI

Set false if not extracting BONSAI-related variables, otherwise true. Can be set to false from command line with option -noBONSAI.

bool bUseNeutFit

Set false if not using Neut-fit and MVA, otherwise true. Can be set to false from command line with option -noFit.

bool candidateVariablesInitialized

A flag to check if iCandidateVarMap and fCandidateVarMap are initialized.

int runNo

Run # of an event.

int subrunNo

Subrun # of an event.

int eventNo

Event # of an event.

int nhitac

Number of OD hits within 1.3 us around the main trigger of an event.

int nqiskz

Number of all hits recorded in vTISKZ.

int trgType

Trigger type. MC: 0, SHE: 1, SHE+AFT: 2, Non-SHE: 3.

int refRunNo

Reference run #, it is needed for calibration and LOWE analysis.

float trgOffset

Trigger offset of an event. Default set to 1,000 [ns].

float tDiff

Time difference from the current event to the previous event. [ms].

float qismsk

Total p.e. deposited in ID within 1.3 us around the main trigger of an event.

float pvx

X position of a prompt-peak vertex (estimated neutron creation point).

float pvy

Y position of a prompt-peak vertex (estimated neutron creation point).

float pvz

Z position of a prompt-peak vertex (estimated neutron creation point).

float dWall

Distance from the prompt vertex to the tank wall.

float evis

Visible energy (the amount of energy if the peak was from an electron).

int apNRings

Number of rings found by APFit.

int apNMuE

Number of mu-e decays found by APFit.

int apNDecays

Number of decay electrons?

std::vector<int> vAPRingPID

Vector of PID corresponding to each ring found by APFit. [Size: apNRings].

std::vector<float> vAPMom

Vector of momentum corresponding to each ring found by APFit. [Size: apNRings]

std::vector<float> vAPMomE

Vector of e-like momentum corresponding to each ring found by APFit. [Size: apNRings]

std::vector<float> vAPMomMu

Vector of mu-like momentum corresponding to each ring found by APFit. [Size: apNRings]

int nCandidates

Number of total found neutron capture candidates.

int maxN200

Maximum N200 found in neutron capture candidates.

float maxN200Time

First hit time of the candidate with maximum N200.

float firstHitTime_ToF

The earliest hit time in an event, subtracted by the ToF from the prompt vertex.

std::vector<int> vFirstHitID

Vector of all indices of the earliest hit in each candidate. The indices are based off vSortedT_ToF.

std::vector<std::vector<float>> *vHitRawTimes

Vector of residual hit times. [Size: nCandidates].

std::vector<std::vector<float>> *vHitResTimes

Vector of residual hit times. [Size: nCandidates].

std::vector<std::vector<int>> *vHitCableIDs

Vector of hit cable IDs. [Size: nCandidates].

std::vector<std::vector<int>> *vHitSigFlags

Vector of signal flags. (0: bkg, 1: sig) [Size: nCandidates].

int nTotalHits

Number of total hits, including unrecorded hits.

int nTotalSigHits

Number of total signal hits, including unrecorded signal hits.

int nFoundSigHits

Number of registered signal hits.

int nRemovedHits

Number of removed hits due to RBN reduction.

int nTrueCaptures

Number of true neutron captures in MC.

std::vector<int> vNGamma

Vector of the total numbers of emitted gammas in true capture. [Size: nTrueCaptures]

std::vector<int> vCandidateID

Vector of matching capture candidate IDs. [Size: nTrueCaptures].

std::vector<float> vTrueCT

Vector of true capture times. [ns] [Size: nTrueCaptures].

std::vector<float> vCapVX

Vector of X coordinates of true capture vertices. [cm] [Size: nTrueCaptures]

std::vector<float> vCapVY

Vector of Y coordinates of true capture vertices. [cm] [Size: nTrueCaptures]

std::vector<float> vCapVZ

Vector of Z coordinates of true capture vertices. [cm] [Size: nTrueCaptures]

std::vector<float> vTotGammaE

Vector of the total emitted gamma energies. [MeV] [Size: nTrueCaptures].

int nSavedSec

Number of saved secondaries.

int nAllSec

Number of all secondaries in the input file.

std::vector<int> vSecPID

Vector of saved secondary PIDs. [Size: nSavedSec].

std::vector<int> vSecIntID

Vector of saved secondary interaction IDs. [Size: nSavedSec].

std::vector<int> vParentPID

Vector of saved parent PIDs. [Size: nSavedSec].

std::vector<int> vCapID

Vector of true capture indices that generates the secondary. -1 is pushed back if the secondary is not from a neutron capture. [Size: nSavedSec]

std::vector<float> vSecVX

Vector of X coordinates of secondary vertices. [cm] [Size: nSavedSec].

std::vector<float> vSecVY

Vector of Y coordinates of secondary vertices. [cm] [Size: nSavedSec].

std::vector<float> vSecVZ

Vector of Z coordinates of secondary vertices. [cm] [Size: nSavedSec].

std::vector<float> vSecPX

Vector of X-direction initial momenta of secondaries. [MeV/c] [Size: nSavedSec]

std::vector<float> vSecPY

Vector of Y-direction initial momenta of secondaries. [MeV/c] [Size: nSavedSec]

std::vector<float> vSecPZ

Vector of Z-direction initial momenta of secondaries. [MeV/c] [Size: nSavedSec]

std::vector<float> vSecDWall

Vector of distances from secondary vertices to the SK barrel. [cm] [Size: nSavedSec]

std::vector<float> vSecMom

Vector of initial momenta of secondaries. [MeV/c] [Size: nSavedSec].

std::vector<float> vSecT

Vector of secondary creation times. [ns] [Size: nSavedSec].

int nNInNeutVec

Number of neutrons in NEUT vectors.

int neutIntMode

NEUT interaction mode.

See also

: nemodsel.F of NEUT.

int nVecInNeut

Number of NEUT vectors.

float neutIntMom

NEUT interaction momentum.

std::vector<int> vNeutVecPID

Vector of NEUT vector PIDs. [Size: nVecInNeut].

int nVec

Number of primary vectors in MC.

float vecx

X coordinate of the primary vertex.

float vecy

Y coordinate of the primary vertex.

float vecz

Z coordinate of the primary vertex.

std::vector<int> vVecPID

Vector of primary vector PIDs. [Size: nVec].

std::vector<float> vVecPX

Vector of X-direction initial momenta of primary vectors. [MeV/c] [Size: nVec].

std::vector<float> vVecPY

Vector of Y-direction initial momenta of primary vectors. [MeV/c] [Size: nVec].

std::vector<float> vVecPZ

Vector of Z-direction initial momenta of primary vectors. [MeV/c] [Size: nVec].

std::vector<float> vVecMom

Vector of initial momenta of primary vectors. [MeV/c] [Size: nVec].

std::vector<NTagCandidate> vCandidates

A container for saved capture candidates.

IVecMap iCandidateVarMap

A map from feature variable name to vectors of integer feature variables of all saved candidates.

FVecMap fCandidateVarMap

A map from feature variable name to vectors of float feature variables of all saved candidates.

Private Members

float TWIDTH

Width of NHits. (By default it’s 10 ns.)

int NHITSTH

Lower limit for NHits.

int NHITSMX

Upper limit for NHits.

int N200MX

Upper limit for N200.

float T0TH

Lower limit for T0.

float T0MX

Upper limit for T0.

float TRBNWIDTH

The width of the dead time to apply to all PMTs to reduce RBN.

float TMATCHWINDOW

Width of the true-reconstructed capture time matching window. [ns]

float TMINPEAKSEP

Minimum candidate peak separation. [ns].

float ODHITMX

Threshold on the number of OD hits. Not used at the moment.

float VTXSRCRANGE

Vertex search range in NTagCandidate::MinimizeTRMS.

See also

NTagCandidate::SetDistanceCut

float MINGRIDWIDTH

Vertex search grid width in NTagCandidate::MinimizeTRMS.

float PVXRES

Prompt vertex resolution. (&Gamma of Breit-Wigner distribution) [cm].

float customvx

X coordinate of a custom prompt vertex.

float customvy

Y coordinate of a custom prompt vertex.

float customvz

Z coordinate of a custom prompt vertex.

VertexMode fVertexMode

#VertexMode of class NTagInfo and all inheriting classes.