51 template<
typename FECODEC,
typename DATA>
75 auto pair = cluster_container.emplace(pid, std::pair<int,l1t::HGCalCluster>(0,
l1t::HGCalCluster() ) ) ;
76 auto iterator = pair.first;
77 iterator ->
second .
second . shapes().Add( energy,eta,phi,
r);
83 auto pair = cluster_container.emplace(pid, std::pair<int,l1t::HGCalCluster>(0,
l1t::HGCalCluster() ) ) ;
84 auto iterator = pair.first;
92 pp4.SetPt ( energy * (2*t)/(1+t*t) ) ;
119 HGCalEESensitive_(conf.getParameter<
std::
string>(
"HGCalEESensitive_tag")),
120 HGCalHESiliconSensitive_(conf.getParameter<
std::
string>(
"HGCalHESiliconSensitive_tag")),
127 edm::LogWarning(
"HGCalTriggerSimCluster") <<
"WARNING: BH simhits not loaded";
166 if (not ee_simhits_h.
isValid()){
167 throw cms::Exception(
"ContentError")<<
"[HGCalTriggerSimCluster]::[run]::[ERROR] EE Digis from HGC not available";
169 if (not fh_simhits_h.
isValid()){
170 throw cms::Exception(
"ContentError")<<
"[HGCalTriggerSimCluster]::[run]::[ERROR] FH Digis from HGC not available";
173 std::unordered_map<uint64_t, double> hgc_simhit_energy;
181 int layer=0,cell=0, sec=0, subsec=0, zp=0,subdet=0;
183 for (
const auto& simhit : *ee_simhits_h)
188 cell = recoLayerCell.first;
189 layer = recoLayerCell.second;
190 if (layer<0 || cell<0) {
193 unsigned recoCell =
HGCalDetId(mysubdet,zp,layer,subsec,sec,cell);
195 hgc_simhit_energy[recoCell] += simhit.energy();
200 int layer=0,cell=0, sec=0, subsec=0, zp=0,subdet=0;
202 for (
const auto& simhit : *fh_simhits_h)
207 cell = recoLayerCell.first;
208 layer = recoLayerCell.second;
209 if (layer<0 || cell<0) {
212 unsigned recoCell =
HGCalDetId(mysubdet,zp,layer,subsec,sec,cell);
213 hgc_simhit_energy[recoCell] += simhit.energy();
219 throw cms::Exception(
"Not Implemented")<<
"HGCalTriggerSimCluster: BH simhits not implemnted";
224 std::unordered_map<uint64_t,std::pair<int,l1t::HGCalCluster> > cluster_container;
227 if (not sim_handle_.
isValid()){
228 throw cms::Exception(
"ContentError")<<
"[HGCalTriggerSimCluster]::[run]::[ERROR] Sim Cluster collection for HGC sim clustering not available";
236 std::unordered_map<uint32_t, std::vector<std::pair< uint64_t, float > > > simclusters;
237 for (
auto& cluster : *sim_handle_)
239 auto pid= cluster.particleId();
240 const auto&
hf = cluster.hits_and_fractions();
241 for (
const auto &
p :
hf )
243 simclusters[
p.first].push_back( std::pair<uint64_t, float>(
pid,
p.second) ) ;
248 for(
const auto& digi : coll )
258 for(
const auto& triggercell : data.payload)
260 if(triggercell.hwPt()<=0)
continue;
262 const HGCalDetId tcellId(triggercell.detId());
270 auto calibratedDigiEnergy=calibratedtriggercell.p4().E();
271 double eta=triggercell.p4().Eta();
272 double phi=triggercell.p4().Phi();
273 double z = triggercell.position().z();
278 map<unsigned, double> energy_for_cluster_shapes;
285 double hgc_energy=1.0e-10;
286 const auto &it = hgc_simhit_energy.find(cell);
287 if (it != hgc_simhit_energy.end()) { hgc_energy = it->second; }
290 const auto & iterator= simclusters.find(cellId);
291 if (iterator == simclusters.end() )
continue;
292 const auto &
particles = iterator->second;
295 const auto &
pid=
p.first;
298 energy_for_cluster_shapes[
pid] += calibratedDigiEnergy *
fraction *hgc_energy;
306 double hgc_energy=1.0e-10;
307 const auto &it = hgc_simhit_energy.find(cell);
308 if (it != hgc_simhit_energy.end()) { hgc_energy = it->second; }
310 const auto & iterator= simclusters.find(cellId);
311 if (iterator == simclusters.end() )
continue;
312 const auto &
particles = iterator->second;
315 const auto &
pid=
p.first;
318 auto energy =
fraction * hgc_energy* calibratedDigiEnergy/norm;
329 for(
const auto& iterator :energy_for_cluster_shapes)
331 double energy = iterator.second / norm;
332 unsigned pid = iterator.first;
339 for (
auto&
p : cluster_container)
342 cluster_product_->push_back(
p.second.first,
p.second.second);
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
HGCalTriggerSimCluster(const edm::ParameterSet &conf, edm::ConsumesCollector &cc)
T getParameter(std::string const &) const
HGCalTriggerBackend::HGCalTriggerSimCluster< HGCalTriggerCellBestChoiceCodec, HGCalTriggerCellBestChoiceDataPayload > HGCalTriggerSimClusterBestChoice
const HGCalTriggerGeometryBase * geometry_
std::vector< PCaloHit > PCaloHitContainer
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > PtEtaPhiMLorentzVectorD
Lorentz vector with cartesian internal representation.
virtual geom_set getCellsFromTriggerCell(const unsigned cell_det_id) const =0
std::string HGCalEESensitive_
HGCalTriggerCellCalibration calibration_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
HGCalTriggerBackend::HGCalTriggerSimCluster< HGCalTriggerCellThresholdCodec, HGCalTriggerCellThresholdDataPayload > HGCalTriggerSimClusterThreshold
ParameterSet const & getParameterSet(ParameterSetID const &id)
void putInEvent(edm::Event &evt) final
bool detectorType() const
edm::EDGetTokenT< std::vector< SimCluster > > sim_token_
edm::ESHandle< HGCalTopology > hgchefTopoHandle_
U second(std::pair< T, U > const &p)
std::pair< int, int > simToReco(int cell, int layer, int mod, bool half) const
const std::string & name() const
void addToCluster(std::unordered_map< uint64_t, std::pair< int, l1t::HGCalCluster > > &cluster_container, uint64_t pid, int pdgid, float energy, float eta, float phi)
edm::Handle< std::vector< SimCluster > > sim_handle_
void run(const l1t::HGCFETriggerDigiCollection &coll, const edm::EventSetup &es, edm::Event &evt) override
unsigned long long uint64_t
const HGCalDDDConstants & dddConstants() const
return(e1-e2)*(e1-e2)+dp *dp
std::string HGCalHESiliconSensitive_
char data[epos_bytes_allocation]
void addToClusterShapes(std::unordered_map< uint64_t, std::pair< int, l1t::HGCalCluster > > &cluster_container, uint64_t pid, int pdgid, float energy, float eta, float phi, float r=0.0)
#define DEFINE_EDM_PLUGIN(factory, type, name)
std::unique_ptr< l1t::HGCalClusterBxCollection > cluster_product_
void setProduces(edm::stream::EDProducer<> &prod) const final
void calibrateInGeV(l1t::HGCalTriggerCell &)
static void unpackHexagonIndex(const uint32_t &idx, int &subdet, int &z, int &lay, int &wafer, int &celltyp, int &cell)
edm::ESHandle< HGCalTopology > hgceeTopoHandle_