Namespace encapsulated evb with name EventBuilder

This commit is contained in:
Gordon McCann 2021-12-15 12:08:12 -05:00
parent 1c6addb941
commit b9ed82a593
39 changed files with 3177 additions and 3061 deletions

View File

@ -14,7 +14,9 @@ Then, in the `build` directory, run the following command to build and install t
`cmake -DCMAKE_BUILD_TYPE=Release .. && make install` `cmake -DCMAKE_BUILD_TYPE=Release .. && make install`
This will compile and link all event builder programs and dependencies. The executables will be installed to the `bin` directory of the SPS_SABRE_EventBuilder directory, shared libraries for ROOT dictionaries will be in the `lib` directory (with necessary .pcm files), and the header files for the shared libraries will be installed to the `include` directory. This will compile and link all event builder programs and dependencies. The executables will be installed to the `bin` directory of the SPS_SABRE_EventBuilder directory, shared libraries for ROOT dictionaries will be in the `lib` directory (with necessary .pcm files), and the header files for the shared libraries will be installed to the `include` directory. To rebuild the program after a change to the code (assuming no files were added), simply run
`make clean && make install`
## GWMEVB vs. GWMEVB_CL ## GWMEVB vs. GWMEVB_CL
There are two programs provided. They are `EventBuilderGui` and `EventBuilder`. The first is a full GUI version of the event builder. The GUI supports all conversion methods and the plotting tool. There are two programs provided. They are `EventBuilderGui` and `EventBuilder`. The first is a full GUI version of the event builder. The GUI supports all conversion methods and the plotting tool.

View File

@ -94,7 +94,7 @@ private:
TGPopupMenu *fFileMenu; TGPopupMenu *fFileMenu;
EVBApp fBuilder; EventBuilder::EVBApp fBuilder;
int counter; int counter;
UInt_t MAIN_W, MAIN_H; UInt_t MAIN_W, MAIN_H;

View File

