Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Origin/calo geom g4 update #1311

Closed
wants to merge 14 commits into from
6 changes: 3 additions & 3 deletions Analyses/src/DiskCal00_module.cc
Original file line number Diff line number Diff line change
@@ -266,15 +266,15 @@ namespace mu2e {

void DiskCal00::printCalInfo(){
DiskCalorimeter const& cal(*GeomHandle<DiskCalorimeter>());
int nSiPM = cal.nCrystal()*cal.caloInfo().getInt("nSiPMPerCrystal");
int nSiPM = cal.nCrystals()*cal.caloInfo().getInt("nSiPMPerCrystal");
cout << "Information about the disk Calorimeter: " << endl;
cout << "Number of disks: " << cal.nDisk() << endl;
cout << "Number of disks: " << cal.nDisks() << endl;
cout << "Number of Readouts: " << nSiPM << " " << CaloConst::_nSiPMPerCrystal << " " << nSiPM/CaloConst::_nSiPMPerCrystal << endl;
cout << "Hex side size: " << 2.0*cal.caloInfo().getDouble("crystalXYLength") << endl;

cout << "Depth: " << cal.caloInfo().getDouble("crystalZLength") << endl;
cout << "Origin: " << cal.geomUtil().origin() << endl;
for (unsigned i=0; i<cal.nDisk(); ++i){
for (unsigned i=0; i<cal.nDisks(); ++i){
Disk const& disk = cal.disk(i);
cout << "Disk: " << i << " " << "origin: " << disk.geomInfo().origin() << endl;
}
7 changes: 1 addition & 6 deletions Analyses/src/PbarAnalysis2_module.cc
Original file line number Diff line number Diff line change
@@ -179,7 +179,7 @@ namespace mu2e {
float _genmomX[16384],_genmomY[16384],_genmomZ[16384],_genStartX[16384],_genStartY[16384],_genStartZ[16384],_genStartT[16384];

int _nHits,_cryId[163840],_crySectionId[163840],_crySimIdx[163840],_crySimLen[163840];
float _cryEtot,_cryTime[163840],_cryEdep[163840],_cryDose[163840],_cryPosX[163840],_cryPosY[163840],_cryPosZ[163840],_cryLeak[163840];
float _cryEtot,_cryTime[163840],_cryEdep[163840],_cryPosX[163840],_cryPosY[163840],_cryPosZ[163840],_cryLeak[163840];

int _nSim,_motId[500000],_motPdgId[500000],_motcrCode[500000],_motGenIdx[500000];
float _motmom[500000],_motStartX[500000],_motStartY[500000],_motStartZ[500000],_motStartT[500000];
@@ -299,7 +299,6 @@ namespace mu2e {
_Ntup->Branch("cryPosZ", &_cryPosZ , "cryPosZ[nCry]/F");
_Ntup->Branch("cryEdep", &_cryEdep , "cryEdep[nCry]/F");
_Ntup->Branch("cryTime", &_cryTime , "cryTime[nCry]/F");
_Ntup->Branch("cryDose", &_cryDose , "cryDose[nCry]/F");
_Ntup->Branch("crySimIdx", &_crySimIdx , "crySimIdx[nCry]/I");
_Ntup->Branch("crySimLen", &_crySimLen , "crySimLen[nCry]/I");

@@ -486,9 +485,6 @@ namespace mu2e {
event.getByLabel(_trackClusterMatchModuleLabel, trackClusterMatchHandle);
TrackClusterMatchCollection const& trackClusterMatches(*trackClusterMatchHandle);

const double CrDensity = 4.9*(CLHEP::g/CLHEP::cm3);
const double CrMass = CrDensity*cal.caloInfo().crystalVolume();


std::map<art::Ptr<SimParticle>, const StepPointMC*> vdMap;
if (vdhits.isValid())
@@ -694,7 +690,6 @@ namespace mu2e {
_cryEtot += hit.energyDep();
_cryTime[_nHits] = hit.time();
_cryEdep[_nHits] = hit.energyDep();
_cryDose[_nHits] = hit.energyDep() / CrMass / (CLHEP::joule/CLHEP::kg); //dose
_cryPosX[_nHits] = crystalPos.x();
_cryPosY[_nHits] = crystalPos.y();
_cryPosZ[_nHits] = crystalPos.z();
2 changes: 1 addition & 1 deletion Analyses/src/ReadCaloDigi_module.cc
Original file line number Diff line number Diff line change
@@ -446,7 +446,7 @@ namespace mu2e {

_evt = event.id().event();
_run = event.run();
_caloCrystals = _calorimeter->nCrystal();
_caloCrystals = _calorimeter->nCrystals();
_caloDisk0Crystals = _calorimeter->disk(0).nCrystals();
_caloDisk1Crystals = _calorimeter->disk(1).nCrystals();
_nTrkGood = 0;
2 changes: 1 addition & 1 deletion CaloCluster/src/CaloClusterFast_module.cc
Original file line number Diff line number Diff line change
@@ -114,7 +114,7 @@ namespace mu2e {

//start the clustering algorithm for the hits between iStart and iStop
std::queue<int> crystalToVisit;
std::vector<bool> isVisited(cal.nCrystal());
std::vector<bool> isVisited(cal.nCrystals());

//put the first hit in the cluster list
std::vector<size_t> clusterList{*iterSeed};
2 changes: 1 addition & 1 deletion CaloCluster/src/CaloProtoClusterMaker_module.cc
Original file line number Diff line number Diff line change
@@ -111,7 +111,7 @@ namespace mu2e {


//declare and fill the hash map crystal_id -> list of CaloHits
std::vector<CaloCrystalList> mainClusterList, splitClusterList, caloIdHitMap(cal.nCrystal());
std::vector<CaloCrystalList> mainClusterList, splitClusterList, caloIdHitMap(cal.nCrystals());
std::set<const CaloHit*> seedList;
std::vector<double> clusterTime;

2 changes: 1 addition & 1 deletion CaloCluster/src/ClusterFinder.cc
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@
namespace mu2e {

ClusterFinder::ClusterFinder(const Calorimeter& cal, const CaloHit* crystalSeed, double deltaTime, double ExpandCut, bool addSecondRing) :
cal_(&cal), crystalSeed_(crystalSeed), seedTime_(crystalSeed->time()), clusterList_(), crystalToVisit_(), isVisited_(cal.nCrystal()),
cal_(&cal), crystalSeed_(crystalSeed), seedTime_(crystalSeed->time()), clusterList_(), crystalToVisit_(), isVisited_(cal.nCrystals()),
deltaTime_(deltaTime), ExpandCut_(ExpandCut), addSecondRing_(addSecondRing)
{}

4 changes: 2 additions & 2 deletions CaloMC/src/CaloDigiMaker_module.cc
Original file line number Diff line number Diff line change
@@ -186,14 +186,14 @@ namespace mu2e {

ConditionsHandle<CalorimeterCalibrations> calorimeterCalibrations("ignored");

if (calorimeter_->nCrystal()<1 || calorimeter_->caloInfo().getInt("nSiPMPerCrystal")<1) return;
if (calorimeter_->nCrystals()<1 || calorimeter_->caloInfo().getInt("nSiPMPerCrystal")<1) return;
int waveformSize = (digitizationEnd_ - digitizationStart_ + startTimeBuffer_) / digiSampling_;
if (ewMarker.spillType() != EventWindowMarker::SpillType::onspill)
{
waveformSize = (ewMarker.eventLength() - digitizationStart_ + startTimeBuffer_) / digiSampling_;
}

int nWaveforms = calorimeter_->nCrystal()*calorimeter_->caloInfo().getInt("nSiPMPerCrystal");
int nWaveforms = calorimeter_->nCrystals()*calorimeter_->caloInfo().getInt("nSiPMPerCrystal");
if (waveformSize<1) throw cet::exception("Rethrow")<< "[CaloMC/CaloDigiMaker] digitization size too short " << std::endl;
bool resetWaveform(false);
std::vector<double> waveform(waveformSize,0.0);
2 changes: 1 addition & 1 deletion CaloReco/src/CaloHitMaker_module.cc
Original file line number Diff line number Diff line change
@@ -113,7 +113,7 @@ namespace mu2e {


// fill the map that associate for each crystal the corresponding CaloRecoDigi indexes
int nSiPM = cal.nCrystal()*cal.caloInfo().getInt("nSiPMPerCrystal");
int nSiPM = cal.nCrystals()*cal.caloInfo().getInt("nSiPMPerCrystal");
std::vector<std::vector<const CaloRecoDigi*>> hitMap(nSiPM,std::vector<const CaloRecoDigi*>());

for (unsigned i=0; i< recoCaloDigis.size(); ++i)
44 changes: 19 additions & 25 deletions CalorimeterGeom/inc/CaloGeomUtil.hh
Original file line number Diff line number Diff line change
@@ -23,47 +23,41 @@ namespace mu2e {
class CaloGeomUtil {

public:

CaloGeomUtil(const std::vector<std::shared_ptr<Disk>>& disks,
const std::vector<const Crystal*>& fullCrystalList);

void origin(const CLHEP::Hep3Vector& vec) {origin_ = vec;}
void trackerCenter(const CLHEP::Hep3Vector& vec) {trackerCenter_ = vec;}
void crystalZLength(double value) {crystalZLength_ = value;}

const CLHEP::Hep3Vector& origin() const {return origin_;}
const CLHEP::Hep3Vector& trackerCenter() const {return trackerCenter_;}
const double crystalZLength() const {return crystalZLength_;}
void origin (const CLHEP::Hep3Vector& vec) {origin_ = vec;}
void trackerCenter (const CLHEP::Hep3Vector& vec) {trackerCenter_ = vec;}
void crystalZLength(double value) {crystalZLength_ = value;}

const Disk& disk(int i) const {return *disks_.at(i);}
const CLHEP::Hep3Vector& origin() const {return origin_;}
const CLHEP::Hep3Vector& trackerCenter() const {return trackerCenter_;}
const double crystalZLength() const {return crystalZLength_;}
const Disk& disk(int i) const {return *disks_.at(i);}


CLHEP::Hep3Vector mu2eToCrystal( int crystalId, const CLHEP::Hep3Vector& pos) const;
CLHEP::Hep3Vector mu2eToDisk( int diskId, const CLHEP::Hep3Vector& pos) const;
CLHEP::Hep3Vector mu2eToDiskFF( int diskId, const CLHEP::Hep3Vector& pos) const;
CLHEP::Hep3Vector mu2eToTracker( const CLHEP::Hep3Vector& pos) const;
CLHEP::Hep3Vector mu2eToCrystal(int crystalId, const CLHEP::Hep3Vector& pos) const;
CLHEP::Hep3Vector mu2eToDisk (int diskId, const CLHEP::Hep3Vector& pos) const;
CLHEP::Hep3Vector mu2eToDiskFF (int diskId, const CLHEP::Hep3Vector& pos) const;
CLHEP::Hep3Vector mu2eToTracker(const CLHEP::Hep3Vector& pos) const;

CLHEP::Hep3Vector crystalToMu2e( int crystalId, const CLHEP::Hep3Vector& pos) const;
CLHEP::Hep3Vector diskToMu2e( int diskId, const CLHEP::Hep3Vector& pos) const;
CLHEP::Hep3Vector diskFFToMu2e( int diskId, const CLHEP::Hep3Vector& pos) const;
CLHEP::Hep3Vector trackerToMu2e( const CLHEP::Hep3Vector& pos) const;
CLHEP::Hep3Vector crystalToMu2e(int crystalId, const CLHEP::Hep3Vector& pos) const;
CLHEP::Hep3Vector diskToMu2e (int diskId, const CLHEP::Hep3Vector& pos) const;
CLHEP::Hep3Vector diskFFToMu2e (int diskId, const CLHEP::Hep3Vector& pos) const;
CLHEP::Hep3Vector trackerToMu2e(const CLHEP::Hep3Vector& pos) const;

bool isInsideCalorimeter(const CLHEP::Hep3Vector& pos) const;
bool isInsideSection(int iDisk, const CLHEP::Hep3Vector& pos) const;
bool isContainedSection(const CLHEP::Hep3Vector& front, const CLHEP::Hep3Vector& back) const;
bool isInsideCalorimeter (const CLHEP::Hep3Vector& pos) const;
bool isInsideSection (int iDisk, const CLHEP::Hep3Vector& pos) const;
bool isContainedSection (const CLHEP::Hep3Vector& front, const CLHEP::Hep3Vector& back) const;


private:

const std::vector<std::shared_ptr<Disk>>& disks_;
const std::vector<const Crystal*>& fullCrystalList_;
const std::vector<const Crystal*>& fullCrystalList_; //non-owning pointers
CLHEP::Hep3Vector origin_;
CLHEP::Hep3Vector trackerCenter_;
double crystalZLength_;


};

}

#endif
31 changes: 14 additions & 17 deletions CalorimeterGeom/inc/CaloInfo.hh
Original file line number Diff line number Diff line change
@@ -8,15 +8,13 @@
#define CalorimeterGeom_CaloInfo_hh

#include "cetlib_except/exception.h"

#include <vector>
#include <map>
#include <string>


namespace mu2e {

//helper class
template <typename T> class CaloInfoData
{
public:
@@ -29,8 +27,7 @@ namespace mu2e {
return iter->second;
};

void set(const std::string key, const T& value) {data_[key] = value;}

void set(const std::string& key, const T& value) {data_[key] = value;}

private:
std::map<std::string,T> data_;
@@ -41,27 +38,27 @@ namespace mu2e {
class CaloInfo {

public:
CaloInfo() : dataBool_(),dataInt_(),dataDouble_(),dataVDouble_() {}

void set(const std::string& key, int value) {dataInt_.set(key,value);}
void set(const std::string& key, double value) {dataDouble_.set(key,value);}
void set(const std::string& key, const std::vector<double>& value){dataVDouble_.set(key,value);}

const bool getBool(const std::string& key) const {return dataBool_.get(key);}
const int getInt(const std::string& key) const {return dataInt_.get(key);}
const double getDouble(const std::string& key) const {return dataDouble_.get(key);}
CaloInfo() : dataBool_(), dataInt_(), dataDouble_(), dataVInt_(), dataVDouble_() {}

void set(const std::string& key, bool value) {dataBool_.set(key,value);}
void set(const std::string& key, int value) {dataInt_.set(key,value);}
void set(const std::string& key, double value) {dataDouble_.set(key,value);}
void set(const std::string& key, const std::vector<int>& value) {dataVInt_.set(key,value);}
void set(const std::string& key, const std::vector<double>& value) {dataVDouble_.set(key,value);}

const bool getBool (const std::string& key) const {return dataBool_.get(key);}
const int getInt (const std::string& key) const {return dataInt_.get(key);}
const double getDouble (const std::string& key) const {return dataDouble_.get(key);}
const std::vector<int> getVInt (const std::string& key) const {return dataVInt_.get(key);}
const std::vector<double> getVDouble(const std::string& key) const {return dataVDouble_.get(key);}

//helper function
double crystalVolume() const {return dataDouble_.get("crystalXYLength")*dataDouble_.get("crystalXYLength")*dataDouble_.get("crystalZLength");}

private:
CaloInfoData<bool> dataBool_;
CaloInfoData<int> dataInt_;
CaloInfoData<double> dataDouble_;
CaloInfoData<std::vector<int>> dataVInt_;
CaloInfoData<std::vector<double>> dataVDouble_;
};

}

#endif
39 changes: 15 additions & 24 deletions CalorimeterGeom/inc/Calorimeter.hh
Original file line number Diff line number Diff line change
@@ -16,43 +16,34 @@
#include "CLHEP/Vector/ThreeVector.h"
#include <vector>


namespace mu2e {

class Calorimeter: virtual public Detector {

public:

//no constructor for this interface
virtual ~Calorimeter(){};


// calo section
virtual unsigned nDisk() const = 0;
virtual const Disk& disk(int i) const = 0;
virtual ~Calorimeter() = default;

virtual size_t nDisks() const = 0;
virtual const Disk& disk(size_t i) const = 0;
virtual const DiskPtrs& diskPtrs() const = 0;

// crystal section - fast access
virtual int nCrystal() const = 0;
virtual const Crystal& crystal(int i) const = 0;
virtual size_t nCrystals() const = 0;
virtual const Crystal& crystal(size_t i) const = 0;
virtual const CrystalPtrs& crystalPtrs() const = 0;

virtual const CaloInfo& caloInfo() const = 0;
virtual const CaloGeomUtil& geomUtil() const = 0;

// calorimeter geometry information
virtual const CaloInfo& caloInfo() const = 0;
virtual const CaloGeomUtil& geomUtil() const = 0;
virtual const std::vector<int>& neighbors(int crystalId) const = 0;
virtual const std::vector<int>& nextNeighbors(int crystalId) const = 0;
virtual std::vector<int> neighborsByLevel(int crystalId, int level) const = 0;
virtual int crystalIdxFromPosition(const CLHEP::Hep3Vector& pos) const = 0;
virtual int nearestIdxFromPosition(const CLHEP::Hep3Vector& pos) const = 0;


// neighbors, indexing
virtual const std::vector<int>& neighbors(int crystalId, bool rawMap=false) const = 0;
virtual const std::vector<int>& nextNeighbors(int crystalId, bool rawMap=false) const = 0;
virtual std::vector<int> neighborsByLevel(int crystalId, int level, bool rawMap = false) const = 0;
virtual int crystalIdxFromPosition(const CLHEP::Hep3Vector& pos) const = 0;
virtual int nearestIdxFromPosition(const CLHEP::Hep3Vector& pos) const = 0;

// get to know me!
virtual void print(std::ostream &os = std::cout) const = 0;
virtual void print(std::ostream &os = std::cout) const = 0;
};

}

#endif
Loading