241 auto outputHcalHBHEMuonColl = std::make_unique<HcalHBHEMuonVariablesCollection>();
244 unsigned int eventNumber =
iEvent.id().event();
245 unsigned int lumiNumber =
iEvent.id().luminosityBlock();
246 unsigned int bxNumber =
iEvent.bunchCrossing();
249 << bxNumber << std::endl;
260 std::vector<std::string>
modules;
262 const std::vector<std::string>& triggerNames_ =
triggerNames.triggerNames();
263 for (
unsigned int iHLT = 0; iHLT <
triggerResults->size(); iHLT++) {
271 edm::LogVerbatim(
"HBHEMuon") <<
"AlCaHcalHBHEMuonFilter::Trigger " << triggerNames_[iHLT] <<
" Flag " <<
hlt 272 <<
":" <<
ok << std::endl;
292 respCorrs->
setTopo(theHBHETopology);
305 unsigned int goodVertex = 0;
306 reco::VertexCollection::const_iterator firstGoodVertex;
307 if (!
vtx.isValid()) {
312 firstGoodVertex =
vtx->end();
313 for (reco::VertexCollection::const_iterator
it =
vtx->begin();
it !=
vtx->end();
it++) {
315 if (firstGoodVertex ==
vtx->end())
316 firstGoodVertex =
it;
320 if (firstGoodVertex !=
vtx->end())
321 pvx = firstGoodVertex->position();
324 if (
ok && (goodVertex > 0) &&
muons.isValid() && barrelRecHitsHandle.isValid() && endcapRecHitsHandle.isValid() &&
326 for (reco::MuonCollection::const_iterator recMuon =
muons->begin(); recMuon !=
muons->end(); ++recMuon) {
333 hbheMuon.
muonGood_ = (recMuon->isPFMuon());
337 hbheMuon.
etaGlob_ = (recMuon->eta());
338 hbheMuon.
phiGlob_ = (recMuon->phi());
340 hbheMuon.
pMuon_ = (recMuon->p());
342 edm::LogVerbatim(
"HBHEMuon") <<
"Energy:" << recMuon->energy() <<
" P:" << recMuon->p();
346 hbheMuon.
muonTrkKink_ = (recMuon->combinedQuality().trkKink);
350 if (recMuon->track().isNonnull()) {
351 hbheMuon.
trackerLayer_ = (recMuon->track()->hitPattern().trackerLayersWithMeasurement());
355 if (recMuon->innerTrack().isNonnull()) {
357 hbheMuon.
numPixelLayers_ = (recMuon->innerTrack()->hitPattern().pixelLayersWithMeasurement());
358 hbheMuon.
chiTracker_ = (recMuon->innerTrack()->normalizedChi2());
359 hbheMuon.
dxyTracker_ = (fabs(recMuon->innerTrack()->dxy(pvx)));
360 hbheMuon.
dzTracker_ = (fabs(recMuon->innerTrack()->dz(pvx)));
364 hbheMuon.
tightPixelHits_ = (recMuon->innerTrack()->hitPattern().numberOfValidPixelHits());
368 if (recMuon->outerTrack().isNonnull()) {
373 hbheMuon.
outerTrackChi_ = (recMuon->outerTrack()->normalizedChi2());
374 hbheMuon.
outerTrackHits_ = (recMuon->outerTrack()->numberOfValidHits());
378 if (recMuon->globalTrack().isNonnull()) {
380 hbheMuon.
chiGlobal_ = (recMuon->globalTrack()->normalizedChi2());
381 hbheMuon.
globalMuonHits_ = (recMuon->globalTrack()->hitPattern().numberOfValidMuonHits());
382 hbheMuon.
matchedStat_ = (recMuon->numberOfMatchedStations());
387 hbheMuon.
tightLongPara_ = (fabs(recMuon->muonBestTrack()->dz(pvx)));
391 ((recMuon->pfIsolationR04().sumChargedHadronPt +
393 recMuon->pfIsolationR04().sumNeutralHadronEt + recMuon->pfIsolationR04().sumPhotonEt -
394 (0.5 * recMuon->pfIsolationR04().sumPUPt))) /
398 ((recMuon->pfIsolationR03().sumChargedHadronPt +
400 recMuon->pfIsolationR03().sumNeutralHadronEt + recMuon->pfIsolationR03().sumPhotonEt -
401 (0.5 * recMuon->pfIsolationR03().sumPUPt))) /
404 hbheMuon.
ecalEnergy_ = (recMuon->calEnergy().emS9);
405 hbheMuon.
hcalEnergy_ = (recMuon->calEnergy().hadS9);
406 hbheMuon.
hoEnergy_ = (recMuon->calEnergy().hoS9);
408 if (recMuon->innerTrack().isNonnull()) {
409 const reco::Track* pTrack = (recMuon->innerTrack()).
get();
412 double activeLengthTot(0), activeLengthHotTot(0);
425 unsigned int isHot(0);
428 eHcalDepth[
i] = eHcalDepthHot[
i] = 0;
429 eHcalDepthC[
i] = eHcalDepthHotC[
i] = 0;
430 cHcalDepthHot[
i] = cHcalDepthHotBG[
i] = 0;
431 eHcalDepthRaw[
i] = eHcalDepthHotRaw[
i] = 0;
432 eHcalDepthCRaw[
i] = eHcalDepthHotCRaw[
i] = 0;
433 cHcalDepthHotRaw[
i] = cHcalDepthHotBGRaw[
i] = 0;
434 eHcalDepthAux[
i] = eHcalDepthHotAux[
i] = 0;
435 eHcalDepthCAux[
i] = eHcalDepthHotCAux[
i] = 0;
436 cHcalDepthHotAux[
i] = cHcalDepthHotBGAux[
i] = 0;
437 activeL[
i] = activeHotL[
i] = 0;
438 matchDepth[
i] = matchDepthHot[
i] =
true;
454 bool okE = trackID.
okECAL;
493 if ((hcidt.ieta() ==
check.ieta()) && (hcidt.iphi() ==
check.iphi()))
505 theHBHETopology, closestCell,
hbhe, 0, 0,
false,
true, -100.0, -100.0, -100.0, -100.0, -500., 500., 0);
507 theHBHETopology, closestCell,
hbhe, 0, 0,
false,
true, -100.0, -100.0, -100.0, -100.0, -500., 500., 1);
509 theHBHETopology, closestCell,
hbhe, 0, 0,
false,
true, -100.0, -100.0, -100.0, -100.0, -500., 500., 2);
510 std::vector<std::pair<double, int>> ehdepth, ehdepthAux, ehdepthRaw;
552 for (
unsigned int i = 0;
i < ehdepth.size(); ++
i) {
558 double ene = ehdepth[
i].first;
559 double eneAux = ehdepthAux[
i].first;
560 double eneRaw = ehdepthRaw[
i].first;
563 if (!(theHBHETopology->
validHcal(hcid0))) {
564 edm::LogWarning(
"HBHEMuon") <<
"(1) Invalid ID " << hcid0 <<
" with E = " << ene;
566 for (
const auto& ehd : ehdepth)
578 int depth = ehdepth[
i].second - 1;
581 depth =
id.depth() - 1;
583 eHcalDepth[
depth] += ene;
584 eHcalDepthC[
depth] += enec;
585 activeL[
depth] += actL;
586 activeLengthTot += actL;
587 matchDepth[
depth] = (matchDepth[
depth] && tmpC);
591 << hcid0 <<
" E " << ene <<
":" << enec <<
" L " << actL <<
" Match " << tmpC;
597 double enecAux(eneAux);
601 int depth = ehdepthAux[
i].second - 1;
604 depth =
id.depth() - 1;
606 eHcalDepthAux[
depth] += eneAux;
607 eHcalDepthCAux[
depth] += enecAux;
611 << hcid0 <<
" E " << eneAux <<
":" << enecAux <<
" L " << actL <<
" Match " << tmpC;
617 double enecRaw(eneRaw);
621 int depth = ehdepthRaw[
i].second - 1;
624 depth =
id.depth() - 1;
626 eHcalDepthRaw[
depth] += eneRaw;
627 eHcalDepthCRaw[
depth] += enecRaw;
631 << hcid0 <<
" E " << eneRaw <<
":" << enecRaw <<
" L " << actL <<
" Match " << tmpC;
639 for (
unsigned int k = 0;
k < ehdepth.size(); ++
k)
640 edm::LogVerbatim(
"HBHEMuon") <<
" [" <<
k <<
":" << ehdepth[
k].second <<
"] " << matchDepth[
k];
645 isHot =
matchId(closestCell, hotCell);
651 std::vector<std::pair<double, int>> ehdepth, ehdepthAux, ehdepthRaw;
693 for (
unsigned int i = 0;
i < ehdepth.size(); ++
i) {
699 double ene = ehdepth[
i].first;
702 if (!(theHBHETopology->
validHcal(hcid0))) {
703 edm::LogWarning(
"HBHEMuon") <<
"(2) Invalid ID " << hcid0 <<
" with E = " << ene;
705 for (
const auto& ehd : ehdepth)
709 double chg(ene), enec(ene);
715 edm::LogVerbatim(
"HBHEMuon") << hcid0 <<
":" <<
id <<
" Corr " <<
corr <<
" E " << ene <<
":" << enec;
723 int depth = ehdepth[
i].second - 1;
726 depth =
id.depth() - 1;
728 eHcalDepthHot[
depth] += ene;
729 eHcalDepthHotC[
depth] += enec;
731 activeHotL[
depth] += actL;
732 activeLengthHotTot += actL;
733 matchDepthHot[
depth] = (matchDepthHot[
depth] && tmpC);
738 <<
chg <<
" L " << actL <<
" Match " << tmpC;
742 double eneAux = ehdepthAux[
i].first;
745 double chgAux(eneAux), enecAux(eneAux);
752 int depth = ehdepthAux[
i].second - 1;
755 depth =
id.depth() - 1;
757 eHcalDepthHotAux[
depth] += eneAux;
758 eHcalDepthHotCAux[
depth] += enecAux;
759 cHcalDepthHotAux[
depth] += chgAux;
763 <<
" C " << chgAux <<
" L " << actL <<
" Match " << tmpC;
767 double eneRaw = ehdepthRaw[
i].first;
770 double chgRaw(eneRaw), enecRaw(eneRaw);
777 int depth = ehdepthRaw[
i].second - 1;
780 depth =
id.depth() - 1;
782 eHcalDepthHotRaw[
depth] += eneRaw;
783 eHcalDepthHotCRaw[
depth] += enecRaw;
784 cHcalDepthHotRaw[
depth] += chgRaw;
788 <<
" C " << chgRaw <<
" L " << actL <<
" Match " << tmpC;
795 std::vector<std::pair<double, int>> ehdeptho, ehdepthoAux, ehdepthoRaw;
835 for (
unsigned int i = 0;
i < ehdeptho.size(); ++
i) {
840 double ene = ehdeptho[
i].first;
842 if (!(theHBHETopology->
validHcal(hcid0))) {
843 edm::LogWarning(
"HBHEMuon") <<
"(3) Invalid ID " << hcid0 <<
" with E = " << ene;
844 edm::LogWarning(
"HBHEMuon") << oppCell <<
" with " << ehdeptho.size() <<
" depths:";
845 for (
const auto& ehd : ehdeptho)
855 << hcid0 <<
":" <<
id <<
" Corr " <<
corr <<
" E " << ene <<
":" << ehdeptho[
i].first;
863 int depth = ehdeptho[
i].second - 1;
866 depth =
id.depth() - 1;
875 double eneAux = ehdepthoAux[
i].first;
878 double chgAux(eneAux);
885 int depth = ehdepthoAux[
i].second - 1;
888 depth =
id.depth() - 1;
890 cHcalDepthHotBGAux[
depth] += chgAux;
897 double eneRaw = ehdepthoRaw[
i].first;
900 double chgRaw(eneRaw);
907 int depth = ehdepthoRaw[
i].second - 1;
910 depth =
id.depth() - 1;
912 cHcalDepthHotBGRaw[
depth] += chgRaw;
924 << hbheMuon.
matchedId_ <<
" Hot " << isHot <<
" Energy " << eHcal;
956 if ((recMuon->p() > 10.0) && (trackID.
okHCAL))
957 outputHcalHBHEMuonColl->emplace_back(hbheMuon);
961 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_
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
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)
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
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 edm::ESGetToken< EcalPFRecHitThresholds, EcalPFRecHitThresholdsRcd > tok_ecalPFRecHitThresholds_
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_
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_