84 debug_(iConfig.getParameter<
int>(
"debug")) {
95 recHitsFH_ = consumes<HGCRecHitCollection>(recHitsFH);
96 recHitsBH_ = consumes<HGCRecHitCollection>(recHitsBH);
102 recHitsFH_ = consumes<HGCRecHitCollection>(recHitsFH);
103 recHitsBH_ = consumes<HGCRecHitCollection>(recHitsBH);
127 ibooker.
book1D(
"h_EoP_CPene_100_calib_fraction",
"", 1000, -0.5, 2.5);
129 ibooker.
book1D(
"h_EoP_CPene_200_calib_fraction",
"", 1000, -0.5, 2.5);
131 ibooker.
book1D(
"h_EoP_CPene_300_calib_fraction",
"", 1000, -0.5, 2.5);
133 ibooker.
book1D(
"hgcal_EoP_CPene_100_calib_fraction",
"", 1000, -0.5, 2.5);
135 ibooker.
book1D(
"hgcal_EoP_CPene_200_calib_fraction",
"", 1000, -0.5, 2.5);
137 ibooker.
book1D(
"hgcal_EoP_CPene_300_calib_fraction",
"", 1000, -0.5, 2.5);
139 ibooker.
book1D(
"hgcal_ele_EoP_CPene_100_calib_fraction",
"", 1000, -0.5, 2.5);
141 ibooker.
book1D(
"hgcal_ele_EoP_CPene_200_calib_fraction",
"", 1000, -0.5, 2.5);
143 ibooker.
book1D(
"hgcal_ele_EoP_CPene_300_calib_fraction",
"", 1000, -0.5, 2.5);
145 ibooker.
book1D(
"hgcal_photon_EoP_CPene_100_calib_fraction",
"", 1000, -0.5, 2.5);
147 ibooker.
book1D(
"hgcal_photon_EoP_CPene_200_calib_fraction",
"", 1000, -0.5, 2.5);
149 ibooker.
book1D(
"hgcal_photon_EoP_CPene_300_calib_fraction",
"", 1000, -0.5, 2.5);
154 std::map<DetId, const HGCRecHit*>& hitmap,
const DetId hitid,
155 const unsigned int hitlayer,
const float fraction,
int& seedDet,
157 if (hitmap.find(hitid) == hitmap.end()) {
160 <<
">>> Failed to find detid " << std::hex << hitid.
rawId() <<
std::dec 161 <<
" Det " << hitid.
det()
162 <<
" Subdet " << hitid.
subdetId() << std::endl;
167 <<
">>> Wrong type of detid " << std::hex << hitid.
rawId() <<
std::dec 168 <<
" Det " << hitid.
det()
169 <<
" Subdet " << hitid.
subdetId() << std::endl;
173 assert(hitlayer == layer);
176 if (seedEnergy < hitmap[hitid]->energy()) {
177 seedEnergy = hitmap[hitid]->energy();
194 const std::vector<CaloParticle>&
caloParticles = *caloParticleHandle;
206 std::map<DetId, const HGCRecHit*> hitmap;
212 const auto& rechitsEE = *recHitHandleEE;
213 const auto& rechitsFH = *recHitHandleFH;
214 const auto& rechitsBH = *recHitHandleBH;
215 for (
unsigned int i = 0;
i < rechitsEE.size(); ++
i) {
216 hitmap[rechitsEE[
i].detid()] = &rechitsEE[
i];
218 for (
unsigned int i = 0;
i < rechitsFH.size(); ++
i) {
219 hitmap[rechitsFH[
i].detid()] = &rechitsFH[
i];
221 for (
unsigned int i = 0;
i < rechitsBH.size(); ++
i) {
222 hitmap[rechitsBH[
i].detid()] = &rechitsBH[
i];
229 for (
unsigned int i = 0;
i < rechitsEE.
size();
i++) {
230 hitmap[rechitsEE[
i].detid()] = &rechitsEE[
i];
237 const auto& rechitsFH = *recHitHandleFH;
238 const auto& rechitsBH = *recHitHandleBH;
239 for (
unsigned int i = 0;
i < rechitsFH.size();
i++) {
240 hitmap[rechitsFH[
i].detid()] = &rechitsFH[
i];
242 for (
unsigned int i = 0;
i < rechitsBH.size();
i++) {
243 hitmap[rechitsBH[
i].detid()] = &rechitsBH[
i];
254 float seedEnergy = 0.;
256 <<
"Number of caloParticles: " << caloParticles.size() << std::endl;
257 for (
const auto& it_caloPart : caloParticles) {
264 for (
const auto& it_sc : simClusterRefVector) {
267 <<
">>> SC.energy(): " << simCluster.
energy()
268 <<
" SC.simEnergy(): " << simCluster.
simEnergy()
270 const std::vector<std::pair<uint32_t, float> >& hits_and_fractions =
274 for (
const auto& it_haf : hits_and_fractions) {
276 DetId hitid = (it_haf.first);
292 <<
">>> MC Energy: " << it_caloPart.energy()
293 <<
" reco energy: " << sumCalibRecHitCalib_fraction
297 it_caloPart.energy());
300 const auto&
clusters = *hgcalMultiClustersHandle;
301 float total_energy = 0.;
302 float max_dR2 = 0.0025;
303 auto closest = std::min_element(
clusters.begin(),
310 auto ERatio_b =
b.correctedEnergy()/it_caloPart.energy();
313 if (dR2_a < max_dR2 && dR2_b < max_dR2)
314 return ERatio_a > ERatio_b;
315 return dR2_a < dR2_b;
319 total_energy = closest->correctedEnergy();
323 it_caloPart.energy());
327 auto closest_fcn = [&](
auto const &
a,
auto const&
b){
330 auto ERatio_a = a.
energy()/it_caloPart.energy();
331 auto ERatio_b =
b.energy()/it_caloPart.energy();
334 if (dR2_a < max_dR2 && dR2_b < max_dR2)
335 return ERatio_a > ERatio_b;
336 return dR2_a < dR2_b;
339 if (PFElectronHandle.
isValid()) {
340 auto const & ele = (*PFElectronHandle);
341 auto closest = std::min_element(ele.begin(),
344 if (closest != ele.end()
345 && closest->superCluster()->seed()->seed().det() ==
DetId::Forward 350 it_caloPart.energy());
356 if (PFPhotonHandle.
isValid()) {
357 auto const &
photon = (*PFPhotonHandle);
358 auto closest = std::min_element(
photon.begin(),
361 if (closest !=
photon.end()
362 && closest->superCluster()->seed()->seed().det() ==
DetId::Forward 367 it_caloPart.energy());
379 desc.
add<
int>(
"debug", 0);
380 desc.
add<
bool>(
"rawRecHits",
true);
389 descriptions.
add(
"hgcalHitCalibration", desc);
T getParameter(std::string const &) const
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_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
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_
std::vector< std::pair< uint32_t, float > > hits_and_fractions() const
Returns list of rechit IDs and fractions for this SimCluster.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::map< int, MonitorElement * > hgcal_ele_EoP_CPene_calib_fraction_
#define DEFINE_FWK_MODULE(type)
#define IfLogTrace(cond, cat)
HGCalHitCalibration(const edm::ParameterSet &)
std::map< int, MonitorElement * > hgcal_photon_EoP_CPene_calib_fraction_
uint32_t rawId() const
get the raw id
MonitorElement * LayerOccupancy_
~HGCalHitCalibration() override
edm::EDGetTokenT< HGCRecHitCollection > recHitsBH_
Monte Carlo truth information used for tracking validation.
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
MonitorElement * book1D(Args &&...args)
float energy() const
Energy. Note this is taken from the first SimTrack only.
ParameterDescriptionBase * add(U const &iLabel, T const &value)
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
double energy() const
cluster energy
hgcal::RecHitTools recHitTools_
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
float simEnergy() const
returns the accumulated sim energy in the cluster
void setCurrentFolder(const std::string &fullpath)
edm::EDGetTokenT< std::vector< reco::GsfElectron > > electrons_
std::map< int, MonitorElement * > h_EoP_CPene_calib_fraction_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
void analyze(const edm::Event &, const edm::EventSetup &) override
void fillWithRecHits(std::map< DetId, const HGCRecHit * > &, DetId, unsigned int, float, int &, float &)
std::array< float, layers_ > Energy_layer_calib_
Detector det() const
get the detector field from this detid