Difference between revisions of "Mattione GlueX Analysis Factories"

From GlueXWiki
Jump to: navigation, search
(DTrackCombo Factory)
 
(313 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Summary ==
+
== Reaction Analysis Factories ==
* In his/her plugin, a user specifies the reactions he/she wants to study (DReaction objects), then just asks JANA for the results (DTrackCombo objects).
+
* NOTE: Most of these are located in sim-recon/src/libraries/ANALYSIS/
** Creates all possible track combinations for the desired reaction; user then cuts on the likelihood that those combinations represent the hypothesized reaction.
+
  
== User Plugin DReaction Factory ==
+
=== Pre-Selection ===
* DReaction.h located in DANA libraries, DReaction_factory.h located in user plugin (along with a factory generator for it).
+
* '''DNeutralShower_factory_PreSelect''': Pre-selects which <span style="color:#0000FF">DNeutralShower</span> objects should be included in analyses.  
* Below shows how to set up DReaction for a Y(2175) analysis. 
+
* '''DChargedTrack_factory_PreSelect''': Pre-selects which <span style="color:#0000FF">DChargedTrack</span> objects should be included in analyses.  
//------------------
+
// init
+
//------------------
+
jerror_t DReaction_factory::init(void)
+
{
+
// 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
+
locReaction = new DReaction();
+
locReaction->Set_ReactionName(<span style="color:#0000FF">"Y2175"</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
+
+
_data.push_back(locReaction);
+
+
return NOERROR;
+
}
+
  
== DTrackCombo Factory ==
+
=== User Input ===
* (Would be) Located in DANA
+
* '''DReaction_factory''': Creates <span style="color:#0000FF">DReaction</span> objects to be analyzedNeeds to be created in each analysis plugin.  
** Still finalizing class format, but looks similar to DReaction, except with full particles instead of just PIDs.
+
* Generate a DTrackCombo object for each possible combination of detected tracks (DBeamPhotons ignored).
+
** 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 (PID is NOT assumed).
+
class DTrackComboStep
+
{
+
private:
+
//PIDS:
+
Particle_t dInitialParticleID; //e.g. lambda, phi, gamma
+
Particle_t dTargetParticleID; //Unknown for no target
+
deque<Particle_t> dFinalParticleIDs;
+
+
//INITIAL PARTICLES:
+
DKinematicData* dInitialParticle; //kinfit result, else measured
+
DKinematicData* dInitialParticle_Measured; //e.g. DBeamPhoton
+
DKinematicData* dTargetParticle; //NULL for no target
+
+
//FINAL PARTICLES:
+
deque<const DKinematicData*> dFinalParticles; //kinfit result, else measured //e.g. DChargedTrackHypothesis, DNeutralParticleHypothesis
+
deque<const DKinematicData*> dFinalParticles_Measured; //e.g. DChargedTrackHypothesis, DNeutralParticleHypothesis
+
deque<const JObject*> dFinalParticleSourceObjects; //original DChargedTrack or DNeutralShower objects
+
+
//CONTROL VARIABLES:
+
int dInitialParticleDecayFromStepIndex; //points to which DTrackComboStep represents the production of the initial particle (e.g. Lambda)
+
deque<int> dDecayStepIndices; //let's you know whether a final state particle is decaying, missing, or detectedif decaying, points to which DTrackComboStep represents its decay
+
  };
+
  
== DKinFitTrackCombo Factory ==
+
=== Combo Construction Factories ===
* (Would be) Located in DANA
+
* '''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.  
** Still finalizing class format, but looks similar to DReaction, except with full particles instead of just PIDs.
+
* '''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.
* Generate a DKinFitTrackCombo object for each possible combination of DTrackCombos and DBeamPhotons (ignore all DBeamPhotons "too far" from RF time).
+
* '''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.
** Perform a single, full kinematic fit testing whether the DTrackCombo matches the DReaction: includes all mass, vertex, timing constraints (vertex & timing not yet implemented).
+
  
== User Plugin DEventProcessor ==
+
=== 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 &theta; 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.).
  
<pre>
+
== Thrown Factories ==
extern "C"  
+
* '''DReaction_factory_Thrown''': Creates a <span style="color:#0000FF">DReaction</span> object representing the thrown reaction.  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.
{
+
* '''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.
void InitPlugin(JApplication *app)
+
* '''DEventRFBunch_factory_Thrown''': Creates a <span style="color:#0000FF">DEventRFBunch</span> object for the simulated event.
{
+
InitJANAPlugin(app);
+
app->AddProcessor(new DEventProcessor_Y2175());
+
app->AddFactoryGenerator(new DFactoryGenerator_DReaction());
+
}
+
} // "C"
+
  
jerror_t DEventProcessor_Y2175::evnt(JEventLoop *locEventLoop, int eventnumber)
+
== Analysis Utilities ==
{
+
vector<const DKinFitTrackCombo*> locKinFitTrackCombos;
+
locEventLoop->Get(locKinFitTrackCombos);
+
  
//DO HISTS/CUTS/TUPLES HERE
+
* '''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.
return NOERROR;
+
** 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 <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.
</pre>
+
** 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.
== Cutting/Histogramming ==
+
* '''DKinFitter_GlueX''': See [[Mattione_GlueX_Kinematic_Fitting | GlueX Kinematic Fitting]]
* Coming Soon...
+
 
+
== Tupling ==
+
* Haven't 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