mirror of
https://github.com/sesps/SPS_SABRE_EventBuilder.git
synced 2024-11-25 19:28:49 -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,86 +9,89 @@
|
|||
#include "EventBuilder.h"
|
||||
#include "ChannelMap.h"
|
||||
|
||||
ChannelMap::ChannelMap() :
|
||||
m_validFlag(false)
|
||||
{
|
||||
}
|
||||
namespace EventBuilder {
|
||||
|
||||
ChannelMap::ChannelMap(const std::string& name) :
|
||||
m_validFlag(false)
|
||||
{
|
||||
FillMap(name);
|
||||
}
|
||||
|
||||
ChannelMap::~ChannelMap() {}
|
||||
|
||||
bool ChannelMap::FillMap(const std::string& name)
|
||||
{
|
||||
std::ifstream input(name);
|
||||
if(!input.is_open())
|
||||
ChannelMap::ChannelMap() :
|
||||
m_validFlag(false)
|
||||
{
|
||||
m_validFlag = false;
|
||||
}
|
||||
|
||||
ChannelMap::ChannelMap(const std::string& name) :
|
||||
m_validFlag(false)
|
||||
{
|
||||
FillMap(name);
|
||||
}
|
||||
|
||||
ChannelMap::~ChannelMap() {}
|
||||
|
||||
bool ChannelMap::FillMap(const std::string& name)
|
||||
{
|
||||
std::ifstream input(name);
|
||||
if(!input.is_open())
|
||||
{
|
||||
m_validFlag = false;
|
||||
return m_validFlag;
|
||||
}
|
||||
std::string junk, type, partname;
|
||||
int gchan, id;
|
||||
|
||||
std::getline(input, junk);
|
||||
std::getline(input, junk);
|
||||
Channel this_chan;
|
||||
while(input>>gchan)
|
||||
{
|
||||
//Set default values
|
||||
this_chan.type = DetType::NoneType;
|
||||
this_chan.local_channel = -1;
|
||||
this_chan.attribute = DetAttribute::NoneAttr;
|
||||
input>>id>>type>>partname;
|
||||
if(type == "SABRERING")
|
||||
{
|
||||
this_chan.type = DetType::Sabre;
|
||||
switch(id)
|
||||
{
|
||||
case 0: this_chan.attribute = DetAttribute::SabreRing0; break;
|
||||
case 1: this_chan.attribute = DetAttribute::SabreRing1; break;
|
||||
case 2: this_chan.attribute = DetAttribute::SabreRing2; break;
|
||||
case 3: this_chan.attribute = DetAttribute::SabreRing3; break;
|
||||
case 4: this_chan.attribute = DetAttribute::SabreRing4; break;
|
||||
}
|
||||
this_chan.local_channel = std::stoi(partname);
|
||||
}
|
||||
else if(type == "SABREWEDGE")
|
||||
{
|
||||
this_chan.type = DetType::Sabre;
|
||||
switch(id)
|
||||
{
|
||||
case 0: this_chan.attribute = DetAttribute::SabreWedge0; break;
|
||||
case 1: this_chan.attribute = DetAttribute::SabreWedge1; break;
|
||||
case 2: this_chan.attribute = DetAttribute::SabreWedge2; break;
|
||||
case 3: this_chan.attribute = DetAttribute::SabreWedge3; break;
|
||||
case 4: this_chan.attribute = DetAttribute::SabreWedge4; break;
|
||||
}
|
||||
this_chan.local_channel = std::stoi(partname);
|
||||
}
|
||||
else if (type == "FOCALPLANE")
|
||||
{
|
||||
this_chan.type = DetType::FocalPlane;
|
||||
this_chan.local_channel = id;
|
||||
if(partname == "SCINTRIGHT") this_chan.attribute = DetAttribute::ScintRight;
|
||||
else if(partname == "SCINTLEFT") this_chan.attribute = DetAttribute::ScintLeft;
|
||||
else if(partname == "DELAYFR") this_chan.attribute = DetAttribute::DelayFR;
|
||||
else if(partname == "DELAYFL") this_chan.attribute = DetAttribute::DelayFL;
|
||||
else if(partname == "DELAYBR") this_chan.attribute = DetAttribute::DelayBR;
|
||||
else if(partname == "DELAYBL") this_chan.attribute = DetAttribute::DelayBL;
|
||||
else if(partname == "CATHODE") this_chan.attribute = DetAttribute::Cathode;
|
||||
else if(partname == "ANODEFRONT") this_chan.attribute = DetAttribute::AnodeFront;
|
||||
else if(partname == "ANODEBACK") this_chan.attribute = DetAttribute::AnodeBack;
|
||||
else if(partname == "MONITOR") this_chan.attribute = DetAttribute::Monitor;
|
||||
}
|
||||
|
||||
m_cmap[gchan] = this_chan;
|
||||
}
|
||||
|
||||
input.close();
|
||||
m_validFlag = true;
|
||||
return m_validFlag;
|
||||
}
|
||||
std::string junk, type, partname;
|
||||
int gchan, id;
|
||||
|
||||
std::getline(input, junk);
|
||||
std::getline(input, junk);
|
||||
Channel this_chan;
|
||||
while(input>>gchan)
|
||||
{
|
||||
//Set default values
|
||||
this_chan.type = DetType::NoneType;
|
||||
this_chan.local_channel = -1;
|
||||
this_chan.attribute = DetAttribute::NoneAttr;
|
||||
input>>id>>type>>partname;
|
||||
if(type == "SABRERING")
|
||||
{
|
||||
this_chan.type = DetType::Sabre;
|
||||
switch(id)
|
||||
{
|
||||
case 0: this_chan.attribute = DetAttribute::SabreRing0; break;
|
||||
case 1: this_chan.attribute = DetAttribute::SabreRing1; break;
|
||||
case 2: this_chan.attribute = DetAttribute::SabreRing2; break;
|
||||
case 3: this_chan.attribute = DetAttribute::SabreRing3; break;
|
||||
case 4: this_chan.attribute = DetAttribute::SabreRing4; break;
|
||||
}
|
||||
this_chan.local_channel = std::stoi(partname);
|
||||
}
|
||||
else if(type == "SABREWEDGE")
|
||||
{
|
||||
this_chan.type = DetType::Sabre;
|
||||
switch(id)
|
||||
{
|
||||
case 0: this_chan.attribute = DetAttribute::SabreWedge0; break;
|
||||
case 1: this_chan.attribute = DetAttribute::SabreWedge1; break;
|
||||
case 2: this_chan.attribute = DetAttribute::SabreWedge2; break;
|
||||
case 3: this_chan.attribute = DetAttribute::SabreWedge3; break;
|
||||
case 4: this_chan.attribute = DetAttribute::SabreWedge4; break;
|
||||
}
|
||||
this_chan.local_channel = std::stoi(partname);
|
||||
}
|
||||
else if (type == "FOCALPLANE")
|
||||
{
|
||||
this_chan.type = DetType::FocalPlane;
|
||||
this_chan.local_channel = id;
|
||||
if(partname == "SCINTRIGHT") this_chan.attribute = DetAttribute::ScintRight;
|
||||
else if(partname == "SCINTLEFT") this_chan.attribute = DetAttribute::ScintLeft;
|
||||
else if(partname == "DELAYFR") this_chan.attribute = DetAttribute::DelayFR;
|
||||
else if(partname == "DELAYFL") this_chan.attribute = DetAttribute::DelayFL;
|
||||
else if(partname == "DELAYBR") this_chan.attribute = DetAttribute::DelayBR;
|
||||
else if(partname == "DELAYBL") this_chan.attribute = DetAttribute::DelayBL;
|
||||
else if(partname == "CATHODE") this_chan.attribute = DetAttribute::Cathode;
|
||||
else if(partname == "ANODEFRONT") this_chan.attribute = DetAttribute::AnodeFront;
|
||||
else if(partname == "ANODEBACK") this_chan.attribute = DetAttribute::AnodeBack;
|
||||
else if(partname == "MONITOR") this_chan.attribute = DetAttribute::Monitor;
|
||||
}
|
||||
|
||||
m_cmap[gchan] = this_chan;
|
||||
}
|
||||
|
||||
input.close();
|
||||
m_validFlag = true;
|
||||
return m_validFlag;
|
||||
}
|
||||
}
|
|
@ -9,66 +9,67 @@
|
|||
#ifndef CHANNELMAP_H
|
||||
#define CHANNELMAP_H
|
||||
|
||||
//Detector part/type identifiers for use in the code
|
||||
enum DetType
|
||||
{
|
||||
Sabre,
|
||||
FocalPlane,
|
||||
NoneType
|
||||
};
|
||||
|
||||
enum DetAttribute
|
||||
{
|
||||
ScintLeft,
|
||||
ScintRight,
|
||||
AnodeFront,
|
||||
AnodeBack,
|
||||
DelayFR,
|
||||
DelayFL,
|
||||
DelayBR,
|
||||
DelayBL,
|
||||
Cathode,
|
||||
Monitor,
|
||||
SabreRing0,
|
||||
SabreRing1,
|
||||
SabreRing2,
|
||||
SabreRing3,
|
||||
SabreRing4,
|
||||
SabreWedge0,
|
||||
SabreWedge1,
|
||||
SabreWedge2,
|
||||
SabreWedge3,
|
||||
SabreWedge4,
|
||||
NoneAttr
|
||||
};
|
||||
|
||||
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
|
||||
{
|
||||
namespace EventBuilder {
|
||||
//Detector part/type identifiers for use in the code
|
||||
enum DetType
|
||||
{
|
||||
Sabre,
|
||||
FocalPlane,
|
||||
NoneType
|
||||
};
|
||||
|
||||
public:
|
||||
typedef std::unordered_map<int, Channel> Containter;
|
||||
typedef std::unordered_map<int, Channel>::iterator Iterator;
|
||||
|
||||
ChannelMap();
|
||||
ChannelMap(const std::string& filename);
|
||||
~ChannelMap();
|
||||
bool FillMap(const std::string& filename);
|
||||
inline const Containter* GetCMap() { return &m_cmap; };
|
||||
inline Iterator FindChannel(int key) { return m_cmap.find(key); };
|
||||
inline Iterator End() { return m_cmap.end(); };
|
||||
inline bool IsValid() { return m_validFlag; };
|
||||
|
||||
private:
|
||||
Containter m_cmap;
|
||||
bool m_validFlag;
|
||||
};
|
||||
|
||||
enum DetAttribute
|
||||
{
|
||||
ScintLeft,
|
||||
ScintRight,
|
||||
AnodeFront,
|
||||
AnodeBack,
|
||||
DelayFR,
|
||||
DelayFL,
|
||||
DelayBR,
|
||||
DelayBL,
|
||||
Cathode,
|
||||
Monitor,
|
||||
SabreRing0,
|
||||
SabreRing1,
|
||||
SabreRing2,
|
||||
SabreRing3,
|
||||
SabreRing4,
|
||||
SabreWedge0,
|
||||
SabreWedge1,
|
||||
SabreWedge2,
|
||||
SabreWedge3,
|
||||
SabreWedge4,
|
||||
NoneAttr
|
||||
};
|
||||
|
||||
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
|
||||
{
|
||||
|
||||
public:
|
||||
typedef std::unordered_map<int, Channel> Containter;
|
||||
typedef std::unordered_map<int, Channel>::iterator Iterator;
|
||||
|
||||
ChannelMap();
|
||||
ChannelMap(const std::string& filename);
|
||||
~ChannelMap();
|
||||
bool FillMap(const std::string& filename);
|
||||
inline const Containter* GetCMap() { return &m_cmap; };
|
||||
inline Iterator FindChannel(int key) { return m_cmap.find(key); };
|
||||
inline Iterator End() { return m_cmap.end(); };
|
||||
inline bool IsValid() { return m_validFlag; };
|
||||
|
||||
private:
|
||||
Containter m_cmap;
|
||||
bool m_validFlag;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -11,157 +11,161 @@
|
|||
#include "EventBuilder.h"
|
||||
#include "CompassFile.h"
|
||||
|
||||
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);
|
||||
}
|
||||
namespace EventBuilder {
|
||||
|
||||
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) :
|
||||
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()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
void CompassFile::Open(const std::string& filename)
|
||||
{
|
||||
eofFlag = false;
|
||||
hitUsedFlag = true;
|
||||
m_filename = filename;
|
||||
m_file->open(m_filename, std::ios::binary | std::ios::in);
|
||||
|
||||
m_file->seekg(0, std::ios_base::end);
|
||||
m_size = m_file->tellg();
|
||||
m_nHits = m_size/24;
|
||||
if(m_size == 0)
|
||||
CompassFile::CompassFile() :
|
||||
m_filename(""), bufferIter(nullptr), bufferEnd(nullptr), m_smap(nullptr), hitUsedFlag(true), m_file(std::make_shared<std::ifstream>()), eofFlag(false)
|
||||
{
|
||||
eofFlag = true;
|
||||
}
|
||||
else
|
||||
m_buffersize = bufsize*hitsize;
|
||||
hitBuffer.resize(m_buffersize);
|
||||
}
|
||||
|
||||
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) :
|
||||
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()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
void CompassFile::Open(const std::string& filename)
|
||||
{
|
||||
eofFlag = false;
|
||||
hitUsedFlag = true;
|
||||
m_filename = filename;
|
||||
m_file->open(m_filename, std::ios::binary | std::ios::in);
|
||||
|
||||
m_file->seekg(0, std::ios_base::end);
|
||||
m_size = m_file->tellg();
|
||||
m_nHits = m_size/24;
|
||||
if(m_size == 0)
|
||||
{
|
||||
eofFlag = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_file->seekg(0, std::ios_base::beg);
|
||||
}
|
||||
}
|
||||
|
||||
void CompassFile::Close()
|
||||
{
|
||||
if(IsOpen())
|
||||
{
|
||||
m_file->close();
|
||||
}
|
||||
}
|
||||
|
||||
int CompassFile::GetHitSize()
|
||||
{
|
||||
if(!IsOpen())
|
||||
{
|
||||
std::cerr<<"Unable to get hit size due to file not being open!"<<std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
char* firstHit = new char[24]; //A compass hit by default has 24 bytes (at least in our setup)
|
||||
|
||||
m_file->read(firstHit, 24);
|
||||
|
||||
firstHit += 16;
|
||||
int nsamples = *((uint32_t*) firstHit);
|
||||
|
||||
m_file->seekg(0, std::ios_base::beg);
|
||||
|
||||
delete firstHit;
|
||||
|
||||
return 24 + nsamples*16;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void CompassFile::Close()
|
||||
{
|
||||
if(IsOpen())
|
||||
|
||||
/*
|
||||
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()
|
||||
{
|
||||
m_file->close();
|
||||
if(!IsOpen()) return true;
|
||||
|
||||
if((bufferIter == nullptr || bufferIter == bufferEnd) && !IsEOF())
|
||||
{
|
||||
GetNextBuffer();
|
||||
}
|
||||
|
||||
if(!IsEOF())
|
||||
{
|
||||
ParseNextHit();
|
||||
hitUsedFlag = false;
|
||||
}
|
||||
|
||||
return eofFlag;
|
||||
}
|
||||
}
|
||||
|
||||
int CompassFile::GetHitSize()
|
||||
{
|
||||
if(!IsOpen())
|
||||
|
||||
/*
|
||||
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()
|
||||
{
|
||||
std::cerr<<"Unable to get hit size due to file not being open!"<<std::endl;
|
||||
return 0;
|
||||
|
||||
if(m_file->eof())
|
||||
{
|
||||
eofFlag = true;
|
||||
return;
|
||||
}
|
||||
|
||||
m_file->read(hitBuffer.data(), hitBuffer.size());
|
||||
|
||||
bufferIter = hitBuffer.data();
|
||||
bufferEnd = bufferIter + m_file->gcount(); //one past the last datum
|
||||
|
||||
}
|
||||
|
||||
char* firstHit = new char[24]; //A compass hit by default has 24 bytes (at least in our setup)
|
||||
|
||||
m_file->read(firstHit, 24);
|
||||
|
||||
firstHit += 16;
|
||||
int nsamples = *((uint32_t*) firstHit);
|
||||
|
||||
m_file->seekg(0, std::ios_base::beg);
|
||||
|
||||
delete firstHit;
|
||||
|
||||
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()
|
||||
{
|
||||
if(!IsOpen()) return true;
|
||||
|
||||
if((bufferIter == nullptr || bufferIter == bufferEnd) && !IsEOF())
|
||||
|
||||
void CompassFile::ParseNextHit()
|
||||
{
|
||||
GetNextBuffer();
|
||||
|
||||
m_currentHit.board = *((uint16_t*)bufferIter);
|
||||
bufferIter += 2;
|
||||
m_currentHit.channel = *((uint16_t*)bufferIter);
|
||||
bufferIter += 2;
|
||||
m_currentHit.timestamp = *((uint64_t*)bufferIter);
|
||||
bufferIter += 8;
|
||||
m_currentHit.lgate = *((uint16_t*)bufferIter);
|
||||
bufferIter += 2;
|
||||
m_currentHit.sgate = *((uint16_t*)bufferIter);
|
||||
bufferIter += 2;
|
||||
m_currentHit.flags = *((uint32_t*)bufferIter);
|
||||
bufferIter += 4;
|
||||
m_currentHit.Ns = *((uint32_t*)bufferIter);
|
||||
bufferIter += 4;
|
||||
|
||||
if(m_smap != nullptr)
|
||||
{ //memory safety
|
||||
int gchan = m_currentHit.channel + m_currentHit.board*16;
|
||||
m_currentHit.timestamp += m_smap->GetShift(gchan);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(!IsEOF())
|
||||
{
|
||||
ParseNextHit();
|
||||
hitUsedFlag = false;
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
|
||||
if(m_file->eof())
|
||||
{
|
||||
eofFlag = true;
|
||||
return;
|
||||
}
|
||||
|
||||
m_file->read(hitBuffer.data(), hitBuffer.size());
|
||||
|
||||
bufferIter = hitBuffer.data();
|
||||
bufferEnd = bufferIter + m_file->gcount(); //one past the last datum
|
||||
|
||||
}
|
||||
|
||||
void CompassFile::ParseNextHit()
|
||||
{
|
||||
|
||||
m_currentHit.board = *((uint16_t*)bufferIter);
|
||||
bufferIter += 2;
|
||||
m_currentHit.channel = *((uint16_t*)bufferIter);
|
||||
bufferIter += 2;
|
||||
m_currentHit.timestamp = *((uint64_t*)bufferIter);
|
||||
bufferIter += 8;
|
||||
m_currentHit.lgate = *((uint16_t*)bufferIter);
|
||||
bufferIter += 2;
|
||||
m_currentHit.sgate = *((uint16_t*)bufferIter);
|
||||
bufferIter += 2;
|
||||
m_currentHit.flags = *((uint32_t*)bufferIter);
|
||||
bufferIter += 4;
|
||||
m_currentHit.Ns = *((uint32_t*)bufferIter);
|
||||
bufferIter += 4;
|
||||
|
||||
if(m_smap != nullptr)
|
||||
{ //memory safety
|
||||
int gchan = m_currentHit.channel + m_currentHit.board*16;
|
||||
m_currentHit.timestamp += m_smap->GetShift(gchan);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -15,57 +15,60 @@
|
|||
#include "ShiftMap.h"
|
||||
#include <memory>
|
||||
|
||||
class CompassFile
|
||||
{
|
||||
namespace EventBuilder {
|
||||
|
||||
class CompassFile
|
||||
{
|
||||
|
||||
public:
|
||||
CompassFile();
|
||||
CompassFile(const std::string& filename);
|
||||
CompassFile(const std::string& filename, int bsize);
|
||||
~CompassFile();
|
||||
void Open(const std::string& filename);
|
||||
void Close();
|
||||
bool GetNextHit();
|
||||
|
||||
public:
|
||||
CompassFile();
|
||||
CompassFile(const std::string& filename);
|
||||
CompassFile(const std::string& filename, int bsize);
|
||||
~CompassFile();
|
||||
void Open(const std::string& filename);
|
||||
void Close();
|
||||
bool GetNextHit();
|
||||
|
||||
inline bool IsOpen() const { return m_file->is_open(); };
|
||||
inline CompassHit GetCurrentHit() const { return m_currentHit; }
|
||||
inline std::string GetName() const { return m_filename; }
|
||||
inline bool CheckHitHasBeenUsed() const { return hitUsedFlag; } //query to find out if we've used the current hit
|
||||
inline void SetHitHasBeenUsed() { hitUsedFlag = true; } //flip the flag to indicate the current hit has been used
|
||||
inline bool IsEOF() const { return eofFlag; } //see if we've read all available data
|
||||
inline bool* GetUsedFlagPtr() { return &hitUsedFlag; }
|
||||
inline void AttachShiftMap(ShiftMap* map) { m_smap = map; }
|
||||
inline unsigned int GetSize() const { return m_size; }
|
||||
inline unsigned int GetNumberOfHits() const { return m_nHits; }
|
||||
|
||||
|
||||
private:
|
||||
int GetHitSize();
|
||||
void ParseNextHit();
|
||||
void GetNextBuffer();
|
||||
|
||||
using Buffer = std::vector<char>;
|
||||
|
||||
using FilePointer = std::shared_ptr<std::ifstream>; //to make this class copy/movable
|
||||
|
||||
std::string m_filename;
|
||||
Buffer hitBuffer;
|
||||
char* bufferIter;
|
||||
char* bufferEnd;
|
||||
ShiftMap* m_smap; //NOT owned by CompassFile. DO NOT delete
|
||||
|
||||
bool hitUsedFlag;
|
||||
int bufsize = 200000; //size of the buffer in hits
|
||||
int hitsize = 24; //size of a CompassHit in bytes (without alignment padding)
|
||||
int m_buffersize;
|
||||
|
||||
CompassHit m_currentHit;
|
||||
FilePointer m_file;
|
||||
bool eofFlag;
|
||||
unsigned int m_size; //size of the file in bytes
|
||||
unsigned int m_nHits; //number of hits in the file (m_size/24)
|
||||
|
||||
};
|
||||
inline bool IsOpen() const { return m_file->is_open(); };
|
||||
inline CompassHit GetCurrentHit() const { return m_currentHit; }
|
||||
inline std::string GetName() const { return m_filename; }
|
||||
inline bool CheckHitHasBeenUsed() const { return hitUsedFlag; } //query to find out if we've used the current hit
|
||||
inline void SetHitHasBeenUsed() { hitUsedFlag = true; } //flip the flag to indicate the current hit has been used
|
||||
inline bool IsEOF() const { return eofFlag; } //see if we've read all available data
|
||||
inline bool* GetUsedFlagPtr() { return &hitUsedFlag; }
|
||||
inline void AttachShiftMap(ShiftMap* map) { m_smap = map; }
|
||||
inline unsigned int GetSize() const { return m_size; }
|
||||
inline unsigned int GetNumberOfHits() const { return m_nHits; }
|
||||
|
||||
|
||||
private:
|
||||
int GetHitSize();
|
||||
void ParseNextHit();
|
||||
void GetNextBuffer();
|
||||
|
||||
using Buffer = std::vector<char>;
|
||||
|
||||
using FilePointer = std::shared_ptr<std::ifstream>; //to make this class copy/movable
|
||||
|
||||
std::string m_filename;
|
||||
Buffer hitBuffer;
|
||||
char* bufferIter;
|
||||
char* bufferEnd;
|
||||
ShiftMap* m_smap; //NOT owned by CompassFile. DO NOT delete
|
||||
|
||||
bool hitUsedFlag;
|
||||
int bufsize = 200000; //size of the buffer in hits
|
||||
int hitsize = 24; //size of a CompassHit in bytes (without alignment padding)
|
||||
int m_buffersize;
|
||||
|
||||
CompassHit m_currentHit;
|
||||
FilePointer m_file;
|
||||
bool eofFlag;
|
||||
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,15 +1,19 @@
|
|||
#ifndef COMPASS_HIT_H
|
||||
#define COMPASS_HIT_H
|
||||
|
||||
struct CompassHit
|
||||
{
|
||||
uint16_t board = 400;
|
||||
uint16_t channel = 400;
|
||||
uint64_t timestamp = 0;
|
||||
uint16_t lgate = 0;
|
||||
uint16_t sgate = 0;
|
||||
uint32_t flags = 0;
|
||||
uint32_t Ns = 0;
|
||||
};
|
||||
namespace EventBuilder {
|
||||
|
||||
struct CompassHit
|
||||
{
|
||||
uint16_t board = 400;
|
||||
uint16_t channel = 400;
|
||||
uint64_t timestamp = 0;
|
||||
uint16_t lgate = 0;
|
||||
uint16_t sgate = 0;
|
||||
uint32_t flags = 0;
|
||||
uint32_t Ns = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -18,54 +18,58 @@
|
|||
#include <TGProgressBar.h>
|
||||
#include <TSystem.h>
|
||||
|
||||
class CompassRun
|
||||
{
|
||||
namespace EventBuilder {
|
||||
|
||||
class CompassRun
|
||||
{
|
||||
|
||||
public:
|
||||
CompassRun();
|
||||
CompassRun(const std::string& dir);
|
||||
~CompassRun();
|
||||
inline void SetDirectory(const std::string& dir) { m_directory = dir; }
|
||||
inline void SetScalerInput(const std::string& filename) { m_scalerinput = filename; }
|
||||
inline void SetRunNumber(int n) { m_runNum = n; }
|
||||
inline void SetShiftMap(const std::string& filename) { m_smap.SetFile(filename); }
|
||||
void Convert2RawRoot(const std::string& name);
|
||||
void Convert2SortedRoot(const std::string& name, const std::string& mapfile, double window);
|
||||
void Convert2FastSortedRoot(const std::string& name, const std::string& mapfile, double window, double fsi_window, double fic_window);
|
||||
void 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);
|
||||
void 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);
|
||||
|
||||
inline void AttachProgressBar(TGProgressBar* pb) { m_pb = pb; }
|
||||
|
||||
private:
|
||||
bool GetBinaryFiles();
|
||||
bool GetHitsFromFiles();
|
||||
void SetScalers();
|
||||
void ReadScalerData(const std::string& filename);
|
||||
void SetProgressBar();
|
||||
|
||||
std::string m_directory, m_scalerinput;
|
||||
std::vector<CompassFile> m_datafiles;
|
||||
unsigned int startIndex; //this is the file we start looking at; increases as we finish files.
|
||||
ShiftMap m_smap;
|
||||
std::unordered_map<std::string, TParameter<Long64_t>> m_scaler_map; //maps scaler files to the TParameter to be saved
|
||||
|
||||
//Potential branch variables
|
||||
CompassHit hit;
|
||||
CoincEvent event;
|
||||
ProcessedEvent pevent;
|
||||
|
||||
//what run is this
|
||||
int m_runNum;
|
||||
unsigned int m_totalHits;
|
||||
|
||||
//Scaler switch
|
||||
bool m_scaler_flag;
|
||||
|
||||
//GUI progress bar, if attached
|
||||
TGProgressBar* m_pb;
|
||||
};
|
||||
|
||||
public:
|
||||
CompassRun();
|
||||
CompassRun(const std::string& dir);
|
||||
~CompassRun();
|
||||
inline void SetDirectory(const std::string& dir) { m_directory = dir; }
|
||||
inline void SetScalerInput(const std::string& filename) { m_scalerinput = filename; }
|
||||
inline void SetRunNumber(int n) { m_runNum = n; }
|
||||
inline void SetShiftMap(const std::string& filename) { m_smap.SetFile(filename); }
|
||||
void Convert2RawRoot(const std::string& name);
|
||||
void Convert2SortedRoot(const std::string& name, const std::string& mapfile, double window);
|
||||
void Convert2FastSortedRoot(const std::string& name, const std::string& mapfile, double window, double fsi_window, double fic_window);
|
||||
void 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);
|
||||
void 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);
|
||||
|
||||
inline void AttachProgressBar(TGProgressBar* pb) { m_pb = pb; }
|
||||
|
||||
private:
|
||||
bool GetBinaryFiles();
|
||||
bool GetHitsFromFiles();
|
||||
void SetScalers();
|
||||
void ReadScalerData(const std::string& filename);
|
||||
void SetProgressBar();
|
||||
|
||||
std::string m_directory, m_scalerinput;
|
||||
std::vector<CompassFile> m_datafiles;
|
||||
unsigned int startIndex; //this is the file we start looking at; increases as we finish files.
|
||||
ShiftMap m_smap;
|
||||
std::unordered_map<std::string, TParameter<Long64_t>> m_scaler_map; //maps scaler files to the TParameter to be saved
|
||||
|
||||
//Potential branch variables
|
||||
CompassHit hit;
|
||||
CoincEvent event;
|
||||
ProcessedEvent pevent;
|
||||
|
||||
//what run is this
|
||||
int m_runNum;
|
||||
unsigned int m_totalHits;
|
||||
|
||||
//Scaler switch
|
||||
bool m_scaler_flag;
|
||||
|
||||
//GUI progress bar, if attached
|
||||
TGProgressBar* m_pb;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,104 +1,108 @@
|
|||
#include "EventBuilder.h"
|
||||
#include "CutHandler.h"
|
||||
|
||||
CutHandler::CutHandler() :
|
||||
validFlag(false)
|
||||
{
|
||||
InitVariableMap();
|
||||
}
|
||||
|
||||
CutHandler::CutHandler(const std::string& filename) :
|
||||
validFlag(false)
|
||||
{
|
||||
SetCuts(filename);
|
||||
InitVariableMap();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
std::ifstream cutlist(filename);
|
||||
|
||||
if(!cutlist.is_open())
|
||||
namespace EventBuilder {
|
||||
|
||||
CutHandler::CutHandler() :
|
||||
validFlag(false)
|
||||
{
|
||||
InitVariableMap();
|
||||
}
|
||||
|
||||
CutHandler::CutHandler(const std::string& filename) :
|
||||
validFlag(false)
|
||||
{
|
||||
validFlag = false;
|
||||
SetCuts(filename);
|
||||
InitVariableMap();
|
||||
}
|
||||
|
||||
std::string junk, name, fname, varx, vary;
|
||||
cutlist>>junk>>junk>>junk>>junk;
|
||||
|
||||
cut_array.clear();
|
||||
file_array.clear();
|
||||
|
||||
while(cutlist>>name)
|
||||
|
||||
CutHandler::~CutHandler()
|
||||
{
|
||||
cutlist>>fname>>varx>>vary;
|
||||
TFile* file = TFile::Open(fname.c_str(), "READ");
|
||||
TCutG* cut = (TCutG*) file->Get("CUTG");
|
||||
if(cut)
|
||||
{
|
||||
cut->SetVarX(varx.c_str());
|
||||
cut->SetVarY(vary.c_str());
|
||||
cut->SetName(name.c_str());
|
||||
cut_array.push_back(cut);
|
||||
file_array.push_back(file);
|
||||
}
|
||||
else
|
||||
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)
|
||||
{
|
||||
std::ifstream cutlist(filename);
|
||||
|
||||
if(!cutlist.is_open())
|
||||
{
|
||||
validFlag = false;
|
||||
std::cerr<<"CutHandler has encountered a bad cut at file: "<<file<<"."<<std::endl;
|
||||
std::cerr<<"The file either does not exist or does not contain a TCutG named CUTG"<<std::endl;
|
||||
std::cerr<<"Cuts will not be used."<<std::endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(cut_array.size() > 0)
|
||||
validFlag = true;
|
||||
else
|
||||
validFlag = false;
|
||||
}
|
||||
|
||||
/*
|
||||
ADD MORE VARIABLES HERE!
|
||||
*/
|
||||
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)
|
||||
{
|
||||
m_event = *eaddress;
|
||||
std::string x, y;
|
||||
for(unsigned int i=0; i<cut_array.size(); i++)
|
||||
{
|
||||
TCutG* cut = cut_array[i];
|
||||
x = cut->GetVarX();
|
||||
y = cut->GetVarY();
|
||||
auto xentry = varmap.find(x);
|
||||
auto yentry = varmap.find(y);
|
||||
if(xentry == varmap.end() || yentry == varmap.end())
|
||||
|
||||
std::string junk, name, fname, varx, vary;
|
||||
cutlist>>junk>>junk>>junk>>junk;
|
||||
|
||||
cut_array.clear();
|
||||
file_array.clear();
|
||||
|
||||
while(cutlist>>name)
|
||||
{
|
||||
std::cerr<<"Unmapped variable called in CutHandler::IsInside()! Var names: "<<xentry->first<<" , "<<yentry->first<<std::endl;
|
||||
return false;
|
||||
cutlist>>fname>>varx>>vary;
|
||||
TFile* file = TFile::Open(fname.c_str(), "READ");
|
||||
TCutG* cut = (TCutG*) file->Get("CUTG");
|
||||
if(cut)
|
||||
{
|
||||
cut->SetVarX(varx.c_str());
|
||||
cut->SetVarY(vary.c_str());
|
||||
cut->SetName(name.c_str());
|
||||
cut_array.push_back(cut);
|
||||
file_array.push_back(file);
|
||||
}
|
||||
else
|
||||
{
|
||||
validFlag = false;
|
||||
std::cerr<<"CutHandler has encountered a bad cut at file: "<<file<<"."<<std::endl;
|
||||
std::cerr<<"The file either does not exist or does not contain a TCutG named CUTG"<<std::endl;
|
||||
std::cerr<<"Cuts will not be used."<<std::endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(!cut->IsInside(*(xentry->second), *(yentry->second)))
|
||||
return false;
|
||||
|
||||
|
||||
if(cut_array.size() > 0)
|
||||
validFlag = true;
|
||||
else
|
||||
validFlag = false;
|
||||
}
|
||||
|
||||
/*
|
||||
ADD MORE VARIABLES HERE!
|
||||
*/
|
||||
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)
|
||||
{
|
||||
m_event = *eaddress;
|
||||
std::string x, y;
|
||||
for(unsigned int i=0; i<cut_array.size(); i++)
|
||||
{
|
||||
TCutG* cut = cut_array[i];
|
||||
x = cut->GetVarX();
|
||||
y = cut->GetVarY();
|
||||
auto xentry = varmap.find(x);
|
||||
auto yentry = varmap.find(y);
|
||||
if(xentry == varmap.end() || yentry == varmap.end())
|
||||
{
|
||||
std::cerr<<"Unmapped variable called in CutHandler::IsInside()! Var names: "<<xentry->first<<" , "<<yentry->first<<std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!cut->IsInside(*(xentry->second), *(yentry->second)))
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,27 +1,30 @@
|
|||
#ifndef CUTHANDLER_H
|
||||
#define CUTHANDLER_H
|
||||
|
||||
#include "DataStructs.h"
|
||||
#include "../spsdict/DataStructs.h"
|
||||
|
||||
class CutHandler {
|
||||
public:
|
||||
CutHandler();
|
||||
CutHandler(const std::string& filename);
|
||||
~CutHandler();
|
||||
void SetCuts(const std::string& filename);
|
||||
bool IsValid() { return validFlag; }
|
||||
bool IsInside(const ProcessedEvent* eaddress);
|
||||
std::vector<TCutG*> GetCuts() { return cut_array; }
|
||||
namespace EventBuilder {
|
||||
|
||||
class CutHandler {
|
||||
public:
|
||||
CutHandler();
|
||||
CutHandler(const std::string& filename);
|
||||
~CutHandler();
|
||||
void SetCuts(const std::string& filename);
|
||||
bool IsValid() { return validFlag; }
|
||||
bool IsInside(const ProcessedEvent* eaddress);
|
||||
std::vector<TCutG*> GetCuts() { return cut_array; }
|
||||
|
||||
private:
|
||||
void InitVariableMap();
|
||||
|
||||
std::vector<TCutG*> cut_array;
|
||||
std::vector<TFile*> file_array;
|
||||
std::unordered_map<std::string, double*> varmap;
|
||||
bool validFlag;
|
||||
ProcessedEvent m_event;
|
||||
};
|
||||
|
||||
private:
|
||||
void InitVariableMap();
|
||||
|
||||
std::vector<TCutG*> cut_array;
|
||||
std::vector<TFile*> file_array;
|
||||
std::unordered_map<std::string, double*> varmap;
|
||||
bool validFlag;
|
||||
ProcessedEvent m_event;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
|
@ -16,421 +16,425 @@
|
|||
#include "SFPAnalyzer.h"
|
||||
#include "SFPPlotter.h"
|
||||
|
||||
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()
|
||||
{
|
||||
}
|
||||
|
||||
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())
|
||||
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)
|
||||
{
|
||||
std::cout<<"Read failed! Unable to open input file!"<<std::endl;
|
||||
return false;
|
||||
}
|
||||
std::string junk;
|
||||
|
||||
std::getline(input, junk);
|
||||
input>>junk>>m_workspace;
|
||||
input>>junk;
|
||||
std::getline(input, junk);
|
||||
std::getline(input, junk);
|
||||
input>>junk>>m_mapfile;
|
||||
input>>junk>>m_scalerfile;
|
||||
input>>junk>>m_cutList;
|
||||
input>>junk>>m_ZT>>junk>>m_AT;
|
||||
input>>junk>>m_ZP>>junk>>m_AP;
|
||||
input>>junk>>m_ZE>>junk>>m_AE;
|
||||
input>>junk>>m_B;
|
||||
input>>junk>>m_BKE;
|
||||
input>>junk>>m_Theta;
|
||||
input>>junk;
|
||||
std::getline(input, junk);
|
||||
std::getline(input, junk);
|
||||
input>>junk>>m_shiftfile;
|
||||
input>>junk>>m_SlowWindow;
|
||||
input>>junk>>m_FastWindowIonCh;
|
||||
input>>junk>>m_FastWindowSABRE;
|
||||
input>>junk;
|
||||
std::getline(input, junk);
|
||||
std::getline(input, junk);
|
||||
input>>junk>>m_rmin;
|
||||
input>>junk>>m_rmax;
|
||||
|
||||
input.close();
|
||||
|
||||
std::cout<<"Completed."<<std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void EVBApp::WriteConfigFile(const std::string& fullpath)
|
||||
{
|
||||
|
||||
std::cout<<"Writing out configuration to file: "<<fullpath<<std::endl;
|
||||
std::ofstream output(fullpath);
|
||||
if(!output.is_open())
|
||||
|
||||
EVBApp::~EVBApp()
|
||||
{
|
||||
std::cout<<"Write failed! Unable to open output file!"<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
output<<"-------Data Location----------"<<std::endl;
|
||||
output<<"WorkspaceDirectory: "<<m_workspace<<std::endl;
|
||||
output<<"-------------------------------"<<std::endl;
|
||||
output<<"------Experimental Inputs------"<<std::endl;
|
||||
output<<"ChannelMapFile: "<<m_mapfile<<std::endl;
|
||||
output<<"ScalerFile: "<<m_scalerfile<<std::endl;
|
||||
output<<"CutListFile: "<<m_cutList<<std::endl;
|
||||
output<<"ZT: "<<m_ZT<<std::endl;
|
||||
output<<"AT: "<<m_AT<<std::endl;
|
||||
output<<"ZP: "<<m_ZP<<std::endl;
|
||||
output<<"AP: "<<m_AP<<std::endl;
|
||||
output<<"ZE: "<<m_ZE<<std::endl;
|
||||
output<<"AE: "<<m_AE<<std::endl;
|
||||
output<<"BField(G): "<<m_B<<std::endl;
|
||||
output<<"BeamKE(MeV): "<<m_BKE<<std::endl;
|
||||
output<<"Theta(deg): "<<m_Theta<<std::endl;
|
||||
output<<"-------------------------------"<<std::endl;
|
||||
output<<"-------Timing Information------"<<std::endl;
|
||||
output<<"BoardOffsetFile: "<<m_shiftfile<<std::endl;
|
||||
output<<"SlowCoincidenceWindow(ps): "<<m_SlowWindow<<std::endl;
|
||||
output<<"FastCoincidenceWindow_IonCh(ps): "<<m_FastWindowIonCh<<std::endl;
|
||||
output<<"FastCoincidenceWindow_SABRE(ps): "<<m_FastWindowSABRE<<std::endl;
|
||||
output<<"-------------------------------"<<std::endl;
|
||||
output<<"--------Run Information--------"<<std::endl;
|
||||
output<<"MinRun: "<<m_rmin<<std::endl;
|
||||
output<<"MaxRun: "<<m_rmax<<std::endl;
|
||||
output<<"-------------------------------"<<std::endl;
|
||||
|
||||
output.close();
|
||||
|
||||
std::cout<<"Completed."<<std::endl;
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
grammer.ApplyCutlist(m_cutList);
|
||||
std::cout<<"-------------GWM Event Builder-------------"<<std::endl;
|
||||
std::cout<<"Generating a histogram file from analyzed files"<<std::endl;
|
||||
std::cout<<"Analyzed directory: "<<analyze_dir<<std::endl;
|
||||
std::cout<<"Min Run: "<<m_rmin<<" Max Run: "<<m_rmax<<std::endl;
|
||||
std::cout<<"Cut List File: "<<m_cutList<<std::endl;
|
||||
std::cout<<"Histogram File: "<<plot_file<<std::endl;
|
||||
|
||||
if(m_pb)
|
||||
grammer.AttachProgressBar(m_pb);
|
||||
grabber.SetSearchParams(analyze_dir, "", ".root", m_rmin, m_rmax);
|
||||
if(grabber.GrabFilesInRange())
|
||||
|
||||
bool EVBApp::ReadConfigFile(const std::string& fullpath)
|
||||
{
|
||||
std::cout<<"Working...";
|
||||
grammer.Run(grabber.GetFileList(), plot_file);
|
||||
std::cout<<"Reading in configuration from file: "<<fullpath<<std::endl;
|
||||
std::ifstream input(fullpath);
|
||||
if(!input.is_open())
|
||||
{
|
||||
std::cout<<"Read failed! Unable to open input file!"<<std::endl;
|
||||
return false;
|
||||
}
|
||||
std::string junk;
|
||||
|
||||
std::getline(input, junk);
|
||||
input>>junk>>m_workspace;
|
||||
input>>junk;
|
||||
std::getline(input, junk);
|
||||
std::getline(input, junk);
|
||||
input>>junk>>m_mapfile;
|
||||
input>>junk>>m_scalerfile;
|
||||
input>>junk>>m_cutList;
|
||||
input>>junk>>m_ZT>>junk>>m_AT;
|
||||
input>>junk>>m_ZP>>junk>>m_AP;
|
||||
input>>junk>>m_ZE>>junk>>m_AE;
|
||||
input>>junk>>m_B;
|
||||
input>>junk>>m_BKE;
|
||||
input>>junk>>m_Theta;
|
||||
input>>junk;
|
||||
std::getline(input, junk);
|
||||
std::getline(input, junk);
|
||||
input>>junk>>m_shiftfile;
|
||||
input>>junk>>m_SlowWindow;
|
||||
input>>junk>>m_FastWindowIonCh;
|
||||
input>>junk>>m_FastWindowSABRE;
|
||||
input>>junk;
|
||||
std::getline(input, junk);
|
||||
std::getline(input, junk);
|
||||
input>>junk>>m_rmin;
|
||||
input>>junk>>m_rmax;
|
||||
|
||||
input.close();
|
||||
|
||||
std::cout<<"Completed."<<std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void EVBApp::WriteConfigFile(const std::string& fullpath)
|
||||
{
|
||||
|
||||
std::cout<<"Writing out configuration to file: "<<fullpath<<std::endl;
|
||||
std::ofstream output(fullpath);
|
||||
if(!output.is_open())
|
||||
{
|
||||
std::cout<<"Write failed! Unable to open output file!"<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
output<<"-------Data Location----------"<<std::endl;
|
||||
output<<"WorkspaceDirectory: "<<m_workspace<<std::endl;
|
||||
output<<"-------------------------------"<<std::endl;
|
||||
output<<"------Experimental Inputs------"<<std::endl;
|
||||
output<<"ChannelMapFile: "<<m_mapfile<<std::endl;
|
||||
output<<"ScalerFile: "<<m_scalerfile<<std::endl;
|
||||
output<<"CutListFile: "<<m_cutList<<std::endl;
|
||||
output<<"ZT: "<<m_ZT<<std::endl;
|
||||
output<<"AT: "<<m_AT<<std::endl;
|
||||
output<<"ZP: "<<m_ZP<<std::endl;
|
||||
output<<"AP: "<<m_AP<<std::endl;
|
||||
output<<"ZE: "<<m_ZE<<std::endl;
|
||||
output<<"AE: "<<m_AE<<std::endl;
|
||||
output<<"BField(G): "<<m_B<<std::endl;
|
||||
output<<"BeamKE(MeV): "<<m_BKE<<std::endl;
|
||||
output<<"Theta(deg): "<<m_Theta<<std::endl;
|
||||
output<<"-------------------------------"<<std::endl;
|
||||
output<<"-------Timing Information------"<<std::endl;
|
||||
output<<"BoardOffsetFile: "<<m_shiftfile<<std::endl;
|
||||
output<<"SlowCoincidenceWindow(ps): "<<m_SlowWindow<<std::endl;
|
||||
output<<"FastCoincidenceWindow_IonCh(ps): "<<m_FastWindowIonCh<<std::endl;
|
||||
output<<"FastCoincidenceWindow_SABRE(ps): "<<m_FastWindowSABRE<<std::endl;
|
||||
output<<"-------------------------------"<<std::endl;
|
||||
output<<"--------Run Information--------"<<std::endl;
|
||||
output<<"MinRun: "<<m_rmin<<std::endl;
|
||||
output<<"MaxRun: "<<m_rmax<<std::endl;
|
||||
output<<"-------------------------------"<<std::endl;
|
||||
|
||||
output.close();
|
||||
|
||||
std::cout<<"Completed."<<std::endl;
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
grammer.ApplyCutlist(m_cutList);
|
||||
std::cout<<"-------------GWM Event Builder-------------"<<std::endl;
|
||||
std::cout<<"Generating a histogram file from analyzed files"<<std::endl;
|
||||
std::cout<<"Analyzed directory: "<<analyze_dir<<std::endl;
|
||||
std::cout<<"Min Run: "<<m_rmin<<" Max Run: "<<m_rmax<<std::endl;
|
||||
std::cout<<"Cut List File: "<<m_cutList<<std::endl;
|
||||
std::cout<<"Histogram File: "<<plot_file<<std::endl;
|
||||
|
||||
if(m_pb)
|
||||
grammer.AttachProgressBar(m_pb);
|
||||
grabber.SetSearchParams(analyze_dir, "", ".root", m_rmin, m_rmax);
|
||||
if(grabber.GrabFilesInRange())
|
||||
{
|
||||
std::cout<<"Working...";
|
||||
grammer.Run(grabber.GetFileList(), plot_file);
|
||||
std::cout<<" Complete."<<std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout<<"Unable to find files at PlotHistograms"<<std::endl;
|
||||
}
|
||||
std::cout<<"-------------------------------------------"<<std::endl;
|
||||
|
||||
}
|
||||
|
||||
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/";
|
||||
std::cout<<"-------------GWM Event Builder-------------"<<std::endl;
|
||||
std::cout<<"Converting Binary file Archive to ROOT file"<<std::endl;
|
||||
std::cout<<"Binary Archive Directory: "<<binary_dir<<std::endl;
|
||||
std::cout<<"Temporary Unpack Directory: "<<unpack_dir<<std::endl;
|
||||
std::cout<<"Timestamp Shift File: "<<m_shiftfile<<std::endl;
|
||||
std::cout<<"Min Run: "<<m_rmin<<" Max Run: "<<m_rmax<<std::endl;
|
||||
|
||||
|
||||
grabber.SetSearchParams(binary_dir, "", ".tar.gz",0,1000);
|
||||
|
||||
std::cout<<"Workspace Directory: "<<m_workspace<<std::endl;
|
||||
|
||||
std::string rawfile, binfile;
|
||||
std::string unpack_command, wipe_command;
|
||||
|
||||
CompassRun converter(unpack_dir);
|
||||
converter.SetShiftMap(m_shiftfile);
|
||||
converter.SetScalerInput(m_scalerfile);
|
||||
if(m_pb)
|
||||
converter.AttachProgressBar(m_pb);
|
||||
|
||||
std::cout<<"Beginning conversion..."<<std::endl;
|
||||
|
||||
for(int i=m_rmin; i<=m_rmax; i++)
|
||||
{
|
||||
binfile = grabber.GrabFile(i);
|
||||
if(binfile == "")
|
||||
continue;
|
||||
converter.SetRunNumber(i);
|
||||
std::cout<<"Converting file: "<<binfile<<std::endl;
|
||||
|
||||
rawfile = rawroot_dir + "compass_run_"+ std::to_string(i) + ".root";
|
||||
unpack_command = "tar -xzf "+binfile+" --directory "+unpack_dir;
|
||||
wipe_command = "rm -r "+unpack_dir+"*.bin";
|
||||
|
||||
system(unpack_command.c_str());
|
||||
converter.Convert2RawRoot(rawfile);
|
||||
system(wipe_command.c_str());
|
||||
|
||||
}
|
||||
std::cout<<std::endl<<"Conversion complete."<<std::endl;
|
||||
std::cout<<"-------------------------------------------"<<std::endl;
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
std::cout<<"Merging ROOT files into single ROOT file"<<std::endl;
|
||||
std::cout<<"Workspace directory: "<<m_workspace<<std::endl;
|
||||
std::cout<<"Min Run: "<<m_rmin<<" Max Run: "<<m_rmax<<std::endl;
|
||||
std::cout<<"Output file: "<<merge_file<<std::endl;
|
||||
std::string prefix = "";
|
||||
std::string suffix = ".root";
|
||||
grabber.SetSearchParams(file_dir, prefix, suffix,m_rmin,m_rmax);
|
||||
std::cout<<"Beginning the merge...";
|
||||
if(!grabber.Merge_TChain(merge_file))
|
||||
{
|
||||
std::cout<<"Unable to find files at MergeROOTFiles"<<std::endl;
|
||||
return;
|
||||
}
|
||||
std::cout<<" Complete."<<std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout<<"Unable to find files at PlotHistograms"<<std::endl;
|
||||
std::cout<<"-------------------------------------------"<<std::endl;
|
||||
}
|
||||
std::cout<<"-------------------------------------------"<<std::endl;
|
||||
|
||||
}
|
||||
|
||||
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/";
|
||||
std::cout<<"-------------GWM Event Builder-------------"<<std::endl;
|
||||
std::cout<<"Converting Binary file Archive to ROOT file"<<std::endl;
|
||||
std::cout<<"Binary Archive Directory: "<<binary_dir<<std::endl;
|
||||
std::cout<<"Temporary Unpack Directory: "<<unpack_dir<<std::endl;
|
||||
std::cout<<"Timestamp Shift File: "<<m_shiftfile<<std::endl;
|
||||
std::cout<<"Min Run: "<<m_rmin<<" Max Run: "<<m_rmax<<std::endl;
|
||||
|
||||
|
||||
grabber.SetSearchParams(binary_dir, "", ".tar.gz",0,1000);
|
||||
|
||||
std::cout<<"Workspace Directory: "<<m_workspace<<std::endl;
|
||||
|
||||
std::string rawfile, binfile;
|
||||
std::string unpack_command, wipe_command;
|
||||
|
||||
CompassRun converter(unpack_dir);
|
||||
converter.SetShiftMap(m_shiftfile);
|
||||
converter.SetScalerInput(m_scalerfile);
|
||||
if(m_pb)
|
||||
converter.AttachProgressBar(m_pb);
|
||||
|
||||
std::cout<<"Beginning conversion..."<<std::endl;
|
||||
|
||||
for(int i=m_rmin; i<=m_rmax; i++)
|
||||
void EVBApp::Convert2SortedRoot()
|
||||
{
|
||||
binfile = grabber.GrabFile(i);
|
||||
if(binfile == "")
|
||||
continue;
|
||||
converter.SetRunNumber(i);
|
||||
std::cout<<"Converting file: "<<binfile<<std::endl;
|
||||
|
||||
rawfile = rawroot_dir + "compass_run_"+ std::to_string(i) + ".root";
|
||||
unpack_command = "tar -xzf "+binfile+" --directory "+unpack_dir;
|
||||
wipe_command = "rm -r "+unpack_dir+"*.bin";
|
||||
|
||||
system(unpack_command.c_str());
|
||||
converter.Convert2RawRoot(rawfile);
|
||||
system(wipe_command.c_str());
|
||||
|
||||
}
|
||||
std::cout<<std::endl<<"Conversion complete."<<std::endl;
|
||||
std::cout<<"-------------------------------------------"<<std::endl;
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
std::cout<<"Merging ROOT files into single ROOT file"<<std::endl;
|
||||
std::cout<<"Workspace directory: "<<m_workspace<<std::endl;
|
||||
std::cout<<"Min Run: "<<m_rmin<<" Max Run: "<<m_rmax<<std::endl;
|
||||
std::cout<<"Output file: "<<merge_file<<std::endl;
|
||||
std::string prefix = "";
|
||||
std::string suffix = ".root";
|
||||
grabber.SetSearchParams(file_dir, prefix, suffix,m_rmin,m_rmax);
|
||||
std::cout<<"Beginning the merge...";
|
||||
if(!grabber.Merge_TChain(merge_file))
|
||||
{
|
||||
std::cout<<"Unable to find files at MergeROOTFiles"<<std::endl;
|
||||
return;
|
||||
}
|
||||
std::cout<<" Complete."<<std::endl;
|
||||
std::cout<<"-------------------------------------------"<<std::endl;
|
||||
}
|
||||
|
||||
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/";
|
||||
std::cout<<"-------------GWM Event Builder-------------"<<std::endl;
|
||||
std::cout<<"Converting Binary file Archive to ROOT file"<<std::endl;
|
||||
std::cout<<"Binary Archive Directory: "<<binary_dir<<std::endl;
|
||||
std::cout<<"Temporary Unpack Directory: "<<unpack_dir<<std::endl;
|
||||
std::cout<<"Timestamp Shift File: "<<m_shiftfile<<std::endl;
|
||||
std::cout<<"Channel Map File: "<<m_mapfile<<std::endl;
|
||||
std::cout<<"Slow Coincidence Window(ps): "<<m_SlowWindow<<std::endl;
|
||||
std::cout<<"Min Run: "<<m_rmin<<" Max Run: "<<m_rmax<<std::endl;
|
||||
|
||||
grabber.SetSearchParams(binary_dir,"",".tar.gz",m_rmin,m_rmax);
|
||||
|
||||
std::cout<<"Workspace Directory: "<<m_workspace<<std::endl;
|
||||
|
||||
std::string sortfile, binfile;
|
||||
std::string unpack_command, wipe_command;
|
||||
|
||||
CompassRun converter(unpack_dir);
|
||||
converter.SetShiftMap(m_shiftfile);
|
||||
converter.SetScalerInput(m_scalerfile);
|
||||
if(m_pb)
|
||||
converter.AttachProgressBar(m_pb);
|
||||
|
||||
std::cout<<"Beginning conversion..."<<std::endl;
|
||||
|
||||
for(int i=m_rmin; i<= m_rmax; i++)
|
||||
{
|
||||
binfile = grabber.GrabFile(i);
|
||||
if(binfile == "")
|
||||
continue;
|
||||
converter.SetRunNumber(i);
|
||||
std::cout<<"Converting file: "<<binfile<<std::endl;
|
||||
|
||||
sortfile = sortroot_dir +"run_"+std::to_string(i)+ ".root";
|
||||
unpack_command = "tar -xzf "+binfile+" --directory "+unpack_dir;
|
||||
wipe_command = "rm -r "+unpack_dir+"*.bin";
|
||||
|
||||
system(unpack_command.c_str());
|
||||
converter.Convert2SortedRoot(sortfile, m_mapfile, m_SlowWindow);
|
||||
system(wipe_command.c_str());
|
||||
|
||||
}
|
||||
std::cout<<std::endl<<"Conversion complete."<<std::endl;
|
||||
std::cout<<"-------------------------------------------"<<std::endl;
|
||||
}
|
||||
|
||||
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/";
|
||||
std::cout<<"-------------GWM Event Builder-------------"<<std::endl;
|
||||
std::cout<<"Converting Binary file Archive to ROOT file"<<std::endl;
|
||||
std::cout<<"Binary Archive Directory: "<<binary_dir<<std::endl;
|
||||
std::cout<<"Temporary Unpack Directory: "<<unpack_dir<<std::endl;
|
||||
std::cout<<"Timestamp Shift File: "<<m_shiftfile<<std::endl;
|
||||
std::cout<<"Channel Map File: "<<m_mapfile<<std::endl;
|
||||
std::cout<<"Slow Coincidence Window(ps): "<<m_SlowWindow<<std::endl;
|
||||
std::cout<<"Min Run: "<<m_rmin<<" Max Run: "<<m_rmax<<std::endl;
|
||||
|
||||
grabber.SetSearchParams(binary_dir,"",".tar.gz",m_rmin,m_rmax);
|
||||
|
||||
std::cout<<"Workspace Directory: "<<m_workspace<<std::endl;
|
||||
|
||||
std::string sortfile, binfile;
|
||||
std::string unpack_command, wipe_command;
|
||||
|
||||
CompassRun converter(unpack_dir);
|
||||
converter.SetShiftMap(m_shiftfile);
|
||||
converter.SetScalerInput(m_scalerfile);
|
||||
if(m_pb)
|
||||
converter.AttachProgressBar(m_pb);
|
||||
|
||||
std::cout<<"Beginning conversion..."<<std::endl;
|
||||
|
||||
for(int i=m_rmin; i<=m_rmax; i++)
|
||||
{
|
||||
binfile = grabber.GrabFile(i);
|
||||
if(binfile == "")
|
||||
continue;
|
||||
converter.SetRunNumber(i);
|
||||
std::cout<<"Converting file: "<<binfile<<std::endl;
|
||||
|
||||
sortfile = sortroot_dir + "run_" + std::to_string(i) + ".root";
|
||||
unpack_command = "tar -xzf "+binfile+" --directory "+unpack_dir;
|
||||
wipe_command = "rm -r "+unpack_dir+"*.bin";
|
||||
|
||||
system(unpack_command.c_str());
|
||||
converter.Convert2FastSortedRoot(sortfile, m_mapfile, m_SlowWindow, m_FastWindowSABRE, m_FastWindowIonCh);
|
||||
system(wipe_command.c_str());
|
||||
|
||||
}
|
||||
std::cout<<std::endl<<"Conversion complete."<<std::endl;
|
||||
std::cout<<"-------------------------------------------"<<std::endl;
|
||||
}
|
||||
|
||||
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/";
|
||||
std::cout<<"-------------GWM Event Builder-------------"<<std::endl;
|
||||
std::cout<<"Converting Binary file Archive to ROOT file"<<std::endl;
|
||||
std::cout<<"Binary Archive Directory: "<<binary_dir<<std::endl;
|
||||
std::cout<<"Temporary Unpack Directory: "<<unpack_dir<<std::endl;
|
||||
std::cout<<"Timestamp Shift File: "<<m_shiftfile<<std::endl;
|
||||
std::cout<<"Channel Map File: "<<m_mapfile<<std::endl;
|
||||
std::cout<<"Slow Coincidence Window(ps): "<<m_SlowWindow<<std::endl;
|
||||
std::cout<<"Min Run: "<<m_rmin<<" Max Run: "<<m_rmax<<std::endl;
|
||||
std::string sortroot_dir = m_workspace+"/sorted/";
|
||||
std::string unpack_dir = m_workspace+"/temp_binary/";
|
||||
std::string binary_dir = m_workspace+"/raw_binary/";
|
||||
std::cout<<"-------------GWM Event Builder-------------"<<std::endl;
|
||||
std::cout<<"Converting Binary file Archive to ROOT file"<<std::endl;
|
||||
std::cout<<"Binary Archive Directory: "<<binary_dir<<std::endl;
|
||||
std::cout<<"Temporary Unpack Directory: "<<unpack_dir<<std::endl;
|
||||
std::cout<<"Timestamp Shift File: "<<m_shiftfile<<std::endl;
|
||||
std::cout<<"Channel Map File: "<<m_mapfile<<std::endl;
|
||||
std::cout<<"Slow Coincidence Window(ps): "<<m_SlowWindow<<std::endl;
|
||||
std::cout<<"Min Run: "<<m_rmin<<" Max Run: "<<m_rmax<<std::endl;
|
||||
|
||||
grabber.SetSearchParams(binary_dir,"",".tar.gz",m_rmin, m_rmax);
|
||||
std::cout<<"Workspace Directory: "<<m_workspace<<std::endl;
|
||||
|
||||
std::string sortfile, binfile;
|
||||
std::string unpack_command, wipe_command;
|
||||
|
||||
CompassRun converter(unpack_dir);
|
||||
converter.SetShiftMap(m_shiftfile);
|
||||
converter.SetScalerInput(m_scalerfile);
|
||||
if(m_pb)
|
||||
converter.AttachProgressBar(m_pb);
|
||||
|
||||
std::cout<<"Beginning conversion..."<<std::endl;
|
||||
|
||||
for(int i=m_rmin; i<=m_rmax; i++)
|
||||
{
|
||||
binfile = grabber.GrabFile(i);
|
||||
if(binfile == "")
|
||||
continue;
|
||||
converter.SetRunNumber(i);
|
||||
std::cout<<"Converting file: "<<binfile<<std::endl;
|
||||
|
||||
sortfile = sortroot_dir + "run_" + std::to_string(i) + ".root";
|
||||
unpack_command = "tar -xzf "+binfile+" --directory "+unpack_dir;
|
||||
wipe_command = "rm -r "+unpack_dir+"*.bin";
|
||||
|
||||
system(unpack_command.c_str());
|
||||
converter.Convert2SlowAnalyzedRoot(sortfile, m_mapfile, m_SlowWindow, m_ZT, m_AT, m_ZP, m_AP, m_ZE, m_AE, m_BKE, m_B, m_Theta);
|
||||
system(wipe_command.c_str());
|
||||
|
||||
}
|
||||
std::cout<<std::endl<<"Conversion complete."<<std::endl;
|
||||
std::cout<<"-------------------------------------------"<<std::endl;
|
||||
}
|
||||
|
||||
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/";
|
||||
std::cout<<"-------------GWM Event Builder-------------"<<std::endl;
|
||||
std::cout<<"Converting Binary file Archive to ROOT file"<<std::endl;
|
||||
std::cout<<"Binary Archive Directory: "<<binary_dir<<std::endl;
|
||||
std::cout<<"Temporary Unpack Directory: "<<unpack_dir<<std::endl;
|
||||
std::cout<<"Timestamp Shift File: "<<m_shiftfile<<std::endl;
|
||||
std::cout<<"Channel Map File: "<<m_mapfile<<std::endl;
|
||||
std::cout<<"Slow Coincidence Window(ps): "<<m_SlowWindow<<std::endl;
|
||||
std::cout<<"Fast Ion Chamber Coincidence Window(ps): "<<m_FastWindowIonCh<<std::endl;
|
||||
std::cout<<"Fast SABRE Coincidence Window(ps): "<<m_FastWindowSABRE<<std::endl;
|
||||
std::cout<<"Min Run: "<<m_rmin<<" Max Run: "<<m_rmax<<std::endl;
|
||||
grabber.SetSearchParams(binary_dir,"",".tar.gz",m_rmin,m_rmax);
|
||||
|
||||
grabber.SetSearchParams(binary_dir,"",".tar.gz",m_rmin,m_rmax);
|
||||
|
||||
std::cout<<"Workspace Directory: "<<m_workspace<<std::endl;
|
||||
|
||||
std::string sortfile, binfile;
|
||||
std::string unpack_command, wipe_command;
|
||||
|
||||
CompassRun converter(unpack_dir);
|
||||
converter.SetShiftMap(m_shiftfile);
|
||||
converter.SetScalerInput(m_scalerfile);
|
||||
if(m_pb)
|
||||
converter.AttachProgressBar(m_pb);
|
||||
|
||||
std::cout<<"Beginning conversion..."<<std::endl;
|
||||
|
||||
for(int i=m_rmin; i<=m_rmax; i++)
|
||||
{
|
||||
binfile = grabber.GrabFile(i);
|
||||
if(binfile == "")
|
||||
continue;
|
||||
converter.SetRunNumber(i);
|
||||
std::cout<<"Converting file: "<<binfile<<std::endl;
|
||||
|
||||
sortfile = sortroot_dir + "run_" + std::to_string(i) + ".root";
|
||||
unpack_command = "tar -xzf "+binfile+" --directory "+unpack_dir;
|
||||
wipe_command = "rm -r "+unpack_dir+"*.bin";
|
||||
|
||||
system(unpack_command.c_str());
|
||||
converter.Convert2FastAnalyzedRoot(sortfile, m_mapfile, m_SlowWindow, m_FastWindowSABRE, m_FastWindowIonCh, m_ZT, m_AT, m_ZP, m_AP, m_ZE, m_AE, m_BKE, m_B, m_Theta);
|
||||
system(wipe_command.c_str());
|
||||
|
||||
std::cout<<"Workspace Directory: "<<m_workspace<<std::endl;
|
||||
|
||||
std::string sortfile, binfile;
|
||||
std::string unpack_command, wipe_command;
|
||||
|
||||
CompassRun converter(unpack_dir);
|
||||
converter.SetShiftMap(m_shiftfile);
|
||||
converter.SetScalerInput(m_scalerfile);
|
||||
if(m_pb)
|
||||
converter.AttachProgressBar(m_pb);
|
||||
|
||||
std::cout<<"Beginning conversion..."<<std::endl;
|
||||
|
||||
for(int i=m_rmin; i<= m_rmax; i++)
|
||||
{
|
||||
binfile = grabber.GrabFile(i);
|
||||
if(binfile == "")
|
||||
continue;
|
||||
converter.SetRunNumber(i);
|
||||
std::cout<<"Converting file: "<<binfile<<std::endl;
|
||||
|
||||
sortfile = sortroot_dir +"run_"+std::to_string(i)+ ".root";
|
||||
unpack_command = "tar -xzf "+binfile+" --directory "+unpack_dir;
|
||||
wipe_command = "rm -r "+unpack_dir+"*.bin";
|
||||
|
||||
system(unpack_command.c_str());
|
||||
converter.Convert2SortedRoot(sortfile, m_mapfile, m_SlowWindow);
|
||||
system(wipe_command.c_str());
|
||||
|
||||
}
|
||||
std::cout<<std::endl<<"Conversion complete."<<std::endl;
|
||||
std::cout<<"-------------------------------------------"<<std::endl;
|
||||
}
|
||||
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)
|
||||
{
|
||||
|
||||
if((at + ap - ae) < 0 || (zt + zp - ze) < 0)
|
||||
{
|
||||
std::cout<<"Invalid Parameters at SetKinematicParameters"<<std::endl;
|
||||
return false;
|
||||
|
||||
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/";
|
||||
std::cout<<"-------------GWM Event Builder-------------"<<std::endl;
|
||||
std::cout<<"Converting Binary file Archive to ROOT file"<<std::endl;
|
||||
std::cout<<"Binary Archive Directory: "<<binary_dir<<std::endl;
|
||||
std::cout<<"Temporary Unpack Directory: "<<unpack_dir<<std::endl;
|
||||
std::cout<<"Timestamp Shift File: "<<m_shiftfile<<std::endl;
|
||||
std::cout<<"Channel Map File: "<<m_mapfile<<std::endl;
|
||||
std::cout<<"Slow Coincidence Window(ps): "<<m_SlowWindow<<std::endl;
|
||||
std::cout<<"Min Run: "<<m_rmin<<" Max Run: "<<m_rmax<<std::endl;
|
||||
|
||||
grabber.SetSearchParams(binary_dir,"",".tar.gz",m_rmin,m_rmax);
|
||||
|
||||
std::cout<<"Workspace Directory: "<<m_workspace<<std::endl;
|
||||
|
||||
std::string sortfile, binfile;
|
||||
std::string unpack_command, wipe_command;
|
||||
|
||||
CompassRun converter(unpack_dir);
|
||||
converter.SetShiftMap(m_shiftfile);
|
||||
converter.SetScalerInput(m_scalerfile);
|
||||
if(m_pb)
|
||||
converter.AttachProgressBar(m_pb);
|
||||
|
||||
std::cout<<"Beginning conversion..."<<std::endl;
|
||||
|
||||
for(int i=m_rmin; i<=m_rmax; i++)
|
||||
{
|
||||
binfile = grabber.GrabFile(i);
|
||||
if(binfile == "")
|
||||
continue;
|
||||
converter.SetRunNumber(i);
|
||||
std::cout<<"Converting file: "<<binfile<<std::endl;
|
||||
|
||||
sortfile = sortroot_dir + "run_" + std::to_string(i) + ".root";
|
||||
unpack_command = "tar -xzf "+binfile+" --directory "+unpack_dir;
|
||||
wipe_command = "rm -r "+unpack_dir+"*.bin";
|
||||
|
||||
system(unpack_command.c_str());
|
||||
converter.Convert2FastSortedRoot(sortfile, m_mapfile, m_SlowWindow, m_FastWindowSABRE, m_FastWindowIonCh);
|
||||
system(wipe_command.c_str());
|
||||
|
||||
}
|
||||
std::cout<<std::endl<<"Conversion complete."<<std::endl;
|
||||
std::cout<<"-------------------------------------------"<<std::endl;
|
||||
}
|
||||
|
||||
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/";
|
||||
std::cout<<"-------------GWM Event Builder-------------"<<std::endl;
|
||||
std::cout<<"Converting Binary file Archive to ROOT file"<<std::endl;
|
||||
std::cout<<"Binary Archive Directory: "<<binary_dir<<std::endl;
|
||||
std::cout<<"Temporary Unpack Directory: "<<unpack_dir<<std::endl;
|
||||
std::cout<<"Timestamp Shift File: "<<m_shiftfile<<std::endl;
|
||||
std::cout<<"Channel Map File: "<<m_mapfile<<std::endl;
|
||||
std::cout<<"Slow Coincidence Window(ps): "<<m_SlowWindow<<std::endl;
|
||||
std::cout<<"Min Run: "<<m_rmin<<" Max Run: "<<m_rmax<<std::endl;
|
||||
|
||||
grabber.SetSearchParams(binary_dir,"",".tar.gz",m_rmin, m_rmax);
|
||||
std::cout<<"Workspace Directory: "<<m_workspace<<std::endl;
|
||||
|
||||
std::string sortfile, binfile;
|
||||
std::string unpack_command, wipe_command;
|
||||
|
||||
CompassRun converter(unpack_dir);
|
||||
converter.SetShiftMap(m_shiftfile);
|
||||
converter.SetScalerInput(m_scalerfile);
|
||||
if(m_pb)
|
||||
converter.AttachProgressBar(m_pb);
|
||||
|
||||
std::cout<<"Beginning conversion..."<<std::endl;
|
||||
|
||||
for(int i=m_rmin; i<=m_rmax; i++)
|
||||
{
|
||||
binfile = grabber.GrabFile(i);
|
||||
if(binfile == "")
|
||||
continue;
|
||||
converter.SetRunNumber(i);
|
||||
std::cout<<"Converting file: "<<binfile<<std::endl;
|
||||
|
||||
sortfile = sortroot_dir + "run_" + std::to_string(i) + ".root";
|
||||
unpack_command = "tar -xzf "+binfile+" --directory "+unpack_dir;
|
||||
wipe_command = "rm -r "+unpack_dir+"*.bin";
|
||||
|
||||
system(unpack_command.c_str());
|
||||
converter.Convert2SlowAnalyzedRoot(sortfile, m_mapfile, m_SlowWindow, m_ZT, m_AT, m_ZP, m_AP, m_ZE, m_AE, m_BKE, m_B, m_Theta);
|
||||
system(wipe_command.c_str());
|
||||
|
||||
}
|
||||
std::cout<<std::endl<<"Conversion complete."<<std::endl;
|
||||
std::cout<<"-------------------------------------------"<<std::endl;
|
||||
}
|
||||
|
||||
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/";
|
||||
std::cout<<"-------------GWM Event Builder-------------"<<std::endl;
|
||||
std::cout<<"Converting Binary file Archive to ROOT file"<<std::endl;
|
||||
std::cout<<"Binary Archive Directory: "<<binary_dir<<std::endl;
|
||||
std::cout<<"Temporary Unpack Directory: "<<unpack_dir<<std::endl;
|
||||
std::cout<<"Timestamp Shift File: "<<m_shiftfile<<std::endl;
|
||||
std::cout<<"Channel Map File: "<<m_mapfile<<std::endl;
|
||||
std::cout<<"Slow Coincidence Window(ps): "<<m_SlowWindow<<std::endl;
|
||||
std::cout<<"Fast Ion Chamber Coincidence Window(ps): "<<m_FastWindowIonCh<<std::endl;
|
||||
std::cout<<"Fast SABRE Coincidence Window(ps): "<<m_FastWindowSABRE<<std::endl;
|
||||
std::cout<<"Min Run: "<<m_rmin<<" Max Run: "<<m_rmax<<std::endl;
|
||||
|
||||
grabber.SetSearchParams(binary_dir,"",".tar.gz",m_rmin,m_rmax);
|
||||
|
||||
std::cout<<"Workspace Directory: "<<m_workspace<<std::endl;
|
||||
|
||||
std::string sortfile, binfile;
|
||||
std::string unpack_command, wipe_command;
|
||||
|
||||
CompassRun converter(unpack_dir);
|
||||
converter.SetShiftMap(m_shiftfile);
|
||||
converter.SetScalerInput(m_scalerfile);
|
||||
if(m_pb)
|
||||
converter.AttachProgressBar(m_pb);
|
||||
|
||||
std::cout<<"Beginning conversion..."<<std::endl;
|
||||
|
||||
for(int i=m_rmin; i<=m_rmax; i++)
|
||||
{
|
||||
binfile = grabber.GrabFile(i);
|
||||
if(binfile == "")
|
||||
continue;
|
||||
converter.SetRunNumber(i);
|
||||
std::cout<<"Converting file: "<<binfile<<std::endl;
|
||||
|
||||
sortfile = sortroot_dir + "run_" + std::to_string(i) + ".root";
|
||||
unpack_command = "tar -xzf "+binfile+" --directory "+unpack_dir;
|
||||
wipe_command = "rm -r "+unpack_dir+"*.bin";
|
||||
|
||||
system(unpack_command.c_str());
|
||||
converter.Convert2FastAnalyzedRoot(sortfile, m_mapfile, m_SlowWindow, m_FastWindowSABRE, m_FastWindowIonCh, m_ZT, m_AT, m_ZP, m_AP, m_ZE, m_AE, m_BKE, m_B, m_Theta);
|
||||
system(wipe_command.c_str());
|
||||
|
||||
}
|
||||
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)
|
||||
{
|
||||
|
||||
if((at + ap - ae) < 0 || (zt + zp - ze) < 0)
|
||||
{
|
||||
std::cout<<"Invalid Parameters at SetKinematicParameters"<<std::endl;
|
||||
return false;
|
||||
}
|
||||
m_ZT = zt; m_AT = at; m_ZP = zp; m_AP = ap; m_ZE = ze; m_AE = ae;
|
||||
m_B = b; m_Theta = theta; m_BKE = bke;
|
||||
|
||||
m_ZR = (zt + zp - ze);
|
||||
m_AR = (at + ap - ae);
|
||||
|
||||
return true;
|
||||
}
|
||||
m_ZT = zt; m_AT = at; m_ZP = zp; m_AP = ap; m_ZE = ze; m_AE = ae;
|
||||
m_B = b; m_Theta = theta; m_BKE = bke;
|
||||
|
||||
m_ZR = (zt + zp - ze);
|
||||
m_AR = (at + ap - ae);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
165
src/evb/EVBApp.h
165
src/evb/EVBApp.h
|
@ -12,87 +12,90 @@
|
|||
#include "RunCollector.h"
|
||||
#include <TGProgressBar.h>
|
||||
|
||||
class EVBApp {
|
||||
public:
|
||||
EVBApp();
|
||||
~EVBApp();
|
||||
|
||||
bool ReadConfigFile(const std::string& filename);
|
||||
void WriteConfigFile(const std::string& filename);
|
||||
|
||||
void PlotHistograms();
|
||||
void MergeROOTFiles();
|
||||
void Convert2SortedRoot();
|
||||
void Convert2FastSortedRoot();
|
||||
void Convert2RawRoot();
|
||||
void Convert2SlowAnalyzedRoot();
|
||||
void Convert2FastAnalyzedRoot();
|
||||
|
||||
inline void SetRunRange(int rmin, int rmax) { m_rmin = rmin; m_rmax = rmax; };
|
||||
inline void SetWorkDirectory(const std::string& fullpath) { m_workspace = fullpath; };
|
||||
inline void SetChannelMap(const std::string& name) { m_mapfile = name; };
|
||||
inline void SetBoardShiftFile(const std::string& name) { m_shiftfile = name; };
|
||||
inline void SetSlowCoincidenceWindow(double window) { m_SlowWindow = window; };
|
||||
inline void SetFastWindowIonChamber(double window) { m_FastWindowIonCh = window; };
|
||||
inline void SetFastWindowSABRE(double window) { m_FastWindowSABRE = window; };
|
||||
inline void SetCutList(const std::string& name) { m_cutList = name; };
|
||||
inline void SetScalerFile(const std::string& fullpath) { m_scalerfile = fullpath; };
|
||||
bool SetKinematicParameters(int zt, int at, int zp, int ap, int ze, int ae, double b, double theta, double bke);
|
||||
|
||||
inline int GetRunMin() const {return m_rmin;}
|
||||
inline int GetRunMax() const {return m_rmax;}
|
||||
inline std::string GetWorkDirectory() const {return m_workspace;}
|
||||
inline int GetTargetZ() const {return m_ZT;}
|
||||
inline int GetTargetA() const {return m_AT;}
|
||||
inline int GetProjectileZ() const {return m_ZP;}
|
||||
inline int GetProjectileA() const {return m_AP;}
|
||||
inline int GetEjectileZ() const {return m_ZE;}
|
||||
inline int GetEjectileA() const {return m_AE;}
|
||||
inline int GetResidualZ() const {return m_ZR;}
|
||||
inline int GetResidualA() const {return m_AR;}
|
||||
inline double GetBField() const {return m_B;}
|
||||
inline double GetBeamKE() const {return m_BKE;}
|
||||
inline double GetTheta() const {return m_Theta;}
|
||||
inline double GetSlowCoincidenceWindow() const { return m_SlowWindow; }
|
||||
inline double GetFastWindowIonChamber() const { return m_FastWindowIonCh; }
|
||||
inline double GetFastWindowSABRE() const { return m_FastWindowSABRE; }
|
||||
inline std::string GetChannelMap() const { return m_mapfile; }
|
||||
inline std::string GetBoardShiftFile() const { return m_shiftfile; }
|
||||
inline std::string GetCutList() const { return m_cutList; }
|
||||
inline std::string GetScalerFile() const { return m_scalerfile; }
|
||||
|
||||
inline void AttachProgressBar(TGProgressBar* pb) { m_pb = pb; }
|
||||
|
||||
enum Operation
|
||||
{
|
||||
Convert,
|
||||
ConvertSlow,
|
||||
ConvertSlowA,
|
||||
ConvertFast,
|
||||
ConvertFastA,
|
||||
Merge,
|
||||
Plot
|
||||
namespace EventBuilder {
|
||||
|
||||
class EVBApp {
|
||||
public:
|
||||
EVBApp();
|
||||
~EVBApp();
|
||||
|
||||
bool ReadConfigFile(const std::string& filename);
|
||||
void WriteConfigFile(const std::string& filename);
|
||||
|
||||
void PlotHistograms();
|
||||
void MergeROOTFiles();
|
||||
void Convert2SortedRoot();
|
||||
void Convert2FastSortedRoot();
|
||||
void Convert2RawRoot();
|
||||
void Convert2SlowAnalyzedRoot();
|
||||
void Convert2FastAnalyzedRoot();
|
||||
|
||||
inline void SetRunRange(int rmin, int rmax) { m_rmin = rmin; m_rmax = rmax; };
|
||||
inline void SetWorkDirectory(const std::string& fullpath) { m_workspace = fullpath; };
|
||||
inline void SetChannelMap(const std::string& name) { m_mapfile = name; };
|
||||
inline void SetBoardShiftFile(const std::string& name) { m_shiftfile = name; };
|
||||
inline void SetSlowCoincidenceWindow(double window) { m_SlowWindow = window; };
|
||||
inline void SetFastWindowIonChamber(double window) { m_FastWindowIonCh = window; };
|
||||
inline void SetFastWindowSABRE(double window) { m_FastWindowSABRE = window; };
|
||||
inline void SetCutList(const std::string& name) { m_cutList = name; };
|
||||
inline void SetScalerFile(const std::string& fullpath) { m_scalerfile = fullpath; };
|
||||
bool SetKinematicParameters(int zt, int at, int zp, int ap, int ze, int ae, double b, double theta, double bke);
|
||||
|
||||
inline int GetRunMin() const {return m_rmin;}
|
||||
inline int GetRunMax() const {return m_rmax;}
|
||||
inline std::string GetWorkDirectory() const {return m_workspace;}
|
||||
inline int GetTargetZ() const {return m_ZT;}
|
||||
inline int GetTargetA() const {return m_AT;}
|
||||
inline int GetProjectileZ() const {return m_ZP;}
|
||||
inline int GetProjectileA() const {return m_AP;}
|
||||
inline int GetEjectileZ() const {return m_ZE;}
|
||||
inline int GetEjectileA() const {return m_AE;}
|
||||
inline int GetResidualZ() const {return m_ZR;}
|
||||
inline int GetResidualA() const {return m_AR;}
|
||||
inline double GetBField() const {return m_B;}
|
||||
inline double GetBeamKE() const {return m_BKE;}
|
||||
inline double GetTheta() const {return m_Theta;}
|
||||
inline double GetSlowCoincidenceWindow() const { return m_SlowWindow; }
|
||||
inline double GetFastWindowIonChamber() const { return m_FastWindowIonCh; }
|
||||
inline double GetFastWindowSABRE() const { return m_FastWindowSABRE; }
|
||||
inline std::string GetChannelMap() const { return m_mapfile; }
|
||||
inline std::string GetBoardShiftFile() const { return m_shiftfile; }
|
||||
inline std::string GetCutList() const { return m_cutList; }
|
||||
inline std::string GetScalerFile() const { return m_scalerfile; }
|
||||
|
||||
inline void AttachProgressBar(TGProgressBar* pb) { m_pb = pb; }
|
||||
|
||||
enum Operation
|
||||
{
|
||||
Convert,
|
||||
ConvertSlow,
|
||||
ConvertSlowA,
|
||||
ConvertFast,
|
||||
ConvertFastA,
|
||||
Merge,
|
||||
Plot
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
int m_rmin, m_rmax;
|
||||
int m_ZT, m_AT, m_ZP, m_AP, m_ZE, m_AE, m_ZR, m_AR;
|
||||
double m_B, m_Theta, m_BKE;
|
||||
|
||||
std::string m_workspace;
|
||||
std::string m_mapfile, m_shiftfile;
|
||||
std::string m_cutList;
|
||||
std::string m_scalerfile;
|
||||
|
||||
double m_SlowWindow;
|
||||
double m_FastWindowIonCh;
|
||||
double m_FastWindowSABRE;
|
||||
|
||||
RunCollector grabber;
|
||||
|
||||
TGProgressBar* m_pb;
|
||||
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
int m_rmin, m_rmax;
|
||||
int m_ZT, m_AT, m_ZP, m_AP, m_ZE, m_AE, m_ZR, m_AR;
|
||||
double m_B, m_Theta, m_BKE;
|
||||
|
||||
std::string m_workspace;
|
||||
std::string m_mapfile, m_shiftfile;
|
||||
std::string m_cutList;
|
||||
std::string m_scalerfile;
|
||||
|
||||
double m_SlowWindow;
|
||||
double m_FastWindowIonCh;
|
||||
double m_FastWindowSABRE;
|
||||
|
||||
RunCollector grabber;
|
||||
|
||||
TGProgressBar* m_pb;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -36,70 +36,73 @@
|
|||
#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,
|
||||
double EP, double angle, double B)
|
||||
{
|
||||
namespace EventBuilder {
|
||||
|
||||
/* CONSTANTS */
|
||||
const double UTOMEV = 931.4940954; //MeV per u;
|
||||
const double MEVTOJ = 1.60218E-13; //J per MeV
|
||||
const double RESTMASS_ELECTRON = 0.000548579909; //amu
|
||||
const double UNIT_CHARGE = 1.602E-19; //Coulombs
|
||||
const double C = 2.9979E8; //m/s
|
||||
|
||||
/* SESPS-SPECIFIC */
|
||||
const double DISP = 1.96; //dispersion (x/rho)
|
||||
const double MAG = 0.39; //magnification in x
|
||||
const double DEGTORAD = M_PI/180.;
|
||||
|
||||
int ZR = ZT + ZP - ZE, AR = AT + AP - AE;
|
||||
double EE=0; //ejectile energy
|
||||
|
||||
double MT=0, MP=0, ME=0, MR=0; //masses (MeV)
|
||||
|
||||
B /= 10000; //convert to tesla
|
||||
angle *= DEGTORAD;
|
||||
|
||||
MT = MASS.FindMass(ZT, AT) - ZT*RESTMASS_ELECTRON*UTOMEV;
|
||||
MP = MASS.FindMass(ZP, AP) - ZP*RESTMASS_ELECTRON*UTOMEV;
|
||||
ME = MASS.FindMass(ZE, AE) - ZE*RESTMASS_ELECTRON*UTOMEV;
|
||||
MR = MASS.FindMass(ZR, AR) - ZR*RESTMASS_ELECTRON*UTOMEV;
|
||||
|
||||
if (MT*MP*ME*MR == 0)
|
||||
//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)
|
||||
{
|
||||
std::cerr << "***WARNING: error loading one or more masses; returning 0\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
double Q = MT + MP - ME - MR; //Q-value
|
||||
|
||||
//kinematics a la Iliadis p.590
|
||||
double term1 = sqrt(MP*ME*EP)/(ME + MR)*cos(angle);
|
||||
double term2 = (EP*(MR - MP) + MR*Q)/(ME + MR);
|
||||
|
||||
EE = term1 + sqrt(term1*term1 + term2);
|
||||
EE *= EE;
|
||||
|
||||
//momentum
|
||||
double PE = sqrt(EE*(EE+2*ME));
|
||||
|
||||
//calculate rho from B a la B*rho = (proj. momentum)/(proj. charge)
|
||||
double rho = (PE*MEVTOJ)/(ZE*UNIT_CHARGE*C*B)*100; //in cm
|
||||
|
||||
double K;
|
||||
|
||||
K = sqrt(MP*ME*EP/EE);
|
||||
K *= sin(angle);
|
||||
|
||||
double denom = ME + MR - sqrt(MP*ME*EP/EE)*cos(angle);
|
||||
|
||||
K /= denom;
|
||||
std::cout<<"Delta Z= "<<-1*rho*DISP*MAG*K<<std::endl;
|
||||
return -1*rho*DISP*MAG*K; //delta-Z in cm
|
||||
/* CONSTANTS */
|
||||
const double UTOMEV = 931.4940954; //MeV per u;
|
||||
const double MEVTOJ = 1.60218E-13; //J per MeV
|
||||
const double RESTMASS_ELECTRON = 0.000548579909; //amu
|
||||
const double UNIT_CHARGE = 1.602E-19; //Coulombs
|
||||
const double C = 2.9979E8; //m/s
|
||||
|
||||
/* SESPS-SPECIFIC */
|
||||
const double DISP = 1.96; //dispersion (x/rho)
|
||||
const double MAG = 0.39; //magnification in x
|
||||
const double DEGTORAD = M_PI/180.;
|
||||
|
||||
int ZR = ZT + ZP - ZE, AR = AT + AP - AE;
|
||||
double EE=0; //ejectile energy
|
||||
|
||||
double MT=0, MP=0, ME=0, MR=0; //masses (MeV)
|
||||
|
||||
B /= 10000; //convert to tesla
|
||||
angle *= DEGTORAD;
|
||||
|
||||
MT = MASS.FindMass(ZT, AT) - ZT*RESTMASS_ELECTRON*UTOMEV;
|
||||
MP = MASS.FindMass(ZP, AP) - ZP*RESTMASS_ELECTRON*UTOMEV;
|
||||
ME = MASS.FindMass(ZE, AE) - ZE*RESTMASS_ELECTRON*UTOMEV;
|
||||
MR = MASS.FindMass(ZR, AR) - ZR*RESTMASS_ELECTRON*UTOMEV;
|
||||
|
||||
if (MT*MP*ME*MR == 0)
|
||||
{
|
||||
std::cerr << "***WARNING: error loading one or more masses; returning 0\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
double Q = MT + MP - ME - MR; //Q-value
|
||||
|
||||
//kinematics a la Iliadis p.590
|
||||
double term1 = sqrt(MP*ME*EP)/(ME + MR)*cos(angle);
|
||||
double term2 = (EP*(MR - MP) + MR*Q)/(ME + MR);
|
||||
|
||||
EE = term1 + sqrt(term1*term1 + term2);
|
||||
EE *= EE;
|
||||
|
||||
//momentum
|
||||
double PE = sqrt(EE*(EE+2*ME));
|
||||
|
||||
//calculate rho from B a la B*rho = (proj. momentum)/(proj. charge)
|
||||
double rho = (PE*MEVTOJ)/(ZE*UNIT_CHARGE*C*B)*100; //in cm
|
||||
|
||||
double K;
|
||||
|
||||
K = sqrt(MP*ME*EP/EE);
|
||||
K *= sin(angle);
|
||||
|
||||
double denom = ME + MR - sqrt(MP*ME*EP/EE)*cos(angle);
|
||||
|
||||
K /= denom;
|
||||
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,
|
||||
double EP, double angle, double B);
|
||||
namespace EventBuilder {
|
||||
|
||||
double Wire_Dist();
|
||||
//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();
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,125 +1,128 @@
|
|||
#include "EventBuilder.h"
|
||||
#include "FastSort.h"
|
||||
|
||||
//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()
|
||||
{
|
||||
delete event_address;
|
||||
}
|
||||
|
||||
void FastSort::ResetSABRE()
|
||||
{
|
||||
for(int i=0; i<5; i++)
|
||||
fastEvent.sabreArray[i] = sblank;
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
/*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
|
||||
*chamber
|
||||
*/
|
||||
if(slowEvent.focalPlane.anodeB.size() > ionch_index)
|
||||
{ //Back anode required to move on`
|
||||
|
||||
float anodeRelTime = fabs(slowEvent.focalPlane.anodeB[ionch_index].Time - slowEvent.focalPlane.scintL[scint_index].Time);
|
||||
if(anodeRelTime > ion_coincWindow)
|
||||
return; //Window check
|
||||
|
||||
fastEvent.focalPlane.anodeB.push_back(slowEvent.focalPlane.anodeB[ionch_index]);
|
||||
fastEvent.focalPlane.scintL.push_back(slowEvent.focalPlane.scintL[scint_index]);
|
||||
if(slowEvent.focalPlane.delayFL.size() > ionch_index)
|
||||
fastEvent.focalPlane.delayFL.push_back(slowEvent.focalPlane.delayFL[ionch_index]);
|
||||
|
||||
if(slowEvent.focalPlane.delayFR.size() > ionch_index)
|
||||
fastEvent.focalPlane.delayFR.push_back(slowEvent.focalPlane.delayFR[ionch_index]);
|
||||
|
||||
if(slowEvent.focalPlane.delayBR.size() > ionch_index)
|
||||
fastEvent.focalPlane.delayBR.push_back(slowEvent.focalPlane.delayBR[ionch_index]);
|
||||
|
||||
if(slowEvent.focalPlane.delayBL.size() > ionch_index)
|
||||
fastEvent.focalPlane.delayBL.push_back(slowEvent.focalPlane.delayBL[ionch_index]);
|
||||
|
||||
if(slowEvent.focalPlane.scintR.size() > ionch_index)
|
||||
fastEvent.focalPlane.scintR.push_back(slowEvent.focalPlane.scintR[ionch_index]);
|
||||
|
||||
if(slowEvent.focalPlane.anodeF.size() > ionch_index)
|
||||
fastEvent.focalPlane.anodeF.push_back(slowEvent.focalPlane.anodeF[ionch_index]);
|
||||
|
||||
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)
|
||||
{
|
||||
for(int i=0; i<5; i++)
|
||||
{ //loop over SABRE silicons
|
||||
std::vector<DetectorHit> rings;
|
||||
std::vector<DetectorHit> wedges;
|
||||
|
||||
if(slowEvent.sabreArray[i].rings.size() == 0 || slowEvent.sabreArray[i].wedges.size() == 0)
|
||||
continue; //save some time on empties
|
||||
|
||||
/*Dump sabre data that doesnt fall within the fast coincidence window with the scint*/
|
||||
for(unsigned int j=0; j<slowEvent.sabreArray[i].rings.size(); j++)
|
||||
{
|
||||
float sabreRelTime = fabs(slowEvent.sabreArray[i].rings[j].Time - slowEvent.focalPlane.scintL[scint_index].Time);
|
||||
if(sabreRelTime < si_coincWindow)
|
||||
rings.push_back(slowEvent.sabreArray[i].rings[j]);
|
||||
}
|
||||
for(unsigned int j=0; j<slowEvent.sabreArray[i].wedges.size(); j++)
|
||||
{
|
||||
float sabreRelTime = fabs(slowEvent.sabreArray[i].wedges[j].Time - slowEvent.focalPlane.scintL[scint_index].Time);
|
||||
if(sabreRelTime < si_coincWindow)
|
||||
wedges.push_back(slowEvent.sabreArray[i].wedges[j]);
|
||||
}
|
||||
|
||||
fastEvent.sabreArray[i].rings = rings;
|
||||
fastEvent.sabreArray[i].wedges = wedges;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<CoincEvent> FastSort::GetFastEvents(CoincEvent& event)
|
||||
{
|
||||
slowEvent = event;
|
||||
std::vector<CoincEvent> fast_events;
|
||||
|
||||
unsigned int sizeArray[7];
|
||||
sizeArray[0] = slowEvent.focalPlane.delayFL.size();
|
||||
sizeArray[1] = slowEvent.focalPlane.delayFR.size();
|
||||
sizeArray[2] = slowEvent.focalPlane.delayBL.size();
|
||||
sizeArray[3] = slowEvent.focalPlane.delayBR.size();
|
||||
sizeArray[4] = slowEvent.focalPlane.anodeF.size();
|
||||
sizeArray[5] = slowEvent.focalPlane.anodeB.size();
|
||||
sizeArray[6] = slowEvent.focalPlane.cathode.size();
|
||||
unsigned int maxSize = *std::max_element(sizeArray, sizeArray+7);
|
||||
//loop over scints
|
||||
for(unsigned int i=0; i<slowEvent.focalPlane.scintL.size(); i++)
|
||||
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)
|
||||
{
|
||||
ResetSABRE();
|
||||
ProcessSABRE(i);
|
||||
//loop over ion chamber
|
||||
//NOTE: as written, this dumps data that does not have an ion chamber hit!
|
||||
//If you want scint/SABRE singles, move the fill outside of this loop
|
||||
for(unsigned int j=0; j<maxSize; j++)
|
||||
{
|
||||
ResetFocalPlane();
|
||||
ProcessFocalPlane(i, j);
|
||||
fast_events.push_back(fastEvent);
|
||||
}
|
||||
|
||||
FastSort::~FastSort()
|
||||
{
|
||||
delete event_address;
|
||||
}
|
||||
|
||||
void FastSort::ResetSABRE()
|
||||
{
|
||||
for(int i=0; i<5; i++)
|
||||
fastEvent.sabreArray[i] = sblank;
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
/*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
|
||||
*chamber
|
||||
*/
|
||||
if(slowEvent.focalPlane.anodeB.size() > ionch_index)
|
||||
{ //Back anode required to move on`
|
||||
|
||||
float anodeRelTime = fabs(slowEvent.focalPlane.anodeB[ionch_index].Time - slowEvent.focalPlane.scintL[scint_index].Time);
|
||||
if(anodeRelTime > ion_coincWindow)
|
||||
return; //Window check
|
||||
|
||||
fastEvent.focalPlane.anodeB.push_back(slowEvent.focalPlane.anodeB[ionch_index]);
|
||||
fastEvent.focalPlane.scintL.push_back(slowEvent.focalPlane.scintL[scint_index]);
|
||||
if(slowEvent.focalPlane.delayFL.size() > ionch_index)
|
||||
fastEvent.focalPlane.delayFL.push_back(slowEvent.focalPlane.delayFL[ionch_index]);
|
||||
|
||||
if(slowEvent.focalPlane.delayFR.size() > ionch_index)
|
||||
fastEvent.focalPlane.delayFR.push_back(slowEvent.focalPlane.delayFR[ionch_index]);
|
||||
|
||||
if(slowEvent.focalPlane.delayBR.size() > ionch_index)
|
||||
fastEvent.focalPlane.delayBR.push_back(slowEvent.focalPlane.delayBR[ionch_index]);
|
||||
|
||||
if(slowEvent.focalPlane.delayBL.size() > ionch_index)
|
||||
fastEvent.focalPlane.delayBL.push_back(slowEvent.focalPlane.delayBL[ionch_index]);
|
||||
|
||||
if(slowEvent.focalPlane.scintR.size() > ionch_index)
|
||||
fastEvent.focalPlane.scintR.push_back(slowEvent.focalPlane.scintR[ionch_index]);
|
||||
|
||||
if(slowEvent.focalPlane.anodeF.size() > ionch_index)
|
||||
fastEvent.focalPlane.anodeF.push_back(slowEvent.focalPlane.anodeF[ionch_index]);
|
||||
|
||||
if(slowEvent.focalPlane.cathode.size() > ionch_index)
|
||||
fastEvent.focalPlane.cathode.push_back(slowEvent.focalPlane.cathode[ionch_index]);
|
||||
}
|
||||
}
|
||||
return fast_events;
|
||||
}
|
||||
|
||||
/*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;
|
||||
std::vector<DetectorHit> wedges;
|
||||
|
||||
if(slowEvent.sabreArray[i].rings.size() == 0 || slowEvent.sabreArray[i].wedges.size() == 0)
|
||||
continue; //save some time on empties
|
||||
|
||||
/*Dump sabre data that doesnt fall within the fast coincidence window with the scint*/
|
||||
for(unsigned int j=0; j<slowEvent.sabreArray[i].rings.size(); j++)
|
||||
{
|
||||
float sabreRelTime = fabs(slowEvent.sabreArray[i].rings[j].Time - slowEvent.focalPlane.scintL[scint_index].Time);
|
||||
if(sabreRelTime < si_coincWindow)
|
||||
rings.push_back(slowEvent.sabreArray[i].rings[j]);
|
||||
}
|
||||
for(unsigned int j=0; j<slowEvent.sabreArray[i].wedges.size(); j++)
|
||||
{
|
||||
float sabreRelTime = fabs(slowEvent.sabreArray[i].wedges[j].Time - slowEvent.focalPlane.scintL[scint_index].Time);
|
||||
if(sabreRelTime < si_coincWindow)
|
||||
wedges.push_back(slowEvent.sabreArray[i].wedges[j]);
|
||||
}
|
||||
|
||||
fastEvent.sabreArray[i].rings = rings;
|
||||
fastEvent.sabreArray[i].wedges = wedges;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<CoincEvent> FastSort::GetFastEvents(CoincEvent& event)
|
||||
{
|
||||
slowEvent = event;
|
||||
std::vector<CoincEvent> fast_events;
|
||||
|
||||
unsigned int sizeArray[7];
|
||||
sizeArray[0] = slowEvent.focalPlane.delayFL.size();
|
||||
sizeArray[1] = slowEvent.focalPlane.delayFR.size();
|
||||
sizeArray[2] = slowEvent.focalPlane.delayBL.size();
|
||||
sizeArray[3] = slowEvent.focalPlane.delayBR.size();
|
||||
sizeArray[4] = slowEvent.focalPlane.anodeF.size();
|
||||
sizeArray[5] = slowEvent.focalPlane.anodeB.size();
|
||||
sizeArray[6] = slowEvent.focalPlane.cathode.size();
|
||||
unsigned int maxSize = *std::max_element(sizeArray, sizeArray+7);
|
||||
//loop over scints
|
||||
for(unsigned int i=0; i<slowEvent.focalPlane.scintL.size(); i++)
|
||||
{
|
||||
ResetSABRE();
|
||||
ProcessSABRE(i);
|
||||
//loop over ion chamber
|
||||
//NOTE: as written, this dumps data that does not have an ion chamber hit!
|
||||
//If you want scint/SABRE singles, move the fill outside of this loop
|
||||
for(unsigned int j=0; j<maxSize; j++)
|
||||
{
|
||||
ResetFocalPlane();
|
||||
ProcessFocalPlane(i, j);
|
||||
fast_events.push_back(fastEvent);
|
||||
}
|
||||
}
|
||||
return fast_events;
|
||||
}
|
||||
|
||||
}
|
|
@ -9,26 +9,29 @@
|
|||
#include "DataStructs.h"
|
||||
#include <TH2.h>
|
||||
|
||||
class FastSort
|
||||
{
|
||||
|
||||
public:
|
||||
FastSort(float si_windowSize, float ion_windowSize);
|
||||
~FastSort();
|
||||
std::vector<CoincEvent> GetFastEvents(CoincEvent& event);
|
||||
namespace EventBuilder {
|
||||
|
||||
private:
|
||||
void ResetSABRE();
|
||||
void ResetFocalPlane();
|
||||
void ProcessSABRE(unsigned int scint_index);
|
||||
void ProcessFocalPlane(unsigned int scint_index, unsigned int ionch_index);
|
||||
|
||||
float si_coincWindow, ion_coincWindow;
|
||||
CoincEvent *event_address, slowEvent;
|
||||
CoincEvent fastEvent, blank;
|
||||
SabreDetector sblank;
|
||||
FPDetector fpblank;
|
||||
|
||||
};
|
||||
class FastSort
|
||||
{
|
||||
|
||||
public:
|
||||
FastSort(float si_windowSize, float ion_windowSize);
|
||||
~FastSort();
|
||||
std::vector<CoincEvent> GetFastEvents(CoincEvent& event);
|
||||
|
||||
private:
|
||||
void ResetSABRE();
|
||||
void ResetFocalPlane();
|
||||
void ProcessSABRE(unsigned int scint_index);
|
||||
void ProcessFocalPlane(unsigned int scint_index, unsigned int ionch_index);
|
||||
|
||||
float si_coincWindow, ion_coincWindow;
|
||||
CoincEvent *event_address, slowEvent;
|
||||
CoincEvent fastEvent, blank;
|
||||
SabreDetector sblank;
|
||||
FPDetector fpblank;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,106 +1,108 @@
|
|||
#include "EventBuilder.h"
|
||||
#include "FlagHandler.h"
|
||||
|
||||
FlagHandler::FlagHandler() :
|
||||
log("./event_log.txt")
|
||||
{
|
||||
}
|
||||
namespace EventBuilder {
|
||||
|
||||
FlagHandler::FlagHandler(const std::string& filename) :
|
||||
log(filename)
|
||||
{
|
||||
}
|
||||
|
||||
FlagHandler::~FlagHandler()
|
||||
{
|
||||
WriteLog();
|
||||
log.close();
|
||||
}
|
||||
|
||||
void FlagHandler::CheckFlag(int board, int channel, int flag)
|
||||
{
|
||||
|
||||
int gchan = channel + board*16;
|
||||
FlagCount& counter = event_count_map[gchan]; //yikes
|
||||
|
||||
counter.total_counts++;
|
||||
|
||||
if(flag & DeadTime)
|
||||
counter.dead_time++;
|
||||
|
||||
if(flag & TimeRollover)
|
||||
counter.time_roll++;
|
||||
|
||||
if(flag & TimeReset)
|
||||
counter.time_reset++;
|
||||
|
||||
if(flag & FakeEvent)
|
||||
counter.fake_event++;
|
||||
|
||||
if(flag & MemFull)
|
||||
counter.mem_full++;
|
||||
|
||||
if(flag & TrigLost)
|
||||
counter.trig_lost++;
|
||||
|
||||
if(flag & NTrigLost)
|
||||
counter.n_trig_lost++;
|
||||
|
||||
if(flag & SaturatingInGate)
|
||||
counter.sat_in_gate++;
|
||||
|
||||
if(flag & Trig1024Counted)
|
||||
counter.trig_1024++;;
|
||||
|
||||
if(flag & SaturatingInput)
|
||||
counter.sat_input++;
|
||||
|
||||
if(flag & NTrigCounted)
|
||||
counter.n_trig_count++;
|
||||
|
||||
if(flag & EventNotMatched)
|
||||
counter.event_not_matched++;
|
||||
|
||||
if(flag & PileUp)
|
||||
counter.pile_up++;
|
||||
|
||||
if(flag & PLLLockLoss)
|
||||
counter.pll_lock_loss++;
|
||||
|
||||
if(flag & OverTemp)
|
||||
counter.over_temp++;
|
||||
|
||||
if(flag & ADCShutdown)
|
||||
counter.adc_shutdown++;
|
||||
|
||||
}
|
||||
|
||||
void FlagHandler::WriteLog()
|
||||
{
|
||||
log<<"Event Flag Log"<<std::endl;
|
||||
log<<"-----------------------------"<<std::endl;
|
||||
for(auto& counter : event_count_map)
|
||||
FlagHandler::FlagHandler() :
|
||||
log("./event_log.txt")
|
||||
{
|
||||
}
|
||||
|
||||
FlagHandler::FlagHandler(const std::string& filename) :
|
||||
log(filename)
|
||||
{
|
||||
}
|
||||
|
||||
FlagHandler::~FlagHandler()
|
||||
{
|
||||
WriteLog();
|
||||
log.close();
|
||||
}
|
||||
|
||||
void FlagHandler::CheckFlag(int board, int channel, int flag)
|
||||
{
|
||||
|
||||
int gchan = channel + board*16;
|
||||
FlagCount& counter = event_count_map[gchan]; //yikes
|
||||
|
||||
counter.total_counts++;
|
||||
|
||||
if(flag & DeadTime)
|
||||
counter.dead_time++;
|
||||
|
||||
if(flag & TimeRollover)
|
||||
counter.time_roll++;
|
||||
|
||||
if(flag & TimeReset)
|
||||
counter.time_reset++;
|
||||
|
||||
if(flag & FakeEvent)
|
||||
counter.fake_event++;
|
||||
|
||||
if(flag & MemFull)
|
||||
counter.mem_full++;
|
||||
|
||||
if(flag & TrigLost)
|
||||
counter.trig_lost++;
|
||||
|
||||
if(flag & NTrigLost)
|
||||
counter.n_trig_lost++;
|
||||
|
||||
if(flag & SaturatingInGate)
|
||||
counter.sat_in_gate++;
|
||||
|
||||
if(flag & Trig1024Counted)
|
||||
counter.trig_1024++;;
|
||||
|
||||
if(flag & SaturatingInput)
|
||||
counter.sat_input++;
|
||||
|
||||
if(flag & NTrigCounted)
|
||||
counter.n_trig_count++;
|
||||
|
||||
if(flag & EventNotMatched)
|
||||
counter.event_not_matched++;
|
||||
|
||||
if(flag & PileUp)
|
||||
counter.pile_up++;
|
||||
|
||||
if(flag & PLLLockLoss)
|
||||
counter.pll_lock_loss++;
|
||||
|
||||
if(flag & OverTemp)
|
||||
counter.over_temp++;
|
||||
|
||||
if(flag & ADCShutdown)
|
||||
counter.adc_shutdown++;
|
||||
|
||||
}
|
||||
|
||||
void FlagHandler::WriteLog()
|
||||
{
|
||||
log<<"Event Flag Log"<<std::endl;
|
||||
log<<"-----------------------------"<<std::endl;
|
||||
log<<"GLOBAL CHANNEL No.: "<<counter.first<<std::endl;
|
||||
log<<"Total number of events: "<<counter.second.total_counts<<std::endl;
|
||||
log<<"Dead time incurred (only for V1724): "<<counter.second.dead_time<<std::endl;
|
||||
log<<"Timestamp rollovers: "<<counter.second.time_roll<<std::endl;
|
||||
log<<"Timestamp resets from external: "<<counter.second.time_reset<<std::endl;
|
||||
log<<"Fake events: "<<counter.second.fake_event<<std::endl;
|
||||
log<<"Memory full: "<<counter.second.mem_full<<std::endl;
|
||||
log<<"Triggers lost: "<<counter.second.trig_lost<<std::endl;
|
||||
log<<"N Triggers lost: "<<counter.second.n_trig_lost<<std::endl;
|
||||
log<<"Saturation within the gate: "<<counter.second.sat_in_gate<<std::endl;
|
||||
log<<"1024 Triggers found: "<<counter.second.trig_1024<<std::endl;
|
||||
log<<"Saturation on input: "<<counter.second.sat_input<<std::endl;
|
||||
log<<"N Triggers counted: "<<counter.second.n_trig_count<<std::endl;
|
||||
log<<"Events not matched: "<<counter.second.event_not_matched<<std::endl;
|
||||
log<<"Pile ups: "<<counter.second.pile_up<<std::endl;
|
||||
log<<"PLL lock lost: "<<counter.second.pll_lock_loss<<std::endl;
|
||||
log<<"Over Temperature: "<<counter.second.over_temp<<std::endl;
|
||||
log<<"ADC Shutdown: "<<counter.second.adc_shutdown<<std::endl;
|
||||
log<<"-----------------------------"<<std::endl;
|
||||
for(auto& counter : event_count_map)
|
||||
{
|
||||
log<<"-----------------------------"<<std::endl;
|
||||
log<<"GLOBAL CHANNEL No.: "<<counter.first<<std::endl;
|
||||
log<<"Total number of events: "<<counter.second.total_counts<<std::endl;
|
||||
log<<"Dead time incurred (only for V1724): "<<counter.second.dead_time<<std::endl;
|
||||
log<<"Timestamp rollovers: "<<counter.second.time_roll<<std::endl;
|
||||
log<<"Timestamp resets from external: "<<counter.second.time_reset<<std::endl;
|
||||
log<<"Fake events: "<<counter.second.fake_event<<std::endl;
|
||||
log<<"Memory full: "<<counter.second.mem_full<<std::endl;
|
||||
log<<"Triggers lost: "<<counter.second.trig_lost<<std::endl;
|
||||
log<<"N Triggers lost: "<<counter.second.n_trig_lost<<std::endl;
|
||||
log<<"Saturation within the gate: "<<counter.second.sat_in_gate<<std::endl;
|
||||
log<<"1024 Triggers found: "<<counter.second.trig_1024<<std::endl;
|
||||
log<<"Saturation on input: "<<counter.second.sat_input<<std::endl;
|
||||
log<<"N Triggers counted: "<<counter.second.n_trig_count<<std::endl;
|
||||
log<<"Events not matched: "<<counter.second.event_not_matched<<std::endl;
|
||||
log<<"Pile ups: "<<counter.second.pile_up<<std::endl;
|
||||
log<<"PLL lock lost: "<<counter.second.pll_lock_loss<<std::endl;
|
||||
log<<"Over Temperature: "<<counter.second.over_temp<<std::endl;
|
||||
log<<"ADC Shutdown: "<<counter.second.adc_shutdown<<std::endl;
|
||||
log<<"-----------------------------"<<std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,59 +3,62 @@
|
|||
|
||||
#include <map>
|
||||
|
||||
struct FlagCount
|
||||
{
|
||||
long total_counts=0;
|
||||
long dead_time=0;
|
||||
long time_roll=0;
|
||||
long time_reset=0;
|
||||
long fake_event=0;
|
||||
long mem_full=0;
|
||||
long trig_lost=0;
|
||||
long n_trig_lost=0;
|
||||
long sat_in_gate=0;
|
||||
long trig_1024=0;
|
||||
long sat_input=0;
|
||||
long n_trig_count=0;
|
||||
long event_not_matched=0;
|
||||
long fine_time=0;
|
||||
long pile_up=0;
|
||||
long pll_lock_loss=0;
|
||||
long over_temp=0;
|
||||
long adc_shutdown=0;
|
||||
};
|
||||
namespace EventBuilder {
|
||||
|
||||
class FlagHandler
|
||||
{
|
||||
public:
|
||||
FlagHandler();
|
||||
FlagHandler(const std::string& filename);
|
||||
~FlagHandler();
|
||||
void CheckFlag(int board, int channel, int flag);
|
||||
|
||||
const int DeadTime = 0x00000001;
|
||||
const int TimeRollover = 0x00000002;
|
||||
const int TimeReset = 0x00000004;
|
||||
const int FakeEvent = 0x00000008;
|
||||
const int MemFull = 0x00000010;
|
||||
const int TrigLost = 0x00000020;
|
||||
const int NTrigLost = 0x00000040;
|
||||
const int SaturatingInGate = 0x00000080;
|
||||
const int Trig1024Counted = 0x00000100;
|
||||
const int SaturatingInput = 0x00000400;
|
||||
const int NTrigCounted = 0x00000800;
|
||||
const int EventNotMatched = 0x00001000;
|
||||
const int FineTime = 0x00004000;
|
||||
const int PileUp = 0x00008000;
|
||||
const int PLLLockLoss = 0x00080000;
|
||||
const int OverTemp = 0x00100000;
|
||||
const int ADCShutdown = 0x00200000;
|
||||
|
||||
private:
|
||||
std::ofstream log;
|
||||
std::map<int, FlagCount> event_count_map;
|
||||
|
||||
void WriteLog();
|
||||
};
|
||||
struct FlagCount
|
||||
{
|
||||
long total_counts=0;
|
||||
long dead_time=0;
|
||||
long time_roll=0;
|
||||
long time_reset=0;
|
||||
long fake_event=0;
|
||||
long mem_full=0;
|
||||
long trig_lost=0;
|
||||
long n_trig_lost=0;
|
||||
long sat_in_gate=0;
|
||||
long trig_1024=0;
|
||||
long sat_input=0;
|
||||
long n_trig_count=0;
|
||||
long event_not_matched=0;
|
||||
long fine_time=0;
|
||||
long pile_up=0;
|
||||
long pll_lock_loss=0;
|
||||
long over_temp=0;
|
||||
long adc_shutdown=0;
|
||||
};
|
||||
|
||||
class FlagHandler
|
||||
{
|
||||
public:
|
||||
FlagHandler();
|
||||
FlagHandler(const std::string& filename);
|
||||
~FlagHandler();
|
||||
void CheckFlag(int board, int channel, int flag);
|
||||
|
||||
const int DeadTime = 0x00000001;
|
||||
const int TimeRollover = 0x00000002;
|
||||
const int TimeReset = 0x00000004;
|
||||
const int FakeEvent = 0x00000008;
|
||||
const int MemFull = 0x00000010;
|
||||
const int TrigLost = 0x00000020;
|
||||
const int NTrigLost = 0x00000040;
|
||||
const int SaturatingInGate = 0x00000080;
|
||||
const int Trig1024Counted = 0x00000100;
|
||||
const int SaturatingInput = 0x00000400;
|
||||
const int NTrigCounted = 0x00000800;
|
||||
const int EventNotMatched = 0x00001000;
|
||||
const int FineTime = 0x00004000;
|
||||
const int PileUp = 0x00008000;
|
||||
const int PLLLockLoss = 0x00080000;
|
||||
const int OverTemp = 0x00100000;
|
||||
const int ADCShutdown = 0x00200000;
|
||||
|
||||
private:
|
||||
std::ofstream log;
|
||||
std::map<int, FlagCount> event_count_map;
|
||||
|
||||
void WriteLog();
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -11,65 +11,67 @@ Written by G.W. McCann Aug. 2020
|
|||
#include "EventBuilder.h"
|
||||
#include "MassLookup.h"
|
||||
|
||||
|
||||
/*
|
||||
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()
|
||||
{
|
||||
std::string filepath;
|
||||
#ifdef ETC_DIR_PATH
|
||||
filepath = ETC_DIR_PATH;
|
||||
filepath += "mass.txt";
|
||||
#else
|
||||
filepath = "./etc/mass.txt";
|
||||
#endif
|
||||
std::ifstream massfile(filepath);
|
||||
if(massfile.is_open())
|
||||
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()
|
||||
{
|
||||
int Z,A;
|
||||
std::string junk, element, key;
|
||||
double atomicMassBig, atomicMassSmall, isotopicMass;
|
||||
std::getline(massfile,junk);
|
||||
std::getline(massfile,junk);
|
||||
while(massfile>>junk)
|
||||
std::string filepath;
|
||||
#ifdef ETC_DIR_PATH
|
||||
filepath = ETC_DIR_PATH;
|
||||
filepath += "mass.txt";
|
||||
#else
|
||||
filepath = "./etc/mass.txt";
|
||||
#endif
|
||||
std::ifstream massfile(filepath);
|
||||
if(massfile.is_open())
|
||||
{
|
||||
massfile>>Z>>A>>element>>atomicMassBig>>atomicMassSmall;
|
||||
isotopicMass = (atomicMassBig + atomicMassSmall*1e-6 - Z*electron_mass)*u_to_mev;
|
||||
key = "("+std::to_string(Z)+","+A+")";
|
||||
massTable[key] = isotopicMass;
|
||||
elementTable[Z] = element;
|
||||
int Z,A;
|
||||
std::string junk, element, key;
|
||||
double atomicMassBig, atomicMassSmall, isotopicMass;
|
||||
std::getline(massfile,junk);
|
||||
std::getline(massfile,junk);
|
||||
while(massfile>>junk)
|
||||
{
|
||||
massfile>>Z>>A>>element>>atomicMassBig>>atomicMassSmall;
|
||||
isotopicMass = (atomicMassBig + atomicMassSmall*1e-6 - Z*electron_mass)*u_to_mev;
|
||||
key = "("+std::to_string(Z)+","+A+")";
|
||||
massTable[key] = isotopicMass;
|
||||
elementTable[Z] = element;
|
||||
}
|
||||
}
|
||||
else
|
||||
std::cerr<<"Unable to open mass.txt at MassLookup! Prepare for errors."<<std::endl;
|
||||
}
|
||||
|
||||
MassLookup::~MassLookup() {}
|
||||
|
||||
//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())
|
||||
{
|
||||
std::cerr<<"Invaild nucleus at MassLookup! Returning mass of 0"<<std::endl;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
std::cerr<<"Unable to open mass.txt at MassLookup! Prepare for errors."<<std::endl;
|
||||
}
|
||||
|
||||
MassLookup::~MassLookup() {}
|
||||
|
||||
//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())
|
||||
{
|
||||
std::cerr<<"Invaild nucleus at MassLookup! Returning mass of 0"<<std::endl;
|
||||
return 0;
|
||||
return data->second;
|
||||
}
|
||||
return data->second;
|
||||
}
|
||||
|
||||
//returns element symbol
|
||||
std::string MassLookup::FindSymbol(int Z, int A)
|
||||
{
|
||||
auto data = elementTable.find(Z);
|
||||
if(data == elementTable.end())
|
||||
|
||||
//returns element symbol
|
||||
std::string MassLookup::FindSymbol(int Z, int A)
|
||||
{
|
||||
std::cerr<<"Invaild nucleus at MassLookup! Returning empty symbol"<<std::endl;
|
||||
return "";
|
||||
auto data = elementTable.find(Z);
|
||||
if(data == elementTable.end())
|
||||
{
|
||||
std::cerr<<"Invaild nucleus at MassLookup! Returning empty symbol"<<std::endl;
|
||||
return "";
|
||||
}
|
||||
std::string fullsymbol = std::to_string(A) + data->second;
|
||||
return fullsymbol;
|
||||
}
|
||||
std::string fullsymbol = std::to_string(A) + data->second;
|
||||
return fullsymbol;
|
||||
}
|
||||
}
|
|
@ -11,25 +11,29 @@ Written by G.W. McCann Aug. 2020
|
|||
#ifndef MASS_LOOKUP_H
|
||||
#define MASS_LOOKUP_H
|
||||
|
||||
class MassLookup
|
||||
{
|
||||
namespace EventBuilder {
|
||||
|
||||
public:
|
||||
MassLookup();
|
||||
~MassLookup();
|
||||
double FindMass(int Z, int A);
|
||||
std::string FindSymbol(int Z, int A);
|
||||
class MassLookup
|
||||
{
|
||||
|
||||
public:
|
||||
MassLookup();
|
||||
~MassLookup();
|
||||
double FindMass(int Z, int A);
|
||||
std::string FindSymbol(int Z, int A);
|
||||
|
||||
private:
|
||||
std::unordered_map<std::string, double> massTable;
|
||||
std::unordered_map<int, std::string> elementTable;
|
||||
|
||||
//constants
|
||||
static constexpr double u_to_mev = 931.4940954;
|
||||
static constexpr double electron_mass = 0.000548579909;
|
||||
|
||||
};
|
||||
|
||||
//static instance for use throught program
|
||||
static MassLookup MASS;
|
||||
|
||||
private:
|
||||
std::unordered_map<std::string, double> massTable;
|
||||
std::unordered_map<int, std::string> elementTable;
|
||||
|
||||
//constants
|
||||
static constexpr double u_to_mev = 931.4940954;
|
||||
static constexpr double electron_mass = 0.000548579909;
|
||||
|
||||
};
|
||||
|
||||
//static instance for use throught program
|
||||
static MassLookup MASS;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -8,33 +8,37 @@
|
|||
#include "EventBuilder.h"
|
||||
#include "OrderChecker.h"
|
||||
|
||||
OrderChecker::OrderChecker()
|
||||
{
|
||||
}
|
||||
|
||||
OrderChecker::~OrderChecker()
|
||||
{
|
||||
}
|
||||
|
||||
bool OrderChecker::IsOrdered(const std::string& filename)
|
||||
{
|
||||
TFile* file = TFile::Open(filename.c_str(), "READ");
|
||||
TTree* tree = (TTree*) file->Get("Data");
|
||||
|
||||
uint64_t ts;
|
||||
tree->SetBranchAddress("Timestamp", &ts);
|
||||
uint64_t prevStamp = 0;
|
||||
|
||||
for(Long64_t i=0; i<tree->GetEntries(); i++)
|
||||
namespace EventBuilder {
|
||||
|
||||
OrderChecker::OrderChecker()
|
||||
{
|
||||
tree->GetEntry();
|
||||
if(prevStamp >= ts)
|
||||
}
|
||||
|
||||
OrderChecker::~OrderChecker()
|
||||
{
|
||||
}
|
||||
|
||||
bool OrderChecker::IsOrdered(const std::string& filename)
|
||||
{
|
||||
TFile* file = TFile::Open(filename.c_str(), "READ");
|
||||
TTree* tree = (TTree*) file->Get("Data");
|
||||
|
||||
uint64_t ts;
|
||||
tree->SetBranchAddress("Timestamp", &ts);
|
||||
uint64_t prevStamp = 0;
|
||||
|
||||
for(Long64_t i=0; i<tree->GetEntries(); i++)
|
||||
{
|
||||
std::cerr<<"Bad order at entry "<<i<<" out of "<<tree->GetEntries()<<std::endl;
|
||||
return false;
|
||||
tree->GetEntry();
|
||||
if(prevStamp >= ts)
|
||||
{
|
||||
std::cerr<<"Bad order at entry "<<i<<" out of "<<tree->GetEntries()<<std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
file->Close();
|
||||
return true;
|
||||
}
|
||||
|
||||
file->Close();
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -8,12 +8,16 @@
|
|||
#ifndef ORDERCHECKER_H
|
||||
#define ORDERCHECKER_H
|
||||
|
||||
class OrderChecker
|
||||
{
|
||||
public:
|
||||
OrderChecker();
|
||||
~OrderChecker();
|
||||
bool IsOrdered(const std::string& filename);
|
||||
};
|
||||
namespace EventBuilder {
|
||||
|
||||
class OrderChecker
|
||||
{
|
||||
public:
|
||||
OrderChecker();
|
||||
~OrderChecker();
|
||||
bool IsOrdered(const std::string& filename);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -7,127 +7,89 @@
|
|||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
|
||||
RunCollector::RunCollector():
|
||||
m_initFlag(false), m_directory(""), m_prefix(""), m_suffix(""), m_minRun(0), m_maxRun(0)
|
||||
{
|
||||
}
|
||||
namespace EventBuilder {
|
||||
|
||||
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) :
|
||||
m_initFlag(true), m_directory(dirname), m_prefix(prefix), m_suffix(suffix), m_minRun(min), m_maxRun(max)
|
||||
{
|
||||
}
|
||||
|
||||
RunCollector::~RunCollector() {}
|
||||
|
||||
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()
|
||||
{
|
||||
if(!m_initFlag)
|
||||
return false;
|
||||
|
||||
TSystemDirectory sysdir(m_directory.c_str(), m_directory.c_str());
|
||||
TList *flist = sysdir.GetListOfFiles();
|
||||
m_filelist.clear();
|
||||
|
||||
if(!flist) //Make sure list is real. If not, means no directory
|
||||
RunCollector::RunCollector():
|
||||
m_initFlag(false), m_directory(""), m_prefix(""), m_suffix(""), m_minRun(0), m_maxRun(0)
|
||||
{
|
||||
std::cerr<<"Unable to find any files in directory; check name given to the input.txt"<<std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
TSystemFile *file;
|
||||
std::string fname, temp;
|
||||
TIter next_element(flist); //List iterator
|
||||
while((file = (TSystemFile*)next_element()))
|
||||
|
||||
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)
|
||||
{
|
||||
temp = file->GetName();
|
||||
if(temp.size() < m_prefix.size() || temp.size() < m_suffix.size())
|
||||
continue;
|
||||
else if(!file->IsDirectory() && !temp.compare(0,m_prefix.size(),m_prefix) &&
|
||||
!temp.compare(temp.size()-m_suffix.size(), m_suffix.size(), m_suffix))
|
||||
}
|
||||
|
||||
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() {}
|
||||
|
||||
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()
|
||||
{
|
||||
if(!m_initFlag)
|
||||
return false;
|
||||
|
||||
TSystemDirectory sysdir(m_directory.c_str(), m_directory.c_str());
|
||||
TList *flist = sysdir.GetListOfFiles();
|
||||
m_filelist.clear();
|
||||
|
||||
if(!flist) //Make sure list is real. If not, means no directory
|
||||
{
|
||||
fname = m_directory+temp;
|
||||
m_filelist.push_back(fname);
|
||||
}
|
||||
}
|
||||
|
||||
delete flist;
|
||||
if(m_filelist.size()>0)
|
||||
return true;
|
||||
else
|
||||
{
|
||||
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) {
|
||||
if(!m_initFlag)
|
||||
return "";
|
||||
TSystemDirectory sysdir(m_directory.c_str(), m_directory.c_str());
|
||||
TList* flist = sysdir.GetListOfFiles();
|
||||
|
||||
if(!flist)
|
||||
return "";
|
||||
|
||||
TSystemFile *file;
|
||||
std::string fname = "", temp;
|
||||
std::string runno = "_"+std::to_string(runNum)+m_suffix;
|
||||
TIter next_element(flist);
|
||||
while((file = (TSystemFile*)next_element()))
|
||||
{
|
||||
temp = file->GetName();
|
||||
if(temp.size() < m_prefix.size() || temp.size() < runno.size())
|
||||
continue;
|
||||
else if(!file->IsDirectory() && !temp.compare(0,m_prefix.size(),m_prefix) &&
|
||||
!temp.compare(temp.size()-runno.size(),runno.size(), runno))
|
||||
std::cerr<<"Unable to find any files in directory; check name given to the input.txt"<<std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
TSystemFile *file;
|
||||
std::string fname, temp;
|
||||
TIter next_element(flist); //List iterator
|
||||
while((file = (TSystemFile*)next_element()))
|
||||
{
|
||||
fname = m_directory+temp;
|
||||
break;
|
||||
temp = file->GetName();
|
||||
if(temp.size() < m_prefix.size() || temp.size() < m_suffix.size())
|
||||
continue;
|
||||
else if(!file->IsDirectory() && !temp.compare(0,m_prefix.size(),m_prefix) &&
|
||||
!temp.compare(temp.size()-m_suffix.size(), m_suffix.size(), m_suffix))
|
||||
{
|
||||
fname = m_directory+temp;
|
||||
m_filelist.push_back(fname);
|
||||
}
|
||||
}
|
||||
|
||||
delete flist;
|
||||
if(m_filelist.size()>0)
|
||||
return true;
|
||||
else
|
||||
{
|
||||
std::cerr<<"Unable to find files with matching run name in directory; check input.txt"<<std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
delete flist;
|
||||
return fname;
|
||||
}
|
||||
|
||||
/*Grabs all files within a specified run range*/
|
||||
bool RunCollector::GrabFilesInRange()
|
||||
{
|
||||
if(!m_initFlag)
|
||||
return false;
|
||||
|
||||
TSystemDirectory sysdir(m_directory.c_str(), m_directory.c_str());
|
||||
TList *flist = sysdir.GetListOfFiles();
|
||||
m_filelist.clear();
|
||||
|
||||
if(!flist)
|
||||
{
|
||||
std::cerr<<"Unable to find any files in directory; check name given to input.txt"<<std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
TSystemFile *file;
|
||||
std::string fname, temp;
|
||||
std::string runno;
|
||||
for(int i=m_minRun; i<=m_maxRun; i++) //loop over range
|
||||
{
|
||||
TIter next_element(flist);//list iterator
|
||||
runno = "_"+std::to_string(i) + m_suffix; //suffix is now _#.suffix
|
||||
while((file = (TSystemFile*)next_element())) //look through directory until file found
|
||||
|
||||
std::string RunCollector::GrabFile(int runNum) {
|
||||
if(!m_initFlag)
|
||||
return "";
|
||||
TSystemDirectory sysdir(m_directory.c_str(), m_directory.c_str());
|
||||
TList* flist = sysdir.GetListOfFiles();
|
||||
|
||||
if(!flist)
|
||||
return "";
|
||||
|
||||
TSystemFile *file;
|
||||
std::string fname = "", temp;
|
||||
std::string runno = "_"+std::to_string(runNum)+m_suffix;
|
||||
TIter next_element(flist);
|
||||
while((file = (TSystemFile*)next_element()))
|
||||
{
|
||||
temp = file->GetName();
|
||||
if(temp.size() < m_prefix.size() || temp.size() < runno.size())
|
||||
|
@ -136,96 +98,138 @@ bool RunCollector::GrabFilesInRange()
|
|||
!temp.compare(temp.size()-runno.size(),runno.size(), runno))
|
||||
{
|
||||
fname = m_directory+temp;
|
||||
m_filelist.push_back(fname);
|
||||
break; //if we find the file, break out of iterator loop
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
delete flist;
|
||||
return fname;
|
||||
}
|
||||
|
||||
delete flist;
|
||||
if(m_filelist.size()>0)
|
||||
return true;
|
||||
else
|
||||
|
||||
/*Grabs all files within a specified run range*/
|
||||
bool RunCollector::GrabFilesInRange()
|
||||
{
|
||||
std::cerr<<"Unable to find files with matching run name in directory; check input.txt"<<std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool RunCollector::Merge_hadd(const std::string& outname)
|
||||
{
|
||||
if(!m_initFlag)
|
||||
return false;
|
||||
|
||||
if(m_maxRun == 0)
|
||||
{
|
||||
if(GrabAllFiles())
|
||||
{
|
||||
std::string clump = "hadd "+outname;
|
||||
for(unsigned int i=0; i<m_filelist.size(); i++)
|
||||
clump += " "+m_filelist[i];
|
||||
std::cout<<"Merging runs into single file..."<<std::endl;
|
||||
std::system(clump.c_str());
|
||||
std::cout<<"Finished merging"<<std::endl;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
if(!m_initFlag)
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(GrabFilesInRange())
|
||||
|
||||
TSystemDirectory sysdir(m_directory.c_str(), m_directory.c_str());
|
||||
TList *flist = sysdir.GetListOfFiles();
|
||||
m_filelist.clear();
|
||||
|
||||
if(!flist)
|
||||
{
|
||||
std::string clump = "hadd "+outname;
|
||||
for(unsigned int i=0; i<m_filelist.size(); i++)
|
||||
clump += " "+m_filelist[i];
|
||||
std::cout<<"Merging runs "<<m_minRun<<" to "<<m_maxRun<<" into a single file..."<<std::endl;
|
||||
std::system(clump.c_str());
|
||||
std::cout<<"Finished merging"<<std::endl;
|
||||
std::cerr<<"Unable to find any files in directory; check name given to input.txt"<<std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
TSystemFile *file;
|
||||
std::string fname, temp;
|
||||
std::string runno;
|
||||
for(int i=m_minRun; i<=m_maxRun; i++) //loop over range
|
||||
{
|
||||
TIter next_element(flist);//list iterator
|
||||
runno = "_"+std::to_string(i) + m_suffix; //suffix is now _#.suffix
|
||||
while((file = (TSystemFile*)next_element())) //look through directory until file found
|
||||
{
|
||||
temp = file->GetName();
|
||||
if(temp.size() < m_prefix.size() || temp.size() < runno.size())
|
||||
continue;
|
||||
else if(!file->IsDirectory() && !temp.compare(0,m_prefix.size(),m_prefix) &&
|
||||
!temp.compare(temp.size()-runno.size(),runno.size(), runno))
|
||||
{
|
||||
fname = m_directory+temp;
|
||||
m_filelist.push_back(fname);
|
||||
break; //if we find the file, break out of iterator loop
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delete flist;
|
||||
if(m_filelist.size()>0)
|
||||
return true;
|
||||
else
|
||||
{
|
||||
std::cerr<<"Unable to find files with matching run name in directory; check input.txt"<<std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool RunCollector::Merge_hadd(const std::string& outname)
|
||||
{
|
||||
if(!m_initFlag)
|
||||
return false;
|
||||
|
||||
if(m_maxRun == 0)
|
||||
{
|
||||
if(GrabAllFiles())
|
||||
{
|
||||
std::string clump = "hadd "+outname;
|
||||
for(unsigned int i=0; i<m_filelist.size(); i++)
|
||||
clump += " "+m_filelist[i];
|
||||
std::cout<<"Merging runs into single file..."<<std::endl;
|
||||
std::system(clump.c_str());
|
||||
std::cout<<"Finished merging"<<std::endl;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool RunCollector::Merge_TChain(const std::string& outname)
|
||||
{
|
||||
if(!m_initFlag)
|
||||
return false;
|
||||
TFile *output = new TFile(outname.c_str(), "RECREATE");
|
||||
TChain *chain = new TChain("SPSTree", "SPSTree");
|
||||
|
||||
if(m_maxRun == 0)
|
||||
{
|
||||
if(GrabAllFiles())
|
||||
{
|
||||
for(unsigned int i=0; i<m_filelist.size(); i++)
|
||||
chain->Add(m_filelist[i].c_str());
|
||||
std::cout<<"Merging runs into single file..."<<std::endl;
|
||||
chain->Merge(output,0,"fast");
|
||||
std::cout<<"Finished merging"<<std::endl;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(GrabFilesInRange())
|
||||
{
|
||||
for(unsigned int i=0; i<m_filelist.size(); i++)
|
||||
chain->Add(m_filelist[i].c_str());
|
||||
std::cout<<"Merging runs "<<m_minRun<<" to "<<m_maxRun<<" into a single file..."<<std::endl;
|
||||
chain->Merge(output,0,"fast");
|
||||
std::cout<<"Finished merging"<<std::endl;
|
||||
return true;
|
||||
} else
|
||||
if(GrabFilesInRange())
|
||||
{
|
||||
std::string clump = "hadd "+outname;
|
||||
for(unsigned int i=0; i<m_filelist.size(); i++)
|
||||
clump += " "+m_filelist[i];
|
||||
std::cout<<"Merging runs "<<m_minRun<<" to "<<m_maxRun<<" into a single file..."<<std::endl;
|
||||
std::system(clump.c_str());
|
||||
std::cout<<"Finished merging"<<std::endl;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool RunCollector::Merge_TChain(const std::string& outname)
|
||||
{
|
||||
if(!m_initFlag)
|
||||
return false;
|
||||
TFile *output = new TFile(outname.c_str(), "RECREATE");
|
||||
TChain *chain = new TChain("SPSTree", "SPSTree");
|
||||
|
||||
if(m_maxRun == 0)
|
||||
{
|
||||
if(GrabAllFiles())
|
||||
{
|
||||
for(unsigned int i=0; i<m_filelist.size(); i++)
|
||||
chain->Add(m_filelist[i].c_str());
|
||||
std::cout<<"Merging runs into single file..."<<std::endl;
|
||||
chain->Merge(output,0,"fast");
|
||||
std::cout<<"Finished merging"<<std::endl;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(GrabFilesInRange())
|
||||
{
|
||||
for(unsigned int i=0; i<m_filelist.size(); i++)
|
||||
chain->Add(m_filelist[i].c_str());
|
||||
std::cout<<"Merging runs "<<m_minRun<<" to "<<m_maxRun<<" into a single file..."<<std::endl;
|
||||
chain->Merge(output,0,"fast");
|
||||
std::cout<<"Finished merging"<<std::endl;
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
if(output->IsOpen())
|
||||
output->Close();
|
||||
return false;
|
||||
}
|
||||
|
||||
if(output->IsOpen())
|
||||
output->Close();
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -10,35 +10,38 @@
|
|||
#ifndef RUNCOLLECTOR_H
|
||||
#define RUNCOLLECTOR_H
|
||||
|
||||
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);
|
||||
~RunCollector();
|
||||
void SetSearchParams(const std::string& dirname, const std::string& prefix, const std::string& suffix, int min, int max);
|
||||
bool Merge_hadd(const std::string& outname);
|
||||
bool Merge_TChain(const std::string& outname);
|
||||
bool GrabAllFiles();
|
||||
bool GrabFilesInRange();
|
||||
std::string GrabFile(int runNum);
|
||||
inline std::string GetSearchDir() { return m_directory; }
|
||||
inline std::string GetSearchPrefix() { return m_prefix; }
|
||||
inline std::string GetSearchSuffix() { return m_suffix; }
|
||||
inline int GetRunMin() { return m_minRun; }
|
||||
inline int GetRunMax() { return m_maxRun; }
|
||||
inline const std::vector<std::string>& GetFileList() { return m_filelist; }
|
||||
namespace EventBuilder {
|
||||
|
||||
private:
|
||||
bool m_initFlag;
|
||||
std::string m_directory;
|
||||
std::string m_prefix;
|
||||
std::string m_suffix;
|
||||
int m_minRun, m_maxRun; //user run limits
|
||||
const int m_maxAllowedRuns = 1000; //class run limit
|
||||
std::vector<std::string> m_filelist;
|
||||
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);
|
||||
~RunCollector();
|
||||
void SetSearchParams(const std::string& dirname, const std::string& prefix, const std::string& suffix, int min, int max);
|
||||
bool Merge_hadd(const std::string& outname);
|
||||
bool Merge_TChain(const std::string& outname);
|
||||
bool GrabAllFiles();
|
||||
bool GrabFilesInRange();
|
||||
std::string GrabFile(int runNum);
|
||||
inline std::string GetSearchDir() { return m_directory; }
|
||||
inline std::string GetSearchPrefix() { return m_prefix; }
|
||||
inline std::string GetSearchSuffix() { return m_suffix; }
|
||||
inline int GetRunMin() { return m_minRun; }
|
||||
inline int GetRunMax() { return m_maxRun; }
|
||||
inline const std::vector<std::string>& GetFileList() { return m_filelist; }
|
||||
|
||||
};
|
||||
private:
|
||||
bool m_initFlag;
|
||||
std::string m_directory;
|
||||
std::string m_prefix;
|
||||
std::string m_suffix;
|
||||
int m_minRun, m_maxRun; //user run limits
|
||||
const int m_maxAllowedRuns = 1000; //class run limit
|
||||
std::vector<std::string> m_filelist;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -12,194 +12,197 @@
|
|||
#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,
|
||||
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()
|
||||
{
|
||||
rootObj->Clear();
|
||||
delete rootObj;
|
||||
delete event_address;
|
||||
}
|
||||
|
||||
void SFPAnalyzer::Reset()
|
||||
{
|
||||
pevent = blank; //set output back to blank
|
||||
}
|
||||
|
||||
/*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()
|
||||
{
|
||||
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,
|
||||
int binsy, double miny, double maxy, double valuey)
|
||||
{
|
||||
TH2F *histo = (TH2F*) rootObj->FindObject(name.c_str());
|
||||
if(histo != nullptr)
|
||||
histo->Fill(valuex, valuey);
|
||||
else
|
||||
/*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)
|
||||
{
|
||||
TH2F *h = new TH2F(name.c_str(), name.c_str(), binsx, minx, maxx, binsy, miny, maxy);
|
||||
h->Fill(valuex, valuey);
|
||||
rootObj->Add(h);
|
||||
zfp = Delta_Z(zt, at, zp, ap, ze, ae, ep, angle, b);
|
||||
event_address = new CoincEvent();
|
||||
rootObj = new THashTable();
|
||||
GetWeights();
|
||||
}
|
||||
}
|
||||
|
||||
/*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);
|
||||
else
|
||||
|
||||
SFPAnalyzer::~SFPAnalyzer()
|
||||
{
|
||||
TH1F *h = new TH1F(name.c_str(), name.c_str(), binsx, minx, maxx);
|
||||
h->Fill(valuex);
|
||||
rootObj->Add(h);
|
||||
rootObj->Clear();
|
||||
delete rootObj;
|
||||
delete event_address;
|
||||
}
|
||||
}
|
||||
|
||||
void SFPAnalyzer::AnalyzeEvent(CoincEvent& event)
|
||||
{
|
||||
Reset();
|
||||
if(!event.focalPlane.anodeF.empty())
|
||||
|
||||
void SFPAnalyzer::Reset()
|
||||
{
|
||||
pevent.anodeFront = event.focalPlane.anodeF[0].Long;
|
||||
pevent.anodeFrontTime = event.focalPlane.anodeF[0].Time;
|
||||
pevent = blank; //set output back to blank
|
||||
}
|
||||
if(!event.focalPlane.anodeB.empty())
|
||||
|
||||
/*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()
|
||||
{
|
||||
pevent.anodeBack = event.focalPlane.anodeB[0].Long;
|
||||
pevent.anodeBackTime = event.focalPlane.anodeB[0].Time;
|
||||
w1 = (Wire_Dist()/2.0-zfp)/Wire_Dist();
|
||||
w2 = 1.0-w1;
|
||||
std::cout<<"w1: "<<w1<<" w2: "<<w2<<std::endl;
|
||||
}
|
||||
if(!event.focalPlane.scintL.empty())
|
||||
|
||||
/*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)
|
||||
{
|
||||
pevent.scintLeft = event.focalPlane.scintL[0].Long;
|
||||
pevent.scintLeftShort = event.focalPlane.scintL[0].Short;
|
||||
pevent.scintLeftTime = event.focalPlane.scintL[0].Time;
|
||||
}
|
||||
if(!event.focalPlane.scintR.empty())
|
||||
{
|
||||
pevent.scintRight = event.focalPlane.scintR[0].Long;
|
||||
pevent.scintRightShort = event.focalPlane.scintR[0].Short;
|
||||
pevent.scintRightTime = event.focalPlane.scintR[0].Time;
|
||||
}
|
||||
if(!event.focalPlane.cathode.empty())
|
||||
{
|
||||
pevent.cathode = event.focalPlane.cathode[0].Long;
|
||||
pevent.cathodeTime = event.focalPlane.cathode[0].Time;
|
||||
}
|
||||
if(!event.focalPlane.monitor.empty())
|
||||
{
|
||||
pevent.monitorE = event.focalPlane.monitor[0].Long;
|
||||
pevent.monitorShort = event.focalPlane.monitor[0].Short;
|
||||
pevent.monitorTime = event.focalPlane.monitor[0].Time;
|
||||
}
|
||||
|
||||
/*Delay lines and all that*/
|
||||
if(!event.focalPlane.delayFR.empty())
|
||||
{
|
||||
pevent.delayFrontRightE = event.focalPlane.delayFR[0].Long;
|
||||
pevent.delayFrontRightTime = event.focalPlane.delayFR[0].Time;
|
||||
pevent.delayFrontRightShort = event.focalPlane.delayFR[0].Short;
|
||||
}
|
||||
if(!event.focalPlane.delayFL.empty())
|
||||
{
|
||||
pevent.delayFrontLeftE = event.focalPlane.delayFL[0].Long;
|
||||
pevent.delayFrontLeftTime = event.focalPlane.delayFL[0].Time;
|
||||
pevent.delayFrontLeftShort = event.focalPlane.delayFL[0].Short;
|
||||
}
|
||||
if(!event.focalPlane.delayBR.empty())
|
||||
{
|
||||
pevent.delayBackRightE = event.focalPlane.delayBR[0].Long;
|
||||
pevent.delayBackRightTime = event.focalPlane.delayBR[0].Time;
|
||||
pevent.delayBackRightShort = event.focalPlane.delayBR[0].Short;
|
||||
}
|
||||
if(!event.focalPlane.delayBL.empty())
|
||||
{
|
||||
pevent.delayBackLeftE = event.focalPlane.delayBL[0].Long;
|
||||
pevent.delayBackLeftTime = event.focalPlane.delayBL[0].Time;
|
||||
pevent.delayBackLeftShort = event.focalPlane.delayBL[0].Short;
|
||||
}
|
||||
if(!event.focalPlane.delayFL.empty() && !event.focalPlane.delayFR.empty())
|
||||
{
|
||||
pevent.fp1_tdiff = (event.focalPlane.delayFL[0].Time-event.focalPlane.delayFR[0].Time)*0.5;
|
||||
pevent.fp1_tsum = (event.focalPlane.delayFL[0].Time+event.focalPlane.delayFR[0].Time);
|
||||
pevent.fp1_tcheck = (pevent.fp1_tsum)/2.0-pevent.anodeFrontTime;
|
||||
pevent.delayFrontMaxTime = std::max(event.focalPlane.delayFL[0].Time, event.focalPlane.delayFR[0].Time);
|
||||
pevent.x1 = pevent.fp1_tdiff*1.0/2.10; //position from time, based on total delay
|
||||
MyFill("x1",1200,-300,300,pevent.x1);
|
||||
MyFill("x1 vs anodeBack",600,-300,300,pevent.x1,512,0,4096,pevent.anodeBack);
|
||||
}
|
||||
if(!event.focalPlane.delayBL.empty() && !event.focalPlane.delayBR.empty())
|
||||
{
|
||||
pevent.fp2_tdiff = (event.focalPlane.delayBL[0].Time-event.focalPlane.delayBR[0].Time)*0.5;
|
||||
pevent.fp2_tsum = (event.focalPlane.delayBL[0].Time+event.focalPlane.delayBR[0].Time);
|
||||
pevent.fp2_tcheck = (pevent.fp2_tsum)/2.0-pevent.anodeBackTime;
|
||||
pevent.delayBackMaxTime = std::max(event.focalPlane.delayBL[0].Time, event.focalPlane.delayBR[0].Time);
|
||||
pevent.x2 = pevent.fp2_tdiff*1.0/1.98; //position from time, based on total delay
|
||||
MyFill("x2",1200,-300,300,pevent.x2);
|
||||
MyFill("x2 vs anodeBack",600,-300,300,pevent.x2,512,0,4096,pevent.anodeBack);
|
||||
}
|
||||
/*SABRE data*/
|
||||
for(int j=0; j<5; j++)
|
||||
{
|
||||
if(!event.sabreArray[j].rings.empty())
|
||||
{
|
||||
pevent.sabreRingE[j] = event.sabreArray[j].rings[0].Long;
|
||||
pevent.sabreRingChannel[j] = event.sabreArray[j].rings[0].Ch;
|
||||
pevent.sabreRingTime[j] = event.sabreArray[j].rings[0].Time;
|
||||
}
|
||||
if(!event.sabreArray[j].wedges.empty())
|
||||
{
|
||||
pevent.sabreWedgeE[j] = event.sabreArray[j].wedges[0].Long;
|
||||
pevent.sabreWedgeChannel[j] = event.sabreArray[j].wedges[0].Ch;
|
||||
pevent.sabreWedgeTime[j] = event.sabreArray[j].wedges[0].Time;
|
||||
}
|
||||
/*Aaaand passes on all of the rest. 4/24/20 GWM*/
|
||||
pevent.sabreArray[j] = event.sabreArray[j];
|
||||
}
|
||||
|
||||
/*Make some histograms and xavg*/
|
||||
MyFill("anodeBack vs scintLeft",512,0,4096,pevent.scintLeft,512,0,4096,pevent.anodeBack);
|
||||
if(pevent.x1 != -1e6 && pevent.x2 != -1e6)
|
||||
{
|
||||
pevent.xavg = pevent.x1*w1+pevent.x2*w2;
|
||||
MyFill("xavg",1200,-300,300,pevent.xavg);
|
||||
if((pevent.x2-pevent.x1) > 0)
|
||||
pevent.theta = std::atan((pevent.x2-pevent.x1)/36.0);
|
||||
else if((pevent.x2-pevent.x1) < 0)
|
||||
pevent.theta = TMath::Pi() + std::atan((pevent.x2-pevent.x1)/36.0);
|
||||
TH2F *histo = (TH2F*) rootObj->FindObject(name.c_str());
|
||||
if(histo != nullptr)
|
||||
histo->Fill(valuex, valuey);
|
||||
else
|
||||
pevent.theta = TMath::Pi()/2.0;
|
||||
MyFill("xavg vs theta",600,-300,300,pevent.xavg,314,0,3.14,pevent.theta);
|
||||
MyFill("x1 vs x2",600,-300,300,pevent.x1,600,-300,300,pevent.x2);
|
||||
{
|
||||
TH2F *h = new TH2F(name.c_str(), name.c_str(), binsx, minx, maxx, binsy, miny, maxy);
|
||||
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)
|
||||
{
|
||||
TH1F *histo = (TH1F*) rootObj->FindObject(name.c_str());
|
||||
if(histo != nullptr)
|
||||
histo->Fill(valuex);
|
||||
else
|
||||
{
|
||||
TH1F *h = new TH1F(name.c_str(), name.c_str(), binsx, minx, maxx);
|
||||
h->Fill(valuex);
|
||||
rootObj->Add(h);
|
||||
}
|
||||
}
|
||||
|
||||
void SFPAnalyzer::AnalyzeEvent(CoincEvent& event)
|
||||
{
|
||||
Reset();
|
||||
if(!event.focalPlane.anodeF.empty())
|
||||
{
|
||||
pevent.anodeFront = event.focalPlane.anodeF[0].Long;
|
||||
pevent.anodeFrontTime = event.focalPlane.anodeF[0].Time;
|
||||
}
|
||||
if(!event.focalPlane.anodeB.empty())
|
||||
{
|
||||
pevent.anodeBack = event.focalPlane.anodeB[0].Long;
|
||||
pevent.anodeBackTime = event.focalPlane.anodeB[0].Time;
|
||||
}
|
||||
if(!event.focalPlane.scintL.empty())
|
||||
{
|
||||
pevent.scintLeft = event.focalPlane.scintL[0].Long;
|
||||
pevent.scintLeftShort = event.focalPlane.scintL[0].Short;
|
||||
pevent.scintLeftTime = event.focalPlane.scintL[0].Time;
|
||||
}
|
||||
if(!event.focalPlane.scintR.empty())
|
||||
{
|
||||
pevent.scintRight = event.focalPlane.scintR[0].Long;
|
||||
pevent.scintRightShort = event.focalPlane.scintR[0].Short;
|
||||
pevent.scintRightTime = event.focalPlane.scintR[0].Time;
|
||||
}
|
||||
if(!event.focalPlane.cathode.empty())
|
||||
{
|
||||
pevent.cathode = event.focalPlane.cathode[0].Long;
|
||||
pevent.cathodeTime = event.focalPlane.cathode[0].Time;
|
||||
}
|
||||
if(!event.focalPlane.monitor.empty())
|
||||
{
|
||||
pevent.monitorE = event.focalPlane.monitor[0].Long;
|
||||
pevent.monitorShort = event.focalPlane.monitor[0].Short;
|
||||
pevent.monitorTime = event.focalPlane.monitor[0].Time;
|
||||
}
|
||||
|
||||
/*Delay lines and all that*/
|
||||
if(!event.focalPlane.delayFR.empty())
|
||||
{
|
||||
pevent.delayFrontRightE = event.focalPlane.delayFR[0].Long;
|
||||
pevent.delayFrontRightTime = event.focalPlane.delayFR[0].Time;
|
||||
pevent.delayFrontRightShort = event.focalPlane.delayFR[0].Short;
|
||||
}
|
||||
if(!event.focalPlane.delayFL.empty())
|
||||
{
|
||||
pevent.delayFrontLeftE = event.focalPlane.delayFL[0].Long;
|
||||
pevent.delayFrontLeftTime = event.focalPlane.delayFL[0].Time;
|
||||
pevent.delayFrontLeftShort = event.focalPlane.delayFL[0].Short;
|
||||
}
|
||||
if(!event.focalPlane.delayBR.empty())
|
||||
{
|
||||
pevent.delayBackRightE = event.focalPlane.delayBR[0].Long;
|
||||
pevent.delayBackRightTime = event.focalPlane.delayBR[0].Time;
|
||||
pevent.delayBackRightShort = event.focalPlane.delayBR[0].Short;
|
||||
}
|
||||
if(!event.focalPlane.delayBL.empty())
|
||||
{
|
||||
pevent.delayBackLeftE = event.focalPlane.delayBL[0].Long;
|
||||
pevent.delayBackLeftTime = event.focalPlane.delayBL[0].Time;
|
||||
pevent.delayBackLeftShort = event.focalPlane.delayBL[0].Short;
|
||||
}
|
||||
if(!event.focalPlane.delayFL.empty() && !event.focalPlane.delayFR.empty())
|
||||
{
|
||||
pevent.fp1_tdiff = (event.focalPlane.delayFL[0].Time-event.focalPlane.delayFR[0].Time)*0.5;
|
||||
pevent.fp1_tsum = (event.focalPlane.delayFL[0].Time+event.focalPlane.delayFR[0].Time);
|
||||
pevent.fp1_tcheck = (pevent.fp1_tsum)/2.0-pevent.anodeFrontTime;
|
||||
pevent.delayFrontMaxTime = std::max(event.focalPlane.delayFL[0].Time, event.focalPlane.delayFR[0].Time);
|
||||
pevent.x1 = pevent.fp1_tdiff*1.0/2.10; //position from time, based on total delay
|
||||
MyFill("x1",1200,-300,300,pevent.x1);
|
||||
MyFill("x1 vs anodeBack",600,-300,300,pevent.x1,512,0,4096,pevent.anodeBack);
|
||||
}
|
||||
if(!event.focalPlane.delayBL.empty() && !event.focalPlane.delayBR.empty())
|
||||
{
|
||||
pevent.fp2_tdiff = (event.focalPlane.delayBL[0].Time-event.focalPlane.delayBR[0].Time)*0.5;
|
||||
pevent.fp2_tsum = (event.focalPlane.delayBL[0].Time+event.focalPlane.delayBR[0].Time);
|
||||
pevent.fp2_tcheck = (pevent.fp2_tsum)/2.0-pevent.anodeBackTime;
|
||||
pevent.delayBackMaxTime = std::max(event.focalPlane.delayBL[0].Time, event.focalPlane.delayBR[0].Time);
|
||||
pevent.x2 = pevent.fp2_tdiff*1.0/1.98; //position from time, based on total delay
|
||||
MyFill("x2",1200,-300,300,pevent.x2);
|
||||
MyFill("x2 vs anodeBack",600,-300,300,pevent.x2,512,0,4096,pevent.anodeBack);
|
||||
}
|
||||
/*SABRE data*/
|
||||
for(int j=0; j<5; j++)
|
||||
{
|
||||
if(!event.sabreArray[j].rings.empty())
|
||||
{
|
||||
pevent.sabreRingE[j] = event.sabreArray[j].rings[0].Long;
|
||||
pevent.sabreRingChannel[j] = event.sabreArray[j].rings[0].Ch;
|
||||
pevent.sabreRingTime[j] = event.sabreArray[j].rings[0].Time;
|
||||
}
|
||||
if(!event.sabreArray[j].wedges.empty())
|
||||
{
|
||||
pevent.sabreWedgeE[j] = event.sabreArray[j].wedges[0].Long;
|
||||
pevent.sabreWedgeChannel[j] = event.sabreArray[j].wedges[0].Ch;
|
||||
pevent.sabreWedgeTime[j] = event.sabreArray[j].wedges[0].Time;
|
||||
}
|
||||
/*Aaaand passes on all of the rest. 4/24/20 GWM*/
|
||||
pevent.sabreArray[j] = event.sabreArray[j];
|
||||
}
|
||||
|
||||
/*Make some histograms and xavg*/
|
||||
MyFill("anodeBack vs scintLeft",512,0,4096,pevent.scintLeft,512,0,4096,pevent.anodeBack);
|
||||
if(pevent.x1 != -1e6 && pevent.x2 != -1e6)
|
||||
{
|
||||
pevent.xavg = pevent.x1*w1+pevent.x2*w2;
|
||||
MyFill("xavg",1200,-300,300,pevent.xavg);
|
||||
if((pevent.x2-pevent.x1) > 0)
|
||||
pevent.theta = std::atan((pevent.x2-pevent.x1)/36.0);
|
||||
else if((pevent.x2-pevent.x1) < 0)
|
||||
pevent.theta = TMath::Pi() + std::atan((pevent.x2-pevent.x1)/36.0);
|
||||
else
|
||||
pevent.theta = TMath::Pi()/2.0;
|
||||
MyFill("xavg vs theta",600,-300,300,pevent.xavg,314,0,3.14,pevent.theta);
|
||||
MyFill("x1 vs x2",600,-300,300,pevent.x1,600,-300,300,pevent.x2);
|
||||
}
|
||||
if(pevent.anodeFrontTime != -1 && pevent.scintRightTime != -1)
|
||||
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)
|
||||
{
|
||||
AnalyzeEvent(event);
|
||||
return pevent;
|
||||
}
|
||||
if(pevent.anodeFrontTime != -1 && pevent.scintRightTime != -1)
|
||||
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)
|
||||
{
|
||||
AnalyzeEvent(event);
|
||||
return pevent;
|
||||
}
|
||||
}
|
|
@ -13,33 +13,36 @@
|
|||
#include "DataStructs.h"
|
||||
#include "FP_kinematics.h"
|
||||
|
||||
namespace EventBuilder {
|
||||
|
||||
class SFPAnalyzer
|
||||
{
|
||||
public:
|
||||
SFPAnalyzer(int zt, int at, int zp, int ap, int ze, int ae, double ep, double angle,
|
||||
double b);
|
||||
~SFPAnalyzer();
|
||||
ProcessedEvent GetProcessedEvent(CoincEvent& event);
|
||||
inline void ClearHashTable() { rootObj->Clear(); }
|
||||
inline THashTable* GetHashTable() { return rootObj; }
|
||||
class SFPAnalyzer
|
||||
{
|
||||
public:
|
||||
SFPAnalyzer(int zt, int at, int zp, int ap, int ze, int ae, double ep, double angle,
|
||||
double b);
|
||||
~SFPAnalyzer();
|
||||
ProcessedEvent GetProcessedEvent(CoincEvent& event);
|
||||
inline void ClearHashTable() { rootObj->Clear(); }
|
||||
inline THashTable* GetHashTable() { return rootObj; }
|
||||
|
||||
private:
|
||||
void Reset(); //Sets ouput structure back to "zero"
|
||||
void GetWeights(); //weights for xavg
|
||||
void AnalyzeEvent(CoincEvent& event);
|
||||
|
||||
/*Fill wrappers for use with THashTable*/
|
||||
void MyFill(const std::string& name, int binsx, double minx, double maxx, double valuex,
|
||||
int binsy, double miny, double maxy, double valuey);
|
||||
void MyFill(const std::string& name, int binsx, double minx, double maxx, double valuex);
|
||||
|
||||
CoincEvent *event_address; //Input branch address
|
||||
ProcessedEvent pevent, blank; //output branch and reset
|
||||
|
||||
double w1, w2, zfp;
|
||||
|
||||
THashTable *rootObj; //root storage
|
||||
};
|
||||
|
||||
private:
|
||||
void Reset(); //Sets ouput structure back to "zero"
|
||||
void GetWeights(); //weights for xavg
|
||||
void AnalyzeEvent(CoincEvent& event);
|
||||
|
||||
/*Fill wrappers for use with THashTable*/
|
||||
void MyFill(const std::string& name, int binsx, double minx, double maxx, double valuex,
|
||||
int binsy, double miny, double maxy, double valuey);
|
||||
void MyFill(const std::string& name, int binsx, double minx, double maxx, double valuex);
|
||||
|
||||
CoincEvent *event_address; //Input branch address
|
||||
ProcessedEvent pevent, blank; //output branch and reset
|
||||
|
||||
double w1, w2, zfp;
|
||||
|
||||
THashTable *rootObj; //root storage
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -10,287 +10,291 @@
|
|||
#include "SFPPlotter.h"
|
||||
#include <TSystem.h>
|
||||
|
||||
/*Generates storage and initializes pointers*/
|
||||
SFPPlotter::SFPPlotter()
|
||||
{
|
||||
event_address = new ProcessedEvent();
|
||||
m_pb = nullptr;
|
||||
}
|
||||
namespace EventBuilder {
|
||||
|
||||
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,
|
||||
int binsy, double miny, double maxy, double valuey)
|
||||
{
|
||||
TH2F *histo = (TH2F*) table->FindObject(name.c_str());
|
||||
if(histo != nullptr)
|
||||
histo->Fill(valuex, valuey);
|
||||
else
|
||||
/*Generates storage and initializes pointers*/
|
||||
SFPPlotter::SFPPlotter()
|
||||
{
|
||||
TH2F *h = new TH2F(name.c_str(), name.c_str(), binsx, minx, maxx, binsy, miny, maxy);
|
||||
h->Fill(valuex, valuey);
|
||||
table->Add(h);
|
||||
event_address = new ProcessedEvent();
|
||||
m_pb = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
/*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);
|
||||
else
|
||||
{
|
||||
TH1F *h = new TH1F(name.c_str(), name.c_str(), binsx, minx, maxx);
|
||||
h->Fill(valuex);
|
||||
table->Add(h);
|
||||
}
|
||||
}
|
||||
|
||||
/*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);
|
||||
MyFill(table,"xavgNoCuts_theta_bothplanes",600,-300,300,ev.xavg,100,0,TMath::Pi()/2.,ev.theta);
|
||||
|
||||
MyFill(table,"x1_delayBackRightE_NoCuts",600,-300,300,ev.x1,512,0,4096,ev.delayBackRightE);
|
||||
MyFill(table,"x2_delayBackRightE_NoCuts",600,-300,300,ev.x2,512,0,4096,ev.delayBackRightE);
|
||||
MyFill(table,"xavg_delayBackRightE_NoCuts",600,-300,300,ev.xavg,512,0,4096,ev.delayBackRightE);
|
||||
MyFill(table,"x1_x2_NoCuts",600,-300,300,ev.x1,600,-300,300,ev.x2);
|
||||
|
||||
Double_t delayBackAvgE = (ev.delayBackRightE+ev.delayBackLeftE)/2.0;
|
||||
MyFill(table,"x1_delayBackAvgE_NoCuts",600,-300,300,ev.x1,512,0,4096,delayBackAvgE);
|
||||
MyFill(table,"x2_delayBackAvgE_NoCuts",600,-300,300,ev.x2,512,0,4096,delayBackAvgE);
|
||||
MyFill(table,"xavg_delayBackAvgE_NoCuts",600,-300,300,ev.xavg,512,0,4096,delayBackAvgE);
|
||||
Double_t delayFrontAvgE = (ev.delayFrontRightE+ev.delayFrontLeftE)/2.0;
|
||||
MyFill(table,"x1_delayFrontAvgE_NoCuts",600,-300,300,ev.x1,512,0,4096,delayFrontAvgE);
|
||||
MyFill(table,"x2_delayFrontAvgE_NoCuts",600,-300,300,ev.x2,512,0,4096,delayFrontAvgE);
|
||||
MyFill(table,"xavg_delayFrontAvgE_NoCuts",600,-300,300,ev.xavg,512,0,4096,delayFrontAvgE);
|
||||
|
||||
MyFill(table,"scintLeft_anodeBack_NoCuts",512,0,4096,ev.scintLeft,512,0,4096,ev.anodeBack);
|
||||
MyFill(table,"scintLeft_anodeFront_NoCuts",512,0,4096,ev.scintLeft,512,0,4096,ev.anodeFront);
|
||||
MyFill(table,"scintLeft_cathode_NoCuts",512,0,4096,ev.scintLeft,512,0,4096,ev.cathode);
|
||||
|
||||
MyFill(table,"x1_scintLeft_NoCuts",600,-300,300,ev.x1,512,0,4096,ev.scintLeft);
|
||||
MyFill(table,"x2_scintLeft_NoCuts",600,-300,300,ev.x2,512,0,4096,ev.scintLeft);
|
||||
MyFill(table,"xavg_scintLeft_NoCuts",600,-300,300,ev.xavg,512,0,4096,ev.scintLeft);
|
||||
|
||||
MyFill(table,"x1_anodeBack_NoCuts",600,-300,300,ev.x1,512,0,4096,ev.anodeBack);
|
||||
MyFill(table,"x2_anodeBack_NoCuts",600,-300,300,ev.x2,512,0,4096,ev.anodeBack);
|
||||
MyFill(table,"xavg_anodeBack_NoCuts",600,-300,300,ev.xavg,512,0,4096,ev.anodeBack);
|
||||
|
||||
MyFill(table,"x1_anodeFront_NoCuts",600,-300,300,ev.x1,512,0,4096,ev.anodeFront);
|
||||
MyFill(table,"x2_anodeFront_NoCuts",600,-300,300,ev.x2,512,0,4096,ev.anodeFront);
|
||||
MyFill(table,"xavg_anodeFront_NoCuts",600,-300,300,ev.xavg,512,0,4096,ev.anodeFront);
|
||||
|
||||
MyFill(table,"x1_cathode_NoCuts",600,-300,300,ev.x1,512,0,4096,ev.cathode);
|
||||
MyFill(table,"x2_cathode_NoCuts",600,-300,300,ev.x2,512,0,4096,ev.cathode);
|
||||
MyFill(table,"xavg_cathode_NoCuts",600,-300,300,ev.xavg,512,0,4096,ev.cathode);
|
||||
|
||||
/****Timing relative to back anode****/
|
||||
if(ev.anodeBackTime != -1 && ev.scintLeftTime != -1)
|
||||
SFPPlotter::~SFPPlotter()
|
||||
{
|
||||
Double_t anodeRelFT = ev.anodeFrontTime - ev.anodeBackTime;
|
||||
Double_t delayRelFT = ev.delayFrontMaxTime - ev.anodeBackTime;
|
||||
Double_t delayRelBT = ev.delayBackMaxTime - ev.anodeBackTime;
|
||||
Double_t anodeRelBT = ev.anodeBackTime - ev.scintLeftTime;
|
||||
Double_t delayRelFT_toScint = ev.delayFrontMaxTime - ev.scintLeftTime;
|
||||
Double_t delayRelBT_toScint = ev.delayBackMaxTime - ev.scintLeftTime;
|
||||
MyFill(table,"anodeRelFrontTime_NoCuts",1000,-3000,3500, anodeRelFT);
|
||||
MyFill(table,"delayRelFrontTime_NoCuts",1000,-3000,-3500,delayRelFT);
|
||||
MyFill(table,"delayRelBackTime_NoCuts",1000,-3000,-3500,delayRelBT);
|
||||
delete event_address;
|
||||
}
|
||||
|
||||
/*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);
|
||||
else
|
||||
{
|
||||
TH2F *h = new TH2F(name.c_str(), name.c_str(), binsx, minx, maxx, binsy, miny, maxy);
|
||||
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)
|
||||
{
|
||||
TH1F *histo = (TH1F*) table->FindObject(name.c_str());
|
||||
if(histo != nullptr)
|
||||
histo->Fill(valuex);
|
||||
else
|
||||
{
|
||||
TH1F *h = new TH1F(name.c_str(), name.c_str(), binsx, minx, maxx);
|
||||
h->Fill(valuex);
|
||||
table->Add(h);
|
||||
}
|
||||
}
|
||||
|
||||
/*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);
|
||||
MyFill(table,"xavgNoCuts_theta_bothplanes",600,-300,300,ev.xavg,100,0,TMath::Pi()/2.,ev.theta);
|
||||
|
||||
MyFill(table,"x1_delayBackRightE_NoCuts",600,-300,300,ev.x1,512,0,4096,ev.delayBackRightE);
|
||||
MyFill(table,"x2_delayBackRightE_NoCuts",600,-300,300,ev.x2,512,0,4096,ev.delayBackRightE);
|
||||
MyFill(table,"xavg_delayBackRightE_NoCuts",600,-300,300,ev.xavg,512,0,4096,ev.delayBackRightE);
|
||||
MyFill(table,"x1_x2_NoCuts",600,-300,300,ev.x1,600,-300,300,ev.x2);
|
||||
|
||||
Double_t delayBackAvgE = (ev.delayBackRightE+ev.delayBackLeftE)/2.0;
|
||||
MyFill(table,"x1_delayBackAvgE_NoCuts",600,-300,300,ev.x1,512,0,4096,delayBackAvgE);
|
||||
MyFill(table,"x2_delayBackAvgE_NoCuts",600,-300,300,ev.x2,512,0,4096,delayBackAvgE);
|
||||
MyFill(table,"xavg_delayBackAvgE_NoCuts",600,-300,300,ev.xavg,512,0,4096,delayBackAvgE);
|
||||
Double_t delayFrontAvgE = (ev.delayFrontRightE+ev.delayFrontLeftE)/2.0;
|
||||
MyFill(table,"x1_delayFrontAvgE_NoCuts",600,-300,300,ev.x1,512,0,4096,delayFrontAvgE);
|
||||
MyFill(table,"x2_delayFrontAvgE_NoCuts",600,-300,300,ev.x2,512,0,4096,delayFrontAvgE);
|
||||
MyFill(table,"xavg_delayFrontAvgE_NoCuts",600,-300,300,ev.xavg,512,0,4096,delayFrontAvgE);
|
||||
|
||||
MyFill(table,"scintLeft_anodeBack_NoCuts",512,0,4096,ev.scintLeft,512,0,4096,ev.anodeBack);
|
||||
MyFill(table,"scintLeft_anodeFront_NoCuts",512,0,4096,ev.scintLeft,512,0,4096,ev.anodeFront);
|
||||
MyFill(table,"scintLeft_cathode_NoCuts",512,0,4096,ev.scintLeft,512,0,4096,ev.cathode);
|
||||
|
||||
MyFill(table,"x1_scintLeft_NoCuts",600,-300,300,ev.x1,512,0,4096,ev.scintLeft);
|
||||
MyFill(table,"x2_scintLeft_NoCuts",600,-300,300,ev.x2,512,0,4096,ev.scintLeft);
|
||||
MyFill(table,"xavg_scintLeft_NoCuts",600,-300,300,ev.xavg,512,0,4096,ev.scintLeft);
|
||||
|
||||
MyFill(table,"x1_anodeBack_NoCuts",600,-300,300,ev.x1,512,0,4096,ev.anodeBack);
|
||||
MyFill(table,"x2_anodeBack_NoCuts",600,-300,300,ev.x2,512,0,4096,ev.anodeBack);
|
||||
MyFill(table,"xavg_anodeBack_NoCuts",600,-300,300,ev.xavg,512,0,4096,ev.anodeBack);
|
||||
|
||||
MyFill(table,"x1_anodeFront_NoCuts",600,-300,300,ev.x1,512,0,4096,ev.anodeFront);
|
||||
MyFill(table,"x2_anodeFront_NoCuts",600,-300,300,ev.x2,512,0,4096,ev.anodeFront);
|
||||
MyFill(table,"xavg_anodeFront_NoCuts",600,-300,300,ev.xavg,512,0,4096,ev.anodeFront);
|
||||
|
||||
MyFill(table,"x1_cathode_NoCuts",600,-300,300,ev.x1,512,0,4096,ev.cathode);
|
||||
MyFill(table,"x2_cathode_NoCuts",600,-300,300,ev.x2,512,0,4096,ev.cathode);
|
||||
MyFill(table,"xavg_cathode_NoCuts",600,-300,300,ev.xavg,512,0,4096,ev.cathode);
|
||||
|
||||
/****Timing relative to back anode****/
|
||||
if(ev.anodeBackTime != -1 && ev.scintLeftTime != -1)
|
||||
{
|
||||
Double_t anodeRelFT = ev.anodeFrontTime - ev.anodeBackTime;
|
||||
Double_t delayRelFT = ev.delayFrontMaxTime - ev.anodeBackTime;
|
||||
Double_t delayRelBT = ev.delayBackMaxTime - ev.anodeBackTime;
|
||||
Double_t anodeRelBT = ev.anodeBackTime - ev.scintLeftTime;
|
||||
Double_t delayRelFT_toScint = ev.delayFrontMaxTime - ev.scintLeftTime;
|
||||
Double_t delayRelBT_toScint = ev.delayBackMaxTime - ev.scintLeftTime;
|
||||
MyFill(table,"anodeRelFrontTime_NoCuts",1000,-3000,3500, anodeRelFT);
|
||||
MyFill(table,"delayRelFrontTime_NoCuts",1000,-3000,-3500,delayRelFT);
|
||||
MyFill(table,"delayRelBackTime_NoCuts",1000,-3000,-3500,delayRelBT);
|
||||
for(int i=0; i<5; i++)
|
||||
{
|
||||
if(ev.sabreRingE[i] != -1)
|
||||
{
|
||||
Double_t sabreRelRT = ev.sabreRingTime[i] - ev.anodeBackTime;
|
||||
Double_t sabreRelWT = ev.sabreWedgeTime[i] - ev.anodeBackTime;
|
||||
Double_t sabreRelRT_toScint = ev.sabreRingTime[i] - ev.scintLeftTime;
|
||||
Double_t sabreRelWT_toScint = ev.sabreWedgeTime[i] - ev.scintLeftTime;
|
||||
MyFill(table,"xavg_sabrefcoinc_NoCuts",600,-300,300, ev.xavg);
|
||||
MyFill(table,"sabreRelRingTime_NoCuts",1000,-3000,3500, sabreRelRT);
|
||||
MyFill(table,"sabreRelWedgeTime_NoCuts",1000,-3000,3500, sabreRelWT);
|
||||
MyFill(table,"sabreRelRingTime_toScint",1000,-3000,3500,sabreRelRT_toScint);
|
||||
MyFill(table,"sabreRelWedgeTime_toScint",1000,-3000,3500,sabreRelWT_toScint);
|
||||
MyFill(table,"sabreRelRTScint_sabreRelRTAnode",500,-3000,3500,sabreRelRT_toScint,500,-3000,3500,sabreRelRT);
|
||||
MyFill(table,"sabreRelRTScint_sabreRingChannel",500,-3000,3500,sabreRelRT_toScint,144,0,144,ev.sabreRingChannel[i]);
|
||||
MyFill(table,"sabreRelRTAnode_sabreRingChannel",500,-3000,3500,sabreRelRT,144,0,144,ev.sabreRingChannel[i]);
|
||||
MyFill(table,"sabreRelWTScint_sabreWedgeChannel",500,-3000,3500,sabreRelWT_toScint,144,0,144,ev.sabreWedgeChannel[i]);
|
||||
MyFill(table,"sabreRelRT_sabreRelWT",500,-3000,3500,sabreRelRT,500,-3000,3500,sabreRelWT);
|
||||
MyFill(table,"sabreRelRT_sabreRelWT_scint",500,-3000,3500,sabreRelRT_toScint,500,-3000,3500,sabreRelWT_toScint);
|
||||
MyFill(table,"sabreRelRTScint_anodeRelT",500,-3000,3500,sabreRelRT_toScint,500,-3000,3500,anodeRelBT);
|
||||
}
|
||||
}
|
||||
MyFill(table,"anodeBackRelTime_toScint",1000,-3000,3500,anodeRelBT);
|
||||
MyFill(table,"delayRelBackTime_toScint",1000,-3000,3500,delayRelBT_toScint);
|
||||
MyFill(table,"delayRelFrontTime_toScint",1000,-3000,3500,delayRelFT_toScint);
|
||||
}
|
||||
else
|
||||
MyFill(table,"noscinttime_counter_NoCuts",2,0,1,1);
|
||||
|
||||
for(int i=0; i<5; i++)
|
||||
{
|
||||
if(ev.sabreRingE[i] != -1) //Again, at this point front&back are required
|
||||
{
|
||||
MyFill(table,"sabreRingE_NoCuts",2000,0,20,ev.sabreRingE[i]);
|
||||
MyFill(table,"sabreRingChannel_sabreRingE_NoCuts",144,0,144,ev.sabreRingChannel[i],200,0,20,ev.sabreRingE[i]);
|
||||
MyFill(table,"sabreWedgeE_NoCuts",2000,0,20,ev.sabreWedgeE[i]);
|
||||
MyFill(table,"sabreWedgeChannel_sabreWedgeE_NoCuts",144,0,144,ev.sabreWedgeChannel[i],200,0,20,ev.sabreWedgeE[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if(ev.x1 != -1e6 && ev.x2 == -1e6)
|
||||
MyFill(table,"x1NoCuts_only1plane",600,-300,300,ev.x1);
|
||||
else if(ev.x2 != -1e6 && ev.x1 == -1e6)
|
||||
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)
|
||||
{
|
||||
if(!cutter.IsInside(&ev))
|
||||
return;
|
||||
|
||||
MyFill(table,"x1_bothplanes_Cut",600,-300,300,ev.x1);
|
||||
MyFill(table,"x2_bothplanes_Cut",600,-300,300,ev.x2);
|
||||
MyFill(table,"xavg_bothplanes_Cut",600,-300,300,ev.xavg);
|
||||
MyFill(table,"x1_x2_Cut",600,-300,300,ev.x1, 600,-300,300,ev.x2);
|
||||
MyFill(table,"xavg_theta_Cut_bothplanes",600,-300,300,ev.xavg,100,0,TMath::Pi()/2.,ev.theta);
|
||||
|
||||
MyFill(table,"x1_delayBackRightE_Cut",600,-300,300,ev.x1,512,0,4096,ev.delayBackRightE);
|
||||
MyFill(table,"x2_delayBackRightE_Cut",600,-300,300,ev.x2,512,0,4096,ev.delayBackRightE);
|
||||
MyFill(table,"xavg_delayBackRightE_Cut",600,-300,300,ev.xavg,512,0,4096,ev.delayBackRightE);
|
||||
|
||||
Double_t delayBackAvgE = (ev.delayBackRightE+ev.delayBackLeftE)/2.0;
|
||||
MyFill(table,"x1_delayBackAvgE_Cut",600,-300,300,ev.x1,512,0,4096,delayBackAvgE);
|
||||
MyFill(table,"x2_delayBackAvgE_Cut",600,-300,300,ev.x2,512,0,4096,delayBackAvgE);
|
||||
MyFill(table,"xavg_delayBackAvgE_Cut",600,-300,300,ev.xavg,512,0,4096,delayBackAvgE);
|
||||
Double_t delayFrontAvgE = (ev.delayFrontRightE+ev.delayFrontLeftE)/2.0;
|
||||
MyFill(table,"x1_delayFrontAvgE_Cut",600,-300,300,ev.x1,512,0,4096,delayFrontAvgE);
|
||||
MyFill(table,"x2_delayFrontAvgE_Cut",600,-300,300,ev.x2,512,0,4096,delayFrontAvgE);
|
||||
MyFill(table,"xavg_delayFrontAvgE_Cut",600,-300,300,ev.xavg,512,0,4096,delayFrontAvgE);
|
||||
|
||||
MyFill(table,"scintLeft_anodeBack_Cut",512,0,4096,ev.scintLeft,512,0,4096,ev.anodeBack);
|
||||
MyFill(table,"scintLeft_anodeFront_Cut",512,0,4096,ev.scintLeft,512,0,4096,ev.anodeFront);
|
||||
MyFill(table,"scintLeft_cathode_Cut",512,0,4096,ev.scintLeft,512,0,4096,ev.cathode);
|
||||
|
||||
MyFill(table,"x1_scintLeft_Cut",600,-300,300,ev.x1,512,0,4096,ev.scintLeft);
|
||||
MyFill(table,"x2_scintLeft_Cut",600,-300,300,ev.x2,512,0,4096,ev.scintLeft);
|
||||
MyFill(table,"xavg_scintLeft_Cut",600,-300,300,ev.xavg,512,0,4096,ev.scintLeft);
|
||||
|
||||
MyFill(table,"x1_anodeBack_Cut",600,-300,300,ev.x1,512,0,4096,ev.anodeBack);
|
||||
MyFill(table,"x2_anodeBack_Cut",600,-300,300,ev.x2,512,0,4096,ev.anodeBack);
|
||||
MyFill(table,"xavg_anodeBack_Cut",600,-300,300,ev.xavg,512,0,4096,ev.anodeBack);
|
||||
|
||||
MyFill(table,"x1_anodeFront_Cut",600,-300,300,ev.x1,512,0,4096,ev.anodeFront);
|
||||
MyFill(table,"x2_anodeFront_Cut",600,-300,300,ev.x2,512,0,4096,ev.anodeFront);
|
||||
MyFill(table,"xavg_anodeFront_Cut",600,-300,300,ev.xavg,512,0,4096,ev.anodeFront);
|
||||
|
||||
MyFill(table,"x1_cathode_Cut",600,-300,300,ev.x1,512,0,4096,ev.cathode);
|
||||
MyFill(table,"x2_cathode_Cut",600,-300,300,ev.x2,512,0,4096,ev.cathode);
|
||||
MyFill(table,"xavg_cathode_Cut",600,-300,300,ev.xavg,512,0,4096,ev.cathode);
|
||||
|
||||
/****Timing relative to back anode****/
|
||||
if(ev.anodeBackTime != -1 && ev.scintLeftTime != -1)
|
||||
{
|
||||
Double_t anodeRelFT = ev.anodeFrontTime - ev.anodeBackTime;
|
||||
Double_t anodeRelBT = ev.anodeBackTime - ev.anodeBackTime;
|
||||
Double_t anodeRelFT_toScint = ev.anodeFrontTime-ev.scintLeftTime;
|
||||
MyFill(table,"anodeRelBackTime_Cut",1000,-3000,3500, anodeRelBT);
|
||||
MyFill(table,"anodeRelFrontTime_Cut",1000,-3000,3500, anodeRelFT);
|
||||
MyFill(table,"anodeRelTime_toScint_Cut",1000,-3000,3500,anodeRelFT_toScint);
|
||||
for(int i=0; i<5; i++)
|
||||
{
|
||||
if(ev.sabreRingE[i] != -1)
|
||||
{
|
||||
Double_t sabreRelRT = ev.sabreRingTime[i] - ev.anodeBackTime;
|
||||
Double_t sabreRelWT = ev.sabreWedgeTime[i] - ev.anodeBackTime;
|
||||
MyFill(table,"sabreRelRingTime_Cut",1000,-3000,3500, sabreRelRT);
|
||||
MyFill(table,"sabreRelWedgeTime_Cut",1000,-3000,3500, sabreRelWT);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MyFill(table,"noscinttime_counter_Cut",2,0,1,1);
|
||||
}
|
||||
|
||||
for(int i=0; i<5; i++)
|
||||
{
|
||||
if(ev.sabreRingE[i] != -1)
|
||||
{
|
||||
Double_t sabreRelRT = ev.sabreRingTime[i] - ev.anodeBackTime;
|
||||
Double_t sabreRelWT = ev.sabreWedgeTime[i] - ev.anodeBackTime;
|
||||
Double_t sabreRelRT_toScint = ev.sabreRingTime[i] - ev.scintLeftTime;
|
||||
Double_t sabreRelWT_toScint = ev.sabreWedgeTime[i] - ev.scintLeftTime;
|
||||
MyFill(table,"xavg_sabrefcoinc_NoCuts",600,-300,300, ev.xavg);
|
||||
MyFill(table,"sabreRelRingTime_NoCuts",1000,-3000,3500, sabreRelRT);
|
||||
MyFill(table,"sabreRelWedgeTime_NoCuts",1000,-3000,3500, sabreRelWT);
|
||||
MyFill(table,"sabreRelRingTime_toScint",1000,-3000,3500,sabreRelRT_toScint);
|
||||
MyFill(table,"sabreRelWedgeTime_toScint",1000,-3000,3500,sabreRelWT_toScint);
|
||||
MyFill(table,"sabreRelRTScint_sabreRelRTAnode",500,-3000,3500,sabreRelRT_toScint,500,-3000,3500,sabreRelRT);
|
||||
MyFill(table,"sabreRelRTScint_sabreRingChannel",500,-3000,3500,sabreRelRT_toScint,144,0,144,ev.sabreRingChannel[i]);
|
||||
MyFill(table,"sabreRelRTAnode_sabreRingChannel",500,-3000,3500,sabreRelRT,144,0,144,ev.sabreRingChannel[i]);
|
||||
MyFill(table,"sabreRelWTScint_sabreWedgeChannel",500,-3000,3500,sabreRelWT_toScint,144,0,144,ev.sabreWedgeChannel[i]);
|
||||
MyFill(table,"sabreRelRT_sabreRelWT",500,-3000,3500,sabreRelRT,500,-3000,3500,sabreRelWT);
|
||||
MyFill(table,"sabreRelRT_sabreRelWT_scint",500,-3000,3500,sabreRelRT_toScint,500,-3000,3500,sabreRelWT_toScint);
|
||||
MyFill(table,"sabreRelRTScint_anodeRelT",500,-3000,3500,sabreRelRT_toScint,500,-3000,3500,anodeRelBT);
|
||||
MyFill(table,"sabreRingE_Cut",2000,0,20,ev.sabreRingE[i]);
|
||||
MyFill(table,"xavg_Cut_sabrefcoinc",600,-300,300,ev.xavg);
|
||||
MyFill(table,"xavg_sabreRingE_Cut",600,-300,300,ev.xavg,200,0,20,ev.sabreRingE[i]);
|
||||
MyFill(table,"sabreWedgeE_Cut",2000,0,20,ev.sabreWedgeE[i]);
|
||||
MyFill(table,"xavg_sabreWedgeE_Cut",600,-300,300,ev.xavg,200,0,20,ev.sabreWedgeE[i]);
|
||||
}
|
||||
}
|
||||
MyFill(table,"anodeBackRelTime_toScint",1000,-3000,3500,anodeRelBT);
|
||||
MyFill(table,"delayRelBackTime_toScint",1000,-3000,3500,delayRelBT_toScint);
|
||||
MyFill(table,"delayRelFrontTime_toScint",1000,-3000,3500,delayRelFT_toScint);
|
||||
}
|
||||
else
|
||||
MyFill(table,"noscinttime_counter_NoCuts",2,0,1,1);
|
||||
|
||||
for(int i=0; i<5; i++)
|
||||
{
|
||||
if(ev.sabreRingE[i] != -1) //Again, at this point front&back are required
|
||||
{
|
||||
MyFill(table,"sabreRingE_NoCuts",2000,0,20,ev.sabreRingE[i]);
|
||||
MyFill(table,"sabreRingChannel_sabreRingE_NoCuts",144,0,144,ev.sabreRingChannel[i],200,0,20,ev.sabreRingE[i]);
|
||||
MyFill(table,"sabreWedgeE_NoCuts",2000,0,20,ev.sabreWedgeE[i]);
|
||||
MyFill(table,"sabreWedgeChannel_sabreWedgeE_NoCuts",144,0,144,ev.sabreWedgeChannel[i],200,0,20,ev.sabreWedgeE[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if(ev.x1 != -1e6 && ev.x2 == -1e6)
|
||||
MyFill(table,"x1NoCuts_only1plane",600,-300,300,ev.x1);
|
||||
else if(ev.x2 != -1e6 && ev.x1 == -1e6)
|
||||
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)
|
||||
{
|
||||
if(!cutter.IsInside(&ev))
|
||||
return;
|
||||
|
||||
MyFill(table,"x1_bothplanes_Cut",600,-300,300,ev.x1);
|
||||
MyFill(table,"x2_bothplanes_Cut",600,-300,300,ev.x2);
|
||||
MyFill(table,"xavg_bothplanes_Cut",600,-300,300,ev.xavg);
|
||||
MyFill(table,"x1_x2_Cut",600,-300,300,ev.x1, 600,-300,300,ev.x2);
|
||||
MyFill(table,"xavg_theta_Cut_bothplanes",600,-300,300,ev.xavg,100,0,TMath::Pi()/2.,ev.theta);
|
||||
|
||||
MyFill(table,"x1_delayBackRightE_Cut",600,-300,300,ev.x1,512,0,4096,ev.delayBackRightE);
|
||||
MyFill(table,"x2_delayBackRightE_Cut",600,-300,300,ev.x2,512,0,4096,ev.delayBackRightE);
|
||||
MyFill(table,"xavg_delayBackRightE_Cut",600,-300,300,ev.xavg,512,0,4096,ev.delayBackRightE);
|
||||
|
||||
Double_t delayBackAvgE = (ev.delayBackRightE+ev.delayBackLeftE)/2.0;
|
||||
MyFill(table,"x1_delayBackAvgE_Cut",600,-300,300,ev.x1,512,0,4096,delayBackAvgE);
|
||||
MyFill(table,"x2_delayBackAvgE_Cut",600,-300,300,ev.x2,512,0,4096,delayBackAvgE);
|
||||
MyFill(table,"xavg_delayBackAvgE_Cut",600,-300,300,ev.xavg,512,0,4096,delayBackAvgE);
|
||||
Double_t delayFrontAvgE = (ev.delayFrontRightE+ev.delayFrontLeftE)/2.0;
|
||||
MyFill(table,"x1_delayFrontAvgE_Cut",600,-300,300,ev.x1,512,0,4096,delayFrontAvgE);
|
||||
MyFill(table,"x2_delayFrontAvgE_Cut",600,-300,300,ev.x2,512,0,4096,delayFrontAvgE);
|
||||
MyFill(table,"xavg_delayFrontAvgE_Cut",600,-300,300,ev.xavg,512,0,4096,delayFrontAvgE);
|
||||
|
||||
MyFill(table,"scintLeft_anodeBack_Cut",512,0,4096,ev.scintLeft,512,0,4096,ev.anodeBack);
|
||||
MyFill(table,"scintLeft_anodeFront_Cut",512,0,4096,ev.scintLeft,512,0,4096,ev.anodeFront);
|
||||
MyFill(table,"scintLeft_cathode_Cut",512,0,4096,ev.scintLeft,512,0,4096,ev.cathode);
|
||||
|
||||
MyFill(table,"x1_scintLeft_Cut",600,-300,300,ev.x1,512,0,4096,ev.scintLeft);
|
||||
MyFill(table,"x2_scintLeft_Cut",600,-300,300,ev.x2,512,0,4096,ev.scintLeft);
|
||||
MyFill(table,"xavg_scintLeft_Cut",600,-300,300,ev.xavg,512,0,4096,ev.scintLeft);
|
||||
|
||||
MyFill(table,"x1_anodeBack_Cut",600,-300,300,ev.x1,512,0,4096,ev.anodeBack);
|
||||
MyFill(table,"x2_anodeBack_Cut",600,-300,300,ev.x2,512,0,4096,ev.anodeBack);
|
||||
MyFill(table,"xavg_anodeBack_Cut",600,-300,300,ev.xavg,512,0,4096,ev.anodeBack);
|
||||
|
||||
MyFill(table,"x1_anodeFront_Cut",600,-300,300,ev.x1,512,0,4096,ev.anodeFront);
|
||||
MyFill(table,"x2_anodeFront_Cut",600,-300,300,ev.x2,512,0,4096,ev.anodeFront);
|
||||
MyFill(table,"xavg_anodeFront_Cut",600,-300,300,ev.xavg,512,0,4096,ev.anodeFront);
|
||||
|
||||
MyFill(table,"x1_cathode_Cut",600,-300,300,ev.x1,512,0,4096,ev.cathode);
|
||||
MyFill(table,"x2_cathode_Cut",600,-300,300,ev.x2,512,0,4096,ev.cathode);
|
||||
MyFill(table,"xavg_cathode_Cut",600,-300,300,ev.xavg,512,0,4096,ev.cathode);
|
||||
|
||||
/****Timing relative to back anode****/
|
||||
if(ev.anodeBackTime != -1 && ev.scintLeftTime != -1)
|
||||
/*Runs a list of files given from a RunCollector class*/
|
||||
void SFPPlotter::Run(const std::vector<std::string>& files, const std::string& output)
|
||||
{
|
||||
Double_t anodeRelFT = ev.anodeFrontTime - ev.anodeBackTime;
|
||||
Double_t anodeRelBT = ev.anodeBackTime - ev.anodeBackTime;
|
||||
Double_t anodeRelFT_toScint = ev.anodeFrontTime-ev.scintLeftTime;
|
||||
MyFill(table,"anodeRelBackTime_Cut",1000,-3000,3500, anodeRelBT);
|
||||
MyFill(table,"anodeRelFrontTime_Cut",1000,-3000,3500, anodeRelFT);
|
||||
MyFill(table,"anodeRelTime_toScint_Cut",1000,-3000,3500,anodeRelFT_toScint);
|
||||
for(int i=0; i<5; i++)
|
||||
TFile *outfile = TFile::Open(output.c_str(), "RECREATE");
|
||||
TChain* chain = new TChain("SPSTree");
|
||||
for(unsigned int i=0; i<files.size(); i++)
|
||||
chain->Add(files[i].c_str());
|
||||
chain->SetBranchAddress("event", &event_address);
|
||||
THashTable* table = new THashTable();
|
||||
|
||||
long blentries = chain->GetEntries();
|
||||
if(m_pb)
|
||||
SetProgressBar(blentries);
|
||||
std::cout<<"Total number of events: "<<blentries<<std::endl;
|
||||
|
||||
long count=0, flush_val=blentries*0.01, flush_count=0;
|
||||
|
||||
for(long i=0; i<chain->GetEntries(); i++)
|
||||
{
|
||||
if(ev.sabreRingE[i] != -1)
|
||||
count++;
|
||||
if(count == flush_val)
|
||||
{
|
||||
Double_t sabreRelRT = ev.sabreRingTime[i] - ev.anodeBackTime;
|
||||
Double_t sabreRelWT = ev.sabreWedgeTime[i] - ev.anodeBackTime;
|
||||
MyFill(table,"sabreRelRingTime_Cut",1000,-3000,3500, sabreRelRT);
|
||||
MyFill(table,"sabreRelWedgeTime_Cut",1000,-3000,3500, sabreRelWT);
|
||||
}
|
||||
if(m_pb) {
|
||||
m_pb->Increment(count);
|
||||
gSystem->ProcessEvents();
|
||||
count = 0;
|
||||
} else {
|
||||
flush_count++;
|
||||
count=0;
|
||||
std::cout<<"\rPercent of data processed: "<<flush_count*10<<"%"<<std::flush;
|
||||
}
|
||||
}
|
||||
chain->GetEntry(i);
|
||||
MakeUncutHistograms(*event_address, table);
|
||||
if(cutter.IsValid()) MakeCutHistograms(*event_address, table);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MyFill(table,"noscinttime_counter_Cut",2,0,1,1);
|
||||
std::cout<<std::endl;
|
||||
outfile->cd();
|
||||
table->Write();
|
||||
if(cutter.IsValid())
|
||||
{
|
||||
auto clist = cutter.GetCuts();
|
||||
for(unsigned int i=0; i<clist.size(); i++)
|
||||
clist[i]->Write();
|
||||
}
|
||||
delete table;
|
||||
outfile->Close();
|
||||
delete outfile;
|
||||
}
|
||||
|
||||
for(int i=0; i<5; i++)
|
||||
|
||||
void SFPPlotter::SetProgressBar(long total)
|
||||
{
|
||||
if(ev.sabreRingE[i] != -1)
|
||||
{
|
||||
MyFill(table,"sabreRingE_Cut",2000,0,20,ev.sabreRingE[i]);
|
||||
MyFill(table,"xavg_Cut_sabrefcoinc",600,-300,300,ev.xavg);
|
||||
MyFill(table,"xavg_sabreRingE_Cut",600,-300,300,ev.xavg,200,0,20,ev.sabreRingE[i]);
|
||||
MyFill(table,"sabreWedgeE_Cut",2000,0,20,ev.sabreWedgeE[i]);
|
||||
MyFill(table,"xavg_sabreWedgeE_Cut",600,-300,300,ev.xavg,200,0,20,ev.sabreWedgeE[i]);
|
||||
}
|
||||
m_pb->SetMax(total);
|
||||
m_pb->SetMin(0);
|
||||
m_pb->SetPosition(0);
|
||||
gSystem->ProcessEvents();
|
||||
}
|
||||
}
|
||||
|
||||
/*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++)
|
||||
chain->Add(files[i].c_str());
|
||||
chain->SetBranchAddress("event", &event_address);
|
||||
THashTable* table = new THashTable();
|
||||
|
||||
long blentries = chain->GetEntries();
|
||||
if(m_pb)
|
||||
SetProgressBar(blentries);
|
||||
std::cout<<"Total number of events: "<<blentries<<std::endl;
|
||||
|
||||
long count=0, flush_val=blentries*0.01, flush_count=0;
|
||||
|
||||
for(long i=0; i<chain->GetEntries(); i++)
|
||||
{
|
||||
count++;
|
||||
if(count == flush_val)
|
||||
{
|
||||
if(m_pb) {
|
||||
m_pb->Increment(count);
|
||||
gSystem->ProcessEvents();
|
||||
count = 0;
|
||||
} else {
|
||||
flush_count++;
|
||||
count=0;
|
||||
std::cout<<"\rPercent of data processed: "<<flush_count*10<<"%"<<std::flush;
|
||||
}
|
||||
}
|
||||
chain->GetEntry(i);
|
||||
MakeUncutHistograms(*event_address, table);
|
||||
if(cutter.IsValid()) MakeCutHistograms(*event_address, table);
|
||||
}
|
||||
std::cout<<std::endl;
|
||||
outfile->cd();
|
||||
table->Write();
|
||||
if(cutter.IsValid())
|
||||
{
|
||||
auto clist = cutter.GetCuts();
|
||||
for(unsigned int i=0; i<clist.size(); i++)
|
||||
clist[i]->Write();
|
||||
}
|
||||
delete table;
|
||||
outfile->Close();
|
||||
delete outfile;
|
||||
}
|
||||
|
||||
|
||||
void SFPPlotter::SetProgressBar(long total)
|
||||
{
|
||||
m_pb->SetMax(total);
|
||||
m_pb->SetMin(0);
|
||||
m_pb->SetPosition(0);
|
||||
gSystem->ProcessEvents();
|
||||
}
|
||||
}
|
|
@ -13,33 +13,37 @@
|
|||
#include "CutHandler.h"
|
||||
#include <TGProgressBar.h>
|
||||
|
||||
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);
|
||||
namespace EventBuilder {
|
||||
|
||||
private:
|
||||
void SetProgressBar(long total);
|
||||
void Chain(const std::vector<std::string>& files); //Form TChain
|
||||
void MakeUncutHistograms(const ProcessedEvent& ev, THashTable* table);
|
||||
void MakeCutHistograms(const ProcessedEvent& ev, THashTable* table);
|
||||
|
||||
/*Histogram fill wrapper functions*/
|
||||
void MyFill(THashTable* table, const std::string& name, int binsx, double minx, double maxx, double valuex,
|
||||
int binsy, double miny, double maxy, double valuey);
|
||||
void MyFill(THashTable* table, const std::string& name, int binsx, double minx, double maxx, double valuex);
|
||||
|
||||
ProcessedEvent *event_address;
|
||||
|
||||
/*Cuts*/
|
||||
CutHandler cutter;
|
||||
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);
|
||||
|
||||
TGProgressBar* m_pb; //GUI progress
|
||||
private:
|
||||
void SetProgressBar(long total);
|
||||
void Chain(const std::vector<std::string>& files); //Form TChain
|
||||
void MakeUncutHistograms(const ProcessedEvent& ev, THashTable* table);
|
||||
void MakeCutHistograms(const ProcessedEvent& ev, THashTable* table);
|
||||
|
||||
/*Histogram fill wrapper functions*/
|
||||
void MyFill(THashTable* table, const std::string& name, int binsx, double minx, double maxx, double valuex,
|
||||
int binsy, double miny, double maxy, double valuey);
|
||||
void MyFill(THashTable* table, const std::string& name, int binsx, double minx, double maxx, double valuex);
|
||||
|
||||
ProcessedEvent *event_address;
|
||||
|
||||
/*Cuts*/
|
||||
CutHandler cutter;
|
||||
|
||||
TGProgressBar* m_pb; //GUI progress
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -12,70 +12,74 @@
|
|||
#include "EventBuilder.h"
|
||||
#include "ShiftMap.h"
|
||||
|
||||
ShiftMap::ShiftMap() :
|
||||
m_filename(""), m_validFlag(false)
|
||||
{
|
||||
}
|
||||
namespace EventBuilder {
|
||||
|
||||
ShiftMap::ShiftMap(const std::string& filename) :
|
||||
m_filename(filename), m_validFlag(false)
|
||||
{
|
||||
ParseFile();
|
||||
}
|
||||
|
||||
ShiftMap::~ShiftMap() {}
|
||||
|
||||
void ShiftMap::SetFile(const std::string& filename)
|
||||
{
|
||||
m_filename = filename;
|
||||
ParseFile();
|
||||
}
|
||||
|
||||
uint64_t ShiftMap::GetShift(int gchan)
|
||||
{
|
||||
if(!m_validFlag)
|
||||
return 0;
|
||||
|
||||
auto iter = m_map.find(gchan);
|
||||
if(iter == m_map.end())
|
||||
return 0;
|
||||
else
|
||||
return iter->second;
|
||||
}
|
||||
|
||||
void ShiftMap::ParseFile()
|
||||
{
|
||||
m_validFlag = false;
|
||||
std::ifstream input(m_filename);
|
||||
if(!input.is_open())
|
||||
return;
|
||||
|
||||
int board, channel, gchan;
|
||||
uint64_t shift;
|
||||
std::string junk, temp;
|
||||
|
||||
std::getline(input, junk);
|
||||
std::getline(input, junk);
|
||||
|
||||
while(input>>board)
|
||||
ShiftMap::ShiftMap() :
|
||||
m_filename(""), m_validFlag(false)
|
||||
{
|
||||
input>>temp;
|
||||
input>>shift;
|
||||
if(temp == "all") //keyword to set all channels in this board to same shift
|
||||
{
|
||||
for(int i=0; i<16; i++)
|
||||
}
|
||||
|
||||
ShiftMap::ShiftMap(const std::string& filename) :
|
||||
m_filename(filename), m_validFlag(false)
|
||||
{
|
||||
ParseFile();
|
||||
}
|
||||
|
||||
ShiftMap::~ShiftMap() {}
|
||||
|
||||
void ShiftMap::SetFile(const std::string& filename)
|
||||
{
|
||||
m_filename = filename;
|
||||
ParseFile();
|
||||
}
|
||||
|
||||
uint64_t ShiftMap::GetShift(int gchan)
|
||||
{
|
||||
if(!m_validFlag)
|
||||
return 0;
|
||||
|
||||
auto iter = m_map.find(gchan);
|
||||
if(iter == m_map.end())
|
||||
return 0;
|
||||
else
|
||||
return iter->second;
|
||||
}
|
||||
|
||||
void ShiftMap::ParseFile()
|
||||
{
|
||||
m_validFlag = false;
|
||||
std::ifstream input(m_filename);
|
||||
if(!input.is_open())
|
||||
return;
|
||||
|
||||
int board, channel, gchan;
|
||||
uint64_t shift;
|
||||
std::string junk, temp;
|
||||
|
||||
std::getline(input, junk);
|
||||
std::getline(input, junk);
|
||||
|
||||
while(input>>board)
|
||||
{
|
||||
input>>temp;
|
||||
input>>shift;
|
||||
if(temp == "all") //keyword to set all channels in this board to same shift
|
||||
{
|
||||
for(int i=0; i<16; i++)
|
||||
{
|
||||
gchan = board*16 + i;
|
||||
m_map[gchan] = shift;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gchan = board*16 + i;
|
||||
channel = stoi(temp);
|
||||
gchan = channel + board*16;
|
||||
m_map[gchan] = shift;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
channel = stoi(temp);
|
||||
gchan = channel + board*16;
|
||||
m_map[gchan] = shift;
|
||||
}
|
||||
|
||||
m_validFlag = true;
|
||||
}
|
||||
|
||||
m_validFlag = true;
|
||||
}
|
||||
}
|
|
@ -12,25 +12,29 @@
|
|||
#ifndef SHIFTMAP_H
|
||||
#define SHIFTMAP_H
|
||||
|
||||
class ShiftMap
|
||||
{
|
||||
public:
|
||||
ShiftMap();
|
||||
ShiftMap(const std::string& filename);
|
||||
~ShiftMap();
|
||||
void SetFile(const std::string& filename);
|
||||
inline bool IsValid() { return m_validFlag; }
|
||||
inline std::string GetFilename() { return m_filename; }
|
||||
uint64_t GetShift(int gchan);
|
||||
namespace EventBuilder {
|
||||
|
||||
private:
|
||||
void ParseFile();
|
||||
class ShiftMap
|
||||
{
|
||||
public:
|
||||
ShiftMap();
|
||||
ShiftMap(const std::string& filename);
|
||||
~ShiftMap();
|
||||
void SetFile(const std::string& filename);
|
||||
inline bool IsValid() { return m_validFlag; }
|
||||
inline std::string GetFilename() { return m_filename; }
|
||||
uint64_t GetShift(int gchan);
|
||||
|
||||
private:
|
||||
void ParseFile();
|
||||
|
||||
std::string m_filename;
|
||||
bool m_validFlag;
|
||||
|
||||
std::unordered_map<int, uint64_t> m_map;
|
||||
|
||||
};
|
||||
|
||||
std::string m_filename;
|
||||
bool m_validFlag;
|
||||
|
||||
std::unordered_map<int, uint64_t> m_map;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -10,171 +10,175 @@
|
|||
#include "EventBuilder.h"
|
||||
#include "SlowSort.h"
|
||||
|
||||
/*Sort the Sabre Data in order of descending energy*/
|
||||
bool SabreSort(const DetectorHit& i, const DetectorHit& j) {
|
||||
return (i.Long>j.Long);
|
||||
}
|
||||
namespace EventBuilder {
|
||||
|
||||
/*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) :
|
||||
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() {}
|
||||
|
||||
/**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*/
|
||||
varMap[DetAttribute::SabreRing0] = &m_event.sabreArray[0].rings;
|
||||
varMap[DetAttribute::SabreRing1] = &m_event.sabreArray[1].rings;
|
||||
varMap[DetAttribute::SabreRing2] = &m_event.sabreArray[2].rings;
|
||||
varMap[DetAttribute::SabreRing3] = &m_event.sabreArray[3].rings;
|
||||
varMap[DetAttribute::SabreRing4] = &m_event.sabreArray[4].rings;
|
||||
varMap[DetAttribute::SabreWedge0] = &m_event.sabreArray[0].wedges;
|
||||
varMap[DetAttribute::SabreWedge1] = &m_event.sabreArray[1].wedges;
|
||||
varMap[DetAttribute::SabreWedge2] = &m_event.sabreArray[2].wedges;
|
||||
varMap[DetAttribute::SabreWedge3] = &m_event.sabreArray[3].wedges;
|
||||
varMap[DetAttribute::SabreWedge4] = &m_event.sabreArray[4].wedges;
|
||||
|
||||
/*For focal plane: Only one focal plane, so each variable is uniquely
|
||||
identified by its attribute
|
||||
*/
|
||||
varMap[DetAttribute::ScintLeft] = &m_event.focalPlane.scintL;
|
||||
varMap[DetAttribute::ScintRight] = &m_event.focalPlane.scintR;
|
||||
varMap[DetAttribute::Cathode] = &m_event.focalPlane.cathode;
|
||||
varMap[DetAttribute::DelayFR] = &m_event.focalPlane.delayFR;
|
||||
varMap[DetAttribute::DelayFL] = &m_event.focalPlane.delayFL;
|
||||
varMap[DetAttribute::DelayBL] = &m_event.focalPlane.delayBL;
|
||||
varMap[DetAttribute::DelayBR] = &m_event.focalPlane.delayBR;
|
||||
varMap[DetAttribute::AnodeFront] = &m_event.focalPlane.anodeF;
|
||||
varMap[DetAttribute::AnodeBack] = &m_event.focalPlane.anodeB;
|
||||
varMap[DetAttribute::Monitor] = &m_event.focalPlane.monitor;
|
||||
|
||||
}
|
||||
|
||||
/*Reset output structure to blank*/
|
||||
void SlowSort::Reset()
|
||||
{
|
||||
m_event = m_blank;
|
||||
}
|
||||
|
||||
bool SlowSort::AddHitToEvent(CompassHit& mhit)
|
||||
{
|
||||
DPPChannel curHit;
|
||||
curHit.Timestamp = mhit.timestamp;
|
||||
curHit.Energy = mhit.lgate;
|
||||
curHit.EnergyShort = mhit.sgate;
|
||||
curHit.Channel = mhit.channel;
|
||||
curHit.Board = mhit.board;
|
||||
curHit.Flags = mhit.flags;
|
||||
|
||||
if(m_hitList.empty())
|
||||
{
|
||||
startTime = curHit.Timestamp;
|
||||
m_hitList.push_back(curHit);
|
||||
}
|
||||
else if (curHit.Timestamp < previousHitTime)
|
||||
return false;
|
||||
else if ((curHit.Timestamp - startTime) < m_coincWindow)
|
||||
m_hitList.push_back(curHit);
|
||||
else
|
||||
{
|
||||
ProcessEvent();
|
||||
m_hitList.clear();
|
||||
startTime = curHit.Timestamp;
|
||||
m_hitList.push_back(curHit);
|
||||
m_eventFlag = true;
|
||||
/*Sort the Sabre Data in order of descending energy*/
|
||||
bool SabreSort(const DetectorHit& i, const DetectorHit& j) {
|
||||
return (i.Long>j.Long);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SlowSort::FlushHitsToEvent()
|
||||
{
|
||||
if(m_hitList.empty())
|
||||
|
||||
/*Constructor takes input of coincidence window size, and fills sabre channel map*/
|
||||
SlowSort::SlowSort() :
|
||||
m_coincWindow(-1.0), m_eventFlag(false)
|
||||
{
|
||||
m_eventFlag = false;
|
||||
return;
|
||||
event_stats = new TH2F("coinc_event_stats","coinc_events_stats;global channel;number of coincident hits;counts",144,0,144,20,0,20);
|
||||
}
|
||||
|
||||
ProcessEvent();
|
||||
m_hitList.clear();
|
||||
m_eventFlag = true;
|
||||
}
|
||||
|
||||
const CoincEvent& SlowSort::GetEvent()
|
||||
{
|
||||
m_eventFlag = false;
|
||||
return m_event;
|
||||
}
|
||||
|
||||
/*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()
|
||||
{
|
||||
Reset();
|
||||
DetectorHit dhit;
|
||||
int gchan;
|
||||
int size = m_hitList.size();
|
||||
for(DPPChannel& curHit: m_hitList)
|
||||
|
||||
SlowSort::SlowSort(double windowSize, const std::string& mapfile) :
|
||||
m_coincWindow(windowSize), m_eventFlag(false), m_event(), cmap(mapfile)
|
||||
{
|
||||
gchan = curHit.Channel + curHit.Board*16; //global channel
|
||||
event_stats->Fill(gchan, size);
|
||||
dhit.Time = curHit.Timestamp/1.0e3;
|
||||
dhit.Ch = gchan;
|
||||
dhit.Long = curHit.Energy;
|
||||
dhit.Short = curHit.EnergyShort;
|
||||
auto channel_info = cmap.FindChannel(gchan);
|
||||
|
||||
if(channel_info == cmap.End())
|
||||
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() {}
|
||||
|
||||
/**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*/
|
||||
varMap[DetAttribute::SabreRing0] = &m_event.sabreArray[0].rings;
|
||||
varMap[DetAttribute::SabreRing1] = &m_event.sabreArray[1].rings;
|
||||
varMap[DetAttribute::SabreRing2] = &m_event.sabreArray[2].rings;
|
||||
varMap[DetAttribute::SabreRing3] = &m_event.sabreArray[3].rings;
|
||||
varMap[DetAttribute::SabreRing4] = &m_event.sabreArray[4].rings;
|
||||
varMap[DetAttribute::SabreWedge0] = &m_event.sabreArray[0].wedges;
|
||||
varMap[DetAttribute::SabreWedge1] = &m_event.sabreArray[1].wedges;
|
||||
varMap[DetAttribute::SabreWedge2] = &m_event.sabreArray[2].wedges;
|
||||
varMap[DetAttribute::SabreWedge3] = &m_event.sabreArray[3].wedges;
|
||||
varMap[DetAttribute::SabreWedge4] = &m_event.sabreArray[4].wedges;
|
||||
|
||||
/*For focal plane: Only one focal plane, so each variable is uniquely
|
||||
identified by its attribute
|
||||
*/
|
||||
varMap[DetAttribute::ScintLeft] = &m_event.focalPlane.scintL;
|
||||
varMap[DetAttribute::ScintRight] = &m_event.focalPlane.scintR;
|
||||
varMap[DetAttribute::Cathode] = &m_event.focalPlane.cathode;
|
||||
varMap[DetAttribute::DelayFR] = &m_event.focalPlane.delayFR;
|
||||
varMap[DetAttribute::DelayFL] = &m_event.focalPlane.delayFL;
|
||||
varMap[DetAttribute::DelayBL] = &m_event.focalPlane.delayBL;
|
||||
varMap[DetAttribute::DelayBR] = &m_event.focalPlane.delayBR;
|
||||
varMap[DetAttribute::AnodeFront] = &m_event.focalPlane.anodeF;
|
||||
varMap[DetAttribute::AnodeBack] = &m_event.focalPlane.anodeB;
|
||||
varMap[DetAttribute::Monitor] = &m_event.focalPlane.monitor;
|
||||
|
||||
}
|
||||
|
||||
/*Reset output structure to blank*/
|
||||
void SlowSort::Reset()
|
||||
{
|
||||
m_event = m_blank;
|
||||
}
|
||||
|
||||
bool SlowSort::AddHitToEvent(CompassHit& mhit)
|
||||
{
|
||||
DPPChannel curHit;
|
||||
curHit.Timestamp = mhit.timestamp;
|
||||
curHit.Energy = mhit.lgate;
|
||||
curHit.EnergyShort = mhit.sgate;
|
||||
curHit.Channel = mhit.channel;
|
||||
curHit.Board = mhit.board;
|
||||
curHit.Flags = mhit.flags;
|
||||
|
||||
if(m_hitList.empty())
|
||||
{
|
||||
std::cout<<std::endl;
|
||||
std::cout<<"------Data Assignment Error!-------"<<std::endl;
|
||||
std::cout<<"Global channel number "<<gchan<<" found in data stream, but not assigned in ChannelMap!"<<std::endl;
|
||||
std::cout<<"Skipping this hit..."<<std::endl;
|
||||
std::cout<<"-----------------------------------"<<std::endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(channel_info->second.type == DetType::FocalPlane)
|
||||
{
|
||||
auto variable = varMap.find(channel_info->second.attribute);
|
||||
if(variable != varMap.end())
|
||||
variable->second->push_back(dhit);
|
||||
startTime = curHit.Timestamp;
|
||||
m_hitList.push_back(curHit);
|
||||
}
|
||||
else if(channel_info->second.type == DetType::Sabre)
|
||||
{
|
||||
auto variable = varMap.find(channel_info->second.attribute);
|
||||
if(variable != varMap.end())
|
||||
variable->second->push_back(dhit);
|
||||
}
|
||||
else if (curHit.Timestamp < previousHitTime)
|
||||
return false;
|
||||
else if ((curHit.Timestamp - startTime) < m_coincWindow)
|
||||
m_hitList.push_back(curHit);
|
||||
else
|
||||
{
|
||||
std::cout<<std::endl;
|
||||
std::cout<<"------Data Assignment Error!-------"<<std::endl;
|
||||
std::cout<<"Channel is present in channel map, but does not have a variable assigned in variable map!"<<std::endl;
|
||||
std::cout<<"global channel number: "<<gchan<<" channel detector type: "<<channel_info->second.type<<" attribute: "<<channel_info->second.attribute<<std::endl;
|
||||
std::cout<<"Skipping this hit..."<<std::endl;
|
||||
std::cout<<"-----------------------------------"<<std::endl;
|
||||
ProcessEvent();
|
||||
m_hitList.clear();
|
||||
startTime = curHit.Timestamp;
|
||||
m_hitList.push_back(curHit);
|
||||
m_eventFlag = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SlowSort::FlushHitsToEvent()
|
||||
{
|
||||
if(m_hitList.empty())
|
||||
{
|
||||
m_eventFlag = false;
|
||||
return;
|
||||
}
|
||||
|
||||
ProcessEvent();
|
||||
m_hitList.clear();
|
||||
m_eventFlag = true;
|
||||
}
|
||||
|
||||
const CoincEvent& SlowSort::GetEvent()
|
||||
{
|
||||
m_eventFlag = false;
|
||||
return m_event;
|
||||
}
|
||||
|
||||
/*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()
|
||||
{
|
||||
Reset();
|
||||
DetectorHit dhit;
|
||||
int gchan;
|
||||
int size = m_hitList.size();
|
||||
for(DPPChannel& curHit: m_hitList)
|
||||
{
|
||||
gchan = curHit.Channel + curHit.Board*16; //global channel
|
||||
event_stats->Fill(gchan, size);
|
||||
dhit.Time = curHit.Timestamp/1.0e3;
|
||||
dhit.Ch = gchan;
|
||||
dhit.Long = curHit.Energy;
|
||||
dhit.Short = curHit.EnergyShort;
|
||||
auto channel_info = cmap.FindChannel(gchan);
|
||||
|
||||
if(channel_info == cmap.End())
|
||||
{
|
||||
std::cout<<std::endl;
|
||||
std::cout<<"------Data Assignment Error!-------"<<std::endl;
|
||||
std::cout<<"Global channel number "<<gchan<<" found in data stream, but not assigned in ChannelMap!"<<std::endl;
|
||||
std::cout<<"Skipping this hit..."<<std::endl;
|
||||
std::cout<<"-----------------------------------"<<std::endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(channel_info->second.type == DetType::FocalPlane)
|
||||
{
|
||||
auto variable = varMap.find(channel_info->second.attribute);
|
||||
if(variable != varMap.end())
|
||||
variable->second->push_back(dhit);
|
||||
}
|
||||
else if(channel_info->second.type == DetType::Sabre)
|
||||
{
|
||||
auto variable = varMap.find(channel_info->second.attribute);
|
||||
if(variable != varMap.end())
|
||||
variable->second->push_back(dhit);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout<<std::endl;
|
||||
std::cout<<"------Data Assignment Error!-------"<<std::endl;
|
||||
std::cout<<"Channel is present in channel map, but does not have a variable assigned in variable map!"<<std::endl;
|
||||
std::cout<<"global channel number: "<<gchan<<" channel detector type: "<<channel_info->second.type<<" attribute: "<<channel_info->second.attribute<<std::endl;
|
||||
std::cout<<"Skipping this hit..."<<std::endl;
|
||||
std::cout<<"-----------------------------------"<<std::endl;
|
||||
}
|
||||
}
|
||||
//Organize the SABRE data in descending energy order
|
||||
for(int s=0; s<5; s++)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
//Organize the SABRE data in descending energy order
|
||||
for(int s=0; s<5; s++)
|
||||
{
|
||||
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,39 +16,43 @@
|
|||
#include <TH2.h>
|
||||
#include <unordered_map>
|
||||
|
||||
class SlowSort
|
||||
{
|
||||
namespace EventBuilder {
|
||||
|
||||
public:
|
||||
SlowSort();
|
||||
SlowSort(double windowSize, const std::string& mapfile);
|
||||
~SlowSort();
|
||||
inline void SetWindowSize(double window) { m_coincWindow = window; }
|
||||
inline bool SetMapFile(const std::string& mapfile) { return cmap.FillMap(mapfile); }
|
||||
bool AddHitToEvent(CompassHit& mhit);
|
||||
const CoincEvent& GetEvent();
|
||||
inline TH2F* GetEventStats() { return event_stats; }
|
||||
void FlushHitsToEvent(); //For use with *last* hit list
|
||||
inline bool IsEventReady() { return m_eventFlag; }
|
||||
|
||||
private:
|
||||
void InitVariableMaps();
|
||||
void Reset();
|
||||
void ProcessEvent();
|
||||
|
||||
double m_coincWindow;
|
||||
std::vector<DPPChannel> m_hitList;
|
||||
bool m_eventFlag;
|
||||
CoincEvent m_event;
|
||||
CoincEvent m_blank;
|
||||
class SlowSort
|
||||
{
|
||||
|
||||
double startTime, previousHitTime;
|
||||
std::unordered_map<DetAttribute, std::vector<DetectorHit>*> varMap;
|
||||
public:
|
||||
SlowSort();
|
||||
SlowSort(double windowSize, const std::string& mapfile);
|
||||
~SlowSort();
|
||||
inline void SetWindowSize(double window) { m_coincWindow = window; }
|
||||
inline bool SetMapFile(const std::string& mapfile) { return cmap.FillMap(mapfile); }
|
||||
bool AddHitToEvent(CompassHit& mhit);
|
||||
const CoincEvent& GetEvent();
|
||||
inline TH2F* GetEventStats() { return event_stats; }
|
||||
void FlushHitsToEvent(); //For use with *last* hit list
|
||||
inline bool IsEventReady() { return m_eventFlag; }
|
||||
|
||||
private:
|
||||
void InitVariableMaps();
|
||||
void Reset();
|
||||
void ProcessEvent();
|
||||
|
||||
double m_coincWindow;
|
||||
std::vector<DPPChannel> m_hitList;
|
||||
bool m_eventFlag;
|
||||
CoincEvent m_event;
|
||||
CoincEvent m_blank;
|
||||
|
||||
double startTime, previousHitTime;
|
||||
std::unordered_map<DetAttribute, std::vector<DetectorHit>*> varMap;
|
||||
|
||||
TH2F* event_stats;
|
||||
|
||||
ChannelMap cmap;
|
||||
|
||||
};
|
||||
|
||||
TH2F* event_stats;
|
||||
|
||||
ChannelMap cmap;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -8,30 +8,34 @@
|
|||
#include "EventBuilder.h"
|
||||
#include "Stopwatch.h"
|
||||
|
||||
Stopwatch::Stopwatch()
|
||||
{
|
||||
start_time = Clock::now();
|
||||
stop_time = start_time;
|
||||
}
|
||||
namespace EventBuilder {
|
||||
|
||||
Stopwatch::~Stopwatch() {}
|
||||
Stopwatch::Stopwatch()
|
||||
{
|
||||
start_time = Clock::now();
|
||||
stop_time = start_time;
|
||||
}
|
||||
|
||||
Stopwatch::~Stopwatch() {}
|
||||
|
||||
void Stopwatch::Start()
|
||||
{
|
||||
start_time = Clock::now();
|
||||
}
|
||||
|
||||
void Stopwatch::Stop()
|
||||
{
|
||||
stop_time = Clock::now();
|
||||
}
|
||||
|
||||
double Stopwatch::GetElapsedSeconds()
|
||||
{
|
||||
return std::chrono::duration_cast<std::chrono::duration<double>>(stop_time-start_time).count();
|
||||
}
|
||||
|
||||
double Stopwatch::GetElapsedMilliseconds()
|
||||
{
|
||||
return std::chrono::duration_cast<std::chrono::duration<double>>(stop_time-start_time).count()*1000.0;
|
||||
}
|
||||
|
||||
void Stopwatch::Start()
|
||||
{
|
||||
start_time = Clock::now();
|
||||
}
|
||||
|
||||
void Stopwatch::Stop()
|
||||
{
|
||||
stop_time = Clock::now();
|
||||
}
|
||||
|
||||
double Stopwatch::GetElapsedSeconds()
|
||||
{
|
||||
return std::chrono::duration_cast<std::chrono::duration<double>>(stop_time-start_time).count();
|
||||
}
|
||||
|
||||
double Stopwatch::GetElapsedMilliseconds()
|
||||
{
|
||||
return std::chrono::duration_cast<std::chrono::duration<double>>(stop_time-start_time).count()*1000.0;
|
||||
}
|
|
@ -10,21 +10,25 @@
|
|||
|
||||
#include <chrono>
|
||||
|
||||
class Stopwatch
|
||||
{
|
||||
public:
|
||||
Stopwatch();
|
||||
~Stopwatch();
|
||||
void Start();
|
||||
void Stop();
|
||||
double GetElapsedSeconds();
|
||||
double GetElapsedMilliseconds();
|
||||
namespace EventBuilder {
|
||||
|
||||
private:
|
||||
using Time = std::chrono::high_resolution_clock::time_point;
|
||||
using Clock = std::chrono::high_resolution_clock;
|
||||
class Stopwatch
|
||||
{
|
||||
public:
|
||||
Stopwatch();
|
||||
~Stopwatch();
|
||||
void Start();
|
||||
void Stop();
|
||||
double GetElapsedSeconds();
|
||||
double GetElapsedMilliseconds();
|
||||
|
||||
private:
|
||||
using Time = std::chrono::high_resolution_clock::time_point;
|
||||
using Clock = std::chrono::high_resolution_clock;
|
||||
|
||||
Time start_time, stop_time;
|
||||
};
|
||||
|
||||
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