@ -9,21 +9,23 @@
#include "EventBuilder.h" #include "EventBuilder.h"
#include "ChannelMap.h" #include "ChannelMap.h"
ChannelMap::ChannelMap() : namespace EventBuilder {
m_validFlag(false)
{
}
ChannelMap::ChannelMap(const std::string& name) : ChannelMap::ChannelMap() :
m_validFlag(false) m_validFlag(false)
{ {
}
ChannelMap::ChannelMap(const std::string& name) :
m_validFlag(false)
{
FillMap(name); FillMap(name);
} }
ChannelMap::~ChannelMap() {} ChannelMap::~ChannelMap() {}
bool ChannelMap::FillMap(const std::string& name) bool ChannelMap::FillMap(const std::string& name)
{ {
std::ifstream input(name); std::ifstream input(name);
if(!input.is_open()) if(!input.is_open())
{ {
@ -91,4 +93,5 @@ bool ChannelMap::FillMap(const std::string& name)
input.close(); input.close();
m_validFlag = true; m_validFlag = true;
return m_validFlag; return m_validFlag;
}
} }

View File

@ -9,16 +9,17 @@
#ifndef CHANNELMAP_H #ifndef CHANNELMAP_H
#define CHANNELMAP_H #define CHANNELMAP_H
//Detector part/type identifiers for use in the code namespace EventBuilder {
enum DetType //Detector part/type identifiers for use in the code
{ enum DetType
{
Sabre, Sabre,
FocalPlane, FocalPlane,
NoneType NoneType
}; };
enum DetAttribute enum DetAttribute
{ {
ScintLeft, ScintLeft,
ScintRight, ScintRight,
AnodeFront, AnodeFront,
@ -40,19 +41,19 @@ enum DetAttribute
SabreWedge3, SabreWedge3,
SabreWedge4, SabreWedge4,
NoneAttr NoneAttr
}; };
struct Channel struct Channel
{ {
DetType type; DetType type;
DetAttribute attribute; //What kind of detector we're looking at DetAttribute attribute; //What kind of detector we're looking at
int local_channel; //Which specific piece of detector we're looking at int local_channel; //Which specific piece of detector we're looking at
}; };
class ChannelMap class ChannelMap
{ {
public: public:
typedef std::unordered_map<int, Channel> Containter; typedef std::unordered_map<int, Channel> Containter;
typedef std::unordered_map<int, Channel>::iterator Iterator; typedef std::unordered_map<int, Channel>::iterator Iterator;
@ -65,10 +66,10 @@ public:
inline Iterator End() { return m_cmap.end(); }; inline Iterator End() { return m_cmap.end(); };
inline bool IsValid() { return m_validFlag; }; inline bool IsValid() { return m_validFlag; };
private: private:
Containter m_cmap; Containter m_cmap;
bool m_validFlag; bool m_validFlag;
}; };
}
#endif #endif

View File

@ -11,37 +11,39 @@
#include "EventBuilder.h" #include "EventBuilder.h"
#include "CompassFile.h" #include "CompassFile.h"
CompassFile::CompassFile() : namespace EventBuilder {
CompassFile::CompassFile() :
m_filename(""), bufferIter(nullptr), bufferEnd(nullptr), m_smap(nullptr), hitUsedFlag(true), m_file(std::make_shared<std::ifstream>()), eofFlag(false) m_filename(""), bufferIter(nullptr), bufferEnd(nullptr), m_smap(nullptr), hitUsedFlag(true), m_file(std::make_shared<std::ifstream>()), eofFlag(false)
{ {
m_buffersize = bufsize*hitsize; m_buffersize = bufsize*hitsize;
hitBuffer.resize(m_buffersize); hitBuffer.resize(m_buffersize);
} }
CompassFile::CompassFile(const std::string& filename) : CompassFile::CompassFile(const std::string& filename) :
m_filename(""), bufferIter(nullptr), bufferEnd(nullptr), m_smap(nullptr), hitUsedFlag(true), m_file(std::make_shared<std::ifstream>()), eofFlag(false) m_filename(""), bufferIter(nullptr), bufferEnd(nullptr), m_smap(nullptr), hitUsedFlag(true), m_file(std::make_shared<std::ifstream>()), eofFlag(false)
{ {
m_buffersize = bufsize*hitsize; m_buffersize = bufsize*hitsize;
hitBuffer.resize(m_buffersize); hitBuffer.resize(m_buffersize);
Open(filename); Open(filename);
} }
CompassFile::CompassFile(const std::string& filename, int bsize) : CompassFile::CompassFile(const std::string& filename, int bsize) :
m_filename(""), bufferIter(nullptr), bufferEnd(nullptr), m_smap(nullptr), hitUsedFlag(true), m_filename(""), bufferIter(nullptr), bufferEnd(nullptr), m_smap(nullptr), hitUsedFlag(true),
bufsize(bsize), m_file(std::make_shared<std::ifstream>()), eofFlag(false) bufsize(bsize), m_file(std::make_shared<std::ifstream>()), eofFlag(false)
{ {
m_buffersize = bufsize*hitsize; m_buffersize = bufsize*hitsize;
hitBuffer.resize(m_buffersize); hitBuffer.resize(m_buffersize);
Open(filename); Open(filename);
} }
CompassFile::~CompassFile() CompassFile::~CompassFile()
{ {
Close(); Close();
} }
void CompassFile::Open(const std::string& filename) void CompassFile::Open(const std::string& filename)
{ {
eofFlag = false; eofFlag = false;
hitUsedFlag = true; hitUsedFlag = true;
m_filename = filename; m_filename = filename;
@ -58,18 +60,18 @@ void CompassFile::Open(const std::string& filename)
{ {
m_file->seekg(0, std::ios_base::beg); m_file->seekg(0, std::ios_base::beg);
} }
} }
void CompassFile::Close() void CompassFile::Close()
{ {
if(IsOpen()) if(IsOpen())
{ {
m_file->close(); m_file->close();
} }
} }
int CompassFile::GetHitSize() int CompassFile::GetHitSize()
{ {
if(!IsOpen()) if(!IsOpen())
{ {
std::cerr<<"Unable to get hit size due to file not being open!"<<std::endl; std::cerr<<"Unable to get hit size due to file not being open!"<<std::endl;
@ -89,18 +91,18 @@ int CompassFile::GetHitSize()
return 24 + nsamples*16; return 24 + nsamples*16;
} }
/* /*
GetNextHit() is the function which... gets the next hit GetNextHit() is the function which... gets the next hit
Has to check if the buffer needs refilled/filled for the first time Has to check if the buffer needs refilled/filled for the first time
Upon pulling a hit, sets the UsedFlag to false, letting the next level know Upon pulling a hit, sets the UsedFlag to false, letting the next level know
that the hit should be free game. that the hit should be free game.
If the file cannot be opened, signals as though file is EOF If the file cannot be opened, signals as though file is EOF
*/ */
bool CompassFile::GetNextHit() bool CompassFile::GetNextHit()
{ {
if(!IsOpen()) return true; if(!IsOpen()) return true;
if((bufferIter == nullptr || bufferIter == bufferEnd) && !IsEOF()) if((bufferIter == nullptr || bufferIter == bufferEnd) && !IsEOF())
@ -115,17 +117,17 @@ bool CompassFile::GetNextHit()
} }
return eofFlag; return eofFlag;
} }
/* /*
GetNextBuffer() ... self-explanatory name GetNextBuffer() ... self-explanatory name
Note tht this is where the EOF flag is set. The EOF is only singaled Note tht this is where the EOF flag is set. The EOF is only singaled
after the LAST buffer is completely read (i.e literally no more data). ifstream sets its eof after the LAST buffer is completely read (i.e literally no more data). ifstream sets its eof
bit upon pulling the last buffer, but this class waits until that entire bit upon pulling the last buffer, but this class waits until that entire
last buffer is read to singal EOF (the true end of file). last buffer is read to singal EOF (the true end of file).
*/ */
void CompassFile::GetNextBuffer() void CompassFile::GetNextBuffer()
{ {
if(m_file->eof()) if(m_file->eof())
{ {
@ -138,10 +140,10 @@ void CompassFile::GetNextBuffer()
bufferIter = hitBuffer.data(); bufferIter = hitBuffer.data();
bufferEnd = bufferIter + m_file->gcount(); //one past the last datum bufferEnd = bufferIter + m_file->gcount(); //one past the last datum
} }
void CompassFile::ParseNextHit() void CompassFile::ParseNextHit()
{ {
m_currentHit.board = *((uint16_t*)bufferIter); m_currentHit.board = *((uint16_t*)bufferIter);
bufferIter += 2; bufferIter += 2;
@ -164,4 +166,6 @@ void CompassFile::ParseNextHit()
m_currentHit.timestamp += m_smap->GetShift(gchan); m_currentHit.timestamp += m_smap->GetShift(gchan);
} }
}
} }

View File

@ -15,10 +15,12 @@
#include "ShiftMap.h" #include "ShiftMap.h"
#include <memory> #include <memory>
class CompassFile namespace EventBuilder {
{
public: class CompassFile
{
public:
CompassFile(); CompassFile();
CompassFile(const std::string& filename); CompassFile(const std::string& filename);
CompassFile(const std::string& filename, int bsize); CompassFile(const std::string& filename, int bsize);
@ -39,7 +41,7 @@ public:
inline unsigned int GetNumberOfHits() const { return m_nHits; } inline unsigned int GetNumberOfHits() const { return m_nHits; }
private: private:
int GetHitSize(); int GetHitSize();
void ParseNextHit(); void ParseNextHit();
void GetNextBuffer(); void GetNextBuffer();
@ -65,7 +67,8 @@ private:
unsigned int m_size; //size of the file in bytes unsigned int m_size; //size of the file in bytes
unsigned int m_nHits; //number of hits in the file (m_size/24) unsigned int m_nHits; //number of hits in the file (m_size/24)
}; };
}
#endif #endif

View File

@ -1,8 +1,10 @@
#ifndef COMPASS_HIT_H #ifndef COMPASS_HIT_H
#define COMPASS_HIT_H #define COMPASS_HIT_H
struct CompassHit namespace EventBuilder {
{
struct CompassHit
{
uint16_t board = 400; uint16_t board = 400;
uint16_t channel = 400; uint16_t channel = 400;
uint64_t timestamp = 0; uint64_t timestamp = 0;
@ -10,6 +12,8 @@ struct CompassHit
uint16_t sgate = 0; uint16_t sgate = 0;
uint32_t flags = 0; uint32_t flags = 0;
uint32_t Ns = 0; uint32_t Ns = 0;
}; };
}
#endif #endif

View File

@ -17,24 +17,26 @@
#include "SFPAnalyzer.h" #include "SFPAnalyzer.h"
#include "FlagHandler.h" #include "FlagHandler.h"
CompassRun::CompassRun() : namespace EventBuilder {
CompassRun::CompassRun() :
m_directory(""), m_scalerinput(""), m_runNum(0), m_scaler_flag(false), m_pb(nullptr) m_directory(""), m_scalerinput(""), m_runNum(0), m_scaler_flag(false), m_pb(nullptr)
{ {
} }
CompassRun::CompassRun(const std::string& dir) : CompassRun::CompassRun(const std::string& dir) :
m_directory(dir), m_scalerinput(""), m_runNum(0), m_scaler_flag(false), m_pb(nullptr) m_directory(dir), m_scalerinput(""), m_runNum(0), m_scaler_flag(false), m_pb(nullptr)
{ {
} }
CompassRun::~CompassRun() {} CompassRun::~CompassRun() {}
/*Load em into a map*/ /*Load em into a map*/
void CompassRun::SetScalers() void CompassRun::SetScalers()
{ {
std::ifstream input(m_scalerinput); std::ifstream input(m_scalerinput);
if(!input.is_open()) if(!input.is_open())
return; return;
@ -52,10 +54,10 @@ void CompassRun::SetScalers()
m_scaler_map[filename] = TParameter<Long64_t>(varname.c_str(), init); m_scaler_map[filename] = TParameter<Long64_t>(varname.c_str(), init);
} }
input.close(); input.close();
} }
bool CompassRun::GetBinaryFiles() bool CompassRun::GetBinaryFiles()
{ {
std::string prefix = ""; std::string prefix = "";
std::string suffix = ".bin"; //binaries std::string suffix = ".bin"; //binaries
RunCollector grabber(m_directory, prefix, suffix); RunCollector grabber(m_directory, prefix, suffix);
@ -95,14 +97,14 @@ bool CompassRun::GetBinaryFiles()
} }
return true; return true;
} }
/* /*
Pure counting of scalers. Potential upgrade path to something like Pure counting of scalers. Potential upgrade path to something like
average count rate etc. average count rate etc.
*/ */
void CompassRun::ReadScalerData(const std::string& filename) void CompassRun::ReadScalerData(const std::string& filename)
{ {
if(!m_scaler_flag) if(!m_scaler_flag)
return; return;
@ -118,9 +120,9 @@ void CompassRun::ReadScalerData(const std::string& filename)
count++; count++;
} }
this_param.SetVal(count); this_param.SetVal(count);
} }
/* /*
GetHitsFromFiles() is the function which actually retrieves and sorts the data from the individual GetHitsFromFiles() is the function which actually retrieves and sorts the data from the individual
files. There are several tricks which allow this to happen. First is that, after sorting, it is impossible files. There are several tricks which allow this to happen. First is that, after sorting, it is impossible
to determine which file the data originally came from (short of parsing the name of the file against board/channel). to determine which file the data originally came from (short of parsing the name of the file against board/channel).
@ -128,9 +130,9 @@ void CompassRun::ReadScalerData(const std::string& filename)
is retrieved along with the data. This flag is flipped so that on the next hit cycle a new hit is pulled. Second is the use is retrieved along with the data. This flag is flipped so that on the next hit cycle a new hit is pulled. Second is the use
of a rolling start index. Once a file has gone EOF, we no longer need it. If this is the first file in the list, we can just skip of a rolling start index. Once a file has gone EOF, we no longer need it. If this is the first file in the list, we can just skip
that index all together. In this way, the loop can go from N times to N-1 times. that index all together. In this way, the loop can go from N times to N-1 times.
*/ */
bool CompassRun::GetHitsFromFiles() bool CompassRun::GetHitsFromFiles()
{ {
std::pair<CompassHit, bool*> earliestHit = std::make_pair(CompassHit(), nullptr); std::pair<CompassHit, bool*> earliestHit = std::make_pair(CompassHit(), nullptr);
for(unsigned int i=startIndex; i<m_datafiles.size(); i++) for(unsigned int i=startIndex; i<m_datafiles.size(); i++)
@ -159,9 +161,9 @@ bool CompassRun::GetHitsFromFiles()
hit = earliestHit.first; hit = earliestHit.first;
*earliestHit.second = true; *earliestHit.second = true;
return true; return true;
} }
void CompassRun::Convert2RawRoot(const std::string& name) { void CompassRun::Convert2RawRoot(const std::string& name) {
TFile* output = TFile::Open(name.c_str(), "RECREATE"); TFile* output = TFile::Open(name.c_str(), "RECREATE");
TTree* outtree = new TTree("Data", "Data"); TTree* outtree = new TTree("Data", "Data");
@ -223,10 +225,10 @@ void CompassRun::Convert2RawRoot(const std::string& name) {
entry.second.Write(); entry.second.Write();
output->Close(); output->Close();
} }
void CompassRun::Convert2SortedRoot(const std::string& name, const std::string& mapfile, double window) void CompassRun::Convert2SortedRoot(const std::string& name, const std::string& mapfile, double window)
{ {
TFile* output = TFile::Open(name.c_str(), "RECREATE"); TFile* output = TFile::Open(name.c_str(), "RECREATE");
TTree* outtree = new TTree("SortTree", "SortTree"); TTree* outtree = new TTree("SortTree", "SortTree");
@ -297,10 +299,10 @@ void CompassRun::Convert2SortedRoot(const std::string& name, const std::string&
coincidizer.GetEventStats()->Write(); coincidizer.GetEventStats()->Write();
output->Close(); output->Close();
} }
void CompassRun::Convert2FastSortedRoot(const std::string& name, const std::string& mapfile, double window, double fsi_window, double fic_window) void CompassRun::Convert2FastSortedRoot(const std::string& name, const std::string& mapfile, double window, double fsi_window, double fic_window)
{ {
TFile* output = TFile::Open(name.c_str(), "RECREATE"); TFile* output = TFile::Open(name.c_str(), "RECREATE");
TTree* outtree = new TTree("SortTree", "SortTree"); TTree* outtree = new TTree("SortTree", "SortTree");
@ -387,12 +389,12 @@ void CompassRun::Convert2FastSortedRoot(const std::string& name, const std::stri
coincidizer.GetEventStats()->Write(); coincidizer.GetEventStats()->Write();
output->Close(); output->Close();
} }
void CompassRun::Convert2SlowAnalyzedRoot(const std::string& name, const std::string& mapfile, double window, void CompassRun::Convert2SlowAnalyzedRoot(const std::string& name, const std::string& mapfile, double window,
int zt, int at, int zp, int ap, int ze, int ae, double bke, double b, double theta) int zt, int at, int zp, int ap, int ze, int ae, double bke, double b, double theta)
{ {
TFile* output = TFile::Open(name.c_str(), "RECREATE"); TFile* output = TFile::Open(name.c_str(), "RECREATE");
TTree* outtree = new TTree("SPSTree", "SPSTree"); TTree* outtree = new TTree("SPSTree", "SPSTree");
@ -488,11 +490,11 @@ void CompassRun::Convert2SlowAnalyzedRoot(const std::string& name, const std::st
analyzer.GetHashTable()->Write(); analyzer.GetHashTable()->Write();
analyzer.ClearHashTable(); analyzer.ClearHashTable();
output->Close(); output->Close();
} }
void CompassRun::Convert2FastAnalyzedRoot(const std::string& name, const std::string& mapfile, double window, double fsi_window, double fic_window, void CompassRun::Convert2FastAnalyzedRoot(const std::string& name, const std::string& mapfile, double window, double fsi_window, double fic_window,
int zt, int at, int zp, int ap, int ze, int ae, double bke, double b, double theta) int zt, int at, int zp, int ap, int ze, int ae, double bke, double b, double theta)
{ {
TFile* output = TFile::Open(name.c_str(), "RECREATE"); TFile* output = TFile::Open(name.c_str(), "RECREATE");
TTree* outtree = new TTree("SPSTree", "SPSTree"); TTree* outtree = new TTree("SPSTree", "SPSTree");
@ -598,12 +600,14 @@ void CompassRun::Convert2FastAnalyzedRoot(const std::string& name, const std::st
analyzer.GetHashTable()->Write(); analyzer.GetHashTable()->Write();
analyzer.ClearHashTable(); analyzer.ClearHashTable();
output->Close(); output->Close();
} }
void CompassRun::SetProgressBar() void CompassRun::SetProgressBar()
{ {
m_pb->SetMax(m_totalHits); m_pb->SetMax(m_totalHits);
m_pb->SetMin(0); m_pb->SetMin(0);
m_pb->SetPosition(0); m_pb->SetPosition(0);
gSystem->ProcessEvents(); gSystem->ProcessEvents();
}
} }

View File

@ -18,10 +18,12 @@
#include <TGProgressBar.h> #include <TGProgressBar.h>
#include <TSystem.h> #include <TSystem.h>
class CompassRun namespace EventBuilder {
{
public: class CompassRun
{
public:
CompassRun(); CompassRun();
CompassRun(const std::string& dir); CompassRun(const std::string& dir);
~CompassRun(); ~CompassRun();
@ -39,7 +41,7 @@ public:
inline void AttachProgressBar(TGProgressBar* pb) { m_pb = pb; } inline void AttachProgressBar(TGProgressBar* pb) { m_pb = pb; }
private: private:
bool GetBinaryFiles(); bool GetBinaryFiles();
bool GetHitsFromFiles(); bool GetHitsFromFiles();
void SetScalers(); void SetScalers();
@ -66,6 +68,8 @@ private:
//GUI progress bar, if attached //GUI progress bar, if attached
TGProgressBar* m_pb; TGProgressBar* m_pb;
}; };
}
#endif #endif

View File

@ -1,28 +1,30 @@
#include "EventBuilder.h" #include "EventBuilder.h"
#include "CutHandler.h" #include "CutHandler.h"
CutHandler::CutHandler() : namespace EventBuilder {
CutHandler::CutHandler() :
validFlag(false) validFlag(false)
{ {
InitVariableMap(); InitVariableMap();
} }
CutHandler::CutHandler(const std::string& filename) : CutHandler::CutHandler(const std::string& filename) :
validFlag(false) validFlag(false)
{ {
SetCuts(filename); SetCuts(filename);
InitVariableMap(); InitVariableMap();
} }
CutHandler::~CutHandler() CutHandler::~CutHandler()
{ {
for(unsigned int i=0; i<file_array.size(); i++) for(unsigned int i=0; i<file_array.size(); i++)
if(file_array[i]->IsOpen()) if(file_array[i]->IsOpen())
file_array[i]->Close(); file_array[i]->Close();
} }
void CutHandler::SetCuts(const std::string& filename) void CutHandler::SetCuts(const std::string& filename)
{ {
std::ifstream cutlist(filename); std::ifstream cutlist(filename);
if(!cutlist.is_open()) if(!cutlist.is_open())
@ -63,23 +65,23 @@ void CutHandler::SetCuts(const std::string& filename)
validFlag = true; validFlag = true;
else else
validFlag = false; validFlag = false;
} }
/* /*
ADD MORE VARIABLES HERE! ADD MORE VARIABLES HERE!
*/ */
void CutHandler::InitVariableMap() void CutHandler::InitVariableMap()
{ {
varmap["x1"] = &m_event.x1; varmap["x1"] = &m_event.x1;
varmap["x2"] = &m_event.x2; varmap["x2"] = &m_event.x2;
varmap["xavg"] = &m_event.xavg; varmap["xavg"] = &m_event.xavg;
varmap["scintLeft"] = &m_event.scintLeft; varmap["scintLeft"] = &m_event.scintLeft;
varmap["anodeBack"] = &m_event.anodeBack; varmap["anodeBack"] = &m_event.anodeBack;
varmap["cathode"] = &m_event.cathode; varmap["cathode"] = &m_event.cathode;
} }
bool CutHandler::IsInside(const ProcessedEvent* eaddress) bool CutHandler::IsInside(const ProcessedEvent* eaddress)
{ {
m_event = *eaddress; m_event = *eaddress;
std::string x, y; std::string x, y;
for(unsigned int i=0; i<cut_array.size(); i++) for(unsigned int i=0; i<cut_array.size(); i++)
@ -101,4 +103,6 @@ bool CutHandler::IsInside(const ProcessedEvent* eaddress)
} }
return true; return true;
}
} }

View File

@ -1,10 +1,12 @@
#ifndef CUTHANDLER_H #ifndef CUTHANDLER_H
#define CUTHANDLER_H #define CUTHANDLER_H
#include "DataStructs.h" #include "../spsdict/DataStructs.h"
class CutHandler { namespace EventBuilder {
public:
class CutHandler {
public:
CutHandler(); CutHandler();
CutHandler(const std::string& filename); CutHandler(const std::string& filename);
~CutHandler(); ~CutHandler();
@ -13,7 +15,7 @@ public:
bool IsInside(const ProcessedEvent* eaddress); bool IsInside(const ProcessedEvent* eaddress);
std::vector<TCutG*> GetCuts() { return cut_array; } std::vector<TCutG*> GetCuts() { return cut_array; }
private: private:
void InitVariableMap(); void InitVariableMap();
std::vector<TCutG*> cut_array; std::vector<TCutG*> cut_array;
@ -21,7 +23,8 @@ private:
std::unordered_map<std::string, double*> varmap; std::unordered_map<std::string, double*> varmap;
bool validFlag; bool validFlag;
ProcessedEvent m_event; ProcessedEvent m_event;
};
}; }
#endif #endif

View File

@ -16,19 +16,21 @@
#include "SFPAnalyzer.h" #include "SFPAnalyzer.h"
#include "SFPPlotter.h" #include "SFPPlotter.h"
EVBApp::EVBApp() : namespace EventBuilder {
EVBApp::EVBApp() :
m_rmin(0), m_rmax(0), m_ZT(0), m_AT(0), m_ZP(0), m_AP(0), m_ZE(0), m_AE(0), m_ZR(0), m_AR(0), m_rmin(0), m_rmax(0), m_ZT(0), m_AT(0), m_ZP(0), m_AP(0), m_ZE(0), m_AE(0), m_ZR(0), m_AR(0),
m_B(0), m_Theta(0), m_BKE(0), m_workspace("none"), m_mapfile("none"), m_shiftfile("none"), m_B(0), m_Theta(0), m_BKE(0), m_workspace("none"), m_mapfile("none"), m_shiftfile("none"),
m_cutList("none"), m_SlowWindow(0), m_FastWindowIonCh(0), m_FastWindowSABRE(0), m_pb(nullptr) m_cutList("none"), m_SlowWindow(0), m_FastWindowIonCh(0), m_FastWindowSABRE(0), m_pb(nullptr)
{ {
} }
EVBApp::~EVBApp() EVBApp::~EVBApp()
{ {
} }
bool EVBApp::ReadConfigFile(const std::string& fullpath) bool EVBApp::ReadConfigFile(const std::string& fullpath)
{ {
std::cout<<"Reading in configuration from file: "<<fullpath<<std::endl; std::cout<<"Reading in configuration from file: "<<fullpath<<std::endl;
std::ifstream input(fullpath); std::ifstream input(fullpath);
if(!input.is_open()) if(!input.is_open())
@ -70,10 +72,10 @@ bool EVBApp::ReadConfigFile(const std::string& fullpath)
std::cout<<"Completed."<<std::endl; std::cout<<"Completed."<<std::endl;
return true; return true;
} }
void EVBApp::WriteConfigFile(const std::string& fullpath) void EVBApp::WriteConfigFile(const std::string& fullpath)
{ {
std::cout<<"Writing out configuration to file: "<<fullpath<<std::endl; std::cout<<"Writing out configuration to file: "<<fullpath<<std::endl;
std::ofstream output(fullpath); std::ofstream output(fullpath);
@ -115,10 +117,10 @@ void EVBApp::WriteConfigFile(const std::string& fullpath)
std::cout<<"Completed."<<std::endl; std::cout<<"Completed."<<std::endl;
} }
void EVBApp::PlotHistograms() void EVBApp::PlotHistograms()
{ {
std::string analyze_dir = m_workspace+"/analyzed/"; std::string analyze_dir = m_workspace+"/analyzed/";
std::string plot_file = m_workspace+"/histograms/run_"+std::to_string(m_rmin)+"_"+std::to_string(m_rmax)+".root"; std::string plot_file = m_workspace+"/histograms/run_"+std::to_string(m_rmin)+"_"+std::to_string(m_rmax)+".root";
SFPPlotter grammer; SFPPlotter grammer;
@ -145,10 +147,10 @@ void EVBApp::PlotHistograms()
} }
std::cout<<"-------------------------------------------"<<std::endl; std::cout<<"-------------------------------------------"<<std::endl;
} }
void EVBApp::Convert2RawRoot() void EVBApp::Convert2RawRoot()
{ {
std::string rawroot_dir = m_workspace+"/raw_root/"; std::string rawroot_dir = m_workspace+"/raw_root/";
std::string unpack_dir = m_workspace+"/temp_binary/"; std::string unpack_dir = m_workspace+"/temp_binary/";
std::string binary_dir = m_workspace+"/raw_binary/"; std::string binary_dir = m_workspace+"/raw_binary/";
@ -195,10 +197,10 @@ void EVBApp::Convert2RawRoot()
std::cout<<std::endl<<"Conversion complete."<<std::endl; std::cout<<std::endl<<"Conversion complete."<<std::endl;
std::cout<<"-------------------------------------------"<<std::endl; std::cout<<"-------------------------------------------"<<std::endl;
} }
void EVBApp::MergeROOTFiles() void EVBApp::MergeROOTFiles()
{ {
std::string merge_file = m_workspace+"/merged/run_"+std::to_string(m_rmin)+"_"+std::to_string(m_rmax)+".root"; std::string merge_file = m_workspace+"/merged/run_"+std::to_string(m_rmin)+"_"+std::to_string(m_rmax)+".root";
std::string file_dir = m_workspace+"/analyzed/"; std::string file_dir = m_workspace+"/analyzed/";
std::cout<<"-------------GWM Event Builder-------------"<<std::endl; std::cout<<"-------------GWM Event Builder-------------"<<std::endl;
@ -217,10 +219,10 @@ void EVBApp::MergeROOTFiles()
} }
std::cout<<" Complete."<<std::endl; std::cout<<" Complete."<<std::endl;
std::cout<<"-------------------------------------------"<<std::endl; std::cout<<"-------------------------------------------"<<std::endl;
} }
void EVBApp::Convert2SortedRoot() void EVBApp::Convert2SortedRoot()
{ {
std::string sortroot_dir = m_workspace+"/sorted/"; std::string sortroot_dir = m_workspace+"/sorted/";
std::string unpack_dir = m_workspace+"/temp_binary/"; std::string unpack_dir = m_workspace+"/temp_binary/";
std::string binary_dir = m_workspace+"/raw_binary/"; std::string binary_dir = m_workspace+"/raw_binary/";
@ -267,9 +269,9 @@ void EVBApp::Convert2SortedRoot()
} }
std::cout<<std::endl<<"Conversion complete."<<std::endl; std::cout<<std::endl<<"Conversion complete."<<std::endl;
std::cout<<"-------------------------------------------"<<std::endl; std::cout<<"-------------------------------------------"<<std::endl;
} }
void EVBApp::Convert2FastSortedRoot() { void EVBApp::Convert2FastSortedRoot() {
std::string sortroot_dir = m_workspace+"/fast/"; std::string sortroot_dir = m_workspace+"/fast/";
std::string unpack_dir = m_workspace+"/temp_binary/"; std::string unpack_dir = m_workspace+"/temp_binary/";
std::string binary_dir = m_workspace+"/raw_binary/"; std::string binary_dir = m_workspace+"/raw_binary/";
@ -316,9 +318,9 @@ void EVBApp::Convert2FastSortedRoot() {
} }
std::cout<<std::endl<<"Conversion complete."<<std::endl; std::cout<<std::endl<<"Conversion complete."<<std::endl;
std::cout<<"-------------------------------------------"<<std::endl; std::cout<<"-------------------------------------------"<<std::endl;
} }
void EVBApp::Convert2SlowAnalyzedRoot() { void EVBApp::Convert2SlowAnalyzedRoot() {
std::string sortroot_dir = m_workspace+"/analyzed/"; std::string sortroot_dir = m_workspace+"/analyzed/";
std::string unpack_dir = m_workspace+"/temp_binary/"; std::string unpack_dir = m_workspace+"/temp_binary/";
std::string binary_dir = m_workspace+"/raw_binary/"; std::string binary_dir = m_workspace+"/raw_binary/";
@ -364,10 +366,10 @@ void EVBApp::Convert2SlowAnalyzedRoot() {
} }
std::cout<<std::endl<<"Conversion complete."<<std::endl; std::cout<<std::endl<<"Conversion complete."<<std::endl;
std::cout<<"-------------------------------------------"<<std::endl; std::cout<<"-------------------------------------------"<<std::endl;
} }
void EVBApp::Convert2FastAnalyzedRoot() void EVBApp::Convert2FastAnalyzedRoot()
{ {
std::string sortroot_dir = m_workspace+"/analyzed/"; std::string sortroot_dir = m_workspace+"/analyzed/";
std::string unpack_dir = m_workspace+"/temp_binary/"; std::string unpack_dir = m_workspace+"/temp_binary/";
std::string binary_dir = m_workspace+"/raw_binary/"; std::string binary_dir = m_workspace+"/raw_binary/";
@ -416,10 +418,10 @@ void EVBApp::Convert2FastAnalyzedRoot()
} }
std::cout<<std::endl<<"Conversion complete."<<std::endl; std::cout<<std::endl<<"Conversion complete."<<std::endl;
std::cout<<"-------------------------------------------"<<std::endl; std::cout<<"-------------------------------------------"<<std::endl;
} }
bool EVBApp::SetKinematicParameters(int zt, int at, int zp, int ap, int ze, int ae, double b, double theta, double bke) bool EVBApp::SetKinematicParameters(int zt, int at, int zp, int ap, int ze, int ae, double b, double theta, double bke)
{ {
if((at + ap - ae) < 0 || (zt + zp - ze) < 0) if((at + ap - ae) < 0 || (zt + zp - ze) < 0)
{ {
@ -433,4 +435,6 @@ bool EVBApp::SetKinematicParameters(int zt, int at, int zp, int ap, int ze, int
m_AR = (at + ap - ae); m_AR = (at + ap - ae);
return true; return true;
}
} }

View File

@ -12,8 +12,10 @@
#include "RunCollector.h" #include "RunCollector.h"
#include <TGProgressBar.h> #include <TGProgressBar.h>
class EVBApp { namespace EventBuilder {
public:
class EVBApp {
public:
EVBApp(); EVBApp();
~EVBApp(); ~EVBApp();
@ -74,7 +76,7 @@ public:
Plot Plot
}; };
private: private:
int m_rmin, m_rmax; int m_rmin, m_rmax;
int m_ZT, m_AT, m_ZP, m_AP, m_ZE, m_AE, m_ZR, m_AR; int m_ZT, m_AT, m_ZP, m_AP, m_ZE, m_AE, m_ZR, m_AR;
@ -93,6 +95,7 @@ private:
TGProgressBar* m_pb; TGProgressBar* m_pb;
}; };
}
#endif #endif

