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;
168 <<
">>> Wrong type of detid " << std::hex << hitid.
rawId() <<
std::dec 169 <<
" Det " << hitid.
det()
170 <<
" Subdet " << hitid.
subdetId() << std::endl;
174 assert(hitlayer == layer);
177 if (seedEnergy < hitmap[hitid]->energy()) {
178 seedEnergy = hitmap[hitid]->energy();
195 const std::vector<CaloParticle>&
caloParticles = *caloParticleHandle;
207 std::map<DetId, const HGCRecHit*> hitmap;
213 const auto& rechitsEE = *recHitHandleEE;
214 const auto& rechitsFH = *recHitHandleFH;
215 const auto& rechitsBH = *recHitHandleBH;
216 for (
unsigned int i = 0;
i < rechitsEE.size(); ++
i) {
217 hitmap[rechitsEE[
i].detid()] = &rechitsEE[
i];
219 for (
unsigned int i = 0;
i < rechitsFH.size(); ++
i) {
220 hitmap[rechitsFH[
i].detid()] = &rechitsFH[
i];
222 for (
unsigned int i = 0;
i < rechitsBH.size(); ++
i) {
223 hitmap[rechitsBH[
i].detid()] = &rechitsBH[
i];
230 for (
unsigned int i = 0;
i < rechitsEE.
size();
i++) {
231 hitmap[rechitsEE[
i].detid()] = &rechitsEE[
i];
238 const auto& rechitsFH = *recHitHandleFH;
239 const auto& rechitsBH = *recHitHandleBH;
240 for (
unsigned int i = 0;
i < rechitsFH.size();
i++) {
241 hitmap[rechitsFH[
i].detid()] = &rechitsFH[
i];
243 for (
unsigned int i = 0;
i < rechitsBH.size();
i++) {
244 hitmap[rechitsBH[
i].detid()] = &rechitsBH[
i];
255 float seedEnergy = 0.;
257 <<
"Number of caloParticles: " << caloParticles.size() << std::endl;
258 for (
const auto& it_caloPart : caloParticles) {
265 for (
const auto& it_sc : simClusterRefVector) {
268 <<
">>> SC.energy(): " << simCluster.
energy()
269 <<
" SC.simEnergy(): " << simCluster.
simEnergy()
271 const std::vector<std::pair<uint32_t, float> >& hits_and_fractions =
275 for (
const auto& it_haf : hits_and_fractions) {
277 DetId hitid = (it_haf.first);
296 <<
">>> MC Energy: " << it_caloPart.energy()
297 <<
" reco energy: " << sumCalibRecHitCalib_fraction
301 it_caloPart.energy());
304 const auto&
clusters = *hgcalMultiClustersHandle;
305 float total_energy = 0.;
306 float max_dR2 = 0.0025;
307 auto closest = std::min_element(
clusters.begin(),
314 auto ERatio_b =
b.correctedEnergy()/it_caloPart.energy();
317 if (dR2_a < max_dR2 && dR2_b < max_dR2)
318 return ERatio_a > ERatio_b;
319 return dR2_a < dR2_b;
323 total_energy = closest->correctedEnergy();
327 it_caloPart.energy());
331 auto closest_fcn = [&](
auto const &
a,
auto const&
b){
334 auto ERatio_a = a.
energy()/it_caloPart.energy();
335 auto ERatio_b =
b.energy()/it_caloPart.energy();
338 if (dR2_a < max_dR2 && dR2_b < max_dR2)
339 return ERatio_a > ERatio_b;
340 return dR2_a < dR2_b;
343 if (PFElectronHandle.
isValid()) {
344 auto const & ele = (*PFElectronHandle);
345 auto closest = std::min_element(ele.begin(),
348 if (closest != ele.end()
349 && (closest->superCluster()->seed()->seed().det() ==
DetId::Forward ||
355 it_caloPart.energy());
361 if (PFPhotonHandle.
isValid()) {
362 auto const &
photon = (*PFPhotonHandle);
363 auto closest = std::min_element(
photon.begin(),
366 if (closest !=
photon.end()
367 && (closest->superCluster()->seed()->seed().det() ==
DetId::Forward ||
373 it_caloPart.energy());
385 desc.
add<
int>(
"debug", 0);
386 desc.
add<
bool>(
"rawRecHits",
true);
395 descriptions.
add(
"hgcalHitCalibrationDefault", 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)
constexpr uint32_t rawId() const
get the raw id
#define IfLogTrace(cond, cat)
HGCalHitCalibration(const edm::ParameterSet &)
std::map< int, MonitorElement * > hgcal_photon_EoP_CPene_calib_fraction_
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)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
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)
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
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
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)
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_
constexpr Detector det() const
get the detector field from this detid