13 #include <boost/regex.hpp>
79 namespace AlCaIsoTracks {
92 return std::make_unique<AlCaIsoTracks::Counters>();
104 const std::vector<std::string>& triggerNames_,
155 trigNames_(iConfig.getParameter<std::
vector<std::
string> >(
"triggers")),
156 theTrackQuality_(iConfig.getParameter<std::
string>(
"trackQuality")),
157 processName_(iConfig.getParameter<std::
string>(
"processName")),
158 a_coneR_(iConfig.getParameter<double>(
"coneRadius")),
159 a_mipR_(iConfig.getParameter<double>(
"coneRadiusMIP")),
160 maxRestrictionP_(iConfig.getParameter<double>(
"maxTrackP")),
161 slopeRestrictionP_(iConfig.getParameter<double>(
"slopeTrackP")),
162 pTrackMin_(iConfig.getParameter<double>(
"minimumTrackP")),
163 eEcalMax_(iConfig.getParameter<double>(
"maximumEcalEnergy")),
164 eIsolate_(iConfig.getParameter<double>(
"isolationEnergy")),
165 pTrackLow_(iConfig.getParameter<double>(
"momentumRangeLow")),
166 pTrackHigh_(iConfig.getParameter<double>(
"momentumRangeHigh")),
167 preScale_(iConfig.getParameter<int>(
"preScaleFactor")),
168 labelGenTrack_(iConfig.getParameter<edm::
InputTag>(
"TrackLabel")),
169 labelRecVtx_(iConfig.getParameter<edm::
InputTag>(
"VertexLabel")),
170 labelBS_(iConfig.getParameter<edm::
InputTag>(
"BeamSpotLabel")),
171 labelEB_(iConfig.getParameter<edm::
InputTag>(
"EBRecHitLabel")),
172 labelEE_(iConfig.getParameter<edm::
InputTag>(
"EERecHitLabel")),
173 labelHBHE_(iConfig.getParameter<edm::
InputTag>(
"HBHERecHitLabel")),
174 labelHltGT_(iConfig.getParameter<edm::
InputTag>(
"L1GTSeedLabel")),
175 labelTriggerEvent_(iConfig.getParameter<edm::
InputTag>(
"TriggerEventLabel")),
176 labelTriggerResults_(iConfig.getParameter<edm::
InputTag>(
"TriggerResultLabel")),
177 labelIsoTk_(iConfig.getParameter<std::
string>(
"IsoTrackLabel")) {
184 const double isolationRadius(28.9);
209 tok_geom_ = esConsumes<CaloGeometry, CaloGeometryRecord, edm::Transition::BeginRun>();
210 tok_magField_ = esConsumes<MagneticField, IdealMagneticFieldRecord, edm::Transition::BeginRun>();
222 <<
"\t a_coneR " <<
a_coneR_ <<
"\t a_charIsoR " << a_charIsoR_ <<
"\t a_mipR "
233 produces<reco::HcalIsolatedTrackCandidateCollection>(
labelIsoTk_);
239 edm::LogVerbatim(
"HcalIsoTrack") <<
" Expected to produce the collections:\n"
240 <<
"reco::HcalIsolatedTrackCandidateCollection "
241 <<
" with label HcalIsolatedTrackCollection\n"
243 <<
"EcalRecHitCollection with label EcalRecHitsEB\n"
244 <<
"EcalRecHitCollection with label EcalRecHitsEE\n"
262 desc.
add<
std::string>(
"IsoTrackLabel",
"HcalIsolatedTrackCollection");
263 std::vector<std::string> triggers = {
"HLT_IsoTrackHB",
"HLT_IsoTrackHE"};
264 desc.
add<std::vector<std::string> >(
"triggers", triggers);
268 desc.
add<
double>(
"minTrackPt", 1.0);
269 desc.
add<
double>(
"maxDxyPV", 10.0);
270 desc.
add<
double>(
"maxDzPV", 100.0);
271 desc.
add<
double>(
"maxChi2", 5.0);
272 desc.
add<
double>(
"maxDpOverP", 0.1);
273 desc.
add<
int>(
"minOuterHit", 4);
274 desc.
add<
int>(
"minLayerCrossed", 8);
275 desc.
add<
int>(
"maxInMiss", 2);
276 desc.
add<
int>(
"maxOutMiss", 2);
278 desc.
add<
double>(
"coneRadius", 34.98);
279 desc.
add<
double>(
"minimumTrackP", 20.0);
281 desc.
add<
double>(
"coneRadiusMIP", 14.0);
282 desc.
add<
double>(
"maximumEcalEnergy", 2.0);
284 desc.
add<
double>(
"maxTrackP", 8.0);
285 desc.
add<
double>(
"slopeTrackP", 0.05090504066);
286 desc.
add<
double>(
"isolationEnergy", 10.0);
288 desc.
add<
double>(
"momentumRangeLow", 20.0);
289 desc.
add<
double>(
"momentumRangeHigh", 40.0);
290 desc.
add<
int>(
"preScaleFactor", 10);
291 descriptions.
add(
"alcaisotrk", desc);
304 if (!triggerEventHandle.isValid()) {
315 if (!trkCollection.isValid()) {
321 if (!recVtxs.isValid()) {
329 if (!recVtxs->empty() && !((*recVtxs)[0].isFake())) {
330 leadPV =
math::XYZPoint((*recVtxs)[0].
x(), (*recVtxs)[0].
y(), (*recVtxs)[0].
z());
331 }
else if (beamSpotH.isValid()) {
332 leadPV = beamSpotH->position();
340 if (!barrelRecHitsHandle.isValid()) {
345 if (!endcapRecHitsHandle.isValid()) {
350 if (!hbhe.isValid()) {
356 double ptL1(0), etaL1(0), phiL1(0);
359 if (l1trigobj.isValid()) {
360 std::vector<edm::Ref<l1extra::L1JetParticleCollection> > l1tauobjref;
364 std::vector<edm::Ref<l1extra::L1JetParticleCollection> > l1jetobjref;
368 std::vector<edm::Ref<l1extra::L1JetParticleCollection> > l1forjetobjref;
375 auto outputHcalIsoTrackColl = std::make_unique<reco::HcalIsolatedTrackCandidateCollection>();
376 auto outputVColl = std::make_unique<reco::VertexCollection>();
377 auto outputEBColl = std::make_unique<EBRecHitCollection>();
378 auto outputEEColl = std::make_unique<EERecHitCollection>();
379 auto outputHBHEColl = std::make_unique<HBHERecHitCollection>();
383 edm::LogWarning(
"HcalIsoTrack") <<
"Error! Can't get some of the products";
388 const std::vector<std::string>& triggerNames_ = triggerNames.
triggerNames();
400 edm::LogVerbatim(
"HcalIsoTrack") <<
"AlCaIsoTracksProducer::select returns " << isotk->size()
401 <<
" isolated tracks";
404 if (!isotk->empty()) {
405 int ntrin(0), ntrout(0);
406 for (reco::HcalIsolatedTrackCandidateCollection::const_iterator itr = isotk->begin(); itr != isotk->end();
413 bool selectEvent = ntrout > 0;
414 if (!selectEvent && ntrin > 0) {
422 for (reco::HcalIsolatedTrackCandidateCollection::const_iterator itr = isotk->begin(); itr != isotk->end();
424 outputHcalIsoTrackColl->push_back(*itr);
426 for (reco::VertexCollection::const_iterator vtx = recVtxs->begin(); vtx != recVtxs->end(); ++vtx)
427 outputVColl->push_back(*vtx);
430 ehit != barrelRecHitsHandle->end();
432 outputEBColl->push_back(*ehit);
435 ehit != endcapRecHitsHandle->end();
437 outputEEColl->push_back(*ehit);
439 for (std::vector<HBHERecHit>::const_iterator hhit = hbhe->begin(); hhit != hbhe->end(); ++hhit)
440 outputHBHEColl->push_back(*hhit);
454 globalCache()->nAll_ +=
nAll_;
455 globalCache()->nGood_ +=
nGood_;
456 globalCache()->nRange_ +=
nRange_;
461 << count->
nRange_ <<
" events in the momentum raange";
480 const std::vector<std::string>& triggerNames_,
493 for (
unsigned int iHLT = 0; iHLT < triggerResults->size(); iHLT++) {
494 int hlt = triggerResults->accept(iHLT);
500 edm::LogVerbatim(
"HcalIsoTrack") <<
"The trigger we are looking for " << triggerNames_[iHLT] <<
" Flag " << hlt
507 std::vector<spr::propagatedTrackDirection> trkCaloDirections;
510 std::vector<spr::propagatedTrackDirection>::const_iterator trkDetItr;
511 unsigned int nTracks(0), nselTracks(0);
512 for (trkDetItr = trkCaloDirections.begin(),
nTracks = 0; trkDetItr != trkCaloDirections.end();
514 const reco::Track* pTrack = &(*(trkDetItr->trkItr));
518 << pTrack->
eta() <<
"|" << pTrack->
phi() <<
"|" << pTrack->
p();
523 edm::LogVerbatim(
"HcalIsoTrack") <<
"qltyFlag|okECAL|okHCAL : " << qltyFlag <<
"|" << trkDetItr->okECAL <<
"|"
524 << trkDetItr->okHCAL;
526 if (qltyFlag && trkDetItr->okECAL && trkDetItr->okHCAL) {
527 double t_p = pTrack->
p();
529 int nRH_eMipDR(0), nNearTRKs(0);
533 trkDetItr->pointHCAL,
534 trkDetItr->pointECAL,
536 trkDetItr->directionECAL,
546 << pTrack->
eta() <<
"|" << pTrack->
phi() <<
"|" << t_p <<
" e_MIP " << eMipDR
547 <<
" Chg Isolation " << hmaxNearP <<
":" << eIsolation;
551 newCandidate.
SetMaxP(hmaxNearP);
553 newCandidate.
setL1(ptL1, etaL1, phiL1);
554 newCandidate.
SetEtaPhiEcal((trkDetItr->pointECAL).eta(), (trkDetItr->pointECAL).
phi());
557 (trkDetItr->pointHCAL).eta(), (trkDetItr->pointHCAL).
phi(), detId.
ieta(), detId.
iphi());
559 for (reco::TrackCollection::const_iterator trkItr1 = trkCollection->begin(); trkItr1 != trkCollection->end();
562 if (pTrack1 == pTrack) {
568 trackCollection->push_back(newCandidate);
579 for (
unsigned int p = 0;
p < objref.size();
p++) {
580 if (objref[
p]->
pt() > ptL1) {
581 ptL1 = objref[
p]->pt();
582 phiL1 = objref[
p]->phi();
583 etaL1 = objref[
p]->eta();
double p() const
momentum vector magnitude
Log< level::Info, true > LogVerbatim
EventNumber_t event() const
reco::HcalIsolatedTrackCandidateCollection * select(edm::Handle< edm::TriggerResults > const &triggerResults, const std::vector< std::string > &triggerNames_, edm::Handle< reco::TrackCollection > &trkCollection, math::XYZPoint &leadPV, edm::Handle< EcalRecHitCollection > &barrelRecHitsHandle, edm::Handle< EcalRecHitCollection > &endcapRecHitsHandle, edm::Handle< HBHERecHitCollection > &hbhe, double ptL1, double etaL1, double phiL1)
const std::string labelIsoTk_
std::vector< spr::propagatedTrackID > propagateCALO(edm::Handle< reco::TrackCollection > &trkCollection, const CaloGeometry *geo, const MagneticField *bField, const std::string &theTrackQuality, bool debug=false)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
constexpr int ietaAbs() const
get the absolute value of the cell ieta
const edm::InputTag labelEE_
The single EDProduct to be saved for each event (AOD case)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
AlCaIsoTracksProducer(edm::ParameterSet const &, const AlCaIsoTracks::Counters *count)
void endStream() override
#define DEFINE_FWK_MODULE(type)
edm::EDGetTokenT< EcalRecHitCollection > tok_EE_
void beginRun(edm::Run const &, edm::EventSetup const &) override
const edm::InputTag labelHBHE_
std::vector< T >::const_iterator const_iterator
int bunchCrossing() const
edm::EDGetTokenT< reco::TrackCollection > tok_genTrack_
void produce(edm::Event &, edm::EventSetup const &) override
edm::LuminosityBlockNumber_t luminosityBlock() const
double phi() const
azimuthal angle of momentum vector
const edm::InputTag labelHltGT_
const edm::InputTag labelBS_
Exp< T >::type exp(const T &t)
const edm::InputTag labelTriggerEvent_
static void globalEndJob(const AlCaIsoTracks::Counters *counters)
double chargeIsolationCone(unsigned int trkIndex, std::vector< spr::propagatedTrackDirection > &trkDirs, double dR, int &nNearTRKs, bool debug=false)
double px() const
x coordinate of momentum vector
edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > tok_hltGT_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Strings const & triggerNames() const
edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const override
const std::string processName_
bool getData(T &iHolder) const
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
const std::string theTrackQuality_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > tok_geom_
edm::EDGetTokenT< EcalRecHitCollection > tok_EB_
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
edm::EDGetTokenT< reco::BeamSpot > tok_bs_
caConstants::TupleMultiplicity const CAHitNtupletGeneratorKernelsGPU::HitToTuple const cms::cuda::AtomicPairCounter GPUCACell const *__restrict__ uint32_t const *__restrict__ gpuPixelDoublets::CellNeighborsVector const gpuPixelDoublets::CellTracksVector const GPUCACell::OuterHitOfCell const int32_t uint32_t CAHitNtupletGeneratorKernelsGPU::Counters * counters
edm::EDGetTokenT< reco::VertexCollection > tok_recVtx_
double eta() const
pseudorapidity of momentum vector
constexpr int iphi() const
get the cell iphi
std::vector< HcalIsolatedTrackCandidate > HcalIsolatedTrackCandidateCollection
collectin of HcalIsolatedTrackCandidate objects
bool goodTrack(const reco::Track *pTrack, math::XYZPoint leadPV, trackSelectionParameters parameters, bool debug=false)
void SetEtaPhiEcal(double eta, double phi)
eta, phi at ECAL surface
double pt() const
track transverse momentum
void setPtEtaPhi(std::vector< edm::Ref< l1extra::L1JetParticleCollection > > &objref, double &ptL1, double &etaL1, double &phiL1)
edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
void SetEnergyEcal(double a)
void SetEtaPhiHcal(double eta, double phi, int ieta, int iphi)
eta, phi at HCAL surface
constexpr int ieta() const
get the cell ieta
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)
const MagneticField * bField
const double maxRestrictionP_
static std::string const triggerResults
ParameterDescriptionBase * add(U const &iLabel, T const &value)
edm::EDGetTokenT< trigger::TriggerEvent > tok_trigEvt_
double pz() const
z coordinate of momentum vector
std::atomic< unsigned int > nGood_
void endRun(edm::Run const &, edm::EventSetup const &) override
HLTConfigProvider hltConfig_
static TrackQuality qualityByName(const std::string &name)
static std::unique_ptr< AlCaIsoTracks::Counters > initializeGlobalCache(edm::ParameterSet const &)
const double slopeRestrictionP_
void setL1(double pt, double eta, double phi)
XYZPointD XYZPoint
point in space with cartesian internal representation
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d'tor
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
T getParameter(std::string const &) const
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::atomic< unsigned int > nAll_
const std::vector< std::string > trigNames_
spr::trackSelectionParameters selectionParameter_
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > tok_magField_
reco::TrackBase::TrackQuality minQuality
const edm::InputTag labelRecVtx_
void setTrack(const reco::TrackRef &tr)
Log< level::Warning, false > LogWarning
edm::EDGetTokenT< edm::TriggerResults > tok_trigRes_
~AlCaIsoTracksProducer() override
const edm::InputTag labelTriggerResults_
std::atomic< unsigned int > nRange_
const edm::InputTag labelEB_
double py() const
y coordinate of momentum vector
const edm::InputTag labelGenTrack_