28 std::unordered_map<uint32_t,
double>& simhits_ee,
29 std::unordered_map<uint32_t,
double>& simhits_fh,
30 std::unordered_map<uint32_t,
double>& simhits_bh);
78 HGCalTriggerNtupleHGCTriggerCells::HGCalTriggerNtupleHGCTriggerCells(
const edm::
ParameterSet& conf)
80 fill_simenergy_(conf.getParameter<
bool>("FillSimEnergy")),
81 fill_truthmap_(conf.getParameter<
bool>("FillTruthMap")),
82 filter_cells_in_multiclusters_(conf.getParameter<
bool>("FilterCellsInMulticlusters")),
83 keV2fC_(conf.getParameter<
double>("
keV2fC")),
111 auto withPrefix([&prefix, &bname](
char const* vname) ->
char const* {
112 bname = prefix +
"_" + vname;
113 return bname.c_str();
116 tree.Branch(withPrefix(
"n"), &
tc_n_, (prefix +
"_n/I").c_str());
117 tree.Branch(withPrefix(
"id"), &
tc_id_);
118 tree.Branch(withPrefix(
"subdet"), &
tc_subdet_);
119 tree.Branch(withPrefix(
"zside"), &
tc_side_);
120 tree.Branch(withPrefix(
"layer"), &
tc_layer_);
121 tree.Branch(withPrefix(
"waferu"), &
tc_waferu_);
122 tree.Branch(withPrefix(
"waferv"), &
tc_waferv_);
124 tree.Branch(withPrefix(
"cellu"), &
tc_cellu_);
125 tree.Branch(withPrefix(
"cellv"), &
tc_cellv_);
126 tree.Branch(withPrefix(
"data"), &
tc_data_);
129 tree.Branch(withPrefix(
"pt"), &
tc_pt_);
130 tree.Branch(withPrefix(
"mipPt"), &
tc_mipPt_);
131 tree.Branch(withPrefix(
"energy"), &
tc_energy_);
134 tree.Branch(withPrefix(
"eta"), &
tc_eta_);
135 tree.Branch(withPrefix(
"phi"), &
tc_phi_);
136 tree.Branch(withPrefix(
"x"), &
tc_x_);
137 tree.Branch(withPrefix(
"y"), &
tc_y_);
138 tree.Branch(withPrefix(
"z"), &
tc_z_);
158 std::unordered_map<uint32_t, double> simhits_ee;
159 std::unordered_map<uint32_t, double> simhits_fh;
160 std::unordered_map<uint32_t, double> simhits_bh;
162 simhits(e, simhits_ee, simhits_fh, simhits_bh);
165 std::unordered_map<uint32_t, unsigned> cell_to_genparticle;
168 for (
auto& keyval : *caloparticles_map_h) {
169 for (
auto& tcref : keyval.val)
170 cell_to_genparticle.emplace(tcref->detId(), keyval.key->g4Tracks().at(0).genpartIndex() - 1);
175 std::unordered_map<uint32_t, uint32_t> cell2cluster;
176 std::unordered_map<uint32_t, l1t::HGCalMulticlusterBxCollection::const_iterator> cell2multicluster;
177 for (
auto mcl_itr = multiclusters.
begin(0); mcl_itr != multiclusters.
end(0); mcl_itr++) {
179 for (
const auto& cl_ptr : mcl_itr->constituents()) {
181 for (
const auto& tc_ptr : cl_ptr.second->constituents()) {
182 cell2cluster.emplace(tc_ptr.second->detId(), cl_ptr.second->detId());
183 cell2multicluster.emplace(tc_ptr.second->detId(), mcl_itr);
191 for (
auto tc_itr = trigger_cells.
begin(0); tc_itr != trigger_cells.
end(0); tc_itr++) {
192 if (tc_itr->hwPt() > 0) {
193 auto cl_itr = cell2cluster.find(tc_itr->detId());
194 auto mcl_itr = cell2multicluster.find(tc_itr->detId());
195 uint32_t cl_id = (cl_itr != cell2cluster.end() ? cl_itr->second : 0);
196 uint32_t mcl_id = (mcl_itr != cell2multicluster.end() ? mcl_itr->second->detId() : 0);
197 float mcl_pt = (mcl_itr != cell2multicluster.end() ? mcl_itr->second->pt() : 0.);
204 tc_id_.emplace_back(tc_itr->detId());
225 <<
"Found unexpected trigger cell detid to be filled in HGCal Trigger Cell ntuple.";
227 tc_data_.emplace_back(tc_itr->hwPt());
232 tc_pt_.emplace_back(tc_itr->pt());
234 tc_eta_.emplace_back(tc_itr->eta());
235 tc_phi_.emplace_back(tc_itr->phi());
236 tc_x_.emplace_back(tc_itr->position().x());
237 tc_y_.emplace_back(tc_itr->position().y());
238 tc_z_.emplace_back(tc_itr->position().z());
251 auto itr = simhits_ee.find(c_id);
252 if (itr != simhits_ee.end())
253 energy +=
calibrate(itr->second, thickness, layer);
255 auto itr = simhits_fh.find(c_id);
256 if (itr != simhits_fh.end())
257 energy +=
calibrate(itr->second, thickness, layer);
259 auto itr = simhits_bh.find(c_id);
260 if (itr != simhits_bh.end())
261 energy += itr->second;
269 auto itr(cell_to_genparticle.find(tc_itr->detId()));
270 if (itr == cell_to_genparticle.end())
282 double TeV2GeV = 1.e3;
283 return energy *
keV2fC_ / fcPerMip * layerWeight * TeV2GeV / thicknessCorrection;
287 std::unordered_map<uint32_t, double>& simhits_ee,
288 std::unordered_map<uint32_t, double>& simhits_fh,
289 std::unordered_map<uint32_t, double>& simhits_bh) {
301 for (
const auto& simhit : ee_simhits) {
305 auto itr_insert = simhits_ee.emplace(
id, 0.);
306 itr_insert.first->second += simhit.energy();
309 for (
const auto& simhit : fh_simhits) {
313 auto itr_insert = simhits_fh.emplace(
id, 0.);
314 itr_insert.first->second += simhit.energy();
317 for (
const auto& simhit : bh_simhits) {
321 auto itr_insert = simhits_bh.emplace(
id, 0.);
322 itr_insert.first->second += simhit.energy();
void initialize(TTree &, const edm::ParameterSet &, edm::ConsumesCollector &&) final
std::vector< float > tc_energy_
const_iterator end(int bx) const
std::vector< int > tc_cellv_
T getUntrackedParameter(std::string const &, T const &) const
std::vector< uint32_t > tc_data_
std::vector< uint32_t > tc_compressedCharge_
std::vector< PCaloHit > PCaloHitContainer
HGCalTriggerSubdetector subdet() const
get the subdetector
BXVector< HGCalTriggerCell > HGCalTriggerCellBxCollection
std::vector< int > tc_waferv_
uint16_t *__restrict__ id
std::vector< double > layerWeights_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
const HGCalTopology & eeTopology() const
~HGCalTriggerNtupleHGCTriggerCells() override
int triggerCellU() const
get the cell #'s in u,v or in x,y
HGCalTriggerNtupleHGCTriggerCells(const edm::ParameterSet &conf)
int type() const
get/set the type
virtual geom_set getCellsFromTriggerCell(const unsigned cell_det_id) const =0
edm::ESHandle< HGCalTriggerGeometryBase > geometry
DetId::Detector subdet() const
get the subdetector
int type() const
get the type
std::vector< int > tc_side_
constexpr std::array< uint8_t, layerIndexSize > layer
std::vector< uint32_t > tc_id_
std::vector< float > tc_eta_
bool filter_cells_in_multiclusters_
std::vector< int > tc_waferu_
edm::EDGetToken multiclusters_token_
std::vector< uint32_t > tc_uncompressedCharge_
edm::EDGetToken simhits_ee_token_
int iphi() const
get the phi index
std::vector< uint32_t > tc_cluster_id_
std::vector< int > tc_cellu_
edm::EDGetToken trigger_cells_token_
HGCalTriggerTools triggerTools_
edm::EDGetToken simhits_bh_token_
void fill(const edm::Event &e, const HGCalTriggerNtupleEventSetup &es) final
std::vector< int > tc_wafertype_
std::vector< float > tc_multicluster_pt_
const HGCalTopology & hscTopology() const
std::vector< double > thicknessCorrections_
std::vector< float > tc_phi_
T const * product() const
T getParameter(std::string const &) const
edm::EDGetToken simhits_fh_token_
std::vector< float > tc_x_
std::vector< float > tc_pt_
std::vector< CaloParticle > CaloParticleCollection
edm::EDGetToken caloparticles_map_token_
std::vector< int > tc_subdet_
std::vector< int > tc_genparticle_index_
std::vector< float > tc_mipPt_
#define DEFINE_EDM_PLUGIN(factory, type, name)
std::vector< float > tc_y_
double calibrate(double, int, unsigned)
void simhits(const edm::Event &e, std::unordered_map< uint32_t, double > &simhits_ee, std::unordered_map< uint32_t, double > &simhits_fh, std::unordered_map< uint32_t, double > &simhits_bh)
std::vector< float > tc_z_
std::vector< double > fcPerMip_
std::vector< int > tc_layer_
const_iterator begin(int bx) const
std::vector< float > tc_simenergy_
std::vector< uint32_t > tc_multicluster_id_
const HGCalTopology & fhTopology() const