85 :
rawRecHits_(iConfig.getParameter<bool>(
"rawRecHits")),
86 debug_(iConfig.getParameter<
int>(
"debug")) {
97 recHitsFH_ = consumes<HGCRecHitCollection>(recHitsFH);
98 recHitsBH_ = consumes<HGCRecHitCollection>(recHitsBH);
104 recHitsFH_ = consumes<HGCRecHitCollection>(recHitsFH);
105 recHitsBH_ = consumes<HGCRecHitCollection>(recHitsBH);
129 ibooker.
book1D(
"h_EoP_CPene_100_calib_fraction",
"", 1000, -0.5, 2.5);
131 ibooker.
book1D(
"h_EoP_CPene_200_calib_fraction",
"", 1000, -0.5, 2.5);
133 ibooker.
book1D(
"h_EoP_CPene_300_calib_fraction",
"", 1000, -0.5, 2.5);
135 ibooker.
book1D(
"hgcal_EoP_CPene_100_calib_fraction",
"", 1000, -0.5, 2.5);
137 ibooker.
book1D(
"hgcal_EoP_CPene_200_calib_fraction",
"", 1000, -0.5, 2.5);
139 ibooker.
book1D(
"hgcal_EoP_CPene_300_calib_fraction",
"", 1000, -0.5, 2.5);
141 ibooker.
book1D(
"hgcal_ele_EoP_CPene_100_calib_fraction",
"", 1000, -0.5, 2.5);
143 ibooker.
book1D(
"hgcal_ele_EoP_CPene_200_calib_fraction",
"", 1000, -0.5, 2.5);
145 ibooker.
book1D(
"hgcal_ele_EoP_CPene_300_calib_fraction",
"", 1000, -0.5, 2.5);
147 ibooker.
book1D(
"hgcal_photon_EoP_CPene_100_calib_fraction",
"", 1000, -0.5, 2.5);
149 ibooker.
book1D(
"hgcal_photon_EoP_CPene_200_calib_fraction",
"", 1000, -0.5, 2.5);
151 ibooker.
book1D(
"hgcal_photon_EoP_CPene_300_calib_fraction",
"", 1000, -0.5, 2.5);
156 std::map<DetId, const HGCRecHit*>& hitmap,
const DetId hitid,
157 const unsigned int hitlayer,
const float fraction,
int& seedDet,
159 if (hitmap.find(hitid) == hitmap.end()) {
162 <<
">>> Failed to find detid " << hitid.
rawId()
163 <<
" Det " << hitid.
det()
164 <<
" Subdet " << hitid.
subdetId() << std::endl;
168 assert(hitlayer == layer);
171 if (seedEnergy < hitmap[hitid]->energy()) {
172 seedEnergy = hitmap[hitid]->energy();
189 const std::vector<CaloParticle>&
caloParticles = *caloParticleHandle;
201 std::map<DetId, const HGCRecHit*> hitmap;
207 const auto& rechitsEE = *recHitHandleEE;
208 const auto& rechitsFH = *recHitHandleFH;
209 const auto& rechitsBH = *recHitHandleBH;
210 for (
unsigned int i = 0;
i < rechitsEE.size(); ++
i) {
211 hitmap[rechitsEE[
i].detid()] = &rechitsEE[
i];
213 for (
unsigned int i = 0;
i < rechitsFH.size(); ++
i) {
214 hitmap[rechitsFH[
i].detid()] = &rechitsFH[
i];
216 for (
unsigned int i = 0;
i < rechitsBH.size(); ++
i) {
217 hitmap[rechitsBH[
i].detid()] = &rechitsBH[
i];
224 for (
unsigned int i = 0;
i < rechitsEE.
size();
i++) {
225 hitmap[rechitsEE[
i].detid()] = &rechitsEE[
i];
232 const auto& rechitsFH = *recHitHandleFH;
233 const auto& rechitsBH = *recHitHandleBH;
234 for (
unsigned int i = 0;
i < rechitsFH.size();
i++) {
235 hitmap[rechitsFH[
i].detid()] = &rechitsFH[
i];
237 for (
unsigned int i = 0;
i < rechitsBH.size();
i++) {
238 hitmap[rechitsBH[
i].detid()] = &rechitsBH[
i];
249 float seedEnergy = 0.;
251 <<
"Number of caloParticles: " << caloParticles.size() << std::endl;
252 for (
const auto& it_caloPart : caloParticles) {
259 for (
const auto& it_sc : simClusterRefVector) {
262 <<
">>> SC.energy(): " << simCluster.
energy()
263 <<
" SC.simEnergy(): " << simCluster.
simEnergy()
265 const std::vector<std::pair<uint32_t, float> >& hits_and_fractions =
269 for (
const auto& it_haf : hits_and_fractions) {
271 DetId hitid = (it_haf.first);
287 <<
">>> MC Energy: " << it_caloPart.energy()
288 <<
" reco energy: " << sumCalibRecHitCalib_fraction
292 it_caloPart.energy());
295 const auto&
clusters = *hgcalMultiClustersHandle;
296 float total_energy = 0.;
297 float max_dR2 = 0.0025;
298 auto closest = std::min_element(
clusters.begin(),
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;
314 total_energy = closest->correctedEnergy();
318 it_caloPart.energy());
322 auto closest_fcn = [&](
auto const &
a,
auto const&
b){
325 auto ERatio_a = a.
energy()/it_caloPart.energy();
326 auto ERatio_b =
b.energy()/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 if (PFElectronHandle.
isValid()) {
335 auto const & ele = (*PFElectronHandle);
336 auto closest = std::min_element(ele.begin(),
339 if (closest != ele.end()
340 && closest->superCluster()->seed()->seed().det() ==
DetId::Forward 345 it_caloPart.energy());
351 if (PFPhotonHandle.
isValid()) {
352 auto const &
photon = (*PFPhotonHandle);
353 auto closest = std::min_element(
photon.begin(),
356 if (closest !=
photon.end()
357 && closest->superCluster()->seed()->seed().det() ==
DetId::Forward 362 it_caloPart.energy());
374 desc.
add<
int>(
"debug", 0);
375 desc.
add<
bool>(
"rawRecHits",
true);
384 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)
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
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