Skip to content

Commit

Permalink
This is a combined bug fixing for EEMC and corresponding algorithms.
Browse files Browse the repository at this point in the history
(1) Corrected the scaleResponse of raw hits in digitization for pECal and pECal insert in reco_flags.py.

(2) The digitization in signal_sum_digi was fixed similar to that in single_hits_digi in CalorimeterHitDigi.cc.

(3) Added factories to produce truth clusters from proto-truth clusters.

(4) Corrected the proto-cluster tag-name for pECal insert in reco_flags.py.

(5) The nested clusters in CalorimeterClusterMerger.cc, which prevented merged clusters to be written out,
    was temporally commented out. This is a global issue with podio reference.

(6) Added dummy factories to let cluster associations written out.

(7) Renamed all tag-names that end with "ClusterAssociations" to "ClustersAssocitions".
    This makes the naming uniform by just adding "Associations" without removing "s" in "Clusters".

(8) Fixed some typos of filenames for the pECal insert.

The code has been tested by 100 events.

(1) It did not produce any error related to EEMC.

(2) The energy responses of truth, reco, and merged clusters were reasonable.

(3) The cluster associations were successfully written out.
  • Loading branch information
jizhongling committed Oct 27, 2022
1 parent 257b91f commit ffc0e79
Show file tree
Hide file tree
Showing 19 changed files with 477 additions and 221 deletions.
2 changes: 1 addition & 1 deletion src/algorithms/calorimetry/CalorimeterClusterMerger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void CalorimeterClusterMerger::AlgorithmProcess() {
time += clus->getTime() * clus->getEnergy();
nhits += clus->getNhits();
position = position + energy * clus->getPosition();
new_clus.addToClusters(*clus);
//new_clus.addToClusters(*clus); // FIXME: global issue with podio reference
for (auto& hit : clus->getHits()) {
new_clus.addToHits(hit);
}
Expand Down
2 changes: 1 addition & 1 deletion src/algorithms/calorimetry/CalorimeterHitDigi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ void CalorimeterHitDigi::signal_sum_digi( void ){
// m_normDist(generator) * eRes[2] / edep;
// }
double ped = m_pedMeanADC + m_normDist(generator) * m_pedSigmaADC;
unsigned long long adc = std::llround(ped + edep * (1. + eResRel) / dyRangeADC * m_capADC);
unsigned long long adc = std::llround(ped + edep * (m_corrMeanScale + eResRel) / dyRangeADC * m_capADC);
unsigned long long tdc = std::llround((time + m_normDist(generator) * tRes) * stepTDC);

auto rawhit = new edm4hep::RawCalorimeterHit(
Expand Down
15 changes: 14 additions & 1 deletion src/detectors/EEMC/Cluster_factory_EcalEndcapNClusters.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@



// Dummy factory for JFactoryGeneratorT
class Association_factory_EcalEndcapNClustersAssociations : public JFactoryT<edm4eic::MCRecoClusterParticleAssociation> {

public:
//------------------------------------------
// Constructor
Association_factory_EcalEndcapNClustersAssociations(){
SetTag("EcalEndcapNClustersAssociations");
}
};



class Cluster_factory_EcalEndcapNClusters : public JFactoryT<edm4eic::Cluster>, CalorimeterClusterRecoCoG {

public:
Expand Down Expand Up @@ -89,7 +102,7 @@ class Cluster_factory_EcalEndcapNClusters : public JFactoryT<edm4eic::Cluster>,

// Hand owner of algorithm objects over to JANA
Set(m_outputClusters);
event->Insert(m_outputAssociations, "EcalEndcapNClusterAssociations");
event->Insert(m_outputAssociations, "EcalEndcapNClustersAssociations");
m_outputClusters.clear(); // not really needed, but better to not leave dangling pointers around
m_outputAssociations.clear();
}
Expand Down
15 changes: 14 additions & 1 deletion src/detectors/EEMC/Cluster_factory_EcalEndcapNMergedClusters.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@



// Dummy factory for JFactoryGeneratorT
class Association_factory_EcalEndcapNMergedClustersAssociations : public JFactoryT<edm4eic::MCRecoClusterParticleAssociation> {

public:
//------------------------------------------
// Constructor
Association_factory_EcalEndcapNMergedClustersAssociations(){
SetTag("EcalEndcapNMergedClustersAssociations");
}
};



class Cluster_factory_EcalEndcapNMergedClusters : public JFactoryT<edm4eic::Cluster>, CalorimeterClusterMerger {

public:
Expand All @@ -29,7 +42,7 @@ class Cluster_factory_EcalEndcapNMergedClusters : public JFactoryT<edm4eic::Clus
auto app = GetApplication();
//-------- Configuration Parameters ------------
m_input_tag="EcalEndcapNClusters";
m_inputAssociations_tag="EcalEndcapNClusterAssociations";
m_inputAssociations_tag="EcalEndcapNClustersAssociations";

std::string tag=this->GetTag();
std::shared_ptr<spdlog::logger> m_log = app->GetService<Log_service>()->logger(tag);
Expand Down
109 changes: 109 additions & 0 deletions src/detectors/EEMC/Cluster_factory_EcalEndcapNTruthClusters.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
// Copyright 2022, Thomas Britton
// Subject to the terms in the LICENSE file found in the top-level directory.
//

#pragma once

#include <random>

#include <JANA/JFactoryT.h>
#include <services/geometry/dd4hep/JDD4hep_service.h>
#include <algorithms/calorimetry/CalorimeterClusterRecoCoG.h>
#include <services/log/Log_service.h>
#include <extensions/spdlog/SpdlogExtensions.h>



// Dummy factory for JFactoryGeneratorT
class Association_factory_EcalEndcapNTruthClustersAssociations : public JFactoryT<edm4eic::MCRecoClusterParticleAssociation> {

public:
//------------------------------------------
// Constructor
Association_factory_EcalEndcapNTruthClustersAssociations(){
SetTag("EcalEndcapNTruthClustersAssociations");
}
};



class Cluster_factory_EcalEndcapNTruthClusters : public JFactoryT<edm4eic::Cluster>, CalorimeterClusterRecoCoG {

public:
//------------------------------------------
// Constructor
Cluster_factory_EcalEndcapNTruthClusters(){
SetTag("EcalEndcapNTruthClusters");
}

//------------------------------------------
// Init
void Init() override{
auto app = GetApplication();
//-------- Configuration Parameters ------------
m_input_simhit_tag="EcalEndcapNHits";
m_input_protoclust_tag="EcalEndcapNTruthProtoClusters";

m_sampFrac=1.0;//{this, "samplingFraction", 1.0};
m_logWeightBase=3.6;//{this, "logWeightBase", 3.6};
m_depthCorrection=0.0;//{this, "depthCorrection", 0.0};
m_energyWeight="log";//{this, "energyWeight", "log"};
m_moduleDimZName="";//{this, "moduleDimZName", ""};
// Constrain the cluster position eta to be within
// the eta of the contributing hits. This is useful to avoid edge effects
// for endcaps.
m_enableEtaBounds=false;//{this, "enableEtaBounds", false};


app->SetDefaultParameter("EEMC:EcalEndcapNTruthClusters:input_protoclust_tag", m_input_protoclust_tag, "Name of input collection to use");
app->SetDefaultParameter("EEMC:EcalEndcapNTruthClusters:samplingFraction", m_sampFrac);
app->SetDefaultParameter("EEMC:EcalEndcapNTruthClusters:logWeightBase", m_logWeightBase);
app->SetDefaultParameter("EEMC:EcalEndcapNTruthClusters:depthCorrection", m_depthCorrection);
app->SetDefaultParameter("EEMC:EcalEndcapNTruthClusters:energyWeight", m_energyWeight);
app->SetDefaultParameter("EEMC:EcalEndcapNTruthClusters:moduleDimZName", m_moduleDimZName);
app->SetDefaultParameter("EEMC:EcalEndcapNTruthClusters:enableEtaBounds", m_enableEtaBounds);

m_geoSvc = app->template GetService<JDD4hep_service>();

std::string tag=this->GetTag();
std::shared_ptr<spdlog::logger> m_log = app->GetService<Log_service>()->logger(tag);

// Get log level from user parameter or default
std::string log_level_str = "info";
auto pm = app->GetJParameterManager();
pm->SetDefaultParameter(tag + ":LogLevel", log_level_str, "verbosity: trace, debug, info, warn, err, critical, off");
m_log->set_level(eicrecon::ParseLogLevel(log_level_str));


AlgorithmInit(m_log);
}

//------------------------------------------
// ChangeRun
void ChangeRun(const std::shared_ptr<const JEvent> &event) override{
AlgorithmChangeRun();
}

//------------------------------------------
// Process
void Process(const std::shared_ptr<const JEvent> &event) override{


// Prefill inputs
m_inputSimhits=event->Get<edm4hep::SimCalorimeterHit>(m_input_simhit_tag);
m_inputProto=event->Get<edm4eic::ProtoCluster>(m_input_protoclust_tag);

// Call Process for generic algorithm
AlgorithmProcess();


//outputs

// Hand owner of algorithm objects over to JANA
Set(m_outputClusters);
event->Insert(m_outputAssociations, "EcalEndcapNTruthClustersAssociations");
m_outputClusters.clear(); // not really needed, but better to not leave dangling pointers around
m_outputAssociations.clear();
}
};

15 changes: 14 additions & 1 deletion src/detectors/EEMC/Cluster_factory_EcalEndcapPClusters.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@



// Dummy factory for JFactoryGeneratorT
class Association_factory_EcalEndcapPClustersAssociations : public JFactoryT<edm4eic::MCRecoClusterParticleAssociation> {

public:
//------------------------------------------
// Constructor
Association_factory_EcalEndcapPClustersAssociations(){
SetTag("EcalEndcapPClustersAssociations");
}
};



class Cluster_factory_EcalEndcapPClusters : public JFactoryT<edm4eic::Cluster>, CalorimeterClusterRecoCoG {

public:
Expand Down Expand Up @@ -88,7 +101,7 @@ class Cluster_factory_EcalEndcapPClusters : public JFactoryT<edm4eic::Cluster>,

// Hand owner of algorithm objects over to JANA
Set(m_outputClusters);
event->Insert(m_outputAssociations, "EcalEndcapPClusterAssociations");
event->Insert(m_outputAssociations, "EcalEndcapPClustersAssociations");
m_outputClusters.clear(); // not really needed, but better to not leave dangling pointers around
m_outputAssociations.clear();
}
Expand Down
15 changes: 14 additions & 1 deletion src/detectors/EEMC/Cluster_factory_EcalEndcapPInsertClusters.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@



// Dummy factory for JFactoryGeneratorT
class Association_factory_EcalEndcapPInsertClustersAssociations : public JFactoryT<edm4eic::MCRecoClusterParticleAssociation> {

public:
//------------------------------------------
// Constructor
Association_factory_EcalEndcapPInsertClustersAssociations(){
SetTag("EcalEndcapPInsertClustersAssociations");
}
};



class Cluster_factory_EcalEndcapPInsertClusters : public JFactoryT<edm4eic::Cluster>, CalorimeterClusterRecoCoG {

public:
Expand Down Expand Up @@ -88,7 +101,7 @@ class Cluster_factory_EcalEndcapPInsertClusters : public JFactoryT<edm4eic::Clus

// Hand owner of algorithm objects over to JANA
Set(m_outputClusters);
event->Insert(m_outputAssociations, "EcalEndcapPInsertClusterAssociations");
event->Insert(m_outputAssociations, "EcalEndcapPInsertClustersAssociations");
m_outputClusters.clear(); // not really needed, but better to not leave dangling pointers around
m_outputAssociations.clear();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@



// Dummy factory for JFactoryGeneratorT
class Association_factory_EcalEndcapPInsertMergedClustersAssociations : public JFactoryT<edm4eic::MCRecoClusterParticleAssociation> {

public:
//------------------------------------------
// Constructor
Association_factory_EcalEndcapPInsertMergedClustersAssociations(){
SetTag("EcalEndcapPInsertMergedClustersAssociations");
}
};



class Cluster_factory_EcalEndcapPInsertMergedClusters : public JFactoryT<edm4eic::Cluster>, CalorimeterClusterMerger {

public:
Expand All @@ -29,7 +42,7 @@ class Cluster_factory_EcalEndcapPInsertMergedClusters : public JFactoryT<edm4eic
auto app = GetApplication();
//-------- Configuration Parameters ------------
m_input_tag="EcalEndcapPInsertClusters";
m_inputAssociations_tag="EcalEndcapPInsertClusterAssociations";
m_inputAssociations_tag="EcalEndcapPInsertClustersAssociations";

std::string tag=this->GetTag();
std::shared_ptr<spdlog::logger> m_log = app->GetService<Log_service>()->logger(tag);
Expand Down
109 changes: 109 additions & 0 deletions src/detectors/EEMC/Cluster_factory_EcalEndcapPInsertTruthClusters.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
// Copyright 2022, Thomas Britton
// Subject to the terms in the LICENSE file found in the top-level directory.
//

#pragma once

#include <random>

#include <JANA/JFactoryT.h>
#include <services/geometry/dd4hep/JDD4hep_service.h>
#include <algorithms/calorimetry/CalorimeterClusterRecoCoG.h>
#include <services/log/Log_service.h>
#include <extensions/spdlog/SpdlogExtensions.h>



// Dummy factory for JFactoryGeneratorT
class Association_factory_EcalEndcapPInsertTruthClustersAssociations : public JFactoryT<edm4eic::MCRecoClusterParticleAssociation> {

public:
//------------------------------------------
// Constructor
Association_factory_EcalEndcapPInsertTruthClustersAssociations(){
SetTag("EcalEndcapPInsertTruthClustersAssociations");
}
};



class Cluster_factory_EcalEndcapPInsertTruthClusters : public JFactoryT<edm4eic::Cluster>, CalorimeterClusterRecoCoG {

public:
//------------------------------------------
// Constructor
Cluster_factory_EcalEndcapPInsertTruthClusters(){
SetTag("EcalEndcapPInsertTruthClusters");
}

//------------------------------------------
// Init
void Init() override{
auto app = GetApplication();
//-------- Configuration Parameters ------------
m_input_simhit_tag="EcalEndcapPInsertHits";
m_input_protoclust_tag="EcalEndcapPInsertTruthProtoClusters";

m_sampFrac=1.0;//{this, "samplingFraction", 1.0};
m_logWeightBase=3.6;//{this, "logWeightBase", 3.6};
m_depthCorrection=0.0;//{this, "depthCorrection", 0.0};
m_energyWeight="log";//{this, "energyWeight", "log"};
m_moduleDimZName="";//{this, "moduleDimZName", ""};
// Constrain the cluster position eta to be within
// the eta of the contributing hits. This is useful to avoid edge effects
// for endcaps.
m_enableEtaBounds=false;//{this, "enableEtaBounds", false};


app->SetDefaultParameter("EEMC:EcalEndcapPInsertTruthClusters:input_protoclust_tag", m_input_protoclust_tag, "Name of input collection to use");
app->SetDefaultParameter("EEMC:EcalEndcapPInsertTruthClusters:samplingFraction", m_sampFrac);
app->SetDefaultParameter("EEMC:EcalEndcapPInsertTruthClusters:logWeightBase", m_logWeightBase);
app->SetDefaultParameter("EEMC:EcalEndcapPInsertTruthClusters:depthCorrection", m_depthCorrection);
app->SetDefaultParameter("EEMC:EcalEndcapPInsertTruthClusters:energyWeight", m_energyWeight);
app->SetDefaultParameter("EEMC:EcalEndcapPInsertTruthClusters:moduleDimZName", m_moduleDimZName);
app->SetDefaultParameter("EEMC:EcalEndcapPInsertTruthClusters:enableEtaBounds", m_enableEtaBounds);

m_geoSvc = app->template GetService<JDD4hep_service>();

std::string tag=this->GetTag();
std::shared_ptr<spdlog::logger> m_log = app->GetService<Log_service>()->logger(tag);

// Get log level from user parameter or default
std::string log_level_str = "info";
auto pm = app->GetJParameterManager();
pm->SetDefaultParameter(tag + ":LogLevel", log_level_str, "verbosity: trace, debug, info, warn, err, critical, off");
m_log->set_level(eicrecon::ParseLogLevel(log_level_str));


AlgorithmInit(m_log);
}

//------------------------------------------
// ChangeRun
void ChangeRun(const std::shared_ptr<const JEvent> &event) override{
AlgorithmChangeRun();
}

//------------------------------------------
// Process
void Process(const std::shared_ptr<const JEvent> &event) override{


// Prefill inputs
m_inputSimhits=event->Get<edm4hep::SimCalorimeterHit>(m_input_simhit_tag);
m_inputProto=event->Get<edm4eic::ProtoCluster>(m_input_protoclust_tag);

// Call Process for generic algorithm
AlgorithmProcess();


//outputs

// Hand owner of algorithm objects over to JANA
Set(m_outputClusters);
event->Insert(m_outputAssociations, "EcalEndcapPInsertTruthClustersAssociations");
m_outputClusters.clear(); // not really needed, but better to not leave dangling pointers around
m_outputAssociations.clear();
}
};

Loading

0 comments on commit ffc0e79

Please sign in to comment.