View File

@ -36,11 +36,13 @@
#include "MassLookup.h" #include "MassLookup.h"
#include "FP_kinematics.h" #include "FP_kinematics.h"
//requires (Z,A) for T, P, and E, as well as energy of P, namespace EventBuilder {
// spectrograph angle of interest, and field value
double Delta_Z(int ZT, int AT, int ZP, int AP, int ZE, int AE, //requires (Z,A) for T, P, and E, as well as energy of P,
// spectrograph angle of interest, and field value
double Delta_Z(int ZT, int AT, int ZP, int AP, int ZE, int AE,
double EP, double angle, double B) double EP, double angle, double B)
{ {
/* CONSTANTS */ /* CONSTANTS */
const double UTOMEV = 931.4940954; //MeV per u; const double UTOMEV = 931.4940954; //MeV per u;
@ -99,7 +101,8 @@ double Delta_Z(int ZT, int AT, int ZP, int AP, int ZE, int AE,
std::cout<<"Delta Z= "<<-1*rho*DISP*MAG*K<<std::endl; std::cout<<"Delta Z= "<<-1*rho*DISP*MAG*K<<std::endl;
return -1*rho*DISP*MAG*K; //delta-Z in cm return -1*rho*DISP*MAG*K; //delta-Z in cm
}
double Wire_Dist() {return 4.28625;} //cm
} }
double Wire_Dist() {return 4.28625;} //cm

