1
0
Fork 0
mirror of https://github.com/gwm17/Mask.git synced 2024-11-22 18:28:51 -05:00

Fix typos in SX3 class. Change name of array classes to array rather than efficiency. Update cmake lists.

This commit is contained in:
Gordon McCann 2022-08-30 15:42:49 -04:00
parent bb67011bb5
commit 3565f7ae28
9 changed files with 66 additions and 65 deletions

View File

@ -1,4 +1,4 @@
#include "AnasenEfficiency.h" #include "AnasenArray.h"
#include <fstream> #include <fstream>
#include <iomanip> #include <iomanip>
#include <iostream> #include <iostream>
@ -6,8 +6,8 @@
#include "TFile.h" #include "TFile.h"
#include "TTree.h" #include "TTree.h"
AnasenEfficiency::AnasenEfficiency() : AnasenArray::AnasenArray() :
DetectorEfficiency(), m_detectorEloss({14}, {28}, {1}, s_detectorThickness) DetectorArray(), m_detectorEloss({14}, {28}, {1}, s_detectorThickness)
{ {
for(int i=0; i<s_nSX3PerBarrel; i++) for(int i=0; i<s_nSX3PerBarrel; i++)
{ {
@ -25,10 +25,10 @@ AnasenEfficiency::AnasenEfficiency() :
} }
} }
AnasenEfficiency::~AnasenEfficiency() {} AnasenArray::~AnasenArray() {}
void AnasenEfficiency::DrawDetectorSystem(const std::string& filename) void AnasenArray::DrawDetectorSystem(const std::string& filename)
{ {
std::ofstream output(filename); std::ofstream output(filename);
@ -135,7 +135,7 @@ void AnasenEfficiency::DrawDetectorSystem(const std::string& filename)
output.close(); output.close();
} }
double AnasenEfficiency::RunConsistencyCheck() double AnasenArray::RunConsistencyCheck()
{ {
std::vector<ROOT::Math::XYZPoint> r1_points; std::vector<ROOT::Math::XYZPoint> r1_points;
std::vector<ROOT::Math::XYZPoint> r2_points; std::vector<ROOT::Math::XYZPoint> r2_points;
@ -230,7 +230,7 @@ double AnasenEfficiency::RunConsistencyCheck()
} }
DetectorResult AnasenEfficiency::IsRing1(Mask::Nucleus& nucleus) DetectorResult AnasenArray::IsRing1(Mask::Nucleus& nucleus)
{ {
DetectorResult observation; DetectorResult observation;
double thetaIncident; double thetaIncident;
@ -255,7 +255,7 @@ DetectorResult AnasenEfficiency::IsRing1(Mask::Nucleus& nucleus)
return observation; return observation;
} }
DetectorResult AnasenEfficiency::IsRing2(Mask::Nucleus& nucleus) DetectorResult AnasenArray::IsRing2(Mask::Nucleus& nucleus)
{ {
DetectorResult observation; DetectorResult observation;
double thetaIncident; double thetaIncident;
@ -280,7 +280,7 @@ DetectorResult AnasenEfficiency::IsRing2(Mask::Nucleus& nucleus)
return observation; return observation;
} }
DetectorResult AnasenEfficiency::IsQQQ(Mask::Nucleus& nucleus) DetectorResult AnasenArray::IsQQQ(Mask::Nucleus& nucleus)
{ {
DetectorResult observation; DetectorResult observation;
double thetaIncident; double thetaIncident;
@ -324,7 +324,7 @@ DetectorResult AnasenEfficiency::IsQQQ(Mask::Nucleus& nucleus)
return observation; return observation;
} }
DetectorResult AnasenEfficiency::IsAnasen(Mask::Nucleus& nucleus) DetectorResult AnasenArray::IsAnasen(Mask::Nucleus& nucleus)
{ {
DetectorResult result; DetectorResult result;
if(nucleus.GetKE() <= s_energyThreshold) if(nucleus.GetKE() <= s_energyThreshold)
@ -339,7 +339,7 @@ DetectorResult AnasenEfficiency::IsAnasen(Mask::Nucleus& nucleus)
return result; return result;
} }
void AnasenEfficiency::CountCoincidences(const std::vector<Mask::Nucleus>& data, std::vector<int>& counts) void AnasenArray::CountCoincidences(const std::vector<Mask::Nucleus>& data, std::vector<int>& counts)
{ {
if (data.size() == 3 && data[1].isDetected && data[2].isDetected) if (data.size() == 3 && data[1].isDetected && data[2].isDetected)
{ {
@ -417,11 +417,11 @@ void AnasenEfficiency::CountCoincidences(const std::vector<Mask::Nucleus>& data,
} }
} }
void AnasenEfficiency::CalculateEfficiency(const std::string& inputname, const std::string& outputname, const std::string& statsname) { void AnasenArray::CalculateEfficiency(const std::string& inputname, const std::string& outputname, const std::string& statsname) {
if(!dmap.IsValid()) if(!dmap.IsValid())
{ {
std::cerr<<"Invalid Dead Channel Map at AnasenEfficiency::CalculateEfficiency()! If you want to run with all possible"; std::cerr<<"Invalid Dead Channel Map at AnasenArray::CalculateEfficiency()! If you want to run with all possible";
std::cerr<<"channels active, simply load an empty file."<<std::endl; std::cerr<<"channels active, simply load an empty file."<<std::endl;
return; return;
} }
@ -460,7 +460,7 @@ void AnasenEfficiency::CalculateEfficiency(const std::string& inputname, const s
case 8: coinc_counts.resize(11, 0); break; case 8: coinc_counts.resize(11, 0); break;
default: default:
{ {
std::cerr<<"Bad reaction type at AnasenEfficiency::CalculateEfficiency (given value: "<<counts.size()<<"). Quiting..."<<std::endl; std::cerr<<"Bad reaction type at AnasenArray::CalculateEfficiency (given value: "<<counts.size()<<"). Quiting..."<<std::endl;
input->Close(); input->Close();
output->Close(); output->Close();
stats.close(); stats.close();

View File

@ -1,23 +1,23 @@
#ifndef ANASEN_EFFICIENCY_H #ifndef ANASEN_ARRAY_H
#define ANASEN_EFFICIENCY_H #define ANASEN_ARRAY_H
#include <string> #include <string>
#include "DetectorEfficiency.h" #include "DetectorArray.h"
#include "SX3Detector.h" #include "SX3Detector.h"
#include "QQQDetector.h" #include "QQQDetector.h"
#include "Target.h" #include "Target.h"
#include "Nucleus.h" #include "Nucleus.h"
#include "AnasenDeadChannelMap.h" #include "AnasenDeadChannelMap.h"
class AnasenEfficiency : public DetectorEfficiency class AnasenArray : public DetectorArray
{ {
public: public:
AnasenEfficiency(); AnasenArray();
~AnasenEfficiency(); ~AnasenArray();
void CalculateEfficiency(const std::string& inputname, const std::string& outputname, const std::string& statsname) override; virtual void CalculateEfficiency(const std::string& inputname, const std::string& outputname, const std::string& statsname) override;
void DrawDetectorSystem(const std::string& filename) override; virtual void DrawDetectorSystem(const std::string& filename) override;
double RunConsistencyCheck() override; virtual double RunConsistencyCheck() override;
inline void SetDeadChannelMap(const std::string& filename) { dmap.LoadMapfile(filename); } inline void SetDeadChannelMap(const std::string& filename) { dmap.LoadMapfile(filename); }
private: private:
@ -27,7 +27,8 @@ private:
DetectorResult IsAnasen(Mask::Nucleus& nucleus); DetectorResult IsAnasen(Mask::Nucleus& nucleus);
void CountCoincidences(const std::vector<Mask::Nucleus>& data, std::vector<int>& counts); void CountCoincidences(const std::vector<Mask::Nucleus>& data, std::vector<int>& counts);
std::vector<StripDetector> m_Ring1, m_Ring2; std::vector<SX3Detector> m_Ring1;
std::vector<SX3Detector> m_Ring2;
std::vector<QQQDetector> m_forwardQQQs; std::vector<QQQDetector> m_forwardQQQs;
std::vector<QQQDetector> m_backwardQQQs; std::vector<QQQDetector> m_backwardQQQs;

View File

@ -4,18 +4,18 @@ target_include_directories(Detectors PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_
target_sources(Detectors PUBLIC target_sources(Detectors PUBLIC
AnasenDeadChannelMap.cpp AnasenDeadChannelMap.cpp
AnasenDeadChannelMap.h AnasenDeadChannelMap.h
AnasenEfficiency.cpp AnasenArray.cpp
AnasenEfficiency.h AnasenArray.h
main.cpp main.cpp
DetectorEfficiency.h DetectorArray.h
QQQDetector.cpp QQQDetector.cpp
QQQDetector.h QQQDetector.h
SabreDeadChannelMap.cpp SabreDeadChannelMap.cpp
SabreDeadChannelMap.h SabreDeadChannelMap.h
SabreDetector.cpp SabreDetector.cpp
SabreDetector.h SabreDetector.h
SabreEfficiency.cpp SabreArray.cpp
SabreEfficiency.h SabreArray.h
SX3Detector.cpp SX3Detector.cpp
SX3Detector.h SX3Detector.h
) )

View File

@ -1,5 +1,5 @@
#ifndef DETECTOREFFICIENCY_H #ifndef DETECTOR_ARRAY_H
#define DETECTOREFFICIENCY_H #define DETECTOR_ARRAY_H
#include <string> #include <string>
#include <cmath> #include <cmath>
@ -14,18 +14,18 @@ struct DetectorResult
std::string det_name = ""; std::string det_name = "";
}; };
class DetectorEfficiency class DetectorArray
{ {
public: public:
DetectorEfficiency() {}; DetectorArray() {};
virtual ~DetectorEfficiency() {}; virtual ~DetectorArray() {};
virtual void CalculateEfficiency(const std::string& inputname, const std::string& outputname, const std::string& statsname) = 0; virtual void CalculateEfficiency(const std::string& inputname, const std::string& outputname, const std::string& statsname) = 0;
virtual void DrawDetectorSystem(const std::string& filename) = 0; virtual void DrawDetectorSystem(const std::string& filename) = 0;
virtual double RunConsistencyCheck() = 0; virtual double RunConsistencyCheck() = 0;
protected: protected:
inline bool IsDoubleEqual(double x, double y) { return std::fabs(x-y) < s_epsilon ? true : false; }; bool IsDoubleEqual(double x, double y) { return std::fabs(x-y) < s_epsilon ? true : false; };
static constexpr double s_epsilon = 1.0e-6; static constexpr double s_epsilon = 1.0e-6;
}; };

View File

@ -15,7 +15,7 @@
y y
*/ */
StripDetector::StripDetector(double centerPhi, double centerZ, double centerRho) : SX3Detector::SX3Detector(double centerPhi, double centerZ, double centerRho) :
m_centerPhi(centerPhi), m_centerZ(centerZ), m_centerRho(centerRho), m_norm(1.0,0.0,0.0), m_uniformFraction(0.0, 1.0), m_isSmearing(false) m_centerPhi(centerPhi), m_centerZ(centerZ), m_centerRho(centerRho), m_norm(1.0,0.0,0.0), m_uniformFraction(0.0, 1.0), m_isSmearing(false)
{ {
m_zRotation.SetAngle(m_centerPhi); m_zRotation.SetAngle(m_centerPhi);
@ -35,9 +35,9 @@ StripDetector::StripDetector(double centerPhi, double centerZ, double centerRho)
} }
StripDetector::~StripDetector() {} SX3Detector::~SX3Detector() {}
void StripDetector::CalculateCorners() void SX3Detector::CalculateCorners()
{ {
double y_min, y_max, z_min, z_max; double y_min, y_max, z_min, z_max;
for (int s=0; s<s_nStrips; s++) for (int s=0; s<s_nStrips; s++)
@ -75,7 +75,7 @@ void StripDetector::CalculateCorners()
} }
} }
ROOT::Math::XYZPoint StripDetector::GetHitCoordinates(int front_stripch, double front_strip_ratio) ROOT::Math::XYZPoint SX3Detector::GetHitCoordinates(int front_stripch, double front_strip_ratio)
{ {
if (!ValidChannel(front_stripch) || !ValidRatio(front_strip_ratio)) if (!ValidChannel(front_stripch) || !ValidRatio(front_strip_ratio))
@ -95,10 +95,10 @@ ROOT::Math::XYZPoint StripDetector::GetHitCoordinates(int front_stripch, double
} }
StripHit StripDetector::GetChannelRatio(double theta, double phi) SX3Hit SX3Detector::GetChannelRatio(double theta, double phi)
{ {
StripHit hit; SX3Hit hit;
while (phi < 0) while (phi < 0)
phi += 2*M_PI; phi += 2*M_PI;

View File

@ -19,19 +19,19 @@
#include "Math/RotationZ.h" #include "Math/RotationZ.h"
#include "Mask/RandomGenerator.h" #include "Mask/RandomGenerator.h"
struct StripHit struct SX3Hit
{ {
int front_strip_index=-1; int front_strip_index=-1;
int back_strip_index=-1; int back_strip_index=-1;
double front_ratio=0.0; double front_ratio=0.0;
}; };
class StripDetector class SX3Detector
{ {
public: public:
StripDetector(double centerPhi, double centerZ, double centerRho); SX3Detector(double centerPhi, double centerZ, double centerRho);
~StripDetector(); ~SX3Detector();
const ROOT::Math::XYZPoint& GetFrontStripCoordinates(int stripch, int corner) const { return m_frontStripCoords[stripch][corner]; } const ROOT::Math::XYZPoint& GetFrontStripCoordinates(int stripch, int corner) const { return m_frontStripCoords[stripch][corner]; }
const ROOT::Math::XYZPoint& GetBackStripCoordinates(int stripch, int corner) const { return m_backStripCoords[stripch][corner]; } const ROOT::Math::XYZPoint& GetBackStripCoordinates(int stripch, int corner) const { return m_backStripCoords[stripch][corner]; }
const ROOT::Math::XYZPoint& GetRotatedFrontStripCoordinates(int stripch, int corner) const const ROOT::Math::XYZPoint& GetRotatedFrontStripCoordinates(int stripch, int corner) const
@ -47,7 +47,7 @@ public:
void SetPixelSmearing(bool isSmearing) { m_isSmearing = isSmearing; } void SetPixelSmearing(bool isSmearing) { m_isSmearing = isSmearing; }
ROOT::Math::XYZPoint GetHitCoordinates(int front_stripch, double front_strip_ratio); ROOT::Math::XYZPoint GetHitCoordinates(int front_stripch, double front_strip_ratio);
StripHit GetChannelRatio(double theta, double phi); SX3Hit GetChannelRatio(double theta, double phi);
private: private:
bool ValidChannel(int f) { return ((f >= 0 && f < s_nStrips) ? true : false); }; bool ValidChannel(int f) { return ((f >= 0 && f < s_nStrips) ? true : false); };

View File

@ -1,4 +1,4 @@
#include "SabreEfficiency.h" #include "SabreArray.h"
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
@ -7,8 +7,8 @@
#include "TTree.h" #include "TTree.h"
SabreEfficiency::SabreEfficiency() : SabreArray::SabreArray() :
DetectorEfficiency(), m_deadlayerEloss({14}, {28}, {1}, s_deadlayerThickness), DetectorArray(), m_deadlayerEloss({14}, {28}, {1}, s_deadlayerThickness),
m_detectorEloss({14}, {28}, {1}, s_detectorThickness), m_degraderEloss({73}, {181}, {1}, s_degraderThickness) m_detectorEloss({14}, {28}, {1}, s_detectorThickness), m_degraderEloss({73}, {181}, {1}, s_degraderThickness)
{ {
@ -29,9 +29,9 @@ SabreEfficiency::SabreEfficiency() :
m_activeDetectors[4] = false; m_activeDetectors[4] = false;
} }
SabreEfficiency::~SabreEfficiency() {} SabreArray::~SabreArray() {}
void SabreEfficiency::CalculateEfficiency(const std::string& inputname, const std::string& outputname, const std::string& statsname) void SabreArray::CalculateEfficiency(const std::string& inputname, const std::string& outputname, const std::string& statsname)
{ {
std::cout<<"----------SABRE Efficiency Calculation----------"<<std::endl; std::cout<<"----------SABRE Efficiency Calculation----------"<<std::endl;
std::cout<<"Loading in output from kinematics simulation: "<<inputname<<std::endl; std::cout<<"Loading in output from kinematics simulation: "<<inputname<<std::endl;
@ -186,7 +186,7 @@ void SabreEfficiency::CalculateEfficiency(const std::string& inputname, const st
std::cout<<"---------------------------------------------"<<std::endl; std::cout<<"---------------------------------------------"<<std::endl;
} }
void SabreEfficiency::DrawDetectorSystem(const std::string& filename) void SabreArray::DrawDetectorSystem(const std::string& filename)
{ {
std::ofstream output(filename); std::ofstream output(filename);
@ -231,7 +231,7 @@ void SabreEfficiency::DrawDetectorSystem(const std::string& filename)
output.close(); output.close();
} }
double SabreEfficiency::RunConsistencyCheck() double SabreArray::RunConsistencyCheck()
{ {
double theta, phi; double theta, phi;
double npoints = 5.0*16.0*4.0; double npoints = 5.0*16.0*4.0;
@ -260,7 +260,7 @@ double SabreEfficiency::RunConsistencyCheck()
} }
/*Returns if detected, as well as total energy deposited in SABRE*/ /*Returns if detected, as well as total energy deposited in SABRE*/
DetectorResult SabreEfficiency::IsSabre(Mask::Nucleus& nucleus) DetectorResult SabreArray::IsSabre(Mask::Nucleus& nucleus)
{ {
DetectorResult observation; DetectorResult observation;
if(nucleus.GetKE() <= s_energyThreshold) if(nucleus.GetKE() <= s_energyThreshold)
@ -300,7 +300,7 @@ DetectorResult SabreEfficiency::IsSabre(Mask::Nucleus& nucleus)
return observation; return observation;
} }
void SabreEfficiency::CountCoincidences(const std::vector<Mask::Nucleus>& data, std::vector<int>& counts) void SabreArray::CountCoincidences(const std::vector<Mask::Nucleus>& data, std::vector<int>& counts)
{ {
if (data.size() == 3 && data[1].isDetected && data[2].isDetected) if (data.size() == 3 && data[1].isDetected && data[2].isDetected)
{ {

View File

@ -1,17 +1,17 @@
#ifndef SABREEFFICIENCY_H #ifndef SABRE_ARRAY_H
#define SABREEFFICIENCY_H #define SABRE_ARRAY_H
#include "DetectorEfficiency.h" #include "DetectorArray.h"
#include "SabreDetector.h" #include "SabreDetector.h"
#include "Target.h" #include "Target.h"
#include "SabreDeadChannelMap.h" #include "SabreDeadChannelMap.h"
#include "Mask/Nucleus.h" #include "Mask/Nucleus.h"
class SabreEfficiency : public DetectorEfficiency class SabreArray : public DetectorArray
{ {
public: public:
SabreEfficiency(); SabreArray();
~SabreEfficiency(); ~SabreArray();
void SetDeadChannelMap(const std::string& filename) { m_deadMap.LoadMapfile(filename); }; void SetDeadChannelMap(const std::string& filename) { m_deadMap.LoadMapfile(filename); };
void CalculateEfficiency(const std::string& inputname, const std::string& outputname, const std::string& statsname) override; void CalculateEfficiency(const std::string& inputname, const std::string& outputname, const std::string& statsname) override;
void DrawDetectorSystem(const std::string& filename) override; void DrawDetectorSystem(const std::string& filename) override;

View File

@ -1,5 +1,5 @@
#include "SabreEfficiency.h" #include "SabreArray.h"
#include "AnasenEfficiency.h" #include "AnasenArray.h"
#include "KinematicsExceptions.h" #include "KinematicsExceptions.h"
#include <iostream> #include <iostream>
#include <string> #include <string>
@ -24,7 +24,7 @@ int main(int argc, char** argv)
std::string statsname = argv[3]; std::string statsname = argv[3];
SabreEfficiency sabre; SabreArray sabre;
std::string mapfile = "./etc/sabreDeadChannels_May2022.txt"; std::string mapfile = "./etc/sabreDeadChannels_May2022.txt";
sabre.SetDeadChannelMap(mapfile); sabre.SetDeadChannelMap(mapfile);
sabre.CalculateEfficiency(inputname, outputname, statsname); sabre.CalculateEfficiency(inputname, outputname, statsname);
@ -33,7 +33,7 @@ int main(int argc, char** argv)
/* /*
AnasenEfficiency anasen; AnasenArray anasen;
std::string mapfile = "./etc/AnasenDeadChannels.txt"; std::string mapfile = "./etc/AnasenDeadChannels.txt";
anasen.SetDeadChannelMap(mapfile); anasen.SetDeadChannelMap(mapfile);
anasen.CalculateEfficiency(inputname, outputname, statsname); anasen.CalculateEfficiency(inputname, outputname, statsname);