Index: trunk/include/eXevent.h
===================================================================
--- trunk/include/eXevent.h (revision 12)
+++ trunk/include/eXevent.h (revision 13)
@@ -1,84 +1,86 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright 2017
//
// This file is part of estarlight.
//
// starlight 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, either version 3 of the License, or
// (at your option) any later version.
//
// starlight 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 starlight. If not, see .
//
///////////////////////////////////////////////////////////////////////////
//
// File and Version Information:
// $Rev:: 263 $: revision of last commit
// $Author:: mlomnitz $: author of last commit
// $Date:: 02/28/2017 #$: date of last commit
//
// Description:
//
// Container for eXEvents
//
//
///////////////////////////////////////////////////////////////////////////
#ifndef eXEVENT_H
#define eXEVENT_H
#include
#include "starlightconstants.h"
#include "starlightparticle.h"
class eXEvent
{
public:
eXEvent();
eXEvent(starlightConstants::event &ev);
~eXEvent();
void addParticle(starlightParticle &part) { _particles.push_back(part); }
void addVertex(vector3 &vertex) { _vertices.push_back(vertex); }
void addGamma(lorentzVector gamma,float egamma, float Q2) { _gamma.push_back(gamma); _gammaEnergies.push_back(egamma); _gammaMasses.push_back(Q2); }
void addSourceElectron(lorentzVector &el){ _sources.push_back(el); }
void addScatteredTarget( lorentzVector &target, double t){ _target.push_back(target); _vertext.push_back(t);}
const std::vector * getParticles() const { return &_particles; }
const std::vector * getVertices() const { return &_vertices; }
const std::vector * getGammaEnergies() const { return &_gammaEnergies; }
const std::vector * getSources() const { return &_sources;}
const std::vector * getGammaMasses() const {return &_gammaMasses; }
const std::vector * getGamma() const { return &_gamma; }
const std::vector * getTarget() const{ return &_target; }
const std::vector * getVertext() const{ return &_vertext; }
eXEvent & operator=(const eXEvent&);
eXEvent & operator+(const eXEvent&);
void boost(double rapidity, double e_rapiditya);
+ void flipZ();
+
private:
std::vector _particles;
std::vector _vertices;
std::vector _sources;
std::vector _target;
std::vector _vertext;
std::vector _gammaMasses;
std::vector _gammaEnergies;
std::vector _gamma;
};
#endif // UPCEVENT_H
Index: trunk/src/eXevent.cpp
===================================================================
--- trunk/src/eXevent.cpp (revision 12)
+++ trunk/src/eXevent.cpp (revision 13)
@@ -1,126 +1,141 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright 2017
//
// This file is part of estarlight.
//
// starlight 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, either version 3 of the License, or
// (at your option) any later version.
//
// starlight 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 starlight. If not, see .
//
///////////////////////////////////////////////////////////////////////////
//
// File and Version Information:
// $Rev:: 263 $: revision of last commit
// $Author:: mlomnitz $: author of last commit
// $Date:: 02/28/2017 #$: date of last commit
//
// Description:
//
// Container for eX eventrs
//
//
///////////////////////////////////////////////////////////////////////////
#include "eXevent.h"
eXEvent::eXEvent() :
_particles(0)
,_vertices(0)
{ }
eXEvent::eXEvent(starlightConstants::event &ev) :
_particles(0)
,_vertices(0)
{
for(int i = 0; i < ev._numberOfTracks; i++)
{
starlightParticle p(
ev.px[i],
ev.py[i],
ev.pz[i],
starlightConstants::UNKNOWN,
starlightConstants::UNKNOWN,
ev._fsParticle[i],
ev._charge[i]
);
addParticle(p);
}
}
eXEvent::~eXEvent()
{ }
eXEvent& eXEvent::operator=(const eXEvent& rhs)
{
if(this != &rhs)
{
this->_particles = rhs._particles;
this->_vertices = rhs._vertices;
this->_gammaEnergies = rhs._gammaEnergies;
this->_sources = rhs._sources;
this->_target = rhs._target;
this->_vertext = rhs._vertext;
}
return *this;
}
eXEvent& eXEvent::operator+(const eXEvent& ev)
{
for(unsigned int n = 0; n < ev._particles.size(); n++)
{
this->_particles.push_back(ev._particles.at(n));
}
for(unsigned int n = 0; n < ev._vertices.size(); n++)
{
this->_vertices.push_back(ev._vertices.at(n));
}
for(unsigned int n = 0; n < ev._gammaEnergies.size(); n++)
{
this->_gammaEnergies.push_back(ev._gammaEnergies.at(n));
}
for(unsigned int n = 0; n_sources.push_back(ev._sources.at(n));
}
for(unsigned int n = 0; n_target.push_back(ev._target.at(n));
}
for(unsigned int n = 0; n_vertext.push_back(ev._vertext.at(n));
}
return *this;
}
void eXEvent::boost(double rapidity, double e_rapidity)
{
vector3 boostVector(0, 0, tanh(rapidity));
vector3 electron_boostVector(0, 0, tanh(e_rapidity));
//
std::vector::iterator part = _particles.begin();
for (part = _particles.begin(); part != _particles.end(); part++)
{
(*part).Boost(boostVector);
}
std::vector::iterator ele = _sources.begin();
for( ele = _sources.begin(); ele != _sources.end(); ++ele){
(*ele).Boost(electron_boostVector);
}
std::vector::iterator target = _target.begin();
for( target = _target.begin(); target != _target.end(); ++target){
(*target).Boost(boostVector);
}
}
+
+void eXEvent::flipZ()
+{
+
+ std::vector::iterator part = _particles.begin();
+
+ for (part = _particles.begin(); part != _particles.end(); part++)
+ {
+ lorentzVector v = (*part).getVertex();
+ (*part).SetXYZT( -1.0*(*part).GetPx(), -1.0*(*part).GetPy() , -1.0*(*part).GetPz() ,(*part).GetE() );
+ (*part).setVertex( lorentzVector(-1.0*v.GetPx(),-1.0*v.GetPy(),-1.0*v.GetPz(),v.GetE()) );
+
+ }
+
+}
Index: trunk/src/e_starlightStandalone.cpp
===================================================================
--- trunk/src/e_starlightStandalone.cpp (revision 12)
+++ trunk/src/e_starlightStandalone.cpp (revision 13)
@@ -1,180 +1,187 @@
//////////////////////////////////////////////////////////////////////////
//
// Copyright 2010
//
// This file is part of starlight.
//
// starlight 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, either version 3 of the License, or
// (at your option) any later version.
//
// starlight 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 starlight. If not, see .
//
///////////////////////////////////////////////////////////////////////////
//
// File and Version Information:
// $Rev:: 270 $: revision of last commit
// $Author:: jnystrand $: author of last commit
// $Date:: 2016-07-08 16:31:51 +0100 #$: date of last commit
//
// Description:
//
//
//
///////////////////////////////////////////////////////////////////////////
#include
-
#include
#include "reportingUtils.h"
#include "e_starlight.h"
#include "inputParameters.h"
#include "eventfilewriter.h"
#include "e_starlightStandalone.h"
using namespace std;
e_starlightStandalone::e_starlightStandalone()
: _configFileName ("slight.in"),
_starlight (0),
_nmbEventsTot (1),
_nmbEventsPerFile (_nmbEventsTot)
{ }
e_starlightStandalone::~e_starlightStandalone()
{ }
bool
e_starlightStandalone::init()
{
_inputParameters = new inputParameters();
// read input parameters from config file
_inputParameters->configureFromFile(_configFileName);
if (!_inputParameters->init()) {
printWarn << "problems initializing input parameters. cannot initialize starlight." << endl;
return false;
}
// copy input file to one with baseFileName naming scheme
std::string inputCopyName, _baseFileName;
_baseFileName = _inputParameters->baseFileName();
if (_baseFileName != "slight") {
inputCopyName = _baseFileName +".in";
ofstream inputCopyFile;
inputCopyFile.open(inputCopyName.c_str());
std::ifstream infile(_configFileName.c_str());
if ((!infile) || (!infile.good()))
{
return -1;
}
int lineSize = 256;
char tmp[lineSize];
while (!infile.getline(tmp, lineSize).eof())
{
cout << tmp << endl;
inputCopyFile << tmp << endl;
}
inputCopyFile.close();
}
// get the number of events
// for now we write everything to one file
_nmbEventsTot = _inputParameters->nmbEvents();
_nmbEventsPerFile = _nmbEventsTot;
// create the starlight object
_starlight = new e_starlight();
// give starlight the input parameters
_starlight->setInputParameters(_inputParameters);
// initialize starlight
return _starlight->init();
}
bool
e_starlightStandalone::run()
{
if (!_starlight) {
printWarn << "null pointer to starlight object. make sure that init() was called. "
<< "cannot generate events." << endl;
return false;
}
// open output file
eventFileWriter fileWriter;
fileWriter.writeFullPythiaInfo(_inputParameters->pythiaFullEventRecord());
_baseFileName = _inputParameters->baseFileName();
_eventDataFileName = _baseFileName +".out";
fileWriter.open(_eventDataFileName);
//
fileWriter.writeInit(*_inputParameters);
//
printInfo << "generating events:" << endl;
unsigned int nmbEvents = 0;
std::chrono::steady_clock::time_point begin= std::chrono::steady_clock::now();
while (nmbEvents < _nmbEventsTot) {
for (unsigned int iEvent = 0; (iEvent < _nmbEventsPerFile) && (nmbEvents < _nmbEventsTot);
++iEvent, ++nmbEvents) {
progressIndicator(iEvent, _nmbEventsTot, true, 4);
eXEvent event = _starlight->produceEvent();
// Boost event from back to lab reference frame
boostEvent(event);
+ // flipZEvent(event);
fileWriter.writeEvent(event, iEvent);
}
}
std::chrono::steady_clock::time_point end= std::chrono::steady_clock::now();
float running_total = 1E-3*std::chrono::duration_cast(end - begin).count();
cout<<"Total time "<nmbAttempts() == 0 )return true;
double _branchingRatio = _inputParameters->inputBranchingRatio();
printInfo << "number of attempts = " << _starlight->nmbAttempts() << ", "
<< "number of accepted events = " << _starlight->nmbAccepted() << endl;
double selectedCrossSection =
((double)_starlight->nmbAccepted()/_starlight->nmbAttempts())*_branchingRatio*_starlight->getTotalCrossSection();
if (selectedCrossSection > 1.){
cout<< " The cross section of the generated sample is "< 1.){
cout<< " The cross section of the generated sample is "<<1.E3*selectedCrossSection<<" mb."< 1.){
cout<< " The cross section of the generated sample is "<<1.E6*selectedCrossSection<<" microbarn."< 1.){
cout<< " The cross section of the generated sample is "<<1.E9*selectedCrossSection<<" nanobarn."< 1.){
cout<< " The cross section of the generated sample is "<<1.E12*selectedCrossSection<<" picobarn."<beam1LorentzGamma());
double rap2 = -acosh(_inputParameters->beam2LorentzGamma());
double boost = (rap1+rap2)/2.;
event.boost(boost, rap2); // Boost back to laboratory reference frame. Electron initially in target frame and V.M. in CMS
// Assuming electron is beam1
+
+
}
+
+void e_starlightStandalone::flipZEvent(eXEvent &event)
+{
+ event.flipZ(); //Change all z to -z
+}