View File

@ -32,11 +32,15 @@
#ifndef FP_KINEMATICS #ifndef FP_KINEMATICS
#define FP_KINEMATICS #define FP_KINEMATICS
//requires (Z,A) for T, P, and E, as well as energy of P, namespace EventBuilder {
// spectrograph angle of interest, and field value
double Delta_Z(int ZT, int AT, int ZP, int AP, int ZE, int AE, //requires (Z,A) for T, P, and E, as well as energy of P,
// spectrograph angle of interest, and field value
double Delta_Z(int ZT, int AT, int ZP, int AP, int ZE, int AE,
double EP, double angle, double B); double EP, double angle, double B);
double Wire_Dist(); double Wire_Dist();
}
#endif #endif

View File

@ -1,30 +1,31 @@
#include "EventBuilder.h" #include "EventBuilder.h"
#include "FastSort.h" #include "FastSort.h"
//windows given in picoseconds, converted to nanoseconds namespace EventBuilder {
FastSort::FastSort(float si_windowSize, float ion_windowSize) : //windows given in picoseconds, converted to nanoseconds
FastSort::FastSort(float si_windowSize, float ion_windowSize) :
si_coincWindow(si_windowSize/1.0e3), ion_coincWindow(ion_windowSize/1.0e3), event_address(nullptr) si_coincWindow(si_windowSize/1.0e3), ion_coincWindow(ion_windowSize/1.0e3), event_address(nullptr)
{ {
} }
FastSort::~FastSort() FastSort::~FastSort()
{ {
delete event_address; delete event_address;
} }
void FastSort::ResetSABRE() void FastSort::ResetSABRE()
{ {
for(int i=0; i<5; i++) for(int i=0; i<5; i++)
fastEvent.sabreArray[i] = sblank; fastEvent.sabreArray[i] = sblank;
} }
void FastSort::ResetFocalPlane() void FastSort::ResetFocalPlane()
{ {
fastEvent.focalPlane = fpblank; fastEvent.focalPlane = fpblank;
} }
/*Assign a set of ion chamber data to the scintillator*/ /*Assign a set of ion chamber data to the scintillator*/
void FastSort::ProcessFocalPlane(unsigned int scint_index, unsigned int ionch_index) { void FastSort::ProcessFocalPlane(unsigned int scint_index, unsigned int ionch_index) {
/*In order to have a coincidence window, one must choose a portion of the ion chamber to form a requirement. /*In order to have a coincidence window, one must choose a portion of the ion chamber to form a requirement.
*In this case, I chose one of the anodes. But in principle you could also choose any other part of the ion *In this case, I chose one of the anodes. But in principle you could also choose any other part of the ion
@ -60,11 +61,11 @@ void FastSort::ProcessFocalPlane(unsigned int scint_index, unsigned int ionch_in
if(slowEvent.focalPlane.cathode.size() > ionch_index) if(slowEvent.focalPlane.cathode.size() > ionch_index)
fastEvent.focalPlane.cathode.push_back(slowEvent.focalPlane.cathode[ionch_index]); fastEvent.focalPlane.cathode.push_back(slowEvent.focalPlane.cathode[ionch_index]);
} }
} }
/*Assign a set of SABRE data that falls within the coincidence window*/ /*Assign a set of SABRE data that falls within the coincidence window*/
void FastSort::ProcessSABRE(unsigned int scint_index) void FastSort::ProcessSABRE(unsigned int scint_index)
{ {
for(int i=0; i<5; i++) for(int i=0; i<5; i++)
{ //loop over SABRE silicons { //loop over SABRE silicons
std::vector<DetectorHit> rings; std::vector<DetectorHit> rings;
@ -90,10 +91,10 @@ void FastSort::ProcessSABRE(unsigned int scint_index)
fastEvent.sabreArray[i].rings = rings; fastEvent.sabreArray[i].rings = rings;
fastEvent.sabreArray[i].wedges = wedges; fastEvent.sabreArray[i].wedges = wedges;
} }
} }
std::vector<CoincEvent> FastSort::GetFastEvents(CoincEvent& event) std::vector<CoincEvent> FastSort::GetFastEvents(CoincEvent& event)
{ {
slowEvent = event; slowEvent = event;
std::vector<CoincEvent> fast_events; std::vector<CoincEvent> fast_events;
@ -122,4 +123,6 @@ std::vector<CoincEvent> FastSort::GetFastEvents(CoincEvent& event)
} }
} }
return fast_events; return fast_events;
}
} }

View File

@ -9,15 +9,17 @@
#include "DataStructs.h" #include "DataStructs.h"
#include <TH2.h> #include <TH2.h>
class FastSort namespace EventBuilder {
{
public: class FastSort
{
public:
FastSort(float si_windowSize, float ion_windowSize); FastSort(float si_windowSize, float ion_windowSize);
~FastSort(); ~FastSort();
std::vector<CoincEvent> GetFastEvents(CoincEvent& event); std::vector<CoincEvent> GetFastEvents(CoincEvent& event);
private: private:
void ResetSABRE(); void ResetSABRE();
void ResetFocalPlane(); void ResetFocalPlane();
void ProcessSABRE(unsigned int scint_index); void ProcessSABRE(unsigned int scint_index);
@ -29,6 +31,7 @@ private:
SabreDetector sblank; SabreDetector sblank;
FPDetector fpblank; FPDetector fpblank;
}; };
}
#endif #endif

View File

