Skip to content

Commit

Permalink
Work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
Katerina Kostova committed Aug 15, 2024
1 parent 0c00e88 commit f7948e0
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
17 changes: 8 additions & 9 deletions k4GaudiPandora/include/DDCaloDigi.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,9 @@ const int MAX_LAYERS = 200;
const int MAX_STAVES = 16;

using retType = std::tuple<edm4hep::CalorimeterHitCollection,
edm4hep::CalorimeterHitCollection,
edm4hep::CaloHitSimCaloHitLinkCollection>;

using DDCaloDigi_t = k4FWCore::MultiTransformer<retType(
const edm4hep::SimCalorimeterHitCollection&,
const edm4hep::SimCalorimeterHitCollection&,
const edm4hep::EventHeaderCollection&)>;

Expand All @@ -119,18 +117,19 @@ struct DDCaloDigi final
StatusCode finalize() override;

retType operator()(
const edm4hep::SimCalorimeterHitCollection& ecalSimCaloHits,
const edm4hep::SimCalorimeterHitCollection& hcalSimCaloHits,
const edm4hep::SimCalorimeterHitCollection& simCaloHits,
const edm4hep::EventHeaderCollection& headers) const;

private:

// collections
Gaudi::Property<std::string> m_ecalCollection{this, "ECALCollection", "ecalCollection", "The input collection for ECAL"};
Gaudi::Property<std::string> m_hcalCollection{this, "HCALCollection", "hcalCollection", "The input collection for HCAL"};
Gaudi::Property<std::string> m_outputEcalCollection{this, "OutputECALCollection", "outputEcalCollection", "The output collection for ECAL"};
Gaudi::Property<std::string> m_outputHcalCollection{this, "OutputHCALCollection", "outputHcalCollection", "The output collection for HCAL"};
Gaudi::Property<std::string> m_outputRelCollection{this, "OutputRelCollection", "outputRelCollection", "The output relation collection"};
Gaudi::Property<std::string> m_inputCollection{this, "inputCaloCollection", {"inputCollection"}, "The input SimCalorimeterHitCollection"};
//Gaudi::Property<std::string> m_ecalCollection{this, "ECALCollection", "ecalCollection", "The input collection for ECAL"};
//Gaudi::Property<std::string> m_hcalCollection{this, "HCALCollection", "hcalCollection", "The input collection for HCAL"};
//Gaudi::Property<std::string> m_outputEcalCollection{this, "OutputECALCollection", "outputEcalCollection", "The output collection for ECAL"};
//Gaudi::Property<std::string> m_outputHcalCollection{this, "OutputHCALCollection", "outputHcalCollection", "The output collection for HCAL"};
Gaudi::Property<std::string> m_outputCollection{this, "outputCollection", {"outputCollection"}, "The output CalorimeterHitCollection"};
Gaudi::Property<std::string> m_RelCollection{this, "RelCollection", {"outputRelCollection"}, "The output relation collection"};

// digitazing parameters for ECAL and HCAL
Gaudi::Property<float> m_thresholdEcal{this, "ECALThreshold", {5.0e-5}, "Threshold for ECAL Hits in GeV"};
Expand Down
12 changes: 6 additions & 6 deletions k4GaudiPandora/options/runDDCaloDigi.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@
calodigi = DDCaloDigi()

#FIXME: add properties
calodigi.ECALCollection = "ECalBarrelCollection" # "ECalBarrelCollection","ECalEndcapCollection"
calodigi.HCALCollection = "HCalBarrelCollection" # "HCalBarrelCollection","HCalEndcapCollection","HCalRingCollection"
calodigi.OutputECALCollection = "ECALCaloHitCollection"
calodigi.OutputHCALCollection = "HCALCaloHitCollection"
calodigi.OutputRelCollection = "RelCollection"
calodigi.inputCollection = "ECalBarrelCollection" # "ECalBarrelCollection","ECalEndcapCollection"
# "HCalBarrelCollection","HCalEndcapCollection","HCalRingCollection"
calodigi.outputCollection = "ECALCaloHitCollection"
#calodigi.OutputHCALCollection = "HCALCaloHitCollection"
calodigi.outputRelCollection = "RelCollection"

iosvc = IOSvc()
iosvc.input = "../simulation/sim_partgun_1000.root"
iosvc.input = "../simulation/sim_edm4hep.root"
iosvc.output = "../outputfiles/outputCaloDigi_Gaudi.root"

