21 #include <gsl/gsl_const.h>
22 #include <gsl/gsl_randist.h>
24 #include <boost/foreach.hpp>
31 const double C_light = GSL_CONST_MKS_SPEED_OF_LIGHT / 1e7;
44 cout <<
Name() <<
" random seed: " << seed << endl;
59 ostringstream hname, htit;
63 ntupprim =
new TNtuple(
"prim",
"Primaries",
"pid:phi:theta:eta:e:p");
64 ntupsec =
new TNtuple(
"sec",
"Secondaries",
"pid:phi:theta:eta:e:p");
65 ntupt =
new TNtuple(
"tnt",
"G4Hits",
"ID:t:dtotal");
66 ntupsigma =
new TNtuple(
"sigma",
"Sigmas",
"mass:inv1:inv2:inv3:t:tres");
69 TH1 *
h1 =
new TH1F(
"edep1GeV",
"edep 0-1GeV",1000,0,1);
71 h1 =
new TH1F(
"edep100GeV",
"edep 0-100GeV",1000,0,100);
79 ostringstream nodename;
81 map<int, PHG4Particle*>::const_iterator particle_iter;
82 PHG4TruthInfoContainer *_truth_container = findNode::getClass<PHG4TruthInfoContainer>(topNode,
"G4TruthInfo");
83 if (_truth_container->
size() > 3)
91 float ntvars[6] = {0};
93 particle_iter != primary_range.second; ++particle_iter)
97 ntvars[0] = particle->
get_pid();
98 ntvars[1] = atan2(particle->
get_py(), particle->
get_px());
99 ntvars[2] = atan(sqrt(particle->
get_py()*particle->
get_py() +
106 ntvars[3] = 0.5*log((particle->
get_e()+particle->
get_pz())/
108 ntvars[4] = particle->
get_e();
109 ntvars[5] = sqrt(particle->
get_py()*particle->
get_py() +
112 sigmass = sqrt(ntvars[4]*ntvars[4] - ntvars[5]*ntvars[5]);
118 bool anti_neutron_ok =
false;
119 bool piminus_ok =
false;
120 int anti_neutron_trk_id = 0;
122 double anti_neutron_mom = NAN;
134 double p_scale = NAN;
135 double e_an_tof = NAN;
136 double e_an_tof_tres = NAN;
137 double p_scale_tres = NAN;
145 particle_iter != secondary_range.second; ++particle_iter)
148 ntvars[0] = particle->
get_pid();
149 ntvars[1] = atan2(particle->
get_py(), particle->
get_px());
150 ntvars[2] = atan(sqrt(particle->
get_py()*particle->
get_py() +
157 ntvars[3] = 0.5*log((particle->
get_e()+particle->
get_pz())/
159 ntvars[4] = particle->
get_e();
160 ntvars[5] = sqrt(particle->
get_py()*particle->
get_py() +
164 if (particle->
get_pid() == -211)
169 px_pi = particle->
get_px();
170 py_pi = particle->
get_py();
171 pz_pi = particle->
get_pz();
173 else if (particle->
get_pid() == -2112)
175 anti_neutron_ok =
true;
177 anti_neutron_mom = ntvars[5];
179 px_an = particle->
get_px();
180 py_an = particle->
get_py();
181 pz_an = particle->
get_pz();
187 if (! (piminus_ok && anti_neutron_ok))
191 set<string>::const_iterator iter;
192 vector<TH1 *>::const_iterator eiter;
196 hits = findNode::getClass<PHG4HitContainer>(topNode,
"G4HIT_CALO");
206 if (hit_iter->second->get_trkid() == anti_neutron_trk_id)
209 t_ave = hit_iter->second->get_avg_t();
210 double dtotal =
get_dtotal(hit_iter->second, ntvars[0],ntvars[1]);
211 ntupt->Fill(hit_iter->second->get_layer(),t_ave,dtotal);
212 double dist = sqrt(hit_iter->second->get_avg_x()*hit_iter->second->get_avg_x()+
213 hit_iter->second->get_avg_y()*hit_iter->second->get_avg_y()+
214 hit_iter->second->get_avg_z()*hit_iter->second->get_avg_z());
215 double beta = dist/t_ave/
C_light;
216 double neutMom =
MASSNEUTRON * beta / sqrt(1.0 - beta*beta);
219 p_scale = neutMom/anti_neutron_mom;
221 double beta_tres = dist/t_res/
C_light;
222 double neutMom_tres = MASSNEUTRON * beta_tres / sqrt(1.0 - beta_tres*beta_tres);
223 e_an_tof_tres = sqrt(neutMom_tres*neutMom_tres+MASSNEUTRON*MASSNEUTRON);
224 p_scale_tres = neutMom_tres/anti_neutron_mom;
229 double im2a =
MASSNEUTRON*
MASSNEUTRON +MASSPION*MASSPION +2*(e_an_tof * E_pi - ((px_an*p_scale)*px_pi+(py_an*p_scale)*py_pi+(pz_an*p_scale)*pz_pi));
230 double im2b =
MASSNEUTRON*
MASSNEUTRON +MASSPION*MASSPION +2*(e_an_tof_tres * E_pi - ((px_an*p_scale_tres)*px_pi+(py_an*p_scale_tres)*py_pi+(pz_an*p_scale_tres)*pz_pi));
232 ntupsigma->Fill(sigmass,sqrt(im2),sqrt(im2a),sqrt(im2b),t_ave,t_res);
269 double diffphi = phi_hit -
phi;
274 else if (diffphi < - M_PI)
282 double difftheta = theta_hit-
theta;
283 double deltasqrt = sqrt(diffphi*diffphi+difftheta*difftheta);