mirror of
https://github.com/sesps/SPS_SABRE_EventBuilder.git
synced 2024-11-26 03:28:51 -05:00
Namespace encapsulated evb with name EventBuilder
This commit is contained in:
parent
1c6addb941
commit
b9ed82a593
|
@ -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`
|
||||
|
||||
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
|
||||
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.
|
||||
|
|
|
@ -94,7 +94,7 @@ private:
|
|||
|
||||
TGPopupMenu *fFileMenu;
|
||||
|
||||
EVBApp fBuilder;
|
||||
EventBuilder::EVBApp fBuilder;
|
||||
|
||||
int counter;
|
||||
UInt_t MAIN_W, MAIN_H;
|
||||
|
|
|
@ -9,21 +9,23 @@
|
|||
#include "EventBuilder.h"
|
||||
#include "ChannelMap.h"
|
||||
|
||||
ChannelMap::ChannelMap() :
|
||||
m_validFlag(false)
|
||||
{
|
||||
}
|
||||
namespace EventBuilder {
|
||||
|
||||
ChannelMap::ChannelMap(const std::string& name) :
|
||||
ChannelMap::ChannelMap() :
|
||||
m_validFlag(false)
|
||||
{
|
||||
{
|
||||
}
|
||||
|
||||
ChannelMap::ChannelMap(const std::string& name) :
|
||||
m_validFlag(false)
|
||||
{
|
||||
FillMap(name);
|
||||
}
|
||||
}
|
||||
|
||||
ChannelMap::~ChannelMap() {}
|
||||
ChannelMap::~ChannelMap() {}
|
||||
|
||||
bool ChannelMap::FillMap(const std::string& name)
|
||||
{
|
||||
bool ChannelMap::FillMap(const std::string& name)
|
||||
{
|
||||
std::ifstream input(name);
|
||||
if(!input.is_open())
|
||||
{
|
||||
|
@ -91,4 +93,5 @@ bool ChannelMap::FillMap(const std::string& name)
|
|||
input.close();
|
||||
m_validFlag = true;
|
||||
return m_validFlag;
|
||||
}
|
||||
}
|
|
@ -9,16 +9,17 @@
|
|||
#ifndef CHANNELMAP_H
|
||||
#define CHANNELMAP_H
|
||||
|
||||
//Detector part/type identifiers for use in the code
|
||||
enum DetType
|
||||
{
|
||||
namespace EventBuilder {
|
||||
//Detector part/type identifiers for use in the code
|
||||
enum DetType
|
||||
{
|
||||
Sabre,
|
||||
FocalPlane,
|
||||
NoneType
|
||||
};
|
||||
};
|
||||
|
||||
enum DetAttribute
|
||||
{
|
||||
enum DetAttribute
|
||||
{
|
||||
ScintLeft,
|
||||
ScintRight,
|
||||
AnodeFront,
|
||||
|
@ -40,19 +41,19 @@ enum DetAttribute
|
|||
SabreWedge3,
|
||||
SabreWedge4,
|
||||
NoneAttr
|
||||
};
|
||||
};
|
||||
|
||||
struct Channel
|
||||
{
|
||||
struct Channel
|
||||
{
|
||||
DetType type;
|
||||
DetAttribute attribute; //What kind 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>::iterator Iterator;
|
||||
|
||||
|
@ -65,10 +66,10 @@ public:
|
|||
inline Iterator End() { return m_cmap.end(); };
|
||||
inline bool IsValid() { return m_validFlag; };
|
||||
|
||||
private:
|
||||
private:
|
||||
Containter m_cmap;
|
||||
bool m_validFlag;
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -11,37 +11,39 @@
|
|||
#include "EventBuilder.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_buffersize = bufsize*hitsize;
|
||||
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_buffersize = bufsize*hitsize;
|
||||
hitBuffer.resize(m_buffersize);
|
||||
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),
|
||||
bufsize(bsize), m_file(std::make_shared<std::ifstream>()), eofFlag(false)
|
||||
{
|
||||
{
|
||||
m_buffersize = bufsize*hitsize;
|
||||
hitBuffer.resize(m_buffersize);
|
||||
Open(filename);
|
||||
}
|
||||
}
|
||||
|
||||
CompassFile::~CompassFile()
|
||||
{
|
||||
CompassFile::~CompassFile()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
void CompassFile::Open(const std::string& filename)
|
||||
{
|
||||
void CompassFile::Open(const std::string& filename)
|
||||
{
|
||||
eofFlag = false;
|
||||
hitUsedFlag = true;
|
||||
m_filename = filename;
|
||||
|
@ -58,18 +60,18 @@ void CompassFile::Open(const std::string& filename)
|
|||
{
|
||||
m_file->seekg(0, std::ios_base::beg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CompassFile::Close()
|
||||
{
|
||||
void CompassFile::Close()
|
||||
{
|
||||
if(IsOpen())
|
||||
{
|
||||
m_file->close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int CompassFile::GetHitSize()
|
||||
{
|
||||
int CompassFile::GetHitSize()
|
||||
{
|
||||
if(!IsOpen())
|
||||
{
|
||||
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;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
GetNextHit() is the function which... gets the next hit
|
||||
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
|
||||
that the hit should be free game.
|
||||
|
||||
If the file cannot be opened, signals as though file is EOF
|
||||
*/
|
||||
bool CompassFile::GetNextHit()
|
||||
{
|
||||
*/
|
||||
bool CompassFile::GetNextHit()
|
||||
{
|
||||
if(!IsOpen()) return true;
|
||||
|
||||
if((bufferIter == nullptr || bufferIter == bufferEnd) && !IsEOF())
|
||||
|
@ -115,17 +117,17 @@ bool CompassFile::GetNextHit()
|
|||
}
|
||||
|
||||
return eofFlag;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
GetNextBuffer() ... self-explanatory name
|
||||
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
|
||||
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).
|
||||
*/
|
||||
void CompassFile::GetNextBuffer()
|
||||
{
|
||||
*/
|
||||
void CompassFile::GetNextBuffer()
|
||||
{
|
||||
|
||||
if(m_file->eof())
|
||||
{
|
||||
|
@ -138,10 +140,10 @@ void CompassFile::GetNextBuffer()
|
|||
bufferIter = hitBuffer.data();
|
||||
bufferEnd = bufferIter + m_file->gcount(); //one past the last datum
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void CompassFile::ParseNextHit()
|
||||
{
|
||||
void CompassFile::ParseNextHit()
|
||||
{
|
||||
|
||||
m_currentHit.board = *((uint16_t*)bufferIter);
|
||||
bufferIter += 2;
|
||||
|
@ -164,4 +166,6 @@ void CompassFile::ParseNextHit()
|
|||
m_currentHit.timestamp += m_smap->GetShift(gchan);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -15,10 +15,12 @@
|
|||
#include "ShiftMap.h"
|
||||
#include <memory>
|
||||
|
||||
class CompassFile
|
||||
{
|
||||
namespace EventBuilder {
|
||||
|
||||
public:
|
||||
class CompassFile
|
||||
{
|
||||
|
||||
public:
|
||||
CompassFile();
|
||||
CompassFile(const std::string& filename);
|
||||
CompassFile(const std::string& filename, int bsize);
|
||||
|
@ -39,7 +41,7 @@ public:
|
|||
inline unsigned int GetNumberOfHits() const { return m_nHits; }
|
||||
|
||||
|
||||
private:
|
||||
private:
|
||||
int GetHitSize();
|
||||
void ParseNextHit();
|
||||
void GetNextBuffer();
|
||||
|
@ -65,7 +67,8 @@ private:
|
|||
unsigned int m_size; //size of the file in bytes
|
||||
unsigned int m_nHits; //number of hits in the file (m_size/24)
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
#ifndef COMPASS_HIT_H
|
||||
#define COMPASS_HIT_H
|
||||
|
||||
struct CompassHit
|
||||
{
|
||||
namespace EventBuilder {
|
||||
|
||||
struct CompassHit
|
||||
{
|
||||
uint16_t board = 400;
|
||||
uint16_t channel = 400;
|
||||
uint64_t timestamp = 0;
|
||||
|
@ -10,6 +12,8 @@ struct CompassHit
|
|||
uint16_t sgate = 0;
|
||||
uint32_t flags = 0;
|
||||
uint32_t Ns = 0;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -17,24 +17,26 @@
|
|||
#include "SFPAnalyzer.h"
|
||||
#include "FlagHandler.h"
|
||||
|
||||
CompassRun::CompassRun() :
|
||||
namespace EventBuilder {
|
||||
|
||||
CompassRun::CompassRun() :
|
||||
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)
|
||||
{
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
CompassRun::~CompassRun() {}
|
||||
CompassRun::~CompassRun() {}
|
||||
|
||||
|
||||
/*Load em into a map*/
|
||||
void CompassRun::SetScalers()
|
||||
{
|
||||
/*Load em into a map*/
|
||||
void CompassRun::SetScalers()
|
||||
{
|
||||
std::ifstream input(m_scalerinput);
|
||||
if(!input.is_open())
|
||||
return;
|
||||
|
@ -52,10 +54,10 @@ void CompassRun::SetScalers()
|
|||
m_scaler_map[filename] = TParameter<Long64_t>(varname.c_str(), init);
|
||||
}
|
||||
input.close();
|
||||
}
|
||||
}
|
||||
|
||||
bool CompassRun::GetBinaryFiles()
|
||||
{
|
||||
bool CompassRun::GetBinaryFiles()
|
||||
{
|
||||
std::string prefix = "";
|
||||
std::string suffix = ".bin"; //binaries
|
||||
RunCollector grabber(m_directory, prefix, suffix);
|
||||
|
@ -95,14 +97,14 @@ bool CompassRun::GetBinaryFiles()
|
|||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
Pure counting of scalers. Potential upgrade path to something like
|
||||
average count rate etc.
|
||||
*/
|
||||
void CompassRun::ReadScalerData(const std::string& filename)
|
||||
{
|
||||
*/
|
||||
void CompassRun::ReadScalerData(const std::string& filename)
|
||||
{
|
||||
if(!m_scaler_flag)
|
||||
return;
|
||||
|
||||
|
@ -118,9 +120,9 @@ void CompassRun::ReadScalerData(const std::string& filename)
|
|||
count++;
|
||||
}
|
||||
this_param.SetVal(count);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
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
|
||||
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
|
||||
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.
|
||||
*/
|
||||
bool CompassRun::GetHitsFromFiles()
|
||||
{
|
||||
*/
|
||||
bool CompassRun::GetHitsFromFiles()
|
||||
{
|
||||
|
||||
std::pair<CompassHit, bool*> earliestHit = std::make_pair(CompassHit(), nullptr);
|
||||
for(unsigned int i=startIndex; i<m_datafiles.size(); i++)
|
||||
|
@ -159,9 +161,9 @@ bool CompassRun::GetHitsFromFiles()
|
|||
hit = earliestHit.first;
|
||||
*earliestHit.second = 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");
|
||||
TTree* outtree = new TTree("Data", "Data");
|
||||
|
||||
|
@ -223,10 +225,10 @@ void CompassRun::Convert2RawRoot(const std::string& name) {
|
|||
entry.second.Write();
|
||||
|
||||
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");
|
||||
TTree* outtree = new TTree("SortTree", "SortTree");
|
||||
|
||||
|
@ -297,10 +299,10 @@ void CompassRun::Convert2SortedRoot(const std::string& name, const std::string&
|
|||
|
||||
coincidizer.GetEventStats()->Write();
|
||||
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");
|
||||
TTree* outtree = new TTree("SortTree", "SortTree");
|
||||
|
||||
|
@ -387,12 +389,12 @@ void CompassRun::Convert2FastSortedRoot(const std::string& name, const std::stri
|
|||
|
||||
coincidizer.GetEventStats()->Write();
|
||||
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)
|
||||
{
|
||||
{
|
||||
|
||||
TFile* output = TFile::Open(name.c_str(), "RECREATE");
|
||||
TTree* outtree = new TTree("SPSTree", "SPSTree");
|
||||
|
@ -488,11 +490,11 @@ void CompassRun::Convert2SlowAnalyzedRoot(const std::string& name, const std::st
|
|||
analyzer.GetHashTable()->Write();
|
||||
analyzer.ClearHashTable();
|
||||
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)
|
||||
{
|
||||
{
|
||||
|
||||
TFile* output = TFile::Open(name.c_str(), "RECREATE");
|
||||
TTree* outtree = new TTree("SPSTree", "SPSTree");
|
||||
|
@ -598,12 +600,14 @@ void CompassRun::Convert2FastAnalyzedRoot(const std::string& name, const std::st
|
|||
analyzer.GetHashTable()->Write();
|
||||
analyzer.ClearHashTable();
|
||||
output->Close();
|
||||
}
|
||||
}
|
||||
|
||||
void CompassRun::SetProgressBar()
|
||||
{
|
||||
void CompassRun::SetProgressBar()
|
||||
{
|
||||
m_pb->SetMax(m_totalHits);
|
||||
m_pb->SetMin(0);
|
||||
m_pb->SetPosition(0);
|
||||
gSystem->ProcessEvents();
|
||||
}
|
||||
|
||||
}
|
|
@ -18,10 +18,12 @@
|
|||
#include <TGProgressBar.h>
|
||||
#include <TSystem.h>
|
||||
|
||||
class CompassRun
|
||||
{
|
||||
namespace EventBuilder {
|
||||
|
||||
public:
|
||||
class CompassRun
|
||||
{
|
||||
|
||||
public:
|
||||
CompassRun();
|
||||
CompassRun(const std::string& dir);
|
||||
~CompassRun();
|
||||
|
@ -39,7 +41,7 @@ public:
|
|||
|
||||
inline void AttachProgressBar(TGProgressBar* pb) { m_pb = pb; }
|
||||
|
||||
private:
|
||||
private:
|
||||
bool GetBinaryFiles();
|
||||
bool GetHitsFromFiles();
|
||||
void SetScalers();
|
||||
|
@ -66,6 +68,8 @@ private:
|
|||
|
||||
//GUI progress bar, if attached
|
||||
TGProgressBar* m_pb;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,28 +1,30 @@
|
|||
#include "EventBuilder.h"
|
||||
#include "CutHandler.h"
|
||||
|
||||
CutHandler::CutHandler() :
|
||||
namespace EventBuilder {
|
||||
|
||||
CutHandler::CutHandler() :
|
||||
validFlag(false)
|
||||
{
|
||||
InitVariableMap();
|
||||
}
|
||||
|
||||
CutHandler::CutHandler(const std::string& filename) :
|
||||
CutHandler::CutHandler(const std::string& filename) :
|
||||
validFlag(false)
|
||||
{
|
||||
{
|
||||
SetCuts(filename);
|
||||
InitVariableMap();
|
||||
}
|
||||
}
|
||||
|
||||
CutHandler::~CutHandler()
|
||||
{
|
||||
CutHandler::~CutHandler()
|
||||
{
|
||||
for(unsigned int i=0; i<file_array.size(); i++)
|
||||
if(file_array[i]->IsOpen())
|
||||
file_array[i]->Close();
|
||||
}
|
||||
}
|
||||
|
||||
void CutHandler::SetCuts(const std::string& filename)
|
||||
{
|
||||
void CutHandler::SetCuts(const std::string& filename)
|
||||
{
|
||||
std::ifstream cutlist(filename);
|
||||
|
||||
if(!cutlist.is_open())
|
||||
|
@ -63,23 +65,23 @@ void CutHandler::SetCuts(const std::string& filename)
|
|||
validFlag = true;
|
||||
else
|
||||
validFlag = false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
ADD MORE VARIABLES HERE!
|
||||
*/
|
||||
void CutHandler::InitVariableMap()
|
||||
{
|
||||
*/
|
||||
void CutHandler::InitVariableMap()
|
||||
{
|
||||
varmap["x1"] = &m_event.x1;
|
||||
varmap["x2"] = &m_event.x2;
|
||||
varmap["xavg"] = &m_event.xavg;
|
||||
varmap["scintLeft"] = &m_event.scintLeft;
|
||||
varmap["anodeBack"] = &m_event.anodeBack;
|
||||
varmap["cathode"] = &m_event.cathode;
|
||||
}
|
||||
}
|
||||
|
||||
bool CutHandler::IsInside(const ProcessedEvent* eaddress)
|
||||
{
|
||||
bool CutHandler::IsInside(const ProcessedEvent* eaddress)
|
||||
{
|
||||
m_event = *eaddress;
|
||||
std::string x, y;
|
||||
for(unsigned int i=0; i<cut_array.size(); i++)
|
||||
|
@ -101,4 +103,6 @@ bool CutHandler::IsInside(const ProcessedEvent* eaddress)
|
|||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,10 +1,12 @@
|
|||
#ifndef CUTHANDLER_H
|
||||
#define CUTHANDLER_H
|
||||
|
||||
#include "DataStructs.h"
|
||||
#include "../spsdict/DataStructs.h"
|
||||
|
||||
class CutHandler {
|
||||
public:
|
||||
namespace EventBuilder {
|
||||
|
||||
class CutHandler {
|
||||
public:
|
||||
CutHandler();
|
||||
CutHandler(const std::string& filename);
|
||||
~CutHandler();
|
||||
|
@ -13,7 +15,7 @@ public:
|
|||
bool IsInside(const ProcessedEvent* eaddress);
|
||||
std::vector<TCutG*> GetCuts() { return cut_array; }
|
||||
|
||||
private:
|
||||
private:
|
||||
void InitVariableMap();
|
||||
|
||||
std::vector<TCutG*> cut_array;
|
||||
|
@ -21,7 +23,8 @@ private:
|
|||
std::unordered_map<std::string, double*> varmap;
|
||||
bool validFlag;
|
||||
ProcessedEvent m_event;
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
|
@ -16,19 +16,21 @@
|
|||
#include "SFPAnalyzer.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_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)
|
||||
{
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
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::ifstream input(fullpath);
|
||||
if(!input.is_open())
|
||||
|
@ -70,10 +72,10 @@ bool EVBApp::ReadConfigFile(const std::string& fullpath)
|
|||
std::cout<<"Completed."<<std::endl;
|
||||
|
||||
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::ofstream output(fullpath);
|
||||
|
@ -115,10 +117,10 @@ void EVBApp::WriteConfigFile(const std::string& fullpath)
|
|||
|
||||
std::cout<<"Completed."<<std::endl;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void EVBApp::PlotHistograms()
|
||||
{
|
||||
void EVBApp::PlotHistograms()
|
||||
{
|
||||
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";
|
||||
SFPPlotter grammer;
|
||||
|
@ -145,10 +147,10 @@ void EVBApp::PlotHistograms()
|
|||
}
|
||||
std::cout<<"-------------------------------------------"<<std::endl;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void EVBApp::Convert2RawRoot()
|
||||
{
|
||||
void EVBApp::Convert2RawRoot()
|
||||
{
|
||||
std::string rawroot_dir = m_workspace+"/raw_root/";
|
||||
std::string unpack_dir = m_workspace+"/temp_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;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
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 file_dir = m_workspace+"/analyzed/";
|
||||
std::cout<<"-------------GWM Event Builder-------------"<<std::endl;
|
||||
|
@ -217,10 +219,10 @@ void EVBApp::MergeROOTFiles()
|
|||
}
|
||||
std::cout<<" Complete."<<std::endl;
|
||||
std::cout<<"-------------------------------------------"<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void EVBApp::Convert2SortedRoot()
|
||||
{
|
||||
void EVBApp::Convert2SortedRoot()
|
||||
{
|
||||
std::string sortroot_dir = m_workspace+"/sorted/";
|
||||
std::string unpack_dir = m_workspace+"/temp_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;
|
||||
}
|
||||
}
|
||||
|
||||
void EVBApp::Convert2FastSortedRoot() {
|
||||
void EVBApp::Convert2FastSortedRoot() {
|
||||
std::string sortroot_dir = m_workspace+"/fast/";
|
||||
std::string unpack_dir = m_workspace+"/temp_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;
|
||||
}
|
||||
}
|
||||
|
||||
void EVBApp::Convert2SlowAnalyzedRoot() {
|
||||
void EVBApp::Convert2SlowAnalyzedRoot() {
|
||||
std::string sortroot_dir = m_workspace+"/analyzed/";
|
||||
std::string unpack_dir = m_workspace+"/temp_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;
|
||||
}
|
||||
}
|
||||
|
||||
void EVBApp::Convert2FastAnalyzedRoot()
|
||||
{
|
||||
void EVBApp::Convert2FastAnalyzedRoot()
|
||||
{
|
||||
std::string sortroot_dir = m_workspace+"/analyzed/";
|
||||
std::string unpack_dir = m_workspace+"/temp_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;
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -433,4 +435,6 @@ bool EVBApp::SetKinematicParameters(int zt, int at, int zp, int ap, int ze, int
|
|||
m_AR = (at + ap - ae);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -12,8 +12,10 @@
|
|||
#include "RunCollector.h"
|
||||
#include <TGProgressBar.h>
|
||||
|
||||
class EVBApp {
|
||||
public:
|
||||
namespace EventBuilder {
|
||||
|
||||
class EVBApp {
|
||||
public:
|
||||
EVBApp();
|
||||
~EVBApp();
|
||||
|
||||
|
@ -74,7 +76,7 @@ public:
|
|||
Plot
|
||||
};
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
int m_rmin, m_rmax;
|
||||
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;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -36,11 +36,13 @@
|
|||
#include "MassLookup.h"
|
||||
#include "FP_kinematics.h"
|
||||
|
||||
//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,
|
||||
namespace EventBuilder {
|
||||
|
||||
//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)
|
||||
{
|
||||
{
|
||||
|
||||
/* CONSTANTS */
|
||||
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;
|
||||
return -1*rho*DISP*MAG*K; //delta-Z in cm
|
||||
|
||||
}
|
||||
|
||||
double Wire_Dist() {return 4.28625;} //cm
|
||||
|
||||
}
|
||||
|
||||
double Wire_Dist() {return 4.28625;} //cm
|
||||
|
||||
|
|
|
@ -32,11 +32,15 @@
|
|||
#ifndef FP_KINEMATICS
|
||||
#define FP_KINEMATICS
|
||||
|
||||
//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,
|
||||
namespace EventBuilder {
|
||||
|
||||
//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 Wire_Dist();
|
||||
double Wire_Dist();
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,30 +1,31 @@
|
|||
#include "EventBuilder.h"
|
||||
#include "FastSort.h"
|
||||
|
||||
//windows given in picoseconds, converted to nanoseconds
|
||||
FastSort::FastSort(float si_windowSize, float ion_windowSize) :
|
||||
namespace EventBuilder {
|
||||
//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)
|
||||
{
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
FastSort::~FastSort()
|
||||
{
|
||||
FastSort::~FastSort()
|
||||
{
|
||||
delete event_address;
|
||||
}
|
||||
}
|
||||
|
||||
void FastSort::ResetSABRE()
|
||||
{
|
||||
void FastSort::ResetSABRE()
|
||||
{
|
||||
for(int i=0; i<5; i++)
|
||||
fastEvent.sabreArray[i] = sblank;
|
||||
}
|
||||
}
|
||||
|
||||
void FastSort::ResetFocalPlane()
|
||||
{
|
||||
void FastSort::ResetFocalPlane()
|
||||
{
|
||||
fastEvent.focalPlane = fpblank;
|
||||
}
|
||||
}
|
||||
|
||||
/*Assign a set of ion chamber data to the scintillator*/
|
||||
void FastSort::ProcessFocalPlane(unsigned int scint_index, unsigned int ionch_index) {
|
||||
/*Assign a set of ion chamber data to the scintillator*/
|
||||
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 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)
|
||||
fastEvent.focalPlane.cathode.push_back(slowEvent.focalPlane.cathode[ionch_index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*Assign a set of SABRE data that falls within the coincidence window*/
|
||||
void FastSort::ProcessSABRE(unsigned int scint_index)
|
||||
{
|
||||
/*Assign a set of SABRE data that falls within the coincidence window*/
|
||||
void FastSort::ProcessSABRE(unsigned int scint_index)
|
||||
{
|
||||
for(int i=0; i<5; i++)
|
||||
{ //loop over SABRE silicons
|
||||
std::vector<DetectorHit> rings;
|
||||
|
@ -90,10 +91,10 @@ void FastSort::ProcessSABRE(unsigned int scint_index)
|
|||
fastEvent.sabreArray[i].rings = rings;
|
||||
fastEvent.sabreArray[i].wedges = wedges;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<CoincEvent> FastSort::GetFastEvents(CoincEvent& event)
|
||||
{
|
||||
std::vector<CoincEvent> FastSort::GetFastEvents(CoincEvent& event)
|
||||
{
|
||||
slowEvent = event;
|
||||
std::vector<CoincEvent> fast_events;
|
||||
|
||||
|
@ -122,4 +123,6 @@ std::vector<CoincEvent> FastSort::GetFastEvents(CoincEvent& event)
|
|||
}
|
||||
}
|
||||
return fast_events;
|
||||
}
|
||||
|
||||
}
|
|
@ -9,15 +9,17 @@
|
|||
#include "DataStructs.h"
|
||||
#include <TH2.h>
|
||||
|
||||
class FastSort
|
||||
{
|
||||
namespace EventBuilder {
|
||||
|
||||
public:
|
||||
class FastSort
|
||||
{
|
||||
|
||||
public:
|
||||
FastSort(float si_windowSize, float ion_windowSize);
|
||||
~FastSort();
|
||||
std::vector<CoincEvent> GetFastEvents(CoincEvent& event);
|
||||
|
||||
private:
|
||||
private:
|
||||
void ResetSABRE();
|
||||
void ResetFocalPlane();
|
||||
void ProcessSABRE(unsigned int scint_index);
|
||||
|
@ -29,6 +31,7 @@ private:
|
|||
SabreDetector sblank;
|
||||
FPDetector fpblank;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,24 +1,26 @@
|
|||
#include "EventBuilder.h"
|
||||
#include "FlagHandler.h"
|
||||
|
||||
FlagHandler::FlagHandler() :
|
||||
namespace EventBuilder {
|
||||
|
||||
FlagHandler::FlagHandler() :
|
||||
log("./event_log.txt")
|
||||
{
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
FlagHandler::FlagHandler(const std::string& filename) :
|
||||
FlagHandler::FlagHandler(const std::string& filename) :
|
||||
log(filename)
|
||||
{
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
FlagHandler::~FlagHandler()
|
||||
{
|
||||
FlagHandler::~FlagHandler()
|
||||
{
|
||||
WriteLog();
|
||||
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;
|
||||
FlagCount& counter = event_count_map[gchan]; //yikes
|
||||
|
@ -73,10 +75,10 @@ void FlagHandler::CheckFlag(int board, int channel, int flag)
|
|||
if(flag & ADCShutdown)
|
||||
counter.adc_shutdown++;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void FlagHandler::WriteLog()
|
||||
{
|
||||
void FlagHandler::WriteLog()
|
||||
{
|
||||
log<<"Event Flag Log"<<std::endl;
|
||||
log<<"-----------------------------"<<std::endl;
|
||||
for(auto& counter : event_count_map)
|
||||
|
@ -102,5 +104,5 @@ void FlagHandler::WriteLog()
|
|||
log<<"ADC Shutdown: "<<counter.second.adc_shutdown<<std::endl;
|
||||
log<<"-----------------------------"<<std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,8 +3,10 @@
|
|||
|
||||
#include <map>
|
||||
|
||||
struct FlagCount
|
||||
{
|
||||
namespace EventBuilder {
|
||||
|
||||
struct FlagCount
|
||||
{
|
||||
long total_counts=0;
|
||||
long dead_time=0;
|
||||
long time_roll=0;
|
||||
|
@ -23,11 +25,11 @@ struct FlagCount
|
|||
long pll_lock_loss=0;
|
||||
long over_temp=0;
|
||||
long adc_shutdown=0;
|
||||
};
|
||||
};
|
||||
|
||||
class FlagHandler
|
||||
{
|
||||
public:
|
||||
class FlagHandler
|
||||
{
|
||||
public:
|
||||
FlagHandler();
|
||||
FlagHandler(const std::string& filename);
|
||||
~FlagHandler();
|
||||
|
@ -51,11 +53,12 @@ public:
|
|||
const int OverTemp = 0x00100000;
|
||||
const int ADCShutdown = 0x00200000;
|
||||
|
||||
private:
|
||||
private:
|
||||
std::ofstream log;
|
||||
std::map<int, FlagCount> event_count_map;
|
||||
|
||||
void WriteLog();
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -11,13 +11,14 @@ Written by G.W. McCann Aug. 2020
|
|||
#include "EventBuilder.h"
|
||||
#include "MassLookup.h"
|
||||
|
||||
namespace EventBuilder {
|
||||
|
||||
/*
|
||||
/*
|
||||
Read in AMDC mass file, preformated to remove excess info. Here assumes that by default
|
||||
the file is in a local directory etc/
|
||||
*/
|
||||
MassLookup::MassLookup()
|
||||
{
|
||||
*/
|
||||
MassLookup::MassLookup()
|
||||
{
|
||||
std::string filepath;
|
||||
#ifdef ETC_DIR_PATH
|
||||
filepath = ETC_DIR_PATH;
|
||||
|
@ -44,13 +45,13 @@ MassLookup::MassLookup()
|
|||
}
|
||||
else
|
||||
std::cerr<<"Unable to open mass.txt at MassLookup! Prepare for errors."<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
MassLookup::~MassLookup() {}
|
||||
MassLookup::~MassLookup() {}
|
||||
|
||||
//Returns nuclear mass in MeV
|
||||
double MassLookup::FindMass(int Z, int A)
|
||||
{
|
||||
//Returns nuclear mass in MeV
|
||||
double MassLookup::FindMass(int Z, int A)
|
||||
{
|
||||
std::string key = "("+std::to_string(Z)+","+std::to_string(A)+")";
|
||||
auto data = massTable.find(key);
|
||||
if(data == massTable.end())
|
||||
|
@ -59,11 +60,11 @@ double MassLookup::FindMass(int Z, int A)
|
|||
return 0;
|
||||
}
|
||||
return data->second;
|
||||
}
|
||||
}
|
||||
|
||||
//returns element symbol
|
||||
std::string MassLookup::FindSymbol(int Z, int A)
|
||||
{
|
||||
//returns element symbol
|
||||
std::string MassLookup::FindSymbol(int Z, int A)
|
||||
{
|
||||
auto data = elementTable.find(Z);
|
||||
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;
|
||||
return fullsymbol;
|
||||
}
|
||||
}
|
|
@ -11,16 +11,18 @@ Written by G.W. McCann Aug. 2020
|
|||
#ifndef MASS_LOOKUP_H
|
||||
#define MASS_LOOKUP_H
|
||||
|
||||
class MassLookup
|
||||
{
|
||||
namespace EventBuilder {
|
||||
|
||||
public:
|
||||
class MassLookup
|
||||
{
|
||||
|
||||
public:
|
||||
MassLookup();
|
||||
~MassLookup();
|
||||
double FindMass(int Z, int A);
|
||||
std::string FindSymbol(int Z, int A);
|
||||
|
||||
private:
|
||||
private:
|
||||
std::unordered_map<std::string, double> massTable;
|
||||
std::unordered_map<int, std::string> elementTable;
|
||||
|
||||
|
@ -28,8 +30,10 @@ private:
|
|||
static constexpr double u_to_mev = 931.4940954;
|
||||
static constexpr double electron_mass = 0.000548579909;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
//static instance for use throught program
|
||||
static MassLookup MASS;
|
||||
//static instance for use throught program
|
||||
static MassLookup MASS;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -8,16 +8,18 @@
|
|||
#include "EventBuilder.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");
|
||||
TTree* tree = (TTree*) file->Get("Data");
|
||||
|
||||
|
@ -37,4 +39,6 @@ bool OrderChecker::IsOrdered(const std::string& filename)
|
|||
|
||||
file->Close();
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -8,12 +8,16 @@
|
|||
#ifndef ORDERCHECKER_H
|
||||
#define ORDERCHECKER_H
|
||||
|
||||
class OrderChecker
|
||||
{
|
||||
public:
|
||||
namespace EventBuilder {
|
||||
|
||||
class OrderChecker
|
||||
{
|
||||
public:
|
||||
OrderChecker();
|
||||
~OrderChecker();
|
||||
bool IsOrdered(const std::string& filename);
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -7,34 +7,36 @@
|
|||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
|
||||
RunCollector::RunCollector():
|
||||
namespace EventBuilder {
|
||||
|
||||
RunCollector::RunCollector():
|
||||
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)
|
||||
{
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
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_prefix = prefix.c_str();
|
||||
m_suffix = suffix.c_str();
|
||||
m_minRun = min; m_maxRun = max;
|
||||
m_initFlag = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool RunCollector::GrabAllFiles()
|
||||
{
|
||||
bool RunCollector::GrabAllFiles()
|
||||
{
|
||||
if(!m_initFlag)
|
||||
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;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string RunCollector::GrabFile(int runNum) {
|
||||
std::string RunCollector::GrabFile(int runNum) {
|
||||
if(!m_initFlag)
|
||||
return "";
|
||||
TSystemDirectory sysdir(m_directory.c_str(), m_directory.c_str());
|
||||
|
@ -102,11 +104,11 @@ std::string RunCollector::GrabFile(int runNum) {
|
|||
|
||||
delete flist;
|
||||
return fname;
|
||||
}
|
||||
}
|
||||
|
||||
/*Grabs all files within a specified run range*/
|
||||
bool RunCollector::GrabFilesInRange()
|
||||
{
|
||||
/*Grabs all files within a specified run range*/
|
||||
bool RunCollector::GrabFilesInRange()
|
||||
{
|
||||
if(!m_initFlag)
|
||||
return false;
|
||||
|
||||
|
@ -151,10 +153,10 @@ bool RunCollector::GrabFilesInRange()
|
|||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
bool RunCollector::Merge_hadd(const std::string& outname)
|
||||
{
|
||||
bool RunCollector::Merge_hadd(const std::string& outname)
|
||||
{
|
||||
if(!m_initFlag)
|
||||
return false;
|
||||
|
||||
|
@ -188,10 +190,10 @@ bool RunCollector::Merge_hadd(const std::string& outname)
|
|||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool RunCollector::Merge_TChain(const std::string& outname)
|
||||
{
|
||||
bool RunCollector::Merge_TChain(const std::string& outname)
|
||||
{
|
||||
if(!m_initFlag)
|
||||
return false;
|
||||
TFile *output = new TFile(outname.c_str(), "RECREATE");
|
||||
|
@ -228,4 +230,6 @@ bool RunCollector::Merge_TChain(const std::string& outname)
|
|||
if(output->IsOpen())
|
||||
output->Close();
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -10,9 +10,11 @@
|
|||
#ifndef RUNCOLLECTOR_H
|
||||
#define RUNCOLLECTOR_H
|
||||
|
||||
class RunCollector
|
||||
{
|
||||
public:
|
||||
namespace EventBuilder {
|
||||
|
||||
class RunCollector
|
||||
{
|
||||
public:
|
||||
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, int min, int max);
|
||||
|
@ -30,7 +32,7 @@ public:
|
|||
inline int GetRunMax() { return m_maxRun; }
|
||||
inline const std::vector<std::string>& GetFileList() { return m_filelist; }
|
||||
|
||||
private:
|
||||
private:
|
||||
bool m_initFlag;
|
||||
std::string m_directory;
|
||||
std::string m_prefix;
|
||||
|
@ -39,6 +41,7 @@ private:
|
|||
const int m_maxAllowedRuns = 1000; //class run limit
|
||||
std::vector<std::string> m_filelist;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -12,45 +12,46 @@
|
|||
#include "EventBuilder.h"
|
||||
#include "SFPAnalyzer.h"
|
||||
|
||||
namespace EventBuilder {
|
||||
|
||||
/*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,
|
||||
/*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,
|
||||
double angle, double b)
|
||||
{
|
||||
{
|
||||
zfp = Delta_Z(zt, at, zp, ap, ze, ae, ep, angle, b);
|
||||
event_address = new CoincEvent();
|
||||
rootObj = new THashTable();
|
||||
GetWeights();
|
||||
}
|
||||
}
|
||||
|
||||
SFPAnalyzer::~SFPAnalyzer()
|
||||
{
|
||||
SFPAnalyzer::~SFPAnalyzer()
|
||||
{
|
||||
rootObj->Clear();
|
||||
delete rootObj;
|
||||
delete event_address;
|
||||
}
|
||||
}
|
||||
|
||||
void SFPAnalyzer::Reset()
|
||||
{
|
||||
void SFPAnalyzer::Reset()
|
||||
{
|
||||
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
|
||||
*from the two focal plane points and finding the intersection with
|
||||
*the kinematic focal plane
|
||||
*/
|
||||
void SFPAnalyzer::GetWeights()
|
||||
{
|
||||
void SFPAnalyzer::GetWeights()
|
||||
{
|
||||
w1 = (Wire_Dist()/2.0-zfp)/Wire_Dist();
|
||||
w2 = 1.0-w1;
|
||||
std::cout<<"w1: "<<w1<<" w2: "<<w2<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
/*2D histogram fill wrapper for use with THashTable (faster)*/
|
||||
void SFPAnalyzer::MyFill(const std::string& name, int binsx, double minx, double maxx, double valuex,
|
||||
/*2D histogram fill wrapper for use with THashTable (faster)*/
|
||||
void SFPAnalyzer::MyFill(const std::string& name, int binsx, double minx, double maxx, double valuex,
|
||||
int binsy, double miny, double maxy, double valuey)
|
||||
{
|
||||
{
|
||||
TH2F *histo = (TH2F*) rootObj->FindObject(name.c_str());
|
||||
if(histo != nullptr)
|
||||
histo->Fill(valuex, valuey);
|
||||
|
@ -60,11 +61,11 @@ void SFPAnalyzer::MyFill(const std::string& name, int binsx, double minx, double
|
|||
h->Fill(valuex, valuey);
|
||||
rootObj->Add(h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*1D histogram fill wrapper for use with THashTable (faster)*/
|
||||
void SFPAnalyzer::MyFill(const std::string& name, int binsx, double minx, double maxx, double valuex)
|
||||
{
|
||||
/*1D histogram fill wrapper for use with THashTable (faster)*/
|
||||
void SFPAnalyzer::MyFill(const std::string& name, int binsx, double minx, double maxx, double valuex)
|
||||
{
|
||||
TH1F *histo = (TH1F*) rootObj->FindObject(name.c_str());
|
||||
if(histo != nullptr)
|
||||
histo->Fill(valuex);
|
||||
|
@ -74,10 +75,10 @@ void SFPAnalyzer::MyFill(const std::string& name, int binsx, double minx, double
|
|||
h->Fill(valuex);
|
||||
rootObj->Add(h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SFPAnalyzer::AnalyzeEvent(CoincEvent& event)
|
||||
{
|
||||
void SFPAnalyzer::AnalyzeEvent(CoincEvent& event)
|
||||
{
|
||||
Reset();
|
||||
if(!event.focalPlane.anodeF.empty())
|
||||
{
|
||||
|
@ -196,10 +197,12 @@ void SFPAnalyzer::AnalyzeEvent(CoincEvent& event)
|
|||
pevent.fp1_y = pevent.anodeFrontTime-pevent.scintRightTime;
|
||||
if(pevent.anodeBackTime != -1 && pevent.scintRightTime != -1)
|
||||
pevent.fp2_y = pevent.anodeBackTime-pevent.scintRightTime;
|
||||
}
|
||||
}
|
||||
|
||||
ProcessedEvent SFPAnalyzer::GetProcessedEvent(CoincEvent& event)
|
||||
{
|
||||
ProcessedEvent SFPAnalyzer::GetProcessedEvent(CoincEvent& event)
|
||||
{
|
||||
AnalyzeEvent(event);
|
||||
return pevent;
|
||||
}
|
||||
|
||||
}
|
|
@ -13,10 +13,11 @@
|
|||
#include "DataStructs.h"
|
||||
#include "FP_kinematics.h"
|
||||
|
||||
namespace EventBuilder {
|
||||
|
||||
class SFPAnalyzer
|
||||
{
|
||||
public:
|
||||
class SFPAnalyzer
|
||||
{
|
||||
public:
|
||||
SFPAnalyzer(int zt, int at, int zp, int ap, int ze, int ae, double ep, double angle,
|
||||
double b);
|
||||
~SFPAnalyzer();
|
||||
|
@ -24,7 +25,7 @@ public:
|
|||
inline void ClearHashTable() { rootObj->Clear(); }
|
||||
inline THashTable* GetHashTable() { return rootObj; }
|
||||
|
||||
private:
|
||||
private:
|
||||
void Reset(); //Sets ouput structure back to "zero"
|
||||
void GetWeights(); //weights for xavg
|
||||
void AnalyzeEvent(CoincEvent& event);
|
||||
|
@ -40,6 +41,8 @@ private:
|
|||
double w1, w2, zfp;
|
||||
|
||||
THashTable *rootObj; //root storage
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -10,22 +10,24 @@
|
|||
#include "SFPPlotter.h"
|
||||
#include <TSystem.h>
|
||||
|
||||
/*Generates storage and initializes pointers*/
|
||||
SFPPlotter::SFPPlotter()
|
||||
{
|
||||
namespace EventBuilder {
|
||||
|
||||
/*Generates storage and initializes pointers*/
|
||||
SFPPlotter::SFPPlotter()
|
||||
{
|
||||
event_address = new ProcessedEvent();
|
||||
m_pb = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
SFPPlotter::~SFPPlotter()
|
||||
{
|
||||
SFPPlotter::~SFPPlotter()
|
||||
{
|
||||
delete event_address;
|
||||
}
|
||||
}
|
||||
|
||||
/*2D histogram fill wrapper*/
|
||||
void SFPPlotter::MyFill(THashTable* table, const std::string& name, int binsx, double minx, double maxx, double valuex,
|
||||
/*2D histogram fill wrapper*/
|
||||
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)
|
||||
{
|
||||
{
|
||||
TH2F *histo = (TH2F*) table->FindObject(name.c_str());
|
||||
if(histo != nullptr)
|
||||
histo->Fill(valuex, valuey);
|
||||
|
@ -35,11 +37,11 @@ void SFPPlotter::MyFill(THashTable* table, const std::string& name, int binsx, d
|
|||
h->Fill(valuex, valuey);
|
||||
table->Add(h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*1D histogram fill wrapper*/
|
||||
void SFPPlotter::MyFill(THashTable* table, const std::string& name, int binsx, double minx, double maxx, double valuex)
|
||||
{
|
||||
/*1D histogram fill wrapper*/
|
||||
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());
|
||||
if(histo != nullptr)
|
||||
histo->Fill(valuex);
|
||||
|
@ -49,11 +51,11 @@ void SFPPlotter::MyFill(THashTable* table, const std::string& name, int binsx, d
|
|||
h->Fill(valuex);
|
||||
table->Add(h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*Makes histograms where only rejection is unset data*/
|
||||
void SFPPlotter::MakeUncutHistograms(const ProcessedEvent& ev, THashTable* table)
|
||||
{
|
||||
/*Makes histograms where only rejection is unset data*/
|
||||
void SFPPlotter::MakeUncutHistograms(const ProcessedEvent& ev, THashTable* table)
|
||||
{
|
||||
MyFill(table,"x1NoCuts_bothplanes",600,-300,300,ev.x2);
|
||||
MyFill(table,"x2NoCuts_bothplanes",600,-300,300,ev.x2);
|
||||
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);
|
||||
else if(ev.x1 == -1e6 && ev.x2 == -1e6)
|
||||
MyFill(table,"nopos_counter",2,0,1,1);
|
||||
}
|
||||
}
|
||||
|
||||
/*Makes histograms with cuts & gates implemented*/
|
||||
void SFPPlotter::MakeCutHistograms(const ProcessedEvent& ev, THashTable* table)
|
||||
{
|
||||
/*Makes histograms with cuts & gates implemented*/
|
||||
void SFPPlotter::MakeCutHistograms(const ProcessedEvent& ev, THashTable* table)
|
||||
{
|
||||
if(!cutter.IsInside(&ev))
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*Runs a list of files given from a RunCollector class*/
|
||||
void SFPPlotter::Run(const std::vector<std::string>& files, const std::string& output)
|
||||
{
|
||||
/*Runs a list of files given from a RunCollector class*/
|
||||
void SFPPlotter::Run(const std::vector<std::string>& files, const std::string& output)
|
||||
{
|
||||
TFile *outfile = TFile::Open(output.c_str(), "RECREATE");
|
||||
TChain* chain = new TChain("SPSTree");
|
||||
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;
|
||||
outfile->Close();
|
||||
delete outfile;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SFPPlotter::SetProgressBar(long total)
|
||||
{
|
||||
void SFPPlotter::SetProgressBar(long total)
|
||||
{
|
||||
m_pb->SetMax(total);
|
||||
m_pb->SetMin(0);
|
||||
m_pb->SetPosition(0);
|
||||
gSystem->ProcessEvents();
|
||||
}
|
||||
|
||||
}
|
|
@ -13,16 +13,18 @@
|
|||
#include "CutHandler.h"
|
||||
#include <TGProgressBar.h>
|
||||
|
||||
class SFPPlotter
|
||||
{
|
||||
public:
|
||||
namespace EventBuilder {
|
||||
|
||||
class SFPPlotter
|
||||
{
|
||||
public:
|
||||
SFPPlotter();
|
||||
~SFPPlotter();
|
||||
inline void AttachProgressBar(TGProgressBar* pb) { m_pb = pb; }
|
||||
inline void ApplyCutlist(const std::string& listname) { cutter.SetCuts(listname); }
|
||||
void Run(const std::vector<std::string>& files, const std::string& output);
|
||||
|
||||
private:
|
||||
private:
|
||||
void SetProgressBar(long total);
|
||||
void Chain(const std::vector<std::string>& files); //Form TChain
|
||||
void MakeUncutHistograms(const ProcessedEvent& ev, THashTable* table);
|
||||
|
@ -40,6 +42,8 @@ private:
|
|||
|
||||
TGProgressBar* m_pb; //GUI progress
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -12,27 +12,29 @@
|
|||
#include "EventBuilder.h"
|
||||
#include "ShiftMap.h"
|
||||
|
||||
ShiftMap::ShiftMap() :
|
||||
namespace EventBuilder {
|
||||
|
||||
ShiftMap::ShiftMap() :
|
||||
m_filename(""), m_validFlag(false)
|
||||
{
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
ShiftMap::ShiftMap(const std::string& filename) :
|
||||
ShiftMap::ShiftMap(const std::string& filename) :
|
||||
m_filename(filename), m_validFlag(false)
|
||||
{
|
||||
{
|
||||
ParseFile();
|
||||
}
|
||||
}
|
||||
|
||||
ShiftMap::~ShiftMap() {}
|
||||
ShiftMap::~ShiftMap() {}
|
||||
|
||||
void ShiftMap::SetFile(const std::string& filename)
|
||||
{
|
||||
void ShiftMap::SetFile(const std::string& filename)
|
||||
{
|
||||
m_filename = filename;
|
||||
ParseFile();
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t ShiftMap::GetShift(int gchan)
|
||||
{
|
||||
uint64_t ShiftMap::GetShift(int gchan)
|
||||
{
|
||||
if(!m_validFlag)
|
||||
return 0;
|
||||
|
||||
|
@ -41,10 +43,10 @@ uint64_t ShiftMap::GetShift(int gchan)
|
|||
return 0;
|
||||
else
|
||||
return iter->second;
|
||||
}
|
||||
}
|
||||
|
||||
void ShiftMap::ParseFile()
|
||||
{
|
||||
void ShiftMap::ParseFile()
|
||||
{
|
||||
m_validFlag = false;
|
||||
std::ifstream input(m_filename);
|
||||
if(!input.is_open())
|
||||
|
@ -78,4 +80,6 @@ void ShiftMap::ParseFile()
|
|||
}
|
||||
|
||||
m_validFlag = true;
|
||||
}
|
||||
|
||||
}
|
|
@ -12,9 +12,11 @@
|
|||
#ifndef SHIFTMAP_H
|
||||
#define SHIFTMAP_H
|
||||
|
||||
class ShiftMap
|
||||
{
|
||||
public:
|
||||
namespace EventBuilder {
|
||||
|
||||
class ShiftMap
|
||||
{
|
||||
public:
|
||||
ShiftMap();
|
||||
ShiftMap(const std::string& filename);
|
||||
~ShiftMap();
|
||||
|
@ -23,7 +25,7 @@ public:
|
|||
inline std::string GetFilename() { return m_filename; }
|
||||
uint64_t GetShift(int gchan);
|
||||
|
||||
private:
|
||||
private:
|
||||
void ParseFile();
|
||||
|
||||
std::string m_filename;
|
||||
|
@ -31,6 +33,8 @@ private:
|
|||
|
||||
std::unordered_map<int, uint64_t> m_map;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -10,30 +10,32 @@
|
|||
#include "EventBuilder.h"
|
||||
#include "SlowSort.h"
|
||||
|
||||
/*Sort the Sabre Data in order of descending energy*/
|
||||
bool SabreSort(const DetectorHit& i, const DetectorHit& j) {
|
||||
namespace EventBuilder {
|
||||
|
||||
/*Sort the Sabre Data in order of descending energy*/
|
||||
bool SabreSort(const DetectorHit& i, const DetectorHit& j) {
|
||||
return (i.Long>j.Long);
|
||||
}
|
||||
}
|
||||
|
||||
/*Constructor takes input of coincidence window size, and fills sabre channel map*/
|
||||
SlowSort::SlowSort() :
|
||||
/*Constructor takes input of coincidence window size, and fills sabre channel map*/
|
||||
SlowSort::SlowSort() :
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
{
|
||||
event_stats = new TH2F("coinc_event_stats","coinc_events_stats;global channel;number of coincident hits;counts",144,0,144,20,0,20);
|
||||
InitVariableMaps();
|
||||
}
|
||||
}
|
||||
|
||||
SlowSort::~SlowSort() {}
|
||||
SlowSort::~SlowSort() {}
|
||||
|
||||
/**EXPERIMENT MODS go here**/
|
||||
void SlowSort::InitVariableMaps()
|
||||
{
|
||||
/**EXPERIMENT MODS go here**/
|
||||
void SlowSort::InitVariableMaps()
|
||||
{
|
||||
|
||||
/*For SABRE: Each SABRE det has ring&wedge, so add the detID to the
|
||||
SABRERING/WEDGE attribute to differentiate*/
|
||||
|
@ -62,16 +64,16 @@ void SlowSort::InitVariableMaps()
|
|||
varMap[DetAttribute::AnodeBack] = &m_event.focalPlane.anodeB;
|
||||
varMap[DetAttribute::Monitor] = &m_event.focalPlane.monitor;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*Reset output structure to blank*/
|
||||
void SlowSort::Reset()
|
||||
{
|
||||
/*Reset output structure to blank*/
|
||||
void SlowSort::Reset()
|
||||
{
|
||||
m_event = m_blank;
|
||||
}
|
||||
}
|
||||
|
||||
bool SlowSort::AddHitToEvent(CompassHit& mhit)
|
||||
{
|
||||
bool SlowSort::AddHitToEvent(CompassHit& mhit)
|
||||
{
|
||||
DPPChannel curHit;
|
||||
curHit.Timestamp = mhit.timestamp;
|
||||
curHit.Energy = mhit.lgate;
|
||||
|
@ -99,10 +101,10 @@ bool SlowSort::AddHitToEvent(CompassHit& mhit)
|
|||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void SlowSort::FlushHitsToEvent()
|
||||
{
|
||||
void SlowSort::FlushHitsToEvent()
|
||||
{
|
||||
if(m_hitList.empty())
|
||||
{
|
||||
m_eventFlag = false;
|
||||
|
@ -112,19 +114,19 @@ void SlowSort::FlushHitsToEvent()
|
|||
ProcessEvent();
|
||||
m_hitList.clear();
|
||||
m_eventFlag = true;
|
||||
}
|
||||
}
|
||||
|
||||
const CoincEvent& SlowSort::GetEvent()
|
||||
{
|
||||
const CoincEvent& SlowSort::GetEvent()
|
||||
{
|
||||
m_eventFlag = false;
|
||||
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
|
||||
*/
|
||||
void SlowSort::ProcessEvent()
|
||||
{
|
||||
void SlowSort::ProcessEvent()
|
||||
{
|
||||
Reset();
|
||||
DetectorHit dhit;
|
||||
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].wedges.begin(), m_event.sabreArray[s].wedges.end(), SabreSort);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -16,10 +16,12 @@
|
|||
#include <TH2.h>
|
||||
#include <unordered_map>
|
||||
|
||||
class SlowSort
|
||||
{
|
||||
namespace EventBuilder {
|
||||
|
||||
public:
|
||||
class SlowSort
|
||||
{
|
||||
|
||||
public:
|
||||
SlowSort();
|
||||
SlowSort(double windowSize, const std::string& mapfile);
|
||||
~SlowSort();
|
||||
|
@ -31,7 +33,7 @@ public:
|
|||
void FlushHitsToEvent(); //For use with *last* hit list
|
||||
inline bool IsEventReady() { return m_eventFlag; }
|
||||
|
||||
private:
|
||||
private:
|
||||
void InitVariableMaps();
|
||||
void Reset();
|
||||
void ProcessEvent();
|
||||
|
@ -49,6 +51,8 @@ private:
|
|||
|
||||
ChannelMap cmap;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -8,30 +8,34 @@
|
|||
#include "EventBuilder.h"
|
||||
#include "Stopwatch.h"
|
||||
|
||||
Stopwatch::Stopwatch()
|
||||
{
|
||||
namespace EventBuilder {
|
||||
|
||||
Stopwatch::Stopwatch()
|
||||
{
|
||||
start_time = Clock::now();
|
||||
stop_time = start_time;
|
||||
}
|
||||
}
|
||||
|
||||
Stopwatch::~Stopwatch() {}
|
||||
Stopwatch::~Stopwatch() {}
|
||||
|
||||
void Stopwatch::Start()
|
||||
{
|
||||
void Stopwatch::Start()
|
||||
{
|
||||
start_time = Clock::now();
|
||||
}
|
||||
}
|
||||
|
||||
void Stopwatch::Stop()
|
||||
{
|
||||
void Stopwatch::Stop()
|
||||
{
|
||||
stop_time = Clock::now();
|
||||
}
|
||||
}
|
||||
|
||||
double Stopwatch::GetElapsedSeconds()
|
||||
{
|
||||
double Stopwatch::GetElapsedSeconds()
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
|
@ -10,9 +10,11 @@
|
|||
|
||||
#include <chrono>
|
||||
|
||||
class Stopwatch
|
||||
{
|
||||
public:
|
||||
namespace EventBuilder {
|
||||
|
||||
class Stopwatch
|
||||
{
|
||||
public:
|
||||
Stopwatch();
|
||||
~Stopwatch();
|
||||
void Start();
|
||||
|
@ -20,11 +22,13 @@ public:
|
|||
double GetElapsedSeconds();
|
||||
double GetElapsedMilliseconds();
|
||||
|
||||
private:
|
||||
private:
|
||||
using Time = std::chrono::high_resolution_clock::time_point;
|
||||
using Clock = std::chrono::high_resolution_clock;
|
||||
|
||||
Time start_time, stop_time;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,7 +1,7 @@
|
|||
#include "EventBuilder.h"
|
||||
#include "evb/EventBuilder.h"
|
||||
#include "spsdict/DataStructs.h"
|
||||
#include <TApplication.h>
|
||||
#include "EVBMainFrame.h"
|
||||
#include "guidict/EVBMainFrame.h"
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
|
|
|
@ -142,13 +142,13 @@ EVBMainFrame::EVBMainFrame(const TGWindow* p, UInt_t w, UInt_t h) :
|
|||
TGLabel *typelabel = new TGLabel(RunFrame, "Operation Type:");
|
||||
fTypeBox = new TGComboBox(RunFrame, TypeBox);
|
||||
//Needs modification for new conversion based sorting GWM -- Dec 2020
|
||||
fTypeBox->AddEntry("Convert Slow", EVBApp::Operation::ConvertSlow);
|
||||
fTypeBox->AddEntry("Convert Fast", EVBApp::Operation::ConvertFast);
|
||||
fTypeBox->AddEntry("Convert SlowA", EVBApp::Operation::ConvertSlowA);
|
||||
fTypeBox->AddEntry("Convert FastA", EVBApp::Operation::ConvertFastA);
|
||||
fTypeBox->AddEntry("Convert", EVBApp::Operation::Convert);
|
||||
fTypeBox->AddEntry("Merge ROOT", EVBApp::Operation::Merge);
|
||||
fTypeBox->AddEntry("Plot", EVBApp::Operation::Plot);
|
||||
fTypeBox->AddEntry("Convert Slow", EventBuilder::EVBApp::Operation::ConvertSlow);
|
||||
fTypeBox->AddEntry("Convert Fast", EventBuilder::EVBApp::Operation::ConvertFast);
|
||||
fTypeBox->AddEntry("Convert SlowA", EventBuilder::EVBApp::Operation::ConvertSlowA);
|
||||
fTypeBox->AddEntry("Convert FastA", EventBuilder::EVBApp::Operation::ConvertFastA);
|
||||
fTypeBox->AddEntry("Convert", EventBuilder::EVBApp::Operation::Convert);
|
||||
fTypeBox->AddEntry("Merge ROOT", EventBuilder::EVBApp::Operation::Merge);
|
||||
fTypeBox->AddEntry("Plot", EventBuilder::EVBApp::Operation::Plot);
|
||||
fTypeBox->Resize(200,20);
|
||||
fTypeBox->Connect("Selected(Int_t, Int_t)","EVBMainFrame",this,"HandleTypeSelection(Int_t,Int_t)");
|
||||
TGLabel *rminlabel = new TGLabel(RunFrame, "Min Run:");
|
||||
|
@ -256,37 +256,37 @@ void EVBMainFrame::DoRun()
|
|||
|
||||
switch(type)
|
||||
{
|
||||
case EVBApp::Operation::Plot :
|
||||
case EventBuilder::EVBApp::Operation::Plot :
|
||||
{
|
||||
RunPlot();
|
||||
break;
|
||||
}
|
||||
case EVBApp::Operation::Convert :
|
||||
case EventBuilder::EVBApp::Operation::Convert :
|
||||
{
|
||||
fBuilder.Convert2RawRoot();
|
||||
break;
|
||||
}
|
||||
case EVBApp::Operation::Merge :
|
||||
case EventBuilder::EVBApp::Operation::Merge :
|
||||
{
|
||||
fBuilder.MergeROOTFiles();
|
||||
break;
|
||||
}
|
||||
case EVBApp::Operation::ConvertSlow :
|
||||
case EventBuilder::EVBApp::Operation::ConvertSlow :
|
||||
{
|
||||
fBuilder.Convert2SortedRoot();
|
||||
break;
|
||||
}
|
||||
case EVBApp::Operation::ConvertFast :
|
||||
case EventBuilder::EVBApp::Operation::ConvertFast :
|
||||
{
|
||||
fBuilder.Convert2FastSortedRoot();
|
||||
break;
|
||||
}
|
||||
case EVBApp::Operation::ConvertSlowA :
|
||||
case EventBuilder::EVBApp::Operation::ConvertSlowA :
|
||||
{
|
||||
fBuilder.Convert2SlowAnalyzedRoot();
|
||||
break;
|
||||
}
|
||||
case EVBApp::Operation::ConvertFastA :
|
||||
case EventBuilder::EVBApp::Operation::ConvertFastA :
|
||||
{
|
||||
fBuilder.Convert2FastAnalyzedRoot();
|
||||
break;
|
||||
|
|
|
@ -94,7 +94,7 @@ private:
|
|||
|
||||
TGPopupMenu *fFileMenu;
|
||||
|
||||
EVBApp fBuilder;
|
||||
EventBuilder::EVBApp fBuilder;
|
||||
|
||||
int counter;
|
||||
UInt_t MAIN_W, MAIN_H;
|
||||
|
|
10
src/main.cpp
10
src/main.cpp
|
@ -1,7 +1,7 @@
|
|||
#include "EventBuilder.h"
|
||||
#include "evb/EventBuilder.h"
|
||||
#include "spsdict/DataStructs.h"
|
||||
#include "EVBApp.h"
|
||||
#include "Stopwatch.h"
|
||||
#include "evb/EVBApp.h"
|
||||
#include "evb/Stopwatch.h"
|
||||
|
||||
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)
|
||||
*/
|
||||
|
||||
EVBApp theBuilder;
|
||||
EventBuilder::EVBApp theBuilder;
|
||||
|
||||
theBuilder.ReadConfigFile(filename);
|
||||
|
||||
Stopwatch timer;
|
||||
EventBuilder::Stopwatch timer;
|
||||
timer.Start();
|
||||
if(operation == "Convert")
|
||||
theBuilder.Convert2RawRoot();
|
||||
|
|
Loading…
Reference in New Issue
Block a user