235 auto outputHcalHBHEMuonColl = std::make_unique<HcalHBHEMuonVariablesCollection>();
238 unsigned int eventNumber = iEvent.
id().
event();
242 edm::LogVerbatim(
"HBHEMuon") <<
"Run " << runNumber <<
" Event " << eventNumber <<
" Lumi " << lumiNumber <<
" BX "
243 << bxNumber << std::endl;
254 std::vector<std::string>
modules;
256 const std::vector<std::string>& triggerNames_ = triggerNames.
triggerNames();
257 for (
unsigned int iHLT = 0; iHLT <
triggerResults->size(); iHLT++) {
265 edm::LogVerbatim(
"HBHEMuon") <<
"AlCaHcalHBHEMuonFilter::Trigger " << triggerNames_[iHLT] <<
" Flag " << hlt
266 <<
":" <<
ok << std::endl;
285 respCorrs->
setTopo(theHBHETopology);
296 unsigned int goodVertex = 0;
297 reco::VertexCollection::const_iterator firstGoodVertex;
298 if (!vtx.isValid()) {
303 firstGoodVertex = vtx->end();
304 for (reco::VertexCollection::const_iterator it = vtx->begin(); it != vtx->end(); it++) {
306 if (firstGoodVertex == vtx->end())
307 firstGoodVertex = it;
311 if (firstGoodVertex != vtx->end())
312 pvx = firstGoodVertex->position();
315 if (
ok && (goodVertex > 0) &&
muons.isValid() && barrelRecHitsHandle.isValid() && endcapRecHitsHandle.isValid() &&
317 for (reco::MuonCollection::const_iterator recMuon =
muons->begin(); recMuon !=
muons->end(); ++recMuon) {
324 hbheMuon.
muonGood_ = (recMuon->isPFMuon());
328 hbheMuon.
etaGlob_ = (recMuon->eta());
329 hbheMuon.
phiGlob_ = (recMuon->phi());
331 hbheMuon.
pMuon_ = (recMuon->p());
333 edm::LogVerbatim(
"HBHEMuon") <<
"Energy:" << recMuon->energy() <<
" P:" << recMuon->p();
337 hbheMuon.
muonTrkKink_ = (recMuon->combinedQuality().trkKink);
341 if (recMuon->track().isNonnull()) {
342 hbheMuon.
trackerLayer_ = (recMuon->track()->hitPattern().trackerLayersWithMeasurement());
346 if (recMuon->innerTrack().isNonnull()) {
348 hbheMuon.
numPixelLayers_ = (recMuon->innerTrack()->hitPattern().pixelLayersWithMeasurement());
349 hbheMuon.
chiTracker_ = (recMuon->innerTrack()->normalizedChi2());
350 hbheMuon.
dxyTracker_ = (fabs(recMuon->innerTrack()->dxy(pvx)));
351 hbheMuon.
dzTracker_ = (fabs(recMuon->innerTrack()->dz(pvx)));
355 hbheMuon.
tightPixelHits_ = (recMuon->innerTrack()->hitPattern().numberOfValidPixelHits());
359 if (recMuon->outerTrack().isNonnull()) {
364 hbheMuon.
outerTrackChi_ = (recMuon->outerTrack()->normalizedChi2());
365 hbheMuon.
outerTrackHits_ = (recMuon->outerTrack()->numberOfValidHits());
369 if (recMuon->globalTrack().isNonnull()) {
371 hbheMuon.
chiGlobal_ = (recMuon->globalTrack()->normalizedChi2());
372 hbheMuon.
globalMuonHits_ = (recMuon->globalTrack()->hitPattern().numberOfValidMuonHits());
373 hbheMuon.
matchedStat_ = (recMuon->numberOfMatchedStations());
378 hbheMuon.
tightLongPara_ = (fabs(recMuon->muonBestTrack()->dz(pvx)));
382 ((recMuon->pfIsolationR04().sumChargedHadronPt +
384 recMuon->pfIsolationR04().sumNeutralHadronEt + recMuon->pfIsolationR04().sumPhotonEt -
385 (0.5 * recMuon->pfIsolationR04().sumPUPt))) /
389 ((recMuon->pfIsolationR03().sumChargedHadronPt +
391 recMuon->pfIsolationR03().sumNeutralHadronEt + recMuon->pfIsolationR03().sumPhotonEt -
392 (0.5 * recMuon->pfIsolationR03().sumPUPt))) /
395 hbheMuon.
ecalEnergy_ = (recMuon->calEnergy().emS9);
396 hbheMuon.
hcalEnergy_ = (recMuon->calEnergy().hadS9);
397 hbheMuon.
hoEnergy_ = (recMuon->calEnergy().hoS9);
399 if (recMuon->innerTrack().isNonnull()) {
400 const reco::Track* pTrack = (recMuon->innerTrack()).
get();
403 double activeLengthTot(0), activeLengthHotTot(0);
416 unsigned int isHot(0);
417 int ieta(-1000), iphi(-1000);
419 eHcalDepth[
i] = eHcalDepthHot[
i] = 0;
420 eHcalDepthC[
i] = eHcalDepthHotC[
i] = 0;
421 cHcalDepthHot[
i] = cHcalDepthHotBG[
i] = 0;
422 eHcalDepthRaw[
i] = eHcalDepthHotRaw[
i] = 0;
423 eHcalDepthCRaw[
i] = eHcalDepthHotCRaw[
i] = 0;
424 cHcalDepthHotRaw[
i] = cHcalDepthHotBGRaw[
i] = 0;
425 eHcalDepthAux[
i] = eHcalDepthHotAux[
i] = 0;
426 eHcalDepthCAux[
i] = eHcalDepthHotCAux[
i] = 0;
427 cHcalDepthHotAux[
i] = cHcalDepthHotBGAux[
i] = 0;
428 activeL[
i] = activeHotL[
i] = 0;
429 matchDepth[
i] = matchDepthHot[
i] =
true;
445 bool okE = trackID.
okECAL;
473 if ((hcidt.ieta() ==
check.ieta()) && (hcidt.iphi() ==
check.iphi()))
476 edm::LogVerbatim(
"HBHEMuon") <<
"Front " << hcidt <<
" Back " << info.first <<
":" <<
check <<
" Match "
482 bool hborhe = (
std::abs(ieta) == 16);
485 theHBHETopology, closestCell, hbhe, 0, 0,
false,
true, -100.0, -100.0, -100.0, -100.0, -500., 500., 0);
487 theHBHETopology, closestCell, hbhe, 0, 0,
false,
true, -100.0, -100.0, -100.0, -100.0, -500., 500., 1);
489 theHBHETopology, closestCell, hbhe, 0, 0,
false,
true, -100.0, -100.0, -100.0, -100.0, -500., 500., 2);
490 std::vector<std::pair<double, int>> ehdepth, ehdepthAux, ehdepthRaw;
532 for (
unsigned int i = 0;
i < ehdepth.size(); ++
i) {
538 double ene = ehdepth[
i].first;
539 double eneAux = ehdepthAux[
i].first;
540 double eneRaw = ehdepthRaw[
i].first;
543 if (!(theHBHETopology->
validHcal(hcid0))) {
544 edm::LogWarning(
"HBHEMuon") <<
"(1) Invalid ID " << hcid0 <<
" with E = " << ene;
546 for (
const auto& ehd : ehdepth)
549 tmpC =
goodCell(hcid0, pTrack, geo, bField, hdc);
558 int depth = ehdepth[
i].second - 1;
561 depth =
id.
depth() - 1;
563 eHcalDepth[
depth] += ene;
564 eHcalDepthC[
depth] += enec;
565 activeL[
depth] += actL;
566 activeLengthTot += actL;
567 matchDepth[
depth] = (matchDepth[
depth] && tmpC);
571 << hcid0 <<
" E " << ene <<
":" << enec <<
" L " << actL <<
" Match " << tmpC;
577 double enecAux(eneAux);
581 int depth = ehdepthAux[
i].second - 1;
584 depth =
id.
depth() - 1;
586 eHcalDepthAux[
depth] += eneAux;
587 eHcalDepthCAux[
depth] += enecAux;
591 << hcid0 <<
" E " << eneAux <<
":" << enecAux <<
" L " << actL <<
" Match " << tmpC;
597 double enecRaw(eneRaw);
601 int depth = ehdepthRaw[
i].second - 1;
604 depth =
id.
depth() - 1;
606 eHcalDepthRaw[
depth] += eneRaw;
607 eHcalDepthCRaw[
depth] += enecRaw;
611 << hcid0 <<
" E " << eneRaw <<
":" << enecRaw <<
" L " << actL <<
" Match " << tmpC;
619 for (
unsigned int k = 0;
k < ehdepth.size(); ++
k)
620 edm::LogVerbatim(
"HBHEMuon") <<
" [" <<
k <<
":" << ehdepth[
k].second <<
"] " << matchDepth[
k];
624 spr::eHCALmatrix(geo, theHBHETopology, closestCell, hbhe, 1, 1, hotCell,
false, 0,
false);
625 isHot =
matchId(closestCell, hotCell);
631 std::vector<std::pair<double, int>> ehdepth, ehdepthAux, ehdepthRaw;
673 for (
unsigned int i = 0;
i < ehdepth.size(); ++
i) {
679 double ene = ehdepth[
i].first;
682 if (!(theHBHETopology->
validHcal(hcid0))) {
683 edm::LogWarning(
"HBHEMuon") <<
"(2) Invalid ID " << hcid0 <<
" with E = " << ene;
685 for (
const auto& ehd : ehdepth)
688 tmpC =
goodCell(hcid0, pTrack, geo, bField, hdc);
689 double chg(ene), enec(ene);
695 edm::LogVerbatim(
"HBHEMuon") << hcid0 <<
":" <<
id <<
" Corr " << corr <<
" E " << ene <<
":" << enec;
703 int depth = ehdepth[
i].second - 1;
706 depth =
id.
depth() - 1;
708 eHcalDepthHot[
depth] += ene;
709 eHcalDepthHotC[
depth] += enec;
711 activeHotL[
depth] += actL;
712 activeLengthHotTot += actL;
713 matchDepthHot[
depth] = (matchDepthHot[
depth] && tmpC);
717 edm::LogVerbatim(
"HBHEMuon") << hcid0 <<
" depth " << depth <<
" E " << ene <<
":" << enec <<
" C "
718 << chg <<
" L " << actL <<
" Match " << tmpC;
722 double eneAux = ehdepthAux[
i].first;
725 double chgAux(eneAux), enecAux(eneAux);
732 int depth = ehdepthAux[
i].second - 1;
735 depth =
id.
depth() - 1;
737 eHcalDepthHotAux[
depth] += eneAux;
738 eHcalDepthHotCAux[
depth] += enecAux;
739 cHcalDepthHotAux[
depth] += chgAux;
742 edm::LogVerbatim(
"HBHEMuon") << hcid0 <<
" depth " << depth <<
" E " << eneAux <<
":" << enecAux
743 <<
" C " << chgAux <<
" L " << actL <<
" Match " << tmpC;
747 double eneRaw = ehdepthRaw[
i].first;
750 double chgRaw(eneRaw), enecRaw(eneRaw);
757 int depth = ehdepthRaw[
i].second - 1;
760 depth =
id.
depth() - 1;
762 eHcalDepthHotRaw[
depth] += eneRaw;
763 eHcalDepthHotCRaw[
depth] += enecRaw;
764 cHcalDepthHotRaw[
depth] += chgRaw;
767 edm::LogVerbatim(
"HBHEMuon") << hcid0 <<
" depth " << depth <<
" E " << eneRaw <<
":" << enecRaw
768 <<
" C " << chgRaw <<
" L " << actL <<
" Match " << tmpC;
775 std::vector<std::pair<double, int>> ehdeptho, ehdepthoAux, ehdepthoRaw;
815 for (
unsigned int i = 0;
i < ehdeptho.size(); ++
i) {
820 double ene = ehdeptho[
i].first;
822 if (!(theHBHETopology->
validHcal(hcid0))) {
823 edm::LogWarning(
"HBHEMuon") <<
"(3) Invalid ID " << hcid0 <<
" with E = " << ene;
824 edm::LogWarning(
"HBHEMuon") << oppCell <<
" with " << ehdeptho.size() <<
" depths:";
825 for (
const auto& ehd : ehdeptho)
835 << hcid0 <<
":" <<
id <<
" Corr " << corr <<
" E " << ene <<
":" << ehdeptho[
i].first;
843 int depth = ehdeptho[
i].second - 1;
846 depth =
id.
depth() - 1;
851 edm::LogVerbatim(
"HBHEMuon") << hcid0 <<
" Depth " << depth <<
" E " << ene <<
" C " <<
chg;
855 double eneAux = ehdepthoAux[
i].first;
858 double chgAux(eneAux);
865 int depth = ehdepthoAux[
i].second - 1;
868 depth =
id.
depth() - 1;
870 cHcalDepthHotBGAux[
depth] += chgAux;
873 edm::LogVerbatim(
"HBHEMuon") << hcid0 <<
" Depth " << depth <<
" E " << eneAux <<
" C " << chgAux;
877 double eneRaw = ehdepthoRaw[
i].first;
880 double chgRaw(eneRaw);
887 int depth = ehdepthoRaw[
i].second - 1;
890 depth =
id.
depth() - 1;
892 cHcalDepthHotBGRaw[
depth] += chgRaw;
895 edm::LogVerbatim(
"HBHEMuon") << hcid0 <<
" Depth " << depth <<
" E " << eneRaw <<
" C " << chgRaw;
904 << hbheMuon.
matchedId_ <<
" Hot " << isHot <<
" Energy " << eHcal;
936 if ((recMuon->p() > 10.0) && (trackID.
okHCAL))
937 outputHcalHBHEMuonColl->emplace_back(hbheMuon);
941 if (!outputHcalHBHEMuonColl->empty())
Log< level::Info, true > LogVerbatim
float muonChi2LocalPosition_
EventNumber_t event() const
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)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
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)
bool isMediumMuon(const reco::Muon &, bool run2016_hip_mitigation=false)
float tightValidFraction_
const edm::ESGetToken< HcalDbService, HcalDbRecord > tok_dbservice_
HcalDetId mergedDepthDetId(const HcalDetId &id) const
std::vector< float > hcalDepthEnergyCorrRaw_
std::vector< float > hcalDepthEnergyRaw_
std::vector< float > hcalDepthEnergy_
std::vector< float > hcalDepthEnergyHotRaw_
int bunchCrossing() const
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > tok_geom1_
std::vector< float > hcalDepthChargeHotRaw_
std::vector< bool > hcalDepthMatchHot_
bool validHcal(const HcalDetId &id) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
LuminosityBlockNumber_t luminosityBlock() const
std::vector< float > hcalDepthChargeHotBGRaw_
Strings const & triggerNames() const
std::vector< float > hcalDepthEnergyHotAux_
std::vector< float > hcalDepthEnergyHotCorr_
const edm::EDGetTokenT< reco::MuonCollection > tok_Muon_
edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const override
const edm::ESGetToken< EcalSeverityLevelAlgo, EcalSeverityLevelAlgoRcd > tok_sevlv_
bool getData(T &iHolder) const
U second(std::pair< T, U > const &p)
const bool isItPreRecHit_
constexpr HcalSubdetector subdet() const
get the subdetector
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
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)
constexpr int iphi() const
get the cell iphi
double respCorr(const DetId &id, const HcalRespCorrs *respCorrs)
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)
constexpr int ieta() const
get the cell ieta
static const int depthMax_
float segmentCompatibility(const reco::Muon &muon, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
std::vector< float > hcalDepthEnergyCorr_
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_
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 &)
constexpr int depth() const
get the tower depth
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)
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_