@ -1,24 +1,26 @@
#include "EventBuilder.h" #include "EventBuilder.h"
#include "FlagHandler.h" #include "FlagHandler.h"
FlagHandler::FlagHandler() : namespace EventBuilder {
FlagHandler::FlagHandler() :
log("./event_log.txt") log("./event_log.txt")
{ {
} }
FlagHandler::FlagHandler(const std::string& filename) : FlagHandler::FlagHandler(const std::string& filename) :
log(filename) log(filename)
{ {
} }
FlagHandler::~FlagHandler() FlagHandler::~FlagHandler()
{ {
WriteLog(); WriteLog();
log.close(); log.close();
} }
void FlagHandler::CheckFlag(int board, int channel, int flag) void FlagHandler::CheckFlag(int board, int channel, int flag)
{ {
int gchan = channel + board*16; int gchan = channel + board*16;
FlagCount& counter = event_count_map[gchan]; //yikes FlagCount& counter = event_count_map[gchan]; //yikes
@ -73,10 +75,10 @@ void FlagHandler::CheckFlag(int board, int channel, int flag)
if(flag & ADCShutdown) if(flag & ADCShutdown)
counter.adc_shutdown++; counter.adc_shutdown++;
} }
void FlagHandler::WriteLog() void FlagHandler::WriteLog()
{ {
log<<"Event Flag Log"<<std::endl; log<<"Event Flag Log"<<std::endl;
log<<"-----------------------------"<<std::endl; log<<"-----------------------------"<<std::endl;
for(auto& counter : event_count_map) for(auto& counter : event_count_map)
@ -102,5 +104,5 @@ void FlagHandler::WriteLog()
log<<"ADC Shutdown: "<<counter.second.adc_shutdown<<std::endl; log<<"ADC Shutdown: "<<counter.second.adc_shutdown<<std::endl;
log<<"-----------------------------"<<std::endl; log<<"-----------------------------"<<std::endl;
} }
}
} }

View File

@ -3,8 +3,10 @@
#include <map> #include <map>
struct FlagCount namespace EventBuilder {
{
struct FlagCount
{
long total_counts=0; long total_counts=0;
long dead_time=0; long dead_time=0;
long time_roll=0; long time_roll=0;
@ -23,11 +25,11 @@ struct FlagCount
long pll_lock_loss=0; long pll_lock_loss=0;
long over_temp=0; long over_temp=0;
long adc_shutdown=0; long adc_shutdown=0;
}; };
class FlagHandler class FlagHandler
{ {
public: public:
FlagHandler(); FlagHandler();
FlagHandler(const std::string& filename); FlagHandler(const std::string& filename);
~FlagHandler(); ~FlagHandler();
@ -51,11 +53,12 @@ public:
const int OverTemp = 0x00100000; const int OverTemp = 0x00100000;
const int ADCShutdown = 0x00200000; const int ADCShutdown = 0x00200000;
private: private:
std::ofstream log; std::ofstream log;
std::map<int, FlagCount> event_count_map; std::map<int, FlagCount> event_count_map;
void WriteLog(); void WriteLog();
}; };
}
#endif #endif

View File

@ -11,13 +11,14 @@ Written by G.W. McCann Aug. 2020
#include "EventBuilder.h" #include "EventBuilder.h"
#include "MassLookup.h" #include "MassLookup.h"
namespace EventBuilder {
/* /*
Read in AMDC mass file, preformated to remove excess info. Here assumes that by default Read in AMDC mass file, preformated to remove excess info. Here assumes that by default
the file is in a local directory etc/ the file is in a local directory etc/
*/ */
MassLookup::MassLookup() MassLookup::MassLookup()
{ {
std::string filepath; std::string filepath;
#ifdef ETC_DIR_PATH #ifdef ETC_DIR_PATH
filepath = ETC_DIR_PATH; filepath = ETC_DIR_PATH;
@ -44,13 +45,13 @@ MassLookup::MassLookup()
} }
else else
std::cerr<<"Unable to open mass.txt at MassLookup! Prepare for errors."<<std::endl; std::cerr<<"Unable to open mass.txt at MassLookup! Prepare for errors."<<std::endl;
} }
MassLookup::~MassLookup() {} MassLookup::~MassLookup() {}
//Returns nuclear mass in MeV //Returns nuclear mass in MeV
double MassLookup::FindMass(int Z, int A) double MassLookup::FindMass(int Z, int A)
{ {
std::string key = "("+std::to_string(Z)+","+std::to_string(A)+")"; std::string key = "("+std::to_string(Z)+","+std::to_string(A)+")";
auto data = massTable.find(key); auto data = massTable.find(key);
if(data == massTable.end()) if(data == massTable.end())
@ -59,11 +60,11 @@ double MassLookup::FindMass(int Z, int A)
return 0; return 0;
} }
return data->second; return data->second;
} }
//returns element symbol //returns element symbol
std::string MassLookup::FindSymbol(int Z, int A) std::string MassLookup::FindSymbol(int Z, int A)
{ {
auto data = elementTable.find(Z); auto data = elementTable.find(Z);
if(data == elementTable.end()) if(data == elementTable.end())
{ {
@ -72,4 +73,5 @@ std::string MassLookup::FindSymbol(int Z, int A)
} }
std::string fullsymbol = std::to_string(A) + data->second; std::string fullsymbol = std::to_string(A) + data->second;
return fullsymbol; return fullsymbol;
}
} }

View File

@ -11,16 +11,18 @@ Written by G.W. McCann Aug. 2020
#ifndef MASS_LOOKUP_H #ifndef MASS_LOOKUP_H
#define MASS_LOOKUP_H #define MASS_LOOKUP_H
class MassLookup namespace EventBuilder {
{
public: class MassLookup
{
public:
MassLookup(); MassLookup();
~MassLookup(); ~MassLookup();
double FindMass(int Z, int A); double FindMass(int Z, int A);
std::string FindSymbol(int Z, int A); std::string FindSymbol(int Z, int A);
private: private:
std::unordered_map<std::string, double> massTable; std::unordered_map<std::string, double> massTable;
std::unordered_map<int, std::string> elementTable; std::unordered_map<int, std::string> elementTable;
@ -28,8 +30,10 @@ private:
static constexpr double u_to_mev = 931.4940954; static constexpr double u_to_mev = 931.4940954;
static constexpr double electron_mass = 0.000548579909; static constexpr double electron_mass = 0.000548579909;
}; };
//static instance for use throught program //static instance for use throught program
static MassLookup MASS; static MassLookup MASS;
}
#endif #endif

View File

@ -8,16 +8,18 @@
#include "EventBuilder.h" #include "EventBuilder.h"
#include "OrderChecker.h" #include "OrderChecker.h"
OrderChecker::OrderChecker() namespace EventBuilder {
{
}
OrderChecker::~OrderChecker() OrderChecker::OrderChecker()
{ {
} }
bool OrderChecker::IsOrdered(const std::string& filename) OrderChecker::~OrderChecker()
{ {
}
bool OrderChecker::IsOrdered(const std::string& filename)
{
TFile* file = TFile::Open(filename.c_str(), "READ"); TFile* file = TFile::Open(filename.c_str(), "READ");
TTree* tree = (TTree*) file->Get("Data"); TTree* tree = (TTree*) file->Get("Data");
@ -37,4 +39,6 @@ bool OrderChecker::IsOrdered(const std::string& filename)
file->Close(); file->Close();
return true; return true;
}
} }

View File

@ -8,12 +8,16 @@
#ifndef ORDERCHECKER_H #ifndef ORDERCHECKER_H
#define ORDERCHECKER_H #define ORDERCHECKER_H
class OrderChecker namespace EventBuilder {
{
public: class OrderChecker
{
public:
OrderChecker(); OrderChecker();
~OrderChecker(); ~OrderChecker();
bool IsOrdered(const std::string& filename); bool IsOrdered(const std::string& filename);
}; };
}
#endif #endif

View File

@ -7,34 +7,36 @@
#include <cstdlib> #include <cstdlib>
#include <cstdio> #include <cstdio>
RunCollector::RunCollector(): namespace EventBuilder {
RunCollector::RunCollector():
m_initFlag(false), m_directory(""), m_prefix(""), m_suffix(""), m_minRun(0), m_maxRun(0) m_initFlag(false), m_directory(""), m_prefix(""), m_suffix(""), m_minRun(0), m_maxRun(0)
{ {
} }
RunCollector::RunCollector(const std::string& dirname, const std::string& prefix, const std::string& suffix) : RunCollector::RunCollector(const std::string& dirname, const std::string& prefix, const std::string& suffix) :
m_initFlag(true), m_directory(dirname), m_prefix(prefix), m_suffix(suffix), m_minRun(0), m_maxRun(0) m_initFlag(true), m_directory(dirname), m_prefix(prefix), m_suffix(suffix), m_minRun(0), m_maxRun(0)
{ {
} }
RunCollector::RunCollector(const std::string& dirname, const std::string& prefix, const std::string& suffix, int min, int max) : RunCollector::RunCollector(const std::string& dirname, const std::string& prefix, const std::string& suffix, int min, int max) :
m_initFlag(true), m_directory(dirname), m_prefix(prefix), m_suffix(suffix), m_minRun(min), m_maxRun(max) m_initFlag(true), m_directory(dirname), m_prefix(prefix), m_suffix(suffix), m_minRun(min), m_maxRun(max)
{ {
} }
RunCollector::~RunCollector() {} RunCollector::~RunCollector() {}
void RunCollector::SetSearchParams(const std::string& dirname, const std::string& prefix, const std::string& suffix, int min, int max) void RunCollector::SetSearchParams(const std::string& dirname, const std::string& prefix, const std::string& suffix, int min, int max)
{ {
m_directory = dirname.c_str(); m_directory = dirname.c_str();
m_prefix = prefix.c_str(); m_prefix = prefix.c_str();
m_suffix = suffix.c_str(); m_suffix = suffix.c_str();
m_minRun = min; m_maxRun = max; m_minRun = min; m_maxRun = max;
m_initFlag = true; m_initFlag = true;
} }
bool RunCollector::GrabAllFiles() bool RunCollector::GrabAllFiles()
{ {
if(!m_initFlag) if(!m_initFlag)
return false; return false;
@ -72,9 +74,9 @@ bool RunCollector::GrabAllFiles()
std::cerr<<"Unable to find files with matching run name in directory; check input.txt"<<std::endl; std::cerr<<"Unable to find files with matching run name in directory; check input.txt"<<std::endl;
return false; return false;
} }
} }
std::string RunCollector::GrabFile(int runNum) { std::string RunCollector::GrabFile(int runNum) {
if(!m_initFlag) if(!m_initFlag)
return ""; return "";
TSystemDirectory sysdir(m_directory.c_str(), m_directory.c_str()); TSystemDirectory sysdir(m_directory.c_str(), m_directory.c_str());
@ -102,11 +104,11 @@ std::string RunCollector::GrabFile(int runNum) {
delete flist; delete flist;
return fname; return fname;
} }
/*Grabs all files within a specified run range*/ /*Grabs all files within a specified run range*/
bool RunCollector::GrabFilesInRange() bool RunCollector::GrabFilesInRange()
{ {
if(!m_initFlag) if(!m_initFlag)
return false; return false;
@ -151,10 +153,10 @@ bool RunCollector::GrabFilesInRange()
return false; return false;
} }
} }
bool RunCollector::Merge_hadd(const std::string& outname) bool RunCollector::Merge_hadd(const std::string& outname)
{ {
if(!m_initFlag) if(!m_initFlag)
return false; return false;
@ -188,10 +190,10 @@ bool RunCollector::Merge_hadd(const std::string& outname)
else else
return false; return false;
} }
} }
bool RunCollector::Merge_TChain(const std::string& outname) bool RunCollector::Merge_TChain(const std::string& outname)
{ {
if(!m_initFlag) if(!m_initFlag)
return false; return false;
TFile *output = new TFile(outname.c_str(), "RECREATE"); TFile *output = new TFile(outname.c_str(), "RECREATE");
@ -228,4 +230,6 @@ bool RunCollector::Merge_TChain(const std::string& outname)
if(output->IsOpen()) if(output->IsOpen())
output->Close(); output->Close();
return false; return false;
}
} }

