Skip to content

Commit

Permalink
Comments and suggestions resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
Katerina Kostova committed Aug 1, 2024
1 parent 51e513f commit 38836ee
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 36 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@ set(PACKAGE_VERSION_PATCH 3)

set(PACKAGE_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}")

list(APPEND CMAKE_MODULE_PATH $ENV{PANDORAPFA}/cmakemodules)

# dependencies are declared like this
find_package(ROOT COMPONENTS RIO Tree)
find_package(EDM4HEP)
find_package(k4FWCore)
find_package(PandoraSDK)
find_package(LCContent)
find_package(Gaudi)
find_package(DD4hep)
#---------------------------------------------------------------
Expand Down
58 changes: 49 additions & 9 deletions k4GaudiPandora/include/CalorimeterHitType.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,22 @@ class CHT {
typedef enum { any = 0, barrel = 1, endcap = 2, plug = 3, ring = 4 } Layout;

/** C'tor for initialization from CalorimeterHit::getType() */
CHT(int type) : _type(type) {}
CHT(int type) : m_type(type) {}

/** C'tor for encoding the calo type inforamtion */
CHT(CaloType c, CaloID n, Layout l, unsigned lay) : _type(c * fCaloType + n * fCaloID + l * fLayout + lay * fLayer) {}
CHT(CaloType c, CaloID n, Layout l, unsigned lay) : m_type(c * fCaloType + n * fCaloID + l * fLayout + lay * fLayer) {}

/** calorimeter type: CHT::em , CHT::had, CHT::muon */
CaloType caloType() const { return (CaloType)(_type % fCaloID); }
CaloType caloType() const { return (CaloType)(m_type % fCaloID); }

/** calo ID - see enum CaloID for allowed values */
CaloID caloID() const { return (CaloID)((_type % fLayout) / fCaloID); }
CaloID caloID() const { return (CaloID)((m_type % fLayout) / fCaloID); }

/** calo layout - see enum layout for allowed values */
Layout layout() const { return (Layout)((_type % fLayer) / fLayout); }
Layout layout() const { return (Layout)((m_type % fLayer) / fLayout); }

/** calo layer of hit */
unsigned layer() const { return unsigned(_type) / fLayer; }
unsigned layer() const { return unsigned(m_type) / fLayer; }

bool is(CaloType t) const { return caloType() == t; }

Expand All @@ -96,10 +96,10 @@ class CHT {
bool is(Layout l) const { return layout() == l; }

/** automatic conversion to int */
operator int() const { return _type; }
operator int() const { return m_type; }

/** explicit conversion to int */
int toInt() const { return _type; }
int toInt() const { return m_type; }

protected:
int m_type;
Expand All @@ -125,4 +125,44 @@ CHT::CaloID caloIDFromString(const std::string& name);
is found, CHT::em is returned.*/
CHT::CaloType caloTypeFromString(const std::string& name);

#endif
#endif

// int main(){

// CHT ct( CHT::em , CHT::ecal , CHT::plug , 12 ) ;

// std::cout << ct << std::endl ;

// std::cout << " caloType : " << ct.toInt() << std::endl ;

// std::cout << " caloID " << ct.caloID()
// << " is bcal " << ct.is( CHT::bcal )
// << " is muon " << ct.is( CHT::muon )
// << " layer " << ct.layer()
// << std::endl ;

// int i = CHT( CHT::muon , CHT::ecal , CHT::endcap , 123 ) ;

// std::cout << " type i : " << i << std::endl ;

// std::cout << " layer from int : " << CHT(i).layer() << std::endl ;

// CHT it(i) ;

// std::cout << " caloID " << it.caloID()
// << " is bcal " << it.is( CHT::bcal )
// << " is muon " << it.is( CHT::muon )
// << " is endcap " << it.is( CHT::endcap )
// << " layer " << it.layer()
// << " layout " << it.layout()
// << std::endl ;

// std::cout << it << std::endl ;

// CHT ct2 = 12345678 ;

// std::cout << ct2 << std::endl ;

// std::cout << " sizeof( CHT ) : " << sizeof( it ) << std::endl ;

// }
6 changes: 3 additions & 3 deletions k4GaudiPandora/include/DDSimpleMuonDigi.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "edm4hep/CaloHitContributionCollection.h"
#include "edm4hep/CalorimeterHitCollection.h"
#include "edm4hep/EventHeaderCollection.h"
#include "edm4hep/MCRecoCaloAssociationCollection.h"
#include "edm4hep/CaloHitSimCaloHitLinkCollection.h"
#include "edm4hep/SimCalorimeterHitCollection.h"

#include "CalorimeterHitType.h"
Expand All @@ -38,14 +38,14 @@

struct DDSimpleMuonDigi final
: k4FWCore::MultiTransformer<
std::tuple<edm4hep::CalorimeterHitCollection, edm4hep::MCRecoCaloAssociationCollection>(
std::tuple<edm4hep::CalorimeterHitCollection, edm4hep::CaloHitSimCaloHitLinkCollection>(
const edm4hep::SimCalorimeterHitCollection&, const edm4hep::EventHeaderCollection&)> {
DDSimpleMuonDigi(const std::string& name, ISvcLocator* svcLoc);

StatusCode initialize() override;
//StatusCode finalize() override;

std::tuple<edm4hep::CalorimeterHitCollection, edm4hep::MCRecoCaloAssociationCollection> operator()(
std::tuple<edm4hep::CalorimeterHitCollection, edm4hep::CaloHitSimCaloHitLinkCollection> operator()(
const edm4hep::SimCalorimeterHitCollection& simCaloHits,
const edm4hep::EventHeaderCollection& headers) const override;

Expand Down
4 changes: 2 additions & 2 deletions k4GaudiPandora/options/runDDSimpleMuonDigi.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
digi = DDSimpleMuonDigi()

digi.SubDetectorName = "VXD"
digi.KeepBarrelLayersVec = [0]
digi.KeepEndcapLayersVec = [0]
digi.KeepBarrelLayersVec = []
digi.KeepEndcapLayersVec = []
digi.muonCollections = "ECalBarrelCollection" # "ECalBarrelCollection","ECalEndcapCollection","HCalBarrelCollection","HCalEndcapCollection","HCalRingCollection","LumiCalCollection","YokeBarrelCollection","YokeEndcapCollection"
digi.outputRelCollection = "RelationMuonHit"
digi.outputMuonCollection = "CalorimeterHit"
Expand Down
32 changes: 10 additions & 22 deletions k4GaudiPandora/src/DDSimpleMuonDigi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,43 +74,31 @@ StatusCode DDSimpleMuonDigi::initialize() {
//If the vectors are empty, we are keeping everything
if (m_layersToKeepBarrelVec.size() > 0) {
//layers start at 0
std::vector<int> layersBarrelVec;
layersBarrelVec = std::vector<int>(layersBarrel, 0);
if (m_layersToKeepBarrelVec[0] != 0) {
for (auto i : layersBarrelVec) {
m_useLayersBarrelVec.push_back(false);
}
for (int k : m_layersToKeepBarrelVec) {
m_useLayersBarrelVec[k - 1] = true;
}
m_useLayersBarrelVec = std::vector<bool>(layersBarrel, false);
for (int k : m_layersToKeepBarrelVec) {
m_useLayersBarrelVec[k - 1] = true;
}
// for the check
//for (auto elem : m_useLayersBarrelVec) { std::cout << "m_useLayersBarrelVec " << elem << std::endl; }
}
if (m_layersToKeepEndCapVec.size() > 0) {
//layers start at 0
std::vector<int> layersEndcapVec;
layersEndcapVec = std::vector<int>(layersEndcap, 0);
if (m_layersToKeepEndCapVec[0] != 0) {
for (auto i : layersEndcapVec) {
m_useLayersEndcapVec.push_back(false);
}
for (int k : m_layersToKeepEndCapVec) {
m_useLayersEndcapVec[k - 1] = true;
}
m_useLayersEndcapVec = std::vector<bool>(layersEndcap, false);
for (int k : m_layersToKeepEndCapVec) {
m_useLayersEndcapVec[k - 1] = true;
}
// just for check
//for (auto elem : m_useLayersEndcapVec) { std::cout << "m_useLayersEndCapVec " << elem << std::endl; }
}
return StatusCode::SUCCESS;
}
std::tuple<edm4hep::CalorimeterHitCollection, edm4hep::MCRecoCaloAssociationCollection> DDSimpleMuonDigi::operator()(
std::tuple<edm4hep::CalorimeterHitCollection, edm4hep::CaloHitSimCaloHitLinkCollection> DDSimpleMuonDigi::operator()(
const edm4hep::SimCalorimeterHitCollection& SimCaloHits, const edm4hep::EventHeaderCollection& headers) const {
debug() << " process event : " << headers[0].getEventNumber() << " - run " << headers[0].getRunNumber()
<< endmsg; // headers[0].getRunNumber(),headers[0].getEventNumber()

auto muoncol = edm4hep::CalorimeterHitCollection();
auto muonRelcol = edm4hep::MCRecoCaloAssociationCollection();
auto muonRelcol = edm4hep::CaloHitSimCaloHitLinkCollection();

std::string initString;

Expand Down Expand Up @@ -145,8 +133,8 @@ std::tuple<edm4hep::CalorimeterHitCollection, edm4hep::MCRecoCaloAssociationColl
calHit.setType(CHT(CHT::muon, CHT::yoke, caloLayout, layer));
calHit.setTime(computeHitTime(hit));
auto muonRel = muonRelcol.create();
muonRel.setRec(calHit);
muonRel.setSim(hit);
muonRel.setFrom(calHit);
muonRel.setTo(hit);
}
}

Expand Down

0 comments on commit 38836ee

Please sign in to comment.