24 const int pLeptonIsUsed = 0;
25 const int thetaIsUsed = 0;
26 const double pi = TMath::Pi();
34 const double NEvents = 1e6;
40 printf(
"Please enter neutrino energy: ");
42 printf(
"Trying to find input file for E_nu = %3.1lf GeV...\n", Enu);
44 inst->
init(Enu, type, reac);
47 std::string fname = Form(
"data/d4sigma_plot_%3.1lfGeV.root", Enu);
48 TFile *
infile =
new TFile(fname.c_str());
50 printf(
"ERROR: File not found!");
53 TH1D *dTl = (TH1D*)infile->Get(
"dsigma_dTlepton");
54 TH1D *dTk = (TH1D*)infile->Get(
"dsigma_dTkaon");
55 TH1D *dct = (TH1D*)infile->Get(
"dsigma_dcostheta");
56 TH1D *dph = (TH1D*)infile->Get(
"dsigma_dphikq");
60 if (type==1) { ml = 0.510998928e-3; strl =
"e"; }
61 else if (type==2) { ml = 0.1056583715; strl =
"#mu"; }
62 else if (type==3) { ml = 1.77682; strl =
"#tau"; }
63 else {
std::cout<<
"ERROR: Invalid lepton type!"<<std::endl;
return;}
67 if (reac==1) { mK = 0.493677; strK =
"K^{+}"; }
68 else if (reac==2) { mK = 0.497614; strK =
"K^{0}"; }
69 else if (reac==3) { mK = 0.493677; strK =
"K^{+}"; }
70 else {
std::cout<<
"ERROR: Invalid reaction!"<<std::endl;
return;}
74 if (reac==1) { mN = 0.939565379; strN0 =
"n"; strN1 =
"n"; }
75 else if (reac==2) { mN = 0.939565379; strN0 =
"n"; strN1 =
"p"; }
76 else if (reac==3) { mN = 0.938272046; strN0 =
"p"; strN1 =
"p"; }
77 else {
std::cout<<
"ERROR: Invalid reaction!"<<std::endl;
return;}
79 std::string reaction = Form(
"%.2lf GeV #nu_{%s} %s #rightarrow %s^{-} %s %s", Enu, strl.c_str(),
80 strN0.c_str(), strl.c_str(), strN1.c_str(), strK.c_str() );
83 const int NBINS = 10*COMP;
86 TH1D *hTK =
new TH1D(
"hTK",
"Kaon kinetic energy", NBINS, 0., Enu-mK-ml);
87 TH1D *hTl =
new TH1D(
"hTl",
"Lepton kinetic energy", NBINS, 0., Enu-mK-ml);
88 TH1D *hct =
new TH1D(
"hct",
"Lepton polar angle", NBINS, -1., 1.);
89 TH1D *hph =
new TH1D(
"hph",
"Kaon azimuthal angle", NBINS/5, -pi, pi);
91 TH1D *hQ2 =
new TH1D(
"hQ2",
"Momentum transfer", NBINS, 0., Enu-mK-ml);
92 TH1D *hTN =
new TH1D(
"hTN",
"Nucleon kinetic energy", NBINS, 0., Enu-mK-ml);
93 TH1D *hcl =
new TH1D(
"hcl",
"Lepton polar angle", NBINS, -1., 1.);
94 TH1D *hcK =
new TH1D(
"hcK",
"Kaon polar angle", NBINS, -1., 1.);
95 TH1D *hcN =
new TH1D(
"hcN",
"Nucleon polar angle", NBINS, -1., 1.);
96 TH1D *hpl =
new TH1D(
"hpl",
"Lepton azimuthal angle", NBINS, -pi, pi);
97 TH1D *hpK =
new TH1D(
"hpK",
"Kaon azimuthal angle", NBINS, -pi, pi);
98 TH1D *hpN =
new TH1D(
"hpN",
"Nucleon azimuthal angle", NBINS, -pi, pi);
101 double maxmom = sqrt(
pow(Enu-mK-ml + mN, 2) - mN*mN);
102 TH1D *hmoml =
new TH1D(
"hmoml",
"Lepton momentum", NBINS, 0., maxmom);
103 TH1D *hmomK =
new TH1D(
"hmomK",
"Kaon momentum", NBINS, 0., maxmom);
104 TH1D *hmomN =
new TH1D(
"hmomN",
"Nucleon momentum", NBINS, 0., maxmom);
105 TH1D *hmomlx =
new TH1D(
"hmomlx",
"Lepton momentum", NBINS, 0., maxmom);
106 TH1D *hmomKx =
new TH1D(
"hmomKx",
"Kaon momentum", NBINS, 0., maxmom);
107 TH1D *hmomNx =
new TH1D(
"hmomNx",
"Nucleon momentum", NBINS, 0., maxmom);
108 TH1D *hmomly =
new TH1D(
"hmomly",
"Lepton momentum", NBINS, 0., maxmom);
109 TH1D *hmomKy =
new TH1D(
"hmomKy",
"Kaon momentum", NBINS, 0., maxmom);
110 TH1D *hmomNy =
new TH1D(
"hmomNy",
"Nucleon momentum", NBINS, 0., maxmom);
111 TH1D *hmomlz =
new TH1D(
"hmomlz",
"Lepton momentum", NBINS, 0., maxmom);
112 TH1D *hmomKz =
new TH1D(
"hmomKz",
"Kaon momentum", NBINS, 0., maxmom);
113 TH1D *hmomNz =
new TH1D(
"hmomNz",
"Nucleon momentum", NBINS, 0., maxmom);
116 double TK_max, TK, Tl_max, Tl, pl_max, pl, costh_l, phi_l, phi_Kq,
xsec;
117 double El, theta,
Q2;
118 TLorentzVector P4_nu, P4_lep, q;
119 TVector3 lep3, p_l, p_Q, p_K, p_N, p_Kq, p_Nq;
120 double TN, EK, pK, pN;
121 double pQ, costh_Kq, theta_Kq, rot_Z, rot_X;
122 double costh_K, costh_N, phi_K, phi_N;
126 const TVector3 e1(1,0,0);
127 const TVector3 e2(0,1,0);
128 const TVector3 e3(0,0,1);
129 const TVector3 p_nu = Enu*e3;
132 for (
int i=0;
i<(int)NEvents;
i++) {
135 TK_max = Enu - mK - ml;
136 TK = TK_max*(rand()/(double)RAND_MAX);
137 Tl_max = Enu - mK - ml;
138 pl_max = sqrt((Tl_max+ml)*(Tl_max+ml)-ml*ml);
140 pl = pl_max*(rand()/(double)RAND_MAX);
141 Tl = sqrt(pl*pl+ml*ml)-ml;
143 Tl = Tl_max*(rand()/(double)RAND_MAX);
146 theta = pi*(rand()/(double)RAND_MAX);
147 costh_l = cos(theta);
149 costh_l = 2.*(rand()/(double)RAND_MAX)-1.;
150 theta = acos(costh_l);
152 phi_l = pi*(2.*(rand()/(double)RAND_MAX)-1.);
153 phi_Kq = pi*(2.*(rand()/(double)RAND_MAX)-1.);
154 xsec = inst->
diffxsec(Tl,TK,theta,phi_Kq);
162 El = Tl + ml; pl = sqrt(El*El - ml*ml);
163 EK = TK + mK; pK = sqrt(EK*EK - mK*mK);
166 P4_nu = TLorentzVector(0.,0.,Enu,Enu);
167 lep3 = TVector3(0.,0.,0.);
168 lep3.SetMagThetaPhi(pl,theta,0.);
169 P4_lep = TLorentzVector(lep3,El);
174 p_l[0] = pl*sin(theta)*cos(phi_l);
175 p_l[1] = pl*sin(theta)*sin(phi_l);
182 TVector3 dirQ = p_Q.Unit();
185 costh_Kq = (pQ*pQ + pK*pK + mN*mN - (Enu-El-EK+mN)*(Enu-El-EK+mN))/(2.*pQ*pK);
186 theta_Kq = acos(costh_Kq);
189 rot_Z = acos(e3*(p_Q.Unit()));
193 if (p_Q[1] > 0) sign = +1;
195 TVector3 p_Qt(p_Q[0],p_Q[1],0);
196 rot_X = sign*acos(e1*(p_Qt.Unit()));
199 p_Kq[0] = pK*sin(theta_Kq)*cos(phi_Kq);
200 p_Kq[1] = pK*sin(theta_Kq)*sin(phi_Kq);
201 p_Kq[2] = pK*costh_Kq;
217 TN = sqrt(pN*pN+mN*mN) - mN;
220 hmoml->Fill(pl, xsec);
221 hmomK->Fill(pK, xsec);
222 hmomN->Fill(pN, xsec);
223 hmomlx->Fill(p_l[0], xsec);
224 hmomKx->Fill(p_K[0], xsec);
225 hmomNx->Fill(p_N[0], xsec);
226 hmomly->Fill(p_l[1], xsec);
227 hmomKy->Fill(p_K[1], xsec);
228 hmomNy->Fill(p_N[1], xsec);
229 hmomlz->Fill(p_l[2], xsec);
230 hmomKz->Fill(p_K[2], xsec);
231 hmomNz->Fill(p_N[2], xsec);
234 costh_l = p_l.CosTheta();
235 costh_K = p_K.CosTheta();
236 costh_N = p_N.CosTheta();
240 p_l.RotateUz(p_l.Unit());
241 p_K.RotateUz(p_l.Unit());
242 p_N.RotateUz(p_l.Unit());
245 phi_l = p_l.Phi() - p_l.Phi();
246 phi_K = p_K.Phi() - p_l.Phi();
247 phi_N = p_N.Phi() - p_l.Phi();
251 if (!pLeptonIsUsed) xsec *= El/pl;
256 hct->Fill(costh_l, xsec);
257 hph->Fill(phi_Kq, xsec);
261 hcl->Fill(costh_l, xsec);
262 hcK->Fill(costh_K, xsec);
263 hcN->Fill(costh_N, xsec);
264 hpl->Fill(phi_l, xsec);
265 hpK->Fill(phi_K, xsec);
266 hpN->Fill(phi_N, xsec);
268 if (
i%((
int)NEvents/20)==0)
cout <<
"Processing... (" <<
i/((int)NEvents/100) <<
"%)" << endl;
272 double totalxsec = dTk->Integral();
273 hTK->Scale(totalxsec/hTK->Integral());
274 hTl->Scale(totalxsec/hTl->Integral());
275 hct->Scale(totalxsec/hct->Integral());
276 hph->Scale(totalxsec/hph->Integral());
277 hQ2->Scale(totalxsec/hQ2->Integral());
278 hTN->Scale(totalxsec/hTN->Integral());
279 hcl->Scale(totalxsec/hcl->Integral());
280 hcK->Scale(totalxsec/hcK->Integral());
281 hcN->Scale(totalxsec/hcN->Integral());
282 hpl->Scale(totalxsec/hpl->Integral());
283 hpK->Scale(totalxsec/hpK->Integral());
284 hpN->Scale(totalxsec/hpN->Integral());
287 hTK->SetLineWidth(2); hTK->SetLineColor(kRed);
288 hTl->SetLineWidth(2); hTl->SetLineColor(kRed);
289 hct->SetLineWidth(2); hct->SetLineColor(kRed);
290 hph->SetLineWidth(2); hph->SetLineColor(kRed);
291 hQ2->SetLineWidth(2);
292 hTN->SetLineWidth(2); hTN->SetLineColor(kOrange);
293 hcl->SetLineWidth(2); hcl->SetLineColor(kRed);
294 hcK->SetLineWidth(2); hcK->SetLineColor(kBlack);
295 hcN->SetLineWidth(2); hcN->SetLineColor(kOrange);
296 hpl->SetLineWidth(2); hpl->SetLineColor(kRed);
297 hpK->SetLineWidth(2); hpK->SetLineColor(kBlack);
298 hpN->SetLineWidth(2); hpN->SetLineColor(kOrange);
299 hmoml->SetLineWidth(2); hmoml->SetLineColor(kRed);
300 hmomK->SetLineWidth(2); hmomK->SetLineColor(kBlack);
301 hmomN->SetLineWidth(2); hmomN->SetLineColor(kOrange);
303 hmomlx->SetLineWidth(2); hmomlx->SetLineColor(kRed);
304 hmomKx->SetLineWidth(2); hmomKx->SetLineColor(kBlack);
305 hmomNx->SetLineWidth(2); hmomNx->SetLineColor(kOrange);
306 hmomly->SetLineWidth(2); hmomly->SetLineColor(kRed);
307 hmomKy->SetLineWidth(2); hmomKy->SetLineColor(kBlack);
308 hmomNy->SetLineWidth(2); hmomNy->SetLineColor(kOrange);
309 hmomlz->SetLineWidth(2); hmomlz->SetLineColor(kRed);
310 hmomKz->SetLineWidth(2); hmomKz->SetLineColor(kBlack);
311 hmomNz->SetLineWidth(2); hmomNz->SetLineColor(kOrange);
314 gStyle->SetOptStat(0);
328 hcl->SetMinimum(0); hcK->SetMinimum(0); hcN->SetMinimum(0);
329 hpl->SetMinimum(0); hpK->SetMinimum(0); hpN->SetMinimum(0);
331 hmoml->SetMinimum(0); hmomK->SetMinimum(0); hmomN->SetMinimum(0);
334 hTK->SetMaximum(1.2*
max(hTK->GetMaximum(),dTk->GetMaximum()));
335 hTl->SetMaximum(1.2*
max(hTl->GetMaximum(),dTl->GetMaximum()));
336 hct->SetMaximum(1.2*
max(hct->GetMaximum(),dct->GetMaximum()));
337 hph->SetMaximum(1.2*
max(hph->GetMaximum(),dph->GetMaximum()));
342 TCanvas *
c1 =
new TCanvas(
"c1",
"Kinematics of single kaon production", 1200, 900);
343 c1->SetTitle(reaction.c_str());
346 for (
int k=0;
k<4;
k++) {
347 p[
k] = (TPad*)c1->GetPad(
k+1);
348 if (logscale) p[
k]->SetLogy();
351 hTl->SetXTitle(
"T_{#mu} [GeV]");
352 hTl->Draw(); dTl->Draw(
"same");
354 hTK->SetXTitle(
"T_{K} [GeV]");
355 hTK->Draw(); dTk->Draw(
"same");
357 hct->SetXTitle(
"cos(#theta_{#mu}) [ ]");
358 hct->Draw(); dct->Draw(
"same");
360 hph->SetXTitle(
"#phi_{Kq} [rad]");
361 hph->Draw(); dph->Draw(
"same");
362 c1->Print((
"images/kinematics_"+outname+
"01_input.png").c_str()); c1->Close();
365 TCanvas *
c2 =
new TCanvas(
"c2",
"Q^2", 1200, 900);
366 c2->SetTitle(reaction.c_str());
369 for (
int k=0;
k<4;
k++) {
370 p[
k] = (TPad*)c2->GetPad(
k+1);
371 if (logscale) p[
k]->SetLogy();
374 hQ2->SetTitle(
"Momentum transfer to nucleon"); hQ2->SetXTitle(
"Q^{2} [GeV^{2}]");
375 hQ2->SetMaximum(1.2*hQ2->GetMaximum());
378 hTl->SetTitle(
"Kinetic energy of particle"); hTl->SetXTitle(
"T_{x} [GeV]");
379 hTl->SetLineColor(kRed); hTK->SetLineColor(kBlack);
380 hTl->SetMaximum(
max(1.2*hTN->GetMaximum(),
max(hTl->GetMaximum(),hTK->GetMaximum())));
381 hTl->Draw(); hTK->Draw(
"same"); hTN->Draw(
"same");
383 hcl->SetTitle(
"Polar angle w.r.t. neutrino"); hcl->SetXTitle(
"cos(#theta_{#nux}) [ ]");
384 hcl->SetMaximum(1.2*
max(hcN->GetMaximum(),
max(hcl->GetMaximum(),hcK->GetMaximum())));
385 hcl->Draw(); hcK->Draw(
"same"); hcN->Draw(
"same");
387 hpl->SetTitle(
"Azimuthal angle w.r.t. lepton"); hpl->SetXTitle(
"#phi_{lx} [rad]");
388 hpl->SetMaximum(1.2*
max(hpK->GetMaximum(),hpN->GetMaximum()));
389 hpl->Draw(); hpK->Draw(
"same"); hpN->Draw(
"same");
390 c2->Print((
"images/kinematics_"+outname+
"02_output.png").c_str()); c2->Close();
393 TCanvas *c3 =
new TCanvas(
"c3",
"Momenta in lab frame", 1200, 900);
394 c3->SetTitle(reaction.c_str());
396 for (
int k=0;
k<4;
k++) {
397 p[
k] = (TPad*)c3->GetPad(
k+1);
398 if (logscale) p[
k]->SetLogy();
401 hmomlx->SetTitle(
"X-momentum"); hmomlx->SetXTitle(
"p_{x} [GeV/c]");
402 hmomlx->SetMaximum(1.2*
max(hmomKx->GetMaximum(),hmomlx->GetMaximum()));
403 hmomlx->Draw(); hmomKx->Draw(
"same"); hmomNx->Draw(
"same");
405 hmomly->SetTitle(
"Y-momentum"); hmomly->SetXTitle(
"p_{y} [GeV/c]");
406 hmomly->SetMaximum(1.2*
max(hmomKy->GetMaximum(),hmomly->GetMaximum()));
407 hmomly->Draw(); hmomKy->Draw(
"same"); hmomNy->Draw(
"same");
409 hmomlz->SetTitle(
"Z-momentum"); hmomlz->SetXTitle(
"p_{z} [GeV/c]");
410 hmomlz->SetMaximum(1.2*
max(hmomKz->GetMaximum(),hmomlz->GetMaximum()));
411 hmomlz->Draw(); hmomKz->Draw(
"same"); hmomNz->Draw(
"same");
413 hmoml->SetTitle(
"Total momentum"); hmoml->SetXTitle(
"|p| [GeV/c]");
414 hmoml->SetMaximum(1.2*
max(hmomK->GetMaximum(),hmoml->GetMaximum()));
415 hmoml->Draw(); hmomK->Draw(
"same"); hmomN->Draw(
"same");
416 c3->Print((
"images/kinematics_"+outname+
"03_momenta.png").c_str()); c3->Close();
419 TFile* outfile =
new TFile((
"data/kinematics_"+outname+
"validation.root").c_str(),
"RECREATE");
421 hTl->Write(
"T_lepton");
422 hTK->Write(
"T_kaon");
423 hTN->Write(
"T_nucleon");
425 hct->Write(
"cos(theta_lepton)");
426 hcK->Write(
"cos(theta_kaon)");
427 hcN->Write(
"cos(theta_nucleon)");
430 hpK->Write(
"phi_kaon");
431 hpN->Write(
"phi_nucleon");
433 hph->Write(
"phi_Kq");
434 hQ2->Write(
"Q_squared");
448 if (hmoml)
delete hmoml;
449 if (hmomK)
delete hmomK;
450 if (hmomN)
delete hmomN;
451 if (hmomlx)
delete hmomlx;
452 if (hmomKx)
delete hmomKx;
453 if (hmomNx)
delete hmomNx;
454 if (hmomly)
delete hmomly;
455 if (hmomKy)
delete hmomKy;
456 if (hmomNy)
delete hmomNy;
457 if (hmomlz)
delete hmomlz;
458 if (hmomKz)
delete hmomKz;
459 if (hmomNz)
delete hmomNz;
460 if (inst)
delete inst;
double Q2(const Interaction *const i)
the ParameterSet object passed in for the configuration of a destination should be the only source that can affect the behavior of that destination This is to eliminate the dependencies of configuring a destination from multiple mostly from the defaults It suppresses possible glitches about changing the configuration file somewhere outside of a destination segament might still affect the behavior of that destination In the previous configuration for a specific the value of a certain e may come from following and have been suppressed It the configuring ParameterSet object for each destination will be required to carry a parameter list as complete as possible If a parameter still cannot be found in the ParameterSet the configuration code will go look for a hardwired default directly The model is a great simplicity comparing with the previous especially when looking for default values Another great advantage is most of the parameters now have very limited places that allows to appear Usually they can only appear at one certain level in a configuration file For in the old configuring model or in a default ParameterSet object inside of a or in a category or in a severity object This layout of multiple sources for a single parameter brings great confusion in both writing a configuration and in processing the configuration file Under the new the only allowed place for the parameter limit to appear is inside of a category which is inside of a destination object Other improvements simplify the meaning of a destination name In the old a destination name has multiple folds of meanings the e cout and cerr have the special meaning of logging messages to standard output or standard error the name also serves as the output filename if the destination is a file these names are also references to look up for detailed configurations in configuring the MessageFacility The multi purpose of the destination name might cause some unwanted behavior in either writing or parsing the configuration file To amend in the new model the destination name is now merely a name for a which might represent the literal purpose of this or just an id All other meanings of the destinations names now go into the destination ParameterSet as individual such as the type parameter and filename parameter Following is the deatiled rule for the new configuring Everything that is related with MessageFacility configuration must be wrapped in a single ParameterSet object with the name MessageFacility The MessageFacility ParameterSet object contains a series of top level parameters These parameters can be chosen a vector of string listing the name of debug enabled models Or use *to enable debug messages in all modules a vector of string a vector of string a vector of string a ParameterSet object containing the list of all destinations The destinations ParameterSet object is a combination of ParameterSet objects for individual destinations There are two types of destinations that you can insert in the destinations ParameterSet ordinary including cout
double diffxsec(double Tlep, double Tkaon, double theta, double phikq)
these are called *plugin *libraries Plugin libraries are loaded by the *LibraryManager *see above The source file in which a module is implemented must be named< module > _plugin cc It must contain an invocation of the *DEFINE_EDM_PLUGIN *macro The *DEFINE_EDM_PLUGIN *macro is responsible for writing the appropriate *factory **function and that takes a const reference to a *ParameterSet *and that returns a newly created instance of the associated module type
operation and maintenance manual for MessageLogger MessageService General Work Flow of a Message The effect of a user issuing a which has been configured to filter these in some way and to dispatch the messages to one or more destinations This section will outline the steps involved The user code may be running in opne or more each of which might issue messages We will call these the client side In any a single the picks up on these messages and forwards them to the looger one at a time
ParameterSet &ps const ParameterSet const * p
void init(double Etot, int type, int reac)
T max(sqlite3 *const db, std::string const &table_name, std::string const &column_name)