View File

@ -10,9 +10,11 @@
#ifndef RUNCOLLECTOR_H #ifndef RUNCOLLECTOR_H
#define RUNCOLLECTOR_H #define RUNCOLLECTOR_H
class RunCollector namespace EventBuilder {
{
public: class RunCollector
{
public:
RunCollector(); RunCollector();
RunCollector(const std::string& dirname, const std::string& prefix, const std::string& suffix); RunCollector(const std::string& dirname, const std::string& prefix, const std::string& suffix);
RunCollector(const std::string& dirname, const std::string& prefix, const std::string& suffix, int min, int max); RunCollector(const std::string& dirname, const std::string& prefix, const std::string& suffix, int min, int max);
@ -30,7 +32,7 @@ public:
inline int GetRunMax() { return m_maxRun; } inline int GetRunMax() { return m_maxRun; }
inline const std::vector<std::string>& GetFileList() { return m_filelist; } inline const std::vector<std::string>& GetFileList() { return m_filelist; }
private: private:
bool m_initFlag; bool m_initFlag;
std::string m_directory; std::string m_directory;
std::string m_prefix; std::string m_prefix;
@ -39,6 +41,7 @@ private:
const int m_maxAllowedRuns = 1000; //class run limit const int m_maxAllowedRuns = 1000; //class run limit
std::vector<std::string> m_filelist; std::vector<std::string> m_filelist;
}; };
}
#endif #endif

View File

@ -12,45 +12,46 @@
#include "EventBuilder.h" #include "EventBuilder.h"
#include "SFPAnalyzer.h" #include "SFPAnalyzer.h"
namespace EventBuilder {
/*Constructor takes in kinematic parameters for generating focal plane weights*/ /*Constructor takes in kinematic parameters for generating focal plane weights*/
SFPAnalyzer::SFPAnalyzer(int zt, int at, int zp, int ap, int ze, int ae, double ep, SFPAnalyzer::SFPAnalyzer(int zt, int at, int zp, int ap, int ze, int ae, double ep,
double angle, double b) double angle, double b)
{ {
zfp = Delta_Z(zt, at, zp, ap, ze, ae, ep, angle, b); zfp = Delta_Z(zt, at, zp, ap, ze, ae, ep, angle, b);
event_address = new CoincEvent(); event_address = new CoincEvent();
rootObj = new THashTable(); rootObj = new THashTable();
GetWeights(); GetWeights();
} }
SFPAnalyzer::~SFPAnalyzer() SFPAnalyzer::~SFPAnalyzer()
{ {
rootObj->Clear(); rootObj->Clear();
delete rootObj; delete rootObj;
delete event_address; delete event_address;
} }
void SFPAnalyzer::Reset() void SFPAnalyzer::Reset()
{ {
pevent = blank; //set output back to blank pevent = blank; //set output back to blank
} }
/*Use functions from FP_kinematics to calculate weights for xavg /*Use functions from FP_kinematics to calculate weights for xavg
*While this seems kind of funny, it is mathematically equivalent to making a line *While this seems kind of funny, it is mathematically equivalent to making a line
*from the two focal plane points and finding the intersection with *from the two focal plane points and finding the intersection with
*the kinematic focal plane *the kinematic focal plane
*/ */
void SFPAnalyzer::GetWeights() void SFPAnalyzer::GetWeights()
{ {
w1 = (Wire_Dist()/2.0-zfp)/Wire_Dist(); w1 = (Wire_Dist()/2.0-zfp)/Wire_Dist();
w2 = 1.0-w1; w2 = 1.0-w1;
std::cout<<"w1: "<<w1<<" w2: "<<w2<<std::endl; std::cout<<"w1: "<<w1<<" w2: "<<w2<<std::endl;
} }
/*2D histogram fill wrapper for use with THashTable (faster)*/ /*2D histogram fill wrapper for use with THashTable (faster)*/
void SFPAnalyzer::MyFill(const std::string& name, int binsx, double minx, double maxx, double valuex, void SFPAnalyzer::MyFill(const std::string& name, int binsx, double minx, double maxx, double valuex,
int binsy, double miny, double maxy, double valuey) int binsy, double miny, double maxy, double valuey)
{ {
TH2F *histo = (TH2F*) rootObj->FindObject(name.c_str()); TH2F *histo = (TH2F*) rootObj->FindObject(name.c_str());
if(histo != nullptr) if(histo != nullptr)
histo->Fill(valuex, valuey); histo->Fill(valuex, valuey);
@ -60,11 +61,11 @@ void SFPAnalyzer::MyFill(const std::string& name, int binsx, double minx, double
h->Fill(valuex, valuey); h->Fill(valuex, valuey);
rootObj->Add(h); rootObj->Add(h);
} }
} }
/*1D histogram fill wrapper for use with THashTable (faster)*/ /*1D histogram fill wrapper for use with THashTable (faster)*/
void SFPAnalyzer::MyFill(const std::string& name, int binsx, double minx, double maxx, double valuex) void SFPAnalyzer::MyFill(const std::string& name, int binsx, double minx, double maxx, double valuex)
{ {
TH1F *histo = (TH1F*) rootObj->FindObject(name.c_str()); TH1F *histo = (TH1F*) rootObj->FindObject(name.c_str());
if(histo != nullptr) if(histo != nullptr)
histo->Fill(valuex); histo->Fill(valuex);
@ -74,10 +75,10 @@ void SFPAnalyzer::MyFill(const std::string& name, int binsx, double minx, double
h->Fill(valuex); h->Fill(valuex);
rootObj->Add(h); rootObj->Add(h);
} }
} }
void SFPAnalyzer::AnalyzeEvent(CoincEvent& event) void SFPAnalyzer::AnalyzeEvent(CoincEvent& event)
{ {
Reset(); Reset();
if(!event.focalPlane.anodeF.empty()) if(!event.focalPlane.anodeF.empty())
{ {
@ -196,10 +197,12 @@ void SFPAnalyzer::AnalyzeEvent(CoincEvent& event)
pevent.fp1_y = pevent.anodeFrontTime-pevent.scintRightTime; pevent.fp1_y = pevent.anodeFrontTime-pevent.scintRightTime;
if(pevent.anodeBackTime != -1 && pevent.scintRightTime != -1) if(pevent.anodeBackTime != -1 && pevent.scintRightTime != -1)
pevent.fp2_y = pevent.anodeBackTime-pevent.scintRightTime; pevent.fp2_y = pevent.anodeBackTime-pevent.scintRightTime;
} }
ProcessedEvent SFPAnalyzer::GetProcessedEvent(CoincEvent& event) ProcessedEvent SFPAnalyzer::GetProcessedEvent(CoincEvent& event)
{ {
AnalyzeEvent(event); AnalyzeEvent(event);
return pevent; return pevent;
}
} }

View File

@ -13,10 +13,11 @@
#include "DataStructs.h" #include "DataStructs.h"
#include "FP_kinematics.h" #include "FP_kinematics.h"
namespace EventBuilder {
class SFPAnalyzer class SFPAnalyzer
{ {
public: public:
SFPAnalyzer(int zt, int at, int zp, int ap, int ze, int ae, double ep, double angle, SFPAnalyzer(int zt, int at, int zp, int ap, int ze, int ae, double ep, double angle,
double b); double b);
~SFPAnalyzer(); ~SFPAnalyzer();
@ -24,7 +25,7 @@ public:
inline void ClearHashTable() { rootObj->Clear(); } inline void ClearHashTable() { rootObj->Clear(); }
inline THashTable* GetHashTable() { return rootObj; } inline THashTable* GetHashTable() { return rootObj; }
private: private:
void Reset(); //Sets ouput structure back to "zero" void Reset(); //Sets ouput structure back to "zero"
void GetWeights(); //weights for xavg void GetWeights(); //weights for xavg
void AnalyzeEvent(CoincEvent& event); void AnalyzeEvent(CoincEvent& event);
@ -40,6 +41,8 @@ private:
double w1, w2, zfp; double w1, w2, zfp;
THashTable *rootObj; //root storage THashTable *rootObj; //root storage
}; };
}
#endif #endif

View File

@ -10,22 +10,24 @@
#include "SFPPlotter.h" #include "SFPPlotter.h"
#include <TSystem.h> #include <TSystem.h>
/*Generates storage and initializes pointers*/ namespace EventBuilder {
SFPPlotter::SFPPlotter()
{ /*Generates storage and initializes pointers*/
SFPPlotter::SFPPlotter()
{
event_address = new ProcessedEvent(); event_address = new ProcessedEvent();
m_pb = nullptr; m_pb = nullptr;
} }
SFPPlotter::~SFPPlotter() SFPPlotter::~SFPPlotter()
{ {
delete event_address; delete event_address;
} }
/*2D histogram fill wrapper*/ /*2D histogram fill wrapper*/
void SFPPlotter::MyFill(THashTable* table, const std::string& name, int binsx, double minx, double maxx, double valuex, void SFPPlotter::MyFill(THashTable* table, const std::string& name, int binsx, double minx, double maxx, double valuex,
int binsy, double miny, double maxy, double valuey) int binsy, double miny, double maxy, double valuey)
{ {
TH2F *histo = (TH2F*) table->FindObject(name.c_str()); TH2F *histo = (TH2F*) table->FindObject(name.c_str());
if(histo != nullptr) if(histo != nullptr)
histo->Fill(valuex, valuey); histo->Fill(valuex, valuey);
@ -35,11 +37,11 @@ void SFPPlotter::MyFill(THashTable* table, const std::string& name, int binsx, d
h->Fill(valuex, valuey); h->Fill(valuex, valuey);
table->Add(h); table->Add(h);
} }
} }
/*1D histogram fill wrapper*/ /*1D histogram fill wrapper*/
void SFPPlotter::MyFill(THashTable* table, const std::string& name, int binsx, double minx, double maxx, double valuex) void SFPPlotter::MyFill(THashTable* table, const std::string& name, int binsx, double minx, double maxx, double valuex)
{ {
TH1F *histo = (TH1F*) table->FindObject(name.c_str()); TH1F *histo = (TH1F*) table->FindObject(name.c_str());
if(histo != nullptr) if(histo != nullptr)
histo->Fill(valuex); histo->Fill(valuex);
@ -49,11 +51,11 @@ void SFPPlotter::MyFill(THashTable* table, const std::string& name, int binsx, d
h->Fill(valuex); h->Fill(valuex);
table->Add(h); table->Add(h);
} }
} }
/*Makes histograms where only rejection is unset data*/ /*Makes histograms where only rejection is unset data*/
void SFPPlotter::MakeUncutHistograms(const ProcessedEvent& ev, THashTable* table) void SFPPlotter::MakeUncutHistograms(const ProcessedEvent& ev, THashTable* table)
{ {
MyFill(table,"x1NoCuts_bothplanes",600,-300,300,ev.x2); MyFill(table,"x1NoCuts_bothplanes",600,-300,300,ev.x2);
MyFill(table,"x2NoCuts_bothplanes",600,-300,300,ev.x2); MyFill(table,"x2NoCuts_bothplanes",600,-300,300,ev.x2);
MyFill(table,"xavgNoCuts_bothplanes",600,-300,300,ev.xavg); MyFill(table,"xavgNoCuts_bothplanes",600,-300,300,ev.xavg);
@ -151,11 +153,11 @@ void SFPPlotter::MakeUncutHistograms(const ProcessedEvent& ev, THashTable* table
MyFill(table,"x2NoCuts_only1plane",600,-300,300,ev.x2); MyFill(table,"x2NoCuts_only1plane",600,-300,300,ev.x2);
else if(ev.x1 == -1e6 && ev.x2 == -1e6) else if(ev.x1 == -1e6 && ev.x2 == -1e6)
MyFill(table,"nopos_counter",2,0,1,1); MyFill(table,"nopos_counter",2,0,1,1);
} }
/*Makes histograms with cuts & gates implemented*/ /*Makes histograms with cuts & gates implemented*/
void SFPPlotter::MakeCutHistograms(const ProcessedEvent& ev, THashTable* table) void SFPPlotter::MakeCutHistograms(const ProcessedEvent& ev, THashTable* table)
{ {
if(!cutter.IsInside(&ev)) if(!cutter.IsInside(&ev))
return; return;
@ -234,11 +236,11 @@ void SFPPlotter::MakeCutHistograms(const ProcessedEvent& ev, THashTable* table)
MyFill(table,"xavg_sabreWedgeE_Cut",600,-300,300,ev.xavg,200,0,20,ev.sabreWedgeE[i]); MyFill(table,"xavg_sabreWedgeE_Cut",600,-300,300,ev.xavg,200,0,20,ev.sabreWedgeE[i]);
} }
} }
} }
/*Runs a list of files given from a RunCollector class*/ /*Runs a list of files given from a RunCollector class*/
void SFPPlotter::Run(const std::vector<std::string>& files, const std::string& output) void SFPPlotter::Run(const std::vector<std::string>& files, const std::string& output)
{ {
TFile *outfile = TFile::Open(output.c_str(), "RECREATE"); TFile *outfile = TFile::Open(output.c_str(), "RECREATE");
TChain* chain = new TChain("SPSTree"); TChain* chain = new TChain("SPSTree");
for(unsigned int i=0; i<files.size(); i++) for(unsigned int i=0; i<files.size(); i++)
@ -284,13 +286,15 @@ void SFPPlotter::Run(const std::vector<std::string>& files, const std::string& o
delete table; delete table;
outfile->Close(); outfile->Close();
delete outfile; delete outfile;
} }
void SFPPlotter::SetProgressBar(long total) void SFPPlotter::SetProgressBar(long total)
{ {
m_pb->SetMax(total); m_pb->SetMax(total);
m_pb->SetMin(0); m_pb->SetMin(0);
m_pb->SetPosition(0); m_pb->SetPosition(0);
gSystem->ProcessEvents(); gSystem->ProcessEvents();
}
} }

