diff --git a/core/EICLundWriter.cpp b/core/EICLundWriter.cpp deleted file mode 100644 index 8d5f991..0000000 --- a/core/EICLundWriter.cpp +++ /dev/null @@ -1,95 +0,0 @@ -#include "EICLundWriter.h" -#include -#include - -namespace elSpectro{ - - ///Constructor to create ouput file and intialise data structures - EICLundWriter::EICLundWriter(const std::string &filename,long evPerFile): - _filename(filename), - _file(filename), - _eventsPerFile(evPerFile) - { - if(!_file.is_open()){ - std::cerr<<"EICLundWriter::EICLundWriter file "<GetParticle(_initialParticles[0]->Pdg())->ParticleClass()==TString("Baryon") ){ - _inTarget=_initialParticles[0]; - _inBeam=_initialParticles[1]; - } - else { - _inTarget=_initialParticles[1]; - _inBeam=_initialParticles[0]; - } - - _beamPdg=_inBeam->Pdg(); - _targetPdg=_inTarget->Pdg(); - } - /////////////////////////////////////////////////////////////// - ///Close the file stream - void EICLundWriter::End(){ - if(!_file.is_open()) return; - _file.close(); - - } - /////////////////////////////////////////////////////////////// - ///Reached max events for this file start another - void EICLundWriter::NewFile(){ - End(); - auto newfilename=TString(_filename); - newfilename.ReplaceAll(".dat",Form("__%d.dat",_nFile++)); - _file.open(newfilename.Data()); - } - - ///////////////////////////////////////////////////////////// - //write all the info required for this event - void EICLundWriter::FillAnEvent(){ - - ////fill _stream - StreamEventInfo(); - - _id=1;//reset particle ID counter - - - //final particles - int final_status=1; - for(const auto* p:_finalParticles){ - - StreamParticle(p,final_status); - - } - - _nEvent++; - - if(_nEvent%_eventsPerFile==0) - NewFile(); - } - - ///////////////////////////////////////////////////////// - - ///////////////////////////////////////////////////////// - void EICLundWriter::Write(){ - //write stream - _file<<_stream.rdbuf(); - //reset stream - _stream.clear(); - } - - -} diff --git a/core/EICLundWriter.h b/core/EICLundWriter.h deleted file mode 100644 index 1ba7c78..0000000 --- a/core/EICLundWriter.h +++ /dev/null @@ -1,86 +0,0 @@ -////////////////////////////////////////////////////////////// -/// -///Class: EICLundWriter -///Description: -/// Instance of Writer for EICLund format - -#pragma once - -#include "Writer.h" -#include -#include -#include - -namespace elSpectro{ - - class EICLundWriter : public Writer { - - - - EICLundWriter()=default; - //don't want default contructor accessible - //only declaring default constructor - //so other 5 constructors also defaulted(rule of 5) - - public: - EICLundWriter(const std::string& filename,long evPerFile=1E18); - ~EICLundWriter() final; - EICLundWriter(const EICLundWriter& other); //need the virtual destructor...so rule of 5 - EICLundWriter(EICLundWriter&&)=default; - EICLundWriter& operator=(const EICLundWriter& other); - EICLundWriter& operator=(EICLundWriter&& other) = default; - - void WriteHeader() final{}; - void FillAnEvent() final; - void Write() final; - void End() final; - void Init() final; - void NewFile(); - - private: - //streaming functions - - void StreamEventInfo(){ - // Header (Event Info): - // # of Particles, # of Target Nucleons, # of Target Protons, - // Pol. of Target, Pol. of Electron, - // BeamType, BeamEnergy,Target ID, ProcessID, Weight - - _stream<< "\t "<<_finalParticles.size()<<" "<<1<<" "<<1 - <<" "<<0.<<" "<<0. - <<" "<<_beamPdg<<" "<<_inBeam->P4().E()<<" "<<_targetPdg<<" "<< _inTarget->P4().E() <<" "<<0.<<"\n"; - } - void StreamParticle(const Particle* p,int status){ - auto p4=p->P4(); - auto ver=p->VertexPosition(); - //second entry 0. == lifetime Could add to Particle.h - //note convert vertex mm->cm - _stream<<_id++<<" "<<0.<<" "<Pdg()<<" "<<0<<" "<<0<<" " - <X()/10<<" "<Y()/10<<" "<Z()/10<<"\n"; - } - - //data members - std::ofstream _file; //! output file - //std::ostream _stream; //! output stream - std::stringstream _stream; - std::string _filename; - - long _nEvent={0}; - int _nFile={1}; - long _eventsPerFile=static_cast(1E18); - - int _id=1; - int _beamPdg=0; - int _targetPdg=0; - - const Particle* _inBeam={nullptr}; - const Particle* _inTarget={nullptr}; - - ClassDef(elSpectro::EICLundWriter,1); //class Writer - }; - - -} - diff --git a/core/EICPythiaWriter.cpp b/core/EICPythiaWriter.cpp deleted file mode 100644 index faab498..0000000 --- a/core/EICPythiaWriter.cpp +++ /dev/null @@ -1,106 +0,0 @@ -#include "EICLundWriter.h" -#include -#include - -namespace elSpectro{ - - ///Constructor to create ouput file and intialise data structures - EICPythiaWriter::EICPythiaWriter(const std::string &filename,long evPerFile): - _filename(filename), - _file(filename), - _eventsPerFile(evPerFile) - { - if(!_file.is_open()){ - std::cerr<<"EICPythiaWriter::EICPythiaWriter file "<GetParticle(_initialParticles[0]->Pdg())->ParticleClass()==TString("Baryon") ){ - _inTarget=_initialParticles[0]; - _inBeam=_initialParticles[1]; - } - else { - _inTarget=_initialParticles[1]; - _inBeam=_initialParticles[0]; - } - - _beamPdg=_inBeam->Pdg(); - _targetPdg=_inTarget->Pdg(); - } - /////////////////////////////////////////////////////////////// - ///Close the file stream - void EICPythiaWriter::End(){ - if(!_file.is_open()) return; - _file.close(); - - } - /////////////////////////////////////////////////////////////// - ///Reached max events for this file start another - void EICPythiaWriter::NewFile(){ - End(); - auto newfilename=TString(_filename); - newfilename.ReplaceAll(".dat",Form("__%d.dat",_nFile++)); - _file.open(newfilename.Data()); - } - - ///////////////////////////////////////////////////////////// - //write all the info required for this event - void EICPythiaWriter::FillAnEvent(){ - - ////fill _stream - StreamEventInfo(); - - _id=1;//reset particle ID counter - - //initial particles - int intial_status=21; - StreamParticle(_initalBeam,initial_status); - StreamParticle(_initalTarget,initial_status); - StreamParticle(&_photon,initial_status); - - //final particles - int final_status=1; - for(const auto* p:_finalParticles){ - - StreamParticle(p,final_status); - - } - _stream << "=============== Event finished ===============\n"; - - _nEvent++; - - if(_nEvent%_eventsPerFile==0) - NewFile(); - } - - ///////////////////////////////////////////////////////// - - ///////////////////////////////////////////////////////// - void EICPythiaWriter::Write(){ - //write stream - _file<<_stream.rdbuf(); - //reset stream - _stream.clear(); - } - - -} diff --git a/core/EICPythiaWriter.h b/core/EICPythiaWriter.h deleted file mode 100644 index 0b353bf..0000000 --- a/core/EICPythiaWriter.h +++ /dev/null @@ -1,91 +0,0 @@ -////////////////////////////////////////////////////////////// -/// -///Class: EICPythiaWriter -///Description: -/// Instance of Writer for EICPythia format - -#pragma once - -#include "Writer.h" -#include -#include -#include - -namespace elSpectro{ - - class EICPythiaWriter : public Writer { - - - - EICPythiaWriter()=default; - //don't want default contructor accessible - //only declaring default constructor - //so other 5 constructors also defaulted(rule of 5) - - public: - EICPythiaWriter(const std::string& filename,long evPerFile=1E18); - ~EICPythiaWriter() final; - EICPythiaWriter(const EICPythiaWriter& other); //need the virtual destructor...so rule of 5 - EICPythiaWriter(EICPythiaWriter&&)=default; - EICPythiaWriter& operator=(const EICPythiaWriter& other); - EICPythiaWriter& operator=(EICPythiaWriter&& other) = default; - - void WriteHeader() final{}; - void FillAnEvent() final; - void Write() final; - void End() final; - void Init() final; - void NewFile(); - - private: - //streaming functions - - void StreamEventInfo(){ - // Header (Event Info): - // # of Particles, # of Target Nucleons, # of Target Protons, - // Pol. of Target, Pol. of Electron, - // BeamType, BeamEnergy,Target ID, ProcessID, Weight - - _stream<<"0"<< "\t"<<_nEvent<< "\t"<<_finalParticles.size()<<"\n"; - _stream << "============================================\n"; - } - void StreamParticle(const Particle* p,int status){ - auto p4=p->P4(); - auto ver=p->VertexPosition(); - //second entry 0. == lifetime Could add to Particle.h - //note assume cm - int parent=0; - int daughter_first=0; - int daughter_last=0; - _stream<<_id++<<"\t"<Pdg()<<"\t"<X()<<"\t"<Y()<<"\t"<Z()<<"\n"; - _stream << "============================================\n"; - } - - //data members - std::ofstream _file; //! output file - //std::ostream _stream; //! output stream - std::stringstream _stream; - std::string _filename; - - long _nEvent={0}; - int _nFile={1}; - long _eventsPerFile=static_cast(1E18); - - int _id=1; - int _beamPdg=0; - int _targetPdg=0; - - const Particle* _inBeam={nullptr}; - const Particle* _inTarget={nullptr}; - Particle _photon={22}; //virtual photon pdg=22 - - ClassDef(elSpectro::EICPythiaWriter,1); //class Writer - }; - - -} -