Completed style overhaul and cleaned up extraneous code. Minor mods to ChannelMap and variable mapping.

This commit is contained in:
Gordon McCann 2021-12-13 17:04:44 -05:00
parent afcdd3bb8c
commit a904f8c0f2
24 changed files with 512 additions and 419 deletions

View File

@ -1,4 +1,4 @@
Format: scaler_param_name assoc_binary_file_name_without_runID Format: scaler_param_name assoc_binary_file_name_without_runID
NOTE: As of this version, scalers are pure counting parameters (the total events will be counted and saved as a TParameter with the data) NOTE: As of this version, scalers are pure counting parameters (the total events will be counted and saved as a TParameter with the data)
CH0@V1730_89_Data t1 CH0@V1730_89_Data t1
CH5@V1730_89_Data t2

View File

@ -9,17 +9,16 @@
#ifndef CHANNELMAP_H #ifndef CHANNELMAP_H
#define CHANNELMAP_H #define CHANNELMAP_H
struct Channel //Detector part/type identifiers for use in the code
enum DetType
{ {
int detectorType; //What kind of detector we're looking at Sabre,
int detectorID; //Which specific detector we're looking at FocalPlane,
int detectorPart; //Which specific part we're looking at NoneType
}; };
//Detector part/type identifiers for use in the code enum DetAttribute
enum class DetAttribute
{ {
FocalPlane,
ScintLeft, ScintLeft,
ScintRight, ScintRight,
AnodeFront, AnodeFront,
@ -30,30 +29,45 @@ enum class DetAttribute
DelayBL, DelayBL,
Cathode, Cathode,
Monitor, Monitor,
SabreRing = 88, //These are offset to avoid interference at the variable mapping phase SabreRing0,
SabreWedge = 99 //Just don't add any new attributes with values greater than 88 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 class ChannelMap
{ {
public: public:
typedef std::unordered_map<DetAttribute, Channel> Containter; typedef std::unordered_map<int, Channel> Containter;
typedef std::unordered_map<DetAttribute, Channel>::iterator Iterator; typedef std::unordered_map<int, Channel>::iterator Iterator;
ChannelMap(); ChannelMap();
ChannelMap(const std::string& filename); ChannelMap(const std::string& filename);
~ChannelMap(); ~ChannelMap();
bool FillMap(const std::string& filename); bool FillMap(const std::string& filename);
inline const Containter* GetCMap() { return &cmap; }; inline const Containter* GetCMap() { return &m_cmap; };
inline Iterator FindChannel(int key) { return cmap.find(key); }; inline Iterator FindChannel(int key) { return m_cmap.find(key); };
inline Iterator End() { return cmap.end(); }; inline Iterator End() { return m_cmap.end(); };
inline bool IsValid() { return is_valid; }; inline bool IsValid() { return m_validFlag; };
private: private:
Containter cmap; Containter m_cmap;
bool is_valid; bool m_validFlag;
}; };

View File

@ -1,6 +1,8 @@
#ifndef COMPASS_HIT_H #ifndef COMPASS_HIT_H
#define COMPASS_HIT_H #define COMPASS_HIT_H
#include <cstdint>
struct CompassHit struct CompassHit
{ {
uint16_t board = 400; uint16_t board = 400;

View File

@ -25,9 +25,9 @@ public:
CompassRun(); CompassRun();
CompassRun(const std::string& dir); CompassRun(const std::string& dir);
~CompassRun(); ~CompassRun();
inline void SetDirectory(const std::string& dir) { directory = dir; } inline void SetDirectory(const std::string& dir) { m_directory = dir; }
inline void SetScalerInput(const std::string& filename) { m_scalerinput = filename; } inline void SetScalerInput(const std::string& filename) { m_scalerinput = filename; }
inline void SetRunNumber(int n) { runNum = n; } inline void SetRunNumber(int n) { m_runNum = n; }
inline void SetShiftMap(const std::string& filename) { m_smap.SetFile(filename); } inline void SetShiftMap(const std::string& filename) { m_smap.SetFile(filename); }
void Convert2RawRoot(const std::string& name); void Convert2RawRoot(const std::string& name);
void Convert2SortedRoot(const std::string& name, const std::string& mapfile, double window); void Convert2SortedRoot(const std::string& name, const std::string& mapfile, double window);
@ -46,7 +46,7 @@ private:
void ReadScalerData(const std::string& filename); void ReadScalerData(const std::string& filename);
void SetProgressBar(); void SetProgressBar();
std::string directory, m_scalerinput; std::string m_directory, m_scalerinput;
std::vector<CompassFile> m_datafiles; std::vector<CompassFile> m_datafiles;
unsigned int startIndex; //this is the file we start looking at; increases as we finish files. unsigned int startIndex; //this is the file we start looking at; increases as we finish files.
ShiftMap m_smap; ShiftMap m_smap;
@ -58,7 +58,7 @@ private:
ProcessedEvent pevent; ProcessedEvent pevent;
//what run is this //what run is this
int runNum; int m_runNum;
unsigned int m_totalHits; unsigned int m_totalHits;
//Scaler switch //Scaler switch

View File

@ -10,7 +10,7 @@ public:
~CutHandler(); ~CutHandler();
void SetCuts(const std::string& filename); void SetCuts(const std::string& filename);
bool IsValid() { return validFlag; } bool IsValid() { return validFlag; }
bool IsInside(ProcessedEvent* eaddress); bool IsInside(const ProcessedEvent* eaddress);
std::vector<TCutG*> GetCuts() { return cut_array; } std::vector<TCutG*> GetCuts() { return cut_array; }
private: private:

View File

@ -12,10 +12,11 @@
#include <TGProgressBar.h> #include <TGProgressBar.h>
#include <TTimer.h> #include <TTimer.h>
#include <TGComboBox.h> #include <TGComboBox.h>
#include "GWMEventBuilder.h" #include "EVBApp.h"
class EVBMainFrame : public TGMainFrame { class EVBMainFrame : public TGMainFrame
{
public: public:
EVBMainFrame(const TGWindow* p, UInt_t w, UInt_t h); EVBMainFrame(const TGWindow* p, UInt_t w, UInt_t h);
virtual ~EVBMainFrame(); virtual ~EVBMainFrame();
@ -47,31 +48,32 @@ public:
void EnableAllInput(); void EnableAllInput();
enum WidgetId { enum WidgetId
WORKDIR, {
CMAP, WorkDir,
SMAP, Cmap,
SCALER, Smap,
CUT, Scaler,
PLOTF, Cut,
BFIELD, PlotF,
BKE, BField,
THETA, Bke,
Theta,
ZT, ZT,
AT, AT,
ZP, ZP,
AP, AP,
ZE, ZE,
AE, AE,
SLOWWIND, SlowWind,
FASTWIND_IC, FastWind_IC,
FASTWIND_SABRE, FastWind_Sabre,
TYPEBOX, TypeBox,
RMIN, RMin,
RMAX, RMax,
M_LOAD_CONFIG, M_Load_Config,
M_SAVE_CONFIG, M_Save_Config,
M_EXIT M_Exit
}; };
ClassDef(EVBMainFrame, 0); ClassDef(EVBMainFrame, 0);
@ -92,7 +94,7 @@ private:
TGPopupMenu *fFileMenu; TGPopupMenu *fFileMenu;
GWMEventBuilder fBuilder; EVBApp fBuilder;
int counter; int counter;
UInt_t MAIN_W, MAIN_H; UInt_t MAIN_W, MAIN_H;

View File

@ -23,7 +23,7 @@ public:
bool GrabAllFiles(); bool GrabAllFiles();
bool GrabFilesInRange(); bool GrabFilesInRange();
std::string GrabFile(int runNum); std::string GrabFile(int runNum);
inline std::string GetSearchDir() { return directory; } inline std::string GetSearchDir() { return m_directory; }
inline std::string GetSearchPrefix() { return m_prefix; } inline std::string GetSearchPrefix() { return m_prefix; }
inline std::string GetSearchSuffix() { return m_suffix; } inline std::string GetSearchSuffix() { return m_suffix; }
inline int GetRunMin() { return m_minRun; } inline int GetRunMin() { return m_minRun; }

View File

@ -20,7 +20,7 @@ public:
~SFPPlotter(); ~SFPPlotter();
inline void AttachProgressBar(TGProgressBar* pb) { m_pb = pb; } inline void AttachProgressBar(TGProgressBar* pb) { m_pb = pb; }
inline void ApplyCutlist(const std::string& listname) { cutter.SetCuts(listname); } inline void ApplyCutlist(const std::string& listname) { cutter.SetCuts(listname); }
void Run(const std::vector<std::string>& files, const string& output); void Run(const std::vector<std::string>& files, const std::string& output);
private: private:
void SetProgressBar(long total); void SetProgressBar(long total);

View File

@ -21,7 +21,7 @@ public:
void SetFile(const std::string& filename); void SetFile(const std::string& filename);
inline bool IsValid() { return m_validFlag; } inline bool IsValid() { return m_validFlag; }
inline std::string GetFilename() { return m_filename; } inline std::string GetFilename() { return m_filename; }
Long64_t GetShift(int gchan); uint64_t GetShift(int gchan);
private: private:
void ParseFile(); void ParseFile();

View File

@ -14,39 +14,36 @@
#include "DataStructs.h" #include "DataStructs.h"
#include "ChannelMap.h" #include "ChannelMap.h"
#include <TH2.h> #include <TH2.h>
#include <unordered_map>
using namespace std; class SlowSort
{
class SlowSort { public:
public:
SlowSort(); SlowSort();
SlowSort(double windowSize, const string& mapfile); SlowSort(double windowSize, const std::string& mapfile);
~SlowSort(); ~SlowSort();
inline void SetWindowSize(double window) { coincWindow = window; }; inline void SetWindowSize(double window) { m_coincWindow = window; }
inline bool SetMapFile(const std::string& mapfile) { return cmap.FillMap(mapfile); }; inline bool SetMapFile(const std::string& mapfile) { return cmap.FillMap(mapfile); }
bool AddHitToEvent(CompassHit& mhit); bool AddHitToEvent(CompassHit& mhit);
CoincEvent GetEvent(); const CoincEvent& GetEvent();
inline TH2F* GetEventStats() { return event_stats; }; inline TH2F* GetEventStats() { return event_stats; }
void FlushHitsToEvent(); //For use with *last* hit list void FlushHitsToEvent(); //For use with *last* hit list
inline bool IsEventReady() { return eventFlag; }; inline bool IsEventReady() { return m_eventFlag; }
private: private:
void InitVariableMaps(); void InitVariableMaps();
void Reset(); void Reset();
void StartEvent();
void ProcessEvent(); void ProcessEvent();
double coincWindow; double m_coincWindow;
vector<DPPChannel> hitList; std::vector<DPPChannel> m_hitList;
bool eventFlag; bool m_eventFlag;
DPPChannel hit; CoincEvent m_event;
CoincEvent event; CoincEvent m_blank;
CoincEvent blank;
double startTime, previousHitTime; double startTime, previousHitTime;
unordered_map<int, vector<DetectorHit>*> fpVMap; std::unordered_map<DetAttribute, std::vector<DetectorHit>*> varMap;
unordered_map<int, vector<DetectorHit>*> sabreVMap;
TH2F* event_stats; TH2F* event_stats;

View File

@ -1,10 +1,10 @@
-------Data Location---------- -------Data Location----------
WorkspaceDirectory: /data1/gwm17/10B3He/Feb2021/ WorkspaceDirectory: /media/gordon/GordonData/gwm17/9BFeb2021
------------------------------- -------------------------------
------Experimental Inputs------ ------Experimental Inputs------
ChannelMapFile: /home/gwm17/GWM_EventBuilder/etc/orig_ChannelMap_Feb2021_SABRE.txt ChannelMapFile: /home/gordon/SPS_SABRE_EventBuilder/etc/ChannelMap_Feb2021_SABRE.txt
ScalerFile: /home/gwm17/GWM_EventBuilder/etc/orig_ScalerFile_Feb2021_SABRE.txt ScalerFile: /home/gordon/SPS_SABRE_EventBuilder/etc/ScalerFile_Feb2021_SABRE.txt
CutListFile: /home/gwm17/GWM_EventBuilder/etc/new_CutList_Feb202110B3hea.txt CutListFile: /home/gordon/SPS_SABRE_EventBuilder/etc/CutList_Feb2021_10B3hea.txt
ZT: 5 ZT: 5
AT: 10 AT: 10
ZP: 2 ZP: 2
@ -16,7 +16,7 @@ BeamKE(MeV): 24
Theta(deg): 15 Theta(deg): 15
------------------------------- -------------------------------
-------Timing Information------ -------Timing Information------
BoardOffsetFile: /home/gwm17/GWM_EventBuilder/etc/orig_ShiftMap_Feb2021_SABRE.txt BoardOffsetFile: /home/gordon/SPS_SABRE_EventBuilder/etc/ShiftMap_Feb2021_SABRE.txt
SlowCoincidenceWindow(ps): 1.5e+06 SlowCoincidenceWindow(ps): 1.5e+06
FastCoincidenceWindow_IonCh(ps): 250000 FastCoincidenceWindow_IonCh(ps): 250000
FastCoincidenceWindow_SABRE(ps): 150000 FastCoincidenceWindow_SABRE(ps): 150000

View File

@ -10,12 +10,12 @@
#include "ChannelMap.h" #include "ChannelMap.h"
ChannelMap::ChannelMap() : ChannelMap::ChannelMap() :
is_valid(false) m_validFlag(false)
{ {
} }
ChannelMap::ChannelMap(const std::string& name) : ChannelMap::ChannelMap(const std::string& name) :
is_valid(false) m_validFlag(false)
{ {
FillMap(name); FillMap(name);
} }
@ -27,8 +27,8 @@ bool ChannelMap::FillMap(const std::string& name)
std::ifstream input(name); std::ifstream input(name);
if(!input.is_open()) if(!input.is_open())
{ {
is_valid = false; m_validFlag = false;
return is_valid; return m_validFlag;
} }
std::string junk, type, partname; std::string junk, type, partname;
int gchan, id; int gchan, id;
@ -39,42 +39,56 @@ bool ChannelMap::FillMap(const std::string& name)
while(input>>gchan) while(input>>gchan)
{ {
//Set default values //Set default values
this_chan.detectorType = -1; this_chan.type = DetType::NoneType;
this_chan.detectorID = -1; this_chan.local_channel = -1;
this_chan.detectorPart = -1; this_chan.attribute = DetAttribute::NoneAttr;
input>>id>>type>>partname; input>>id>>type>>partname;
if(type == "SABRERING") if(type == "SABRERING")
{ {
this_chan.detectorType = DetAttribute::SabreRing; this_chan.type = DetType::Sabre;
this_chan.detectorID = id; switch(id)
this_chan.detectorPart = std::stoi(partname); {
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") else if(type == "SABREWEDGE")
{ {
this_chan.detectorType = DetAttribute::SabreWedge; this_chan.type = DetType::Sabre;
this_chan.detectorID = id; switch(id)
this_chan.detectorPart = std::stoi(partname); {
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") else if (type == "FOCALPLANE")
{ {
this_chan.detectorType = FOCALPLANE; this_chan.type = DetType::FocalPlane;
this_chan.detectorID = id; this_chan.local_channel = id;
if(partname == "SCINTRIGHT") this_chan.detectorPart = DetAttribute::ScintRight; if(partname == "SCINTRIGHT") this_chan.attribute = DetAttribute::ScintRight;
else if(partname == "SCINTLEFT") this_chan.detectorPart = DetAttribute::ScintLeft; else if(partname == "SCINTLEFT") this_chan.attribute = DetAttribute::ScintLeft;
else if(partname == "DELAYFR") this_chan.detectorPart = DetAttribute::DelayFR; else if(partname == "DELAYFR") this_chan.attribute = DetAttribute::DelayFR;
else if(partname == "DELAYFL") this_chan.detectorPart = DetAttribute::DelayFL; else if(partname == "DELAYFL") this_chan.attribute = DetAttribute::DelayFL;
else if(partname == "DELAYBR") this_chan.detectorPart = DetAttribute::DelayBR; else if(partname == "DELAYBR") this_chan.attribute = DetAttribute::DelayBR;
else if(partname == "DELAYBL") this_chan.detectorPart = DetAttribute::DelayBL; else if(partname == "DELAYBL") this_chan.attribute = DetAttribute::DelayBL;
else if(partname == "CATHODE") this_chan.detectorPart = DetAttribute::Cathode; else if(partname == "CATHODE") this_chan.attribute = DetAttribute::Cathode;
else if(partname == "ANODEFRONT") this_chan.detectorPart = DetAttribute::AnodeFront; else if(partname == "ANODEFRONT") this_chan.attribute = DetAttribute::AnodeFront;
else if(partname == "ANODEBACK") this_chan.detectorPart = DetAttribute::AnodeBack; else if(partname == "ANODEBACK") this_chan.attribute = DetAttribute::AnodeBack;
else if(partname == "MONITOR") this_chan.detectorPart = DetAttribute::Monitor; else if(partname == "MONITOR") this_chan.attribute = DetAttribute::Monitor;
} }
cmap[gchan] = this_chan; m_cmap[gchan] = this_chan;
} }
input.close(); input.close();
is_valid = true; m_validFlag = true;
return is_valid; return m_validFlag;
} }

View File

@ -18,13 +18,13 @@
#include "FlagHandler.h" #include "FlagHandler.h"
CompassRun::CompassRun() : CompassRun::CompassRun() :
directory(""), m_scalerinput(""), runNum(0), m_scaler_flag(false), m_pb(nullptr) m_directory(""), m_scalerinput(""), m_runNum(0), m_scaler_flag(false), m_pb(nullptr)
{ {
} }
CompassRun::CompassRun(const std::string& dir) : CompassRun::CompassRun(const std::string& dir) :
directory(dir), m_scalerinput(""), runNum(0), m_scaler_flag(false), m_pb(nullptr) m_directory(dir), m_scalerinput(""), m_runNum(0), m_scaler_flag(false), m_pb(nullptr)
{ {
} }
@ -48,7 +48,7 @@ void CompassRun::SetScalers()
while(input>>filename) while(input>>filename)
{ {
input>>varname; input>>varname;
filename = directory+filename+"_run_"+to_string(runNum)+".bin"; filename = m_directory+filename+"_run_"+std::to_string(m_runNum)+".bin";
m_scaler_map[filename] = TParameter<Long64_t>(varname.c_str(), init); m_scaler_map[filename] = TParameter<Long64_t>(varname.c_str(), init);
} }
input.close(); input.close();
@ -58,15 +58,15 @@ bool CompassRun::GetBinaryFiles()
{ {
std::string prefix = ""; std::string prefix = "";
std::string suffix = ".bin"; //binaries std::string suffix = ".bin"; //binaries
RunCollector grabber(directory, prefix, suffix); RunCollector grabber(m_directory, prefix, suffix);
grabber.GrabAllFiles(); grabber.GrabAllFiles();
m_datafiles.clear(); //so that the CompassRun can be reused m_datafiles.clear(); //so that the CompassRun can be reused
m_datafiles.reserve(grabber.filelist.size()); m_datafiles.reserve(grabber.GetFileList().size());
bool scalerd; bool scalerd;
m_totalHits = 0; //reset total run size m_totalHits = 0; //reset total run size
for(auto& entry : grabber.filelist) for(auto& entry : grabber.GetFileList())
{ {
//Handle scaler files, if they exist //Handle scaler files, if they exist
if(m_scaler_flag) if(m_scaler_flag)
@ -74,9 +74,9 @@ bool CompassRun::GetBinaryFiles()
scalerd = false; scalerd = false;
for(auto& scaler_pair : m_scaler_map) for(auto& scaler_pair : m_scaler_map)
{ {
if(std::string(entry.Data()) == scaler_pair.first) if(entry == scaler_pair.first)
{ {
ReadScalerData(entry.Data()); ReadScalerData(entry);
scalerd = true; scalerd = true;
break; break;
} }
@ -85,7 +85,7 @@ bool CompassRun::GetBinaryFiles()
continue; continue;
} }
m_datafiles.emplace_back(entry.Data()); m_datafiles.emplace_back(entry);
m_datafiles[m_datafiles.size()-1].AttachShiftMap(&m_smap); m_datafiles[m_datafiles.size()-1].AttachShiftMap(&m_smap);
//Any time we have a file that fails to be found, we terminate the whole process //Any time we have a file that fails to be found, we terminate the whole process
if(!m_datafiles[m_datafiles.size() - 1].IsOpen()) if(!m_datafiles[m_datafiles.size() - 1].IsOpen())
@ -132,26 +132,25 @@ void CompassRun::ReadScalerData(const std::string& filename)
bool CompassRun::GetHitsFromFiles() bool CompassRun::GetHitsFromFiles()
{ {
std::pair<CompassHit, bool*> earliestHit = make_pair(CompassHit(), nullptr); std::pair<CompassHit, bool*> earliestHit = std::make_pair(CompassHit(), nullptr);
for(unsigned int i=startIndex; i<m_datafiles.size(); i++) for(unsigned int i=startIndex; i<m_datafiles.size(); i++)
{ {
if(m_datafiles[i].CheckHitHasBeenUsed()) if(m_datafiles[i].CheckHitHasBeenUsed())
{
m_datafiles[i].GetNextHit(); m_datafiles[i].GetNextHit();
}
if(m_datafiles[i].IsEOF()) if(m_datafiles[i].IsEOF())
{ {
if(i == startIndex) startIndex++; if(i == startIndex)
startIndex++;
continue; continue;
} }
else if(i == startIndex) else if(i == startIndex)
{ {
earliestHit = make_pair(m_datafiles[i].GetCurrentHit(), m_datafiles[i].GetUsedFlagPtr()); earliestHit = std::make_pair(m_datafiles[i].GetCurrentHit(), m_datafiles[i].GetUsedFlagPtr());
} }
else if(m_datafiles[i].GetCurrentHit().timestamp < earliestHit.first.timestamp) else if(m_datafiles[i].GetCurrentHit().timestamp < earliestHit.first.timestamp)
{ {
earliestHit = make_pair(m_datafiles[i].GetCurrentHit(), m_datafiles[i].GetUsedFlagPtr()); earliestHit = std::make_pair(m_datafiles[i].GetCurrentHit(), m_datafiles[i].GetUsedFlagPtr());
} }
} }
@ -173,7 +172,7 @@ void CompassRun::Convert2RawRoot(const std::string& name) {
outtree->Branch("Timestamp", &hit.timestamp); outtree->Branch("Timestamp", &hit.timestamp);
outtree->Branch("Flags", &hit.flags); outtree->Branch("Flags", &hit.flags);
if(!m_smap.IsSet()) if(!m_smap.IsValid())
{ {
std::cerr<<"Bad shift map at CompassRun::Convert()."<<std::endl; std::cerr<<"Bad shift map at CompassRun::Convert()."<<std::endl;
std::cerr<<"Shifts will be locked to 0"<<std::endl; std::cerr<<"Shifts will be locked to 0"<<std::endl;
@ -233,7 +232,7 @@ void CompassRun::Convert2SortedRoot(const std::string& name, const std::string&
outtree->Branch("event", &event); outtree->Branch("event", &event);
if(!m_smap.IsSet()) if(!m_smap.IsValid())
{ {
std::cerr<<"Bad shift map at CompassRun::Convert()."<<std::endl; std::cerr<<"Bad shift map at CompassRun::Convert()."<<std::endl;
std::cerr<<"Shifts will be locked to 0"<<std::endl; std::cerr<<"Shifts will be locked to 0"<<std::endl;
@ -307,7 +306,7 @@ void CompassRun::Convert2FastSortedRoot(const std::string& name, const std::stri
outtree->Branch("event", &event); outtree->Branch("event", &event);
if(!m_smap.IsSet()) if(!m_smap.IsValid())
{ {
std::cerr<<"Bad shift map at CompassRun::Convert()."<<std::endl; std::cerr<<"Bad shift map at CompassRun::Convert()."<<std::endl;
std::cerr<<"Shifts will be locked to 0"<<std::endl; std::cerr<<"Shifts will be locked to 0"<<std::endl;
@ -400,7 +399,7 @@ void CompassRun::Convert2SlowAnalyzedRoot(const std::string& name, const std::st
outtree->Branch("event", &pevent); outtree->Branch("event", &pevent);
if(!m_smap.IsSet()) if(!m_smap.IsValid())
{ {
std::cerr<<"Bad shift map at CompassRun::Convert()."<<std::endl; std::cerr<<"Bad shift map at CompassRun::Convert()."<<std::endl;
std::cerr<<"Shifts will be locked to 0"<<std::endl; std::cerr<<"Shifts will be locked to 0"<<std::endl;
@ -422,7 +421,7 @@ void CompassRun::Convert2SlowAnalyzedRoot(const std::string& name, const std::st
SlowSort coincidizer(window, mapfile); SlowSort coincidizer(window, mapfile);
SFPAnalyzer analyzer(zt, at, zp, ap, ze, ae, bke, theta, b); SFPAnalyzer analyzer(zt, at, zp, ap, ze, ae, bke, theta, b);
vector<TParameter<Double_t>> parvec; std::vector<TParameter<Double_t>> parvec;
parvec.reserve(9); parvec.reserve(9);
parvec.emplace_back("ZT", zt); parvec.emplace_back("ZT", zt);
parvec.emplace_back("AT", at); parvec.emplace_back("AT", at);
@ -500,7 +499,7 @@ void CompassRun::Convert2FastAnalyzedRoot(const std::string& name, const std::st
outtree->Branch("event", &pevent); outtree->Branch("event", &pevent);
if(!m_smap.IsSet()) if(!m_smap.IsValid())
{ {
std::cerr<<"Bad shift map at CompassRun::Convert()."<<std::endl; std::cerr<<"Bad shift map at CompassRun::Convert()."<<std::endl;
std::cerr<<"Shifts will be locked to 0"<<std::endl; std::cerr<<"Shifts will be locked to 0"<<std::endl;
@ -524,7 +523,7 @@ void CompassRun::Convert2FastAnalyzedRoot(const std::string& name, const std::st
FastSort speedyCoincidizer(fsi_window, fic_window); FastSort speedyCoincidizer(fsi_window, fic_window);
SFPAnalyzer analyzer(zt, at, zp, ap, ze, ae, bke, theta, b); SFPAnalyzer analyzer(zt, at, zp, ap, ze, ae, bke, theta, b);
vector<TParameter<Double_t>> parvec; std::vector<TParameter<Double_t>> parvec;
parvec.reserve(9); parvec.reserve(9);
parvec.emplace_back("ZT", zt); parvec.emplace_back("ZT", zt);
parvec.emplace_back("AT", at); parvec.emplace_back("AT", at);

View File

@ -78,7 +78,7 @@ void CutHandler::InitVariableMap()
varmap["cathode"] = &m_event.cathode; varmap["cathode"] = &m_event.cathode;
} }
bool CutHandler::IsInside(ProcessedEvent* eaddress) bool CutHandler::IsInside(const ProcessedEvent* eaddress)
{ {
m_event = *eaddress; m_event = *eaddress;
std::string x, y; std::string x, y;

View File

@ -120,7 +120,7 @@ void EVBApp::WriteConfigFile(const std::string& fullpath)
void EVBApp::PlotHistograms() void EVBApp::PlotHistograms()
{ {
std::string analyze_dir = m_workspace+"/analyzed/"; std::string analyze_dir = m_workspace+"/analyzed/";
std::string plot_file = m_workspace+"/histograms/run_"+to_string(m_rmin)+"_"+to_string(m_rmax)+".root"; std::string plot_file = m_workspace+"/histograms/run_"+std::to_string(m_rmin)+"_"+std::to_string(m_rmax)+".root";
SFPPlotter grammer; SFPPlotter grammer;
grammer.ApplyCutlist(m_cutList); grammer.ApplyCutlist(m_cutList);
std::cout<<"-------------GWM Event Builder-------------"<<std::endl; std::cout<<"-------------GWM Event Builder-------------"<<std::endl;
@ -136,7 +136,7 @@ void EVBApp::PlotHistograms()
if(grabber.GrabFilesInRange()) if(grabber.GrabFilesInRange())
{ {
std::cout<<"Working..."; std::cout<<"Working...";
grammer.Run(grabber.filelist, plot_file); grammer.Run(grabber.GetFileList(), plot_file);
std::cout<<" Complete."<<std::endl; std::cout<<" Complete."<<std::endl;
} }
else else
@ -183,7 +183,7 @@ void EVBApp::Convert2RawRoot()
converter.SetRunNumber(i); converter.SetRunNumber(i);
std::cout<<"Converting file: "<<binfile<<std::endl; std::cout<<"Converting file: "<<binfile<<std::endl;
rawfile = rawroot_dir + "compass_run_"+ to_string(i) + ".root"; rawfile = rawroot_dir + "compass_run_"+ std::to_string(i) + ".root";
unpack_command = "tar -xzf "+binfile+" --directory "+unpack_dir; unpack_command = "tar -xzf "+binfile+" --directory "+unpack_dir;
wipe_command = "rm -r "+unpack_dir+"*.bin"; wipe_command = "rm -r "+unpack_dir+"*.bin";
@ -199,7 +199,7 @@ void EVBApp::Convert2RawRoot()
void EVBApp::MergeROOTFiles() void EVBApp::MergeROOTFiles()
{ {
std::string merge_file = m_workspace+"/merged/run_"+to_string(m_rmin)+"_"+to_string(m_rmax)+".root"; std::string merge_file = m_workspace+"/merged/run_"+std::to_string(m_rmin)+"_"+std::to_string(m_rmax)+".root";
std::string file_dir = m_workspace+"/analyzed/"; std::string file_dir = m_workspace+"/analyzed/";
std::cout<<"-------------GWM Event Builder-------------"<<std::endl; std::cout<<"-------------GWM Event Builder-------------"<<std::endl;
std::cout<<"Merging ROOT files into single ROOT file"<<std::endl; std::cout<<"Merging ROOT files into single ROOT file"<<std::endl;
@ -256,7 +256,7 @@ void EVBApp::Convert2SortedRoot()
converter.SetRunNumber(i); converter.SetRunNumber(i);
std::cout<<"Converting file: "<<binfile<<std::endl; std::cout<<"Converting file: "<<binfile<<std::endl;
sortfile = sortroot_dir +"run_"+to_string(i)+ ".root"; sortfile = sortroot_dir +"run_"+std::to_string(i)+ ".root";
unpack_command = "tar -xzf "+binfile+" --directory "+unpack_dir; unpack_command = "tar -xzf "+binfile+" --directory "+unpack_dir;
wipe_command = "rm -r "+unpack_dir+"*.bin"; wipe_command = "rm -r "+unpack_dir+"*.bin";
@ -305,7 +305,7 @@ void EVBApp::Convert2FastSortedRoot() {
converter.SetRunNumber(i); converter.SetRunNumber(i);
std::cout<<"Converting file: "<<binfile<<std::endl; std::cout<<"Converting file: "<<binfile<<std::endl;
sortfile = sortroot_dir + "run_" + to_string(i) + ".root"; sortfile = sortroot_dir + "run_" + std::to_string(i) + ".root";
unpack_command = "tar -xzf "+binfile+" --directory "+unpack_dir; unpack_command = "tar -xzf "+binfile+" --directory "+unpack_dir;
wipe_command = "rm -r "+unpack_dir+"*.bin"; wipe_command = "rm -r "+unpack_dir+"*.bin";
@ -353,7 +353,7 @@ void EVBApp::Convert2SlowAnalyzedRoot() {
converter.SetRunNumber(i); converter.SetRunNumber(i);
std::cout<<"Converting file: "<<binfile<<std::endl; std::cout<<"Converting file: "<<binfile<<std::endl;
sortfile = sortroot_dir + "run_" + to_string(i) + ".root"; sortfile = sortroot_dir + "run_" + std::to_string(i) + ".root";
unpack_command = "tar -xzf "+binfile+" --directory "+unpack_dir; unpack_command = "tar -xzf "+binfile+" --directory "+unpack_dir;
wipe_command = "rm -r "+unpack_dir+"*.bin"; wipe_command = "rm -r "+unpack_dir+"*.bin";
@ -405,7 +405,7 @@ void EVBApp::Convert2FastAnalyzedRoot()
converter.SetRunNumber(i); converter.SetRunNumber(i);
std::cout<<"Converting file: "<<binfile<<std::endl; std::cout<<"Converting file: "<<binfile<<std::endl;
sortfile = sortroot_dir + "run_" + to_string(i) + ".root"; sortfile = sortroot_dir + "run_" + std::to_string(i) + ".root";
unpack_command = "tar -xzf "+binfile+" --directory "+unpack_dir; unpack_command = "tar -xzf "+binfile+" --directory "+unpack_dir;
wipe_command = "rm -r "+unpack_dir+"*.bin"; wipe_command = "rm -r "+unpack_dir+"*.bin";

View File

@ -2,7 +2,7 @@
#include "FastSort.h" #include "FastSort.h"
//windows given in picoseconds, converted to nanoseconds //windows given in picoseconds, converted to nanoseconds
FastSort::FastSort(float si_windowSize, float ion_windowSize) FastSort::FastSort(float si_windowSize, float ion_windowSize) :
si_coincWindow(si_windowSize/1.0e3), ion_coincWindow(ion_windowSize/1.0e3), event_address(nullptr) si_coincWindow(si_windowSize/1.0e3), ion_coincWindow(ion_windowSize/1.0e3), event_address(nullptr)
{ {
} }
@ -105,7 +105,7 @@ std::vector<CoincEvent> FastSort::GetFastEvents(CoincEvent& event)
sizeArray[4] = slowEvent.focalPlane.anodeF.size(); sizeArray[4] = slowEvent.focalPlane.anodeF.size();
sizeArray[5] = slowEvent.focalPlane.anodeB.size(); sizeArray[5] = slowEvent.focalPlane.anodeB.size();
sizeArray[6] = slowEvent.focalPlane.cathode.size(); sizeArray[6] = slowEvent.focalPlane.cathode.size();
unsigned int maxSize = *max_element(sizeArray, sizeArray+7); unsigned int maxSize = *std::max_element(sizeArray, sizeArray+7);
//loop over scints //loop over scints
for(unsigned int i=0; i<slowEvent.focalPlane.scintL.size(); i++) for(unsigned int i=0; i<slowEvent.focalPlane.scintL.size(); i++)
{ {

View File

@ -21,15 +21,16 @@ MassLookup::MassLookup()
std::ifstream massfile("./etc/mass.txt"); std::ifstream massfile("./etc/mass.txt");
if(massfile.is_open()) if(massfile.is_open())
{ {
int Z; int Z,A;
std::string junk, element, key;
double atomicMassBig, atomicMassSmall, isotopicMass; double atomicMassBig, atomicMassSmall, isotopicMass;
getline(massfile,junk); std::getline(massfile,junk);
getline(massfile,junk); std::getline(massfile,junk);
while(massfile>>junk) while(massfile>>junk)
{ {
massfile>>Z>>A>>element>>atomicMassBig>>atomicMassSmall; massfile>>Z>>A>>element>>atomicMassBig>>atomicMassSmall;
isotopicMass = (atomicMassBig + atomicMassSmall*1e-6 - Z*electron_mass)*u_to_mev; isotopicMass = (atomicMassBig + atomicMassSmall*1e-6 - Z*electron_mass)*u_to_mev;
std::string key = "("+std::to_string(Z)+","+A+")"; key = "("+std::to_string(Z)+","+A+")";
massTable[key] = isotopicMass; massTable[key] = isotopicMass;
elementTable[Z] = element; elementTable[Z] = element;
} }

View File

@ -8,16 +8,16 @@
#include <cstdio> #include <cstdio>
RunCollector::RunCollector(): RunCollector::RunCollector():
m_initFlag(false), m_directory(""), m_prefix(""), m_suffix(""), m_maxRun(0), m_minRun(0) m_initFlag(false), m_directory(""), m_prefix(""), m_suffix(""), m_minRun(0), m_maxRun(0)
{ {
} }
RunCollector::RunCollector(const std::string& dirname, const std::string& prefix, const std::string& suffix) RunCollector::RunCollector(const std::string& dirname, const std::string& prefix, const std::string& suffix) :
m_initFlag(true), m_directory(dirname), m_prefix(prefix), m_suffix(suffix), m_minRun(0), m_maxRun(0) m_initFlag(true), m_directory(dirname), m_prefix(prefix), m_suffix(suffix), m_minRun(0), m_maxRun(0)
{ {
} }
RunCollector::RunCollector(const std::string& dirname, const std::string& prefix, const std::string& suffix, int min, int max) RunCollector::RunCollector(const std::string& dirname, const std::string& prefix, const std::string& suffix, int min, int max) :
m_initFlag(true), m_directory(dirname), m_prefix(prefix), m_suffix(suffix), m_minRun(min), m_maxRun(max) m_initFlag(true), m_directory(dirname), m_prefix(prefix), m_suffix(suffix), m_minRun(min), m_maxRun(max)
{ {
} }
@ -44,7 +44,7 @@ bool RunCollector::GrabAllFiles()
if(!flist) //Make sure list is real. If not, means no directory if(!flist) //Make sure list is real. If not, means no directory
{ {
cerr<<"Unable to find any files in directory; check name given to the input.txt"<<endl; std::cerr<<"Unable to find any files in directory; check name given to the input.txt"<<std::endl;
return false; return false;
} }
@ -54,12 +54,12 @@ bool RunCollector::GrabAllFiles()
while((file = (TSystemFile*)next_element())) while((file = (TSystemFile*)next_element()))
{ {
temp = file->GetName(); temp = file->GetName();
if(temp.size() < prefix.size() || temp.size() < suffix.size()) if(temp.size() < m_prefix.size() || temp.size() < m_suffix.size())
continue; continue;
else if(!file->IsDirectory() && !temp.compare(0,prefix.size(),prefix) && else if(!file->IsDirectory() && !temp.compare(0,m_prefix.size(),m_prefix) &&
!temp.compare(temp.size()-(1+suffix.size()), suffix.size(), suffix)) !temp.compare(temp.size()-m_suffix.size(), m_suffix.size(), m_suffix))
{ {
fname = dir+temp; fname = m_directory+temp;
m_filelist.push_back(fname); m_filelist.push_back(fname);
} }
} }
@ -69,7 +69,7 @@ bool RunCollector::GrabAllFiles()
return true; return true;
else else
{ {
cerr<<"Unable to find files with matching run name in directory; check input.txt"<<endl; std::cerr<<"Unable to find files with matching run name in directory; check input.txt"<<std::endl;
return false; return false;
} }
} }
@ -77,7 +77,7 @@ bool RunCollector::GrabAllFiles()
std::string RunCollector::GrabFile(int runNum) { std::string RunCollector::GrabFile(int runNum) {
if(!m_initFlag) if(!m_initFlag)
return ""; return "";
TSystemDirectory sysdir(dir.Data(), dir.Data()); TSystemDirectory sysdir(m_directory.c_str(), m_directory.c_str());
TList* flist = sysdir.GetListOfFiles(); TList* flist = sysdir.GetListOfFiles();
if(!flist) if(!flist)
@ -85,7 +85,7 @@ std::string RunCollector::GrabFile(int runNum) {
TSystemFile *file; TSystemFile *file;
std::string fname = "", temp; std::string fname = "", temp;
std::string runno = "_"+to_string(runNum)+m_suffix; std::string runno = "_"+std::to_string(runNum)+m_suffix;
TIter next_element(flist); TIter next_element(flist);
while((file = (TSystemFile*)next_element())) while((file = (TSystemFile*)next_element()))
{ {
@ -93,9 +93,9 @@ std::string RunCollector::GrabFile(int runNum) {
if(temp.size() < m_prefix.size() || temp.size() < runno.size()) if(temp.size() < m_prefix.size() || temp.size() < runno.size())
continue; continue;
else if(!file->IsDirectory() && !temp.compare(0,m_prefix.size(),m_prefix) && else if(!file->IsDirectory() && !temp.compare(0,m_prefix.size(),m_prefix) &&
!temp.compare(temp.size()-(1+runno.size()),runno.size(), runno)) !temp.compare(temp.size()-runno.size(),runno.size(), runno))
{ {
fname = dir+temp; fname = m_directory+temp;
break; break;
} }
} }
@ -105,19 +105,18 @@ std::string RunCollector::GrabFile(int runNum) {
} }
/*Grabs all files within a specified run range*/ /*Grabs all files within a specified run range*/
int RunCollector::GrabFilesInRange() bool RunCollector::GrabFilesInRange()
{ {
if(!m_initFlag) if(!m_initFlag)
return false; return false;
TSystemDirectory sysdir(dir.Data(), dir.Data()); TSystemDirectory sysdir(m_directory.c_str(), m_directory.c_str());
TList *flist = sysdir.GetListOfFiles(); TList *flist = sysdir.GetListOfFiles();
m_filelist.clear(); m_filelist.clear();
int counter = 0;
if(!flist) if(!flist)
{ {
cerr<<"Unable to find any files in directory; check name given to input.txt"<<endl; std::cerr<<"Unable to find any files in directory; check name given to input.txt"<<std::endl;
return false; return false;
} }
@ -127,17 +126,16 @@ int RunCollector::GrabFilesInRange()
for(int i=m_minRun; i<=m_maxRun; i++) //loop over range for(int i=m_minRun; i<=m_maxRun; i++) //loop over range
{ {
TIter next_element(flist);//list iterator TIter next_element(flist);//list iterator
runno = "_"+to_string(i) + m_suffix; //suffix is now _#.suffix runno = "_"+std::to_string(i) + m_suffix; //suffix is now _#.suffix
while((file = (TSystemFile*)next_element())) //look through directory until file found while((file = (TSystemFile*)next_element())) //look through directory until file found
{ {
temp = file->GetName(); temp = file->GetName();
if(temp.size() < m_prefix.size() || temp.size() < runno.size()) if(temp.size() < m_prefix.size() || temp.size() < runno.size())
continue; continue;
else if(!file->IsDirectory() && !temp.compare(0,m_prefix.size(),m_prefix) && else if(!file->IsDirectory() && !temp.compare(0,m_prefix.size(),m_prefix) &&
!temp.compare(temp.size()-(1+runno.size()),runno.size(), runno)) !temp.compare(temp.size()-runno.size(),runno.size(), runno))
{ {
counter++; fname = m_directory+temp;
fname = dir+temp;
m_filelist.push_back(fname); m_filelist.push_back(fname);
break; //if we find the file, break out of iterator loop break; //if we find the file, break out of iterator loop
} }
@ -145,11 +143,11 @@ int RunCollector::GrabFilesInRange()
} }
delete flist; delete flist;
if(counter>0) if(m_filelist.size()>0)
return true; return true;
else else
{ {
cerr<<"Unable to find files with matching run name in directory; check input.txt"<<endl; std::cerr<<"Unable to find files with matching run name in directory; check input.txt"<<std::endl;
return false; return false;
} }
@ -158,18 +156,18 @@ int RunCollector::GrabFilesInRange()
bool RunCollector::Merge_hadd(const std::string& outname) bool RunCollector::Merge_hadd(const std::string& outname)
{ {
if(!m_initFlag) if(!m_initFlag)
false; return false;
if(m_maxRun == 0) if(m_maxRun == 0)
{ {
if(GrabAllFiles()) if(GrabAllFiles())
{ {
std::string clump = "hadd "+outname; std::string clump = "hadd "+outname;
for(unsigned int i=0; i<filelist.size(); i++) for(unsigned int i=0; i<m_filelist.size(); i++)
clump += " "+filelist[i]; clump += " "+m_filelist[i];
cout<<"Merging runs into single file..."<<endl; std::cout<<"Merging runs into single file..."<<std::endl;
std::system(clump); std::system(clump.c_str());
cout<<"Finished merging"<<endl; std::cout<<"Finished merging"<<std::endl;
return true; return true;
} }
else else
@ -180,11 +178,11 @@ bool RunCollector::Merge_hadd(const std::string& outname)
if(GrabFilesInRange()) if(GrabFilesInRange())
{ {
std::string clump = "hadd "+outname; std::string clump = "hadd "+outname;
for(unsigned int i=0; i<filelist.size(); i++) for(unsigned int i=0; i<m_filelist.size(); i++)
clump += " "+filelist[i]; clump += " "+m_filelist[i];
cout<<"Merging runs "<<m_minRun<<" to "<<m_maxRun<<" into a single file..."<<endl; std::cout<<"Merging runs "<<m_minRun<<" to "<<m_maxRun<<" into a single file..."<<std::endl;
system(clump); std::system(clump.c_str());
cout<<"Finished merging"<<endl; std::cout<<"Finished merging"<<std::endl;
return true; return true;
} }
else else
@ -204,10 +202,10 @@ bool RunCollector::Merge_TChain(const std::string& outname)
if(GrabAllFiles()) if(GrabAllFiles())
{ {
for(unsigned int i=0; i<m_filelist.size(); i++) for(unsigned int i=0; i<m_filelist.size(); i++)
chain->Add(m_filelist[i].Data()); chain->Add(m_filelist[i].c_str());
cout<<"Merging runs into single file..."<<endl; std::cout<<"Merging runs into single file..."<<std::endl;
chain->Merge(output,0,"fast"); chain->Merge(output,0,"fast");
cout<<"Finished merging"<<endl; std::cout<<"Finished merging"<<std::endl;
return true; return true;
} }
else else
@ -218,10 +216,10 @@ bool RunCollector::Merge_TChain(const std::string& outname)
if(GrabFilesInRange()) if(GrabFilesInRange())
{ {
for(unsigned int i=0; i<m_filelist.size(); i++) for(unsigned int i=0; i<m_filelist.size(); i++)
chain->Add(m_filelist[i]); chain->Add(m_filelist[i].c_str());
cout<<"Merging runs "<<m_minRun<<" to "<<m_maxRun<<" into a single file..."<<endl; std::cout<<"Merging runs "<<m_minRun<<" to "<<m_maxRun<<" into a single file..."<<std::endl;
chain->Merge(output,0,"fast"); chain->Merge(output,0,"fast");
cout<<"Finished merging"<<endl; std::cout<<"Finished merging"<<std::endl;
return true; return true;
} else } else
return false; return false;

View File

@ -44,7 +44,7 @@ void SFPAnalyzer::GetWeights()
{ {
w1 = (Wire_Dist()/2.0-zfp)/Wire_Dist(); w1 = (Wire_Dist()/2.0-zfp)/Wire_Dist();
w2 = 1.0-w1; w2 = 1.0-w1;
cout<<"w1: "<<w1<<" w2: "<<w2<<endl; std::cout<<"w1: "<<w1<<" w2: "<<w2<<std::endl;
} }
/*2D histogram fill wrapper for use with THashTable (faster)*/ /*2D histogram fill wrapper for use with THashTable (faster)*/
@ -143,7 +143,7 @@ void SFPAnalyzer::AnalyzeEvent(CoincEvent& event)
pevent.fp1_tdiff = (event.focalPlane.delayFL[0].Time-event.focalPlane.delayFR[0].Time)*0.5; 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_tsum = (event.focalPlane.delayFL[0].Time+event.focalPlane.delayFR[0].Time);
pevent.fp1_tcheck = (pevent.fp1_tsum)/2.0-pevent.anodeFrontTime; pevent.fp1_tcheck = (pevent.fp1_tsum)/2.0-pevent.anodeFrontTime;
pevent.delayFrontMaxTime = max(event.focalPlane.delayFL[0].Time, event.focalPlane.delayFR[0].Time); 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 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",1200,-300,300,pevent.x1);
MyFill("x1 vs anodeBack",600,-300,300,pevent.x1,512,0,4096,pevent.anodeBack); MyFill("x1 vs anodeBack",600,-300,300,pevent.x1,512,0,4096,pevent.anodeBack);
@ -153,7 +153,7 @@ void SFPAnalyzer::AnalyzeEvent(CoincEvent& event)
pevent.fp2_tdiff = (event.focalPlane.delayBL[0].Time-event.focalPlane.delayBR[0].Time)*0.5; 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_tsum = (event.focalPlane.delayBL[0].Time+event.focalPlane.delayBR[0].Time);
pevent.fp2_tcheck = (pevent.fp2_tsum)/2.0-pevent.anodeBackTime; pevent.fp2_tcheck = (pevent.fp2_tsum)/2.0-pevent.anodeBackTime;
pevent.delayBackMaxTime = max(event.focalPlane.delayBL[0].Time, event.focalPlane.delayBR[0].Time); 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 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",1200,-300,300,pevent.x2);
MyFill("x2 vs anodeBack",600,-300,300,pevent.x2,512,0,4096,pevent.anodeBack); MyFill("x2 vs anodeBack",600,-300,300,pevent.x2,512,0,4096,pevent.anodeBack);

View File

@ -13,10 +13,7 @@
/*Generates storage and initializes pointers*/ /*Generates storage and initializes pointers*/
SFPPlotter::SFPPlotter() SFPPlotter::SFPPlotter()
{ {
rootObj = new THashTable();
rootObj->SetOwner(false);//THashTable doesnt own members; avoid double delete
event_address = new ProcessedEvent(); event_address = new ProcessedEvent();
chain = new TChain("SPSTree");
m_pb = nullptr; m_pb = nullptr;
} }
@ -29,28 +26,28 @@ SFPPlotter::~SFPPlotter()
void SFPPlotter::MyFill(THashTable* table, const std::string& name, int binsx, double minx, double maxx, double valuex, void SFPPlotter::MyFill(THashTable* table, const std::string& name, int binsx, double minx, double maxx, double valuex,
int binsy, double miny, double maxy, double valuey) int binsy, double miny, double maxy, double valuey)
{ {
TH2F *histo = (TH2F*) rootObj->FindObject(name.c_str()); TH2F *histo = (TH2F*) table->FindObject(name.c_str());
if(histo != nullptr) if(histo != nullptr)
histo->Fill(valuex, valuey); histo->Fill(valuex, valuey);
else else
{ {
TH2F *h = new TH2F(name.c_str(), name.c_str(), binsx, minx, maxx, binsy, miny, maxy); TH2F *h = new TH2F(name.c_str(), name.c_str(), binsx, minx, maxx, binsy, miny, maxy);
h->Fill(valuex, valuey); h->Fill(valuex, valuey);
rootObj->Add(h); table->Add(h);
} }
} }
/*1D histogram fill wrapper*/ /*1D histogram fill wrapper*/
void SFPPlotter::MyFill(THashTable* table, const std::string& name, int binsx, double minx, double maxx, double valuex) void SFPPlotter::MyFill(THashTable* table, const std::string& name, int binsx, double minx, double maxx, double valuex)
{ {
TH1F *histo = (TH1F*) rootObj->FindObject(name.c_str()); TH1F *histo = (TH1F*) table->FindObject(name.c_str());
if(histo != nullptr) if(histo != nullptr)
histo->Fill(valuex); histo->Fill(valuex);
else else
{ {
TH1F *h = new TH1F(name.c_str(), name.c_str(), binsx, minx, maxx); TH1F *h = new TH1F(name.c_str(), name.c_str(), binsx, minx, maxx);
h->Fill(valuex); h->Fill(valuex);
rootObj->Add(h); table->Add(h);
} }
} }
@ -247,12 +244,12 @@ void SFPPlotter::Run(const std::vector<std::string>& files, const std::string& o
for(unsigned int i=0; i<files.size(); i++) for(unsigned int i=0; i<files.size(); i++)
chain->Add(files[i].c_str()); chain->Add(files[i].c_str());
chain->SetBranchAddress("event", &event_address); chain->SetBranchAddress("event", &event_address);
THastTable* table = new THashTable(); THashTable* table = new THashTable();
long blentries = chain->GetEntries(); long blentries = chain->GetEntries();
if(m_pb) if(m_pb)
SetProgressBar(blentries); SetProgressBar(blentries);
cout<<"Total number of events: "<<blentries<<endl; std::cout<<"Total number of events: "<<blentries<<std::endl;
long count=0, flush_val=blentries*0.01, flush_count=0; long count=0, flush_val=blentries*0.01, flush_count=0;
@ -272,19 +269,19 @@ void SFPPlotter::Run(const std::vector<std::string>& files, const std::string& o
} }
} }
chain->GetEntry(i); chain->GetEntry(i);
MakeUncutHistograms(*event_address); MakeUncutHistograms(*event_address, table);
if(cutter.IsValid()) MakeCutHistograms(*event_address); if(cutter.IsValid()) MakeCutHistograms(*event_address, table);
} }
cout<<endl; std::cout<<std::endl;
outfile->cd(); outfile->cd();
rootObj->Write(); table->Write();
if(cutter.IsValid()) if(cutter.IsValid())
{ {
auto clist = cutter.GetCuts(); auto clist = cutter.GetCuts();
for(unsigned int i=0; i<clist.size(); i++) for(unsigned int i=0; i<clist.size(); i++)
clist[i]->Write(); clist[i]->Write();
} }
delete rootObj; delete table;
outfile->Close(); outfile->Close();
delete outfile; delete outfile;
} }

View File

@ -11,59 +11,67 @@
#include "SlowSort.h" #include "SlowSort.h"
/*Sort the Sabre Data in order of descending energy*/ /*Sort the Sabre Data in order of descending energy*/
bool SabreSort(DetectorHit i, DetectorHit j) { bool SabreSort(const DetectorHit& i, const DetectorHit& j) {
return (i.Long>j.Long); return (i.Long>j.Long);
} }
/*Constructor takes input of coincidence window size, and fills sabre channel map*/ /*Constructor takes input of coincidence window size, and fills sabre channel map*/
SlowSort::SlowSort() : SlowSort::SlowSort() :
coincWindow(-1.0), eventFlag(false), event(), cmap() m_coincWindow(-1.0), m_eventFlag(false)
{ {
event_stats = new TH2F("coinc_event_stats","coinc_events_stats;global channel;number of coincident hits;counts",144,0,144,20,0,20); event_stats = new TH2F("coinc_event_stats","coinc_events_stats;global channel;number of coincident hits;counts",144,0,144,20,0,20);
} }
SlowSort::SlowSort(double windowSize, const string& mapfile) : SlowSort::SlowSort(double windowSize, const std::string& mapfile) :
coincWindow(windowSize), eventFlag(false), event(), cmap(mapfile) m_coincWindow(windowSize), m_eventFlag(false), m_event(), cmap(mapfile)
{ {
event_stats = new TH2F("coinc_event_stats","coinc_events_stats;global channel;number of coincident hits;counts",144,0,144,20,0,20); event_stats = new TH2F("coinc_event_stats","coinc_events_stats;global channel;number of coincident hits;counts",144,0,144,20,0,20);
InitVariableMaps(); InitVariableMaps();
} }
SlowSort::~SlowSort() { SlowSort::~SlowSort() {}
}
/**EXPERIMENT MODS go here**/ /**EXPERIMENT MODS go here**/
void SlowSort::InitVariableMaps() { void SlowSort::InitVariableMaps()
{
/*For SABRE: Each SABRE det has ring&wedge, so add the detID to the /*For SABRE: Each SABRE det has ring&wedge, so add the detID to the
SABRERING/WEDGE attribute to differentiate*/ SABRERING/WEDGE attribute to differentiate*/
for(int i=0; i<5; i++) { varMap[DetAttribute::SabreRing0] = &m_event.sabreArray[0].rings;
sabreVMap[SABRERING + i] = &event.sabreArray[i].rings; varMap[DetAttribute::SabreRing1] = &m_event.sabreArray[1].rings;
sabreVMap[SABREWEDGE + i] = &event.sabreArray[i].wedges; 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 /*For focal plane: Only one focal plane, so each variable is uniquely
identified by its attribute identified by its attribute
*/ */
fpVMap[SCINTLEFT] = &event.focalPlane.scintL; varMap[DetAttribute::ScintLeft] = &m_event.focalPlane.scintL;
fpVMap[SCINTRIGHT] = &event.focalPlane.scintR; varMap[DetAttribute::ScintRight] = &m_event.focalPlane.scintR;
fpVMap[CATHODE] = &event.focalPlane.cathode; varMap[DetAttribute::Cathode] = &m_event.focalPlane.cathode;
fpVMap[DELAYFR] = &event.focalPlane.delayFR; varMap[DetAttribute::DelayFR] = &m_event.focalPlane.delayFR;
fpVMap[DELAYFL] = &event.focalPlane.delayFL; varMap[DetAttribute::DelayFL] = &m_event.focalPlane.delayFL;
fpVMap[DELAYBL] = &event.focalPlane.delayBL; varMap[DetAttribute::DelayBL] = &m_event.focalPlane.delayBL;
fpVMap[DELAYBR] = &event.focalPlane.delayBR; varMap[DetAttribute::DelayBR] = &m_event.focalPlane.delayBR;
fpVMap[ANODEFRONT] = &event.focalPlane.anodeF; varMap[DetAttribute::AnodeFront] = &m_event.focalPlane.anodeF;
fpVMap[ANODEBACK] = &event.focalPlane.anodeB; varMap[DetAttribute::AnodeBack] = &m_event.focalPlane.anodeB;
fpVMap[MONITOR] = &event.focalPlane.monitor; varMap[DetAttribute::Monitor] = &m_event.focalPlane.monitor;
} }
/*Reset output structure to blank*/ /*Reset output structure to blank*/
void SlowSort::Reset() { void SlowSort::Reset()
event = blank; {
m_event = m_blank;
} }
bool SlowSort::AddHitToEvent(CompassHit& mhit) { bool SlowSort::AddHitToEvent(CompassHit& mhit)
{
DPPChannel curHit; DPPChannel curHit;
curHit.Timestamp = mhit.timestamp; curHit.Timestamp = mhit.timestamp;
curHit.Energy = mhit.lgate; curHit.Energy = mhit.lgate;
@ -72,58 +80,57 @@ bool SlowSort::AddHitToEvent(CompassHit& mhit) {
curHit.Board = mhit.board; curHit.Board = mhit.board;
curHit.Flags = mhit.flags; curHit.Flags = mhit.flags;
if(hitList.empty()) { if(m_hitList.empty())
{
startTime = curHit.Timestamp; startTime = curHit.Timestamp;
hitList.push_back(curHit); m_hitList.push_back(curHit);
} else if (curHit.Timestamp < previousHitTime) { }
else if (curHit.Timestamp < previousHitTime)
return false; return false;
} else if ((curHit.Timestamp - startTime) < coincWindow) { else if ((curHit.Timestamp - startTime) < m_coincWindow)
hitList.push_back(curHit); m_hitList.push_back(curHit);
} else { else
{
ProcessEvent(); ProcessEvent();
hitList.clear(); m_hitList.clear();
startTime = curHit.Timestamp; startTime = curHit.Timestamp;
hitList.push_back(curHit); m_hitList.push_back(curHit);
eventFlag = true; m_eventFlag = true;
} }
return true; return true;
} }
void SlowSort::FlushHitsToEvent() { void SlowSort::FlushHitsToEvent()
if(hitList.empty()) { {
eventFlag = false; if(m_hitList.empty())
{
m_eventFlag = false;
return; return;
} }
ProcessEvent(); ProcessEvent();
hitList.clear(); m_hitList.clear();
eventFlag = true; m_eventFlag = true;
} }
CoincEvent SlowSort::GetEvent() { const CoincEvent& SlowSort::GetEvent()
eventFlag = false; {
return event; m_eventFlag = false;
} return m_event;
/*Function called when a start of a coincidence event is detected*/
void SlowSort::StartEvent() {
if(hitList.size() != 0) {
cerr<<"Attempting to initalize hitList when not cleared!! Check processing order."<<endl;
}
startTime = hit.Timestamp;
hitList.push_back(hit);
} }
/*Function called when an event outside the coincidence window is detected /*Function called when an event outside the coincidence window is detected
*Process all of the hits in the list, and write them to the sorted tree *Process all of the hits in the list, and write them to the sorted tree
*/ */
void SlowSort::ProcessEvent() { void SlowSort::ProcessEvent()
{
Reset(); Reset();
DetectorHit dhit; DetectorHit dhit;
int gchan; int gchan;
int size = hitList.size(); int size = m_hitList.size();
for(DPPChannel& curHit: hitList) { for(DPPChannel& curHit: m_hitList)
{
gchan = curHit.Channel + curHit.Board*16; //global channel gchan = curHit.Channel + curHit.Board*16; //global channel
event_stats->Fill(gchan, size); event_stats->Fill(gchan, size);
dhit.Time = curHit.Timestamp/1.0e3; dhit.Time = curHit.Timestamp/1.0e3;
@ -131,36 +138,43 @@ void SlowSort::ProcessEvent() {
dhit.Long = curHit.Energy; dhit.Long = curHit.Energy;
dhit.Short = curHit.EnergyShort; dhit.Short = curHit.EnergyShort;
auto channel_info = cmap.FindChannel(gchan); auto channel_info = cmap.FindChannel(gchan);
if(channel_info == cmap.End()) {
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; continue;
} }
if(channel_info->second.detectorType == SABRERING || channel_info->second.detectorType == SABREWEDGE) {
auto variable = sabreVMap.find(channel_info->second.detectorType + channel_info->second.detectorID); if(channel_info->second.type == DetType::FocalPlane)
if(variable != sabreVMap.end()) { {
auto variable = varMap.find(channel_info->second.attribute);
if(variable != varMap.end())
variable->second->push_back(dhit); variable->second->push_back(dhit);
} }
else if(channel_info->second.type == DetType::Sabre)
} else if(channel_info->second.detectorType == FOCALPLANE) { {
auto variable = varMap.find(channel_info->second.attribute);
auto variable = fpVMap.find(channel_info->second.detectorPart); if(variable != varMap.end())
if(variable != fpVMap.end()) {
variable->second->push_back(dhit); variable->second->push_back(dhit);
} }
else
} else { {
std::cout<<std::endl; std::cout<<std::endl;
std::cout<<"------Data Assignment Error!-------"<<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<<"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.detectorType<<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<<"Skipping this hit..."<<std::endl;
std::cout<<"-----------------------------------"<<std::endl; std::cout<<"-----------------------------------"<<std::endl;
} }
} }
//Organize the SABRE data in descending energy order //Organize the SABRE data in descending energy order
for(int s=0; s<5; s++) { for(int s=0; s<5; s++)
sort(event.sabreArray[s].rings.begin(), event.sabreArray[s].rings.end(), SabreSort); {
sort(event.sabreArray[s].wedges.begin(), event.sabreArray[s].wedges.end(), SabreSort); sort(m_event.sabreArray[s].rings.begin(), m_event.sabreArray[s].rings.end(), SabreSort);
sort(m_event.sabreArray[s].wedges.begin(), m_event.sabreArray[s].wedges.end(), SabreSort);
} }
} }

View File

@ -28,7 +28,7 @@ EVBMainFrame::EVBMainFrame(const TGWindow* p, UInt_t w, UInt_t h) :
TGHorizontalFrame *WorkFrame = new TGHorizontalFrame(NameFrame, w, h*0.1); TGHorizontalFrame *WorkFrame = new TGHorizontalFrame(NameFrame, w, h*0.1);
TGLabel* workLabel = new TGLabel(WorkFrame, "Workspace Directory:"); TGLabel* workLabel = new TGLabel(WorkFrame, "Workspace Directory:");
fWorkField = new TGTextEntry(WorkFrame, new TGTextBuffer(120), WORKDIR); fWorkField = new TGTextEntry(WorkFrame, new TGTextBuffer(120), WorkDir);
fWorkField->Resize(w*0.25, fWorkField->GetDefaultHeight()); fWorkField->Resize(w*0.25, fWorkField->GetDefaultHeight());
fWorkField->Connect("ReturnPressed()","EVBMainFrame",this,"UpdateWorkdir()"); fWorkField->Connect("ReturnPressed()","EVBMainFrame",this,"UpdateWorkdir()");
fOpenWorkButton = new TGTextButton(WorkFrame, "Open"); fOpenWorkButton = new TGTextButton(WorkFrame, "Open");
@ -39,7 +39,7 @@ EVBMainFrame::EVBMainFrame(const TGWindow* p, UInt_t w, UInt_t h) :
TGHorizontalFrame *CMapFrame = new TGHorizontalFrame(NameFrame, w, h*0.1); TGHorizontalFrame *CMapFrame = new TGHorizontalFrame(NameFrame, w, h*0.1);
TGLabel* cmaplabel = new TGLabel(CMapFrame, "Channel Map File:"); TGLabel* cmaplabel = new TGLabel(CMapFrame, "Channel Map File:");
fCMapField = new TGTextEntry(CMapFrame, new TGTextBuffer(120), CMAP); fCMapField = new TGTextEntry(CMapFrame, new TGTextBuffer(120), Cmap);
fCMapField->Resize(w*0.25, fCMapField->GetDefaultHeight()); fCMapField->Resize(w*0.25, fCMapField->GetDefaultHeight());
fCMapField->Connect("ReturnPressed()","EVBMainFrame",this,"UpdateCMap()"); fCMapField->Connect("ReturnPressed()","EVBMainFrame",this,"UpdateCMap()");
fOpenCMapButton = new TGTextButton(CMapFrame, "Open"); fOpenCMapButton = new TGTextButton(CMapFrame, "Open");
@ -50,7 +50,7 @@ EVBMainFrame::EVBMainFrame(const TGWindow* p, UInt_t w, UInt_t h) :
TGHorizontalFrame *SMapFrame = new TGHorizontalFrame(NameFrame, w, h*0.1); TGHorizontalFrame *SMapFrame = new TGHorizontalFrame(NameFrame, w, h*0.1);
TGLabel* smaplabel = new TGLabel(SMapFrame, "Board Shift File:"); TGLabel* smaplabel = new TGLabel(SMapFrame, "Board Shift File:");
fSMapField = new TGTextEntry(SMapFrame, new TGTextBuffer(120), SMAP); fSMapField = new TGTextEntry(SMapFrame, new TGTextBuffer(120), Smap);
fSMapField->Resize(w*0.25, fSMapField->GetDefaultHeight()); fSMapField->Resize(w*0.25, fSMapField->GetDefaultHeight());
fSMapField->Connect("ReturnPressed()","EVBMainFrame",this,"UpdateSMap()"); fSMapField->Connect("ReturnPressed()","EVBMainFrame",this,"UpdateSMap()");
fOpenSMapButton = new TGTextButton(SMapFrame, "Open"); fOpenSMapButton = new TGTextButton(SMapFrame, "Open");
@ -61,7 +61,7 @@ EVBMainFrame::EVBMainFrame(const TGWindow* p, UInt_t w, UInt_t h) :
TGHorizontalFrame *ScalerFrame = new TGHorizontalFrame(NameFrame, w, h*0.1); TGHorizontalFrame *ScalerFrame = new TGHorizontalFrame(NameFrame, w, h*0.1);
TGLabel* sclabel = new TGLabel(ScalerFrame, "Scaler File: "); TGLabel* sclabel = new TGLabel(ScalerFrame, "Scaler File: ");
fScalerField = new TGTextEntry(ScalerFrame, new TGTextBuffer(120), SCALER); fScalerField = new TGTextEntry(ScalerFrame, new TGTextBuffer(120), Scaler);
fScalerField->Connect("ReturnPressed()","EVBMainFrame",this,"UpdateScaler()"); fScalerField->Connect("ReturnPressed()","EVBMainFrame",this,"UpdateScaler()");
fOpenScalerButton = new TGTextButton(ScalerFrame, "Open"); fOpenScalerButton = new TGTextButton(ScalerFrame, "Open");
fOpenScalerButton->Connect("Clicked()","EVBMainFrame", this, "DoOpenScalerfile()"); fOpenScalerButton->Connect("Clicked()","EVBMainFrame", this, "DoOpenScalerfile()");
@ -71,7 +71,7 @@ EVBMainFrame::EVBMainFrame(const TGWindow* p, UInt_t w, UInt_t h) :
TGHorizontalFrame *CutFrame = new TGHorizontalFrame(NameFrame, w, h*0.1); TGHorizontalFrame *CutFrame = new TGHorizontalFrame(NameFrame, w, h*0.1);
TGLabel* clabel = new TGLabel(CutFrame, "Cut List: "); TGLabel* clabel = new TGLabel(CutFrame, "Cut List: ");
fCutField = new TGTextEntry(CutFrame, new TGTextBuffer(120), CUT); fCutField = new TGTextEntry(CutFrame, new TGTextBuffer(120), Cut);
fCutField->Connect("ReturnPressed()","EVBMainFrame",this,"UpdateCut()"); fCutField->Connect("ReturnPressed()","EVBMainFrame",this,"UpdateCut()");
fOpenCutButton = new TGTextButton(CutFrame, "Open"); fOpenCutButton = new TGTextButton(CutFrame, "Open");
fOpenCutButton->Connect("Clicked()","EVBMainFrame",this,"DoOpenCutfile()"); fOpenCutButton->Connect("Clicked()","EVBMainFrame",this,"DoOpenCutfile()");
@ -88,11 +88,11 @@ EVBMainFrame::EVBMainFrame(const TGWindow* p, UInt_t w, UInt_t h) :
TGHorizontalFrame *ParamFrame = new TGHorizontalFrame(InputFrame, w, h*0.1); TGHorizontalFrame *ParamFrame = new TGHorizontalFrame(InputFrame, w, h*0.1);
TGLabel *bkelabel = new TGLabel(ParamFrame, "Beam KE (MeV):"); TGLabel *bkelabel = new TGLabel(ParamFrame, "Beam KE (MeV):");
fBKEField = new TGNumberEntryField(ParamFrame, BKE, 0, TGNumberEntry::kNESRealFour, TGNumberEntry::kNEANonNegative); fBKEField = new TGNumberEntryField(ParamFrame, Bke, 0, TGNumberEntry::kNESRealFour, TGNumberEntry::kNEANonNegative);
TGLabel *bfieldlabel = new TGLabel(ParamFrame, "B-Field (G):"); TGLabel *bfieldlabel = new TGLabel(ParamFrame, "B-Field (G):");
fBField = new TGNumberEntryField(ParamFrame, BFIELD, 0, TGNumberEntry::kNESRealFour, TGNumberEntry::kNEANonNegative); fBField = new TGNumberEntryField(ParamFrame, BField, 0, TGNumberEntry::kNESRealFour, TGNumberEntry::kNEANonNegative);
TGLabel *thetalabel = new TGLabel(ParamFrame, "Angle (deg):"); TGLabel *thetalabel = new TGLabel(ParamFrame, "Angle (deg):");
fThetaField = new TGNumberEntryField(ParamFrame, THETA, 0, TGNumberEntry::kNESRealFour, TGNumberEntry::kNEANonNegative); fThetaField = new TGNumberEntryField(ParamFrame, Theta, 0, TGNumberEntry::kNESRealFour, TGNumberEntry::kNEANonNegative);
TGLabel *ztlabel = new TGLabel(ParamFrame, "ZT:"); TGLabel *ztlabel = new TGLabel(ParamFrame, "ZT:");
fZTField = new TGNumberEntryField(ParamFrame, ZT, 0, TGNumberEntry::kNESInteger, TGNumberEntry::kNEANonNegative); fZTField = new TGNumberEntryField(ParamFrame, ZT, 0, TGNumberEntry::kNESInteger, TGNumberEntry::kNEANonNegative);
TGLabel *atlabel = new TGLabel(ParamFrame, "AT:"); TGLabel *atlabel = new TGLabel(ParamFrame, "AT:");
@ -126,11 +126,11 @@ EVBMainFrame::EVBMainFrame(const TGWindow* p, UInt_t w, UInt_t h) :
TGHorizontalFrame *WindowFrame = new TGHorizontalFrame(InputFrame, w, h*0.1); TGHorizontalFrame *WindowFrame = new TGHorizontalFrame(InputFrame, w, h*0.1);
TGLabel *slowlabel = new TGLabel(WindowFrame, "Slow Coincidence Window (ps):"); TGLabel *slowlabel = new TGLabel(WindowFrame, "Slow Coincidence Window (ps):");
fSlowWindowField = new TGNumberEntryField(WindowFrame, SLOWWIND, 0, TGNumberEntry::kNESReal, TGNumberEntry::kNEANonNegative); fSlowWindowField = new TGNumberEntryField(WindowFrame, SlowWind, 0, TGNumberEntry::kNESReal, TGNumberEntry::kNEANonNegative);
TGLabel *fasticlabel = new TGLabel(WindowFrame, "Fast Coincidence Window IC (ps):"); TGLabel *fasticlabel = new TGLabel(WindowFrame, "Fast Coincidence Window IC (ps):");
fFastICField = new TGNumberEntryField(WindowFrame, FASTWIND_IC, 0, TGNumberEntry::kNESReal, TGNumberEntry::kNEANonNegative); fFastICField = new TGNumberEntryField(WindowFrame, FastWind_IC, 0, TGNumberEntry::kNESReal, TGNumberEntry::kNEANonNegative);
TGLabel *fastsabrelabel = new TGLabel(WindowFrame, "Fast Coincidence Window SABRE (ps):"); TGLabel *fastsabrelabel = new TGLabel(WindowFrame, "Fast Coincidence Window SABRE (ps):");
fFastSABREField = new TGNumberEntryField(WindowFrame, FASTWIND_SABRE, 0, TGNumberEntry::kNESReal, TGNumberEntry::kNEANonNegative); fFastSABREField = new TGNumberEntryField(WindowFrame, FastWind_Sabre, 0, TGNumberEntry::kNESReal, TGNumberEntry::kNEANonNegative);
WindowFrame->AddFrame(slowlabel, lhints); WindowFrame->AddFrame(slowlabel, lhints);
WindowFrame->AddFrame(fSlowWindowField, fhints); WindowFrame->AddFrame(fSlowWindowField, fhints);
WindowFrame->AddFrame(fasticlabel, lhints); WindowFrame->AddFrame(fasticlabel, lhints);
@ -140,21 +140,21 @@ EVBMainFrame::EVBMainFrame(const TGWindow* p, UInt_t w, UInt_t h) :
TGHorizontalFrame *RunFrame = new TGHorizontalFrame(InputFrame, w, h*0.1); TGHorizontalFrame *RunFrame = new TGHorizontalFrame(InputFrame, w, h*0.1);
TGLabel *typelabel = new TGLabel(RunFrame, "Operation Type:"); TGLabel *typelabel = new TGLabel(RunFrame, "Operation Type:");
fTypeBox = new TGComboBox(RunFrame, TYPEBOX); fTypeBox = new TGComboBox(RunFrame, TypeBox);
//Needs modification for new conversion based sorting GWM -- Dec 2020 //Needs modification for new conversion based sorting GWM -- Dec 2020
fTypeBox->AddEntry("Convert Slow", GWMEventBuilder::CONVERT_S); fTypeBox->AddEntry("Convert Slow", EVBApp::Operation::ConvertSlow);
fTypeBox->AddEntry("Convert Fast", GWMEventBuilder::CONVERT_F); fTypeBox->AddEntry("Convert Fast", EVBApp::Operation::ConvertFast);
fTypeBox->AddEntry("Convert SlowA", GWMEventBuilder::CONVERT_SA); fTypeBox->AddEntry("Convert SlowA", EVBApp::Operation::ConvertSlowA);
fTypeBox->AddEntry("Convert FastA", GWMEventBuilder::CONVERT_FA); fTypeBox->AddEntry("Convert FastA", EVBApp::Operation::ConvertFastA);
fTypeBox->AddEntry("Convert", GWMEventBuilder::CONVERT); fTypeBox->AddEntry("Convert", EVBApp::Operation::Convert);
fTypeBox->AddEntry("Merge ROOT", GWMEventBuilder::MERGE); fTypeBox->AddEntry("Merge ROOT", EVBApp::Operation::Merge);
fTypeBox->AddEntry("Plot", GWMEventBuilder::PLOT); fTypeBox->AddEntry("Plot", EVBApp::Operation::Plot);
fTypeBox->Resize(200,20); fTypeBox->Resize(200,20);
fTypeBox->Connect("Selected(Int_t, Int_t)","EVBMainFrame",this,"HandleTypeSelection(Int_t,Int_t)"); fTypeBox->Connect("Selected(Int_t, Int_t)","EVBMainFrame",this,"HandleTypeSelection(Int_t,Int_t)");
TGLabel *rminlabel = new TGLabel(RunFrame, "Min Run:"); TGLabel *rminlabel = new TGLabel(RunFrame, "Min Run:");
fRMinField = new TGNumberEntryField(RunFrame, RMIN, 0, TGNumberEntry::kNESInteger, TGNumberEntry::kNEANonNegative); fRMinField = new TGNumberEntryField(RunFrame, RMin, 0, TGNumberEntry::kNESInteger, TGNumberEntry::kNEANonNegative);
TGLabel *rmaxlabel = new TGLabel(RunFrame, "Max Run:"); TGLabel *rmaxlabel = new TGLabel(RunFrame, "Max Run:");
fRMaxField = new TGNumberEntryField(RunFrame, RMAX, 0, TGNumberEntry::kNESInteger, TGNumberEntry::kNEANonNegative); fRMaxField = new TGNumberEntryField(RunFrame, RMax, 0, TGNumberEntry::kNESInteger, TGNumberEntry::kNEANonNegative);
fRunButton = new TGTextButton(RunFrame, "Run!"); fRunButton = new TGTextButton(RunFrame, "Run!");
fRunButton->SetState(kButtonDisabled); fRunButton->SetState(kButtonDisabled);
fRunButton->Connect("Clicked()","EVBMainFrame",this,"DoRun()"); fRunButton->Connect("Clicked()","EVBMainFrame",this,"DoRun()");
@ -182,9 +182,9 @@ EVBMainFrame::EVBMainFrame(const TGWindow* p, UInt_t w, UInt_t h) :
TGMenuBar* menuBar = new TGMenuBar(this, w, h*0.1); TGMenuBar* menuBar = new TGMenuBar(this, w, h*0.1);
fFileMenu = new TGPopupMenu(gClient->GetRoot()); fFileMenu = new TGPopupMenu(gClient->GetRoot());
fFileMenu->AddEntry("Load...", M_LOAD_CONFIG); fFileMenu->AddEntry("Load...", M_Load_Config);
fFileMenu->AddEntry("Save...", M_SAVE_CONFIG); fFileMenu->AddEntry("Save...", M_Save_Config);
fFileMenu->AddEntry("Exit", M_EXIT); fFileMenu->AddEntry("Exit", M_Exit);
fFileMenu->Connect("Activated(Int_t)","EVBMainFrame", this, "HandleMenuSelection(Int_t)"); fFileMenu->Connect("Activated(Int_t)","EVBMainFrame", this, "HandleMenuSelection(Int_t)");
menuBar->AddPopup("File", fFileMenu, mhints); menuBar->AddPopup("File", fFileMenu, mhints);
@ -199,82 +199,94 @@ EVBMainFrame::EVBMainFrame(const TGWindow* p, UInt_t w, UInt_t h) :
} }
EVBMainFrame::~EVBMainFrame() { EVBMainFrame::~EVBMainFrame()
{
Cleanup(); Cleanup();
delete this; delete this;
} }
void EVBMainFrame::CloseWindow() { void EVBMainFrame::CloseWindow()
{
gApplication->Terminate(); gApplication->Terminate();
} }
void EVBMainFrame::HandleMenuSelection(int id) { void EVBMainFrame::HandleMenuSelection(int id)
if(id == M_SAVE_CONFIG) new FileViewFrame(gClient->GetRoot(), this, MAIN_W*0.5, MAIN_H*0.25, this, M_SAVE_CONFIG); {
else if(id == M_LOAD_CONFIG) new FileViewFrame(gClient->GetRoot(), this, MAIN_W*0.5, MAIN_H*0.25, this, M_LOAD_CONFIG); if(id == M_Save_Config)
else if(id == M_EXIT) CloseWindow(); new FileViewFrame(gClient->GetRoot(), this, MAIN_W*0.5, MAIN_H*0.25, this, M_Save_Config);
else if(id == M_Load_Config)
new FileViewFrame(gClient->GetRoot(), this, MAIN_W*0.5, MAIN_H*0.25, this, M_Load_Config);
else if(id == M_Exit)
CloseWindow();
} }
void EVBMainFrame::DoOpenWorkdir() { void EVBMainFrame::DoOpenWorkdir()
new FileViewFrame(gClient->GetRoot(), this, MAIN_W*0.5, MAIN_H*0.25, this, WORKDIR); {
new FileViewFrame(gClient->GetRoot(), this, MAIN_W*0.5, MAIN_H*0.25, this, WorkDir);
} }
void EVBMainFrame::DoOpenCMapfile() { void EVBMainFrame::DoOpenCMapfile()
new FileViewFrame(gClient->GetRoot(), this, MAIN_W*0.5, MAIN_H*0.25, this, CMAP); {
new FileViewFrame(gClient->GetRoot(), this, MAIN_W*0.5, MAIN_H*0.25, this, Cmap);
} }
void EVBMainFrame::DoOpenSMapfile() { void EVBMainFrame::DoOpenSMapfile()
new FileViewFrame(gClient->GetRoot(), this, MAIN_W*0.5, MAIN_H*0.25, this, SMAP); {
new FileViewFrame(gClient->GetRoot(), this, MAIN_W*0.5, MAIN_H*0.25, this, Smap);
} }
void EVBMainFrame::DoOpenScalerfile() { void EVBMainFrame::DoOpenScalerfile()
new FileViewFrame(gClient->GetRoot(), this, MAIN_W*0.5, MAIN_H*0.25, this, SCALER); {
new FileViewFrame(gClient->GetRoot(), this, MAIN_W*0.5, MAIN_H*0.25, this, Scaler);
} }
void EVBMainFrame::DoOpenCutfile() { void EVBMainFrame::DoOpenCutfile()
new FileViewFrame(gClient->GetRoot(), this, MAIN_W*0.5, MAIN_H*0.25, this, CUT); {
new FileViewFrame(gClient->GetRoot(), this, MAIN_W*0.5, MAIN_H*0.25, this, Cut);
} }
void EVBMainFrame::DoRun() { void EVBMainFrame::DoRun()
{
DisableAllInput(); DisableAllInput();
SetParameters(); SetParameters();
int type = fTypeBox->GetSelected(); int type = fTypeBox->GetSelected();
fBuilder.SetAnalysisType(type);
switch(type) { switch(type)
case GWMEventBuilder::PLOT : {
case EVBApp::Operation::Plot :
{ {
RunPlot(); RunPlot();
break; break;
} }
case GWMEventBuilder::CONVERT : case EVBApp::Operation::Convert :
{ {
fBuilder.Convert2RawRoot(); fBuilder.Convert2RawRoot();
break; break;
} }
case GWMEventBuilder::MERGE : case EVBApp::Operation::Merge :
{ {
fBuilder.MergeROOTFiles(); fBuilder.MergeROOTFiles();
break; break;
} }
case GWMEventBuilder::CONVERT_S : case EVBApp::Operation::ConvertSlow :
{ {
fBuilder.Convert2SortedRoot(); fBuilder.Convert2SortedRoot();
break; break;
} }
case GWMEventBuilder::CONVERT_F : case EVBApp::Operation::ConvertFast :
{ {
fBuilder.Convert2FastSortedRoot(); fBuilder.Convert2FastSortedRoot();
break; break;
} }
case GWMEventBuilder::CONVERT_SA : case EVBApp::Operation::ConvertSlowA :
{ {
fBuilder.Convert2SlowAnalyzedRoot(); fBuilder.Convert2SlowAnalyzedRoot();
break; break;
} }
case GWMEventBuilder::CONVERT_FA : case EVBApp::Operation::ConvertFastA :
{ {
fBuilder.Convert2FastAnalyzedRoot(); fBuilder.Convert2FastAnalyzedRoot();
break; break;
@ -284,11 +296,13 @@ void EVBMainFrame::DoRun() {
EnableAllInput(); EnableAllInput();
} }
void EVBMainFrame::HandleTypeSelection(int box, int entry) { void EVBMainFrame::HandleTypeSelection(int box, int entry)
{
fRunButton->SetState(kButtonUp); fRunButton->SetState(kButtonUp);
} }
bool EVBMainFrame::SetParameters() { bool EVBMainFrame::SetParameters()
{
fBuilder.SetRunRange(fRMinField->GetIntNumber(), fRMaxField->GetIntNumber()); fBuilder.SetRunRange(fRMinField->GetIntNumber(), fRMaxField->GetIntNumber());
fBuilder.SetSlowCoincidenceWindow(fSlowWindowField->GetNumber()); fBuilder.SetSlowCoincidenceWindow(fSlowWindowField->GetNumber());
fBuilder.SetFastWindowIonChamber(fFastICField->GetNumber()); fBuilder.SetFastWindowIonChamber(fFastICField->GetNumber());
@ -306,37 +320,44 @@ bool EVBMainFrame::SetParameters() {
return test; return test;
} }
void EVBMainFrame::DisplayWorkdir(const char* dir) { void EVBMainFrame::DisplayWorkdir(const char* dir)
{
fWorkField->SetText(dir); fWorkField->SetText(dir);
fBuilder.SetWorkDirectory(dir); fBuilder.SetWorkDirectory(dir);
} }
void EVBMainFrame::DisplayCMap(const char* file) { void EVBMainFrame::DisplayCMap(const char* file)
{
fCMapField->SetText(file); fCMapField->SetText(file);
fBuilder.SetChannelMap(file); fBuilder.SetChannelMap(file);
} }
void EVBMainFrame::DisplaySMap(const char* file) { void EVBMainFrame::DisplaySMap(const char* file)
{
fSMapField->SetText(file); fSMapField->SetText(file);
fBuilder.SetBoardShiftFile(file); fBuilder.SetBoardShiftFile(file);
} }
void EVBMainFrame::DisplayScaler(const char* file) { void EVBMainFrame::DisplayScaler(const char* file)
{
fScalerField->SetText(file); fScalerField->SetText(file);
fBuilder.SetScalerFile(file); fBuilder.SetScalerFile(file);
} }
void EVBMainFrame::DisplayCut(const char* file) { void EVBMainFrame::DisplayCut(const char* file)
{
fCutField->SetText(file); fCutField->SetText(file);
fBuilder.SetCutList(file); fBuilder.SetCutList(file);
} }
void EVBMainFrame::SaveConfig(const char* file) { void EVBMainFrame::SaveConfig(const char* file)
{
std::string filename = file; std::string filename = file;
fBuilder.WriteConfigFile(filename); fBuilder.WriteConfigFile(filename);
} }
void EVBMainFrame::LoadConfig(const char* file) { void EVBMainFrame::LoadConfig(const char* file)
{
std::string filename = file; std::string filename = file;
fBuilder.ReadConfigFile(filename); fBuilder.ReadConfigFile(filename);
@ -365,38 +386,45 @@ void EVBMainFrame::LoadConfig(const char* file) {
} }
void EVBMainFrame::UpdateWorkdir() { void EVBMainFrame::UpdateWorkdir()
{
const char* dir = fWorkField->GetText(); const char* dir = fWorkField->GetText();
fBuilder.SetWorkDirectory(dir); fBuilder.SetWorkDirectory(dir);
} }
void EVBMainFrame::UpdateSMap() { void EVBMainFrame::UpdateSMap()
{
const char* file = fSMapField->GetText(); const char* file = fSMapField->GetText();
fBuilder.SetBoardShiftFile(file); fBuilder.SetBoardShiftFile(file);
} }
void EVBMainFrame::UpdateCMap() { void EVBMainFrame::UpdateCMap()
{
const char* file = fCMapField->GetText(); const char* file = fCMapField->GetText();
fBuilder.SetChannelMap(file); fBuilder.SetChannelMap(file);
} }
void EVBMainFrame::UpdateScaler() { void EVBMainFrame::UpdateScaler()
{
const char* file = fScalerField->GetText(); const char* file = fScalerField->GetText();
fBuilder.SetScalerFile(file); fBuilder.SetScalerFile(file);
} }
void EVBMainFrame::UpdateCut() { void EVBMainFrame::UpdateCut()
{
const char* file = fCutField->GetText(); const char* file = fCutField->GetText();
fBuilder.SetCutList(file); fBuilder.SetCutList(file);
} }
void EVBMainFrame::RunPlot() { void EVBMainFrame::RunPlot()
{
fBuilder.PlotHistograms(); fBuilder.PlotHistograms();
} }
void EVBMainFrame::RunMerge(const char* file, const char* dir) {} void EVBMainFrame::RunMerge(const char* file, const char* dir) {}
void EVBMainFrame::DisableAllInput() { void EVBMainFrame::DisableAllInput()
{
fRunButton->SetState(kButtonDisabled); fRunButton->SetState(kButtonDisabled);
fOpenWorkButton->SetState(kButtonDisabled); fOpenWorkButton->SetState(kButtonDisabled);
fOpenCMapButton->SetState(kButtonDisabled); fOpenCMapButton->SetState(kButtonDisabled);
@ -431,7 +459,8 @@ void EVBMainFrame::DisableAllInput() {
fFastSABREField->SetState(false); fFastSABREField->SetState(false);
} }
void EVBMainFrame::EnableAllInput() { void EVBMainFrame::EnableAllInput()
{
fRunButton->SetState(kButtonUp); fRunButton->SetState(kButtonUp);
fOpenWorkButton->SetState(kButtonUp); fOpenWorkButton->SetState(kButtonUp);
fOpenCMapButton->SetState(kButtonUp); fOpenCMapButton->SetState(kButtonUp);

View File

@ -15,7 +15,8 @@
#include <TGLabel.h> #include <TGLabel.h>
#include <TTimer.h> #include <TTimer.h>
FileViewFrame::FileViewFrame(const TGWindow* p, const TGFrame* main, UInt_t w, UInt_t h, EVBMainFrame *parent, int type) { FileViewFrame::FileViewFrame(const TGWindow* p, const TGFrame* main, UInt_t w, UInt_t h, EVBMainFrame *parent, int type)
{
fMain = new TGTransientFrame(p,main,w,h); fMain = new TGTransientFrame(p,main,w,h);
fMain->SetCleanup(kDeepCleanup); //delete all child frames fMain->SetCleanup(kDeepCleanup); //delete all child frames
fMain->DontCallClose(); //Close button on window disabled fMain->DontCallClose(); //Close button on window disabled
@ -23,10 +24,13 @@ FileViewFrame::FileViewFrame(const TGWindow* p, const TGFrame* main, UInt_t w, U
dirFlag = false; dirFlag = false;
bool rootFlag = false; bool rootFlag = false;
suffix = ".txt"; suffix = ".txt";
if(type == EVBMainFrame::WORKDIR) { if(type == EVBMainFrame::WorkDir)
{
dirFlag = true; dirFlag = true;
suffix = ".NOTHING"; suffix = ".NOTHING";
} else if(type == EVBMainFrame::PLOTF) { }
else if(type == EVBMainFrame::PlotF)
{
rootFlag = true; rootFlag = true;
suffix = ".root"; suffix = ".root";
} }
@ -48,8 +52,10 @@ FileViewFrame::FileViewFrame(const TGWindow* p, const TGFrame* main, UInt_t w, U
/*Add in text options*/ /*Add in text options*/
TGVerticalFrame *NameFrame = new TGVerticalFrame(fMain, w, h*0.25); TGVerticalFrame *NameFrame = new TGVerticalFrame(fMain, w, h*0.25);
TGLabel *nameLabel; TGLabel *nameLabel;
if(dirFlag) nameLabel = new TGLabel(NameFrame, "Dir:"); if(dirFlag)
else nameLabel = new TGLabel(NameFrame, "File:"); nameLabel = new TGLabel(NameFrame, "Dir:");
else
nameLabel = new TGLabel(NameFrame, "File:");
TGTextBuffer* fNameBuffer; TGTextBuffer* fNameBuffer;
fNameField = new TGTextEntry(NameFrame, fNameBuffer = new TGTextBuffer(50)); fNameField = new TGTextEntry(NameFrame, fNameBuffer = new TGTextBuffer(50));
fNameField->Resize(w*0.5, fNameField->GetDefaultHeight()); fNameField->Resize(w*0.5, fNameField->GetDefaultHeight());
@ -70,14 +76,22 @@ FileViewFrame::FileViewFrame(const TGWindow* p, const TGFrame* main, UInt_t w, U
fMain->AddFrame(ButtonFrame, fbhints); fMain->AddFrame(ButtonFrame, fbhints);
/*Send signal to appropriate location*/ /*Send signal to appropriate location*/
if(type == EVBMainFrame::WORKDIR) Connect("SendText(const char*)","EVBMainFrame",parent,"DisplayWorkdir(const char*)"); if(type == EVBMainFrame::WorkDir)
else if(type == EVBMainFrame::CMAP) Connect("SendText(const char*)","EVBMainFrame",parent,"DisplayCMap(const char*)"); Connect("SendText(const char*)","EVBMainFrame",parent,"DisplayWorkdir(const char*)");
else if(type == EVBMainFrame::SMAP) Connect("SendText(const char*)","EVBMainFrame",parent,"DisplaySMap(const char*)"); else if(type == EVBMainFrame::Cmap)
else if(type == EVBMainFrame::SCALER) Connect("SendText(const char*)","EVBMainFrame",parent,"DisplayScaler(const char*)"); Connect("SendText(const char*)","EVBMainFrame",parent,"DisplayCMap(const char*)");
else if(type == EVBMainFrame::CUT) Connect("SendText(const char*)","EVBMainFrame",parent,"DisplayCut(const char*)"); else if(type == EVBMainFrame::Smap)
else if(type == EVBMainFrame::M_LOAD_CONFIG) Connect("SendText(const char*)","EVBMainFrame",parent,"LoadConfig(const char*)"); Connect("SendText(const char*)","EVBMainFrame",parent,"DisplaySMap(const char*)");
else if(type == EVBMainFrame::M_SAVE_CONFIG) Connect("SendText(const char*)","EVBMainFrame",parent,"SaveConfig(const char*)"); else if(type == EVBMainFrame::Scaler)
else if(type == EVBMainFrame::PLOTF) Connect("SendText(const char*)","EVBMainFrame",parent,"RunPlot(const char*)"); Connect("SendText(const char*)","EVBMainFrame",parent,"DisplayScaler(const char*)");
else if(type == EVBMainFrame::Cut)
Connect("SendText(const char*)","EVBMainFrame",parent,"DisplayCut(const char*)");
else if(type == EVBMainFrame::M_Load_Config)
Connect("SendText(const char*)","EVBMainFrame",parent,"LoadConfig(const char*)");
else if(type == EVBMainFrame::M_Save_Config)
Connect("SendText(const char*)","EVBMainFrame",parent,"SaveConfig(const char*)");
else if(type == EVBMainFrame::PlotF)
Connect("SendText(const char*)","EVBMainFrame",parent,"RunPlot(const char*)");
fMain->SetWindowName("Select File"); fMain->SetWindowName("Select File");
fMain->MapSubwindows(); fMain->MapSubwindows();
@ -97,16 +111,19 @@ FileViewFrame::FileViewFrame(const TGWindow* p, const TGFrame* main, UInt_t w, U
fMain->Resize(); fMain->Resize();
} }
FileViewFrame::~FileViewFrame() { FileViewFrame::~FileViewFrame()
{
fMain->Cleanup(); //delete children fMain->Cleanup(); //delete children
fMain->DeleteWindow(); fMain->DeleteWindow();
} }
void FileViewFrame::CloseWindow() { void FileViewFrame::CloseWindow()
{
delete this; delete this;
} }
void FileViewFrame::DoOk() { void FileViewFrame::DoOk()
{
/*Prevent user from doing something dumb*/ /*Prevent user from doing something dumb*/
fOkButton->SetState(kButtonDisabled); fOkButton->SetState(kButtonDisabled);
fCancelButton->SetState(kButtonDisabled); fCancelButton->SetState(kButtonDisabled);
@ -115,7 +132,8 @@ void FileViewFrame::DoOk() {
TString fullpath; TString fullpath;
if(!dirFlag) fullpath = TString(fContents->GetDirectory()) + "/" + filename; if(!dirFlag) fullpath = TString(fContents->GetDirectory()) + "/" + filename;
else fullpath = filename; else fullpath = filename;
if(fullpath == "") { //check validity if(fullpath == "") //check validity
{
std::cerr<<"Need to give a name!"<<std::endl; std::cerr<<"Need to give a name!"<<std::endl;
fOkButton->SetState(kButtonUp); fOkButton->SetState(kButtonUp);
fCancelButton->SetState(kButtonUp); fCancelButton->SetState(kButtonUp);
@ -127,7 +145,8 @@ void FileViewFrame::DoOk() {
TTimer::SingleShot(150,"FileViewFrame",this,"CloseWindow()"); TTimer::SingleShot(150,"FileViewFrame",this,"CloseWindow()");
} }
void FileViewFrame::DoCancel() { void FileViewFrame::DoCancel()
{
/*Prevent user from doing something dumb*/ /*Prevent user from doing something dumb*/
fOkButton->SetState(kButtonDisabled); fOkButton->SetState(kButtonDisabled);
fCancelButton->SetState(kButtonDisabled); fCancelButton->SetState(kButtonDisabled);
@ -137,7 +156,8 @@ void FileViewFrame::DoCancel() {
} }
//Handle directory selection //Handle directory selection
void FileViewFrame::DisplayDir(const TString& name) { void FileViewFrame::DisplayDir(const TString& name)
{
fContents->SetDefaultHeaders(); fContents->SetDefaultHeaders();
fContents->ChangeDirectory(name); fContents->ChangeDirectory(name);
fContents->DisplayDirectory(); fContents->DisplayDirectory();
@ -146,23 +166,28 @@ void FileViewFrame::DisplayDir(const TString& name) {
} }
//Handle double click //Handle double click
void FileViewFrame::DoDoubleClick(TGLVEntry *entry, int id) { void FileViewFrame::DoDoubleClick(TGLVEntry *entry, int id)
if( id != kButton1) return; {
if( id != kButton1)
return;
TString dirname(fContents->GetDirectory()); TString dirname(fContents->GetDirectory());
TString entryname(entry->GetTitle()); TString entryname(entry->GetTitle());
if(entryname.EndsWith(suffix.c_str())) { //check if its a file if(entryname.EndsWith(suffix.c_str())) //check if its a file
{
TString name = entryname; TString name = entryname;
fNameField->SetText(name.Data()); fNameField->SetText(name.Data());
} else {
DisplayDir(entryname);
if(dirFlag) {
fNameField->SetText((dirname+"/"+entryname).Data());
} }
else
{
DisplayDir(entryname);
if(dirFlag)
fNameField->SetText((dirname+"/"+entryname).Data());
} }
} }
/*SIGNAL*/ /*SIGNAL*/
void FileViewFrame::SendText(const char* text) { void FileViewFrame::SendText(const char* text)
{
Emit("SendText(const char*)", text); Emit("SendText(const char*)", text);
} }

View File

@ -2,7 +2,8 @@
#include <TApplication.h> #include <TApplication.h>
#include "EVBMainFrame.h" #include "EVBMainFrame.h"
int main(int argc, char** argv) { int main(int argc, char** argv)
{
TApplication app("app", &argc, argv); TApplication app("app", &argc, argv);
UInt_t h = 400; UInt_t h = 400;
UInt_t w = 400; UInt_t w = 400;