236 auto outputHcalHBHEMuonColl = std::make_unique<HcalHBHEMuonVariablesCollection>();
239 unsigned int eventNumber =
iEvent.id().event();
240 unsigned int lumiNumber =
iEvent.id().luminosityBlock();
241 unsigned int bxNumber =
iEvent.bunchCrossing();
244 << bxNumber << std::endl;
255 std::vector<std::string>
modules;
257 const std::vector<std::string>& triggerNames_ =
triggerNames.triggerNames();
258 for (
unsigned int iHLT = 0; iHLT <
triggerResults->size(); iHLT++) {
266 edm::LogVerbatim(
"HBHEMuon") <<
"AlCaHcalHBHEMuonFilter::Trigger " << triggerNames_[iHLT] <<
" Flag " <<
hlt 267 <<
":" <<
ok << std::endl;
287 respCorrs->
setTopo(theHBHETopology);
298 unsigned int goodVertex = 0;
299 reco::VertexCollection::const_iterator firstGoodVertex;
300 if (!
vtx.isValid()) {
305 firstGoodVertex =
vtx->end();
306 for (reco::VertexCollection::const_iterator it =
vtx->begin(); it !=
vtx->end(); it++) {
308 if (firstGoodVertex ==
vtx->end())
309 firstGoodVertex = it;
313 if (firstGoodVertex !=
vtx->end())
314 pvx = firstGoodVertex->position();
317 if (
ok && (goodVertex > 0) &&
muons.isValid() && barrelRecHitsHandle.isValid() && endcapRecHitsHandle.isValid() &&
319 for (reco::MuonCollection::const_iterator recMuon =
muons->begin(); recMuon !=
muons->end(); ++recMuon) {
326 hbheMuon.
muonGood_ = (recMuon->isPFMuon());
330 hbheMuon.
etaGlob_ = (recMuon->eta());
331 hbheMuon.
phiGlob_ = (recMuon->phi());
333 hbheMuon.
pMuon_ = (recMuon->p());
335 edm::LogVerbatim(
"HBHEMuon") <<
"Energy:" << recMuon->energy() <<
" P:" << recMuon->p();
339 hbheMuon.
muonTrkKink_ = (recMuon->combinedQuality().trkKink);
343 if (recMuon->track().isNonnull()) {
344 hbheMuon.
trackerLayer_ = (recMuon->track()->hitPattern().trackerLayersWithMeasurement());
348 if (recMuon->innerTrack().isNonnull()) {
350 hbheMuon.
numPixelLayers_ = (recMuon->innerTrack()->hitPattern().pixelLayersWithMeasurement());
351 hbheMuon.
chiTracker_ = (recMuon->innerTrack()->normalizedChi2());
352 hbheMuon.
dxyTracker_ = (fabs(recMuon->innerTrack()->dxy(pvx)));
353 hbheMuon.
dzTracker_ = (fabs(recMuon->innerTrack()->dz(pvx)));
357 hbheMuon.
tightPixelHits_ = (recMuon->innerTrack()->hitPattern().numberOfValidPixelHits());
361 if (recMuon->outerTrack().isNonnull()) {
366 hbheMuon.
outerTrackChi_ = (recMuon->outerTrack()->normalizedChi2());
367 hbheMuon.
outerTrackHits_ = (recMuon->outerTrack()->numberOfValidHits());
371 if (recMuon->globalTrack().isNonnull()) {
373 hbheMuon.
chiGlobal_ = (recMuon->globalTrack()->normalizedChi2());
374 hbheMuon.
globalMuonHits_ = (recMuon->globalTrack()->hitPattern().numberOfValidMuonHits());
375 hbheMuon.
matchedStat_ = (recMuon->numberOfMatchedStations());
380 hbheMuon.
tightLongPara_ = (fabs(recMuon->muonBestTrack()->dz(pvx)));
384 ((recMuon->pfIsolationR04().sumChargedHadronPt +
386 recMuon->pfIsolationR04().sumNeutralHadronEt + recMuon->pfIsolationR04().sumPhotonEt -
387 (0.5 * recMuon->pfIsolationR04().sumPUPt))) /
391 ((recMuon->pfIsolationR03().sumChargedHadronPt +
393 recMuon->pfIsolationR03().sumNeutralHadronEt + recMuon->pfIsolationR03().sumPhotonEt -
394 (0.5 * recMuon->pfIsolationR03().sumPUPt))) /
397 hbheMuon.
ecalEnergy_ = (recMuon->calEnergy().emS9);
398 hbheMuon.
hcalEnergy_ = (recMuon->calEnergy().hadS9);
399 hbheMuon.
hoEnergy_ = (recMuon->calEnergy().hoS9);
401 if (recMuon->innerTrack().isNonnull()) {
402 const reco::Track* pTrack = (recMuon->innerTrack()).
get();
405 double activeLengthTot(0), activeLengthHotTot(0);
418 unsigned int isHot(0);
421 eHcalDepth[
i] = eHcalDepthHot[
i] = 0;
422 eHcalDepthC[
i] = eHcalDepthHotC[
i] = 0;
423 cHcalDepthHot[
i] = cHcalDepthHotBG[
i] = 0;
424 eHcalDepthRaw[
i] = eHcalDepthHotRaw[
i] = 0;
425 eHcalDepthCRaw[
i] = eHcalDepthHotCRaw[
i] = 0;
426 cHcalDepthHotRaw[
i] = cHcalDepthHotBGRaw[
i] = 0;
427 eHcalDepthAux[
i] = eHcalDepthHotAux[
i] = 0;
428 eHcalDepthCAux[
i] = eHcalDepthHotCAux[
i] = 0;
429 cHcalDepthHotAux[
i] = cHcalDepthHotBGAux[
i] = 0;
430 activeL[
i] = activeHotL[
i] = 0;
431 matchDepth[
i] = matchDepthHot[
i] =
true;
447 bool okE = trackID.
okECAL;
475 if ((hcidt.ieta() ==
check.ieta()) && (hcidt.iphi() ==
check.iphi()))
487 theHBHETopology, closestCell,
hbhe, 0, 0,
false,
true, -100.0, -100.0, -100.0, -100.0, -500., 500., 0);
489 theHBHETopology, closestCell,
hbhe, 0, 0,
false,
true, -100.0, -100.0, -100.0, -100.0, -500., 500., 1);
491 theHBHETopology, closestCell,
hbhe, 0, 0,
false,
true, -100.0, -100.0, -100.0, -100.0, -500., 500., 2);
492 std::vector<std::pair<double, int>> ehdepth, ehdepthAux, ehdepthRaw;
534 for (
unsigned int i = 0;
i < ehdepth.size(); ++
i) {
540 double ene = ehdepth[
i].first;
541 double eneAux = ehdepthAux[
i].first;
542 double eneRaw = ehdepthRaw[
i].first;
545 if (!(theHBHETopology->
validHcal(hcid0))) {
546 edm::LogWarning(
"HBHEMuon") <<
"(1) Invalid ID " << hcid0 <<
" with E = " << ene;
548 for (
const auto& ehd : ehdepth)
560 int depth = ehdepth[
i].second - 1;
563 depth =
id.depth() - 1;
565 eHcalDepth[
depth] += ene;
566 eHcalDepthC[
depth] += enec;
567 activeL[
depth] += actL;
568 activeLengthTot += actL;
569 matchDepth[
depth] = (matchDepth[
depth] && tmpC);
573 << hcid0 <<
" E " << ene <<
":" << enec <<
" L " << actL <<
" Match " << tmpC;
579 double enecAux(eneAux);
583 int depth = ehdepthAux[
i].second - 1;
586 depth =
id.depth() - 1;
588 eHcalDepthAux[
depth] += eneAux;
589 eHcalDepthCAux[
depth] += enecAux;
593 << hcid0 <<
" E " << eneAux <<
":" << enecAux <<
" L " << actL <<
" Match " << tmpC;
599 double enecRaw(eneRaw);
603 int depth = ehdepthRaw[
i].second - 1;
606 depth =
id.depth() - 1;
608 eHcalDepthRaw[
depth] += eneRaw;
609 eHcalDepthCRaw[
depth] += enecRaw;
613 << hcid0 <<
" E " << eneRaw <<
":" << enecRaw <<
" L " << actL <<
" Match " << tmpC;
621 for (
unsigned int k = 0;
k < ehdepth.size(); ++
k)
622 edm::LogVerbatim(
"HBHEMuon") <<
" [" <<
k <<
":" << ehdepth[
k].second <<
"] " << matchDepth[
k];
627 isHot =
matchId(closestCell, hotCell);
633 std::vector<std::pair<double, int>> ehdepth, ehdepthAux, ehdepthRaw;
675 for (
unsigned int i = 0;
i < ehdepth.size(); ++
i) {
681 double ene = ehdepth[
i].first;
684 if (!(theHBHETopology->
validHcal(hcid0))) {
685 edm::LogWarning(
"HBHEMuon") <<
"(2) Invalid ID " << hcid0 <<
" with E = " << ene;
687 for (
const auto& ehd : ehdepth)
691 double chg(ene), enec(ene);
697 edm::LogVerbatim(
"HBHEMuon") << hcid0 <<
":" <<
id <<
" Corr " <<
corr <<
" E " << ene <<
":" << enec;
705 int depth = ehdepth[
i].second - 1;
708 depth =
id.depth() - 1;
710 eHcalDepthHot[
depth] += ene;
711 eHcalDepthHotC[
depth] += enec;
713 activeHotL[
depth] += actL;
714 activeLengthHotTot += actL;
715 matchDepthHot[
depth] = (matchDepthHot[
depth] && tmpC);
720 <<
chg <<
" L " << actL <<
" Match " << tmpC;
724 double eneAux = ehdepthAux[
i].first;
727 double chgAux(eneAux), enecAux(eneAux);
734 int depth = ehdepthAux[
i].second - 1;
737 depth =
id.depth() - 1;
739 eHcalDepthHotAux[
depth] += eneAux;
740 eHcalDepthHotCAux[
depth] += enecAux;
741 cHcalDepthHotAux[
depth] += chgAux;
745 <<
" C " << chgAux <<
" L " << actL <<
" Match " << tmpC;
749 double eneRaw = ehdepthRaw[
i].first;
752 double chgRaw(eneRaw), enecRaw(eneRaw);
759 int depth = ehdepthRaw[
i].second - 1;
762 depth =
id.depth() - 1;
764 eHcalDepthHotRaw[
depth] += eneRaw;
765 eHcalDepthHotCRaw[
depth] += enecRaw;
766 cHcalDepthHotRaw[
depth] += chgRaw;
770 <<
" C " << chgRaw <<
" L " << actL <<
" Match " << tmpC;
777 std::vector<std::pair<double, int>> ehdeptho, ehdepthoAux, ehdepthoRaw;
817 for (
unsigned int i = 0;
i < ehdeptho.size(); ++
i) {
822 double ene = ehdeptho[
i].first;
824 if (!(theHBHETopology->
validHcal(hcid0))) {
825 edm::LogWarning(
"HBHEMuon") <<
"(3) Invalid ID " << hcid0 <<
" with E = " << ene;
826 edm::LogWarning(
"HBHEMuon") << oppCell <<
" with " << ehdeptho.size() <<
" depths:";
827 for (
const auto& ehd : ehdeptho)
837 << hcid0 <<
":" <<
id <<
" Corr " <<
corr <<
" E " << ene <<
":" << ehdeptho[
i].first;
845 int depth = ehdeptho[
i].second - 1;
848 depth =
id.depth() - 1;
857 double eneAux = ehdepthoAux[
i].first;
860 double chgAux(eneAux);
867 int depth = ehdepthoAux[
i].second - 1;
870 depth =
id.depth() - 1;
872 cHcalDepthHotBGAux[
depth] += chgAux;
879 double eneRaw = ehdepthoRaw[
i].first;
882 double chgRaw(eneRaw);
889 int depth = ehdepthoRaw[
i].second - 1;
892 depth =
id.depth() - 1;
894 cHcalDepthHotBGRaw[
depth] += chgRaw;
906 << hbheMuon.
matchedId_ <<
" Hot " << isHot <<
" Energy " << eHcal;
938 if ((recMuon->p() > 10.0) && (trackID.
okHCAL))
939 outputHcalHBHEMuonColl->emplace_back(hbheMuon);
943 if (!outputHcalHBHEMuonColl->empty())
Log< level::Info, true > LogVerbatim
float muonChi2LocalPosition_
const bool collapseDepth_
std::vector< spr::propagatedTrackID > propagateCALO(edm::Handle< reco::TrackCollection > &trkCollection, const CaloGeometry *geo, const MagneticField *bField, const std::string &theTrackQuality, bool debug=false)
int depth16HE(int ieta, int iphi, const HcalTopology *theHBHETopology)
const edm::EDGetTokenT< EcalRecHitCollection > tok_EB_
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > tok_magField_
bool goodCell(const HcalDetId &hcid, const reco::Track *pTrack, const CaloGeometry *geo, const MagneticField *bField, const HcalDDDRecConstants *hdc)
HcalDetId mergedDepthDetId(const HcalDetId &id) const
bool isMediumMuon(const reco::Muon &, bool run2016_hip_mitigation=false)
float tightValidFraction_
const edm::ESGetToken< HcalDbService, HcalDbRecord > tok_dbservice_
std::vector< float > hcalDepthEnergyCorrRaw_
std::vector< float > hcalDepthEnergyRaw_
std::vector< float > hcalDepthEnergy_
std::vector< float > hcalDepthEnergyHotRaw_
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > tok_geom1_
std::vector< float > hcalDepthChargeHotRaw_
std::vector< bool > hcalDepthMatchHot_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::vector< float > hcalDepthChargeHotBGRaw_
std::vector< float > hcalDepthEnergyHotAux_
std::vector< float > hcalDepthEnergyHotCorr_
const edm::EDGetTokenT< reco::MuonCollection > tok_Muon_
const edm::ESGetToken< EcalSeverityLevelAlgo, EcalSeverityLevelAlgoRcd > tok_sevlv_
U second(std::pair< T, U > const &p)
const bool isItPreRecHit_
constexpr HcalSubdetector subdet() const
get the subdetector
bool isGoodVertex(const reco::Vertex &vtx)
double activeLength(const DetId &, const HcalDDDRecConstants *hdc)
const std::vector< std::string > trigNames_
spr::propagatedTrackDirection propagateHCALBack(unsigned int thisTrk, edm::Handle< edm::SimTrackContainer > &SimTk, edm::Handle< edm::SimVertexContainer > &SimVtx, const CaloGeometry *geo, const MagneticField *bField, bool debug=false)
double respCorr(const DetId &id, const HcalRespCorrs *respCorrs)
constexpr int ieta() const
get the cell ieta
float hcalActiveLengthHot_
const edm::ESGetToken< EcalChannelStatus, EcalChannelStatusRcd > tok_chan_
const std::string labelHBHEMuon_
std::vector< float > hcalDepthChargeHotAux_
std::vector< float > hcalDepthEnergyHot_
const edm::ESGetToken< HcalDDDRecConstants, HcalRecNumberingRecord > tok_ddrec1_
Abs< T >::type abs(const T &t)
static const int depthMax_
float segmentCompatibility(const reco::Muon &muon, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
std::vector< float > hcalDepthEnergyCorr_
bool getData(T &iHolder) const
std::vector< float > hcalDepthActiveLength_
static std::string const triggerResults
const edm::ESGetToken< HcalTopology, HcalRecNumberingRecord > tok_htopo1_
std::vector< float > hcalDepthEnergyAux_
std::vector< float > hcalDepthEnergyHotCorrRaw_
std::vector< float > hcalDepthChargeHotBG_
XYZPointD XYZPoint
point in space with cartesian internal representation
const edm::ESGetToken< CaloTopology, CaloTopologyRecord > tok_topo_
unsigned int eventNumber_
bool validHcal(const HcalDetId &id) const
const edm::ESGetToken< HcalRespCorrs, HcalRespCorrsRcd > tok_respcorr1_
std::vector< float > hcalDepthChargeHot_
const edm::EDGetTokenT< edm::TriggerResults > tok_trigRes_
std::vector< float > hcalDepthEnergyCorrAux_
std::vector< bool > hcalDepthMatch_
double gainFactor(const HcalDbService *dbserv, const HcalDetId &id)
const edm::EDGetTokenT< reco::VertexCollection > tok_Vtx_
int matchId(const HcalDetId &, const HcalDetId &)
std::vector< float > hcalDepthEnergyHotCorrAux_
Log< level::Warning, false > LogWarning
bool isTightMuon(const reco::Muon &, const reco::Vertex &)
std::vector< float > hcalDepthActiveLengthHot_
void energyHCALCell(HcalDetId detId, edm::Handle< T > &hits, std::vector< std::pair< double, int > > &energyCell, int maxDepth=1, double hbThr=-100, double heThr=-100, double hfThr=-100, double hoThr=-100, double tMin=-500, double tMax=500, int useRaw=0, int depthHE=3, bool debug=false)
constexpr int iphi() const
get the cell iphi
void setTopo(const HcalTopology *topo)
const edm::EDGetTokenT< HBHERecHitCollection > tok_HBHE_
std::vector< float > hcalDepthChargeHotBGAux_
double eECALmatrix(const DetId &detId, edm::Handle< T > &hitsEB, edm::Handle< T > &hitsEE, const CaloGeometry *geo, const CaloTopology *caloTopology, int ieta, int iphi, double ebThr=-100, double eeThr=-100, double tMin=-500, double tMax=500, bool debug=false)
double eHCALmatrix(const HcalTopology *topology, const DetId &det, edm::Handle< T > &hits, int ieta, int iphi, bool includeHO=false, bool algoNew=true, double hbThr=-100, double heThr=-100, double hfThr=-100, double hoThr=-100, double tMin=-500, double tMax=500, int useRaw=0, bool debug=false)
const edm::EDGetTokenT< EcalRecHitCollection > tok_EE_