Skip to content

Commit

Permalink
Segmented Crystal ECAL (SCEPCal) geometry addition
Browse files Browse the repository at this point in the history
  • Loading branch information
wonyongc committed Dec 11, 2024
1 parent 37e6562 commit a6d10af
Show file tree
Hide file tree
Showing 10 changed files with 1,771 additions and 0 deletions.
577 changes: 577 additions & 0 deletions detector/calorimeter/SCEPCalConstructor.cpp

Large diffs are not rendered by default.

75 changes: 75 additions & 0 deletions detectorSegmentations/include/detectorSegmentations/DRCrystalHit.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
//===============================
// Author: Wonyong Chung
// Princeton University
//===============================
#ifndef DRCrystalHit_h
#define DRCrystalHit_h 1
#include "G4VHit.hh"
#include "G4THitsCollection.hh"
#include "G4Allocator.hh"
#include "G4ThreeVector.hh"
#include "DDG4/Geant4Data.h"
#include "G4OpticalPhoton.hh"
#include "G4VProcess.hh"
#include "DD4hep/Objects.h"
#include "DD4hep/Segmentations.h"
#include "CLHEP/Vector/ThreeVector.h"

namespace SCEPCal {

typedef ROOT::Math::XYZVector Position;

const int nsipmbins=6000;

class DRCrystalHit : public dd4hep::sim::Geant4HitData {

public:
typedef dd4hep::sim::Geant4HitData base_t;

Position position;
Contributions truth;
double energyDeposit;

int eta;
int phi;
int depth;
int system;

int ncerenkov;
int nscintillator;

int nbins=nsipmbins;

float wavelen_min=300;
float wavelen_max=1000;

float time_min=0;
float time_max=300;

std::array<int,nsipmbins> nwavelen_cer;
std::array<int,nsipmbins> nwavelen_scint;

std::array<int,nsipmbins> ntime_cer;
std::array<int,nsipmbins> ntime_scint;

public:
DRCrystalHit();
DRCrystalHit(DRCrystalHit&& c) = delete;
DRCrystalHit(const DRCrystalHit& c) = delete;
DRCrystalHit(const Position& cell_pos);
virtual ~DRCrystalHit();
DRCrystalHit& operator=(DRCrystalHit&& c) = delete;
DRCrystalHit& operator=(const DRCrystalHit& c) = delete;
};
};

#if defined(__CINT__) || defined(__MAKECINT__) || defined(__CLING__) || defined(__ROOTCLING__)
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ namespace dd4hep;
#pragma link C++ namespace dd4hep::sim;
#pragma link C++ namespace SCEPCal;
#pragma link C++ class SCEPCal::DRCrystalHit+;
#endif
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
//===============================
// Author: Wonyong Chung
// Princeton University
//===============================
#ifndef SCEPCalSegmentation_h
#define SCEPCalSegmentation_h 1
#include "DDSegmentation/Segmentation.h"
#include "TVector3.h"
#include "DD4hep/DetFactoryHelper.h"
#include <vector>
#include <cmath>

