13 #include "TDirectory.h" 15 #include "TLorentzVector.h" 16 #include "TInterpreter.h" 100 std::array<int,3>
fillTree(std::vector< math::XYZTLorentzVector>& vecL1,
101 std::vector< math::XYZTLorentzVector>& vecL3,
103 std::vector<spr::propagatedTrackDirection>& trkCaloDirections,
116 const std::vector<DetId>&
ids,
117 std::vector<double>& edet,
double & eHcal,
118 std::vector<unsigned int> *detIds,
119 std::vector<double> *hitEnergies);
189 a_coneR_(iConfig.getParameter<double>(
"coneRadius")),
190 a_mipR_(iConfig.getParameter<double>(
"coneRadiusMIP")),
191 pTrackMin_(iConfig.getParameter<double>(
"minimumTrackP")),
192 eEcalMax_(iConfig.getParameter<double>(
"maximumEcalEnergy")),
195 hcalScale_(iConfig.getUntrackedParameter<double>(
"hHcalScale",1.0)),
196 eIsolate1_(iConfig.getParameter<double>(
"isolationEnergyTight")),
197 eIsolate2_(iConfig.getParameter<double>(
"isolationEnergyLoose")),
198 useRaw_(iConfig.getUntrackedParameter<
int>(
"useRaw",0)),
199 dataType_(iConfig.getUntrackedParameter<
int>(
"dataType",0)),
200 mode_(iConfig.getUntrackedParameter<
int>(
"outMode",11)),
205 hitEthrEB_(iConfig.getParameter<double>(
"EBHitEnergyThreshold") ),
206 hitEthrEE0_(iConfig.getParameter<double>(
"EEHitEnergyThreshold0") ),
207 hitEthrEE1_(iConfig.getParameter<double>(
"EEHitEnergyThreshold1") ),
208 hitEthrEE2_(iConfig.getParameter<double>(
"EEHitEnergyThreshold2") ),
209 hitEthrEE3_(iConfig.getParameter<double>(
"EEHitEnergyThreshold3") ),
224 const double isolationRadius(28.9), innerR(10.0), outerR(30.0);
253 tok_bs_ = consumes<reco::BeamSpot>(labelBS);
258 tok_alg_ = consumes<BXVector<GlobalAlgBlk>>(algTag);
305 <<
"\t a_charIsoR " << a_charIsoR_
318 <<
"\t mode_ " <<
mode_ 323 <<
" L1Filter:" <<
l1Filter_ <<
" L2Filter:" 339 unsigned int k1(0), k2(0);
340 for (
auto phi : phibins_) {
343 for (
auto eta : etabins_) {
378 respCorrs->
setTopo(theHBHETopology);
388 reco::TrackCollection::const_iterator trkItr;
389 if (!trkCollection.
isValid()) {
408 if (recVtxs.
isValid() && recVtxs->size()>0) {
410 for (
unsigned int k=0;
k<recVtxs->size(); ++
k) {
411 if (!((*recVtxs)[
k].isFake()) && ((*recVtxs)[
k].ndof() > 4)) {
422 edm::LogVerbatim(
"HcalIsoTrack") <<
"Primary Vertex " << leadPV <<
" out of " 431 if (!barrelRecHitsHandle.
isValid()) {
438 if (!endcapRecHitsHandle.
isValid()) {
454 std::vector<spr::propagatedTrackDirection> trkCaloDirections;
456 trkCaloDirections,
false);
457 std::vector<math::XYZTLorentzVector> vecL1, vecL3;
465 <<
" out of " <<
t_Tracks <<
" with Trigger " 479 for (
const auto& decision : finalDecisions) {
480 if (decision.first.find(
l1TrigName_.c_str()) != std::string::npos) {
487 <<
" is " <<
t_L1Bit <<
" from a list of " 488 << finalDecisions.size() <<
" decisions";
494 if (triggerResults.
isValid()) {
498 for (
unsigned int iHLT=0; iHLT<triggerResults->
size(); iHLT++) {
507 << names[iHLT] <<
" Flag " 520 std::array<int,3> ntksave{ {0,0,0} };
525 ntksave =
fillTree(vecL1, vecL3, leadPV, trkCaloDirections, geo,
526 barrelRecHitsHandle, endcapRecHitsHandle, hbhe,
527 caloTower, genParticles, respCorrs);
535 if (!triggerEventHandle.
isValid()) {
539 triggerEvent = *(triggerEventHandle.
product());
542 if (triggerResults.
isValid()) {
543 std::vector<std::string>
modules;
546 for (
unsigned int iHLT=0; iHLT<triggerResults->
size(); iHLT++) {
551 std::vector<math::XYZTLorentzVector> vecL2;
552 vecL1.clear(); vecL3.clear();
554 for (
unsigned int ifilter=0; ifilter<triggerEvent.
sizeFilters();
556 std::vector<int>
Keys;
559 for (
unsigned int imodule=0; imodule<moduleLabels.size(); imodule++) {
560 if (label.find(moduleLabels[imodule]) != std::string::npos) {
564 for (
unsigned int ifiltrKey=0; ifiltrKey<triggerEvent.
filterKeys(ifilter).size(); ++ifiltrKey) {
565 Keys.push_back(triggerEvent.
filterKeys(ifilter)[ifiltrKey]);
568 if (label.find(
l2Filter_) != std::string::npos) {
570 }
else if (label.find(
l3Filter_) != std::string::npos) {
577 <<
" : pt " << TO.
pt()
578 <<
" eta " << TO.
eta()
579 <<
" phi " << TO.
phi()
580 <<
" mass " << TO.
mass()
586 <<
":" << vecL2.size() <<
":" 595 for (
unsigned int i=0;
i<vecL2.size();
i++) {
596 double dr =
dR(vecL1[0],vecL2[
i]);
602 mindRvec1 = vecL2[
i];
607 << mindRvec1 <<
" at Dr " 611 if (vecL1.size()>0) {
618 if (vecL3.size()>0) {
627 ntksave =
fillTree(vecL1, vecL3, leadPV, trkCaloDirections, geo,
628 barrelRecHitsHandle,endcapRecHitsHandle, hbhe,
629 caloTower, genParticles, respCorrs);
651 tree =
fs->
make<TTree>(
"CalibTree",
"CalibTree");
653 tree->Branch(
"t_Run", &
t_Run,
"t_Run/I");
662 if (((
mode_/10)%10) == 1) {
670 tree->Branch(
"t_p", &
t_p,
"t_p/D");
671 tree->Branch(
"t_pt", &
t_pt,
"t_pt/D");
672 tree->Branch(
"t_phi", &
t_phi,
"t_phi/D");
687 t_DetIds =
new std::vector<unsigned int>();
688 t_DetIds1 =
new std::vector<unsigned int>();
689 t_DetIds3 =
new std::vector<unsigned int>();
694 tree->Branch(
"t_DetIds",
"std::vector<unsigned int>", &
t_DetIds);
695 tree->Branch(
"t_HitEnergies",
"std::vector<double>", &t_HitEnergies);
696 if (((
mode_/10)%10) == 1) {
697 tree->Branch(
"t_trgbits",
"std::vector<bool>", &t_trgbits);
699 if ((
mode_%10) == 1) {
700 tree->Branch(
"t_DetIds1",
"std::vector<unsigned int>", &t_DetIds1);
701 tree->Branch(
"t_DetIds3",
"std::vector<unsigned int>", &t_DetIds3);
702 tree->Branch(
"t_HitEnergies1",
"std::vector<double>", &t_HitEnergies1);
703 tree->Branch(
"t_HitEnergies3",
"std::vector<double>", &t_HitEnergies3);
705 tree2 =
fs->
make<TTree>(
"EventInfo",
"Event Information");
722 tree2->Branch(
"t_ietaAll",
"std::vector<int>", &t_ietaAll);
723 tree2->Branch(
"t_ietaGood",
"std::vector<int>", &t_ietaGood);
724 tree2->Branch(
"t_trackType",
"std::vector<int>", &t_trackType);
739 <<
" init flag " << flag <<
" change flag " 748 for (
unsigned itrig=0; itrig<
trigNames_.size(); itrig++) {
750 if (triggerindx >=
n) {
752 << triggerindx <<
" does not exist in " 753 <<
"the current menu";
757 << triggerindx <<
" exists";
772 std::vector<std::string> trig = {
"HLT_PFJet40",
"HLT_PFJet60",
"HLT_PFJet80",
773 "HLT_PFJet140",
"HLT_PFJet200",
"HLT_PFJet260",
774 "HLT_PFJet320",
"HLT_PFJet400",
"HLT_PFJet450",
776 desc.
add<std::vector<std::string>>(
"triggers",trig);
783 desc.
add<
double>(
"minTrackPt",1.0);
784 desc.
add<
double>(
"maxDxyPV",0.02);
785 desc.
add<
double>(
"maxDzPV",0.02);
786 desc.
add<
double>(
"maxChi2",5.0);
787 desc.
add<
double>(
"maxDpOverP",0.1);
788 desc.
add<
int>(
"minOuterHit",4);
789 desc.
add<
int>(
"minLayerCrossed",8);
790 desc.
add<
int>(
"maxInMiss",0);
791 desc.
add<
int>(
"maxOutMiss",0);
793 desc.
add<
double>(
"minimumTrackP",20.0);
794 desc.
add<
double>(
"coneRadius",34.98);
796 desc.
add<
double>(
"coneRadiusMIP",14.0);
797 desc.
add<
double>(
"maximumEcalEnergy",2.0);
799 desc.
add<
double>(
"maxTrackP",8.0);
800 desc.
add<
double>(
"slopeTrackP",0.05090504066);
801 desc.
add<
double>(
"isolationEnergyTight",2.0);
802 desc.
add<
double>(
"isolationEnergyLoose",10.0);
804 desc.
add<
double>(
"EBHitEnergyThreshold",0.10);
805 desc.
add<
double>(
"EEHitEnergyThreshold0",-41.0664);
806 desc.
add<
double>(
"EEHitEnergyThreshold1",68.7950);
807 desc.
add<
double>(
"EEHitEnergyThreshold2",-38.1483);
808 desc.
add<
double>(
"EEHitEnergyThreshold3",7.04303);
834 descriptions.
add(
"HcalIsoTrkAnalyzer",desc);
838 std::vector< math::XYZTLorentzVector>& vecL3,
840 std::vector<spr::propagatedTrackDirection>& trkCaloDirections,
849 int nSave(0),
nLoose(0), nTight(0);
851 std::vector<spr::propagatedTrackDirection>::const_iterator trkDetItr;
852 unsigned int nTracks(0), nselTracks(0);
853 t_nTrk = trkCaloDirections.size();
855 for (trkDetItr = trkCaloDirections.begin(),
nTracks=0;
856 trkDetItr != trkCaloDirections.end(); trkDetItr++,
nTracks++) {
857 const reco::Track* pTrack = &(*(trkDetItr->trkItr));
859 pTrack->
pz(), pTrack->
p());
862 <<
" (pt|eta|phi|p) :" << pTrack->
pt()
863 <<
"|" << pTrack->
eta() <<
"|" 864 << pTrack->
phi() <<
"|" <<pTrack->
p();
867 for (
unsigned int k=0;
k<vecL3.size(); ++
k) {
868 double dr =
dR(vecL3[
k],v4);
873 t_mindR1 = (vecL1.size() > 0) ?
dR(vecL1[0],v4) : 999;
879 if (trkDetItr->okHCAL) {
889 oneCutParameters.
maxDzPV = 100;
892 bool qltyFlag =
spr::goodTrack(pTrack,leadPV,oneCutParameters,
false);
895 oneCutParameters.
maxDzPV = 100;
906 << qltyFlag <<
"|" << trkDetItr->okECAL
907 <<
"|" << trkDetItr->okHCAL
908 <<
" eIsolation " << eIsolation;
910 t_qltyFlag = (qltyFlag && trkDetItr->okECAL && trkDetItr->okHCAL);
914 std::vector<DetId> eIds;
915 std::vector<double> eHit;
917 endcapRecHitsHandle, trkDetItr->pointHCAL,
919 trkDetItr->directionECAL, eIds, eHit);
921 for (
unsigned int k=0;
k<eIds.size(); ++
k) {
926 if (eHit[k] > eThr) eEcal += eHit[
k];
940 int nRecHits(-999), nRecHits1(-999), nRecHits3(-999);
941 std::vector<DetId>
ids, ids1, ids3;
942 std::vector<double> edet0, edet1, edet3;
945 trkDetItr->directionHCAL,nRecHits,
952 trkDetItr->directionHCAL,nRecHits1,
959 trkDetItr->directionHCAL,nRecHits3,
969 <<
" (pt|eta|phi|p) :" <<
t_pt 970 <<
"|" << pTrack->
eta() <<
"|" 972 <<
" Generator Level p " 976 <<
" eHcal" <<
t_eHcal <<
" ieta " 977 << t_ieta <<
" Quality " 980 for (
unsigned int ll=0; ll<
t_DetIds->size(); ll++) {
982 <<
" hit enery is = " 985 for (
unsigned int ll=0; ll<
t_DetIds1->size(); ll++) {
987 <<
" hit enery is = " 990 for (
unsigned int ll=0; ll<
t_DetIds3->size(); ll++) {
992 <<
" hit enery is = " 1004 if (
t_p > 40.0 &&
t_p <= 60.0 && t_selectTk) {
1018 std::array<int,3> i3{ {nSave,
nLoose,nTight} };
1023 return reco::deltaR(vec1.eta(),vec1.phi(),vec2.eta(),vec2.phi());
1031 double mindR(999.9);
1032 for (
const auto &
p : (*genParticles)) {
1034 p.momentum().Eta(),
p.momentum().Phi());
1036 mindR =
dR; pmom =
p.momentum().R();
1045 std::vector<double> sumPFNallSMDQH2;
1051 for (
const auto & pf_it : (*tower)) {
1054 hadder += pf_it.hadEt();
1056 sumPFNallSMDQH2.emplace_back(hadder);
1061 std::sort(sumPFNallSMDQH2.begin(),sumPFNallSMDQH2.end());
1062 if (sumPFNallSMDQH2.size()%2) evt_smdq = sumPFNallSMDQH2[(sumPFNallSMDQH2.size()-1)/2];
1063 else evt_smdq = (sumPFNallSMDQH2[sumPFNallSMDQH2.size()/2]+sumPFNallSMDQH2[(sumPFNallSMDQH2.size()-2)/2])/2.;
1072 const std::vector<DetId>&
ids,
1073 std::vector<double>& edet,
1075 std::vector<unsigned int> *detIds,
1076 std::vector<double> *hitEnergies) {
1079 for (
unsigned int k=0;
k<ids.size(); ++
k) {
1081 if (corr != 0) edet[
k] /=
corr;
1085 for (
const auto& en : edet) ehcal += en;
1088 edm::LogWarning(
"HcalIsoTrack") <<
"Check inconsistent energies: " << indx
1089 <<
" " << eHcal <<
":" << ehcal
1090 <<
" from " << ids.size() <<
" cells";
1094 std::map<HcalDetId,double> hitMap;
1095 for (
unsigned int k=0;
k<ids.size(); ++
k) {
1097 auto itr = hitMap.find(
id);
1098 if (itr == hitMap.end()) {
1099 hitMap[
id] = edet[
k];
1101 (itr->second) += edet[k];
1104 detIds->reserve(hitMap.size()); hitEnergies->reserve(hitMap.size());
1105 for (
const auto&
hit : hitMap) {
1106 detIds->emplace_back(
hit.first.rawId());
1107 hitEnergies->emplace_back(
hit.second);
1110 detIds->reserve(ids.size()); hitEnergies->reserve(ids.size());
1111 for (
unsigned int k=0;
k<ids.size(); ++
k) {
1112 detIds->emplace_back(ids[
k].rawId());
1113 hitEnergies->emplace_back(edet[
k]);
1118 << ids.size() <<
" cells";
1119 for (
unsigned int k=0;
k<ids.size(); ++
k)
1123 << detIds->size() <<
" cells and Etot " 1125 for (
unsigned int k=0; k<detIds->size(); ++
k)
1128 << (*hitEnergies)[
k];
unsigned int size() const
number of trigger paths in trigger table
static const std::string kSharedResource
const std::string labelHBHE_
constexpr double deltaPhi(double phi1, double phi2)
const std::vector< std::string > trigNames_
double p() const
momentum vector magnitude
double eCone_hcal(const CaloGeometry *geo, edm::Handle< T > &hits, const GlobalPoint &hpoint1, const GlobalPoint &point1, double dR, const GlobalVector &trackMom, int &nRecHits, double hbThr=-100, double heThr=-100, double hfThr=-100, double hoThr=-100, double tMin=-500, double tMax=500, int detOnly=-1, int useRaw=0, bool debug=false)
spr::trackSelectionParameters selectionParameter_
T getParameter(std::string const &) const
EventNumber_t event() const
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 unsigned int nTracks(const reco::Vertex &sv)
const std::string l1TrigName_
const double maxRestrictionP_
edm::EDGetTokenT< EcalRecHitCollection > tok_EE_
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
The single EDProduct to be saved for each event (AOD case)
trigger::size_type sizeFilters() const
const std::string labelRecVtx_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
TrackQuality
track quality
HcalDetId mergedDepthDetId(const HcalDetId &id) const
const std::string labelTower_
#define DEFINE_FWK_MODULE(type)
std::vector< int > * t_ietaAll
bool accept() const
Has at least one path accepted the event?
const Keys & filterKeys(trigger::size_type index) const
int bunchCrossing() const
edm::LuminosityBlockNumber_t luminosityBlock() const
double phi() const
azimuthal angle of momentum vector
T * make(const Args &...args) const
make new ROOT object
edm::EDGetTokenT< BXVector< GlobalAlgBlk > > tok_alg_
const Item * getValues(DetId fId, bool throwOnFail=true) const
edm::EDGetTokenT< EcalRecHitCollection > tok_EB_
std::vector< double > * t_HitEnergies
double chargeIsolationCone(unsigned int trkIndex, std::vector< spr::propagatedTrackDirection > &trkDirs, double dR, int &nNearTRKs, bool debug=false)
virtual void beginRun(edm::Run const &, edm::EventSetup const &) override
edm::EDGetTokenT< reco::TrackCollection > tok_genTrack_
double px() const
x coordinate of momentum vector
void storeEnergy(int indx, const HcalRespCorrs *respCorrs, const std::vector< DetId > &ids, std::vector< double > &edet, double &eHcal, std::vector< unsigned int > *detIds, std::vector< double > *hitEnergies)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::vector< double > etabins_
Strings const & triggerNames() const
std::vector< unsigned int > * t_DetIds
const std::string names[nVars_]
edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
std::vector< double > * t_HitEnergies1
virtual void analyze(edm::Event const &, edm::EventSetup const &) override
static const bool useL1GtTriggerMenuLite(true)
edm::EDGetTokenT< reco::GenParticleCollection > tok_parts_
const bool ignoreTrigger_
unsigned int triggerIndex(const std::string &triggerName) const
slot position of trigger path in trigger table (0 to size-1)
Single trigger physics object (e.g., an isolated muon)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
static const bool useL1EventSetup(false)
edm::EDGetTokenT< trigger::TriggerEvent > tok_trigEvt_
std::vector< double > * t_HitEnergies3
const std::string labelGenTrack_
double eta() const
pseudorapidity of momentum vector
edm::EDGetTokenT< reco::BeamSpot > tok_bs_
double trackP(const reco::Track *, const edm::Handle< reco::GenParticleCollection > &)
edm::EDGetTokenT< GenEventInfoProduct > tok_ew_
edm::Service< TFileService > fs
bool goodTrack(const reco::Track *pTrack, math::XYZPoint leadPV, trackSelectionParameters parameters, bool debug=false)
const TriggerObjectCollection & getObjects() const
std::vector< double > vec1
const bool collapseDepth_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
l1t::L1TGlobalUtil * l1GtUtils_
unsigned int size() const
Get number of paths stored.
double pt() const
track transverse momentum
std::vector< bool > * t_hltbits
int ieta() const
get the cell ieta
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Abs< T >::type abs(const T &t)
double eCone_ecal(const CaloGeometry *geo, edm::Handle< T > &barrelhits, edm::Handle< T > &endcaphits, const GlobalPoint &hpoint1, const GlobalPoint &point1, double dR, const GlobalVector &trackMom, int &nRecHits, double ebThr=-100, double eeThr=-100, double tMin=-500, double tMax=500, bool debug=false)
static std::string const triggerResults
ParameterDescriptionBase * add(U const &iLabel, T const &value)
HLTConfigProvider hltConfig_
const std::string l3Filter_
double pz() const
z coordinate of momentum vector
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
std::vector< bool > * t_trgbits
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
int iphi() const
get the cell iphi
const double slopeRestrictionP_
const edm::InputTag filterTag(trigger::size_type index) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
static TrackQuality qualityByName(const std::string &name)
const std::string l2Filter_
T const * product() const
const std::string processName_
XYZPointD XYZPoint
point in space with cartesian internal representation
std::vector< size_type > Keys
const std::string labelEB_
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d'tor
std::vector< double > phibins_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
double rhoh(const edm::Handle< CaloTowerCollection > &)
double dR(math::XYZTLorentzVector &, math::XYZTLorentzVector &)
const edm::InputTag theTriggerResultsLabel_
virtual void endRun(edm::Run const &, edm::EventSetup const &) override
HcalIsoTrkAnalyzer(edm::ParameterSet const &)
const HcalDDDRecConstants * hdc_
reco::TrackBase::TrackQuality minQuality
const std::vector< std::pair< std::string, bool > > & decisionsFinal()
const JetExtendedData & getValue(const Container &, const reco::JetBaseRef &)
get value for the association. Throw exception if no association found
const Point & position() const
position
std::vector< unsigned int > * t_DetIds1
edm::EDGetTokenT< edm::TriggerResults > tok_trigRes_
const edm::InputTag triggerEvent_
std::vector< int > * t_ietaGood
virtual void beginJob() override
std::array< int, 3 > fillTree(std::vector< math::XYZTLorentzVector > &vecL1, std::vector< math::XYZTLorentzVector > &vecL3, math::XYZPoint &leadPV, std::vector< spr::propagatedTrackDirection > &trkCaloDirections, const CaloGeometry *geo, edm::Handle< EcalRecHitCollection > &barrelRecHitsHandle, edm::Handle< EcalRecHitCollection > &endcapRecHitsHandle, edm::Handle< HBHERecHitCollection > &hbhe, edm::Handle< CaloTowerCollection > &towerHandle, edm::Handle< reco::GenParticleCollection > &genParticles, const HcalRespCorrs *respCorrs)
edm::EDGetTokenT< reco::VertexCollection > tok_recVtx_
edm::EDGetTokenT< CaloTowerCollection > tok_cala_
std::vector< unsigned int > * t_DetIds3
T const * product() const
edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const override
const std::string labelEE_
void setTopo(const HcalTopology *topo)
void retrieveL1(const edm::Event &iEvent, const edm::EventSetup &evSetup)
initialize the class (mainly reserve)
double py() const
y coordinate of momentum vector
const std::string l1Filter_
const std::string theTrackQuality_
std::vector< int > * t_trackType