hps = RootHistSvc("HistogramPersistencySvc")
Expand Down
29 changes: 15 additions & 14 deletions k4GaudiPandora/src/DDCaloDigi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,20 @@ dd4hep::rec::LayeredCalorimeterData* getExtension(unsigned int includeFlag, unsi
DDCaloDigi::DDCaloDigi(const std::string& aName, ISvcLocator* aSvcLoc)
: MultiTransformer(aName, aSvcLoc,
{
KeyValues("ECALCollection", {"ECalBarrelCollection"}),
KeyValues("HCALCollection", {"HCalBarrelCollection"}),
KeyValues("inputCollection", {"ECalBarrelCollection"}),
KeyValues("HeaderName", {"EventHeader"}),
},
{
KeyValues("OutputECALCollection", {"ECalorimeterHit1"}), //, "ECalorimeterHit2", "ECalorimeterHit3"}),
KeyValues("OutputHCALCollection", {"HCalorimeterHit1"}), //, "HCalorimeterHit2", "HCalorimeterHit3"}),
KeyValues("OutputRelCollection", {"RelationSimCaloHit"})
KeyValues("outputECALCollection", {"ECalorimeterHit1"}), //, "ECalorimeterHit2", "ECalorimeterHit3"}),
//KeyValues("OutputHCALCollection", {"HCalorimeterHit1"}), //, "HCalorimeterHit2", "HCalorimeterHit3"}),
KeyValues("outputRelCollection", {"RelationCaloHit"})
})
{
m_uidSvc = service<IUniqueIDGenSvc>("UniqueIDGenSvc", true);
if (!m_uidSvc) {
error() << "Unable to get UniqueIDGenSvc" << endmsg;
}
m_geoSvc = serviceLocator()->service("GeoSvc"); // important to initialize m_geoSvc
//m_geoSvc = serviceLocator()->service("GeoSvc"); // important to initialize m_geoSvc


// // helper struct for string comparision --- Is needed???
Expand Down Expand Up @@ -275,15 +274,14 @@ StatusCode DDCaloDigi::initialize() {
}

retType DDCaloDigi::operator()(
const edm4hep::SimCalorimeterHitCollection& ecalSimCaloHitCollection,
const edm4hep::SimCalorimeterHitCollection& hcalSimCaloHitCollection,
const edm4hep::SimCalorimeterHitCollection& simCaloHitCollection,
const edm4hep::EventHeaderCollection& eventHeaders) const {
auto const& headers = eventHeaders.at(nRun); //FIXME maybe
debug() << " process event : " << headers.getEventNumber() << " - run " << headers.getRunNumber()
<< endmsg; // headers[0].getRunNumber(),headers[0].getEventNumber()

auto ecalcol = edm4hep::CalorimeterHitCollection(); // create output collection for ECAL
auto hcalcol = edm4hep::CalorimeterHitCollection(); // create output collection for HCAL
//auto hcalcol = edm4hep::CalorimeterHitCollection(); // create output collection for HCAL
//edm4hep::CaloHitSimCaloHitLinkCollection outputRelation;
auto Relcol = edm4hep::CaloHitSimCaloHitLinkCollection(); // create relation collection CalorimeterHit-SimCalorimeterHit

Expand All @@ -299,7 +297,7 @@ retType DDCaloDigi::operator()(
//
// * Reading Collections of ECAL Simulated Hits *
//
std::string ecalColName = m_ecalCollection; // The input collection for ECAL
std::string ecalColName = m_inputCollection; // The input collection for ECAL
cout << "looking for collection: " << ecalColName << endl;

if (ecalColName.find("dummy") != string::npos) {
Expand Down Expand Up @@ -335,7 +333,7 @@ retType DDCaloDigi::operator()(
}


for (const auto& hit : ecalSimCaloHitCollection) {
for (const auto& hit : simCaloHitCollection) {
// SimCalorimeterHit * hit = dynamic_cast<SimCalorimeterHit*>( col->getElementAt( j ) ) ;
const int cellID = hit.getCellID();
float energy = hit.getEnergy();
Expand Down Expand Up @@ -576,7 +574,7 @@ retType DDCaloDigi::operator()(
// ecalcol->parameters().setValue(LCIO::CellIDEncoding,initString);
}

//return std::make_tuple(std::move(ecalcol), std::move(Relcol));
return std::make_tuple(std::move(ecalcol), std::move(Relcol));


if (m_histograms) {
Expand All @@ -603,6 +601,7 @@ retType DDCaloDigi::operator()(
//
// * Reading HCAL Collections of Simulated Hits *
//
/*
std::string hcalColName = m_hcalCollection; // The input collection for HCAL
cout << "looking for collection: " << hcalColName << endl;
Expand All @@ -621,7 +620,7 @@ retType DDCaloDigi::operator()(
// for (int j(0); j < numElements; ++j) { //loop over all SimCalorimeterHits in this collection
//auto hcaloRel = Relcol.create();
for (const auto& hit : hcalSimCaloHitCollection) {
for (const auto& hit : simCaloHitCollection) {
float energy = hit.getEnergy();
//preselect for SimHits with energySum>threshold. Doubtful at least, as lower energy hit might fluctuate up and still be counted
if (energy > m_thresholdHcal[0] / 2) {
Expand Down Expand Up @@ -800,9 +799,11 @@ retType DDCaloDigi::operator()(
// evt->addCollection(chschcol,_outputRelCollection.c_str());
// _nEvt++;
return std::make_tuple(std::move(ecalcol), std::move(hcalcol), std::move(Relcol));
return std::make_tuple(std::move(hcalcol), std::move(Relcol));
*/
}


StatusCode DDCaloDigi::finalize() { return StatusCode::SUCCESS; } //fix

// if (_histograms) {
Expand Down

0 comments on commit f7948e0

Please sign in to comment.