namespace dd4hep {
namespace DDSegmentation {

class SCEPCalSegmentation : public Segmentation {
public:
SCEPCalSegmentation(const std::string& aCellEncoding);
SCEPCalSegmentation(const BitFieldCoder* decoder);
virtual ~SCEPCalSegmentation() override;

virtual Vector3D position(const CellID& aCellID) const;

virtual Vector3D myPosition(const CellID& aCellID) ;

virtual CellID cellID(const Vector3D& aLocalPosition,
const Vector3D& aGlobalPosition,
const VolumeID& aVolumeID) const;

VolumeID setVolumeID(int System, int Eta, int Phi, int Depth) const;
CellID setCellID(int System, int Eta, int Phi, int Depth) const;

int System(const CellID& aCellID) const;
int Eta(const CellID& aCellID) const;
int Phi(const CellID& aCellID) const;
int Depth(const CellID& aCellID) const;

int getFirst32bits(const CellID& aCellID) const { return (int)aCellID; }
int getLast32bits(const CellID& aCellID) const;

CellID convertFirst32to64(const int aId32) const { return (CellID)aId32; }
CellID convertLast32to64(const int aId32) const;

int System(const int& aId32) const { return System( convertFirst32to64(aId32) ); }
int Eta(const int& aId32) const { return Eta( convertFirst32to64(aId32) ); }
int Phi(const int& aId32) const { return Phi( convertFirst32to64(aId32) ); }
int Depth(const int& aId32) const { return Depth( convertFirst32to64(aId32) ); }

inline void setGeomParams(double Fdz, double Rdz,
double nomfw, double nomth,
double EBz, double Rin,
double sipmth,
int phiSegments, int NProjectiveFill) {
f_Fdz = Fdz;
f_Rdz = Rdz;
f_nomfw = nomfw;
f_nomth = nomth;
f_EBz = EBz;
f_Rin = Rin;
f_sipmth = sipmth;
f_phiSegments = phiSegments;
f_NProjectiveFill = NProjectiveFill;
}

inline double getFdz() const{ return f_Fdz; }
inline double getRdz() const{ return f_Rdz; }
inline double getnomfw() const{ return f_nomfw; }
inline double getnomth() const{ return f_nomth; }
inline double getEBz() const{ return f_EBz; }
inline double getRin() const{ return f_Rin; }
inline double getSipmth() const{ return f_sipmth; }
inline int getphiSegments() const{ return f_phiSegments; }
inline int getNProjectiveFill() const{ return f_NProjectiveFill; }

protected:
std::string fSystemId;
std::string fEtaId;
std::string fPhiId;
std::string fDepthId;

double f_Fdz;
double f_Rdz;
double f_nomfw;
double f_nomth;
double f_EBz;
double f_Rin;
double f_sipmth;
int f_phiSegments;
int f_NProjectiveFill;

private:
std::unordered_map<int, Vector3D> fPositionOf;

};
}
}

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
//===============================
// Author: Wonyong Chung
// Princeton University
//===============================
#ifndef SCEPCalSegmentationHandle_h
#define SCEPCalSegmentationHandle_h 1
#include "detectorSegmentations/SCEPCalSegmentation.h"
#include "DD4hep/Segmentations.h"
#include "DD4hep/detail/SegmentationsInterna.h"

