Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DCustomAction_p2pi0_hists.cc
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: DCustomAction_p2pi0_hists.cc
4 // Created: Wed Jan 21 16:53:41 EST 2015
5 // Creator: jrsteven (on Linux ifarm1401 2.6.32-431.el6.x86_64 x86_64)
6 //
7 
9 
10 void DCustomAction_p2pi0_hists::Initialize(JEventLoop* locEventLoop)
11 {
12  //CREATE THE HISTOGRAMS
13  //Since we are creating histograms, the contents of gDirectory will be modified: must use JANA-wide ROOT lock
14  japp->RootWriteLock(); //ACQUIRE ROOT LOCK!!
15  {
16  //Required: Create a folder in the ROOT output file that will contain all of the output ROOT objects (if any) for this action.
17  //If another thread has already created the folder, it just changes to it.
19 
20  dEgamma = GetOrCreate_Histogram<TH1I>("Egamma", "TAGGER photon energy; E_{#gamma}", 400, 0., 12.);
21 
22  dMM2_M2pi0 = GetOrCreate_Histogram<TH2I>("MM2_M2pi0", "MM^{2} off p#pi^{0}#pi^{0} vs M_{#pi^{0}#pi^{0}}; M_{#pi^{0}#pi^{0}}; MM^{2}", 200, 0.0, 2.0, 200, -1., 1.);
23  dDeltaE_M2pi0 = GetOrCreate_Histogram<TH2I>("dDeltaE_M2pi0", "#Delta E vs M_{#pi^{0}#pi^{0}}; M_{#pi^{0}}; #Delta E (tagger - tracks)", 200, 0.0, 2.0, 200, -5., 5.);
24  dMpi0_corr = GetOrCreate_Histogram<TH2I>("Mpi0_corr", "M_{#gamma#gamma}(1) vs M_{#gamma#gamma}(2); M_{#gamma#gamma}(1); M_{#gamma#gamma}(2)", 200, 0.0, 1.0, 200, 0., 1.);
25 
26  dPhi2pi0_PhiP = GetOrCreate_Histogram<TH2I>("Phi2pi0_PhiP", "#phi_{#pi^{0}#pi^{0}} vs. #phi_{p}; #phi_{p}; #phi_{#pi^{0}#pi^{0}}", 360, -180.0, 180.0, 360, -180., 180.);
27  dDeltaPhi_M2pi0 = GetOrCreate_Histogram<TH2I>("DeltaPhi_M2pi0", "#Delta#phi vs M_{#pi^{0}#pi^{0}}; M_{#pi^{0}#pi^{0}}; #Delta#phi", 200, 0.0, 2.0, 360, 0.0, 360.0);
28 
29  dMM2_M2pi0_CoplanarTag = GetOrCreate_Histogram<TH2I>("MM2_M2pi0_CoplanarTag", "MM^{2} off p #pi^{0}#pi^{0} vs M_{#pi^{0}#pi^{0}}: Coplanar Tag; M_{#pi^{0}#pi^{0}}; MM^{2}", 200, 0.0, 2.0, 200, -1., 1.);
30  dDeltaE_M2pi0_CoplanarTag = GetOrCreate_Histogram<TH2I>("dDeltaE_M2pi0_CoplanarTag", "#Delta E vs M_{#pi^{0}#pi^{0}}: Coplanar Tag; M_{#pi^{0}#pi^{0}}; #Delta E (tagger - p#pi^{0}#pi^{0})", 200, 0.0, 2.0, 200, -5., 5.);
31  dMpi0_corr_CoplanarTag = GetOrCreate_Histogram<TH2I>("Mpi0_Corr_CoplanarTag", "M_{#gamma#gamma}(1) vs M_{#gamma#gamma}(2); M_{#gamma#gamma}(1); M_{#gamma#gamma}(2)", 200, 0.0, 1.0, 200, 0., 1.);
32 
33  dMM2_M2pi0_ProtonTag = GetOrCreate_Histogram<TH2I>("MM2_M2pi0_ProtonTag", "MM^{2} off p #pi^{0}#pi^{0} vs M_{#pi^{0}#pi^{0}}: Proton Tag; M_{#pi^{0}#pi^{0}}; MM^{2}", 200, 0.0, 2.0, 200, -1., 1.);
34  dDeltaE_M2pi0_ProtonTag = GetOrCreate_Histogram<TH2I>("dDeltaE_M2pi0_ProtonTag", "#Delta E vs M_{#pi^{0}#pi^{0}}: Proton Tag; M_{#pi^{0}#pi^{0}}; #Delta E (tagger - p#pi^{0}#pi^{0})", 200, 0.0, 2.0, 200, -5., 5.);
35  dMpi0_corr_ProtonTag = GetOrCreate_Histogram<TH2I>("Mpi0_corr_ProtonTag", "M_{#gamma#gamma}(1) vs M_{#gamma#gamma}(2); M_{#gamma#gamma}(1); M_{#gamma#gamma}(2)", 200, 0.0, 1.0, 200, 0., 1.);
36 
37  dMpi0_corr_MMTag = GetOrCreate_Histogram<TH2I>("Mpi0_corr_MMTag", "M_{#gamma#gamma}(1) vs M_{#gamma#gamma}(2); M_{#gamma#gamma}(1); M_{#gamma#gamma}(2)", 200, 0.0, 1.0, 200, 0., 1.);
38 
39  dMM2_M2pi0_Pi0Tag = GetOrCreate_Histogram<TH2I>("MM2_M2pi0_Pi0Tag", "MM^{2} off p #pi^{0}#pi^{0} vs M_{#pi^{0}#pi^{0}}: Pi0 Tag; M_{#pi^{0}#pi^{0}}; MM^{2}", 200, 0.0, 2.0, 200, -1., 1.);
40  dDeltaE_M2pi0_Pi0Tag = GetOrCreate_Histogram<TH2I>("dDeltaE_M2pi0_Pi0Tag", "#Delta E vs M_{#pi^{0}#pi^{0}}: Pi0 Tag; M_{#pi^{0}#pi^{0}}; #Delta E (tagger - p#pi^{0}#pi^{0})", 200, 0.0, 2.0, 200, -5., 5.);
41  dMM2_DeltaE_Pi0Tag = GetOrCreate_Histogram<TH2I>("dMM2_DeltaE_Pi0Tag", "MM^{2} vs #Delta E: Coplanar Tag; #Delta E (tagger - p#gamma#gamma); MM^{2}", 200, -5., 5., 200, -1., 1.);
42 
43  dEgamma_M2pi0_Pi0Tag = GetOrCreate_Histogram<TH2I>("Egamma_M2pi0_Pi0Tag", "E_{#gamma} vs M_{#pi^{0}#pi^{0}}: Pi0 Tag; M_{#pi^{0}#pi^{0}}; E_{#gamma}", 200, 0.0, 2.0, 400, 0., 12.);
44  dDalitz1_Pi0Tag = GetOrCreate_Histogram<TH2I>("Dalitz1_Pi0Tag", "Dalitz Pi0 Tag; M^{2}_{p#pi^{0}}; M^{2}_{p#pi^{0}}", 200, 1.0, 11.0, 200, 1., 11.);
45  dDalitz2_Pi0Tag = GetOrCreate_Histogram<TH2I>("Dalitz2_Pi0Tag", "Dalitz Pi0 Tag; M^{2}_{p#pi^{0}}; M^{2}_{p#pi^{0}}", 200, 1.0, 11.0, 200, 1., 11.);
46  dDalitz3_Pi0Tag = GetOrCreate_Histogram<TH2I>("Dalitz3_Pi0Tag", "Dalitz Pi0 Tag; M^{2}_{p#pi^{0}}; M^{2}_{p#pi^{0}}", 200, 1.0, 11.0, 200, 1., 11.);
47  dDalitz4_Pi0Tag = GetOrCreate_Histogram<TH2I>("Dalitz4_Pi0Tag", "Dalitz Pi0 Tag; M^{2}_{p#pi^{0}}; M^{2}_{p#pi^{0}}", 200, 1.0, 11.0, 200, 1., 11.);
48 
49 
50  dProton_dEdx_P = GetOrCreate_Histogram<TH2I>("Proton_dEdx_P","dE/dx vs p; p; dE/dx",200,0,2,500,0,5);
51  dProton_P_Theta = GetOrCreate_Histogram<TH2I>("Proton_P_Theta","p vs #theta; #theta; p (GeV/c)",180,0,180,120,0,12);
52 
53  //Return to the base directory
55  }
56  japp->RootUnLock(); //RELEASE ROOT LOCK!!
57 }
58 
59 bool DCustomAction_p2pi0_hists::Perform_Action(JEventLoop* locEventLoop, const DParticleCombo* locParticleCombo)
60 {
61  const DParticleComboStep* locParticleComboStep = locParticleCombo->Get_ParticleComboStep(0);
62 
63  // get beam photon energy and final state particles
64  const DKinematicData* locBeamPhoton = Get_UseKinFitResultsFlag() ? locParticleComboStep->Get_InitialParticle() : locParticleComboStep->Get_InitialParticle_Measured();
65  auto locParticles = Get_UseKinFitResultsFlag() ? locParticleComboStep->Get_FinalParticles() : locParticleComboStep->Get_FinalParticles_Measured();
66  double locBeamPhotonEnergy = locBeamPhoton->energy();
67 
68  // calculate missing mass
70 
71  // calculate Pi0 masses
74  DLorentzVector loc2pi0_P4 = locPi01_P4; loc2pi0_P4 += locPi02_P4;
75 
76  // reconstructed proton variables
77  double dEdx = 0.;
78  DLorentzVector locProtonP4;
79  const DChargedTrack* locChargedTrack = static_cast<const DChargedTrack*>(locParticleComboStep->Get_FinalParticle_SourceObject(2));
80  const DChargedTrackHypothesis* locChargedTrackHypothesis = locChargedTrack->Get_Hypothesis(Proton);
81  dEdx = locChargedTrackHypothesis->Get_TrackTimeBased()->dEdx()*1e6;
82  locProtonP4 = locChargedTrackHypothesis->lorentzMomentum();
83 
84  DLorentzVector locPi01P_P4 = locProtonP4; locPi01P_P4 += locPi01_P4;
85  DLorentzVector locPi02P_P4 = locProtonP4; locPi02P_P4 += locPi02_P4;
86 
87  double dEdxCut = 2.2;
88 
89  //FILL HISTOGRAMS
90  //Since we are filling histograms local to this action, it will not interfere with other ROOT operations: can use action-wide ROOT lock
91  //Note, the mutex is unique to this DReaction + action_string combo: actions of same class with different hists will have a different mutex
92  Lock_Action(); //ACQUIRE ROOT LOCK!!
93  {
94  // Fill histograms here
95  dEgamma->Fill(locBeamPhotonEnergy);
96 
97  dMM2_M2pi0->Fill(loc2pi0_P4.M(), locMissingP4.M2());
98  dDeltaE_M2pi0->Fill(loc2pi0_P4.M(),locMissingP4.E());
99  dMpi0_corr->Fill(locPi01_P4.M(), locPi02_P4.M());
100 
101  double locDeltaPhi = (locProtonP4.Phi() - loc2pi0_P4.Phi())*180./TMath::Pi();
102  if(locDeltaPhi > 360.) locDeltaPhi -= 360.;
103  if(locDeltaPhi < 0.) locDeltaPhi += 360.;
104  dPhi2pi0_PhiP->Fill(locProtonP4.Phi()*180./TMath::Pi(), loc2pi0_P4.Phi()*180./TMath::Pi());
105  dDeltaPhi_M2pi0->Fill(loc2pi0_P4.M(), locDeltaPhi);
106 
107  // require proton and omega are back-to-back
108  if(locDeltaPhi < 170. || locDeltaPhi > 190.) return true;
109  dMM2_M2pi0_CoplanarTag->Fill(loc2pi0_P4.M(), locMissingP4.M2());
110  dDeltaE_M2pi0_CoplanarTag->Fill(loc2pi0_P4.M(),locMissingP4.E());
111  dMpi0_corr_CoplanarTag->Fill(locPi01_P4.M(), locPi02_P4.M());
112 
113  // tag proton with dE/dx
114  if(dEdx > dEdxCut) {
115  dMM2_M2pi0_ProtonTag->Fill(loc2pi0_P4.M(), locMissingP4.M2());
116  dDeltaE_M2pi0_ProtonTag->Fill(loc2pi0_P4.M(),locMissingP4.E());
117  dMpi0_corr_ProtonTag->Fill(locPi01_P4.M(), locPi02_P4.M());
118  }
119 
120  // cut on pi0 masses
121  if(locPi01_P4.M() > 0.10 && locPi01_P4.M() < 0.16 && locPi02_P4.M() > 0.10 && locPi02_P4.M() < 0.16){
122  dMM2_M2pi0_Pi0Tag->Fill(loc2pi0_P4.M(), locMissingP4.M2());
123  dDeltaE_M2pi0_Pi0Tag->Fill(loc2pi0_P4.M(),locMissingP4.E());
124  dMM2_DeltaE_Pi0Tag->Fill(locMissingP4.E(), locMissingP4.M2());
125  }
126 
127  // 2pi invariant mass for exclusive
128  if(fabs(locMissingP4.M2()) < 0.05 && fabs(locMissingP4.E()) < 0.5) {
129  dMpi0_corr_MMTag->Fill(locPi01_P4.M(), locPi02_P4.M());
130 
131  if(locPi01_P4.M() > 0.10 && locPi01_P4.M() < 0.16 && locPi02_P4.M() > 0.10 && locPi02_P4.M() < 0.16){
132  dEgamma_M2pi0_Pi0Tag->Fill(loc2pi0_P4.M(), locBeamPhotonEnergy);
133  if(locBeamPhotonEnergy > 1.5 && locBeamPhotonEnergy < 2.0)
134  dDalitz1_Pi0Tag->Fill(locPi01P_P4.M2(),locPi02P_P4.M2());
135  if(locBeamPhotonEnergy > 2.0 && locBeamPhotonEnergy < 2.5)
136  dDalitz2_Pi0Tag->Fill(locPi01P_P4.M2(),locPi02P_P4.M2());
137  if(locBeamPhotonEnergy > 2.5 && locBeamPhotonEnergy < 3.0)
138  dDalitz3_Pi0Tag->Fill(locPi01P_P4.M2(),locPi02P_P4.M2());
139  if(locBeamPhotonEnergy > 3.0 && locBeamPhotonEnergy < 5.5)
140  dDalitz4_Pi0Tag->Fill(locPi01P_P4.M2(),locPi02P_P4.M2());
141  }
142  }
143 
144  if(fabs(locMissingP4.M2()) < 0.05 && fabs(locMissingP4.E()) < 0.5) {
145 
146  dProton_dEdx_P->Fill(locProtonP4.Vect().Mag(), dEdx);
147  dProton_P_Theta->Fill(locProtonP4.Vect().Theta()*180/TMath::Pi(), locProtonP4.Vect().Mag());
148 
149  if(dEdx < dEdxCut)
150  {
151  Unlock_Action(); //RELEASE ROOT LOCK!!
152  return true;
153  }
154  }
155  }
156  Unlock_Action(); //RELEASE ROOT LOCK!!
157 
158  return true; //return false if you want to use this action to apply a cut (and it fails the cut!)
159 }
vector< const DKinematicData * > Get_FinalParticles_Measured(void) const
TDirectoryFile * ChangeTo_BaseDirectory(void)
const DReaction * Get_Reaction(void) const
double energy(void) const
void Initialize(JEventLoop *locEventLoop)
const DTrackTimeBased * Get_TrackTimeBased(void) const
TDirectoryFile * CreateAndChangeTo_ActionDirectory(void)
const DKinematicData * Get_InitialParticle_Measured(void) const
TLorentzVector DLorentzVector
const DChargedTrackHypothesis * Get_Hypothesis(Particle_t locPID) const
Definition: DChargedTrack.h:59
bool Get_UseKinFitResultsFlag(void) const
JApplication * japp
DLorentzVector Calc_FinalStateP4(const DReaction *locReaction, const DParticleCombo *locParticleCombo, size_t locStepIndex, bool locUseKinFitDataFlag) const
DLorentzVector Calc_MissingP4(const DReaction *locReaction, const DParticleCombo *locParticleCombo, bool locUseKinFitDataFlag) const
vector< const DKinematicData * > Get_FinalParticles(void) const
const DAnalysisUtilities * dAnalysisUtilities
bool Perform_Action(JEventLoop *locEventLoop, const DParticleCombo *locParticleCombo)
DLorentzVector lorentzMomentum(void) const
const JObject * Get_FinalParticle_SourceObject(size_t locFinalParticleIndex) const
const DKinematicData * Get_InitialParticle(void) const
double dEdx(void) const
const DParticleComboStep * Get_ParticleComboStep(size_t locStepIndex) const