Index: trunk/examples/sartreTest.cpp
===================================================================
--- trunk/examples/sartreTest.cpp (revision 378)
+++ trunk/examples/sartreTest.cpp (revision 379)
@@ -1,542 +1,542 @@
//==============================================================================
// sartreTest.cpp
//
// Copyright (C) 2010-2019 Tobias Toll and Thomas Ullrich
//
// This file is part of Sartre.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation.
// This program is distributed in the hope that it will be useful,
// but without any warranty; without even the implied warranty of
// merchantability or fitness for a particular purpose. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
//
// Author: Thomas Ullrich
// Last update:
// $Date$
// $Author$
//==============================================================================
//
// Developer test program. Checks individual components.
// Should not be in the distribution.
//
//==============================================================================
#include "EventGeneratorSettings.h"
#include "Table.h"
#include
#include "TParticlePDG.h"
#include "TRandom2.h"
#include "Event.h"
#include "ExclusiveFinalStateGenerator.h"
#include "Kinematics.h"
#include "FrangibleNucleus.h"
#include "Enumerations.h"
#include "TableCollection.h"
#include "Sartre.h"
#include
#include
#include "TFile.h"
#include "TH3D.h"
#include "TH2D.h"
#include "Nucleus.h"
using namespace std;
#define PR(x) cout << #x << " = " << (x) << endl;
//#define TEST_SETTINGS
//#define TEST_WRITETABLE
//#define TEST_READTABLE
//#define TEST_BREAKUP
//#define TEST_FINALSTATE
//#define TEST_TABLECOLLECTION
//#define TEST_GENERATOR
//#define TEST_INTERPOLATE
//#define TEST_SLOPE
//#define TEST_CROSSSECTION
#define TEST_GLAUBER
//#define TEST_UPC_TABLE
#if defined(TEST_INTERPOLATE)
struct InterTestPoint {
double t, Q2, W2, value;
};
#endif
#if defined(TEST_SLOPE)
struct InterTestSlope {
double t, Q2, W2, slope;
};
#endif
#if defined(TEST_UPC_TABLE)
double testfun(double x, double t)
{
return fabs(log(x)*exp(t)*(exp(t)+x)+sin(t*300));
}
#endif
int main()
{
#if defined(TEST_SETTINGS)
//
// Test Settings
//
EventGeneratorSettings* settings = EventGeneratorSettings::instance();
settings->readSettingsFromFile("sartreRuncard.txt");
settings->setVerbose(true);
settings->setVerboseLevel(3);
settings->list();
//
// Test PDG lookup
//
TParticlePDG *part = settings->lookupPDG(113);
PR(part->Mass());
PR(part->ParticleClass());
PR(part->GetName());
#endif
//
// Test reading tables
//
#if defined(TEST_READTABLE)
Table table1, table2;
table1.read("table1.root");
table2.read("table2.root");
table3.read("table3.root");
table1.list(cout, false);
table2.list(cout, false);
table3.list(cout, false);
#endif
#if defined (TEST_UPC_TABLE)
cout << "Creating UPC tables" << endl;
Table tableA;
Table tableA2;
int n1 = tableA.create(50, 1e-5, 0.2, // x
100, -0.051, 0, // t
true, false, true, // bool logx, bool logt, bool logContent,
mean_A, transverse, 197, 411, bSat, HMPZ, "tableA.root");
int n2 = tableA2.create(1000, 1e-5, 0.2,
1000, -0.051, 0,
true, false, true,
mean_A2, transverse, 197, 411, bSat, HMPZ, "tableA2.root");
cout << "Filling UPC tables" << endl;
double xpom, t;
for (int i=0; ieBeam();
event.particles[1].p = settings->hBeam();
generator.generate(443, 0, -event.t, event.y, event.Q2, false, &event);
cout << endl;
event.list();
cout << endl;
#endif
#if defined(TEST_BREAKUP)
FrangibleNucleus kern(208, true);
kern.normalizationOfT();
TLorentzVector someVec(0.5, 0.3, 99., sqrt(0.5*0.5+0.3*0.3+99.*99.)+0.01);
kern.breakup(someVec);
kern.listBreakupProducts();
kern.breakup(someVec);
kern.listBreakupProducts();
kern.breakup(someVec);
kern.listBreakupProducts();
#endif
#if defined(TEST_TABLECOLLECTION)
TableCollection coll;
coll.init(197, bSat, 443);
PR(coll.minQ2());
PR(coll.maxQ2());
PR(coll.minW2());
PR(coll.maxW2());
PR(coll.minW());
PR(coll.maxW());
PR(coll.minT());
PR(coll.maxT());
#endif
#if defined(TEST_GENERATOR)
Sartre sartre;
sartre.init("sartreRuncard.txt");
Event *myEvent = sartre.generateEvent();
myEvent->list();
PR(sartre.totalCrossSection());
#endif
#if defined(TEST_INTERPOLATE)
TableCollection coll;
coll.init(1, bSat, 22);
vector vector_L;
ifstream ifs("../testing/dvcs/randomPoints_L.txt");
double t, Q2, W2, val;
while (ifs.good() && !ifs.eof()) {
ifs >> t >> Q2 >> W2 >> val;
if (ifs.eof()) break;
InterTestPoint point;
point.t = t;
point.Q2 = Q2;
point.W2 = W2;
point.value = val;
vector_L.push_back(point);
}
vector vector_L2;
ifstream ifs2("../testing/dvcs/randomPoints_L2.txt");
while (ifs2.good() && !ifs2.eof()) {
ifs2 >> t >> Q2 >> W2 >> val;
if (ifs2.eof()) break;
InterTestPoint point;
point.t = t;
point.Q2 = Q2;
point.W2 = W2;
point.value = val;
vector_L2.push_back(point);
}
vector vector_T;
ifstream ifs3("../testing/dvcs/randomPoints_T.txt");
while (ifs3.good() && !ifs3.eof()) {
ifs3 >> t >> Q2 >> W2 >> val;
if (ifs3.eof()) break;
InterTestPoint point;
point.t = t;
point.Q2 = Q2;
point.W2 = W2;
point.value = val;
vector_T.push_back(point);
}
vector vector_T2;
ifstream ifs4("../testing/dvcs/randomPoints_T2.txt");
while (ifs4.good() && !ifs4.eof()) {
ifs4 >> t >> Q2 >> W2 >> val;
if (ifs4.eof()) break;
InterTestPoint point;
point.t = t;
point.Q2 = Q2;
point.W2 = W2;
point.value = val;
vector_T2.push_back(point);
}
PR(vector_T.size());
PR(vector_T2.size());
PR(vector_L.size());
PR(vector_L2.size());
TFile *hfile = new TFile("interTest.root","RECREATE");
TH1D histoL("histoL", "L", 100, -0.1, 0.1);
for (unsigned int i=0; iWrite();
hfile->Close();
#endif
#if defined(TEST_SLOPE)
//
// For this test need to remove jacobian in CrossSection::logDerivateOfAmplitude()
// and make the method public
//
TableCollection coll;
coll.init(1, bSat, 443);
CrossSection xSection(&coll);
vector vector_L;
ifstream ifs("randomPoints_dAdW2L.txt");
double t, Q2, W2, val;
while (ifs.good() && !ifs.eof()) {
ifs >> t >> Q2 >> W2 >> val;
if (ifs.eof()) break;
InterTestSlope point;
point.t = t;
point.Q2 = Q2;
point.W2 = W2;
point.slope = val;
vector_L.push_back(point);
}
vector vector_T;
ifstream ifs2("randomPoints_dAdW2T.txt");
while (ifs2.good() && !ifs2.eof()) {
ifs2 >> t >> Q2 >> W2 >> val;
if (ifs2.eof()) break;
InterTestSlope point;
point.t = t;
point.Q2 = Q2;
point.W2 = W2;
point.slope = val;
vector_T.push_back(point);
}
PR(vector_T.size());
PR(vector_L.size());
TFile *hfile = new TFile("slopeTest.root","RECREATE");
TH1D histoL("histoL", "L", 100, -0.1, 0.1);
for (unsigned int i=0; iWrite();
hfile->Close();
#endif
#if defined(TEST_CROSSSECTION)
Sartre sartre;
EventGeneratorSettings* settings = sartre.runSettings();
bool useCorrections = true;
settings->setVerbose(true);
settings->setVerboseLevel(1);
settings->setNumberOfEvents(0);
settings->setTimesToShow(0);
settings->setQ2min(1);
settings->setQ2max(2);
settings->setWmin(64);
settings->setWmax(65);
settings->setVectorMesonId(333);
settings->setElectronBeamEnergy(20);
settings->setHadronBeamEnergy(100);
settings->setA(1);
settings->setDipoleModelType(bNonSat);
settings->setCorrectForRealAmplitude(true);
settings->setCorrectSkewedness(true);
settings->setEnableNuclearBreakup(false);
settings->setMaxLambdaUsedInCorrections(0.2);
// settings->list();
bool ok = sartre.init();
if (!ok) {
cout << "Initialization of sartre failed." << endl;
return 0;
}
// Normalize Sartre cross-section
double sartreCS = sartre.totalCrossSection();
cout << "sartreCS = " << sartreCS << endl;
#endif
#if defined(TEST_GLAUBER)
Nucleus deuteron(2);
Nucleus lead(208);
lead.normalizationOfT();
deuteron.normalizationOfT();
/*
TFile *hfile = new TFile("glauberTest.root","RECREATE");
TH1D h1("h1","Density", 300, 0, 15.);
TH2D h2xy("h2xy","xy", 60, -15, 15., 60, -15., 15.);
TH2D h2xz("h2xz","xz", 60, -15, 15., 60, -15., 15.);
TH2D h2yz("h2yz","yz", 60, -15, 15., 60, -15., 15.);
TH2D h2xy_1("h2xy_1","xy", 60, -15, 15., 60, -15., 15.);
TH2D h2xz_1("h2xz_1","xz", 60, -15, 15., 60, -15., 15.);
TH2D h2yz_1("h2yz_1","yz", 60, -15, 15., 60, -15., 15.);
TH2D h2xy_2("h2xy_2","xy", 60, -15, 15., 60, -15., 15.);
TH2D h2xz_2("h2xz_2","xz", 60, -15, 15., 60, -15., 15.);
TH2D h2yz_2("h2yz_2","yz", 60, -15, 15., 60, -15., 15.);
TH2D h2xy_3("h2xy_3","xy", 60, -15, 15., 60, -15., 15.);
TH2D h2xz_3("h2xz_3","xz", 60, -15, 15., 60, -15., 15.);
TH2D h2yz_3("h2yz_3","yz", 60, -15, 15., 60, -15., 15.);
double binsize = h1.GetBinWidth(1);
NewNucleus nucleus(208);
vector nucleons;
const unsigned int numberOfNuclei = 100000;
for (unsigned int i=0; i < numberOfNuclei; i++) {
if (i%10000 == 0) cout << i << endl;
nucleus.generate();
nucleons = nucleus.configuration();
for (unsigned int k=0; kWrite();
hfile->Close();
cout << "Histograms written to file 'glauberTest.root'" << endl;
*/
#endif
return 0;
}