13 #include <boost/regex.hpp>
80 namespace AlCaIsoTracks {
136 nRun_(0), nAll_(0), nGood_(0) {
138 const double isolationRadius(28.9);
182 edm::LogInfo(
"HcalIsoTrack") <<
"Parameters read from config file \n"
183 <<
"\t minPt " << maxRestrictionPt_
184 <<
":" << slopeRestrictionPt_
185 <<
"\t theTrackQuality " << theTrackQuality_
195 <<
"\t a_coneR " << a_coneR_
196 <<
"\t a_charIsoR " << a_charIsoR_
198 <<
"\t pTrackMin " << pTrackMin_
199 <<
"\t eEcalMax " << eEcalMax_
200 <<
"\t eIsolation " << eIsolation_
206 produces<reco::HcalIsolatedTrackCandidateCollection>(
labelIsoTk_);
207 produces<reco::VertexCollection>(labelRecVtx_.
label());
208 produces<EcalRecHitCollection>(labelEB_.
instance());
209 produces<EcalRecHitCollection>(labelEE_.
instance());
210 produces<HBHERecHitCollection>(labelHBHE_.
label());
212 edm::LogInfo(
"HcalIsoTrack") <<
" Expected to produce the collections:\n"
213 <<
"reco::HcalIsolatedTrackCandidateCollection "
214 <<
" with label HcalIsolatedTrackCollection\n"
215 <<
"reco::VertexCollection with label " << labelRecVtx_.
label() <<
"\n"
216 <<
"EcalRecHitCollection with label EcalRecHitsEB\n"
217 <<
"EcalRecHitCollection with label EcalRecHitsEE\n"
218 <<
"HBHERecHitCollection with label " << labelHBHE_.
label();
230 << iEvent.
id().
event() <<
" Luminosity "
239 if (!triggerEventHandle.
isValid()) {
245 if (!triggerResults.
isValid()) {
252 if (!trkCollection.
isValid()) {
256 reco::TrackCollection::const_iterator trkItr;
269 if (recVtxs->size()>0 && !((*recVtxs)[0].isFake())) {
272 }
else if (beamSpotH.
isValid()) {
273 leadPV = beamSpotH->position();
277 edm::LogInfo(
"HcalIsoTrack") <<
"Primary Vertex " << leadPV;
282 if (!barrelRecHitsHandle.
isValid()) {
288 if (!endcapRecHitsHandle.
isValid()) {
300 double ptL1(0), etaL1(0), phiL1(0);
305 std::vector< edm::Ref<l1extra::L1JetParticleCollection> > l1tauobjref;
309 std::vector< edm::Ref<l1extra::L1JetParticleCollection> > l1jetobjref;
313 std::vector< edm::Ref<l1extra::L1JetParticleCollection> > l1forjetobjref;
328 edm::LogWarning(
"HcalIsoTrack") <<
"Error! Can't get some of the products";
331 if (triggerResults.
isValid()) {
333 const std::vector<std::string> & triggerNames_ = triggerNames.
triggerNames();
336 edm::LogInfo(
"HcalIsoTrack") <<
"AlCaIsoTracksProducer::select returns "
337 << isotk->size() <<
" isolated tracks";
340 if (isotk->size() > 0) {
341 for (reco::HcalIsolatedTrackCandidateCollection::const_iterator itr=isotk->begin(); itr!=isotk->end(); ++itr)
342 outputHcalIsoTrackColl->push_back(*itr);
344 for (reco::VertexCollection::const_iterator vtx=recVtxs->begin(); vtx!=recVtxs->end(); ++vtx)
345 outputVColl->push_back(*vtx);
348 outputEBColl->push_back(*ehit);
351 outputEEColl->push_back(*ehit);
353 for (std::vector<HBHERecHit>::const_iterator hhit=hbhe->begin(); hhit!=hbhe->end(); ++hhit)
354 outputHBHEColl->push_back(*hhit);
367 globalCache()->nAll_ +=
nAll_;
368 globalCache()->nGood_ +=
nGood_;
373 << count->
nAll_ <<
" events";
396 const std::vector<std::string> & triggerNames_,
401 double ptL1,
double etaL1,
double phiL1) {
407 for (
unsigned int iHLT=0; iHLT<triggerResults->size(); iHLT++) {
408 int hlt = triggerResults->accept(iHLT);
410 if (triggerNames_[iHLT].
find(
trigNames_[
i].c_str())!=std::string::npos) {
414 edm::LogInfo(
"HcalIsoTrack") <<
"The trigger we are looking for "
415 << triggerNames_[iHLT] <<
" Flag "
422 std::vector<spr::propagatedTrackDirection> trkCaloDirections;
424 trkCaloDirections,
false);
426 std::vector<spr::propagatedTrackDirection>::const_iterator trkDetItr;
427 unsigned int nTracks(0), nselTracks(0);
428 for (trkDetItr = trkCaloDirections.begin(),nTracks=0;
429 trkDetItr != trkCaloDirections.end(); trkDetItr++,nTracks++) {
430 const reco::Track* pTrack = &(*(trkDetItr->trkItr));
432 pTrack->
pz(), pTrack->
p());
434 edm::LogInfo(
"HcalIsoTrack") <<
"This track : " << nTracks
435 <<
" (pt|eta|phi|p) :" << pTrack->
pt()
436 <<
"|" << pTrack->
eta() <<
"|"
437 << pTrack->
phi() <<
"|" << pTrack->
p();
443 edm::LogInfo(
"HcalIsoTrack") <<
"qltyFlag|okECAL|okHCAL : " << qltyFlag
444 <<
"|" << trkDetItr->okECAL <<
"|"
445 << trkDetItr->okHCAL;
447 if (qltyFlag && trkDetItr->okECAL && trkDetItr->okHCAL) {
448 double t_p = pTrack->
p();
450 int nRH_eMipDR(0), nNearTRKs(0);
453 trkDetItr->pointHCAL,
455 trkDetItr->directionECAL,
462 edm::LogInfo(
"HcalIsoTrack") <<
"This track : " << nTracks
463 <<
" (pt|eta|phi|p) :" << pTrack->
pt()
464 <<
"|" << pTrack->
eta() <<
"|"
465 << pTrack->
phi() <<
"|" << t_p
466 <<
" e_MIP " << eMipDR
467 <<
" Chg Isolation " << hmaxNearP;
471 newCandidate.
SetMaxP(hmaxNearP);
473 newCandidate.
setL1(ptL1,etaL1,phiL1);
475 (trkDetItr->pointECAL).
phi());
478 (trkDetItr->pointHCAL).
phi(),
481 reco::TrackCollection::const_iterator trkItr1;
482 for (trkItr1=trkCollection->begin(); trkItr1 != trkCollection->end(); ++trkItr1,++indx) {
484 if (pTrack1 == pTrack) {
490 trackCollection->push_back(newCandidate);
499 for (
unsigned int p=0;
p<objref.size();
p++) {
500 if (objref[
p]->
pt()>ptL1) {
501 ptL1 = objref[
p]->pt();
502 phiL1 = objref[
p]->phi();
503 etaL1 = objref[
p]->eta();
double p() const
momentum vector magnitude
T getParameter(std::string const &) const
EventNumber_t event() const
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
std::vector< spr::propagatedTrackID > propagateCALO(edm::Handle< reco::TrackCollection > &trkCollection, const CaloGeometry *geo, const MagneticField *bField, std::string &theTrackQuality, bool debug=false)
The single EDProduct to be saved for each event (AOD case)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
AlCaIsoTracksProducer(edm::ParameterSet const &, const AlCaIsoTracks::Counters *count)
virtual void endStream() override
#define DEFINE_FWK_MODULE(type)
edm::EDGetTokenT< EcalRecHitCollection > tok_EE_
virtual void beginRun(edm::Run const &, edm::EventSetup const &) override
std::vector< T >::const_iterator const_iterator
int bunchCrossing() const
edm::EDGetTokenT< reco::TrackCollection > tok_genTrack_
virtual void produce(edm::Event &, edm::EventSetup const &) override
edm::LuminosityBlockNumber_t luminosityBlock() const
double phi() const
azimuthal angle of momentum vector
std::vector< Vertex > VertexCollection
collection of Vertex objects
std::atomic< unsigned int > nAll_
static void globalEndJob(const AlCaIsoTracks::Counters *counters)
double chargeIsolationCone(unsigned int trkIndex, std::vector< spr::propagatedTrackDirection > &trkDirs, double dR, int &nNearTRKs, bool debug=false)
std::string theTrackQuality_
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
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
edm::EDGetTokenT< EcalRecHitCollection > tok_EB_
std::vector< std::string > HLTNames_
edm::EDGetTokenT< reco::BeamSpot > tok_bs_
edm::EDGetTokenT< reco::VertexCollection > tok_recVtx_
double eta() const
pseudorapidity of momentum vector
std::vector< HcalIsolatedTrackCandidate > HcalIsolatedTrackCandidateCollection
collectin of HcalIsolatedTrackCandidate objects
bool goodTrack(const reco::Track *pTrack, math::XYZPoint leadPV, trackSelectionParameters parameters, bool debug=false)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
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_
int ieta() const
get the cell ieta
void SetEnergyEcal(double a)
edm::InputTag labelHltGT_
Abs< T >::type abs(const T &t)
void SetEtaPhiHcal(double eta, double phi, int ieta, int iphi)
eta, phi at HCAL surface
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
static std::string const triggerResults
edm::InputTag labelTriggerEvent_
edm::EDGetTokenT< trigger::TriggerEvent > tok_trigEvt_
double pz() const
z coordinate of momentum vector
virtual void endRun(edm::Run const &, edm::EventSetup const &) override
int iphi() const
get the cell iphi
HLTConfigProvider hltConfig_
edm::InputTag labelTriggerResults_
static TrackQuality qualityByName(const std::string &name)
static std::unique_ptr< AlCaIsoTracks::Counters > initializeGlobalCache(edm::ParameterSet const &)
T const * product() const
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 const * product() const
double slopeRestrictionPt_
spr::trackSelectionParameters selectionParameter_
std::vector< std::string > trigNames_
reco::TrackBase::TrackQuality minQuality
edm::InputTag labelRecVtx_
void setTrack(const reco::TrackRef &tr)
edm::InputTag labelGenTrack_
reco::HcalIsolatedTrackCandidateCollection * select(edm::Handle< edm::TriggerResults > &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)
edm::EDGetTokenT< edm::TriggerResults > tok_trigRes_
std::atomic< unsigned int > nGood_
double py() const
y coordinate of momentum vector