namespace dd4hep {

class Segmentation;
template <typename T>
class SegmentationWrapper;

typedef Handle<SegmentationWrapper<DDSegmentation::SCEPCalSegmentation>> SCEPCalSegmentationHandle;

class SCEPCalSegmentation : public SCEPCalSegmentationHandle {
public:
typedef SCEPCalSegmentationHandle::Object Object;

public:
SCEPCalSegmentation() = default;
SCEPCalSegmentation(const SCEPCalSegmentation& e) = default;
SCEPCalSegmentation(const Segmentation& e) : Handle<Object>(e) {}
SCEPCalSegmentation(const Handle<Object>& e) : Handle<Object>(e) {}
template <typename Q>
SCEPCalSegmentation(const Handle<Q>& e) : Handle<Object>(e) {}
SCEPCalSegmentation& operator=(const SCEPCalSegmentation& seg) = default;
bool operator==(const SCEPCalSegmentation& seg) const { return m_element == seg.m_element; }

inline Position position(const CellID& id) const {
return Position(access()->implementation->position(id));
}

inline dd4hep::CellID cellID(const Position& local, const Position& global, const VolumeID& volID) const {
return access()->implementation->cellID(local, global, volID);
}

inline VolumeID setVolumeID(int System, int Eta, int Phi, int Depth) const {
return access()->implementation->setVolumeID(System, Eta,Phi,Depth);
}

inline CellID setCellID(int System, int Eta, int Phi, int Depth) const {
return access()->implementation->setCellID(System, Eta, Phi, Depth);
}

inline int System(const CellID& aCellID) const { return access()->implementation->System(aCellID); }
inline int Eta(const CellID& aCellID) const { return access()->implementation->Eta(aCellID); }
inline int Phi(const CellID& aCellID) const { return access()->implementation->Phi(aCellID); }
inline int Depth(const CellID& aCellID) const { return access()->implementation->Depth(aCellID); }

inline int getFirst32bits(const CellID& aCellID) const { return access()->implementation->getFirst32bits(aCellID); }
inline int getLast32bits(const CellID& aCellID) const { return access()->implementation->getLast32bits(aCellID); }

inline CellID convertFirst32to64(const int aId32) const { return access()->implementation->convertFirst32to64(aId32); }
inline CellID convertLast32to64(const int aId32) const { return access()->implementation->convertLast32to64(aId32); }

inline int System(const int& aId32) const { return access()->implementation->System(aId32); }
inline int Eta(const int& aId32) const { return access()->implementation->Eta(aId32); }
inline int Phi(const int& aId32) const { return access()->implementation->Phi(aId32); }
inline int Depth(const int& aId32) const { return access()->implementation->Depth(aId32); }

inline void setGeomParams(double Fdz, double Rdz,
double nomfw, double nomth,
double EBz, double Rin,
double sipmth,
int phiSegments,
int NProjectiveFill) const {
return access()->implementation->setGeomParams(Fdz,Rdz,nomfw,nomth,EBz,Rin,sipmth,phiSegments,NProjectiveFill);
}

inline double getFdz() const{ return access()->implementation->getFdz(); }
inline double getRdz() const{ return access()->implementation->getRdz(); }
inline double getnomfw() const{ return access()->implementation->getnomfw(); }
inline double getnomth() const{ return access()->implementation->getnomth(); }
inline double getEBz() const{ return access()->implementation->getEBz(); }
inline double getRin() const{ return access()->implementation->getRin(); }
inline double getSipmth() const{ return access()->implementation->getSipmth(); }
inline int getphiSegments() const{ return access()->implementation->getphiSegments(); }
inline int getNProjectiveFill() const{ return access()->implementation->getNProjectiveFill(); }

};

}
#endif
49 changes: 49 additions & 0 deletions detectorSegmentations/src/DRCrystalHit.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//===============================
// Author: Wonyong Chung
// Princeton University
//===============================
#include <DD4hep/Printout.h>
#include <DD4hep/InstanceCount.h>
#include <DDG4/Geant4Data.h>
#include <DDG4/Geant4StepHandler.h>
#include <DDG4/Geant4FastSimHandler.h>
#include <G4Step.hh>
#include <G4Allocator.hh>
#include <G4OpticalPhoton.hh>
#include "detectorSegmentations/DRCrystalHit.h"
#include "G4Track.hh"

using namespace dd4hep::sim;
using namespace dd4hep;
using namespace std;
using namespace SCEPCal;

DRCrystalHit::DRCrystalHit()
: Geant4HitData(), position(), truth(), energyDeposit(0), eta(0), phi(0), depth(0), system(0), ncerenkov(0), nscintillator(0) {

InstanceCount::increment(this);

for( int i=0; i<nsipmbins; i++) {
nwavelen_cer[i]=0;
nwavelen_scint[i]=0;
ntime_cer[i]=0;
ntime_scint[i]=0;
}
}

DRCrystalHit::DRCrystalHit(const Position& pos)
: Geant4HitData(), position(pos), truth(), energyDeposit(0), eta(0), phi(0), depth(0), system(0), ncerenkov(0), nscintillator(0) {

InstanceCount::increment(this);

for( int i=0; i<nsipmbins; i++) {
nwavelen_cer[i]=0;
nwavelen_scint[i]=0;
ntime_cer[i]=0;
ntime_scint[i]=0;
}
}

DRCrystalHit::~DRCrystalHit() {
InstanceCount::decrement(this);
}
Loading

0 comments on commit a6d10af

Please sign in to comment.