54 void fillWithRecHits(std::map<DetId, const HGCRecHit*>&,
DetId,
unsigned int,
float,
int&,
float&);
94 recHitsFH_ = consumes<HGCRecHitCollection>(recHitsFH);
95 recHitsBH_ = consumes<HGCRecHitCollection>(recHitsBH);
101 recHitsFH_ = consumes<HGCRecHitCollection>(recHitsFH);
102 recHitsBH_ = consumes<HGCRecHitCollection>(recHitsBH);
130 ibooker.
book1D(
"hgcal_EoP_CPene_100_calib_fraction",
"", 1000, -0.5, 2.5);
132 ibooker.
book1D(
"hgcal_EoP_CPene_200_calib_fraction",
"", 1000, -0.5, 2.5);
134 ibooker.
book1D(
"hgcal_EoP_CPene_300_calib_fraction",
"", 1000, -0.5, 2.5);
136 ibooker.
book1D(
"hgcal_ele_EoP_CPene_100_calib_fraction",
"", 1000, -0.5, 2.5);
138 ibooker.
book1D(
"hgcal_ele_EoP_CPene_200_calib_fraction",
"", 1000, -0.5, 2.5);
140 ibooker.
book1D(
"hgcal_ele_EoP_CPene_300_calib_fraction",
"", 1000, -0.5, 2.5);
142 ibooker.
book1D(
"hgcal_photon_EoP_CPene_100_calib_fraction",
"", 1000, -0.5, 2.5);
144 ibooker.
book1D(
"hgcal_photon_EoP_CPene_200_calib_fraction",
"", 1000, -0.5, 2.5);
146 ibooker.
book1D(
"hgcal_photon_EoP_CPene_300_calib_fraction",
"", 1000, -0.5, 2.5);
152 const unsigned int hitlayer,
156 if (hitmap.find(hitid) == hitmap.end()) {
159 <<
">>> Failed to find detid " << std::hex << hitid.
rawId() <<
std::dec <<
" Det " << hitid.
det() <<
" Subdet " 166 <<
">>> Wrong type of detid " << std::hex << hitid.
rawId() <<
std::dec <<
" Det " << hitid.
det() <<
" Subdet " 171 assert(hitlayer == layer);
174 if (seedEnergy < hitmap[hitid]->
energy()) {
175 seedEnergy = hitmap[hitid]->energy();
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) &&
367 desc.
add<
int>(
"debug", 0);
368 desc.
add<
bool>(
"rawRecHits",
true);
370 desc.
add<
int>(
"depletionFine", 100);
378 descriptions.
add(
"hgcalHitCalibrationDefault", desc);
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX)
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_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::map< int, MonitorElement * > hgcal_ele_EoP_CPene_calib_fraction_
void setCurrentFolder(std::string const &fullpath)
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
#define DEFINE_FWK_MODULE(type)
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.
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())
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_
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