Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DReaction_factory_p2pi_hists.cc
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: DReaction_factory_p2pi_hists.cc
4 // Created: Wed Mar 11 20:34:14 EDT 2015
5 // Creator: jrsteven (on Linux halldw1.jlab.org 2.6.32-504.8.1.el6.x86_64 x86_64)
6 //
7 
9 
10 //------------------
11 // brun
12 //------------------
13 jerror_t DReaction_factory_p2pi_hists::brun(JEventLoop* locEventLoop, int32_t locRunNumber)
14 {
15  vector<double> locBeamPeriodVector;
16  locEventLoop->GetCalib("PHOTON_BEAM/RF/beam_period", locBeamPeriodVector);
17  dBeamBunchPeriod = locBeamPeriodVector[0];
18 
19  return NOERROR;
20 }
21 
22 //------------------
23 // init
24 //------------------
25 jerror_t DReaction_factory_p2pi_hists::evnt(JEventLoop* locEventLoop, uint64_t locEventNumber)
26 {
27  // Make as many DReaction objects as desired
28  DReactionStep* locReactionStep = NULL;
29  DReaction* locReaction = new DReaction("p2pi_pmiss"); //needs to be a unique name for each DReaction object, CANNOT (!) be "Thrown"
30 
31  // DOCUMENTATION:
32  // ANALYSIS library: https://halldweb1.jlab.org/wiki/index.php/GlueX_Analysis_Software
33  // DReaction factory: https://halldweb1.jlab.org/wiki/index.php/Analysis_DReaction
34 
35  /**************************************************** p2pi_preco Reaction Steps ****************************************************/
36 
37  bool unused = false;
38  locReaction = new DReaction("p2pi_preco"); //needs to be a unique name for each DReaction object, CANNOT (!) be "Thrown"
39 
40  // g, p -> pi+, pi- ,p
41  locReactionStep = new DReactionStep();
42  locReactionStep->Set_InitialParticleID(Gamma);
43  locReactionStep->Set_TargetParticleID(Proton);
44  locReactionStep->Add_FinalParticleID(Proton);
45  locReactionStep->Add_FinalParticleID(PiPlus);
46  locReactionStep->Add_FinalParticleID(PiMinus);
47  locReaction->Add_ReactionStep(locReactionStep);
48  dReactionStepPool.push_back(locReactionStep); //register so will be deleted later: prevent memory leak
49 
50  /**************************************************** p2pi_preco Control Settings ****************************************************/
51 
52  // Event Store
53  locReaction->Set_EventStoreSkims("2q+,q-"); // boolean-AND of skims
54 
55  // Kinematic Fit
56  //locReaction->Set_KinFitType(d_NoFit); //simultaneously constrain apply four-momentum conservation, invariant masses, and common-vertex constraints
57 
58  // Highly Recommended: When generating particle combinations, reject all beam photons that match to a different RF bunch
59  locReaction->Set_NumPlusMinusRFBunches(0);
60 
61  /**************************************************** p2pi_preco Analysis Actions ****************************************************/
62 
63  // Recommended: Analysis actions automatically performed by the DAnalysisResults factories to histogram useful quantities.
64  //These actions are executed sequentially, and are executed on each surviving (non-cut) particle combination
65  //Pre-defined actions can be found in ANALYSIS/DHistogramActions.h and ANALYSIS/DCutActions.h
66 
67  // PID
68  locReaction->Add_AnalysisAction(new DHistogramAction_PID(locReaction, false));
69 
70  // Custom histograms for p2pi
71  locReaction->Add_AnalysisAction(new DCustomAction_p2pi_hists(locReaction, false));
72 
73  //MISSING MASS
74  locReaction->Add_AnalysisAction(new DHistogramAction_MissingMassSquared(locReaction, false, 1000, -0.1, 0.1));
75  locReaction->Add_AnalysisAction(new DCutAction_MissingMassSquared(locReaction, false, -0.01, 0.005));
76 
77  // RHO
78  deque<Particle_t> locRhoPIDs; locRhoPIDs.push_back(PiPlus); locRhoPIDs.push_back(PiMinus);
79  locReaction->Add_AnalysisAction(new DHistogramAction_InvariantMass(locReaction, 0, locRhoPIDs, false, 900, 0.3, 1.2, "Rho"));
80 
81  if(unused)
82  {
83  // Custom cuts (can be applied in TSelector)
84  locReaction->Add_AnalysisAction(new DCustomAction_p2pi_cuts(locReaction, false));
85 
86  // Diagnostics for unused tracks and showers with final selection (only useful when analyzing EVIO data)
87  locReaction->Add_AnalysisAction(new DCustomAction_p2pi_unusedHists(locReaction, false, "Unused"));
88  }
89 
90  // Kinematics of final selection
91  locReaction->Add_AnalysisAction(new DHistogramAction_ParticleComboKinematics(locReaction, false)); //false: fill histograms with measured particle data
92 
93  _data.push_back(locReaction); //Register the DReaction with the factory
94 
95 
96 
97  /**************************************************** p2pi_preco_kinfit Reaction Steps ****************************************************/
98 
99  locReaction = new DReaction("p2pi_preco_kinfit"); //needs to be a unique name for each DReaction object, CANNOT (!) be "Thrown"
100 
101  // g, p -> pi+, pi- ,p
102  locReaction->Add_ReactionStep(locReactionStep);
103 
104  /**************************************************** p2pi_preco_kinfit Control Settings ****************************************************/
105 
106  // Event Store
107  locReaction->Set_EventStoreSkims("2q+,q-"); // boolean-AND of skims
108 
109  // Kinematic Fit
110  locReaction->Set_KinFitType(d_P4AndVertexFit); //simultaneously constrain apply four-momentum conservation, invariant masses, and common-vertex constraints
111 
112  // Highly Recommended: When generating particle combinations, reject all beam photons that match to a different RF bunch
113  locReaction->Set_NumPlusMinusRFBunches(0);
114 
115  /**************************************************** p2pi_preco_kinfit Analysis Actions ****************************************************/
116 
117  // Recommended: Analysis actions automatically performed by the DAnalysisResults factories to histogram useful quantities.
118  //These actions are executed sequentially, and are executed on each surviving (non-cut) particle combination
119  //Pre-defined actions can be found in ANALYSIS/DHistogramActions.h and ANALYSIS/DCutActions.h
120 
121  // PID
122  locReaction->Add_AnalysisAction(new DHistogramAction_PID(locReaction, false));
123 
124  //MASSES
125  locReaction->Add_AnalysisAction(new DHistogramAction_MissingMassSquared(locReaction, false, 1000, -0.1, 0.1));
126  locReaction->Add_AnalysisAction(new DHistogramAction_InvariantMass(locReaction, 0, locRhoPIDs, false, 900, 0.3, 1.2, "Rho"));
127  locReaction->Add_AnalysisAction(new DHistogramAction_InvariantMass(locReaction, 0, locRhoPIDs, true, 900, 0.3, 1.2, "Rho_KinFit"));
128 
129  // Kinematic Fit Results
130  locReaction->Add_AnalysisAction(new DHistogramAction_KinFitResults(locReaction, 0.05, true)); //5% confidence level cut on pull histograms only
131  locReaction->Add_AnalysisAction(new DCutAction_KinFitFOM(locReaction, 5.73303E-7)); // confidence level cut //+/- 5 sigma
132 
133  // MASSES, POST-KINFIT
134  locReaction->Add_AnalysisAction(new DHistogramAction_MissingMassSquared(locReaction, false, 1000, -0.1, 0.1, "PostKinFitCut"));
135  locReaction->Add_AnalysisAction(new DHistogramAction_InvariantMass(locReaction, 0, locRhoPIDs, false, 900, 0.3, 1.2, "Rho_PostKinFitCut"));
136  locReaction->Add_AnalysisAction(new DHistogramAction_InvariantMass(locReaction, 0, locRhoPIDs, true, 900, 0.3, 1.2, "Rho_KinFit_PostKinFitCut"));
137 
138  // Kinematics of final selection
139  locReaction->Add_AnalysisAction(new DHistogramAction_ParticleComboKinematics(locReaction, false)); //false: fill histograms with measured particle data
140 
141  _data.push_back(locReaction); //Register the DReaction with the factory
142 
143  return NOERROR;
144 }
145 
146 //------------------
147 // fini
148 //------------------
150 {
151  for(size_t loc_i = 0; loc_i < dReactionStepPool.size(); ++loc_i)
152  delete dReactionStepPool[loc_i]; //cleanup memory
153  return NOERROR;
154 }
155 
jerror_t fini(void)
Called after last event of last event source has been processed.
void Add_ReactionStep(const DReactionStep *locReactionStep)
Definition: DReaction.h:48
void Set_NumPlusMinusRFBunches(size_t locNumPlusMinusRFBunches)
Definition: DReaction.h:57
deque< DReactionStep * > dReactionStepPool
jerror_t evnt(JEventLoop *locEventLoop, uint64_t locEventNumber)
void Set_KinFitType(DKinFitType locKinFitType)
Definition: DReaction.h:53
void Set_EventStoreSkims(string locEventStoreSkims)
Definition: DReaction.h:72
jerror_t brun(JEventLoop *locEventLoop, int32_t locRunNumber)
void Add_FinalParticleID(Particle_t locPID, bool locIsMissingFlag=false)
void Set_InitialParticleID(Particle_t locPID, bool locIsMissingFlag=false)
void Add_AnalysisAction(DAnalysisAction *locAnalysisAction)
Definition: DReaction.h:50
void Set_TargetParticleID(Particle_t locPID)
Definition: DReactionStep.h:76