191 const std::vector<CaloParticle>&
caloParticles = *caloParticleHandle;
203 std::map<DetId, const HGCRecHit*> hitmap;
209 const auto& rechitsEE = *recHitHandleEE;
210 const auto& rechitsFH = *recHitHandleFH;
211 const auto& rechitsBH = *recHitHandleBH;
212 for (
unsigned int i = 0;
i < rechitsEE.size(); ++
i) {
213 hitmap[rechitsEE[
i].detid()] = &rechitsEE[
i];
215 for (
unsigned int i = 0;
i < rechitsFH.size(); ++
i) {
216 hitmap[rechitsFH[
i].detid()] = &rechitsFH[
i];
218 for (
unsigned int i = 0;
i < rechitsBH.size(); ++
i) {
219 hitmap[rechitsBH[
i].detid()] = &rechitsBH[
i];
226 for (
unsigned int i = 0;
i < rechitsEE.
size();
i++) {
227 hitmap[rechitsEE[
i].detid()] = &rechitsEE[
i];
234 const auto& rechitsFH = *recHitHandleFH;
235 const auto& rechitsBH = *recHitHandleBH;
236 for (
unsigned int i = 0;
i < rechitsFH.size();
i++) {
237 hitmap[rechitsFH[
i].detid()] = &rechitsFH[
i];
239 for (
unsigned int i = 0;
i < rechitsBH.size();
i++) {
240 hitmap[rechitsBH[
i].detid()] = &rechitsBH[
i];
251 float seedEnergy = 0.;
252 IfLogTrace(
debug_ > 0,
"HGCalHitCalibration") <<
"Number of caloParticles: " << caloParticles.size() << std::endl;
253 for (
const auto& it_caloPart : caloParticles) {
254 if (it_caloPart.g4Tracks()[0].eventId().event() != 0
or it_caloPart.g4Tracks()[0].eventId().bunchCrossing() != 0) {
255 LogDebug(
"HGCalHitCalibration") <<
"Excluding CaloParticles from event: " 256 << it_caloPart.g4Tracks()[0].eventId().event()
257 <<
" with BX: " << it_caloPart.g4Tracks()[0].eventId().bunchCrossing()
268 for (
const auto& it_sc : simClusterRefVector) {
271 <<
">>> SC.energy(): " << simCluster.
energy() <<
" SC.simEnergy(): " << simCluster.
simEnergy() << std::endl;
272 const std::vector<std::pair<uint32_t, float> >& hits_and_fractions = simCluster.
hits_and_fractions();
275 for (
const auto& it_haf : hits_and_fractions) {
277 DetId hitid = (it_haf.first);
284 fillWithRecHits(hitmap, hitid, hitlayer, it_haf.second, seedDet, seedEnergy);
289 auto sumCalibRecHitCalib_fraction =
292 <<
">>> MC Energy: " << it_caloPart.energy() <<
" reco energy: " << sumCalibRecHitCalib_fraction << std::endl;
297 const auto&
clusters = *hgcalMultiClustersHandle;
298 float total_energy = 0.;
299 float max_dR2 = 0.0025;
305 auto ERatio_b =
b.correctedEnergy() / it_caloPart.energy();
308 if (dR2_a < max_dR2 && dR2_b < max_dR2)
309 return ERatio_a > ERatio_b;
310 return dR2_a < dR2_b;
313 total_energy = closest->correctedEnergy();
320 auto closest_fcn = [&](
auto const&
a,
auto const&
b) {
323 auto ERatio_a = a.
energy() / it_caloPart.energy();
324 auto ERatio_b =
b.energy() / it_caloPart.energy();
327 if (dR2_a < max_dR2 && dR2_b < max_dR2)
328 return ERatio_a > ERatio_b;
329 return dR2_a < dR2_b;
332 if (PFElectronHandle.
isValid()) {
333 auto const& ele = (*PFElectronHandle);
334 auto closest = std::min_element(ele.begin(), ele.end(), closest_fcn);
335 if (closest != ele.end() &&
336 (closest->superCluster()->seed()->seed().det() ==
DetId::Forward ||
337 closest->superCluster()->seed()->seed().det() ==
DetId::HGCalEE) &&
347 if (PFPhotonHandle.
isValid()) {
348 auto const&
photon = (*PFPhotonHandle);
349 auto closest = std::min_element(
photon.begin(),
photon.end(), closest_fcn);
350 if (closest !=
photon.end() &&
351 (closest->superCluster()->seed()->seed().det() ==
DetId::Forward ||
352 closest->superCluster()->seed()->seed().det() ==
DetId::HGCalEE) &&
edm::EDGetTokenT< std::vector< CaloParticle > > caloParticles_
edm::EDGetTokenT< std::vector< reco::Photon > > photons_
std::array< float, layers_ > Energy_layer_calib_fraction_
edm::EDGetTokenT< std::vector< reco::PFCluster > > hgcalMultiClusters_
std::map< int, MonitorElement * > hgcal_EoP_CPene_calib_fraction_
double correctedEnergy() const
edm::EDGetTokenT< HGCRecHitCollection > recHitsFH_
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
edm::EDGetTokenT< HGCRecHitCollection > recHitsEE_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::map< int, MonitorElement * > hgcal_ele_EoP_CPene_calib_fraction_
#define IfLogTrace(cond, cat)
std::map< int, MonitorElement * > hgcal_photon_EoP_CPene_calib_fraction_
edm::EDGetTokenT< HGCRecHitCollection > recHitsBH_
Monte Carlo truth information used for tracking validation.
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
float energy() const
Energy. Note this is taken from the first SimTrack only.
double energy() const
cluster energy
hgcal::RecHitTools recHitTools_
float simEnergy() const
returns the accumulated sim energy in the cluster
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
edm::EDGetTokenT< std::vector< reco::GsfElectron > > electrons_
std::map< int, MonitorElement * > h_EoP_CPene_calib_fraction_
void fillWithRecHits(std::map< DetId, const HGCRecHit * > &, DetId, unsigned int, float, int &, float &)
std::array< float, layers_ > Energy_layer_calib_
std::vector< std::pair< uint32_t, float > > hits_and_fractions() const
Returns list of rechit IDs and fractions for this SimCluster.
constexpr Detector det() const
get the detector field from this detid