Analysis DReaction

From GlueXWiki
Revision as of 21:52, 25 September 2014 by Pmatt (Talk | contribs) (Comboing Cuts)

Jump to: navigation, search


  • Note: The objects (not the factory) are located in: $HALLD_HOME/src/libraries/ANALYSIS/
  • DReactionStep: Contains the particle types for an interaction or decay step in a reaction.
    • The particle types are from the Particle_t enum defined in sim-recon/src/libraries/include/particleType.h
  • DReaction: Contains the DReactionStep objects for a reaction, along with (optional) analysis actions/instructions.
  • DReaction_factory: Users should create the DReaction objects they want to study in this factory, and place it in their plugin.
    • It is recommended that users create their class with a unique name and corresponding tag so that multiple analysis plugins can be run simultaneously.
  • The perl script can be used to create template code for a new plugin.

DReaction Notes

  • The user should create a DReaction object in their plugin for each analysis they want to perform (can analyze more than one at once). For example, by creating additional DReaction objects you can:
    • Analyze different reactions in the same plugin.
    • Treat different particles as missing in the same reaction (or have no particles missing).
    • Perform different kinematic fits to the same reaction (e.g. compare results from p4-only and vertex-p4 fits)
    • Perform different DAnalysisActions to compare the results from having different cuts.
  • IMPORTANT NOTE FOR DEVELOPERS: Grabbing the DReaction objects from JANA is tricky, because a user may have several factories per plugin, or may be running several plugins at once. See DParticleComboBlueprint_factory::evnt() for an example on how to correctly grab all DReaction objects from JANA.

DReactionStep Notes

  • The DReactionStep objects must be added to the DReaction in the correct order: the decay step for a particle must always be after its production step (it can be anywhere after it, but it must be after it).
    • However, you can study (for example) π0 decays without a π0 production step if you don't care how they're produced. E.g.:
//pi0 -> gamma, gamma
DReaction* locReaction = new DReaction("pi0"); //unique name
DReactionStep* locReactionStep = new DReactionStep();
  • To define one of the particles as missing, when adding the particle add the optional "true" flag:
