156 std::vector<HcalDDDRecConstants::HcalActiveLength>
actHB,
actHE;
170 verbosity_(iConfig.getUntrackedParameter<
int>(
"verbosity", 0)),
198 if (modnam.empty()) {
215 if (infile.is_open()) {
219 infile >>
id >> cfac;
230 <<
":" << mergedDepth_ <<
" IsItPlan1 " <<
isItPlan1_ <<
" IsItPreRecHit " 263 std::vector<int>
index;
264 for (
int i = 0;
i < Ntriggers;
i++) {
266 int triggerSize =
int(_Triggers->
size());
269 edm::LogVerbatim(
"HBHEMuon") <<
"outside loop " << index[
i] <<
"\ntriggerSize " << triggerSize << std::endl;
271 if (index[i] < triggerSize) {
275 edm::LogVerbatim(
"HBHEMuon") <<
"Trigger_info " << triggerSize <<
" triggerSize " << index[
i]
276 <<
" trigger_index " <<
hltresults_.at(i) <<
" hltresult" << std::endl;
281 <<
"\" does not exist\n";
333 reco::VertexCollection::const_iterator firstGoodVertex = vtx->end();
334 for (reco::VertexCollection::const_iterator it = vtx->begin(); it != vtx->end(); it++) {
336 if (firstGoodVertex == vtx->end())
337 firstGoodVertex = it;
341 if (firstGoodVertex != vtx->end())
342 pvx = firstGoodVertex->position();
346 for (reco::MuonCollection::const_iterator RecMuon = _Muon->begin(); RecMuon != _Muon->end(); ++RecMuon) {
354 pMuon_.push_back(RecMuon->p());
356 edm::LogVerbatim(
"HBHEMuon") <<
"Energy:" << RecMuon->energy() <<
" P:" << RecMuon->p() << std::endl;
360 muon_trkKink.push_back(RecMuon->combinedQuality().trkKink);
364 if (RecMuon->track().isNonnull()) {
365 trackerLayer_.push_back(RecMuon->track()->hitPattern().trackerLayersWithMeasurement());
369 if (RecMuon->innerTrack().isNonnull()) {
371 numPixelLayers_.push_back(RecMuon->innerTrack()->hitPattern().pixelLayersWithMeasurement());
372 chiTracker_.push_back(RecMuon->innerTrack()->normalizedChi2());
373 dxyTracker_.push_back(fabs(RecMuon->innerTrack()->dxy(pvx)));
374 dzTracker_.push_back(fabs(RecMuon->innerTrack()->dz(pvx)));
378 tight_PixelHits_.push_back(RecMuon->innerTrack()->hitPattern().numberOfValidPixelHits());
393 if (RecMuon->outerTrack().isNonnull()) {
398 outerTrackChi_.push_back(RecMuon->outerTrack()->normalizedChi2());
411 if (RecMuon->globalTrack().isNonnull()) {
413 chiGlobal_.push_back(RecMuon->globalTrack()->normalizedChi2());
414 globalMuonHits_.push_back(RecMuon->globalTrack()->hitPattern().numberOfValidMuonHits());
415 matchedStat_.push_back(RecMuon->numberOfMatchedStations());
434 ((RecMuon->pfIsolationR04().sumChargedHadronPt +
436 RecMuon->pfIsolationR04().sumNeutralHadronEt + RecMuon->pfIsolationR04().sumPhotonEt -
437 (0.5 * RecMuon->pfIsolationR04().sumPUPt))) /
441 ((RecMuon->pfIsolationR03().sumChargedHadronPt +
443 RecMuon->pfIsolationR03().sumNeutralHadronEt + RecMuon->pfIsolationR03().sumPhotonEt -
444 (0.5 * RecMuon->pfIsolationR03().sumPUPt))) /
449 hoEnergy_.push_back(RecMuon->calEnergy().hoS9);
451 double eEcal(0), eHcal(0), activeLengthTot(0), activeLengthHotTot(0);
458 unsigned int isHot(0);
459 bool tmpmatch(
false);
460 int ieta(-1000), iphi(-1000);
462 eHcalDepth[
i] = eHcalDepthHot[
i] = 0;
463 eHcalDepthC[
i] = eHcalDepthHotC[
i] = 0;
464 cHcalDepthHot[
i] = cHcalDepthHotBG[
i] = 0;
465 activeL[
i] = activeHotL[
i] = 0;
466 matchDepth[
i] = matchDepthHot[
i] =
true;
468 if (RecMuon->innerTrack().isNonnull()) {
469 const reco::Track* pTrack = (RecMuon->innerTrack()).
get();
471 if ((RecMuon->p() > 10.0) && (trackID.
okHCAL))
484 bool okE = trackID.
okECAL;
505 edm::LogVerbatim(
"HBHEMuon") <<
"Propagate Track to ECAL: " << okE <<
":" << trackID.
okECAL <<
" E " << eEcal;
511 if ((hcidt.ieta() == check.
ieta()) && (hcidt.iphi() == check.
iphi()))
514 edm::LogVerbatim(
"HBHEMuon") <<
"Front " << hcidt <<
" Back " << info.first <<
":" << check <<
" Match " 521 bool hborhe = (
std::abs(ieta) == 16);
537 std::vector<std::pair<double, int>> ehdepth;
553 for (
unsigned int i = 0;
i < ehdepth.size(); ++
i) {
558 double ene = ehdepth[
i].first;
562 edm::LogWarning(
"HBHEMuon") <<
"(1) Invalid ID " << hcid0 <<
" with E = " << ene;
564 for (
const auto& ehd : ehdepth)
567 tmpC =
goodCell(hcid0, pTrack, geo, bField);
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;
598 edm::LogVerbatim(
"HBHEMuon") << hcidt <<
" Match " << tmpmatch <<
" Depths " << ehdepth.size();
599 for (
unsigned int k = 0;
k < ehdepth.size(); ++
k)
600 edm::LogVerbatim(
"HBHEMuon") <<
" [" <<
k <<
":" << ehdepth[
k].second <<
"] " << matchDepth[
k];
605 isHot =
matchId(closestCell, hotCell);
611 std::vector<std::pair<double, int>> ehdepth;
627 for (
unsigned int i = 0;
i < ehdepth.size(); ++
i) {
632 double ene = ehdepth[
i].first;
636 edm::LogWarning(
"HBHEMuon") <<
"(2) Invalid ID " << hcid0 <<
" with E = " << ene;
638 for (
const auto& ehd : ehdepth)
641 tmpC =
goodCell(hcid0, pTrack, geo, bField);
642 double chg(ene), enec(ene);
650 << hcid0 <<
":" <<
id <<
" Corr " << corr <<
" E " << ene <<
":" << enec;
661 int depth = ehdepth[
i].second - 1;
664 depth =
id.
depth() - 1;
666 eHcalDepthHot[
depth] += ene;
667 eHcalDepthHotC[
depth] += enec;
669 activeHotL[
depth] += actL;
670 activeLengthHotTot += actL;
671 matchDepthHot[
depth] = (matchDepthHot[
depth] && tmpC);
674 edm::LogVerbatim(
"HBHEMuon") << hcid0 <<
" depth " << depth <<
" E " << ene <<
":" << enec <<
" C " 675 <<
chg <<
" L " << actL <<
" Match " << tmpC;
682 std::vector<std::pair<double, int>> ehdeptho;
696 for (
unsigned int i = 0;
i < ehdeptho.size(); ++
i) {
700 double ene = ehdeptho[
i].first;
703 edm::LogWarning(
"HBHEMuon") <<
"(3) Invalid ID " << hcid0 <<
" with E = " << ene;
704 edm::LogWarning(
"HBHEMuon") << oppCell <<
" with " << ehdeptho.size() <<
" depths:";
705 for (
const auto& ehd : ehdeptho)
716 << hcid0 <<
":" <<
id <<
" Corr " << corr <<
" E " << ene <<
":" << ehdeptho[
i].first;
727 int depth = ehdeptho[
i].second - 1;
730 depth =
id.
depth() - 1;
735 edm::LogVerbatim(
"HBHEMuon") << hcid0 <<
" Depth " << depth <<
" E " << ene <<
" C " <<
chg;
744 <<
" Hot " << isHot <<
" Energy " << eHcal << std::endl;
856 sprintf(name,
"hcal_edepth%d", (
k + 1));
858 sprintf(name,
"hcal_activeL%d", (k + 1));
860 sprintf(name,
"hcal_edepthHot%d", (k + 1));
862 sprintf(name,
"hcal_activeHotL%d", (k + 1));
864 sprintf(name,
"hcal_cdepthHot%d", (k + 1));
866 sprintf(name,
"hcal_cdepthHotBG%d", (k + 1));
868 sprintf(name,
"hcal_edepthCorrect%d", (k + 1));
870 sprintf(name,
"hcal_edepthHotCorrect%d", (k + 1));
872 sprintf(name,
"hcal_depthMatch%d", (k + 1));
874 sprintf(name,
"hcal_depthMatchHot%d", (k + 1));
895 unsigned int k1(0), k2(0);
897 for (
const auto& act :
actHB) {
898 edm::LogVerbatim(
"HBHEMuon") <<
"[" << k1 <<
"] ieta " << act.ieta <<
" depth " << act.depth <<
" zside " 899 << act.zside <<
" type " << act.stype <<
" phi " << act.iphis.size() <<
":" 900 << act.iphis[0] <<
" L " << act.thick;
907 for (
const auto& act :
actHE) {
908 edm::LogVerbatim(
"HBHEMuon") <<
"[" << k2 <<
"] ieta " << act.ieta <<
" depth " << act.depth <<
" zside " 909 << act.zside <<
" type " << act.stype <<
" phi " << act.iphis.size() <<
":" 910 << act.iphis[0] <<
" L " << act.thick;
925 <<
" successfully extracted" << std::endl;
928 for (
unsigned int t = 0;
t < ntriggers; ++
t) {
930 for (
unsigned int ik = 0; ik < 6; ++ik) {
939 edm::LogError(
"HBHEMuon") <<
"Error! HLT config extraction with process " 940 <<
"name HLT failed";
959 edm::LogVerbatim(
"HBHEMuon") <<
"\nTable of Correction Factors for Run " << iRun.
run() <<
"\n";
960 for (
auto const&
id : ids) {
978 std::vector<std::string> trig = {
"HLT_IsoMu17",
"HLT_IsoMu20",
"HLT_IsoMu24",
"HLT_IsoMu27",
"HLT_Mu45",
"HLT_Mu50"};
979 desc.
add<std::vector<std::string>>(
"triggers", trig);
981 desc.
add<
int>(
"useRaw", 0);
982 desc.
add<
bool>(
"unCorrect",
false);
983 desc.
add<
bool>(
"getCharge",
false);
984 desc.
add<
bool>(
"collapseDepth",
false);
985 desc.
add<
bool>(
"isItPlan1",
false);
993 descriptions.
add(
"hcalHBHEMuon", desc);
1082 int match = ((kd1 == kd2) ? 1 : 0);
1088 int ieta =
id.ietaAbs();
1089 int zside =
id.zside();
1090 int iphi =
id.iphi();
1091 std::vector<int> dpths;
1093 std::vector<HcalDetId> ids;
1095 for (
auto idh : ids)
1096 dpths.emplace_back(idh.depth());
1098 dpths.emplace_back(
id.
depth());
1102 for (
unsigned int i = 0;
i <
actHB.size(); ++
i) {
1103 if ((ieta ==
actHB[
i].ieta) && (zside ==
actHB[
i].zside) &&
1104 (
std::find(dpths.begin(), dpths.end(),
actHB[
i].depth) != dpths.end()) &&
1110 for (
unsigned int i = 0;
i <
actHE.size(); ++
i) {
1111 if ((ieta ==
actHE[
i].ieta) && (zside ==
actHE[
i].zside) &&
1112 (
std::find(dpths.begin(), dpths.end(),
actHE[
i].depth) != dpths.end()) &&
1128 if (fabs(vtx.
position().Z()) > 24.)
1148 for (
int capid = 0; capid < 4; ++capid)
1157 int zside = (ieta > 0) ? 1 : -1;
1163 <<
" depth " <<
depth;
1172 std::pair<double, double> rz =
hdc_->
getRZ(hcid);
unsigned int size() const
number of trigger paths in trigger table
static const std::string kSharedResource
std::vector< double > tight_validFraction_
std::vector< int > hltresults_
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
EventNumber_t event() const
std::vector< double > innerTrackphi_
HcalHBHEMuonAnalyzer(const edm::ParameterSet &)
const std::string labelMuon_
T getUntrackedParameter(std::string const &, T const &) const
std::vector< spr::propagatedTrackID > propagateCALO(edm::Handle< reco::TrackCollection > &trkCollection, const CaloGeometry *geo, const MagneticField *bField, const std::string &theTrackQuality, bool debug=false)
const HcalTopology * theHBHETopology_
const HcalDDDRecConstants * dddConstants() const
unsigned int eventNumber_
std::vector< std::string > all_triggers_
std::vector< double > dzTracker_
static const int depthMax_
HcalSubdetector subdet() const
get the subdetector
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void analyze(edm::Event const &, edm::EventSetup const &) override
const std::string & triggerName(unsigned int triggerIndex) const
std::vector< double > outerTrackChi_
bool isMediumMuon(const reco::Muon &, bool run2016_hip_mitigation=false)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
HcalDetId mergedDepthDetId(const HcalDetId &id) const
std::vector< double > hcalDepthChargeHotBG_[depthMax_]
std::vector< double > tight_LongPara_
std::pair< math::XYZPoint, bool > propagateHCAL(const reco::Track *, const MagneticField *, bool debug=false)
edm::EDGetTokenT< EcalRecHitCollection > tok_EE_
std::vector< unsigned int > ecalDetId_
const std::vector< DetId > & getValidDetIds(DetId::Detector det=DetId::Detector(0), int subdet=0) const override
Get a list of valid detector ids (for the given subdetector)
std::vector< double > pMuon_
bool accept() const
Has at least one path accepted the event?
std::vector< double > globalTrckPhi_
constexpr uint32_t rawId() const
get the raw id
std::vector< bool > muon_is_tight_
int bunchCrossing() const
double respCorr(const DetId &id)
T * make(const Args &...args) const
make new ROOT object
const Item * getValues(DetId fId, bool throwOnFail=true) const
std::vector< HcalDDDRecConstants::HcalActiveLength > actHE
bool validHcal(const HcalDetId &id) const
const edm::InputTag hlTriggerResults_
std::vector< double > isolationR03_
std::vector< int > outerTrackHits_
const bool writeRespCorr_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
LuminosityBlockNumber_t luminosityBlock() const
const Point & position() const
position
double gainFactor(const edm::ESHandle< HcalDbService > &, const HcalDetId &id)
std::vector< bool > muon_global_
edm::EDGetTokenT< edm::TriggerResults > tok_trigRes_
std::vector< float > muon_trkKink
std::vector< double > hcalDepthEnergy_[depthMax_]
const edm::InputTag labelEERecHit_
std::vector< double > outerTrackPt_
U second(std::pair< T, U > const &p)
const edm::InputTag labelEBRecHit_
edm::EDGetTokenT< reco::VertexCollection > tok_Vtx_
void beginRun(edm::Run const &, edm::EventSetup const &) override
std::vector< double > globalTrckPt_
int depth() const
get the tower depth
std::vector< int > tight_PixelHits_
#define DEFINE_FWK_MODULE(type)
std::vector< bool > muon_tracker_
std::vector< double > ecalEnergy_
unsigned int triggerIndex(std::string const &name) const
std::vector< int > numPixelLayers_
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)
std::vector< double > hcalActiveLengthHot_
std::vector< double > innerTracketa_
const bool isItPreRecHit_
std::vector< double > globalTrckEta_
std::vector< double > isolationR04_
unsigned int size() const
Get number of paths stored.
std::vector< double > hcalDepthActiveLengthHot_[depthMax_]
std::vector< double > hcalDepthEnergyHotCorr_[depthMax_]
int getMinDepth(const int &itype, const int &ieta, const int &iphi, const int &zside) const
double getRZ(const int &subdet, const int &ieta, const int &depth) const
std::vector< double > ptGlob_
std::vector< unsigned int > ehcalDetId_
int ieta() const
get the cell ieta
Abs< T >::type abs(const T &t)
float segmentCompatibility(const reco::Muon &muon, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
std::vector< double > hcalEnergy_
std::vector< int > hcal_iphi_
const std::string labelVtx_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::vector< double > outerTrackEta_
double activeLength(const DetId &)
std::vector< bool > globalTrack_
std::vector< double > hcal1x1Energy_
edm::EDGetTokenT< reco::MuonCollection > tok_Muon_
bool goodCell(const HcalDetId &hcid, const reco::Track *pTrack, const CaloGeometry *geo, const MagneticField *bField)
std::vector< int > outerTrackRHits_
std::vector< bool > hcalHot_
const edm::InputTag labelHBHERecHit_
std::vector< bool > muon_is_good_
int iphi() const
get the cell iphi
std::map< DetId, double > corrValue_
std::vector< double > chiGlobal_
std::vector< HcalDDDRecConstants::HcalActiveLength > actHB
std::vector< float > muon_segComp
int depth16HE(int ieta, int iphi)
std::vector< unsigned int > hcalDetId_
std::vector< double > hcalDepthEnergyHot_[depthMax_]
std::vector< int > matchedStat_
std::vector< bool > matchedId_
void endRun(edm::Run const &, edm::EventSetup const &) override
XYZPointD XYZPoint
point in space with cartesian internal representation
std::vector< double > hcalDepthEnergyCorr_[depthMax_]
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d'tor
void unmergeDepthDetId(const HcalDetId &id, std::vector< HcalDetId > &ids) const
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::vector< int > hcal_ieta_
std::vector< double > hcalDepthActiveLength_[depthMax_]
std::vector< double > hoEnergy_
int matchId(const HcalDetId &, const HcalDetId &)
HcalRespCorrs * respCorrs_
const HcalDDDRecConstants * hdc_
std::vector< double > phiGlob_
HLTConfigProvider hltConfig_
edm::EDGetTokenT< EcalRecHitCollection > tok_EB_
std::vector< bool > muon_is_medium_
std::vector< int > globalMuonHits_
std::vector< double > hcalActiveLength_
std::vector< double > chiTracker_
std::vector< double > hcalDepthChargeHot_[depthMax_]
const JetExtendedData & getValue(const Container &, const reco::JetBaseRef &)
get value for the association. Throw exception if no association found
std::vector< bool > hcalDepthMatchHot_[depthMax_]
std::vector< HcalActiveLength > getThickActive(const int &type) const
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
std::vector< int > trackerLayer_
const bool collapseDepth_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< bool > outerTrack_
bool isTightMuon(const reco::Muon &, const reco::Vertex &)
const HcalCalibrations & getHcalCalibrations(const HcalGenericDetId &fId) const
edm::EDGetTokenT< HBHERecHitCollection > tok_HBHE_
const std::string fileInCorr_
edm::Service< TFileService > fs
T const * product() const
std::vector< double > dxyTracker_
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 double respcorrgain(int fCapId) const
get response corrected gain for capid=0..3
edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const override
std::vector< double > ecal3x3Energy_
void setTopo(const HcalTopology *topo)
std::vector< double > tight_TransImpara_
const std::vector< std::string > triggers_
std::vector< double > energyMuon_
std::vector< double > etaGlob_
bool isGoodVertex(const reco::Vertex &vtx)
std::vector< double > outerTrackPhi_
std::vector< double > innerTrackpt_
std::vector< bool > innerTrack_
std::vector< bool > hcalDepthMatch_[depthMax_]
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)
std::vector< float > muon_chi2LocalPosition