Difference between revisions of "Mattione GlueX Analysis Factories"

From GlueXWiki
Jump to: navigation, search
(Analysis Chain Specifics - Analysis)
 
(217 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Quick Start ==
+
== Reaction Analysis Factories ==
 +
* NOTE: Most of these are located in sim-recon/src/libraries/ANALYSIS/
  
* NOTE: For an example of the below steps, see one of the existing analysis plugins (e.g. sim-recon/src/programs/Analysis/plugins/b1pi_hists).
+
=== Pre-Selection ===
* Create a new plugin containing a DEventProcessor, DReactionFactory, and DFactoryGenerator (for the DReactionFactory).
+
* '''DNeutralShower_factory_PreSelect''': Pre-selects which <span style="color:#0000FF">DNeutralShower</span> objects should be included in analyses.  
* Setup the DEventProcessor and DFactoryGenerator.
+
* '''DChargedTrack_factory_PreSelect''': Pre-selects which <span style="color:#0000FF">DChargedTrack</span> objects should be included in analyses.  
** In DEventProcessor, make sure to grab the DAnalysisResults objects from the JEventLoop in the evnt() method, and to add the DFactoryGenerator to the application in the InitPlugin() method.
+
** The DFactoryGenerator contents can be identical to those from sim-recon/src/programs/Analysis/plugins/b1pi_hists, although you may want a unique class name in case more than one plugin is used at once.
+
* Create desired custom DAnalysisAction objects for your analysis (if any).
+
** See existing analysis actions in sim-recon/src/libraries/ANALYSIS/DHistogramActions.h and sim-recon/src/libraries/ANALYSIS/DCutActions.h for examples.
+
* In DReactionFactory::init(void), create a DReaction object (with a unique name!) for each reaction you want to study, specify the kinematic fit type for it, specify the DAnalysisActions for each, and add them to _data.
+
** Make sure to call SetFactoryFlag(PERSISTANT); in this function.
+
** The DAnalysisAction objects are executed sequentially for each possible particle combination (DParticleCombo) matching the given DReaction, until it fails a cut.
+
** If more than one DAnalysisAction object of a given type is used in a DReaction, all of their constructors must be called with a unique identifier string (including the default "").
+
** More details on analysis actions in sim-recon/src/libraries/ANALYSIS/: DAnalysisAction.*, DHistogramActions.*, DCutActions.*
+
* Compile and run hd_root with your plugin (preferably on REST data).
+
  
== Analysis Details ==
+
=== User Input ===
=== Overview ===
+
* '''DReaction_factory''': Creates <span style="color:#0000FF">DReaction</span> objects to be analyzed. Needs to be created in each analysis plugin.   
* Generate every possible combination of particles (DParticleCombo) that can represent the desired DReaction(s).
+
** This can yield many DParticleCombo objects per event.
+
** This is regardless of PID, # of remaining tracks, timing, track position or momentum, etc.
+
*** Only extremely-loose cuts are placed by default on PID and track-vertex-z prior to creating DParticleCombo objects: this is to avoid memory spikes from events with too many particles.
+
**** These can be changed by modifying the command line parameters defined in DParticleComboBlueprint_factory::brun().  
+
* User-specified cuts are then used to eliminate DParticleCombo objects that do not much the desired DReaction(s) (e.g. PID, kinematic fit, invariant mass, etc.)
+
** This is done by execute DAnalysisActions (e.g. histogramming, cutting) in sequence on each DParticleCombo until it fails a cut.   
+
** The kinematic fit (if specified) is not performed until it is required for a DAnalysisAction.  This is to save time/memory by letting users cut DParticleCombo objects prior to fitting.
+
* Save the results to disk further analysis (currently not built-in (except for histograms)).
+
  
=== Analysis Chain Specifics - PID ===
+
=== Combo Construction Factories ===
 +
* '''DTrackTimeBased_factory_Combo''': If a charged PID is needed for an analysis for which a corresponding <span style="color:#0000FF">DTrackTimeBased</span> is not present in the data, a new one is created.  E.g. if mu+/- are requested.  This uses the reconstructed momentum from the <span style="color:#0000FF">DTrackTimeBased</span> object with the closest mass.
 +
* '''DDetectorMatches_factory_Combo''': Stores the matching between each new <span style="color:#0000FF">DTrackTimeBased</span> object (from the <span style="color:Red">"Combo"</span> factory) and the existing shower/hit objects. No new matching is done, it just uses the matching results from the source object. Also stores the matching results from the default factory.
 +
* '''DAnalysisResults_factory''': Creates the combos via the DSourceComboer class (detailed below). Loops over the <span style="color:#0000FF">DAnalysisAction</span> objects stored in each <span style="color:#0000FF">DReaction</span>, and executing them on the corresponding <span style="color:#0000FF">DParticleCombo</span>.  This creates and fills histograms of the number of events and <span style="color:#0000FF">DParticleCombo</span> objects that survive each cut.
  
* DBeamPhoton_factory: Currently just reads the generated DBeamPhoton objects in from the hddm file.  
+
=== Combo Construction Classes (not factories) ===
* DChargedTrackHypothesis_factory: Creates a DChargedTrackHypothesis object for each DTrackTimeBased object (one per PID hypothesis, can be more than one per particle). When creating these objects, the tracks are matched to hits in the SC, BCAL, FCAL, and TOF and the PID FOM is calculated (from TOF and DC dE/dx).  
+
* '''DSourceComboer''': Finds all combos of charged tracks / neutral showers necessary to make the desired combos.  Calls methods in the other DSourceCombo* classes below as needed.  Also is responsible for dE/dx and E/p PID cuts.  
* DChargedTrack_factory: Creates a DChargedTrack object for each reconstructed charged particleThese contain all of the DChargedTrackHypothesis objects associated with this particle.  
+
* '''DSourceComboTimeHandler''': Responsible for PID timing cuts, binning photons by vertex-z, and RF bunch selection.
* DNeutralShower_factory: Creates a DNeutralShower object for each DBCALShower and DFCALShower object that is not matched to any of the DChargedTrackHypothesis objects.  
+
* '''DSourceComboVertexHandler''': Responsible for finding pre-kinfit vertex positions for the combosIf is photoproduction step, the POCA to the beamline of the tracks with &theta; closest to 90 degrees.  Otherwise, is the POCA between the two closest tracks.  
* DNeutralParticleHypothesis_factory: Creates two DNeutralParticleHypothesis objects for each DNeutralShower: PIDs = photon and neutron.  The particle vertex is assumed to be the center of the target.  
+
* '''DSourceComboP4Handler''': Responsible for placing invariant mass and missing mass squared cuts on the combos.  Also for reconstructing the P4 of decaying particles as needed.  
 +
* '''DParticleComboCreator''': Takes the results from the DSourceComboer and creates DParticleCombo objects from them, along with new DChargedTrackHypothesis and DNeutralParticleHypothesis objects for the tracks (using the combo-specific vertex position for PID, etc.).  
  
=== Analysis Chain Specifics - Analysis ===
+
== Thrown Factories ==
* DReaction_factory: Creates DReaction objects to be analyzedNeeds to be created in each analysis plugin.   
+
* '''DReaction_factory_Thrown''': Creates a <span style="color:#0000FF">DReaction</span> object representing the thrown reactionFinal state particles listed in <span style="color:#0000FF">DMCThrown</span> are ignored if they have decayed from pions, kaons, or other "typical" final state particles (e.g. muons, electrons, pions, and neutrinos are ignored if they decay from a kaon, etc.)Also, particles not defined in sim-recon/src/libraries/include/particleType.h are ignored.
* DParticleComboBlueprint_factory: Creates a DParticleComboBlueprint object for each possible track combination, excluding any beam photons.   
+
* '''DParticleCombo_factory_Thrown''': Creates a <span style="color:#0000FF">DParticleCombo</span> object representing the thrown reaction.  The <span style="color:#0000FF">DMCThrown</span> objects are used for the particle data, except pure <span style="color:#0000FF">DKinematicData</span> objects are used for the beam particle and target objects (from <span style="color:#0000FF">DMCReaction</span>). Final state particles listed in <span style="color:#0000FF">DMCThrown</span> are ignored if they have decayed from pions, kaons, or other "typical" final state particles (e.g. muons, electrons, pions, and neutrinos are ignored if they decay from a kaon, etc.)Also, particles not defined in sim-recon/src/libraries/include/particleType.h are ignored.
* DTrackTimeBased_factory_Reaction
+
* '''DEventRFBunch_factory_Thrown''': Creates a <span style="color:#0000FF">DEventRFBunch</span> object for the simulated event.
* DChargedTrackHypothesis_factory_Reaction
+
* DParticleCombo
+
* DParticleCombo_factory_PreKinFit
+
* DAnalysisResults_PreKinFit
+
* DKinFitResults_factory
+
* DChargedTrackHypothesis_factory_KinFit
+
* DNeutralTrackHypothesis_factory_KinFit
+
* DBeamPhoton_factory_KinFit
+
* DParticleCombo_factory
+
* DAnalysisResults_factory
+
  
=== Analysis Actions/Utilities Specifics ===
+
== Analysis Utilities ==
  
* DAnalysisAction
+
* '''DParticleID''': (Located in the PID library) Collection of functions used to match charged tracks to hits in the BCAL, FCAL, SC, and TOF, and to calculate the PID FOM from the TOF and DC dE/dx information.
* DMCThrownMatching
+
* '''DMCThrownMatching''': Matches reconstructed particles to generated particles. Only the best match for each particle is saved.
* DAnalysisUtilities
+
** For neutrals, compares the thrown and reconstructed shower momenta and uses the shower covariance matrix to calculate a match FOM. This FOM is NOT cut, so extremely poor matches are included in the results.  
* DKinFitter
+
** For tracks, compares the hits on the track to the thrown hits. First, the % of the track hits on each thrown track is computed (in the <span style="color:#0000FF">DTrackTimeBased</span> factory), and the highest total is set in <span style="color:#0000FF">DTrackTimeBased</span> (as well as the corresponding <span style="color:#0000FF">DMCThrown</span>::<span style="color:#008000">myid</span>). In the <span style="color:#0000FF">DMCThrownMatching</span> factory, for each <span style="color:#0000FF">DTrackTimeBased</span>, the number of matched hits is weighted (multiplied) by the track hit-fraction (#-hits-on-track-matched-to-MC / #-hits-on-track). Matches are then recorded in order from highest weighted-#-hits to least, such that each <span style="color:#0000FF">DMCThrown</span> is only matched once (other matches are ignored).  Hit fractions less than <span style="color:#0000FF">DMCThrownMatching</span>::<span style="color:#008000">dMinTrackMatchHitFraction</span> (default <span style="color:Red">0.5</span>, set-able on command-line via <span style="color:Red">-PMCMATCH:MIN_TRACK_MATCH</span>) are ignored.  
* DHistogramActions
+
** Also matches thrown and reconstructed BCAL, FCAL, and TOF hits, although currently only the TOF hits have been vetted.   
* DCutActions
+
* '''DAnalysisUtilities''': Collection of utility functions used to facilitate physics analysesThese include methods for calculating invariant mass, missing mass, DOCA, etc.
 
+
* '''DKinFitter_GlueX''': See [[Mattione_GlueX_Kinematic_Fitting | GlueX Kinematic Fitting]]
== Tricks for saving time and memory ==
+
* Re-use DReactionStep objects when
+
* To branch an analysis, create an identical DReaction (with the same DReactionStep objects), perform all the same cuts as before, but skip the histogramming steps.
+
 
+
== Summary ==
+
* In his/her plugin, a user specifies the reaction(s) he/she wants to study (<span style="color:#0000FF">DReaction</span>), along with the histograms and cuts to perform (<span style="color:#0000FF">DAnalysisAction</span>), then just asks JANA for the results (<span style="color:#0000FF">DAnalysisResults</span>).
+
* Through this process, the program creates all possible track combinations for the desired reaction (<span style="color:#0000FF">DParticleCombo</span>, tag <span style="color:#0000FF">"PreKinFit"</span>), kinematic fits the event to the reaction (<span style="color:#0000FF">DKinFitResults</span>), and updates the tracks with the new kinfit information (<span style="color:#0000FF">DParticleCombo</span>, no tag).
+
* The <span style="color:#0000FF">DAnalysisAction</span> objects encapsulate the setup and execution of an action (e.g. cut, histogram) into a single object.
+
** Many common actions will be predefined in DANA (see libraries/ANALYSIS/DHistogramActions.h and libraries/ANALYSIS/DCutActions.h), but the user can write custom ones for their analysis in their plugin.  
+
* The <span style="color:#0000FF">DAnalysisResults</span> objects indicate which DParticleCombo objects have passed/failed the DAnalysisAction cuts for each DReaction.
+
 
+
== DReaction ==
+
* Located in src/libraries/ANALYSIS
+
* The factory needs to be defined in your plugin (see DReaction_factory section below)
+
* User creates one of these in their plugin for each reaction they want to analyze (example shown later below) (can analyze more than one at once).
+
class <span style="color:#0000FF">DReaction</span> : public <span style="color:#0000FF">JObject</span>
+
{
+
private:
+
<span style="color:#0000FF">//REACTION AND ANALYSIS:</span>
+
string <span style="color:#0000FF">dReactionName</span>; //must be unique: e.g. "Y2175"
+
deque<const DReactionStep*> <span style="color:#0000FF">dReactionSteps</span>;
+
deque<const DAnalysisAction*> <span style="color:#0000FF">dAnalysisActions</span>;
+
+
<span style="color:#0000FF">//CONTROL VARIABLES:</span>
+
DKinFitType <span style="color:#0000FF">dKinFitType</span>; //defined in ANALYSIS/DKinFitResults.h
+
deque<size_t> <span style="color:#0000FF">dDecayingParticlesExcludedFromKinfit</span>; //to exclude decaying particles from the kinematic fit (resonances are automatically excluded)
+
};
+
 
+
class <span style="color:#0000FF">DReactionStep</span>
+
{
+
private:
+
Particle_t <span style="color:#0000FF">dInitialParticleID</span>; //e.g. lambda, phi, gamma
+
Particle_t <span style="color:#0000FF">dTargetParticleID</span>; //Unknown for no target
+
deque<Particle_t> <span style="color:#0000FF">dFinalParticleIDs</span>;
+
+
int <span style="color:#0000FF">dMissingParticleIndex</span>; //-1 for no missing particles, else final state particle at this index is missing (0 -> x)
+
};
+
 
+
== DParticleCombo ==
+
* Located in src/libraries/ANALYSIS
+
* <span style="color:#0000FF">DParticleCombo_factory_PreKinFit</span>: Generates a DParticleCombo object for each possible combination of detected tracks and DBeamPhotons (configurable time cut used to eliminate way-out-of-time photons).  
+
** PID is NOT assumed, all possibilities are tested: For each q = +/-/0 particle in a given DReaction, all detected q = +/-/0 tracks are tested as to whether or not they are that particle.
+
* <span style="color:#0000FF">DKinFitResults_factory</span>: Performs a single kinematic fit testing whether each DParticleCombo matches the DReaction: includes all mass, vertex, timing constraints if requested.
+
* <span style="color:#0000FF">DParticleCombo_factory</span>: Create new DParticleCombo objects, using the kinematic fit track information and results.  
+
 
+
class <span style="color:#0000FF">DParticleCombo</span> : public <span style="color:#0000FF">JObject</span>
+
{
+
private:
+
<span style="color:#0000FF">//REACTION AND ANALYSIS:</span>
+
const DReaction* <span style="color:#0000FF">dReaction</span>;
+
deque<const DParticleComboStep*> <span style="color:#0000FF">dParticleComboSteps</span>;
+
const DKinFitResults* <span style="color:#0000FF">dKinFitResults</span>;
+
+
<span style="color:#0000FF">//UNUSED TRACKS:</span>
+
deque<const DChargedTrack*> <span style="color:#0000FF">dUnusedPositiveTracks</span>;
+
deque<const DChargedTrack*> <span style="color:#0000FF">dUnusedNegativeTracks</span>;
+
deque<const DNeutralShower*> <span style="color:#0000FF">dUnusedNeutralShowers</span>;
+
};
+
 
+
class <span style="color:#0000FF">DParticleComboStep</span>
+
{
+
private:
+
<span style="color:#0000FF">//PIDS:</span>
+
Particle_t <span style="color:#0000FF">dInitialParticleID</span>; //e.g. lambda, phi, gamma
+
Particle_t <span style="color:#0000FF">dTargetParticleID</span>; //Unknown for no target
+
deque<Particle_t> <span style="color:#0000FF">dFinalParticleIDs</span>;
+
+
<span style="color:#0000FF">//INITIAL PARTICLES:</span>
+
DKinematicData* <span style="color:#0000FF">dInitialParticle</span>; //kinfit result, else measured
+
DKinematicData* <span style="color:#0000FF">dInitialParticle_Measured</span>; //e.g. DBeamPhoton
+
DKinematicData* <span style="color:#0000FF">dTargetParticle</span>; //NULL for no target
+
+
<span style="color:#0000FF">//FINAL PARTICLES:</span>
+
deque<const DKinematicData*> <span style="color:#0000FF">dFinalParticles</span>; //kinfit result, else measured //e.g. DChargedTrackHypothesis, DNeutralParticleHypothesis
+
deque<const DKinematicData*> <span style="color:#0000FF">dFinalParticles_Measured</span>; //e.g. DChargedTrackHypothesis, DNeutralParticleHypothesis
+
deque<const JObject*> <span style="color:#0000FF">dFinalParticleSourceObjects</span>; //original DChargedTrack or DNeutralShower objects
+
+
<span style="color:#0000FF">//CONTROL VARIABLES:</span>
+
int <span style="color:#0000FF">dInitialParticleDecayFromStepIndex</span>; //points to which DParticleComboStep represents the production of the initial particle (e.g. Lambda)
+
deque<int> <span style="color:#0000FF">dDecayStepIndices</span>; //let's you know whether a final state particle is decaying, missing, or detected.  if decaying, points to which DParticleComboStep represents its decay
+
};
+
 
+
== Cutting & Histogramming: DAnalysisAction, DAnalysisResults ==
+
=== DAnalysisAction ===
+
* Virtual base class that encapsulates the setup (e.g. histogram creation) and execution (cut, hist, etc.) of the contained action for each DParticleCombo that has passed all previous cuts.
+
** Many common actions (e.g. histogramming kinfit pulls, comparing thrown and reconstructed MC data, etc.) are pre-defined in src/libraries/ANALYSIS/ (see DHistogramActions.h and DCutActions.h)
+
** Custom, analysis-specific actions can be created and stored in the plugin, along with any custom factories you need for them (e.g.: studying the background). 
+
** These actions should be added to the DReaction objects in the order that they will be executed.
+
class <span style="color:#0000FF">DAnalysisAction</span>
+
{
+
public:
+
//returns true/false if passes/fails cut/hist/etc.
+
virtual bool <span style="color:#0000FF">operator()</span>(JEventLoop* locEventLoop, map<const DParticleCombo*, bool>& locParticleCombos) const = 0;
+
};
+
 
+
=== DAnalysisResults ===
+
* Loops over all DReaction objects, executing the DAnalysisAction objects for each one.  Returns the cut status of each DParticleCombo (which cut they failed on, if any).
+
class <span style="color:#0000FF">DAnalysisResults</span> : public <span style="color:#0000FF">JObject</span>
+
{
+
private:
+
DReaction* <span style="color:#0000FF">dReaction</span>;
+
map<const DParticleCombo*, size_t> <span style="color:#0000FF">dFailedParticleComboMap</span>; //indicates at which action these DParticleCombo failed to pass the cut
+
deque<const DParticleCombo*> <span style="color:#0000FF">dPassedParticleCombos</span>; //DParticleCombo objects that passed all DAnalysisAction cuts.  
+
};
+
 
+
=== Simple Example ===
+
* Cutting the confidence level of a kinematic fit:
+
class <span style="color:#0000FF">DAnalysisAction_KinFitFOM</span> : public <span style="color:#0000FF">DAnalysisAction</span>
+
{
+
  public:
+
double <span style="color:#0000FF">dMinimumConfidenceLevel</span>; //e.g. 0.01
+
+
<span style="color:#0000FF">DAnalysisAction_KinFitFOM</span>(double locMinimumConfidenceLevel) : dMinimumConfidenceLevel(locMinimumConfidenceLevel) {} //cut setup upon construction
+
+
bool <span style="color:#0000FF">operator()</span>(JEventLoop* locEventLoop, map<const DParticleCombo*, bool>& locParticleComboStatusMap) const
+
{
+
bool locEventPassedCutFlag = false;
+
<span style="color:#0000FF">//loop over all particle combos and perform the cut (unless already failed a previous cut)</span>
+
for(map<const DParticleCombo*, bool>::iterator locIterator = locParticleComboStatusMap(); locIterator != locParticleComboStatusMap(); ++locIterator)
+
{
+
if(!locIterator->second)
+
<span style="color:#0000FF">continue</span>; //particle combo failed a previous cut!
+
+
const DParticleCombo* locParticleCombo = locIterator->first;
+
DKinFitResults* locKinFitResults = locParticleCombo->Get_KinFitResults();
+
double <span style="color:#0000FF">locConfidenceLevel</span> = locKinFitResults->Get_ConfidenceLevel();
+
+
<span style="color:#0000FF">if(locConfidenceLevel > dMinimumConfidenceLevel)</span>
+
locParticleCombos[locParticleCombo] = <span style="color:#0000FF">false</span>; //mark the DParticleCombo as having failed the cut
+
else
+
locEventPassedCutFlag = <span style="color:#0000FF">true</span>; //at least once DParticleCombo passed the cut
+
}
+
return locEventPassedCutFlag;
+
}
+
};
+
 
+
== User Plugin DReaction Factory ==
+
* Below shows how to set up DReaction for a Y(2175) analysis. 
+
* Note that while most of the analysis actions are pre-defined, built-in ones (e.g. histogramming kinfit results), some are custom to the plugin (for now) (e.g. histogramming phi invariant mass).
+
//------------------
+
// init
+
//------------------
+
jerror_t <span style="color:#0000FF">DReaction_factory::init(void)</span>
+
{
+
// Setting the PERSISTANT prevents JANA from deleting
+
// the objects every event so we only create them once.
+
SetFactoryFlag(PERSISTANT);
+
+
DReaction* locReaction;
+
DReactionStep* locReactionStep;
+
+
// Make as many DReaction objects as desired
+
<span style="color:#0000FF">locReaction = new DReaction();</span>
+
locReaction->Set_ReactionName(<span style="color:#0000FF">"Y2175"</span>);
+
locReaction->Set_FitTypeFlag(<span style="color:#0000FF">3</span>); //kinfit p4, v, & t simultaneously (0 is no kinfit)
+
 
+
  <span style="color:#0000FF">//SETUP REACTION</span>
+
+
//<span style="color:#0000FF">g, p -> phi(2175), (p)</span>
+
locReactionStep = new DReactionStep();
+
locReactionStep->Set_InitialParticleID(<span style="color:#0000FF">Gamma</span>);
+
locReactionStep->Set_TargetParticleID(<span style="color:#0000FF">Proton</span>);
+
locReactionStep->Add_FinalParticleID(<span style="color:#0000FF">Unknown</span>); //phi(2175)
+
locReactionStep->Add_FinalParticleID(<span style="color:#0000FF">Proton</span>);
+
locReactionStep->Set_MissingParticleIndex(<span style="color:#0000FF">1</span>); //proton missing
+
locReaction->Add_ReactionStep(locReactionStep);
+
dReactionStepPool.push_back(locReactionStep); //prevent memory leak
+
   
+
//<span style="color:#0000FF">phi(2175) -> pi+, pi-, phi</span>
+
locReactionStep = new DReactionStep();
+
locReactionStep->Set_InitialParticleID(<span style="color:#0000FF">Unknown</span>); //phi(2175)
+
locReactionStep->Set_TargetParticleID(<span style="color:#0000FF">Unknown</span>); //no target for this step
+
locReactionStep->Add_FinalParticleID(<span style="color:#0000FF">PiPlus</span>);
+
locReactionStep->Add_FinalParticleID(<span style="color:#0000FF">PiMinus</span>);
+
locReactionStep->Add_FinalParticleID(<span style="color:#0000FF">phiMeson</span>);
+
locReactionStep->Set_MissingParticleIndex(<span style="color:#0000FF">-1</span>); //none missing
+
locReaction->Add_ReactionStep(locReactionStep);
+
dReactionStepPool.push_back(locReactionStep); //prevent memory leak
+
+
//<span style="color:#0000FF">phi -> K+, K-</span>
+
locReactionStep = new DReactionStep();
+
locReactionStep->Set_InitialParticleID(<span style="color:#0000FF">Unknown</span>); //phi(2175)
+
locReactionStep->Set_TargetParticleID(<span style="color:#0000FF">Unknown</span>); //no target for this step
+
locReactionStep->Add_FinalParticleID(<span style="color:#0000FF">KPlus</span>);
+
locReactionStep->Add_FinalParticleID(<span style="color:#0000FF">KMinus</span>);
+
  locReactionStep->Set_MissingParticleIndex(<span style="color:#0000FF">-1</span>); //none missing
+
  locReaction->Add_ReactionStep(locReactionStep);
+
dReactionStepPool.push_back(locReactionStep); //prevent memory leak
+
 
+
  <span style="color:#0000FF">//SETUP ANALYSIS ACTIONS</span>
+
+
<span style="color:#0000FF">//Track reconstruction quality/multiplicity</span>
+
dReaction->Add_AnalysisAction(new DHistogramFunctor_TrackMultiplicity());
+
dReaction->Add_AnalysisAction(new DHistogramFunctor_GenReconTrackComparison());
+
+
<span style="color:#0000FF">//Vertex reconstruction and cuts of tracks with bogus vertex-z</span>
+
dReaction->Add_AnalysisAction(new DHistogramFunctor_ParticleComboKinematics(1)); //1: initial data
+
dReaction->Add_AnalysisAction(new DCutFunctor_AllVertexZ(45.0, 85.0));
+
dReaction->Add_AnalysisAction(new DHistogramFunctor_TrackVertexComparison());
+
+
<span style="color:#0000FF">//PID</span>
+
dReaction->Add_AnalysisAction(new DHistogramFunctor_PID());
+
dReaction->Add_AnalysisAction(new DCutFunctor_AllPID(0.01, 1)); //1%, all charged tracks
+
dReaction->Add_AnalysisAction(new DHistogramFunctor_TruePID());
+
+
<span style="color:#0000FF">//Phi Invariant Mass Cut & PID Check</span>
+
dReaction->Add_AnalysisAction(new DHistogramFunctor_PhiMass(1)); //1: initial data
+
dReaction->Add_AnalysisAction(new DCutFunctor_InvariantMass(phiMeson, 1, 1.004, 1.04)); //~3sigma
+
dReaction->Add_AnalysisAction(new DHistogramFunctor_TruePID());
+
   
+
<span style="color:#0000FF">//Initial Proton and Y2175 Mass Distributions</span>
+
dReaction->Add_AnalysisAction(new DHistogramFunctor_ProtonMass(1)); //1: initial data
+
dReaction->Add_AnalysisAction(new DHistogramFunctor_Phi2175Mass(1)); //1: initial data
+
+
<span style="color:#0000FF">//Missing Proton Kinematic Fit</span>
+
dReaction->Add_AnalysisAction(new DHistogramFunctor_KinFitResults(0.1));
+
dReaction->Add_AnalysisAction(new DCutFunctor_KinFitFOM(0.01); //1%
+
   
+
<span style="color:#0000FF">//Final Proton and Y2175 Mass Distributions</span>
+
dReaction->Add_AnalysisAction(new DHistogramFunctor_ProtonMass(1)); //1: initial data
+
dReaction->Add_AnalysisAction(new DHistogramFunctor_Phi2175Mass(1)); //1: initial data
+
dReaction->Add_AnalysisAction(new DHistogramFunctor_Phi2175Mass(2)); //2: final data
+
+
<span style="color:#0000FF">//Final track kinematics & PID Check</span>
+
dReaction->Add_AnalysisAction(new DHistogramFunctor_ParticleComboKinematics(2)); //2: final data
+
dReaction->Add_AnalysisAction(new DHistogramFunctor_TruePID());
+
+
_data.push_back(locReaction);
+
+
return NOERROR;
+
}
+
 
+
== User Plugin DEventProcessor ==
+
* The DEventProcessor itself is extremely minimal in content:
+
extern "C"
+
{
+
void InitPlugin(JApplication *app)
+
{
+
InitJANAPlugin(app);
+
app->AddProcessor(new DEventProcessor_Y2175());
+
<span style="color:#0000FF">app->AddFactoryGenerator(new DFactoryGenerator_DReaction());</span>
+
}
+
} // "C"
+
+
jerror_t DEventProcessor_Y2175::evnt(JEventLoop *locEventLoop, int eventnumber)
+
{
+
vector<const <span style="color:#0000FF">DAnalysisResults*</span>> locAnalysisResultsVector;
+
locEventLoop->Get(locAnalysisResultsVector);
+
+
//SAVE PROGRAM OUTPUT HERE (e.g. surviving DParticleCombo objects, custom tuples, etc. (format undetermined)
+
+
return NOERROR;
+
}
+
 
+
== Program Output ==
+
* Other than histograms, I haven't really gotten this far yet...
+

Latest revision as of 07:41, 3 November 2017

Reaction Analysis Factories

  • NOTE: Most of these are located in sim-recon/src/libraries/ANALYSIS/

Pre-Selection

  • DNeutralShower_factory_PreSelect: Pre-selects which DNeutralShower objects should be included in analyses.
  • DChargedTrack_factory_PreSelect: Pre-selects which DChargedTrack objects should be included in analyses.

User Input

  • DReaction_factory: Creates DReaction objects to be analyzed. Needs to be created in each analysis plugin.

Combo Construction Factories

  • DTrackTimeBased_factory_Combo: If a charged PID is needed for an analysis for which a corresponding DTrackTimeBased is not present in the data, a new one is created. E.g. if mu+/- are requested. This uses the reconstructed momentum from the DTrackTimeBased object with the closest mass.
  • DDetectorMatches_factory_Combo: Stores the matching between each new DTrackTimeBased object (from the "Combo" factory) and the existing shower/hit objects. No new matching is done, it just uses the matching results from the source object. Also stores the matching results from the default factory.
  • DAnalysisResults_factory: Creates the combos via the DSourceComboer class (detailed below). Loops over the DAnalysisAction objects stored in each DReaction, and executing them on the corresponding DParticleCombo. This creates and fills histograms of the number of events and DParticleCombo objects that survive each cut.

Combo Construction Classes (not factories)

  • DSourceComboer: Finds all combos of charged tracks / neutral showers necessary to make the desired combos. Calls methods in the other DSourceCombo* classes below as needed. Also is responsible for dE/dx and E/p PID cuts.
  • DSourceComboTimeHandler: Responsible for PID timing cuts, binning photons by vertex-z, and RF bunch selection.
  • DSourceComboVertexHandler: Responsible for finding pre-kinfit vertex positions for the combos. If is photoproduction step, the POCA to the beamline of the tracks with θ closest to 90 degrees. Otherwise, is the POCA between the two closest tracks.
  • DSourceComboP4Handler: Responsible for placing invariant mass and missing mass squared cuts on the combos. Also for reconstructing the P4 of decaying particles as needed.
  • DParticleComboCreator: Takes the results from the DSourceComboer and creates DParticleCombo objects from them, along with new DChargedTrackHypothesis and DNeutralParticleHypothesis objects for the tracks (using the combo-specific vertex position for PID, etc.).

Thrown Factories

  • DReaction_factory_Thrown: Creates a DReaction object representing the thrown reaction. Final state particles listed in DMCThrown are ignored if they have decayed from pions, kaons, or other "typical" final state particles (e.g. muons, electrons, pions, and neutrinos are ignored if they decay from a kaon, etc.). Also, particles not defined in sim-recon/src/libraries/include/particleType.h are ignored.
  • DParticleCombo_factory_Thrown: Creates a DParticleCombo object representing the thrown reaction. The DMCThrown objects are used for the particle data, except pure DKinematicData objects are used for the beam particle and target objects (from DMCReaction). Final state particles listed in DMCThrown are ignored if they have decayed from pions, kaons, or other "typical" final state particles (e.g. muons, electrons, pions, and neutrinos are ignored if they decay from a kaon, etc.). Also, particles not defined in sim-recon/src/libraries/include/particleType.h are ignored.
  • DEventRFBunch_factory_Thrown: Creates a DEventRFBunch object for the simulated event.

Analysis Utilities

  • DParticleID: (Located in the PID library) Collection of functions used to match charged tracks to hits in the BCAL, FCAL, SC, and TOF, and to calculate the PID FOM from the TOF and DC dE/dx information.
  • DMCThrownMatching: Matches reconstructed particles to generated particles. Only the best match for each particle is saved.
    • For neutrals, compares the thrown and reconstructed shower momenta and uses the shower covariance matrix to calculate a match FOM. This FOM is NOT cut, so extremely poor matches are included in the results.
    • For tracks, compares the hits on the track to the thrown hits. First, the % of the track hits on each thrown track is computed (in the DTrackTimeBased factory), and the highest total is set in DTrackTimeBased (as well as the corresponding DMCThrown::myid). In the DMCThrownMatching factory, for each DTrackTimeBased, the number of matched hits is weighted (multiplied) by the track hit-fraction (#-hits-on-track-matched-to-MC / #-hits-on-track). Matches are then recorded in order from highest weighted-#-hits to least, such that each DMCThrown is only matched once (other matches are ignored). Hit fractions less than DMCThrownMatching::dMinTrackMatchHitFraction (default 0.5, set-able on command-line via -PMCMATCH:MIN_TRACK_MATCH) are ignored.
    • Also matches thrown and reconstructed BCAL, FCAL, and TOF hits, although currently only the TOF hits have been vetted.
  • DAnalysisUtilities: Collection of utility functions used to facilitate physics analyses. These include methods for calculating invariant mass, missing mass, DOCA, etc.
  • DKinFitter_GlueX: See GlueX Kinematic Fitting