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());
265 int cellThickness = 0;
267 if( subdet ==
HGCEE ){
268 cellThickness = (
hgceeTopoHandle_)->dddConstants().waferTypeL((
unsigned int)tcellId.wafer() );
269 }
else if( subdet ==
HGCHEF ){
270 cellThickness = (
hgchefTopoHandle_)->dddConstants().waferTypeL((
unsigned int)tcellId.wafer() );
271 }
else if( subdet ==
HGCHEB ){
272 edm::LogWarning(
"DataNotFound") <<
"ATTENTION: the BH trgCells are not yet implemented !! ";
276 calibration_.
calibrateInGeV(calibratedtriggercell, cellThickness);
280 auto calibratedDigiEnergy=calibratedtriggercell.
p4().E();
281 double eta=triggercell.p4().Eta();
282 double phi=triggercell.p4().Phi();
283 double z = triggercell.position().z();
288 map<unsigned, double> energy_for_cluster_shapes;
295 double hgc_energy=1.0e-10;
296 const auto &it = hgc_simhit_energy.find(cell);
297 if (it != hgc_simhit_energy.end()) { hgc_energy = it->second; }
300 const auto & iterator= simclusters.find(cellId);
301 if (iterator == simclusters.end() )
continue;
302 const auto &
particles = iterator->second;
305 const auto &
pid=
p.first;
308 energy_for_cluster_shapes[
pid] += calibratedDigiEnergy *
fraction *hgc_energy;
316 double hgc_energy=1.0e-10;
317 const auto &it = hgc_simhit_energy.find(cell);
318 if (it != hgc_simhit_energy.end()) { hgc_energy = it->second; }
320 const auto & iterator= simclusters.find(cellId);
321 if (iterator == simclusters.end() )
continue;
322 const auto &
particles = iterator->second;
325 const auto &
pid=
p.first;
328 auto energy =
fraction * hgc_energy* calibratedDigiEnergy/norm;
339 for(
const auto& iterator :energy_for_cluster_shapes)
341 double energy = iterator.second / norm;
342 unsigned pid = iterator.first;
349 for (
auto&
p : cluster_container)
352 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
virtual void putInEvent(edm::Event &evt) override final
HGCalTriggerBackend::HGCalTriggerSimCluster< HGCalTriggerCellThresholdCodec, HGCalTriggerCellThresholdDataPayload > HGCalTriggerSimClusterThreshold
virtual void setProduces(edm::stream::EDProducer<> &prod) const override final
ParameterSet const & getParameterSet(ParameterSetID const &id)
virtual void run(const l1t::HGCFETriggerDigiCollection &coll, const edm::EventSetup &es, edm::Event &evt)
bool detectorType() const
edm::EDGetTokenT< std::vector< SimCluster > > sim_token_
edm::ESHandle< HGCalTopology > hgchefTopoHandle_
void calibrateInGeV(l1t::HGCalTriggerCell &, int cellThickness)
U second(std::pair< T, U > const &p)
std::pair< int, int > simToReco(int cell, int layer, int mod, bool half) const
virtual void reset() override final
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)
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
edm::Handle< std::vector< SimCluster > > sim_handle_
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_
virtual const LorentzVector & p4() const final
four-momentum Lorentz vector
static void unpackHexagonIndex(const uint32_t &idx, int &subdet, int &z, int &lay, int &wafer, int &celltyp, int &cell)
edm::ESHandle< HGCalTopology > hgceeTopoHandle_