MINOS Standard Reconstruction and RECOBASE Packages
[2](#minos-standard-reconstruction-and-recobase-packages)

Overview [2](#overview)

CandStrip [5](#candstrip)

Candidate Definition [5](#candidate-definition)

Algorithm [5](#algorithm)

Candidate Methods [5](#section-1)

Algorithm Parameters [7](#candstrip-algorithm-parameters)

CandSlice [8](#candslicesr)

Candidate Definition [8](#candidate-definition-1)

Algorithm [8](#algorithm-1)

Candidate Methods [9](#candslice-methods)

Algorithm Parameters [10](#candslice-algorithm-parameters)

CandCluster [11](#candclustersr)

Candidate Definition [11](#candidate-definition-2)

Algorithm [11](#algorithm-2)

Candidate Methods [11](#candcluster-methods)

Algorithm Parameters [13](#algorithm-parameters)

CandShower [14](#candshowersr)

Candidate Definition [14](#candidate-definition-3)

Algorithm [14](#algorithm-3)

Candidate Methods [14](#__RefHeading___Toc15212962)

Algorithm Parameters [15](#algorithm-parameters-1)

CandTrack [16](#candtracksr)

Candidate Definition [16](#candidate-definition-4)

Algorithm [16](#algorithm-4)

Candidate Methods [20](#candidate-methods)

Algorithm Parameters [21](#algorithm-parameters-2)

CandFitTrack [23](#candfittracksr)

Candidate Definition [23](#candidate-definition-5)

Algorithm [23](#algorithm-5)

Candidate Methods [23](#candidate-methods-1)

Algorithm Parameters [24](#algorithm-parameters-3)

CandEvent [25](#candeventsr)

Candidate Definition [25](#candidate-definition-6)

Algorithm [25](#algorithm-6)

Candidate Methods [27](#candidate-methods-2)

Algorithm Parameters [29](#algorithm-parameters-4)

Output Ntuple Definitions [30](#__RefHeading___Toc15212979)

# 

# MINOS Standard Reconstruction and RecoBase Packages

## Overview

> As described in the offline framework documentation, each stage of
> reconstruction produces a set of 'candidate' objects of a certain type
> (shower, track, etc). A candidate has an associated set of 'Set/Get'
> methods which are used to pass to the user anything that one could
> possibly want to know about this object. The general sequence of
> reconstruction steps, and the corresponding candidates which are
> generated, is shown in Figure 1.
>
> The RecoBase package provides a set of candidate-related classes
> intended to serve as base classes from which the corresponding classes
> in alternative reconstruction software can (and should) inherit. This
> allows analysis code to access alternative reconstruction packages
> through a common interface. The 'SR' (Standard Reconstruction)
> reconstruction package provides a set of standard reconstruction
> algorithms and job modules, and uses the RecoBase candidate classes.
>
> In general, the actual reconstruction algorithms are found in the
> AlgxxxSR and AlgxxxSRList RunAlg methods. The AlgxxxSR::RunAlg method
> builds a candidate after it has been identified in
> AlgxxxSRList::RunAlg. The candidate member variables are held in the
> Candxxx classes in RecoBase. In rare cases, such as CandTrackSR, there
> are candidate classes specific to the standard reconstruction code
> which inherit from the candidate base class. Currently, the Get/Set
> methods associated with the candidate are found in CandxxxHandle. This
> is expected to change in the near future, and these methods will move
> to the candidate classes.

![](media/image1.png){width="3.283333333333333in"
height="3.0145833333333334in"}

Figure 1 lists the primary candidate objects generated by the
reconstruction code. These are:

1.  **CandStrip**: A group of CandDigit objects on the same strip. On
    the far detector, this would correspond to CandDigits from the two
    strip ends. On the near detector, CandStrips contain all
    digitizations in a given 'Snarl' which satisfy time adjacency
    requirements (see offline framework documention for the definition
    of a snarl).

2.  **CandSlice**: Provisional event blocking of CandStrips based on
    time produces CandSlices. In the far detector, there is typically 1
    CandSlice per snarl, while for near detector data a snarl may be
    subdivided into an arbitrary number of CandSlices.

3.  **CandCluster:** CandStrips which are spatially adjacent (according
    to an algorithm described below) are combined to form CandClusters.
    CandClusters are 2d objects.

4.  **CandShower:** The 2d CandCusters are merged to form 3d CandShowers
    based on time/space adjacency.

5.  **CandTrack:** The SR package contains a track finder which combines
    CandStrips to form CandTracks. There are both 2d and 3d versions of
    CandTracks, as described below.

6.  **CandFitTrack:** The track fitter operates on CandTrack objects and
    produces CandFitTrack objects, which include the results of the
    track fitting algorithm.

7.  **CandEvent:** A CandEvent object contains lists of all CandTracks
    and CandShowers which have been reconstructed for a given CandSlice.

## CandStrip

### Candidate Definition

A CandStrip contains all CandDigits belonging to a given strip. Strip
end matching is performed for far detector analysis after the
demultiplexer has determined the best of the possible strip end
alternatives. For the near detector, CandDigits for a given strip in a
snarl are combined to form a CandStrip based on timing.

### Algorithm 

####### Far Detector

Construction of a CandStripList begins in AlgStripList::RunAlgFar. To be
included in a CandStrip, the charge in a given digitization must be
larger than *AdjPixelChargeFraction* of the total charge in this pixel
plus the charge in the 4 nearest neighbor occurring within
*MaxXtalkTimeWindow* in time. This ensures that cross talk hits are not
included in CandStrips. CandDigits are sorted by plane and strip, which
ensures that CandDigits that will be associated into CandStrips occupy
adjacent entries in this sorted list. One pass is made through the
sorted list, checking for identical strip/plane values in adjacent
entries. If this occurs, and the CandDigit is not identified as
cross-talk according to the definition above, the CandDigits are added
to the CandStrip

######## Near Detector

CandDigits are sorted by plane, strip, and time, which ensures that
CandDigits which will be associated into CandStrips occupy adjacent
entries in this sorted list, and that the CandDigit with the earliest
time in a given strip and plane will appear first. One pass is made
through the sorted list, checking for identical strip/plane values in
adjacent entries, requiring that the conditions defining a cross-talk
digitization are not met (see above), and checking that the time is
within the tolerances set by the variables *MaxLocTimeSep* and
*MaxGloTimeSep*. The first variable is used to check that no large time
gaps occur within a CandStrip, and the second is used to ensure that the
total duration of a CandStrip is sensible. If these conditions are met,
the CandDigit is added to the CandStrip. When one of the time separation
requirements is violated, a CandStrip is constructed using the digit
list, and a new digit list is started. This continues until the full
digit list has been completely examined.

######## 

######## Mixed

CandDigits are sorted by plane and strip, and nested passes are made
through the sorted CanddDigit list. The initial stage of the outer loop
constructs an array of CandDigits for a given strip Id. The inner loop
is then made over this list of digits, which is sorted by time. Then, as
in the near detector algorithm, we check that adjacent entries are
within the tolerances set by the variables *MaxLocTimeSep* and
*MaxGloTimeSep*. The first variable is used to check that no large time
gaps occur within a CandStrip, and the second is used to ensure that the
total duration of a CandStrip is sensible. If the CandDigit satisfies
timing requirements it is added to the CandStrip daughter list. When one
of the time separation requirements is violated, a CandStrip is
constructed with the previous digits, and a new daughter list is
started. This continues until the digit list has been completely
examined. The outer loop then proceeds to make a digit list for the next
seid, continuing until the full CandDigitList has been examined

In AlgStrip::RunAlg, the 'Set' functions are called to load the
CandStrip member variables based on the CandDigit members, and the
daughter list is file.

### 

### CandStrip methods

SetPlaneView(PlaneView::PlaneView_t)

PlaneView::PlaneView_t GetPlaneView()

> The plane view of this strip. Possible values are PlaneView::kX, kY,
> kU, kV, kA (Caldet muon trigger strips running perpendicular to the
> beam), and kB (Caldet muon trigger strip running parallel to the
> beam).

SetZPos(Double_t)

Double_t GetZPos()

> The Z position of the strip, in meters. The Z coordinate runs along
> the beam direction.

SetStripEndId(PlexStripEndId\*)

PlexStripEndId GetStripEndId(StripEnd::StripEnd_t = StripEnd::kWhole)

> Sets the strip end IDs or gets the id for the desired end.

SetTPos(Double_t)

Double_t GetTPos()

> The transverse position of the strip, in meters. This is the U
> position of a strip running along the V direction, etc.

Int_t GetPlane()

Int_t GetStrip()

Double_t GetBegTime(StripEnd::StripEnd_t = StripEnd::kWhole)

Double_t GetEndTime(StripEnd::StripEnd_t = StripEnd::kWhole)

> For the far detector, BegTime and EndTime take the same value, and are
> the CandDigit times for each of the two strip ends, calibrated
> according to the value of caltimetype (see below). For the near
> detector, these quantities represent the earliest and latest times in
> a CandStrip. Units are nanoseconds.

Double_t GetCharge()

Double_t GetCharge(StripEnd::StripEnd_t)

Double_t GetCharge(CalDigitType::CalDigitType_t)

Double_t GetCharge(StripEnd::StripEnd_t,CalDigitType::CalDigitType_t)

Double_t GetCharge(CalDigitType::CalDigitType_t,StripEnd::StripEnd_t)

> ChargeNone refers to raw ADC counts. SigLin is ADC counts, corrected
> for 'drift point' and non-linearity. SigCorr is ADC counts corrected
> for drift point, non-linearity, and strip to strip normalization. In
> the GetCharge calls, the value of CalDigitType determines which of
> these quantities is returned. Possible values of the parameter are
> CalDigitType::kNone, kSigLin, kSigCorr, and kPE. The StripEnd
> parameter determines which of the two strip ends are returned.
> Possible values are StripEnd::kUnknown, kNegative, kPositive, kEast,
> kWest, kUp, kDown, kWhole. In the case of kWhole, the summed charge
> over the strip ends is returned. The default returns raw ADC counts.
> It is planned to change this in the future to return PEs as the
> default.

Int_t GetNDigit(StripEnd::StripEnd_t)

> The number of digits in the CandStrip, for the appropriate strip end.
> If the parameter passed in the Get function is kWhole, the total digit
> count is returned.

Double_t GetCorrBegTime()

> CorrBegTime is the time corrected for the ToF of the particle through
> the detector.

### 

Ushort_t GetDemuxVetoFlag(StripEnd::StripEnd_t)

The Demux Veto flag can be used to determine if the demuxer was unable
to demultiplex

one or more of the CandDigits in this strip.

### CandStrip Algorithm Parameters

+---------------+-------+---------------------------------------------+
| **            | ***   | ***Description***                           |
| *Parameter*** | Defau |                                             |
|               | lt*** |                                             |
+---------------+-------+---------------------------------------------+
| MaxLocTimeSep | 60 ns | max time separation between two neighboring |
|               |       | digits in same strip.                       |
+---------------+-------+---------------------------------------------+
| MaxGloTimeSep | 120   | max time separation between any two digits  |
|               | ns    | in same strip                               |
+---------------+-------+---------------------------------------------+
| caltimetype   | T0s   | Determines whether timing calibrations are  |
|               | ap    | applied                                     |
|               | plied |                                             |
|               |       | kT0 = offsets applied                       |
|               |       |                                             |
|               |       | kNone = raw times used                      |
+---------------+-------+---------------------------------------------+
| MaxXt         | 40 ns | Time window within which charge can be      |
| alkTimeWindow |       | considered xtalk                            |
+---------------+-------+---------------------------------------------+
| AdjPixelC     | 0.1   | Min charge/(charge+neighbor pixel charge) - |
| hargeFraction |       | defines xtalk                               |
+---------------+-------+---------------------------------------------+
|               |       |                                             |
+---------------+-------+---------------------------------------------+
| BegP          |       | Used to restrict plane interval in which    |
| lane/EndPlane |       | CandStrips are constructed                  |
+---------------+-------+---------------------------------------------+

###  

### 

## CandSliceSR

### Candidate Definition

A CandSlice consists of a list of CandStrip objects corresponding to one
physics event. In far detector, the raw data record (snarl) and
CandSlice contain the same digitizations. In near detector, a fast
clustering algorithm, based primarily on time, is used to separate
snarls into separate CandSlices. It should be noted that the same
CandStrip may belong to more than one CandSlice.

### Algorithm

Candstrips in the upstream (non-spectrometer) planes are treated first.
For these planes the Candstrips are sorted by ToF-corrected time,
keeping only strips which return GetCharge()\>*MinCharge*. CandStrips
meeting this requirement are placed in a list, and the time of the new
CandStrip is checked against that of the previous last entry. If this
time difference is greater than *MaxTimeGap*, and the number of
CandStrips is greater than *MinStrip*, the CandStrips in the list are
assumed to constitute a CandSlice, and a CandSlice is constructed from
these members. If this time difference is less than *MaxTimeGap*, but
the total list time duration is greater than *TimeWindow*, we assume
that we have missed the true start of this CandSlice. In this case, we
first check to see if, by removing the first entry on the list, and
adding the new entry, we end up with a shorter time duration in the
list. If so, we perform this operation, adding the new CandStrip, and
dropping the earliest from the list. If, on the other hand, performing
this operation would result in a longer time duration, we use the list
without the new entry to create a new CandSlice, and start a new list
with the orphan CandStrip. After looping over all upstream CandStrips,
we take the list contents remaining, and construct a CandSlice, if the
list has at least MinStrip members.

In the next phase, we pick up CandStrips in the spectrometer. To do
this, we iterate over CandSlices constructed in the previous stage, and
determine which remaining CandStrips should be added. For each
CandSlice, a time interval bounded by the CandSlice start time minus
*EarlyTimeDiff* and the CandSlice start time plus *TimeDiffSpect* is
defined, and a list of all spectrometer CandStrips with times inside
this interval is constructed. This list of CandStrips is now looped
over. If the CandStrip is in the spectrometer, then this CandStrip is
added to the current CandSlice.

Next, the CandSlice list is iterated over again, this time to pick up
the CandStrips with charge \< *MinCharge*. For each CandSlice, a time
interval bounded by the CandSlice start time and the CandSlice start
time plus *TimeWindow* is defined, and a list of all CandStrips with
times inside this interval is constructed. If the pulse height is less
than *MinCharge* and the CandStrip is not in the spectrometer, the
CandStrip is added to the CandSlice.

**Far Detector**

In the far detector, all CandStrips in a given snarl are combined into a
single CandSlice. No selections on CandStrips are made.

### CandSlice Methods 

GetNStrip(PlaneView::PlaneView_t=kUnknown)

> Returns the number of strips in a CandSlice.

GetBegPlane(PlaneView::PlaneView_t=kUnknown)

GetEndPlane(PlaneView::PlaneView_t=kUnknown)

> Returns the most upstream and downstream planes in a CandSlice.

GetCharge(CalDigitType::CalDigitType_t=kPE)

> Total charge in the CandSlice.

GetBegTime()

GetEndTime()

> CorrBegTime and CorrEndTime are the earliest and latest times (in
> nanoseconds) in a CandSlice.

GetCorrBegTime()

GetCorrEndTime()

> CorrBegTime and CorrEndTime are the earliest and latest times (in
> nanoseconds) in a CandSlice, corrected for the ToF of the particle to
> the location of the earliest and latest CandStrip hits in the
> CandSlice.

### 

### 

###  

### CandSlice Algorithm Parameters

+-----------------+-------+-------------------------------------------+
| ***Parameter*** | ***   | ***Description***                         |
|                 | Defau |                                           |
|                 | lt*** |                                           |
+-----------------+-------+-------------------------------------------+
| TimeWindow      | 150   | Assumed maximum nominal duration of a     |
|                 | ns    | CandSlice.                                |
+-----------------+-------+-------------------------------------------+
| MaxTimeGap      | 40 ns | Largest allowable time gap within a       |
|                 |       | CandSlice.                                |
|                 |       |                                           |
|                 |       | .                                         |
+-----------------+-------+-------------------------------------------+
| MinStrip        | 10    | The minimum number of strips in a         |
|                 |       | CandSlice. A CandSlice is required to     |
|                 |       | have MinStrip/2 strips per view.          |
+-----------------+-------+-------------------------------------------+
| MinCharge       | 2\.   | Charge cut applied in the initial stage   |
|                 |       | of CandSlice construction.                |
+-----------------+-------+-------------------------------------------+
| EarlyTimeDiff   | 30 ns | Time prior to CandSlice start allowed for |
|                 |       | spectrometer CandStrip addition to        |
|                 |       | CandSlice.                                |
+-----------------+-------+-------------------------------------------+
| TimeDiff        | 60 ns | Time after CandSlice start time allowed   |
|                 |       | for non-spectrometer CandStrip addition   |
|                 |       | to CandSlice.                             |
+-----------------+-------+-------------------------------------------+
| TimeDiffSpect   | 60 ns | Time after CandSlice start time allowed   |
|                 |       | for spectrometer CandStrip addition to    |
|                 |       | CandSlice.                                |
+-----------------+-------+-------------------------------------------+
| PlaneDiff       | 4     | Minimum number of planes separating       |
|                 |       | CandStrips from two CandSlices which will |
|                 |       | contribute to SliceMatchFrac merger       |
|                 |       | requirement.                              |
+-----------------+-------+-------------------------------------------+
| TPosDiff        | 20 cm | Minimum transverse position separating    |
|                 |       | CandStrips from two CandSlices which will |
|                 |       | contribute to SliceMatchFrac merger       |
|                 |       | requirement.                              |
+-----------------+-------+-------------------------------------------+

## CandClusterSR

### Candidate Definition

CandClusters consist of CandStrips which are spatially adjacent (see
algorithm) CandClusters are 2D objects. These are combined in a
subsequent reconstruction step to form 3D shower objects (CandShowers)

### Algorithm

The first action taken in AlgClusterSRList::RunAlg is construct a
neighbor map, which holds for each CandStrip in the CandSlice the number
of neighbor CandStrips, defined to be the number of CandStrips on the
same plane having times within *StripNeighborTimeDiff*, and which lie
within *StripNeighborStripDiff* strips. Having determined the number of
neighbors for each CandStrip, we loop over views. For each view, the
following clustering algorithm is applied to all non-spectrometer planes
(or all planes in the far detector). We first iterate over all
CandStrips in the view satisfying this plane cut. For each CandStrip, we
iterate over previously constructed CandClusters, determining whether
the strip should be added to an existing cluster. For each CandCluster,
we select CandStrips which lie within +/- *StripNeighborPlaneDiff* of
the primary CandStrip. In the far detector, this interval is extended by
*SMPlaneFirst-SMPlaneLast*-1 (3) planes on the low plane side if the
CandStrip plane is *StripNeighborPlaneDiff* or more lower than the first
plane in SM2 (SMPlaneFirst) or by the same number of planes on the high
plane side if the CandStrip plane is *StripNeighborPlaneDiff* or more
higher than the last plane in SM1 (SMPlaneLast). We now iterate over
this CandStrip set within the CandCluster. If a CandStrip in this set
lies in the same plane as the primary CandStrip, we compare the timing
and strip different. If a CandStrip in this set lies in a different
plane from the primary CandStrip, we use these criteria, and in addition
require that the CandStrip lie within a transverse distance of
*StripNeighborTPosDiffShower* if the primary CandStrip was found to have
neighbors in the initial step, or within *StripNeighborTPosDiffTrack* if
the CandStrip was found to be isolated. If these criteria are met for
any CandStrip in the selected set, the primary CandStrip is added to
this CandCluster. If a match is found for multiple CandClusters, these
clusters are merged. If, after iterating over existing CandClusters, no
match is found, a new CandCluster is created with a single daughter --
the primary CandStrip. If the primary CandStrip has strip neighbors, the
new CandCluster is labeled 'showerlike'. If not, it is labeled
'tracklike'.

### CandCluster Methods 

###### 

IsShowerLike()

IsTrackLike()

IsShowerLike(Bool_t)

IsTrackLike(Bool_t)

> Set or gets the tracklike or showerlike attribute of a CandCluster, as
> defined in the algorithm section above.

GetNStrip()

> Returns the number of strips in a CandCluster.

GetBegPlane()

GetEndPlane()

> Returns the most upstream and downstream planes in a CandCluster.

GetCharge()

> Total charge in the CandCluster. The default form of
> CandStrip::GetCharge() is used, implying that at present, this returns
> summed PEs.

GetBegTime()

GetEndTime()

> CorrBegTime and CorrEndTime are the earliest and latest times in a
> CandCluster.

GetNPlane()

> Returns the number of planes in the CandCluster.

GetTPos()

> Mean transverse position of CandCluster.

GetPlaneView()

> The plane view of this CandCluster. Possible values are PlaneView::kX,
> kY, kU, kV, kA (Caldet muon trigger strips running perpendicular to
> the beam), and kB (Caldet muon trigger strip running parallel to the
> beam).

### Algorithm Parameters

  ----------------------------- --------------- ------------------------------------------
  ***Parameter***               ***Default***   ***Description***

  StripNeighborTimeDiff         60 ns           Time difference allowed between strips on
                                                a given plane.

  StripNeighborStripDiff        3               Strip separation allowed between strips on
                                                a given plane.

  SMPlaneLast                   248             Last plane of SM1

  SMPlaneFirst                  250             First plane of SM2

  MinPulseHeight                2               Minimum cluster pulse height. (Pes)

  MinPlaneCoverageShower        1               Minimum number of planes spanned by a
                                                cluster.

  MinPlaneNeighbor              1               Minimum number of neighbors in a plane.

                                                

  MinPlaneCoverageTrack         8               Minimum number of planes spanned.

  StripNeighborPlaneDiff        4               Plane separation allowed in strip
                                                neighbors.

  StripNeighborTPosDiffShower   20 cm           Transverse separation allowed in strip
                                                neighbors.

  StripNeighborTPosDiffTrack    20 cm           Transverse separation allowed in strip
                                                neighbors.
  ----------------------------- --------------- ------------------------------------------

## CandShowerSR

### Candidate Definition

3D reconstructed showers. CandShowerSR inherits from virtual class
CandReco, and contains pointers to CandCluster objects. More than one
may exist per CandSlice, and CandStrip daughters are not necessarily
exclusive.

### Algorithm

We begin with a nested loop over all CandSlices, and over all
CandClusters within each CandSlice, generating list of all clusters in
the U and V planes.

Next, we execute a nested loop over U-view and V-view CandClusters,
checking for matching 2D clusters. The following criteria are used:

-   Beginning planes for the two 2D 'long' CandClusters (defined by
    *PlaneScale*) must be within *DiffViewPlaneMatch,* or
    *DiffViewPlaneMatchShort* if one or more clusters is short.

-   Beginning times for the two 2D CandClusters must be within
    *DiffViewTimeMatch*.

-   The fractional overlap of U and V clusters must exceed
    *DiffViewPlaneCoverage*, if both clusters are long.

-   The total pulse heights of the U and V clusters must agree to within
    *DiffViewPulseHeightCut* if at least one of the clusters is long.
    (Note: This should probably be changed to a charge ratio)

If a U/V cluster set is found which satisfies these requirements, a
second loop over U clusters is performed, searching for alternative U/V
pairs involving the original V cluster satisfying the requirements
above, but higher in total energy. If no better alternative is found a
CandShower is constructed. In this way, a given CandCluster will only be
used once, in the shower with the highest total energy.

Within AlgShowerSR::RunAlg, the vertex location and shower direction is
determined. First, the most upstream U and V planes are found. Next, a
loop over all shower clusters is used to obtain the total shower charge.
The charge-weighted U/V positions of the CandClusters in the plane
interval from the most upstream planes to VtxPlaneSpan planes downstream
is identified as the shower vertex location. To obtain the shower
direction, a linear fit is performed to the charge-weighted transverse
position in a given plane vs the Z position of that plane. A weighted
linear fit is performed in each viewed, weighted by the total cluster
charge for this shower in a given plane. The du/dz and dv/dz slopes
obtained in these fits are then used to obtain the direction cosines of
the shower axis. Finally, the shower energy
i[]{#__RefHeading___Toc15212962 .anchor}s set.

CandShower Methods

CandClusterHandle \* GetUCluster(Int_t)

CandClusterHandle \* GetVCluster(Int_t)

void AddCluster(CandClusterHandle \*)

> Adds a CandCluster to the CandShower daughter list, first checking
> that this cluster not already a member of the list.

CandClusterHandle \* GetCluster(Int_t)

> Returns the 'i'th cluster in the CandShower daughter list. If the
> entry requested is greater than the list size, the function returns
> null.

Int_t GetLastCluster()

> Returns the last cluster in the CandShower daughter list.

Double_t GetEnergy()

void SetEnergy(Double_t)

> Set/gets the total shower energy.

### Algorithm Parameters

  ------------------------- --------------- -----------------------------------------
  ***Parameter***           ***Default***   ***Description***

  MIPperGeV                 14.8            

  DiffViewPlaneMatch        6               Allowable difference in U/V cluster begin
                                            plane

  DiffViewPlaneMatchShort   3               Allowable difference in U/V cluster
                                            beginning for short clusters

  MinAvgPulseHeight         800\.           

  PlaneScale                5               Defines short vs long clusters

  MinAvgNStrip              2               Min. \# strips for showerlike cluster
                                            (unused)

  MinPlane                  1               Minimum \# planes for showerlike cluster
                                            (unused)

  DiffViewPlaneCoverage     0.5             Minimum allowable fractional plane
                                            overlap of U/C clusters

  DiffViewTimeMatch         30 ns           Max. start time difference of U/V
                                            clusters

  VtxPlaneSpan              5               Use strips with plane \# at most this
                                            many away from beginning plane in view
  ------------------------- --------------- -----------------------------------------

## CandTrackSR

### Candidate Definition

3D reconstructed tracks. CandTracks inherit from the virtual class
CandReco. More than one CandTrack may exist per CandSlice. The CandStrip
daughters of a pair of CandTracks are not necessarily exclusive - tracks
can share strips.

### Algorithm

Track processing begins in AlgTrackSRList::RunAlg with a loop over
CandSlices. For each CandSlice, we start by determining the number of
digitzations in each view/side, and construct a list of CandStrips with
pulseheights greater than MinStripPulseHeight for each view. Next, for
each view we perform a Hough transform. This preliminary track finding
step is used to determine the sign of dZ/dtime, the rough track
multiplicity, and to obtain a linear fit to Z vs transverse position
that can be used in the more refined track finder used in subsequent
steps.

Using the result of the Hough track finder, we loop over CandStrips and
calculate the transverse (U/V) position and the transit time, correcting
for T0s, propagation time of the light down the strip (using the hough
track fit to determine the position along the strip.), etc. A linear fit
to Z position vs time is then performed. Each entry with residuals \> 20
ns are then removed from the fit arrays, and refits are done until no
hits are removed, or there are fewer than 5 hits left. We then perform a
Z vs time fit for the combined U and V views, using the hit points
surviving the prior step. We now know the sign of dZ/dtime, which can be
used to find tracks consistently from the direction of track head to
track tail.

We now find track clusters, starting with the construction of an array
containing the number of hits per plane. The minimum track size is then
defined as the larger of Trk2DNSeed, and Trk2DNSeedFrac time the number
of planes with hits. CandStrips are sorted by plane, strip, and time. We
loop over non-spectrometer CandStrips from earliest to latest, as
determined by directionality. If the plane of a given CandStrip is the
same as that of the last cluster formed, and this strip is within
ClsNSkip+1 strips, this CandStrip is added to this cluster. Otherwise,
this CandStrip forms the start of a new track cluster. We then iterate
over this track cluster list, and remove track clusters with more than
MaxNStrip CandStrip members, or with a total charge less than
MinClusterPulseheight

We now proceed to form 2D tracks. This is an iterative process, with
track seed hits found from the track cluster list, tracks formed
starting with these seeds, overlapping tracks and bad tracks removed,
and track clusters in good tracks removed from the track cluster list.
This process is repeated until either the track cluster list is empty,
or we satisfy conditions for terminating the 2D track finding process,
defined below.

The first track finding step is the identification of track seed hits.
We perform a nested loop over track clusters, with the inner loop being
over clusters earlier in the list than the outer loop. If the two
clusters are in the same view, their planes are within Trk2DplnEnd, and
their time difference is greater than Trk2DHitNTime and less than
Trk2DhitTime, we check agreement between their transverse positions.
Using the Hough fit parameters, we extrapolate one transverse position
to the other, and require that these agree to within Trk2Dwin0 times the
difference in Z positions.

If all of these conditions exists we assume that these track clusters
will eventually lie on the same track, and the later of the two is not
an appropriate track seed. If no match is found over the inner track
cluster loop, the track cluster in the outer loop would appear to be a
good track seed, if the number of CandStrips in the seed is less than
SingleHitDef. In this case a track with this single entry is added to
the track list. After the track seed step is complete, and if IsCosmics
is true, we perform a nested loop over tracks in the track list. If any
two track seeds are on the same plane, we keep only the one with the
largest charge.

We now proceed to add track clusters to tracks in the track list. We
loop over planes with hits. For a given plane, we construct a list of
the clusters within this plane (the plane cluster list). We now loop
over all tracks which were seeded on this track finding iteration. For
each of these new tracks, we use the last cluster added and compare it
with each of the clusters in the plane cluster list. For each, we
require that the plane cluster be within Trk2DNSkip planes (adding 3
toTrk2DNSkip if the gap spans the SM1-2 boundary), and either that the
number of current track hits be greater than Trk2DNContiguous or that
the plane cluster be with 2 planes ( adding 3 for the SM1-2 gap if
applicable).

We now perform a fit to Z vs transverse position using the last track
points, and extrapolating to the plane cluster. If the track length is
less than Trk2DHough0 the full track is used in the fit, and we set the
maximum allowable residual to Trk2DLinA0+Trk2DLinB0\*∆z. Otherwise, we
set the number of fit points to Trk2DNHough, and the maximum allowable
residual to LinA+LinB\*∆z.

If the track length is greater than one cluster, we load the fit arrays
with the Z and transverse positions of the last 'nfit' track clusters.
Each fit point is assigned a weight given by the CandStrip charge/700
time 12.0 divided by the square of the track cluster transverse width. A
linear fit is then performed, and the result extrapolated to the plane
cluster under consideration. To include the effect of the plane cluster
width on the maximum allowable residual, we add to the maximum residual
described earlier Trk2DsigmaA times the plane cluster transverse width
divided by the square root of 12.

If the track contains only one member, we use the Hough track fit to
extrapolate to the cluster position. Extrapolating to the plane cluster,
we add to the maximum residual described earlier Trk2DsigmaA times the
plane cluster transverse width divided by the square root of 12.

Next, we require that either the track length is greater than
MinSingleHit or that the number of strips in the plane cluster is less
than SingleHitDef, that the difference between the extrapolated track
time and plane cluster time be less than Trk2DHitNTime and less than
Trk2DhitTime. Finally, we require that the residual obtained in
extrapolating the fit to the plane cluster be less than the maximum
allowable residual. In this case, we consider this plane cluster to be a
potential member of this track.

After iterating over all tracks, we add this cluster to the track with
the best match, and proceed to the next plane cluster. After exhausting
the plane cluster list, we move to the next plane with hits, and repeat
the process above until all planes with hits are examined. This
completes the 2D track finding process for this iteration.

We now remove tracks with various pathological problems, starting with
tracks which are missinga large number of hits. We compare the number of
hits in a track to the difference between start and ending planes. If
this hit fraction is less than Trk2DhitFraction the track is removed.
Next, tracks shorter than the minimum allowed 2d track are removed. The
number of hits in the track must than the larger of Trk2DNSeed and
Trk2DNSeedFrac times the track length, or the track is removed and
placed on a bad track list. Single hit tracks are removed in all cases.
The linearity of remaining short tracks with a number of hits less than
or equal to Trk2dNHough and which were created on this track building
iteration. An unweighted linear fit between Z and transverse positions
is performed, and the hit with the worst residual is found. If the
residual is larger than Trk2DmaxResid, the track is removed from the
track list, and added to the bad track list. At this point, all clusters
on the remaining tracks, and clusters on tracks which have been set to '
not iterate' are removed from the track cluster list.

Next, we investigate whether removing clusters from the head or tail of
a bad track will improve it. In this case, the cluster is removed from
the cluster list, so that the same bad track is not built in the next
iteration. If a Hough solution exists for this view, we calculate the
residual of the first and last clusters in the track in a fit,
calculating the expected transverse position for the cluster's Z
position, and the Hough fit parameters. The cluster with the worst
residual is removed from the cluster list.

We now determine whether a track is contained as a subset of another
track. The shorter track is removed. If there is a complete overlap, the
shorter track is removed in all cases. If there is partial overlap, we
determine whether one of the two tracks should be removed. If the number
of unmatched clusters in track 2 is less than Trk2DsubsetNHit, and the
track 2 is smaller than track 1 by more than Trk2DsubsetDHit clusters,
we remove track 2. If the match fraction, defined as the ratio of the
number of matching clusters and the number of track clusters, is greater
than Trk2DTwinMatchFraction we remove the track in the pair with the
largest reduced chi^2^.

We now determine whether the track building iterations should terminate.
If IsCosmic is true, we determine whether any of the tracks span the
snarl from the lowest to highest plane. If this is true, we terminate
iterations. Otherwise, we terminate when the track cluster list is
empty. If this is not the case, we advance the iteration counter, and
return to the track seed hit building step with our new, more
restricted, track cluster list and a refined track list.

After 2D track building has terminated, we build 3D tracks. We perform a
nested loop over tracks, requiring 1 U track and 1 V track. We now
determine whether these tracks can be combined into a 3D track. The two
track's start times are required to be within DiffViewTimeMatch, the
beginning planes must match to within DiffViewBegPlaneMatch, and the
ending planes must match to within DiffViewEndPlaneMatch. We also
require that the tracks overlap by a number of planes given by the
length of the shortest of the two times DiffViewPlaneOverlap. If these
conditions are met, a CandTrack is constructed from the two 2D tracks.

One final check of track overlap is performed on the list of 3D
CandTracks. A nested loop over CandTracks is performed, and pairwise
comparisons of the CandTracks are done. If the fraction of common strips
to total strips is larger than Track3DTwinFrac for either track we flag
the track with the lowest 'score' for removal. The track score is
currently defined as the sum of the number of slices in the track and
the total charge/700.

The remaining CandTracks are sorted by length -- the largest
Trk3DTrackMax are kept, the rest being removed from the list.

In AlgTrackSR::RunAlg, tracks which have been found using the procedure
described above are analyzed to determine their essential attributes
(direction, etc), and to load the CandTrack daughter list with
CandStrips associated with the track. We start be identifying
CandClusters on the track which are 'track-like'. For each cluster, the
local angle to the Z axis (the normal to the strip surface) is used to
determine the expected number of strips tranversed in that plane, given
by the larger of 1 and dz/ds /4.0. If the actual number of strip hits in
this plane does not exceed this value, the 'InShower' attribute of each
CandStrip in this cluster is set to zero, and all CandStrips in this
cluster are added to the CandTrack daughter list. If, on the other hand,
the cluster is wider than expected by the track inclination, we
determine the most likely subset of the cluster the particle passed
through. We start by finding the nearest upstream and nearest downstream
'tracklike' clusters, and using the locations of these clusters to
define a local track slope, and from this, an estimate of the track
centroid in the CandCluster determined to be shower-like. Defining the
expected number of tranversed strips in this cluster as described above,
we examine each possible set of adjacent strips of this extent in the
cluster. For each strip set, we calculate the average distance of each
strip in this set to the local track centroid, and add to this the
average distance of each strip in the set to the previously determine
cluster centroid. In this case that IsCosmic is true, we take the strip
set which has the minimum value for this distance-to-centroid estimator
as the track CandStrip daughters for this cluster. If IsCosmic is false,
the strip set with the largest summed pulse height is used. The InShower
attribute of each of the strips added to the CandTrack daughter list is
set to the number of strips in this cluster with a signal greater than 1
PE. (Actually, strips with charge\>105 counts at this time)

Next, we determine the pathlength between adjacent clusters in the
track, and from this, the total pathlength and range-based momentum. The
sign of dt/dz determined in AlgTrackSRList::RunAlg is used to determine
the track head and tail. The U and V view 2D track extremes are used to
define the 3D track beginning and end planes. If dt/dz\>0, the track
beginning plane is given by the smaller of the two 2D track beginning
planes, and the end plane by the larger of the two 2D track end planes.
. If dt/dz\<0, the track beginning plane is given by the larger of the
two 2D track beginning planes, and the end plane by the smaller of the
two 2D track end planes. (ie, the 3D track is made a long as possible)
We now iterate over planes from the track head to the track tail,
calculating the difference in position between track centroid locations
in adjacent planes, maintaining a running sum of total path length to
this plane. Taking the energy loss per plane (for a normally incident
particle) as 40 MeV/c, we set the integrated energy loss from the track
head to each track CandStrip daughter through calls to SetMomentum in
this loop.

We now proceed to refined determination of dt/dz. We start by
constructing arrays of CandDigit Z positions vs time for each view and
side, where time is corrected for propagation delays in the clear and
wls fiber, and for timewalk. Each fit point is weighted by a
charge-dependent factor which accounts both for the increase in time
resolution with signal, and the degradation is time resolution for very
large amplitudes due to the transverse width of showers. The weighting
factor takes a minimum value at approximately 10 photoelectrons. If the
InShower value (see above) for this digit is greater than 5 (there are 5
more CandStrips in the cluster than expected) the weight of this digit
is set to zero. Following this loop over track CandDigits, the
SetNTrackStrip method is called, passing the total number of strips in
this track which are members of CandClusters with no more than 1 extra
strip.

The track time vs position fitting now proceeds, with separate fits for
each view/side and assumed track direction (sign of dt/dz) in the case
in which CalTimeType =kRaw, and with all view/sides combined when
CalTimeType=kT0. (differences in offsets between views and sides makes
it inappropriate to combine views if T0s are not subtracted). The next
step in the time fit is to remove hits with large time residuals. We do
this by assuming that the muon velocity is equal to the speed of light
and that the track is straight. In this case, we can subtract the time
of flight of the muon from the observed time and compare the value of
this ToF-corrected time for a given hit with the average value of this
quantity over the track. If the corrected hit time differs from the mean
by more than 20 ns, it is removed from the fit. We then recalculate the
mean removing these bad hits, looking for additional out of tolerance
times, until no new hits are removed, or we are left with only 5 good
time hits on the track. At the termination of this procedure, a final
chi^2^ is calculated for this view/side/direction, and a weighted linear
fit of time vs Z using the surviving hits is performed.

In the case that CalTimeType =kRaw, the individual fits results for each
view/side are now combined. The first step is the determination of the
track direction The average fit chi^2^ obtained over the views & sides
for dt/dz\>0 is compared with the average for dt/dz\<0. The track
direction is assume to be that giving the smaller average chi^2^ in the
ToF-corrected time distributions. The track TimeOffset and TimeSlope are
then set to the average of the linear fit parameters over the view/sides
for the selected track direction.

In the case that CalTimeType=kT0 the time fitting proceeds much as
above, but with hits from all views and sides combined in a single fit.
Because the time values are assumed to be of higher accuracy in this
case, ToF-corrected times are required to be within 10 ns of the track
average to be used in the fit, and not more that 20% of the track hits
are allowed to be removed in this procedure.

Finally, it is possible that the more careful determination of track
time slope may differ from that determined initially in AlgTrackSRList.
In that case, we need to reverse our definition of track head and tail,
and recalculate the integrated energy loss along the track, this time
starting from the opposite track end. In addition, vertex U/V/Z , etc
positions must be reloaded for the new track head. This is done at the
end of RunAlg. The final step in RunAlg is a call to Calibrate, which
will apply the post-reconstruction calibration to the 3D track members.

### Candidate Methods 

AddCluster(CandClusterHandle \*)

Adds a CandCluster to the CandTrack daughter list.

SetUTrack(Track2DSR \*)

SetVTrack(Track2DSR \*)

GetUTrack()

GetVTrack()

Sets or returns the 2D track component of the CandTrack for a given
plane view.

GetDirCosU(Int_t)

GetDirCosV(Int_t)

GetDirCosZ(Int_t)

Returns direction cosines at a specified plane.

GetHoughDirCosU()

GetHoughDirCosV()

GetHoughDirCosZ()

GetHoughResid2()

Returns various results of the initial Hough track finder.

GetScore()

> Returns a 'track robustness' score. Currently, the track score is
> currently defined as the sum of the number of slices in the track and
> the total charge/700.

GetTimeWeight(const CandDigitHandle \*)

GetNTrackPlane(PlaneView::PlaneView_t = PlaneView::kUnknown)

> Returns the number of planes in the track. The count can be restricted
> to a particular plane using the function parameter.

CreateDigitMap(CandContext &, const CandDigitListHandle\*)

TObjArray \*DigitMapArray(const CandDigitHandle\*)

Set or Gets a map of digits on this track which belong to the same PMT.

SetNTrackStrip(Int_t)

SetNTrackDigit(Int_t)

SetNTimeFitDigit(Int_t)

SetTimeFitChi2(Double_t)

GetNTrackStrip()

GetNTrackDigit()

GetNTimeFitDigit()

GetTimeFitChi2()

SetdS(Int_t,Double_t)

GetdS(Int_t = -1) travel distance from vertex

### Algorithm Parameters

+---------------------+---------+--------------------------------------+
| ***Parameter***     | ***Def  | ***Description***                    |
|                     | ault*** |                                      |
+---------------------+---------+--------------------------------------+
| MinPlane            | 3       |                                      |
+---------------------+---------+--------------------------------------+
| Trk2DplnEnd         | 6       |                                      |
+---------------------+---------+--------------------------------------+
| Trk2DNSkip          | 20      |                                      |
+---------------------+---------+--------------------------------------+
| Trk2DmaxResid       | 6 cm    |                                      |
+---------------------+---------+--------------------------------------+
| Trk2DhitFraction    | 0.75    |                                      |
+---------------------+---------+--------------------------------------+
| MinSingleHit        | 0       | \# of planes required in a track     |
|                     |         | before non-single hits are used      |
+---------------------+---------+--------------------------------------+
| Trk2DsubsetNHit     | 5       |                                      |
+---------------------+---------+--------------------------------------+
| Trk2DsubsetDHit     | 5       |                                      |
+---------------------+---------+--------------------------------------+
| Trk2DNPlaneBeg      | 3       |                                      |
+---------------------+---------+--------------------------------------+
| Di                  | 20      |                                      |
| ffViewBegPlaneMatch |         |                                      |
+---------------------+---------+--------------------------------------+
| Di                  | 20      |                                      |
| ffViewEndPlaneMatch |         |                                      |
+---------------------+---------+--------------------------------------+
| D                   | 0.5     |                                      |
| iffViewPlaneOverlap |         |                                      |
+---------------------+---------+--------------------------------------+
| Track2DSlopeWeight  | -0.25   |                                      |
+---------------------+---------+--------------------------------------+
| Trk3DTwinFrac       | 0.75    |                                      |
+---------------------+---------+--------------------------------------+
| MinStripPulseHeight | 200     |                                      |
+---------------------+---------+--------------------------------------+
| Mi                  | 140     |                                      |
| nClusterPulseHeight |         |                                      |
+---------------------+---------+--------------------------------------+
| Trk3DTrackMax       | 0       |                                      |
+---------------------+---------+--------------------------------------+
| LandauEp            | 600     | Parameters for a Landau              |
|                     |         | distribution, approximated by        |
|                     |         | sqrt(e(-(                            |
|                     |         | R\*(E-E~p~)+exp(-R\*(E-E~p~))))/2/π) |
|                     |         |                                      |
|                     |         | where E~p~ is most probably energy   |
|                     |         | (pulse height), and R is scale       |
|                     |         | factor. These parameters are used in |
|                     |         | selecting hits on a track based on   |
|                     |         | pulseheight so we should not make R  |
|                     |         | so large that landau distribution is |
|                     |         | narrow.                              |
+---------------------+---------+--------------------------------------+
| LandauR             | 0.0025  |                                      |
+---------------------+---------+--------------------------------------+
| LandauMinProb       | 0.05    |                                      |
+---------------------+---------+--------------------------------------+
| IsCosmic            | I       | Determines which set of values for   |
|                     | sCosmic | parameters below are used. The       |
|                     |         | default parameters are for cosmics.  |
+---------------------+---------+--------------------------------------+
| MaxNStrip           | 50      |                                      |
+---------------------+---------+--------------------------------------+
| HitNTime            | -999999 |                                      |
|                     | ns      |                                      |
+---------------------+---------+--------------------------------------+
| HitTime             | 999999  |                                      |
|                     | ns      |                                      |
+---------------------+---------+--------------------------------------+
| SingleHitDef        | 50      |                                      |
+---------------------+---------+--------------------------------------+
| Trk2Dwin0           | 4\.     |                                      |
+---------------------+---------+--------------------------------------+
| DxA                 | 20 cm   |                                      |
+---------------------+---------+--------------------------------------+
| DxExpA              | 400 cm  |                                      |
+---------------------+---------+--------------------------------------+
| DxExpB              | -1.5    |                                      |
+---------------------+---------+--------------------------------------+
| DxPlnA              | 0.8     |                                      |
+---------------------+---------+--------------------------------------+
| DxPlnExpA           | 15\.    |                                      |
+---------------------+---------+--------------------------------------+
| DxPlnExpB           | -0.1    |                                      |
+---------------------+---------+--------------------------------------+
| Trk2DAlpha          | 0.4     |                                      |
+---------------------+---------+--------------------------------------+
| Trk2DLinA0          | 50 cm   |                                      |
+---------------------+---------+--------------------------------------+
| Trk2DLinB0          | 0.5     |                                      |
+---------------------+---------+--------------------------------------+
| Trk2DLinA           | 20 cm   |                                      |
+---------------------+---------+--------------------------------------+
| Trk2DLinB           | 0.5     |                                      |
+---------------------+---------+--------------------------------------+
| Trk3DNSigmaA        | 3       |                                      |
+---------------------+---------+--------------------------------------+
| Trk                 | 0.5     |                                      |
| 2DTwinMatchFraction |         |                                      |
+---------------------+---------+--------------------------------------+
| Trk2DNSeed          | 3       |                                      |
+---------------------+---------+--------------------------------------+
| Trk2DNSeedFrac      | 0.3     |                                      |
+---------------------+---------+--------------------------------------+
| Trk2DNContiguous    | 0       |                                      |
+---------------------+---------+--------------------------------------+
| DiffViewTimeMatch   | 999999  |                                      |
|                     | ns      |                                      |
+---------------------+---------+--------------------------------------+
| TrkClsNSkip         | 2       | Number of missing strips allowed     |
+---------------------+---------+--------------------------------------+
| Trk2DNHough0        | 4       |                                      |
+---------------------+---------+--------------------------------------+
| Trk2DNHough         | 3       |                                      |
+---------------------+---------+--------------------------------------+
|                     |         |                                      |
+---------------------+---------+--------------------------------------+
|                     |         |                                      |
+---------------------+---------+--------------------------------------+
|                     |         |                                      |
+---------------------+---------+--------------------------------------+

## CandFitTrackSR

### Candidate Definition

Stores information from magnetic track fitting

Inherits from CandTrack

### Algorithm

### Candidate Methods 

###### CandFitTrackSR Members

GetKalmanPlane(Int_t)

RemoveKalmanPlane(Int_t)

CompressKalmanPlaneList()

GetCurrentKalmanPlane(PlaneView::PlaneView_t = PlaneView::kUnknown)

SetCurrentKalmanPlane(KalmanPlaneSR\*)

RemoveForward(KalmanPlaneSR \*kp = 0)

AddToFit(TrackClusterSR \*,Int_t)

ReverseFit(Int_t)

SetInitialQP(Double_t)

AddUpstreamPlaneList(TObjArray\*)

CalculateVtxT(TrackClusterSR \*tc = 0)

**CandFitTrack (Base Class) Members**

GetEMCharge()

SetEMCharge(Double_t)

GetChi2()

SetChi2(Double_t)

### Algorithm Parameters

  ----------------------- --------------- ------------------------------------------
  ***Parameter***         ***Default***   ***Description***

  Swimmer                                 

  IsCosmic                1               

  SeedTrkNSTrip           8               

  SeedTrkNStripView       2               

  TposError2              1.4 cm2         

  InitialPositionError2   1.4 cm2         

  InitialSlopeError2      0.1             

  InitialQPError2         0.01 GeV        

  InitialPOff             2 GeV           

  MaxIterate              10              

  QPDiff                  0.01            

  KalmanDState1           0.01 GeV        

  KalmanDState2           0.01 GeV        

  KalmanDState3           0.0025 Gev      

  KalmanDState4           0.0025 GeV      

  KalmanDState5           0.05 GeV        

  KalmanPlnRadLen         1.47            

  Kalmandedx              0.038 GeV       

  KalmanMaxQP             5\.             Max abs(q/p) before fitter stops

  MaxInitialChi2          30\.            

  HitDTime0               -20 ns          Hit -- track time \> Dtime0

  HitDTime1               50 ns           Hit -- track time \< Dtime1

  NskipView               3               Up to n missing planes allowed in each
                                          view

  FitInputHits            1               

                                          
  ----------------------- --------------- ------------------------------------------

## CandEventSR

### Candidate Definition

The CandEvent is the highest level candidate objection. It associates
tracks and showers which are determined to originate in the same physics
event, refining the original blocking provided by CandSlices. A
CandEvent may contain more than one candidate of each type. The
CandEvent allows for sharing of digits between tracks and showers, as
well as between CandSlice objects.

### Algorithm

AlgSREventList::RunAlg begins by iterating over all CandSlices, adding
the CandShowers and CandTracks from each into a reconstructed object
array. If a slice has no tracks or showers, BuildEventsFromUnassoc is
called.

BuildEventsFromUnassoc loops over strips in the slice, filling an array
of 'unassociated' strips. This array is now looped over. An event is
seeded with the first strip in the list. Strips are then added to the
event strip list, if they meet the following criteria. A new strip is
compared with other strips in the same view using the Dist2 parameter,
defined as

Dist2= ∆plane^2^ \*HitAssocZParm **+** ∆tpos**^2^** \*HitAssocPParm +
∆time^2^ \*HitAssocTParm

This value is required to be less than HitAssocMaxDist2\*4 for at least
one pre-existing strip in the event, compared with the new strip. For
strips in the orthogonal view, the time difference must be less than
HitAssocDTime0 and greater than HitAssocDTime1, and the plane difference
must be less than HitAssocPlane for at least one preexisting strip. This
check is made for strips in the orthogonal view until the first match is
found. Subsequent strips in this view are compared to strip in the same
view using the Dist2 parameter. Following a complete loop over
unassociated hits, if strips are found in both views a shower, and
subsequently an event, is created from these strips. These strips are
then removed from the unassociated hit list. This process is repeated
until no new events are found in a loop over the unassociated hits.

In the case in which a slice contains either tracks and/or showers, we
now iterate over these objects. For each object, we iterate over
previously constructed CandEvents, and determine whether this object
should be added to this event. For each of these previously constructed
CandEvents, we iterate over its reconstructed objects, a list of showers
and tracks in this event, performing the following tests to determine if
the two objects are associated with each other.

We deal first with the case in which the event object is a CandShower.
If the new reco object is also a CandShower, we calculate the U,V,Z and
time differences between the new object and the event CandShower
vertices. If the new object is a CandTrack, we extrapolate the CandTrack
to the CandShower vertex Z position and calculate the U and V distances
at that point. In all cases, if the two object vertices are in opposite
SMs in the far detector, we subtract the inter-SM gap from the Z
position difference. As an alternative estimator of Z separation we take
the end plane of the event CandShower (as opposed to its vertex) and
compare this Z position with the new object vertex Z position. Again, if
the two object vertices are in opposite SMs in the far detector, we
subtract the inter-SM gap from the Z position difference. Finally, if
the new object is a CandShower we compare the end plane Z position of
the new object CandShower with the event CandShower vertex Z position,
compensating for the inter-SM if necessary. We take the smaller of the Z
differences obtained in these three cases above as the actual Z
difference in the case

that the new object is a CandShower, and the smallest of the first two
cases if the new object is a CandTrack.

If the new object is a shower, and the object distances satisfy:

  

∆u^2^+∆v^2^ \< ShwShwDtpos2 and abs(∆z)\<ShwShwDz and abs(∆t)\<ShwShwDt

or if the new object is a track and the object distances satisfy:

∆u^2^+∆v^2^ \< ShwTrkDtpos2 and abs(∆z)\<ShwTrkDz and abs(∆t)\<ShwTrkDt

then the new object is added to this event. If this object was also
found to be associated with previous events in the event list, these
events are merged.

If the previous checks failed to find a match and the new object is a
CandTrack we perform an additional check of proximity, if the event
CandShower vertex Z position is greater than the new track vertex minus
ShwTrkDz. This handles the case in which the event shower is associated
with the track, downstream of the vertex. The track U, V, and time
values are extrapolated to the event CandShower vertex, and the shower
vertex Z position is compared with the track end Z position. If the
following condition is satisfied the new track is added to the event:

∆u^2^+∆v^2^ \< ShwTrkDtpos2 and abs(∆t)\<ShwTrkDt and event shower
vertex Z is less than the track end Z plus ShwTrkDz.

If this object was also found to be associated with previous events in
the event list, these events are merged.

We deal next with the case in which the event object is a CandTrack. If
the new reco object is a CandShower or if the event CandTrack vertex is
downstream (has larger Z) of the new object, we calculate the U,V,Z and
time differences between the new object and the event CandTrack, using
the event CandTrack to extrapolate to the new object vertex position.
Otherwise, we use the new CandTrack to extrapolate to the event
CandTrack vertex. In all cases, if the two object vertices are in
opposite SMs in the far detector, we subtract the inter-SM gap from the
Z position difference. We next determine the distance between the new
object vertex transverse position and the transverse position of the
event CandTrack. If the new object is a shower, we also compare the end
position of the shower with the new CandTrack vertex Z position,
corrected for inter-SM gaps if necessary. If this Z separation is less
than the previous value we use the latter.

If the new object is a shower, and the object distances satisfy:

  

∆u^2^+∆v^2^ \< TrkTrkDtpos2 and abs(∆z)\<TrkTrkDz and abs(∆t)\<TrkTrkDt

or if the new object is a track and the object distances satisfy:

∆u^2^+∆v^2^ \< ShwTrkDtpos2 and abs(∆z)\<ShwTrkDz and abs(∆t)\<ShwTrkDt

then the new object is added to this event. If this object was also
found to be associated with previous events in the event list, these
events are merged.

If the previous checks failed to find a match and the new object is a
CandShower we perform an additional check of proximity, if the new
CandShower vertex Z position is greater than the event CandTrack vertex
minus ShwTrkDz. This handles the case in which the new shower is
associated with the CandTrack, downstream of the track vertex. The
CandTrack U, V, and time values are interpolated to the new CandShower
vertex, and the shower vertex Z position is compared with the track end
Z position. If the following condition is satisfied the new track is
added to the event:

∆u^2^+∆v^2^ \< ShwTrkDtpos2 and abs(∆t)\<ShwTrkDt and the shower vertex
Z is less than the track end Z plus ShwTrkDz.

If this object was also found to be associated with previous events in
the event list, these events are merged.

Having iterated over all objects, and building events from them, we
treat hits unassociated with any object. We iterate over all CandStrips
in all CandSlices, building a list of CandStrips which are not contained
yet in any CandEvent.

We then compare the time of each unassociated CandStrips with the vertex
time of each event. If the unassociated hit time minus the vertex time
is greater than HitAssocDTime0 and less than HitAssocDTime1, and the
event has a primary shower, we attempt first to associate the hit with
the primary shower. If the event has a track but no primary shower, or
the shower is further than ShwShwDz from the track vertex, we will
consider in addition whether to create a new shower near the track
vertex, using this strip plus the strips in the first U/V planes of the
track. In the former case, for each CandStrip in the primary shower we
determine the difference in planes between this CandStrip and the
unassociated hit, as well as the difference in transverse position. The
distance between these CandStrips is define as HitAssocZParm\*Z^2^ +
HitAssocPParm\*TransversePos^2^ + HitAssocTParm\*time^2^. Looping over
all shower CandStrips, we determine the smallest separation. Looping
over all events, we determine the event with vertex time consistent with
the unassociated hit, and with the smallest value for this space/time
separation. If this separation is less than HitAssocMaxDist2, we remove
this unassociated CandStrip from the list, and add it to the event and
primary shower daughter lists. In the case in which we are considering
whether to create a new shower, the distance between the strip and event
is based on the strip position and track vertex position. If this is
determined to be the shortest event distance for this strip, a new
shower is created using this strip plus the strips in the first U and
first V plane of the track, and the strip is removed from the
unassociated hit list. In either case, since the event has been modified
as a result of adding this strip, we recalculate the shortest distance
of all other unassociated hits to this modified event, as before. The
process continues until we have looped over all unassociated hits. The
loop over unassociated event is repeated until no new association is
found for a complete loop.

As each event is constructed In AlgEventSR::RunAlg, the track list is
examined for duplicates according to the algorithm discussed below, with
duplicates being removed from the list. In addition, the primary track
and shower is identified and flagged.

Processing in AlgEventSR::RunAlg begins with a loop over all
reconstructed objects in the Event. For each track, a call to GetScore
is made (see CandTrack documentation). The track with the highest score
is called the primary event track. The shower with the largest energy is
called the primary track as long as it is within ShwTrkDz of the track
vertex (if a track vertex exists). Otherwise, the shower closest to the
track vertex is called the primary, if its energy is at least
MinShwEFract of the largest shower.

If a best track is found, the event vertex location is set to the vertex
of the best track. Otherwise, the vertex of the best shower is used as
the event vertex.

AlgSREventList::RunAlg begins by iterating over all CandSlices, adding
the CandShowers and CandTracks from each into a reconstructed object
array. Having built this object array, we now iterate over objects in
it. For each object, we iterate over previously constructed CandEvents,
and determine whether this object should be added to this event. For
each of these previously constructed CandEvents, we iterate over its
reconstructed objects, a list of showers and tracks in this event,
performing the following tests to determine if the two objects are
associated with each other.

We deal first with the case in which the event object is a CandShower.
If the new reco object is also a CandShower, we calculate the U,V,Z and
time differences between the new object and the event CandShower
vertices. If the new object is a CandTrack, we extrapolate the CandTrack
to the CandShower vertex Z position and calculate the U and V distances
at that point. In all cases, if the two object vertices are in opposite
SMs in the far detector, we subtract the inter-SM gap from the Z
position difference. As an alternative estimator of Z separation we take
the end plane of the event CandShower (as opposed to its vertex) and
compare this Z position with the new object vertex Z position. Again, if
the two object vertices are in opposite SMs in the far detector, we
subtract the inter-SM gap from the Z position difference. Finally, if
the new object is a CandShower we compare the end plane location of the
new object CandShower and compare its Z position with the event
CandShower vertex Z position, compensating for the inter-SM if
necessary. We take the smaller of the Z differences obtained in these
three cases above as the actual Z difference in the case that the new
object is a CandShower, and the smallest of the first two cases if the
new object is a CandTrack.

If the new object is a shower, and the object distances satisfy:

  

∆u^2^+∆v^2^ \< ShwShwDtpos2 and abs(∆z)\<ShwShwDz and abs(∆t)\<ShwShwDt

or if the new object is a track and the object distances satisfy:

∆u^2^+∆v^2^ \< ShwTrkDtpos2 and abs(∆z)\<ShwTrkDz and abs(∆t)\<ShwTrkDt

then the new object is added to this event. If this object was also
found to be associated with previous events in the event list, these
events are merged.

If the previous checks failed to find a match and the new object is a
CandTrack we perform an additional check of proximity, if the event
CandShower vertex Z position is greater than the new track vertex minus
ShwTrkDz. This handles the case in which the event shower is associated
with the track, downstream of the vertex. The track U, V, and time
values are extrapolated to the event

CandShower vertex, and the shower vertex Z position is compared with the
track end Z position. If the following condition is satisfied the new
track is added to the event:

∆u^2^+∆v^2^ \< ShwTrkDtpos2 and abs(∆t)\<ShwTrkDt and event shower
vertex Z is less than the track end Z plus ShwTrkDz.

If this object was also found to be associated with previous events in
the event list, these events are merged.

We deal next with the case in which the event object is a CandTrack. If
the new reco object is a CandShower or if the event CandTrack vertex is
downstream (has larger Z) of the new object, we calculate the U,V,Z and
time differences between the new object and the event CandTrack, using
the event CandTrack to extrapolate to the new object vertex position.
Otherwise, we use the new CandTrack to extrapolate to the event
CandTrack vertex. In all cases, if the two object vertices are in
opposite SMs in the far detector, we subtract the inter-SM gap from the
Z position difference. We next determine the distance between the new
object vertex transverse position and the transverse position of the
event CandTrack. If the new object is a shower, we also compare the end
position of the shower with the new CandTrack vertex Z position,
corrected for inter-SM gaps if necessary. If this Z separation is less
than the previous value we use the latter.

If the new object is a shower, and the object distances satisfy:

  

∆u^2^+∆v^2^ \< TrkTrkDtpos2 and abs(∆z)\<TrkTrkDz and abs(∆t)\<TrkTrkDt

or if the new object is a track and the object distances satisfy:

∆u^2^+∆v^2^ \< ShwTrkDtpos2 and abs(∆z)\<ShwTrkDz and abs(∆t)\<ShwTrkDt

then the new object is added to this event. If this object was also
found to be associated with previous events in the event list, these
events are merged.

If the previous checks failed to find a match and the new object is a
CandShower we perform an additional check of proximity, if the new
CandShower vertex Z position is greater than the event CandTrack vertex
minus ShwTrkDz. This handles the case in which the new shower is
associated with the CandTrack, downstream of the track vertex. The
CandTrack U, V, and time values are interpolated to the new CandShower
vertex, and the shower vertex Z position is compared with the track end
Z position. If the following condition is satisfied the new track is
added to the event:

∆u^2^+∆v^2^ \< ShwTrkDtpos2 and abs(∆t)\<ShwTrkDt and the shower vertex
Z is less than the track end Z plus ShwTrkDz.

If this object was also found to be associated with previous events in
the event list, these events are merged.

Having iterated over all objects, and building events from them, we
treat hits unassociated with any object. We iterate over all CandStrips
in all CandSlices, building a list of CandStrips which are not contained
yet in any CandEvent.

We then compare the time of each unassociated CandStrips with the vertex
time of each event. If the unassociated hit is more than HitAssocDTime0
ns later than the event vertex, but not more than HitAssocDTime1 later,
and the event has a primary shower, we attempt first to associate the
hit with the primary shower. For each CandStrip in the primary shower,
we determine the difference in planes between this CandStrip and the
unassociated hit, as well as the difference in transverse position. The
distance between these CandStrips is define as HitAssocZParm\*Z^2^ +
HitAssocPParm\*TransversePos^2^ + HitAssocTParm\*time^2^. Looping over
all shower CandStrips, we determine the smallest separation. Looping
over all events, we determine the event with vertex time consistent with
the unassociated hit, and with the smallest value for this space/time
separation. If this separation is less than HitAssocMaxDist2, we remove
this unassociated CandStrip from the list, and add it to the event and
primary shower daughter lists. Since this shower has now been modified,
we recalculate the shortest distance of all other unassociated hits to
this modified primary shower, as before. The process continues until we
have looped over all unassociated hits, and compared them with each
event's primary shower.

As each event is constructed In AlgEventSR::RunAlg, the track list is
examined for duplicates according to the algorithm discussed below, with
duplicates being removed from the list. In addition, the primary track
and shower is identified and flagged. Finally, the post-reconstruction
calibration step is initiated by a call to CandEvent::Calibrate.

Processing in AlgEventSR::RunAlg begins with a loop over all
reconstructed objects in the Event. For each track, a call to GetScore
is made (see CandTrack documentation). The track with the highest score
is called the primary event track. The shower with the largest number of
strips is called the primary shower.

One final check of track overlap is performed on the list of 3D
CandTracks. A nested loop over CandTracks is performed, and pairwise
comparisons of the CandTracks are done. If the fraction of common strips
to total strips is larger than TrkTrk3DTwinFrac for either track we flag
the track with the lowest 'score' for removal.

If a best track is found, the event vertex location is set to the vertex
of the best track. Otherwise, the vertex of the best shower is used as
the event vertex.

### Candidate Methods 

**CandEventSR Members**

###### CandEvent Base Class Members

Double_t GetVtxU()

Double_t GetVtxV()

Double_t GetVtxZ()

Double_t GetVtxT()

Double_t GetVtxPlane()

SetVtxU(Double_t)

SetVtxV(Double_t)

SetVtxZ(Double_t)

SetVtxT(Double_t)

SetVtxPlane(Int_t)

> If a best track is found, the event vertex location is set to the
> vertex of the best track. Otherwise, the vertex of the best shower is
> used as the event vertex.

AddShower(const CandShowerHandle \*)

AddTrack(const CandTrackHandle \*)

SetPrimaryShower(const CandShowerHandle \*)

SetPrimaryTrack(const CandTrackHandle \*)

> These routines first check whether this CandShower or CandTrack
> already exists in the CandEvent. If not, the new object is added to
> the appropriate list. In addition, the 'SetPrimary' members flag these
> object as the primary track or shower in the event.

CandShowerHandle \*GetShower(Int_t)

CandTrackHandle \*GetTrack(Int_t)

> The members return the 'i^th^' track or shower in the appropriate
> object list, and return a null result if "i" is greater than the list
> length.

CandShowerHandle \*GetPrimaryShower()

CandTrackHandle \*GetPrimaryTrack()

Int_t GetLastShower()

Int_t GetLastTrack()

> Returns the length of the shower or track list.

CompressShower()

CompressTrack()

Calibrate()

> This method should only be called in Algorithms. The
> post-reconstruction calibration step (calibrations needing the 3D
> position of each hit) is initiated with a call to this method. In
> Calibrate, all CandStrips in the reconstruction CandTracks and
> CandShowers (ie all 3d objects) are iterated over, and the calibrated
> charges of each type (obtained by calls to StripCalibrator::GetMIPs
> and StripCalibrator::GetSigMapped) are stored in lists in CandEvent.
> Subsequent calls to the GetCharge or GetStripCharge methods will
> access these lists if MIPs or SigMapped calibration values are
> requested.

Double_t GetCharge(CalStripType::CalStripType_t = CalStripType::kMIP)
const;

> Returns the total charge of the event. Charge is calibrated according
> to the value of CalStripType, with the default returning a total
> charge in MIPs. Other possibilities are kNone (returns raw ADC
> counts), kSigLin (returns ADC counts corrected for drift point and
> non-linearity), kSigCorr (returns ADC counts corrected for drift
> point, non-linearity, and strip-strip normalization), kSigMapped
> (returns ADC counts corrected for drift point,
> non-linearity,strip-strip normalization, and strip attenuation), and
> kPE (returns summed photoelectrons in the event)

Double_t GetStripCharge(CandStripHandle \*)

> Returns the total charge in MIPs of the given strip.

Double_t GetStripCharge(CandStripHandle \*,
CalStripType::CalStripType_t, StripEnd::StripEnd_t = StripEnd::kWhole)

Double_t GetStripCharge(CandStripHandle \*, StripEnd::StripEnd_t,
CalStripType::CalStripType_t = CalStripType::kMIP)

> Returns the charge of a particular CandStrip or CandStrip end.
> Calibrated charge is returned according to the value of CalStripType,
> with the default returning a total charge in MIPs. Other possibilities
> are kNone (returns raw ADC counts), kSigLin (returns ADC counts
> corrected for drift point and non-linearity), kSigCorr ( returns ADC
> counts corrected for drift point, non-linearity, and strip-strip
> normalization), kSigMapped (returns ADC counts corrected for drift
> point, non-linearity,strip-strip normalization, and strip
> attenuation), and kPE (returns summed photoelectrons in the event).
> The second two versions of this call are identical.

### Algorithm Parameters

  ------------------ --------------- ---------------------------------------------
  ***Parameter***    ***Default***   ***Description***

  TrkTrkDtpos2       500 cm2         Maximum transverse separation between track
                                     vertices for event association.

  TrkTrkDz           100 cm          Maximum Z position difference between track
                                     vertices for event association

  TrkTrkDt           50 ns           Maximum time difference between tracks for
                                     event association

  ShwTrkDz           100 cm          Maximum Z position difference between shower
                                     and track vertices for event association

  ShwTrkDt           50 ns           Maximum time difference between shower and
                                     track for event association

  ShwTrkDtpos2       500 cm2         Maximum transverse separation between shower
                                     and track for event association

  ShwShwDz           100 cm          Maximum Z position difference between showers
                                     for event association

  ShwShwDt           50 ns           Maximum time difference between showers for
                                     event association

  ShwShwDtpos2       500 cm2         Maximum transverse separation between showers
                                     for event association

  HitAssocDTime0     -20 ns          Maximum time prior to event vertex for
                                     unassociated hit

  HitAssocDTime1     100 ns          Maximum time after event vertex for
                                     unassociated hit

  HitAssocMaxDist    0               Maximum allowable time/space separation
                                     between unassociated hit and closest primary
                                     shower.

  HitAssocTParm      .0001 ns        Time parameter used in time/space sep.
                                     between unassociated hits and primary shower

  HitAssocZParm      0.0224          Z position parameter used in time/space sep.
                                     between unassociated hits and primary shower

  HitAssocPParm      20.25 m2        Transverse position parameter used in
                                     time/space sep. between unassociated hits and
                                     primary shower

  TrkTrk3DTwinFrac                   

                                     
  ------------------ --------------- ---------------------------------------------