50 void fillWithRecHits(std::map<DetId, const HGCRecHit*>&,
DetId,
unsigned int,
float,
int&,
float&);
83 rawRecHits_(iConfig.getParameter<
bool>(
"rawRecHits")),
84 debug_(iConfig.getParameter<
int>(
"debug")),
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);
140 ibooker.
book1D(
"hgcal_ele_EoP_CPene_100_calib_fraction",
"", 1000, -0.5, 2.5);
142 ibooker.
book1D(
"hgcal_ele_EoP_CPene_200_calib_fraction",
"", 1000, -0.5, 2.5);
144 ibooker.
book1D(
"hgcal_ele_EoP_CPene_300_calib_fraction",
"", 1000, -0.5, 2.5);
146 ibooker.
book1D(
"hgcal_ele_EoP_CPene_scint_calib_fraction",
"", 1000, -0.5, 2.5);
148 ibooker.
book1D(
"hgcal_photon_EoP_CPene_100_calib_fraction",
"", 1000, -0.5, 2.5);
150 ibooker.
book1D(
"hgcal_photon_EoP_CPene_200_calib_fraction",
"", 1000, -0.5, 2.5);
152 ibooker.
book1D(
"hgcal_photon_EoP_CPene_300_calib_fraction",
"", 1000, -0.5, 2.5);
154 ibooker.
book1D(
"hgcal_photon_EoP_CPene_scint_calib_fraction",
"", 1000, -0.5, 2.5);
160 const unsigned int hitlayer,
164 if (hitmap.find(hitid) == hitmap.end()) {
167 <<
">>> Failed to find detid " << std::hex << hitid.
rawId() <<
std::dec <<
" Det " << hitid.
det() <<
" Subdet " 174 <<
">>> Wrong type of detid " << std::hex << hitid.
rawId() <<
std::dec <<
" Det " << hitid.
det() <<
" Subdet " 183 if (seedEnergy < hitmap[hitid]->
energy()) {
184 seedEnergy = hitmap[hitid]->energy();
199 const std::vector<CaloParticle>&
caloParticles = *caloParticleHandle;
208 std::map<DetId, const HGCRecHit*> hitmap;
212 if (!rechitsEE_handle.isValid())
216 if (!rechitsFH_handle.isValid())
220 if (!rechitsBH_handle.isValid())
223 auto const& rechitsEE = *rechitsEE_handle;
224 auto const& rechitsFH = *rechitsFH_handle;
225 auto const& rechitsBH = *rechitsBH_handle;
226 for (
unsigned int i = 0;
i < rechitsEE.size(); ++
i) {
227 hitmap[rechitsEE[
i].detid()] = &rechitsEE[
i];
229 for (
unsigned int i = 0;
i < rechitsFH.size(); ++
i) {
230 hitmap[rechitsFH[
i].detid()] = &rechitsFH[
i];
232 for (
unsigned int i = 0;
i < rechitsBH.size(); ++
i) {
233 hitmap[rechitsBH[
i].detid()] = &rechitsBH[
i];
239 if (!rechitsEE_handle.isValid())
242 auto const& rechitsEE = *rechitsEE_handle;
243 for (
unsigned int i = 0;
i < rechitsEE.size();
i++) {
244 hitmap[rechitsEE[
i].detid()] = &rechitsEE[
i];
250 if (!rechitsFH_handle.isValid())
254 if (!rechitsBH_handle.isValid())
257 auto const& rechitsFH = *rechitsFH_handle;
258 auto const& rechitsBH = *rechitsBH_handle;
259 for (
unsigned int i = 0;
i < rechitsFH.size();
i++) {
260 hitmap[rechitsFH[
i].detid()] = &rechitsFH[
i];
262 for (
unsigned int i = 0;
i < rechitsBH.size();
i++) {
263 hitmap[rechitsBH[
i].detid()] = &rechitsBH[
i];
274 float seedEnergy = 0.;
277 if (it_caloPart.g4Tracks()[0].eventId().event() != 0
or it_caloPart.g4Tracks()[0].eventId().bunchCrossing() != 0) {
278 LogDebug(
"HGCalHitCalibration") <<
"Excluding CaloParticles from event: " 279 << it_caloPart.g4Tracks()[0].eventId().event()
280 <<
" with BX: " << it_caloPart.g4Tracks()[0].eventId().bunchCrossing()
291 for (
const auto& it_sc : simClusterRefVector) {
294 <<
">>> SC.energy(): " << simCluster.
energy() <<
" SC.simEnergy(): " << simCluster.
simEnergy() << std::endl;
295 const std::vector<std::pair<uint32_t, float> >& hits_and_fractions = simCluster.
hits_and_fractions();
298 for (
const auto& it_haf : hits_and_fractions) {
300 DetId hitid = (it_haf.first);
305 fillWithRecHits(hitmap, hitid, hitlayer, it_haf.second, seedDet, seedEnergy);
310 auto sumCalibRecHitCalib_fraction =
313 <<
">>> MC Energy: " << it_caloPart.energy() <<
" reco energy: " << sumCalibRecHitCalib_fraction << std::endl;
318 if (hgcalMultiClustersHandle.
isValid()) {
319 const auto&
clusters = *hgcalMultiClustersHandle;
320 float total_energy = 0.;
325 auto ERatio_a =
a.correctedEnergy() / it_caloPart.energy();
326 auto ERatio_b =
b.correctedEnergy() / it_caloPart.energy();
329 if (dR2_a < max_dR2 && dR2_b < max_dR2)
330 return ERatio_a > ERatio_b;
331 return dR2_a < dR2_b;
334 total_energy =
closest->correctedEnergy();
345 auto closest_fcn = [&](
auto const&
a,
auto const&
b) {
348 auto ERatio_a =
a.energy() / it_caloPart.energy();
349 auto ERatio_b =
b.energy() / it_caloPart.energy();
352 if (dR2_a < max_dR2 && dR2_b < max_dR2)
353 return ERatio_a > ERatio_b;
354 return dR2_a < dR2_b;
358 if (PFElectronHandle.
isValid()) {
359 auto const& ele = (*PFElectronHandle);
360 auto closest = std::min_element(ele.begin(), ele.end(), closest_fcn);
377 if (PFPhotonHandle.
isValid()) {
378 auto const&
photon = (*PFPhotonHandle);
398 desc.add<
int>(
"debug", 0);
399 desc.add<
bool>(
"rawRecHits",
true);
402 desc.add<
int>(
"depletionFine", 120);
410 descriptions.
add(
"hgcalHitCalibrationDefault",
desc);
static constexpr int layers_
edm::EDGetTokenT< std::vector< CaloParticle > > caloParticles_
static constexpr int depletion2_
static constexpr int scint_
edm::EDGetTokenT< std::vector< reco::Photon > > photons_
T getParameter(std::string const &) const
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_
edm::EDGetTokenT< HGCRecHitCollection > recHitsFH_
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
virtual void setCurrentFolder(std::string const &fullpath)
edm::EDGetTokenT< HGCRecHitCollection > recHitsEE_
#define IfLogTrace(cond, cat)
std::map< int, MonitorElement * > hgcal_ele_EoP_CPene_calib_fraction_
int closest(std::vector< int > const &vec, int value)
HGCalHitCalibration(const edm::ParameterSet &)
constexpr Detector det() const
get the detector field from this detid
std::map< int, MonitorElement * > hgcal_photon_EoP_CPene_calib_fraction_
std::vector< std::pair< uint32_t, float > > hits_and_fractions() const
Returns list of rechit IDs and fractions for this SimCluster.
float simEnergy() const
returns the accumulated sim energy in the cluster
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)
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
void fillWithRecHits(std::map< DetId, const HGCRecHit *> &, DetId, unsigned int, float, int &, float &)
#define DEFINE_FWK_MODULE(type)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
hgcal::RecHitTools recHitTools_
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
constexpr uint32_t rawId() const
get the raw id
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
float energy() const
Energy. Note this is taken from the first SimTrack only.
std::array< float, layers_ > Energy_layer_calib_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeomToken_
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
static constexpr int depletion1_