locReactionStep->Add_FinalParticleID(Proton, true); //missing proton
  • IMPORTANT NOTE FOR ANALYZERS: Resonance PIDs (except for ω and φ) are not allowed anywhere in a DReactionStep. This is because you cannot identify on an event-by-event basis which particles decayed from a resonance and which did not. However, since they are extremely narrow, the ω and φ resonances are allowed.
  • IMPORTANT NOTE FOR ANALYZERS: The Unknown PID can only be used as an initial particle (for when you don't want to worry about beam particle selection) or as a missing final state particle. If a kinematic fit with a P4 constraint is selected, then four-momentum will not be constrained but any mass constraints still will be (inclusive kinematic fit).
  • To disable a mass constraint from being applied during a kinematic fit, call the following on the DReactionStep where that particle is the initial particle:

Setting up DReactionStep Example: b1pi

jerror_t DReaction_factory_b1pi_hists::init(void)
  DReactionStep* locReactionStep;
  DReaction* locReaction = new DReaction("b1pi"); //unique name
/**************************************************** b1pi Steps ****************************************************/
  //g, p -> omega, pi-, pi+, (p)
  locReactionStep = new DReactionStep();
  locReactionStep->Add_FinalParticleID(omega); //omega
  locReactionStep->Add_FinalParticleID(PiMinus); //pi-
  locReactionStep->Add_FinalParticleID(PiPlus); //pi+
  locReactionStep->Add_FinalParticleID(Proton, true); //proton missing
  //omega -> pi+, pi-, pi0
  locReactionStep = new DReactionStep();
  //pi0 -> gamma, gamma
  locReactionStep = new DReactionStep();

DReaction Control Variables

Kinematic Fit Type

  • Defined by the DKinFitType enum in sim-recon/src/libraries/Analysis/DKinFitResults.h
    • Values: d_NoFit, d_P4Fit, d_VertexFit, d_SpacetimeFit, d_P4AndVertexFit, d_P4AndSpacetimeFit
    • P4 fits include mass constraints
    • The spacetime fits are currently unsupported.

TTree Output

  • Output the results from the analysis of a DReaction is disabled by default, and must be enabled for each desired DReaction. This enabling is in addition to actually writing out the TTree (see Standard TTree for details). To enable TTree output for a DReaction, call:
locReaction->Enable_TTreeOutput("tree_b1pi.root"); //string is output file name (must end in ".root"!!)
  • Note that if you specify more than one DReaction to have the same file name, then they will both be saved in the same file.
  • You can set a threshold on the thrown/reconstructed matching FOM for the ROOT TTree. Matches below this cut will not be registered in the TTree. Default cut is -1.0 (all matches included).
locReaction->Set_MinThrownMatchFOMForROOT(5.73303E-7); //+/- 5 sigma

Comboing Cuts

  • There are several different cuts the user can place to cut out potential particle combinations that are "obviously" invalid before they are created.
  • These are useful for reducing memory usage spikes and cpu-time, especially in events with many (10+) garbage tracks/showers (in some cases the # of DParticleCombos can exceed 20000)
  • Most of these cuts are disabled by default.
  • The values of these cuts are overridden if specified on the command line.
DReaction set/enable method Command-line parameter Default Comment
Set_MaxExtraGoodTracks(size_t) COMBO:MAX_EXTRA_GOOD_TRACKS disabled Maximum # extra good charged particles. Good tracks are ones that survive the DChargedTrack "PreSelect" (or user custom) factory.
Set_MinChargedPIDFOM(double) COMBO:MIN_CHARGED_PID_FOM disabled Minimum charged particle PID confidence level.
Set_MinPhotonPIDFOM(double) COMBO:MIN_PHOTON_PID_FOM disabled Minimum photon particle PID confidence level.
Set_MaxPhotonRFDeltaT(double) COMBO:MAX_PHOTON_RF_DELTAT disabled Maximum photon-RF time difference. For selecting potential beam photon(s) during high-luminosity running.
Set_MinProtonMomentum(double) COMBO:MIN_PROTON_MOMENTUM enabled, 0.25 GeV/c Minimum momentum for a DChargedTrack without a "Proton" hypothesis (e.g. failed tracking: slow pion) to be tested as a proton during comboing (default value from track reconstruction).

  • In addition, you can make cuts on the invariant mass of a particle decay during combo creation. For neutrals, the event start vertex (and time for massive particles) from DVertex are used to calculate the momentum.
    • An example cut on the π0 invariant mass:
// Loose Pi0 Invariant Mass Cut (from 0.08 to 0.19), applied during blueprint construction
locReaction->Set_InvariantMassCut(Pi0, 0.08, 0.19);
  • Finally, you can use objects inheriting from DAnalysisAction to place cuts on the particle combinations just as they are created (but before they are saved). Note that you CANNOT call actions that require kinematic fit results: they will be ignored.
    • Details on DAnalysisAction objects can be found at: Analysis Actions
    • An example cut on the missing mass squared of the reaction (missing particle is proton):
// Loose missing mass squared cut, applied just after creating the combination (before saving it)
   //Cut from -0.1 to 2.56, "false" means use measured data. 
locReaction->Add_ComboPreSelectionAction(new DCutAction_MissingMassSquared(locReaction, false, -0.1, 2.56));

Custom Track / Shower Pre-selection

  • Users can place custom cuts to select a subset of the reconstructed DChargedTrack and DNeutralShower objects. To do this, create factories in your plugin(s) that perform the desired cuts. Tracks and showers that survive these cuts should be copied and saved as data members of those factories. Then, specify which factories you would like to use on the command line with "COMBO:TRACK_SELECT_TAG" and "COMBO:SHOWER_SELECT_TAG". For example:
  hd_root dana_rest.hddm -PPLUGINS=b1pi_hists -PCOMBO:TRACK_SELECT_TAG:MyTracks -PCOMBO:SHOWER_SELECT_TAG:MyShowers
  • Example: A pre-selection factory cutting on the DNeutralShower energy (where "MyShowers" is the factory tag):
jerror_t DNeutralShower_factory_MyShowers::init(void)
  //Setting this flag makes it so that JANA does not delete the objects in _data.  This factory will manage this memory. 
    //This is because some/all of these pointers are just copied from earlier objects, and should not be deleted.  
  return NOERROR;
jerror_t DNeutralShower_factory_MyShowers::evnt(JEventLoop* locEventLoop, int locEventNumber)
  //Clear previous memory
    //IF YOUR FACTORY CREATES NEW OBJECTS: be sure to manually delete them since NOT_OBJECT_OWNER is set. 
  //Grab already pre-selected showers. 
  vector<const DNeutralShower*> locNeutralShowers;
  locEventLoop->Get(locNeutralShowers, "PreSelect");
  //Place further cuts
  for(size_t loc_i = 0; loc_i < locNeutralShowers.size(); ++loc_i)
    if(locNeutralShowers[loc_i]->dEnergy < 0.02) //e.g. 20 MeV
    _data.push_back(locNeutralShowers[loc_i]); //save a copy of the shower
  return NOERROR;
  • Tell JANA that your factory exists by setting it in your plugin's factory generator:
jerror_t GenerateFactories(jana::JEventLoop *loop)
  loop->AddFactory(new DReaction_factory_b1pi_hists());
  loop->AddFactory(new DNeutralShower_factory_MyShowers());
  return NOERROR;
  • Enable the usage of these factories for your DReaction:
locReaction->Set_NeutralShowerFactoryTag("MyShowers"); //factory tag
locReaction->Set_ChargedTrackFactoryTag("MyTracks"); //factory tag
  • Flags used to enable the usage of the desired factories for all DReactions via the command line:

Example: b1pi

// continuation of DReaction_factory_b1pi_hists::init()
/**************************************************** b1pi Control Variables ****************************************************/
  // Type of kinematic fit to perform:
  locReaction->Set_KinFitType(d_P4AndVertexFit); //enum defined in DKinFitResults.h
  // Highly Recommended: When generating particle combinations, reject all tracks with a tracking confidence level < 0.27% (+/- 3-sigma)
  // Highly Recommended: When generating particle combinations, reject all tracks without a matching hit in a detector system (ST/TOF/BCAL/FCAL)
  // Highly Recommended: When generating particle combinations, reject all neutral particles with a PID confidence level < 5.73303E-7 (+/- 5-sigma)
  // Enable ROOT TTree Output
  locReaction->Enable_TTreeOutput("tree_b1pi.root"); //string is file name (must end in ".root"!!)

Adding DAnalysisActions to DReaction Example: b1pi

// continuation of DReaction_factory_b1pi_hists::init()
/**************************************************** b1pi Actions ****************************************************/
  locReaction->Add_AnalysisAction(new DHistogramAction_PID(locReaction));
  locReaction->Add_AnalysisAction(new DCutAction_CombinedPIDFOM(locReaction, 0.01)); //1%
  //Kinematic Fit Results and Confidence Level Cut
  locReaction->Add_AnalysisAction(new DHistogramAction_KinFitResults(locReaction, 0.05)); //5% confidence level cut on pull histograms only
  locReaction->Add_AnalysisAction(new DCutAction_KinFitFOM(locReaction, 0.01)); //1%
  //Constrained Mass Distributions
  locReaction->Add_AnalysisAction(new DHistogramAction_MissingMass(locReaction, false, 650, 0.3, 1.6, "PostKinFit")); //false: measured data
  locReaction->Add_AnalysisAction(new DHistogramAction_InvariantMass(locReaction, Pi0, false, 500, 0.0, 0.5, "Pi0_PostKinFit")); //false: measured data
  //omega mass
  locReaction->Add_AnalysisAction(new DHistogramAction_InvariantMass(locReaction, omega, true, 600, 0.2, 1.4, "omega_PostKinFit")); //true: kinfit data
  //resonance masses
  locReaction->Add_AnalysisAction(new DCustomAction_HistMass_b1_1235(locReaction, true)); //true: kinfit data
  locReaction->Add_AnalysisAction(new DCustomAction_HistMass_X_2000(locReaction, true)); //true: kinfit data
  _data.push_back(locReaction); //Register the DReaction
  return NOERROR;