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;
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;
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 !! ";
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)
const HGCalTriggerGeometryBase * geometry_
virtual geom_set getCellsFromTriggerCell(const unsigned cell_det_id) const =0
std::string HGCalEESensitive_
HGCalTriggerCellCalibration calibration_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
bool detectorType() const
edm::EDGetTokenT< std::vector< SimCluster > > sim_token_
edm::ESHandle< HGCalTopology > hgchefTopoHandle_
void calibrateInGeV(l1t::HGCalTriggerCell &, int cellThickness)
std::pair< int, int > simToReco(int cell, int layer, int mod, bool half) 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_
const HGCalDDDConstants & dddConstants() const
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)
std::unique_ptr< l1t::HGCalClusterBxCollection > cluster_product_
static void unpackHexagonIndex(const uint32_t &idx, int &subdet, int &z, int &lay, int &wafer, int &celltyp, int &cell)
edm::ESHandle< HGCalTopology > hgceeTopoHandle_