View File

@ -13,16 +13,18 @@
#include "CutHandler.h" #include "CutHandler.h"
#include <TGProgressBar.h> #include <TGProgressBar.h>
class SFPPlotter namespace EventBuilder {
{
public: class SFPPlotter
{
public:
SFPPlotter(); SFPPlotter();
~SFPPlotter(); ~SFPPlotter();
inline void AttachProgressBar(TGProgressBar* pb) { m_pb = pb; } inline void AttachProgressBar(TGProgressBar* pb) { m_pb = pb; }
inline void ApplyCutlist(const std::string& listname) { cutter.SetCuts(listname); } inline void ApplyCutlist(const std::string& listname) { cutter.SetCuts(listname); }
void Run(const std::vector<std::string>& files, const std::string& output); void Run(const std::vector<std::string>& files, const std::string& output);
private: private:
void SetProgressBar(long total); void SetProgressBar(long total);
void Chain(const std::vector<std::string>& files); //Form TChain void Chain(const std::vector<std::string>& files); //Form TChain
void MakeUncutHistograms(const ProcessedEvent& ev, THashTable* table); void MakeUncutHistograms(const ProcessedEvent& ev, THashTable* table);
@ -40,6 +42,8 @@ private:
TGProgressBar* m_pb; //GUI progress TGProgressBar* m_pb; //GUI progress
}; };
}
#endif #endif

View File

@ -12,27 +12,29 @@
#include "EventBuilder.h" #include "EventBuilder.h"
#include "ShiftMap.h" #include "ShiftMap.h"
ShiftMap::ShiftMap() : namespace EventBuilder {
ShiftMap::ShiftMap() :
m_filename(""), m_validFlag(false) m_filename(""), m_validFlag(false)
{ {
} }
ShiftMap::ShiftMap(const std::string& filename) : ShiftMap::ShiftMap(const std::string& filename) :
m_filename(filename), m_validFlag(false) m_filename(filename), m_validFlag(false)
{ {
ParseFile(); ParseFile();
} }
ShiftMap::~ShiftMap() {} ShiftMap::~ShiftMap() {}
void ShiftMap::SetFile(const std::string& filename) void ShiftMap::SetFile(const std::string& filename)
{ {
m_filename = filename; m_filename = filename;
ParseFile(); ParseFile();
} }
uint64_t ShiftMap::GetShift(int gchan) uint64_t ShiftMap::GetShift(int gchan)
{ {
if(!m_validFlag) if(!m_validFlag)
return 0; return 0;
@ -41,10 +43,10 @@ uint64_t ShiftMap::GetShift(int gchan)
return 0; return 0;
else else
return iter->second; return iter->second;
} }
void ShiftMap::ParseFile() void ShiftMap::ParseFile()
{ {
m_validFlag = false; m_validFlag = false;
std::ifstream input(m_filename); std::ifstream input(m_filename);
if(!input.is_open()) if(!input.is_open())
@ -78,4 +80,6 @@ void ShiftMap::ParseFile()
} }
m_validFlag = true; m_validFlag = true;
}
} }

View File

@ -12,9 +12,11 @@
#ifndef SHIFTMAP_H #ifndef SHIFTMAP_H
#define SHIFTMAP_H #define SHIFTMAP_H
class ShiftMap namespace EventBuilder {
{
public: class ShiftMap
{
public:
ShiftMap(); ShiftMap();
ShiftMap(const std::string& filename); ShiftMap(const std::string& filename);
~ShiftMap(); ~ShiftMap();
@ -23,7 +25,7 @@ public:
inline std::string GetFilename() { return m_filename; } inline std::string GetFilename() { return m_filename; }
uint64_t GetShift(int gchan); uint64_t GetShift(int gchan);
private: private:
void ParseFile(); void ParseFile();
std::string m_filename; std::string m_filename;
@ -31,6 +33,8 @@ private:
std::unordered_map<int, uint64_t> m_map; std::unordered_map<int, uint64_t> m_map;
}; };
}
#endif #endif

View File

@ -10,30 +10,32 @@
#include "EventBuilder.h" #include "EventBuilder.h"
#include "SlowSort.h" #include "SlowSort.h"
/*Sort the Sabre Data in order of descending energy*/ namespace EventBuilder {
bool SabreSort(const DetectorHit& i, const DetectorHit& j) {
/*Sort the Sabre Data in order of descending energy*/
bool SabreSort(const DetectorHit& i, const DetectorHit& j) {
return (i.Long>j.Long); return (i.Long>j.Long);
} }
/*Constructor takes input of coincidence window size, and fills sabre channel map*/ /*Constructor takes input of coincidence window size, and fills sabre channel map*/
SlowSort::SlowSort() : SlowSort::SlowSort() :
m_coincWindow(-1.0), m_eventFlag(false) m_coincWindow(-1.0), m_eventFlag(false)
{ {
event_stats = new TH2F("coinc_event_stats","coinc_events_stats;global channel;number of coincident hits;counts",144,0,144,20,0,20); event_stats = new TH2F("coinc_event_stats","coinc_events_stats;global channel;number of coincident hits;counts",144,0,144,20,0,20);
} }
SlowSort::SlowSort(double windowSize, const std::string& mapfile) : SlowSort::SlowSort(double windowSize, const std::string& mapfile) :
m_coincWindow(windowSize), m_eventFlag(false), m_event(), cmap(mapfile) m_coincWindow(windowSize), m_eventFlag(false), m_event(), cmap(mapfile)
{ {
event_stats = new TH2F("coinc_event_stats","coinc_events_stats;global channel;number of coincident hits;counts",144,0,144,20,0,20); event_stats = new TH2F("coinc_event_stats","coinc_events_stats;global channel;number of coincident hits;counts",144,0,144,20,0,20);
InitVariableMaps(); InitVariableMaps();
} }
SlowSort::~SlowSort() {} SlowSort::~SlowSort() {}
/**EXPERIMENT MODS go here**/ /**EXPERIMENT MODS go here**/
void SlowSort::InitVariableMaps() void SlowSort::InitVariableMaps()
{ {
/*For SABRE: Each SABRE det has ring&wedge, so add the detID to the /*For SABRE: Each SABRE det has ring&wedge, so add the detID to the
SABRERING/WEDGE attribute to differentiate*/ SABRERING/WEDGE attribute to differentiate*/
@ -62,16 +64,16 @@ void SlowSort::InitVariableMaps()
varMap[DetAttribute::AnodeBack] = &m_event.focalPlane.anodeB; varMap[DetAttribute::AnodeBack] = &m_event.focalPlane.anodeB;
varMap[DetAttribute::Monitor] = &m_event.focalPlane.monitor; varMap[DetAttribute::Monitor] = &m_event.focalPlane.monitor;
} }
/*Reset output structure to blank*/ /*Reset output structure to blank*/
void SlowSort::Reset() void SlowSort::Reset()
{ {
m_event = m_blank; m_event = m_blank;
} }
bool SlowSort::AddHitToEvent(CompassHit& mhit) bool SlowSort::AddHitToEvent(CompassHit& mhit)
{ {
DPPChannel curHit; DPPChannel curHit;
curHit.Timestamp = mhit.timestamp; curHit.Timestamp = mhit.timestamp;
curHit.Energy = mhit.lgate; curHit.Energy = mhit.lgate;
@ -99,10 +101,10 @@ bool SlowSort::AddHitToEvent(CompassHit& mhit)
} }
return true; return true;
} }
void SlowSort::FlushHitsToEvent() void SlowSort::FlushHitsToEvent()
{ {
if(m_hitList.empty()) if(m_hitList.empty())
{ {
m_eventFlag = false; m_eventFlag = false;
@ -112,19 +114,19 @@ void SlowSort::FlushHitsToEvent()
ProcessEvent(); ProcessEvent();
m_hitList.clear(); m_hitList.clear();
m_eventFlag = true; m_eventFlag = true;
} }
const CoincEvent& SlowSort::GetEvent() const CoincEvent& SlowSort::GetEvent()
{ {
m_eventFlag = false; m_eventFlag = false;
return m_event; return m_event;
} }
/*Function called when an event outside the coincidence window is detected /*Function called when an event outside the coincidence window is detected
*Process all of the hits in the list, and write them to the sorted tree *Process all of the hits in the list, and write them to the sorted tree
*/ */
void SlowSort::ProcessEvent() void SlowSort::ProcessEvent()
{ {
Reset(); Reset();
DetectorHit dhit; DetectorHit dhit;
int gchan; int gchan;
@ -177,4 +179,6 @@ void SlowSort::ProcessEvent()
sort(m_event.sabreArray[s].rings.begin(), m_event.sabreArray[s].rings.end(), SabreSort); sort(m_event.sabreArray[s].rings.begin(), m_event.sabreArray[s].rings.end(), SabreSort);
sort(m_event.sabreArray[s].wedges.begin(), m_event.sabreArray[s].wedges.end(), SabreSort); sort(m_event.sabreArray[s].wedges.begin(), m_event.sabreArray[s].wedges.end(), SabreSort);
} }
}
} }

