235 auto outputHcalHBHEMuonColl = std::make_unique<HcalHBHEMuonVariablesCollection>();
238 unsigned int eventNumber =
iEvent.id().event();
239 unsigned int lumiNumber =
iEvent.id().luminosityBlock();
240 unsigned int bxNumber =
iEvent.bunchCrossing();
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;
286 respCorrs->
setTopo(theHBHETopology);
297 unsigned int goodVertex = 0;
298 reco::VertexCollection::const_iterator firstGoodVertex;
299 if (!
vtx.isValid()) {
304 firstGoodVertex =
vtx->end();
305 for (reco::VertexCollection::const_iterator it =
vtx->begin(); it !=
vtx->end(); it++) {
307 if (firstGoodVertex ==
vtx->end())
308 firstGoodVertex = it;
312 if (firstGoodVertex !=
vtx->end())
313 pvx = firstGoodVertex->position();
316 if (
ok && (goodVertex > 0) &&
muons.isValid() && barrelRecHitsHandle.isValid() && endcapRecHitsHandle.isValid() &&
318 for (reco::MuonCollection::const_iterator recMuon =
muons->begin(); recMuon !=
muons->end(); ++recMuon) {
325 hbheMuon.
muonGood_ = (recMuon->isPFMuon());
329 hbheMuon.
etaGlob_ = (recMuon->eta());
330 hbheMuon.
phiGlob_ = (recMuon->phi());
332 hbheMuon.
pMuon_ = (recMuon->p());
334 edm::LogVerbatim(
"HBHEMuon") <<
"Energy:" << recMuon->energy() <<
" P:" << recMuon->p();
338 hbheMuon.
muonTrkKink_ = (recMuon->combinedQuality().trkKink);
342 if (recMuon->track().isNonnull()) {
343 hbheMuon.
trackerLayer_ = (recMuon->track()->hitPattern().trackerLayersWithMeasurement());
347 if (recMuon->innerTrack().isNonnull()) {
349 hbheMuon.
numPixelLayers_ = (recMuon->innerTrack()->hitPattern().pixelLayersWithMeasurement());
350 hbheMuon.
chiTracker_ = (recMuon->innerTrack()->normalizedChi2());
351 hbheMuon.
dxyTracker_ = (fabs(recMuon->innerTrack()->dxy(pvx)));
352 hbheMuon.
dzTracker_ = (fabs(recMuon->innerTrack()->dz(pvx)));
356 hbheMuon.
tightPixelHits_ = (recMuon->innerTrack()->hitPattern().numberOfValidPixelHits());
360 if (recMuon->outerTrack().isNonnull()) {
365 hbheMuon.
outerTrackChi_ = (recMuon->outerTrack()->normalizedChi2());
366 hbheMuon.
outerTrackHits_ = (recMuon->outerTrack()->numberOfValidHits());
370 if (recMuon->globalTrack().isNonnull()) {
372 hbheMuon.
chiGlobal_ = (recMuon->globalTrack()->normalizedChi2());
373 hbheMuon.
globalMuonHits_ = (recMuon->globalTrack()->hitPattern().numberOfValidMuonHits());
374 hbheMuon.
matchedStat_ = (recMuon->numberOfMatchedStations());
379 hbheMuon.
tightLongPara_ = (fabs(recMuon->muonBestTrack()->dz(pvx)));
383 ((recMuon->pfIsolationR04().sumChargedHadronPt +
385 recMuon->pfIsolationR04().sumNeutralHadronEt + recMuon->pfIsolationR04().sumPhotonEt -
386 (0.5 * recMuon->pfIsolationR04().sumPUPt))) /
390 ((recMuon->pfIsolationR03().sumChargedHadronPt +
392 recMuon->pfIsolationR03().sumNeutralHadronEt + recMuon->pfIsolationR03().sumPhotonEt -
393 (0.5 * recMuon->pfIsolationR03().sumPUPt))) /
396 hbheMuon.
ecalEnergy_ = (recMuon->calEnergy().emS9);
397 hbheMuon.
hcalEnergy_ = (recMuon->calEnergy().hadS9);
398 hbheMuon.
hoEnergy_ = (recMuon->calEnergy().hoS9);
400 if (recMuon->innerTrack().isNonnull()) {
401 const reco::Track* pTrack = (recMuon->innerTrack()).
get();
404 double activeLengthTot(0), activeLengthHotTot(0);
417 unsigned int isHot(0);
420 eHcalDepth[
i] = eHcalDepthHot[
i] = 0;
421 eHcalDepthC[
i] = eHcalDepthHotC[
i] = 0;
422 cHcalDepthHot[
i] = cHcalDepthHotBG[
i] = 0;
423 eHcalDepthRaw[
i] = eHcalDepthHotRaw[
i] = 0;
424 eHcalDepthCRaw[
i] = eHcalDepthHotCRaw[
i] = 0;
425 cHcalDepthHotRaw[
i] = cHcalDepthHotBGRaw[
i] = 0;
426 eHcalDepthAux[
i] = eHcalDepthHotAux[
i] = 0;
427 eHcalDepthCAux[
i] = eHcalDepthHotCAux[
i] = 0;
428 cHcalDepthHotAux[
i] = cHcalDepthHotBGAux[
i] = 0;
429 activeL[
i] = activeHotL[
i] = 0;
430 matchDepth[
i] = matchDepthHot[
i] =
true;
446 bool okE = trackID.
okECAL;
474 if ((hcidt.ieta() ==
check.ieta()) && (hcidt.iphi() ==
check.iphi()))
486 theHBHETopology, closestCell,
hbhe, 0, 0,
false,
true, -100.0, -100.0, -100.0, -100.0, -500., 500., 0);
488 theHBHETopology, closestCell,
hbhe, 0, 0,
false,
true, -100.0, -100.0, -100.0, -100.0, -500., 500., 1);
490 theHBHETopology, closestCell,
hbhe, 0, 0,
false,
true, -100.0, -100.0, -100.0, -100.0, -500., 500., 2);
491 std::vector<std::pair<double, int>> ehdepth, ehdepthAux, ehdepthRaw;
533 for (
unsigned int i = 0;
i < ehdepth.size(); ++
i) {
539 double ene = ehdepth[
i].first;
540 double eneAux = ehdepthAux[
i].first;
541 double eneRaw = ehdepthRaw[
i].first;
544 if (!(theHBHETopology->
validHcal(hcid0))) {
545 edm::LogWarning(
"HBHEMuon") <<
"(1) Invalid ID " << hcid0 <<
" with E = " << ene;
547 for (
const auto& ehd : ehdepth)
559 int depth = ehdepth[
i].second - 1;
562 depth =
id.depth() - 1;
564 eHcalDepth[
depth] += ene;
565 eHcalDepthC[
depth] += enec;
566 activeL[
depth] += actL;
567 activeLengthTot += actL;
568 matchDepth[
depth] = (matchDepth[
depth] && tmpC);
572 << hcid0 <<
" E " << ene <<
":" << enec <<
" L " << actL <<
" Match " << tmpC;
578 double enecAux(eneAux);
582 int depth = ehdepthAux[
i].second - 1;
585 depth =
id.depth() - 1;
587 eHcalDepthAux[
depth] += eneAux;
588 eHcalDepthCAux[
depth] += enecAux;
592 << hcid0 <<
" E " << eneAux <<
":" << enecAux <<
" L " << actL <<
" Match " << tmpC;
598 double enecRaw(eneRaw);
602 int depth = ehdepthRaw[
i].second - 1;
605 depth =
id.depth() - 1;
607 eHcalDepthRaw[
depth] += eneRaw;
608 eHcalDepthCRaw[
depth] += enecRaw;
612 << hcid0 <<
" E " << eneRaw <<
":" << enecRaw <<
" L " << actL <<
" Match " << tmpC;
620 for (
unsigned int k = 0;
k < ehdepth.size(); ++
k)
621 edm::LogVerbatim(
"HBHEMuon") <<
" [" <<
k <<
":" << ehdepth[
k].second <<
"] " << matchDepth[
k];
626 isHot =
matchId(closestCell, hotCell);
632 std::vector<std::pair<double, int>> ehdepth, ehdepthAux, ehdepthRaw;
674 for (
unsigned int i = 0;
i < ehdepth.size(); ++
i) {
680 double ene = ehdepth[
i].first;
683 if (!(theHBHETopology->
validHcal(hcid0))) {
684 edm::LogWarning(
"HBHEMuon") <<
"(2) Invalid ID " << hcid0 <<
" with E = " << ene;
686 for (
const auto& ehd : ehdepth)
690 double chg(ene), enec(ene);
696 edm::LogVerbatim(
"HBHEMuon") << hcid0 <<
":" <<
id <<
" Corr " <<
corr <<
" E " << ene <<
":" << enec;
704 int depth = ehdepth[
i].second - 1;
707 depth =
id.depth() - 1;
709 eHcalDepthHot[
depth] += ene;
710 eHcalDepthHotC[
depth] += enec;
712 activeHotL[
depth] += actL;
713 activeLengthHotTot += actL;
714 matchDepthHot[
depth] = (matchDepthHot[
depth] && tmpC);
719 <<
chg <<
" L " << actL <<
" Match " << tmpC;
723 double eneAux = ehdepthAux[
i].first;
726 double chgAux(eneAux), enecAux(eneAux);
733 int depth = ehdepthAux[
i].second - 1;
736 depth =
id.depth() - 1;
738 eHcalDepthHotAux[
depth] += eneAux;
739 eHcalDepthHotCAux[
depth] += enecAux;
740 cHcalDepthHotAux[
depth] += chgAux;
744 <<
" C " << chgAux <<
" L " << actL <<
" Match " << tmpC;
748 double eneRaw = ehdepthRaw[
i].first;
751 double chgRaw(eneRaw), enecRaw(eneRaw);
758 int depth = ehdepthRaw[
i].second - 1;
761 depth =
id.depth() - 1;
763 eHcalDepthHotRaw[
depth] += eneRaw;
764 eHcalDepthHotCRaw[
depth] += enecRaw;
765 cHcalDepthHotRaw[
depth] += chgRaw;
769 <<
" C " << chgRaw <<
" L " << actL <<
" Match " << tmpC;
776 std::vector<std::pair<double, int>> ehdeptho, ehdepthoAux, ehdepthoRaw;
816 for (
unsigned int i = 0;
i < ehdeptho.size(); ++
i) {
821 double ene = ehdeptho[
i].first;
823 if (!(theHBHETopology->
validHcal(hcid0))) {
824 edm::LogWarning(
"HBHEMuon") <<
"(3) Invalid ID " << hcid0 <<
" with E = " << ene;
825 edm::LogWarning(
"HBHEMuon") << oppCell <<
" with " << ehdeptho.size() <<
" depths:";
826 for (
const auto& ehd : ehdeptho)
836 << hcid0 <<
":" <<
id <<
" Corr " <<
corr <<
" E " << ene <<
":" << ehdeptho[
i].first;
844 int depth = ehdeptho[
i].second - 1;
847 depth =
id.depth() - 1;
856 double eneAux = ehdepthoAux[
i].first;
859 double chgAux(eneAux);
866 int depth = ehdepthoAux[
i].second - 1;
869 depth =
id.depth() - 1;
871 cHcalDepthHotBGAux[
depth] += chgAux;
878 double eneRaw = ehdepthoRaw[
i].first;
881 double chgRaw(eneRaw);
888 int depth = ehdepthoRaw[
i].second - 1;
891 depth =
id.depth() - 1;
893 cHcalDepthHotBGRaw[
depth] += chgRaw;
905 << hbheMuon.
matchedId_ <<
" Hot " << isHot <<
" Energy " << eHcal;
937 if ((recMuon->p() > 10.0) && (trackID.
okHCAL))
938 outputHcalHBHEMuonColl->emplace_back(hbheMuon);
942 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_