Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
update processors to renamed geo condition
Browse files Browse the repository at this point in the history
  • Loading branch information
tomeichlersmith committed Sep 16, 2022
1 parent 6b36b74 commit 0bb3022
Show file tree
Hide file tree
Showing 18 changed files with 134 additions and 155 deletions.
4 changes: 2 additions & 2 deletions include/Ecal/DNNEcalVetoProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
#define EVENTPROC_DNNECALVETOPROCESSOR_H_

// LDMX
#include "DetDescr/EcalHexReadout.h"
#include "Ecal/Event/EcalHit.h"
#include "Ecal/Event/EcalVetoResult.h"
#include "DetDescr/EcalGeometry.h"
#include "Framework/Configure/Parameters.h"
#include "Framework/EventProcessor.h"

Expand All @@ -36,7 +36,7 @@ class DNNEcalVetoProcessor : public framework::Producer {
* Make inputs to the DNN from ECAL RecHits.
* @param ecalRecHits The EcalHit collection.
*/
void make_inputs(const ldmx::EcalHexReadout& geom,
void make_inputs(const ldmx::EcalGeometry& geom,
const std::vector<ldmx::EcalHit>& ecalRecHits);

private:
Expand Down
2 changes: 1 addition & 1 deletion include/Ecal/EcalClusterProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// LDMX //
//----------//
#include "DetDescr/DetectorID.h"
#include "DetDescr/EcalHexReadout.h"
#include "DetDescr/EcalGeometry.h"
#include "DetDescr/EcalID.h"
#include "Ecal/Event/ClusterAlgoResult.h"
#include "Ecal/Event/EcalCluster.h"
Expand Down
1 change: 0 additions & 1 deletion include/Ecal/EcalDigiProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
//----------//
// LDMX //
//----------//
#include "DetDescr/EcalHexReadout.h"
#include "DetDescr/EcalID.h"
#include "Framework/EventProcessor.h"
#include "Recon/Event/EventConstants.h"
Expand Down
2 changes: 1 addition & 1 deletion include/Ecal/EcalRecProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class EcalRecProducer : public framework::Producer {
*
* This function unfolds the digi samples taken by the HGC ROC
* and reconstructs their energy using knowledge of how
* the chip operates and the position using EcalHexReadout.
* the chip operates and the position using EcalGeometry.
*/
virtual void produce(framework::Event& event);

Expand Down
28 changes: 20 additions & 8 deletions include/Ecal/EcalTriggerGeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <vector>

namespace ldmx {
class EcalHexReadout;
class EcalGeometry;
}

namespace ecal {
Expand All @@ -32,7 +32,7 @@ class EcalTriggerGeometry : public framework::ConditionsObject {
public:
static constexpr const char* CONDITIONS_OBJECT_NAME{"EcalTriggerGeometry"};

EcalTriggerGeometry(int symmetry, const ldmx::EcalHexReadout* ecalGeom = 0);
EcalTriggerGeometry(int symmetry, const ldmx::EcalGeometry* ecalGeom = 0);

/**
* Returns the set of precision (full-granularity/DAQ) cells which are
Expand All @@ -53,13 +53,25 @@ class EcalTriggerGeometry : public framework::ConditionsObject {
*/
ldmx::EcalTriggerID belongsTo(ldmx::EcalID precisionCell) const;

/** Returns the center of the given trigger cell, depends on Ecal Geometry
* (ldmx::EcalHexReadout) */
std::pair<double, double> globalPosition(
/**
* Returns the center of the given trigger cell in world coordinates
*
* depends on Ecal Geometry (ldmx::EcalGeometry)
*
* C++17's structured bindings is helpful here
* ```cpp
* auto [x,y,z] = trig_geom.globalPosition(triggerCell);
* // x,y,z are the world coordinates of the center of the trigger cell
* ```
*/
std::tuple<double, double,double> globalPosition(
ldmx::EcalTriggerID triggerCell) const;

/** Returns the local (within module) center of the given trigger cell,
* depends on Ecal Geometry (ldmx::EcalHexReadout) */
/**
* Returns the local (within module) center of the given trigger cell
*
* depends on Ecal Geometry (ldmx::EcalGeometry)
*/
std::pair<double, double> localPosition(
ldmx::EcalTriggerID triggerCell) const;

Expand All @@ -70,7 +82,7 @@ class EcalTriggerGeometry : public framework::ConditionsObject {
*/
int symmetry_;
/** Reference to the Ecal geometry used for trigger geometry information */
const ldmx::EcalHexReadout* ecalGeometry_;
const ldmx::EcalGeometry* ecalGeometry_;
/** Map of precision cells to trigger cells, under symmetry assumptions
*/
std::map<ldmx::EcalID, ldmx::EcalTriggerID> precision2trigger_;
Expand Down
31 changes: 4 additions & 27 deletions include/Ecal/EcalVetoProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#define EVENTPROC_ECALVETOPROCESSOR_H_

// LDMX
#include "DetDescr/EcalHexReadout.h"
#include "DetDescr/EcalGeometry.h"
#include "DetDescr/EcalID.h"
#include "Ecal/Event/EcalHit.h"
#include "Ecal/Event/EcalVetoResult.h"
Expand Down Expand Up @@ -57,32 +57,8 @@ class EcalVetoProcessor : public framework::Producer {
};

private:
/** Wrappers for ecalHexReadout functions. See hitToPair().
* Necessary to easily combine cellID with moduleID to get unique ID of
* hit in layer. In future: combine celID+moduleID+layerID.
*/
bool isInShowerInnerRing(ldmx::EcalID centroidID, ldmx::EcalID probeID) {
return hexReadout_->isNN(centroidID, probeID);
}
bool isInShowerOuterRing(ldmx::EcalID centroidID, ldmx::EcalID probeID) {
return hexReadout_->isNNN(centroidID, probeID);
}
std::pair<double, double> getCellCentroidXYPair(ldmx::EcalID centroidID) {
return hexReadout_->getCellCenterAbsolute(centroidID);
}
std::vector<ldmx::EcalID> getInnerRingCellIds(ldmx::EcalID id) {
return hexReadout_->getNN(id);
}
std::vector<ldmx::EcalID> getOuterRingCellIds(ldmx::EcalID id) {
return hexReadout_->getNNN(id);
}

void clearProcessor();

ldmx::EcalID hitID(const ldmx::EcalHit& hit) const {
return ldmx::EcalID(hit.getID());
}

/* Function to calculate the energy weighted shower centroid */
ldmx::EcalID GetShowerCentroidIDAndRMS(
const std::vector<ldmx::EcalHit>& ecalRecHits, double& showerRMS);
Expand Down Expand Up @@ -167,8 +143,6 @@ class EcalVetoProcessor : public framework::Producer {
bool verbose_{false};
bool doesPassVeto_{false};

const ldmx::EcalHexReadout* hexReadout_;

std::string bdtFileName_;
std::string cellFileNamexy_;
std::vector<float> bdtFeatures_;
Expand All @@ -180,6 +154,9 @@ class EcalVetoProcessor : public framework::Producer {
std::string collectionName_{"EcalVeto"};

std::unique_ptr<ldmx::Ort::ONNXRuntime> rt_;

/// handle to current geometry (to share with member functions)
const ldmx::EcalGeometry* geometry_;
};

} // namespace ecal
Expand Down
2 changes: 1 addition & 1 deletion include/Ecal/TemplatedClusterFinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ template <class WeightClass>

class TemplatedClusterFinder {
public:
void add(const ldmx::EcalHit* eh, const ldmx::EcalHexReadout& hex) {
void add(const ldmx::EcalHit* eh, const ldmx::EcalGeometry& hex) {
clusters_.push_back(WorkingCluster(eh, hex));
}

Expand Down
6 changes: 3 additions & 3 deletions include/Ecal/WorkingCluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@

#include <iostream>
#include <vector>
#include "DetDescr/EcalHexReadout.h"
#include "DetDescr/EcalGeometry.h"
#include "Ecal/Event/EcalHit.h"
#include "TLorentzVector.h"

namespace ecal {

class WorkingCluster {
public:
WorkingCluster(const ldmx::EcalHit* eh, const ldmx::EcalHexReadout& geom);
WorkingCluster(const ldmx::EcalHit* eh, const ldmx::EcalGeometry& geom);

~WorkingCluster(){};

void add(const ldmx::EcalHit* eh, const ldmx::EcalHexReadout& geom);
void add(const ldmx::EcalHit* eh, const ldmx::EcalGeometry& geom);

void add(const WorkingCluster& wc);

Expand Down
18 changes: 9 additions & 9 deletions python/EcalGeometry.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""ConditionsProvider for EcalHexReadout and other Ecal geometry-related aspects"""
"""ConditionsProvider for EcalGeometry and other Ecal geometry-related aspects"""
from LDMX.Framework import ldmxcfg

class EcalGeometryProvider(ldmxcfg.ConditionsObjectProvider):
"""Provider that provides access to Ecal geometry (ecal::EcalHexReadout)
"""Provider that provides access to Ecal geometry (ecal::EcalGeometry)
Parameters
----------
Expand All @@ -11,7 +11,7 @@ class EcalGeometryProvider(ldmxcfg.ConditionsObjectProvider):
Attributes
----------
EcalHexReadout : EcalHexReadout
EcalGeometry : EcalGeometry
Actual class providing precision cellular layout in Ecal
__instance : EcalGeometryProvider
Singleton instance of this object
Expand All @@ -38,15 +38,15 @@ def __init__(self):
raise Exception('EcalGeometryProvider is a singleton class and should only be retrieved using getInstance()')
else:
super().__init__("EcalGeometryProvider","ecal::EcalGeometryProvider","Ecal")
from LDMX.DetDescr import EcalHexReadout
self.EcalHexReadout = EcalHexReadout.EcalHexReadout()
from LDMX.DetDescr import EcalGeometry
self.EcalGeometry = EcalGeometry.EcalGeometry()
EcalGeometryProvider.__instance = self

# make sure global instance is created, this registers the condition
EcalGeometryProvider.getInstance()

class EcalTriggerGeometryProvider(ldmxcfg.ConditionsObjectProvider):
"""Provider that provides access to Ecal geometry (ldmx::EcalHexReadout)
"""Provider that provides access to Ecal geometry (ldmx::EcalGeometry)
Parameters
----------
Expand All @@ -55,7 +55,7 @@ class EcalTriggerGeometryProvider(ldmxcfg.ConditionsObjectProvider):
Attributes
----------
EcalHexReadout : EcalHexReadout
EcalGeometry : EcalGeometry
Actual class providing precision cellular layout in Ecal
__instance : EcalTriggerGeometryProvider
Singleton instance of this object
Expand All @@ -82,8 +82,8 @@ def __init__(self):
raise Exception('EcalTriggerGeometryProvider is a singleton class and should only be retrieved using getInstance()')
else:
super().__init__("EcalTriggerGeometry","ecal::EcalTriggerGeometryProvider","Ecal")
from LDMX.DetDescr import EcalHexReadout
self.EcalHexReadout = EcalHexReadout.EcalHexReadout()
from LDMX.DetDescr import EcalGeometry
self.EcalGeometry = EcalGeometry.EcalGeometry()
EcalTriggerGeometryProvider.__instance = self

# make sure global instance is created, this registers the condition
Expand Down
13 changes: 6 additions & 7 deletions src/Ecal/DNNEcalVetoProcessor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ void DNNEcalVetoProcessor::produce(framework::Event& event) {
ldmx::EcalVetoResult result;

// Get the Ecal Geometry
const ldmx::EcalHexReadout& hexReadout = getCondition<ldmx::EcalHexReadout>(
ldmx::EcalHexReadout::CONDITIONS_OBJECT_NAME);
const auto& ecal_geometry = getCondition<ldmx::EcalGeometry>(
ldmx::EcalGeometry::CONDITIONS_OBJECT_NAME);

// Get the collection of digitized Ecal hits from the event.
const auto ecalRecHits = event.getCollection<ldmx::EcalHit>("EcalRecHits");
Expand All @@ -48,7 +48,7 @@ void DNNEcalVetoProcessor::produce(framework::Event& event) {

if (nhits < max_num_hits_) {
// make inputs
make_inputs(hexReadout, ecalRecHits);
make_inputs(ecal_geometry, ecalRecHits);
// run the DNN
auto outputs = rt_->run(input_names_, data_)[0];
result.setDiscValue(outputs.at(1));
Expand All @@ -73,7 +73,7 @@ void DNNEcalVetoProcessor::produce(framework::Event& event) {
}

void DNNEcalVetoProcessor::make_inputs(
const ldmx::EcalHexReadout& geom,
const ldmx::EcalGeometry& geom,
const std::vector<ldmx::EcalHit>& ecalRecHits) {
// clear data
for (auto& v : data_) {
Expand All @@ -83,14 +83,13 @@ void DNNEcalVetoProcessor::make_inputs(
unsigned idx = 0;
for (const auto& hit : ecalRecHits) {
if (hit.getEnergy() <= 0) continue;
double x = 0, y = 0, z = 0;
geom.getCellAbsolutePosition(hit.getID(), x, y, z);
ldmx::EcalID id(hit.getID());
auto [x,y,z] = geom.getPosition(id);

data_[0].at(coordinate_x_offset_ + idx) = x;
data_[0].at(coordinate_y_offset_ + idx) = y;
data_[0].at(coordinate_z_offset_ + idx) = z;

ldmx::EcalID id(hit.getID());
data_[1].at(feature_x_offset_ + idx) = x;
data_[1].at(feature_y_offset_ + idx) = y;
data_[1].at(feature_z_offset_ + idx) = z;
Expand Down
6 changes: 3 additions & 3 deletions src/Ecal/EcalClusterProducer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ void EcalClusterProducer::configure(framework::config::Parameters& parameters) {

void EcalClusterProducer::produce(framework::Event& event) {
// Get the Ecal Geometry
const ldmx::EcalHexReadout& hexReadout = getCondition<ldmx::EcalHexReadout>(
ldmx::EcalHexReadout::CONDITIONS_OBJECT_NAME);
const auto& geometry = getCondition<ldmx::EcalGeometry>(
ldmx::EcalGeometry::CONDITIONS_OBJECT_NAME);

TemplatedClusterFinder<MyClusterWeight> cf;

Expand All @@ -45,7 +45,7 @@ void EcalClusterProducer::produce(framework::Event& event) {
continue;
}

cf.add(&hit, hexReadout);
cf.add(&hit, geometry);
}

cf.cluster(seedThreshold_, cutoff_);
Expand Down
11 changes: 6 additions & 5 deletions src/Ecal/EcalDigiProducer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

#include "Ecal/EcalDigiProducer.h"
#include "DetDescr/EcalGeometry.h"
#include "Framework/RandomNumberSeedService.h"

namespace ecal {
Expand Down Expand Up @@ -157,11 +158,11 @@ void EcalDigiProducer::produce(framework::Event& event) {
// geometry constants
// These are used in the noise generation so that we can randomly
// distribute the noise uniformly throughout the ECal channels.
const auto& hexGeom = getCondition<ldmx::EcalHexReadout>(
ldmx::EcalHexReadout::CONDITIONS_OBJECT_NAME);
int nEcalLayers = hexGeom.getNumLayers();
int nModulesPerLayer = hexGeom.getNumModulesPerLayer();
int nCellsPerModule = hexGeom.getNumCellsPerModule();
const auto& geom = getCondition<ldmx::EcalGeometry>(
ldmx::EcalGeometry::CONDITIONS_OBJECT_NAME);
int nEcalLayers = geom.getNumLayers();
int nModulesPerLayer = geom.getNumModulesPerLayer();
int nCellsPerModule = geom.getNumCellsPerModule();
int numEmptyChannels = nEcalLayers * nModulesPerLayer * nCellsPerModule -
ecalDigis.getNumDigis();

Expand Down
Loading

0 comments on commit 0bb3022

Please sign in to comment.