diff --git a/etc/ScalerFile_Feb2021_SABRE.txt b/etc/ScalerFile_Feb2021_SABRE.txt index 88c1a8f..a2f4e92 100644 --- a/etc/ScalerFile_Feb2021_SABRE.txt +++ b/etc/ScalerFile_Feb2021_SABRE.txt @@ -1,4 +1,4 @@ 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) CH0@V1730_89_Data t1 - +CH5@V1730_89_Data t2 \ No newline at end of file diff --git a/include/ChannelMap.h b/include/ChannelMap.h index f23eed9..d7b0171 100644 --- a/include/ChannelMap.h +++ b/include/ChannelMap.h @@ -9,17 +9,16 @@ #ifndef 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 - int detectorID; //Which specific detector we're looking at - int detectorPart; //Which specific part we're looking at + Sabre, + FocalPlane, + NoneType }; -//Detector part/type identifiers for use in the code -enum class DetAttribute +enum DetAttribute { - FocalPlane, ScintLeft, ScintRight, AnodeFront, @@ -30,30 +29,45 @@ enum class DetAttribute DelayBL, Cathode, Monitor, - SabreRing = 88, //These are offset to avoid interference at the variable mapping phase - SabreWedge = 99 //Just don't add any new attributes with values greater than 88 + 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 Containter; - typedef std::unordered_map::iterator Iterator; + typedef std::unordered_map Containter; + typedef std::unordered_map::iterator Iterator; ChannelMap(); ChannelMap(const std::string& filename); ~ChannelMap(); bool FillMap(const std::string& filename); - inline const Containter* GetCMap() { return &cmap; }; - inline Iterator FindChannel(int key) { return cmap.find(key); }; - inline Iterator End() { return cmap.end(); }; - inline bool IsValid() { return is_valid; }; + 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 cmap; - bool is_valid; + Containter m_cmap; + bool m_validFlag; }; diff --git a/include/CompassHit.h b/include/CompassHit.h index 10aca98..b03e4de 100644 --- a/include/CompassHit.h +++ b/include/CompassHit.h @@ -1,6 +1,8 @@ #ifndef COMPASS_HIT_H #define COMPASS_HIT_H +#include + struct CompassHit { uint16_t board = 400; diff --git a/include/CompassRun.h b/include/CompassRun.h index fef90d5..985d9fd 100644 --- a/include/CompassRun.h +++ b/include/CompassRun.h @@ -25,9 +25,9 @@ public: CompassRun(); CompassRun(const std::string& dir); ~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 SetRunNumber(int n) { runNum = n; } + 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); @@ -46,7 +46,7 @@ private: void ReadScalerData(const std::string& filename); void SetProgressBar(); - std::string directory, m_scalerinput; + std::string m_directory, m_scalerinput; std::vector m_datafiles; unsigned int startIndex; //this is the file we start looking at; increases as we finish files. ShiftMap m_smap; @@ -58,7 +58,7 @@ private: ProcessedEvent pevent; //what run is this - int runNum; + int m_runNum; unsigned int m_totalHits; //Scaler switch diff --git a/include/CutHandler.h b/include/CutHandler.h index dd9ab1b..0128709 100644 --- a/include/CutHandler.h +++ b/include/CutHandler.h @@ -10,7 +10,7 @@ public: ~CutHandler(); void SetCuts(const std::string& filename); bool IsValid() { return validFlag; } - bool IsInside(ProcessedEvent* eaddress); + bool IsInside(const ProcessedEvent* eaddress); std::vector GetCuts() { return cut_array; } private: diff --git a/include/EVBMainFrame.h b/include/EVBMainFrame.h index f600c1d..0f20e59 100644 --- a/include/EVBMainFrame.h +++ b/include/EVBMainFrame.h @@ -12,10 +12,11 @@ #include #include #include -#include "GWMEventBuilder.h" +#include "EVBApp.h" -class EVBMainFrame : public TGMainFrame { +class EVBMainFrame : public TGMainFrame +{ public: EVBMainFrame(const TGWindow* p, UInt_t w, UInt_t h); virtual ~EVBMainFrame(); @@ -47,31 +48,32 @@ public: void EnableAllInput(); - enum WidgetId { - WORKDIR, - CMAP, - SMAP, - SCALER, - CUT, - PLOTF, - BFIELD, - BKE, - THETA, + enum WidgetId + { + WorkDir, + Cmap, + Smap, + Scaler, + Cut, + PlotF, + BField, + Bke, + Theta, ZT, AT, ZP, AP, ZE, AE, - SLOWWIND, - FASTWIND_IC, - FASTWIND_SABRE, - TYPEBOX, - RMIN, - RMAX, - M_LOAD_CONFIG, - M_SAVE_CONFIG, - M_EXIT + SlowWind, + FastWind_IC, + FastWind_Sabre, + TypeBox, + RMin, + RMax, + M_Load_Config, + M_Save_Config, + M_Exit }; ClassDef(EVBMainFrame, 0); @@ -92,7 +94,7 @@ private: TGPopupMenu *fFileMenu; - GWMEventBuilder fBuilder; + EVBApp fBuilder; int counter; UInt_t MAIN_W, MAIN_H; diff --git a/include/RunCollector.h b/include/RunCollector.h index 000f1f3..a4bb748 100644 --- a/include/RunCollector.h +++ b/include/RunCollector.h @@ -23,7 +23,7 @@ public: bool GrabAllFiles(); bool GrabFilesInRange(); 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 GetSearchSuffix() { return m_suffix; } inline int GetRunMin() { return m_minRun; } diff --git a/include/SFPPlotter.h b/include/SFPPlotter.h index fb13d3f..3217093 100644 --- a/include/SFPPlotter.h +++ b/include/SFPPlotter.h @@ -20,7 +20,7 @@ public: ~SFPPlotter(); inline void AttachProgressBar(TGProgressBar* pb) { m_pb = pb; } inline void ApplyCutlist(const std::string& listname) { cutter.SetCuts(listname); } - void Run(const std::vector& files, const string& output); + void Run(const std::vector& files, const std::string& output); private: void SetProgressBar(long total); diff --git a/include/ShiftMap.h b/include/ShiftMap.h index 847169b..2d21eea 100644 --- a/include/ShiftMap.h +++ b/include/ShiftMap.h @@ -21,7 +21,7 @@ public: void SetFile(const std::string& filename); inline bool IsValid() { return m_validFlag; } inline std::string GetFilename() { return m_filename; } - Long64_t GetShift(int gchan); + uint64_t GetShift(int gchan); private: void ParseFile(); diff --git a/include/SlowSort.h b/include/SlowSort.h index 7655b61..de5d49a 100644 --- a/include/SlowSort.h +++ b/include/SlowSort.h @@ -14,43 +14,40 @@ #include "DataStructs.h" #include "ChannelMap.h" #include +#include -using namespace std; +class SlowSort +{ -class SlowSort { +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; } - public: - SlowSort(); - SlowSort(double windowSize, const string& mapfile); - ~SlowSort(); - inline void SetWindowSize(double window) { coincWindow = window; }; - inline bool SetMapFile(const std::string& mapfile) { return cmap.FillMap(mapfile); }; - bool AddHitToEvent(CompassHit& mhit); - CoincEvent GetEvent(); - inline TH2F* GetEventStats() { return event_stats; }; - void FlushHitsToEvent(); //For use with *last* hit list - inline bool IsEventReady() { return eventFlag; }; +private: + void InitVariableMaps(); + void Reset(); + void ProcessEvent(); - private: - void InitVariableMaps(); - void Reset(); - void StartEvent(); - void ProcessEvent(); + double m_coincWindow; + std::vector m_hitList; + bool m_eventFlag; + CoincEvent m_event; + CoincEvent m_blank; + + double startTime, previousHitTime; + std::unordered_map*> varMap; - double coincWindow; - vector hitList; - bool eventFlag; - DPPChannel hit; - CoincEvent event; - CoincEvent blank; - - double startTime, previousHitTime; - unordered_map*> fpVMap; - unordered_map*> sabreVMap; + TH2F* event_stats; - TH2F* event_stats; - - ChannelMap cmap; + ChannelMap cmap; }; diff --git a/input.txt b/input.txt index b5f7a71..d73fd22 100644 --- a/input.txt +++ b/input.txt @@ -1,10 +1,10 @@ -------Data Location---------- -WorkspaceDirectory: /data1/gwm17/10B3He/Feb2021/ +WorkspaceDirectory: /media/gordon/GordonData/gwm17/9BFeb2021 ------------------------------- ------Experimental Inputs------ -ChannelMapFile: /home/gwm17/GWM_EventBuilder/etc/orig_ChannelMap_Feb2021_SABRE.txt -ScalerFile: /home/gwm17/GWM_EventBuilder/etc/orig_ScalerFile_Feb2021_SABRE.txt -CutListFile: /home/gwm17/GWM_EventBuilder/etc/new_CutList_Feb202110B3hea.txt +ChannelMapFile: /home/gordon/SPS_SABRE_EventBuilder/etc/ChannelMap_Feb2021_SABRE.txt +ScalerFile: /home/gordon/SPS_SABRE_EventBuilder/etc/ScalerFile_Feb2021_SABRE.txt +CutListFile: /home/gordon/SPS_SABRE_EventBuilder/etc/CutList_Feb2021_10B3hea.txt ZT: 5 AT: 10 ZP: 2 @@ -16,7 +16,7 @@ BeamKE(MeV): 24 Theta(deg): 15 ------------------------------- -------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 FastCoincidenceWindow_IonCh(ps): 250000 FastCoincidenceWindow_SABRE(ps): 150000 diff --git a/src/evb/ChannelMap.cpp b/src/evb/ChannelMap.cpp index da32eac..8295272 100644 --- a/src/evb/ChannelMap.cpp +++ b/src/evb/ChannelMap.cpp @@ -10,12 +10,12 @@ #include "ChannelMap.h" ChannelMap::ChannelMap() : - is_valid(false) + m_validFlag(false) { } ChannelMap::ChannelMap(const std::string& name) : - is_valid(false) + m_validFlag(false) { FillMap(name); } @@ -27,8 +27,8 @@ bool ChannelMap::FillMap(const std::string& name) std::ifstream input(name); if(!input.is_open()) { - is_valid = false; - return is_valid; + m_validFlag = false; + return m_validFlag; } std::string junk, type, partname; int gchan, id; @@ -39,42 +39,56 @@ bool ChannelMap::FillMap(const std::string& name) while(input>>gchan) { //Set default values - this_chan.detectorType = -1; - this_chan.detectorID = -1; - this_chan.detectorPart = -1; + this_chan.type = DetType::NoneType; + this_chan.local_channel = -1; + this_chan.attribute = DetAttribute::NoneAttr; input>>id>>type>>partname; - if(type == "SABRERING") + if(type == "SABRERING") { - this_chan.detectorType = DetAttribute::SabreRing; - this_chan.detectorID = id; - this_chan.detectorPart = std::stoi(partname); + 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.detectorType = DetAttribute::SabreWedge; - this_chan.detectorID = id; - this_chan.detectorPart = std::stoi(partname); + 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.detectorType = FOCALPLANE; - this_chan.detectorID = id; - if(partname == "SCINTRIGHT") this_chan.detectorPart = DetAttribute::ScintRight; - else if(partname == "SCINTLEFT") this_chan.detectorPart = DetAttribute::ScintLeft; - else if(partname == "DELAYFR") this_chan.detectorPart = DetAttribute::DelayFR; - else if(partname == "DELAYFL") this_chan.detectorPart = DetAttribute::DelayFL; - else if(partname == "DELAYBR") this_chan.detectorPart = DetAttribute::DelayBR; - else if(partname == "DELAYBL") this_chan.detectorPart = DetAttribute::DelayBL; - else if(partname == "CATHODE") this_chan.detectorPart = DetAttribute::Cathode; - else if(partname == "ANODEFRONT") this_chan.detectorPart = DetAttribute::AnodeFront; - else if(partname == "ANODEBACK") this_chan.detectorPart = DetAttribute::AnodeBack; - else if(partname == "MONITOR") this_chan.detectorPart = DetAttribute::Monitor; + 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; } - cmap[gchan] = this_chan; + m_cmap[gchan] = this_chan; } input.close(); - is_valid = true; - return is_valid; + m_validFlag = true; + return m_validFlag; } diff --git a/src/evb/CompassRun.cpp b/src/evb/CompassRun.cpp index 4009f6e..df005c1 100644 --- a/src/evb/CompassRun.cpp +++ b/src/evb/CompassRun.cpp @@ -18,13 +18,13 @@ #include "FlagHandler.h" 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) : - 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) { 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(varname.c_str(), init); } input.close(); @@ -58,15 +58,15 @@ bool CompassRun::GetBinaryFiles() { std::string prefix = ""; std::string suffix = ".bin"; //binaries - RunCollector grabber(directory, prefix, suffix); + RunCollector grabber(m_directory, prefix, suffix); grabber.GrabAllFiles(); m_datafiles.clear(); //so that the CompassRun can be reused - m_datafiles.reserve(grabber.filelist.size()); + m_datafiles.reserve(grabber.GetFileList().size()); bool scalerd; m_totalHits = 0; //reset total run size - for(auto& entry : grabber.filelist) + for(auto& entry : grabber.GetFileList()) { //Handle scaler files, if they exist if(m_scaler_flag) @@ -74,9 +74,9 @@ bool CompassRun::GetBinaryFiles() scalerd = false; 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; break; } @@ -85,7 +85,7 @@ bool CompassRun::GetBinaryFiles() continue; } - m_datafiles.emplace_back(entry.Data()); + m_datafiles.emplace_back(entry); 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 if(!m_datafiles[m_datafiles.size() - 1].IsOpen()) @@ -132,26 +132,25 @@ void CompassRun::ReadScalerData(const std::string& filename) bool CompassRun::GetHitsFromFiles() { - std::pair earliestHit = make_pair(CompassHit(), nullptr); + std::pair earliestHit = std::make_pair(CompassHit(), nullptr); for(unsigned int i=startIndex; iBranch("Timestamp", &hit.timestamp); outtree->Branch("Flags", &hit.flags); - if(!m_smap.IsSet()) + if(!m_smap.IsValid()) { std::cerr<<"Bad shift map at CompassRun::Convert()."<Branch("event", &event); - if(!m_smap.IsSet()) + if(!m_smap.IsValid()) { std::cerr<<"Bad shift map at CompassRun::Convert()."<Branch("event", &event); - if(!m_smap.IsSet()) + if(!m_smap.IsValid()) { std::cerr<<"Bad shift map at CompassRun::Convert()."<Branch("event", &pevent); - if(!m_smap.IsSet()) + if(!m_smap.IsValid()) { std::cerr<<"Bad shift map at CompassRun::Convert()."<> parvec; + std::vector> parvec; parvec.reserve(9); parvec.emplace_back("ZT", zt); parvec.emplace_back("AT", at); @@ -500,7 +499,7 @@ void CompassRun::Convert2FastAnalyzedRoot(const std::string& name, const std::st outtree->Branch("event", &pevent); - if(!m_smap.IsSet()) + if(!m_smap.IsValid()) { std::cerr<<"Bad shift map at CompassRun::Convert()."<> parvec; + std::vector> parvec; parvec.reserve(9); parvec.emplace_back("ZT", zt); parvec.emplace_back("AT", at); diff --git a/src/evb/CutHandler.cpp b/src/evb/CutHandler.cpp index e016078..013eb15 100644 --- a/src/evb/CutHandler.cpp +++ b/src/evb/CutHandler.cpp @@ -78,7 +78,7 @@ void CutHandler::InitVariableMap() varmap["cathode"] = &m_event.cathode; } -bool CutHandler::IsInside(ProcessedEvent* eaddress) +bool CutHandler::IsInside(const ProcessedEvent* eaddress) { m_event = *eaddress; std::string x, y; diff --git a/src/evb/EVBApp.cpp b/src/evb/EVBApp.cpp index cadf877..0155d36 100644 --- a/src/evb/EVBApp.cpp +++ b/src/evb/EVBApp.cpp @@ -120,7 +120,7 @@ void EVBApp::WriteConfigFile(const std::string& fullpath) void EVBApp::PlotHistograms() { 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; grammer.ApplyCutlist(m_cutList); std::cout<<"-------------GWM Event Builder-------------"< FastSort::GetFastEvents(CoincEvent& event) sizeArray[4] = slowEvent.focalPlane.anodeF.size(); sizeArray[5] = slowEvent.focalPlane.anodeB.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 for(unsigned int i=0; i>junk) { massfile>>Z>>A>>element>>atomicMassBig>>atomicMassSmall; 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; elementTable[Z] = element; } diff --git a/src/evb/RunCollector.cpp b/src/evb/RunCollector.cpp index a980121..c300e2d 100644 --- a/src/evb/RunCollector.cpp +++ b/src/evb/RunCollector.cpp @@ -8,16 +8,16 @@ #include 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) { } -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) { } @@ -44,7 +44,7 @@ bool RunCollector::GrabAllFiles() 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"<GetName(); - if(temp.size() < prefix.size() || temp.size() < suffix.size()) + if(temp.size() < m_prefix.size() || temp.size() < m_suffix.size()) continue; - else if(!file->IsDirectory() && !temp.compare(0,prefix.size(),prefix) && - !temp.compare(temp.size()-(1+suffix.size()), suffix.size(), suffix)) + 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 = dir+temp; + fname = m_directory+temp; m_filelist.push_back(fname); } } @@ -69,7 +69,7 @@ bool RunCollector::GrabAllFiles() return true; else { - cerr<<"Unable to find files with matching run name in directory; check input.txt"<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; } } @@ -105,19 +105,18 @@ std::string RunCollector::GrabFile(int runNum) { } /*Grabs all files within a specified run range*/ -int RunCollector::GrabFilesInRange() +bool RunCollector::GrabFilesInRange() { if(!m_initFlag) return false; - TSystemDirectory sysdir(dir.Data(), dir.Data()); + TSystemDirectory sysdir(m_directory.c_str(), m_directory.c_str()); TList *flist = sysdir.GetListOfFiles(); m_filelist.clear(); - int counter = 0; if(!flist) { - cerr<<"Unable to find any files in directory; check name given to input.txt"<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()-(1+runno.size()),runno.size(), runno)) + !temp.compare(temp.size()-runno.size(),runno.size(), runno)) { - counter++; - fname = dir+temp; + fname = m_directory+temp; m_filelist.push_back(fname); break; //if we find the file, break out of iterator loop } @@ -145,11 +143,11 @@ int RunCollector::GrabFilesInRange() } delete flist; - if(counter>0) + if(m_filelist.size()>0) return true; else { - cerr<<"Unable to find files with matching run name in directory; check input.txt"<Add(m_filelist[i].Data()); - cout<<"Merging runs into single file..."<Add(m_filelist[i].c_str()); + std::cout<<"Merging runs into single file..."<Merge(output,0,"fast"); - cout<<"Finished merging"<Add(m_filelist[i]); - cout<<"Merging runs "<Add(m_filelist[i].c_str()); + std::cout<<"Merging runs "<Merge(output,0,"fast"); - cout<<"Finished merging"<SetOwner(false);//THashTable doesnt own members; avoid double delete event_address = new ProcessedEvent(); - chain = new TChain("SPSTree"); 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, 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) 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); - rootObj->Add(h); + 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*) rootObj->FindObject(name.c_str()); + 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); - rootObj->Add(h); + table->Add(h); } } @@ -247,12 +244,12 @@ void SFPPlotter::Run(const std::vector& files, const std::string& o for(unsigned int i=0; iAdd(files[i].c_str()); chain->SetBranchAddress("event", &event_address); - THastTable* table = new THashTable(); + THashTable* table = new THashTable(); long blentries = chain->GetEntries(); if(m_pb) SetProgressBar(blentries); - cout<<"Total number of events: "<& files, const std::string& o } } chain->GetEntry(i); - MakeUncutHistograms(*event_address); - if(cutter.IsValid()) MakeCutHistograms(*event_address); + MakeUncutHistograms(*event_address, table); + if(cutter.IsValid()) MakeCutHistograms(*event_address, table); } - cout<cd(); - rootObj->Write(); + table->Write(); if(cutter.IsValid()) { auto clist = cutter.GetCuts(); for(unsigned int i=0; iWrite(); } - delete rootObj; + delete table; outfile->Close(); delete outfile; } diff --git a/src/evb/SlowSort.cpp b/src/evb/SlowSort.cpp index 8daefa7..faff4c1 100644 --- a/src/evb/SlowSort.cpp +++ b/src/evb/SlowSort.cpp @@ -11,156 +11,170 @@ #include "SlowSort.h" /*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); } /*Constructor takes input of coincidence window size, and fills sabre channel map*/ 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) : - coincWindow(windowSize), eventFlag(false), event(), cmap(mapfile) +SlowSort::SlowSort(double windowSize, const std::string& mapfile) : + m_coincWindow(windowSize), m_eventFlag(false), m_event(), cmap(mapfile) { - event_stats = new TH2F("coinc_event_stats","coinc_events_stats;global channel;number of coincident hits;counts",144,0,144,20,0,20); - InitVariableMaps(); + event_stats = new TH2F("coinc_event_stats","coinc_events_stats;global channel;number of coincident hits;counts",144,0,144,20,0,20); + InitVariableMaps(); } -SlowSort::~SlowSort() { -} +SlowSort::~SlowSort() {} /**EXPERIMENT MODS go here**/ -void SlowSort::InitVariableMaps() { +void SlowSort::InitVariableMaps() +{ - /*For SABRE: Each SABRE det has ring&wedge, so add the detID to the - SABRERING/WEDGE attribute to differentiate*/ - for(int i=0; i<5; i++) { - sabreVMap[SABRERING + i] = &event.sabreArray[i].rings; - sabreVMap[SABREWEDGE + i] = &event.sabreArray[i].wedges; - } + /*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 - */ - fpVMap[SCINTLEFT] = &event.focalPlane.scintL; - fpVMap[SCINTRIGHT] = &event.focalPlane.scintR; - fpVMap[CATHODE] = &event.focalPlane.cathode; - fpVMap[DELAYFR] = &event.focalPlane.delayFR; - fpVMap[DELAYFL] = &event.focalPlane.delayFL; - fpVMap[DELAYBL] = &event.focalPlane.delayBL; - fpVMap[DELAYBR] = &event.focalPlane.delayBR; - fpVMap[ANODEFRONT] = &event.focalPlane.anodeF; - fpVMap[ANODEBACK] = &event.focalPlane.anodeB; - fpVMap[MONITOR] = &event.focalPlane.monitor; + /*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() { - event = 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; +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(hitList.empty()) { - startTime = curHit.Timestamp; - hitList.push_back(curHit); - } else if (curHit.Timestamp < previousHitTime) { - return false; - } else if ((curHit.Timestamp - startTime) < coincWindow) { - hitList.push_back(curHit); - } else { - ProcessEvent(); - hitList.clear(); - startTime = curHit.Timestamp; - hitList.push_back(curHit); - eventFlag = true; - } + 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; + } - return true; + return true; } -void SlowSort::FlushHitsToEvent() { - if(hitList.empty()) { - eventFlag = false; - return; - } +void SlowSort::FlushHitsToEvent() +{ + if(m_hitList.empty()) + { + m_eventFlag = false; + return; + } - ProcessEvent(); - hitList.clear(); - eventFlag = true; + ProcessEvent(); + m_hitList.clear(); + m_eventFlag = true; } -CoincEvent SlowSort::GetEvent() { - eventFlag = false; - return 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."<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()) { - continue; - } - if(channel_info->second.detectorType == SABRERING || channel_info->second.detectorType == SABREWEDGE) { +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); - auto variable = sabreVMap.find(channel_info->second.detectorType + channel_info->second.detectorID); - if(variable != sabreVMap.end()) { - variable->second->push_back(dhit); - } - - } else if(channel_info->second.detectorType == FOCALPLANE) { - - auto variable = fpVMap.find(channel_info->second.detectorPart); - if(variable != fpVMap.end()) { - variable->second->push_back(dhit); - } - - } else { - std::cout<second.detectorType<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<second.type<<" attribute: "<second.attribute<Resize(w*0.25, fWorkField->GetDefaultHeight()); fWorkField->Connect("ReturnPressed()","EVBMainFrame",this,"UpdateWorkdir()"); 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); 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->Connect("ReturnPressed()","EVBMainFrame",this,"UpdateCMap()"); 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); 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->Connect("ReturnPressed()","EVBMainFrame",this,"UpdateSMap()"); 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); 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()"); fOpenScalerButton = new TGTextButton(ScalerFrame, "Open"); 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); 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()"); fOpenCutButton = new TGTextButton(CutFrame, "Open"); 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); 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):"); - 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):"); - 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:"); fZTField = new TGNumberEntryField(ParamFrame, ZT, 0, TGNumberEntry::kNESInteger, TGNumberEntry::kNEANonNegative); 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); 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):"); - 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):"); - 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(fSlowWindowField, fhints); 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); 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 - fTypeBox->AddEntry("Convert Slow", GWMEventBuilder::CONVERT_S); - fTypeBox->AddEntry("Convert Fast", GWMEventBuilder::CONVERT_F); - fTypeBox->AddEntry("Convert SlowA", GWMEventBuilder::CONVERT_SA); - fTypeBox->AddEntry("Convert FastA", GWMEventBuilder::CONVERT_FA); - fTypeBox->AddEntry("Convert", GWMEventBuilder::CONVERT); - fTypeBox->AddEntry("Merge ROOT", GWMEventBuilder::MERGE); - fTypeBox->AddEntry("Plot", GWMEventBuilder::PLOT); + 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->Resize(200,20); fTypeBox->Connect("Selected(Int_t, Int_t)","EVBMainFrame",this,"HandleTypeSelection(Int_t,Int_t)"); 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:"); - 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->SetState(kButtonDisabled); 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); fFileMenu = new TGPopupMenu(gClient->GetRoot()); - fFileMenu->AddEntry("Load...", M_LOAD_CONFIG); - fFileMenu->AddEntry("Save...", M_SAVE_CONFIG); - fFileMenu->AddEntry("Exit", M_EXIT); + fFileMenu->AddEntry("Load...", M_Load_Config); + fFileMenu->AddEntry("Save...", M_Save_Config); + fFileMenu->AddEntry("Exit", M_Exit); fFileMenu->Connect("Activated(Int_t)","EVBMainFrame", this, "HandleMenuSelection(Int_t)"); 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(); delete this; } -void EVBMainFrame::CloseWindow() { +void EVBMainFrame::CloseWindow() +{ gApplication->Terminate(); } -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); - else if(id == M_EXIT) CloseWindow(); +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); + else if(id == M_Exit) + CloseWindow(); } -void EVBMainFrame::DoOpenWorkdir() { - new FileViewFrame(gClient->GetRoot(), this, MAIN_W*0.5, MAIN_H*0.25, this, WORKDIR); +void EVBMainFrame::DoOpenWorkdir() +{ + new FileViewFrame(gClient->GetRoot(), this, MAIN_W*0.5, MAIN_H*0.25, this, WorkDir); } -void EVBMainFrame::DoOpenCMapfile() { - new FileViewFrame(gClient->GetRoot(), this, MAIN_W*0.5, MAIN_H*0.25, this, CMAP); +void EVBMainFrame::DoOpenCMapfile() +{ + new FileViewFrame(gClient->GetRoot(), this, MAIN_W*0.5, MAIN_H*0.25, this, Cmap); } -void EVBMainFrame::DoOpenSMapfile() { - new FileViewFrame(gClient->GetRoot(), this, MAIN_W*0.5, MAIN_H*0.25, this, SMAP); +void EVBMainFrame::DoOpenSMapfile() +{ + new FileViewFrame(gClient->GetRoot(), this, MAIN_W*0.5, MAIN_H*0.25, this, Smap); } -void EVBMainFrame::DoOpenScalerfile() { - new FileViewFrame(gClient->GetRoot(), this, MAIN_W*0.5, MAIN_H*0.25, this, SCALER); +void EVBMainFrame::DoOpenScalerfile() +{ + new FileViewFrame(gClient->GetRoot(), this, MAIN_W*0.5, MAIN_H*0.25, this, Scaler); } -void EVBMainFrame::DoOpenCutfile() { - new FileViewFrame(gClient->GetRoot(), this, MAIN_W*0.5, MAIN_H*0.25, this, CUT); +void EVBMainFrame::DoOpenCutfile() +{ + new FileViewFrame(gClient->GetRoot(), this, MAIN_W*0.5, MAIN_H*0.25, this, Cut); } -void EVBMainFrame::DoRun() { +void EVBMainFrame::DoRun() +{ DisableAllInput(); SetParameters(); int type = fTypeBox->GetSelected(); - fBuilder.SetAnalysisType(type); - switch(type) { - case GWMEventBuilder::PLOT : + switch(type) + { + case EVBApp::Operation::Plot : { RunPlot(); break; } - case GWMEventBuilder::CONVERT : + case EVBApp::Operation::Convert : { fBuilder.Convert2RawRoot(); break; } - case GWMEventBuilder::MERGE : + case EVBApp::Operation::Merge : { fBuilder.MergeROOTFiles(); break; } - case GWMEventBuilder::CONVERT_S : + case EVBApp::Operation::ConvertSlow : { fBuilder.Convert2SortedRoot(); break; } - case GWMEventBuilder::CONVERT_F : + case EVBApp::Operation::ConvertFast : { fBuilder.Convert2FastSortedRoot(); break; } - case GWMEventBuilder::CONVERT_SA : + case EVBApp::Operation::ConvertSlowA : { fBuilder.Convert2SlowAnalyzedRoot(); break; } - case GWMEventBuilder::CONVERT_FA : + case EVBApp::Operation::ConvertFastA : { fBuilder.Convert2FastAnalyzedRoot(); break; @@ -284,11 +296,13 @@ void EVBMainFrame::DoRun() { EnableAllInput(); } -void EVBMainFrame::HandleTypeSelection(int box, int entry) { +void EVBMainFrame::HandleTypeSelection(int box, int entry) +{ fRunButton->SetState(kButtonUp); } -bool EVBMainFrame::SetParameters() { +bool EVBMainFrame::SetParameters() +{ fBuilder.SetRunRange(fRMinField->GetIntNumber(), fRMaxField->GetIntNumber()); fBuilder.SetSlowCoincidenceWindow(fSlowWindowField->GetNumber()); fBuilder.SetFastWindowIonChamber(fFastICField->GetNumber()); @@ -306,37 +320,44 @@ bool EVBMainFrame::SetParameters() { return test; } -void EVBMainFrame::DisplayWorkdir(const char* dir) { +void EVBMainFrame::DisplayWorkdir(const char* dir) +{ fWorkField->SetText(dir); fBuilder.SetWorkDirectory(dir); } -void EVBMainFrame::DisplayCMap(const char* file) { +void EVBMainFrame::DisplayCMap(const char* file) +{ fCMapField->SetText(file); fBuilder.SetChannelMap(file); } -void EVBMainFrame::DisplaySMap(const char* file) { +void EVBMainFrame::DisplaySMap(const char* file) +{ fSMapField->SetText(file); fBuilder.SetBoardShiftFile(file); } -void EVBMainFrame::DisplayScaler(const char* file) { +void EVBMainFrame::DisplayScaler(const char* file) +{ fScalerField->SetText(file); fBuilder.SetScalerFile(file); } -void EVBMainFrame::DisplayCut(const char* file) { +void EVBMainFrame::DisplayCut(const char* file) +{ fCutField->SetText(file); fBuilder.SetCutList(file); } -void EVBMainFrame::SaveConfig(const char* file) { +void EVBMainFrame::SaveConfig(const char* file) +{ std::string filename = file; fBuilder.WriteConfigFile(filename); } -void EVBMainFrame::LoadConfig(const char* file) { +void EVBMainFrame::LoadConfig(const char* file) +{ std::string filename = file; fBuilder.ReadConfigFile(filename); @@ -365,38 +386,45 @@ void EVBMainFrame::LoadConfig(const char* file) { } -void EVBMainFrame::UpdateWorkdir() { +void EVBMainFrame::UpdateWorkdir() +{ const char* dir = fWorkField->GetText(); fBuilder.SetWorkDirectory(dir); } -void EVBMainFrame::UpdateSMap() { +void EVBMainFrame::UpdateSMap() +{ const char* file = fSMapField->GetText(); fBuilder.SetBoardShiftFile(file); } -void EVBMainFrame::UpdateCMap() { +void EVBMainFrame::UpdateCMap() +{ const char* file = fCMapField->GetText(); fBuilder.SetChannelMap(file); } -void EVBMainFrame::UpdateScaler() { +void EVBMainFrame::UpdateScaler() +{ const char* file = fScalerField->GetText(); fBuilder.SetScalerFile(file); } -void EVBMainFrame::UpdateCut() { +void EVBMainFrame::UpdateCut() +{ const char* file = fCutField->GetText(); fBuilder.SetCutList(file); } -void EVBMainFrame::RunPlot() { +void EVBMainFrame::RunPlot() +{ fBuilder.PlotHistograms(); } void EVBMainFrame::RunMerge(const char* file, const char* dir) {} -void EVBMainFrame::DisableAllInput() { +void EVBMainFrame::DisableAllInput() +{ fRunButton->SetState(kButtonDisabled); fOpenWorkButton->SetState(kButtonDisabled); fOpenCMapButton->SetState(kButtonDisabled); @@ -431,7 +459,8 @@ void EVBMainFrame::DisableAllInput() { fFastSABREField->SetState(false); } -void EVBMainFrame::EnableAllInput() { +void EVBMainFrame::EnableAllInput() +{ fRunButton->SetState(kButtonUp); fOpenWorkButton->SetState(kButtonUp); fOpenCMapButton->SetState(kButtonUp); diff --git a/src/gui/FileViewFrame.cpp b/src/gui/FileViewFrame.cpp index 0565f34..7491e05 100644 --- a/src/gui/FileViewFrame.cpp +++ b/src/gui/FileViewFrame.cpp @@ -15,7 +15,8 @@ #include #include -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->SetCleanup(kDeepCleanup); //delete all child frames 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; bool rootFlag = false; suffix = ".txt"; - if(type == EVBMainFrame::WORKDIR) { + if(type == EVBMainFrame::WorkDir) + { dirFlag = true; suffix = ".NOTHING"; - } else if(type == EVBMainFrame::PLOTF) { + } + else if(type == EVBMainFrame::PlotF) + { rootFlag = true; suffix = ".root"; } @@ -48,8 +52,10 @@ FileViewFrame::FileViewFrame(const TGWindow* p, const TGFrame* main, UInt_t w, U /*Add in text options*/ TGVerticalFrame *NameFrame = new TGVerticalFrame(fMain, w, h*0.25); TGLabel *nameLabel; - if(dirFlag) nameLabel = new TGLabel(NameFrame, "Dir:"); - else nameLabel = new TGLabel(NameFrame, "File:"); + if(dirFlag) + nameLabel = new TGLabel(NameFrame, "Dir:"); + else + nameLabel = new TGLabel(NameFrame, "File:"); TGTextBuffer* fNameBuffer; fNameField = new TGTextEntry(NameFrame, fNameBuffer = new TGTextBuffer(50)); 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); /*Send signal to appropriate location*/ - if(type == EVBMainFrame::WORKDIR) Connect("SendText(const char*)","EVBMainFrame",parent,"DisplayWorkdir(const char*)"); - else if(type == EVBMainFrame::CMAP) Connect("SendText(const char*)","EVBMainFrame",parent,"DisplayCMap(const char*)"); - else if(type == EVBMainFrame::SMAP) Connect("SendText(const char*)","EVBMainFrame",parent,"DisplaySMap(const char*)"); - else if(type == EVBMainFrame::SCALER) 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*)"); + if(type == EVBMainFrame::WorkDir) + Connect("SendText(const char*)","EVBMainFrame",parent,"DisplayWorkdir(const char*)"); + else if(type == EVBMainFrame::Cmap) + Connect("SendText(const char*)","EVBMainFrame",parent,"DisplayCMap(const char*)"); + else if(type == EVBMainFrame::Smap) + Connect("SendText(const char*)","EVBMainFrame",parent,"DisplaySMap(const char*)"); + else if(type == EVBMainFrame::Scaler) + 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->MapSubwindows(); @@ -97,16 +111,19 @@ FileViewFrame::FileViewFrame(const TGWindow* p, const TGFrame* main, UInt_t w, U fMain->Resize(); } -FileViewFrame::~FileViewFrame() { +FileViewFrame::~FileViewFrame() +{ fMain->Cleanup(); //delete children fMain->DeleteWindow(); } -void FileViewFrame::CloseWindow() { +void FileViewFrame::CloseWindow() +{ delete this; } -void FileViewFrame::DoOk() { +void FileViewFrame::DoOk() +{ /*Prevent user from doing something dumb*/ fOkButton->SetState(kButtonDisabled); fCancelButton->SetState(kButtonDisabled); @@ -115,7 +132,8 @@ void FileViewFrame::DoOk() { TString fullpath; if(!dirFlag) fullpath = TString(fContents->GetDirectory()) + "/" + filename; else fullpath = filename; - if(fullpath == "") { //check validity + if(fullpath == "") //check validity + { std::cerr<<"Need to give a name!"<SetState(kButtonUp); fCancelButton->SetState(kButtonUp); @@ -127,7 +145,8 @@ void FileViewFrame::DoOk() { TTimer::SingleShot(150,"FileViewFrame",this,"CloseWindow()"); } -void FileViewFrame::DoCancel() { +void FileViewFrame::DoCancel() +{ /*Prevent user from doing something dumb*/ fOkButton->SetState(kButtonDisabled); fCancelButton->SetState(kButtonDisabled); @@ -137,7 +156,8 @@ void FileViewFrame::DoCancel() { } //Handle directory selection -void FileViewFrame::DisplayDir(const TString& name) { +void FileViewFrame::DisplayDir(const TString& name) +{ fContents->SetDefaultHeaders(); fContents->ChangeDirectory(name); fContents->DisplayDirectory(); @@ -146,23 +166,28 @@ void FileViewFrame::DisplayDir(const TString& name) { } //Handle double click -void FileViewFrame::DoDoubleClick(TGLVEntry *entry, int id) { - if( id != kButton1) return; +void FileViewFrame::DoDoubleClick(TGLVEntry *entry, int id) +{ + if( id != kButton1) + return; TString dirname(fContents->GetDirectory()); 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; fNameField->SetText(name.Data()); - } else { + } + else + { DisplayDir(entryname); - if(dirFlag) { + if(dirFlag) fNameField->SetText((dirname+"/"+entryname).Data()); - } } } /*SIGNAL*/ -void FileViewFrame::SendText(const char* text) { +void FileViewFrame::SendText(const char* text) +{ Emit("SendText(const char*)", text); } diff --git a/src/gui_main.cpp b/src/gui_main.cpp index be2cb82..58bd5a0 100644 --- a/src/gui_main.cpp +++ b/src/gui_main.cpp @@ -2,7 +2,8 @@ #include #include "EVBMainFrame.h" -int main(int argc, char** argv) { +int main(int argc, char** argv) +{ TApplication app("app", &argc, argv); UInt_t h = 400; UInt_t w = 400;