View File

@ -16,10 +16,12 @@
#include <TH2.h> #include <TH2.h>
#include <unordered_map> #include <unordered_map>
class SlowSort namespace EventBuilder {
{
public: class SlowSort
{
public:
SlowSort(); SlowSort();
SlowSort(double windowSize, const std::string& mapfile); SlowSort(double windowSize, const std::string& mapfile);
~SlowSort(); ~SlowSort();
@ -31,7 +33,7 @@ public:
void FlushHitsToEvent(); //For use with *last* hit list void FlushHitsToEvent(); //For use with *last* hit list
inline bool IsEventReady() { return m_eventFlag; } inline bool IsEventReady() { return m_eventFlag; }
private: private:
void InitVariableMaps(); void InitVariableMaps();
void Reset(); void Reset();
void ProcessEvent(); void ProcessEvent();
@ -49,6 +51,8 @@ private:
ChannelMap cmap; ChannelMap cmap;
}; };
}
#endif #endif

View File

@ -8,30 +8,34 @@
#include "EventBuilder.h" #include "EventBuilder.h"
#include "Stopwatch.h" #include "Stopwatch.h"
Stopwatch::Stopwatch() namespace EventBuilder {
{
Stopwatch::Stopwatch()
{
start_time = Clock::now(); start_time = Clock::now();
stop_time = start_time; stop_time = start_time;
} }
Stopwatch::~Stopwatch() {} Stopwatch::~Stopwatch() {}
void Stopwatch::Start() void Stopwatch::Start()
{ {
start_time = Clock::now(); start_time = Clock::now();
} }
void Stopwatch::Stop() void Stopwatch::Stop()
{ {
stop_time = Clock::now(); stop_time = Clock::now();
} }
double Stopwatch::GetElapsedSeconds() double Stopwatch::GetElapsedSeconds()
{ {
return std::chrono::duration_cast<std::chrono::duration<double>>(stop_time-start_time).count(); return std::chrono::duration_cast<std::chrono::duration<double>>(stop_time-start_time).count();
} }
double Stopwatch::GetElapsedMilliseconds() double Stopwatch::GetElapsedMilliseconds()
{ {
return std::chrono::duration_cast<std::chrono::duration<double>>(stop_time-start_time).count()*1000.0; return std::chrono::duration_cast<std::chrono::duration<double>>(stop_time-start_time).count()*1000.0;
}
} }

View File

@ -10,9 +10,11 @@
#include <chrono> #include <chrono>
class Stopwatch namespace EventBuilder {
{
public: class Stopwatch
{
public:
Stopwatch(); Stopwatch();
~Stopwatch(); ~Stopwatch();
void Start(); void Start();
@ -20,11 +22,13 @@ public:
double GetElapsedSeconds(); double GetElapsedSeconds();
double GetElapsedMilliseconds(); double GetElapsedMilliseconds();
private: private:
using Time = std::chrono::high_resolution_clock::time_point; using Time = std::chrono::high_resolution_clock::time_point;
using Clock = std::chrono::high_resolution_clock; using Clock = std::chrono::high_resolution_clock;
Time start_time, stop_time; Time start_time, stop_time;
}; };
}
#endif #endif

View File

@ -1,7 +1,7 @@
#include "EventBuilder.h" #include "evb/EventBuilder.h"
#include "spsdict/DataStructs.h" #include "spsdict/DataStructs.h"
#include <TApplication.h> #include <TApplication.h>
#include "EVBMainFrame.h" #include "guidict/EVBMainFrame.h"
int main(int argc, char** argv) int main(int argc, char** argv)
{ {

View File

@ -142,13 +142,13 @@ EVBMainFrame::EVBMainFrame(const TGWindow* p, UInt_t w, UInt_t h) :
TGLabel *typelabel = new TGLabel(RunFrame, "Operation Type:"); TGLabel *typelabel = new TGLabel(RunFrame, "Operation Type:");
fTypeBox = new TGComboBox(RunFrame, TypeBox); fTypeBox = new TGComboBox(RunFrame, TypeBox);
//Needs modification for new conversion based sorting GWM -- Dec 2020 //Needs modification for new conversion based sorting GWM -- Dec 2020
fTypeBox->AddEntry("Convert Slow", EVBApp::Operation::ConvertSlow); fTypeBox->AddEntry("Convert Slow", EventBuilder::EVBApp::Operation::ConvertSlow);
fTypeBox->AddEntry("Convert Fast", EVBApp::Operation::ConvertFast); fTypeBox->AddEntry("Convert Fast", EventBuilder::EVBApp::Operation::ConvertFast);
fTypeBox->AddEntry("Convert SlowA", EVBApp::Operation::ConvertSlowA); fTypeBox->AddEntry("Convert SlowA", EventBuilder::EVBApp::Operation::ConvertSlowA);
fTypeBox->AddEntry("Convert FastA", EVBApp::Operation::ConvertFastA); fTypeBox->AddEntry("Convert FastA", EventBuilder::EVBApp::Operation::ConvertFastA);
fTypeBox->AddEntry("Convert", EVBApp::Operation::Convert); fTypeBox->AddEntry("Convert", EventBuilder::EVBApp::Operation::Convert);
fTypeBox->AddEntry("Merge ROOT", EVBApp::Operation::Merge); fTypeBox->AddEntry("Merge ROOT", EventBuilder::EVBApp::Operation::Merge);
fTypeBox->AddEntry("Plot", EVBApp::Operation::Plot); fTypeBox->AddEntry("Plot", EventBuilder::EVBApp::Operation::Plot);
fTypeBox->Resize(200,20); fTypeBox->Resize(200,20);
fTypeBox->Connect("Selected(Int_t, Int_t)","EVBMainFrame",this,"HandleTypeSelection(Int_t,Int_t)"); fTypeBox->Connect("Selected(Int_t, Int_t)","EVBMainFrame",this,"HandleTypeSelection(Int_t,Int_t)");
TGLabel *rminlabel = new TGLabel(RunFrame, "Min Run:"); TGLabel *rminlabel = new TGLabel(RunFrame, "Min Run:");
@ -256,37 +256,37 @@ void EVBMainFrame::DoRun()
switch(type) switch(type)
{ {
case EVBApp::Operation::Plot : case EventBuilder::EVBApp::Operation::Plot :
{ {
RunPlot(); RunPlot();
break; break;
} }
case EVBApp::Operation::Convert : case EventBuilder::EVBApp::Operation::Convert :
{ {
fBuilder.Convert2RawRoot(); fBuilder.Convert2RawRoot();
break; break;
} }
case EVBApp::Operation::Merge : case EventBuilder::EVBApp::Operation::Merge :
{ {
fBuilder.MergeROOTFiles(); fBuilder.MergeROOTFiles();
break; break;
} }
case EVBApp::Operation::ConvertSlow : case EventBuilder::EVBApp::Operation::ConvertSlow :
{ {
fBuilder.Convert2SortedRoot(); fBuilder.Convert2SortedRoot();
break; break;
} }
case EVBApp::Operation::ConvertFast : case EventBuilder::EVBApp::Operation::ConvertFast :
{ {
fBuilder.Convert2FastSortedRoot(); fBuilder.Convert2FastSortedRoot();
break; break;
} }
case EVBApp::Operation::ConvertSlowA : case EventBuilder::EVBApp::Operation::ConvertSlowA :
{ {
fBuilder.Convert2SlowAnalyzedRoot(); fBuilder.Convert2SlowAnalyzedRoot();
break; break;
} }
case EVBApp::Operation::ConvertFastA : case EventBuilder::EVBApp::Operation::ConvertFastA :
{ {
fBuilder.Convert2FastAnalyzedRoot(); fBuilder.Convert2FastAnalyzedRoot();
break; break;

View File

@ -94,7 +94,7 @@ private:
TGPopupMenu *fFileMenu; TGPopupMenu *fFileMenu;
EVBApp fBuilder; EventBuilder::EVBApp fBuilder;
int counter; int counter;
UInt_t MAIN_W, MAIN_H; UInt_t MAIN_W, MAIN_H;

View File

@ -1,7 +1,7 @@
#include "EventBuilder.h" #include "evb/EventBuilder.h"
#include "spsdict/DataStructs.h" #include "spsdict/DataStructs.h"
#include "EVBApp.h" #include "evb/EVBApp.h"
#include "Stopwatch.h" #include "evb/Stopwatch.h"
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
@ -27,11 +27,11 @@ int main(int argc, char** argv)
Plot (generate a default histogram file from analyzed data) Plot (generate a default histogram file from analyzed data)
*/ */
EVBApp theBuilder; EventBuilder::EVBApp theBuilder;
theBuilder.ReadConfigFile(filename); theBuilder.ReadConfigFile(filename);
Stopwatch timer; EventBuilder::Stopwatch timer;
timer.Start(); timer.Start();
if(operation == "Convert") if(operation == "Convert")
theBuilder.Convert2RawRoot(); theBuilder.Convert2RawRoot();