CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Attributes
reco::tau::PFRecoTauChargedHadronFromTrackPlugin Class Reference
Inheritance diagram for reco::tau::PFRecoTauChargedHadronFromTrackPlugin:
reco::tau::PFRecoTauChargedHadronBuilderPlugin reco::tau::RecoTauEventHolderPlugin reco::tau::RecoTauNamedPlugin

Public Member Functions

virtual void beginEvent ()
 Hook called at the beginning of the event. More...
 
return_type operator() (const reco::PFJet &) const
 Build a collection of chargedHadrons from objects in the input jet. More...
 
 PFRecoTauChargedHadronFromTrackPlugin (const edm::ParameterSet &, edm::ConsumesCollector &&iC)
 
virtual ~PFRecoTauChargedHadronFromTrackPlugin ()
 
- Public Member Functions inherited from reco::tau::PFRecoTauChargedHadronBuilderPlugin
 PFRecoTauChargedHadronBuilderPlugin (const edm::ParameterSet &pset, edm::ConsumesCollector &&iC)
 
virtual ~PFRecoTauChargedHadronBuilderPlugin ()
 
- Public Member Functions inherited from reco::tau::RecoTauEventHolderPlugin
const edm::Eventevt () const
 
edm::Eventevt ()
 
const edm::EventSetupevtSetup () const
 
 RecoTauEventHolderPlugin (const edm::ParameterSet &pset)
 
void setup (edm::Event &, const edm::EventSetup &)
 
virtual ~RecoTauEventHolderPlugin ()
 
- Public Member Functions inherited from reco::tau::RecoTauNamedPlugin
const std::string & name () const
 
 RecoTauNamedPlugin (const edm::ParameterSet &pset)
 
virtual ~RecoTauNamedPlugin ()
 

Private Types

typedef std::vector< reco::PFCandidatePtrPFCandPtrs
 

Private Attributes

double dRcone_
 
bool dRconeLimitedToJetArea_
 
double dRmergeNeutralHadron_
 
double dRmergePhoton_
 
math::XYZVector magneticFieldStrength_
 
int maxWarnings_
 
int numWarnings_
 
RecoTauQualityCutsqcuts_
 
edm::InputTag srcTracks_
 
edm::EDGetTokenT< reco::TrackCollectionTracks_token
 
int verbosity_
 
RecoTauVertexAssociator vertexAssociator_
 

Additional Inherited Members

- Public Types inherited from reco::tau::PFRecoTauChargedHadronBuilderPlugin
typedef boost::ptr_vector< PFRecoTauChargedHadronChargedHadronVector
 
typedef std::auto_ptr< ChargedHadronVectorreturn_type
 

Detailed Description

Definition at line 46 of file PFRecoTauChargedHadronFromTrackPlugin.cc.

Member Typedef Documentation

Definition at line 57 of file PFRecoTauChargedHadronFromTrackPlugin.cc.

Constructor & Destructor Documentation

reco::tau::PFRecoTauChargedHadronFromTrackPlugin::PFRecoTauChargedHadronFromTrackPlugin ( const edm::ParameterSet pset,
edm::ConsumesCollector &&  iC 
)
explicit

Definition at line 79 of file PFRecoTauChargedHadronFromTrackPlugin.cc.

References dRcone_, dRconeLimitedToJetArea_, dRmergeNeutralHadron_, dRmergePhoton_, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterSet(), maxWarnings_, numWarnings_, qcuts_, srcTracks_, Tracks_token, and verbosity_.

82  qcuts_(0)
83 {
84  edm::ParameterSet qcuts_pset = pset.getParameterSet("qualityCuts").getParameterSet("signalQualityCuts");
85  qcuts_ = new RecoTauQualityCuts(qcuts_pset);
86 
87  srcTracks_ = pset.getParameter<edm::InputTag>("srcTracks");
89  dRcone_ = pset.getParameter<double>("dRcone");
90  dRconeLimitedToJetArea_ = pset.getParameter<bool>("dRconeLimitedToJetArea");
91 
92  dRmergeNeutralHadron_ = pset.getParameter<double>("dRmergeNeutralHadron");
93  dRmergePhoton_ = pset.getParameter<double>("dRmergePhoton");
94 
95  numWarnings_ = 0;
96  maxWarnings_ = 3;
97 
98  verbosity_ = ( pset.exists("verbosity") ) ?
99  pset.getParameter<int>("verbosity") : 0;
100 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
bool exists(std::string const &parameterName) const
checks if a parameter exists
ParameterSet const & getParameterSet(std::string const &) const
def move(src, dest)
Definition: eostools.py:510
PFRecoTauChargedHadronBuilderPlugin(const edm::ParameterSet &pset, edm::ConsumesCollector &&iC)
reco::tau::PFRecoTauChargedHadronFromTrackPlugin::~PFRecoTauChargedHadronFromTrackPlugin ( )
virtual

Definition at line 102 of file PFRecoTauChargedHadronFromTrackPlugin.cc.

References qcuts_.

Member Function Documentation

void reco::tau::PFRecoTauChargedHadronFromTrackPlugin::beginEvent ( )
virtual

Hook called at the beginning of the event.

Reimplemented from reco::tau::PFRecoTauChargedHadronBuilderPlugin.

Definition at line 108 of file PFRecoTauChargedHadronFromTrackPlugin.cc.

References reco::tau::RecoTauEventHolderPlugin::evt(), reco::tau::RecoTauEventHolderPlugin::evtSetup(), edm::EventSetup::get(), MagneticField::inTesla(), seedCreatorFromRegionConsecutiveHitsEDProducer_cff::magneticField, magneticFieldStrength_, reco::tau::RecoTauVertexAssociator::setEvent(), and vertexAssociator_.

109 {
110  vertexAssociator_.setEvent(*this->evt());
111 
113  evtSetup()->get<IdealMagneticFieldRecord>().get(magneticField);
114  magneticFieldStrength_ = magneticField->inTesla(GlobalPoint(0.,0.,0.));
115 }
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
void setEvent(const edm::Event &evt)
Load the vertices from the event.
const edm::EventSetup * evtSetup() const
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
const T & get() const
Definition: EventSetup.h:56
PFRecoTauChargedHadronFromTrackPlugin::return_type reco::tau::PFRecoTauChargedHadronFromTrackPlugin::operator() ( const reco::PFJet ) const
virtual

Build a collection of chargedHadrons from objects in the input jet.

Implements reco::tau::PFRecoTauChargedHadronBuilderPlugin.

Definition at line 131 of file PFRecoTauChargedHadronFromTrackPlugin.cc.

References reco::tau::RecoTauVertexAssociator::associatedVertex(), muons2muons_cfi::chargedHadron, DEFINE_EDM_PLUGIN, reco::deltaR(), PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, dRcone_, dRconeLimitedToJetArea_, CaloRecoTauDiscriminationAgainstMuon_cfi::dRmatch, dRmergeNeutralHadron_, dRmergePhoton_, reco::LeafCandidate::eta(), reco::tau::RecoTauEventHolderPlugin::evt(), reco::tau::RecoTauQualityCuts::filterTrack(), reco::PFCandidate::gamma, edm::Event::getByToken(), reco::PFJet::getPFConstituents(), reco::PFCandidate::h0, edm::Ref< C, T, F >::isNonnull(), reco::Jet::jetArea(), reco::PFRecoTauChargedHadron::kTrack, magneticFieldStrength_, maxWarnings_, Min(), reco::tau::RecoTauNamedPlugin::name(), numWarnings_, convertSQLitetoXML_cfg::output, reco::LeafCandidate::phi(), Pi, reco::LeafCandidate::pt(), qcuts_, ctppsDiamondLocalTracks_cfi::resolution, RawParticle::setCharge(), reco::tau::setChargedHadronP4(), reco::tau::RecoTauQualityCuts::setPV(), mathSSE::sqrt(), HiIsolationCommonParameters_cff::track, l1t::tracks, Tracks_token, verbosity_, vertexAssociator_, and badGlobalMuonTaggersAOD_cff::vtx.

132 {
133  if ( verbosity_ ) {
134  edm::LogPrint("TauChHFromTrack") << "<PFRecoTauChargedHadronFromTrackPlugin::operator()>:" ;
135  edm::LogPrint("TauChHFromTrack") << " pluginName = " << name() ;
136  }
137 
139 
140  const edm::Event& evt = (*this->evt());
141 
143  evt.getByToken(Tracks_token, tracks);
144 
146  float jEta=jet.eta();
147  float jPhi=jet.phi();
148  size_t numTracks = tracks->size();
149  for ( size_t iTrack = 0; iTrack < numTracks; ++iTrack ) {
150  reco::TrackRef track(tracks, iTrack);
151 
152  // consider tracks in vicinity of tau-jet candidate only
153  double dR = deltaR(track->eta(), track->phi(), jEta,jPhi);
154  double dRmatch = dRcone_;
155  if ( dRconeLimitedToJetArea_ ) {
156  double jetArea = jet.jetArea();
157  if ( jetArea > 0. ) {
158  dRmatch = TMath::Min(dRmatch, TMath::Sqrt(jetArea/TMath::Pi()));
159  } else {
160  if ( numWarnings_ < maxWarnings_ ) {
161  edm::LogInfo("PFRecoTauChargedHadronFromTrackPlugin::operator()")
162  << "Jet: Pt = " << jet.pt() << ", eta = " << jet.eta() << ", phi = " << jet.phi() << " has area = " << jetArea << " !!" << std::endl;
163  ++numWarnings_;
164  }
165  dRmatch = 0.1;
166  }
167  }
168  if ( dR > dRmatch ) continue;
169 
170  // ignore tracks which fail quality cuts
171  if ( !qcuts_->filterTrack(track) ) continue;
172 
173  reco::Candidate::Charge trackCharge_int = 0;
174  if ( track->charge() > 0. ) trackCharge_int = +1;
175  else if ( track->charge() < 0. ) trackCharge_int = -1;
176 
177  const double chargedPionMass = 0.13957; // GeV
178  double chargedPionP = track->p();
179  double chargedPionEn = TMath::Sqrt(chargedPionP*chargedPionP + chargedPionMass*chargedPionMass);
180  reco::Candidate::LorentzVector chargedPionP4(track->px(), track->py(), track->pz(), chargedPionEn);
181 
182  reco::Vertex::Point vtx(0.,0.,0.);
184 
185  std::auto_ptr<PFRecoTauChargedHadron> chargedHadron(new PFRecoTauChargedHadron(trackCharge_int, chargedPionP4, vtx, 0, true, PFRecoTauChargedHadron::kTrack));
186  chargedHadron->track_ = edm::Ptr<reco::Track>(tracks, iTrack);
187 
188  // CV: Take code for propagating track to ECAL entrance
189  // from RecoParticleFlow/PFTracking/src/PFTrackTransformer.cc
190  // to make sure propagation is done in the same way as for charged PFCandidates.
191  //
192  // The following replacements need to be made
193  // outerMomentum -> momentum
194  // outerPosition -> referencePoint
195  // in order to run on AOD input
196  // (outerMomentum and outerPosition require access to reco::TrackExtra objects, which are available in RECO only)
197  //
198  XYZTLorentzVector chargedPionPos(track->referencePoint().x(), track->referencePoint().y(), track->referencePoint().z(), 0.);
199  BaseParticlePropagator trackPropagator(RawParticle(chargedPionP4, chargedPionPos), 0., 0., magneticFieldStrength_.z());
200  trackPropagator.setCharge(track->charge());
201  trackPropagator.propagateToEcalEntrance(false);
202  if ( trackPropagator.getSuccess() != 0 ) {
203  chargedHadron->positionAtECALEntrance_ = trackPropagator.vertex();
204  } else {
205  if ( chargedPionP4.pt() > 2. ) {
206  edm::LogWarning("PFRecoTauChargedHadronFromTrackPlugin::operator()")
207  << "Failed to propagate track: Pt = " << track->pt() << ", eta = " << track->eta() << ", phi = " << track->phi() << " to ECAL entrance !!" << std::endl;
208  }
209  chargedHadron->positionAtECALEntrance_ = math::XYZPointF(0.,0.,0.);
210  }
211 
212  std::vector<PFCandidate_withDistance> neutralJetConstituents_withDistance;
213  std::vector<reco::PFCandidatePtr> jetConstituents = jet.getPFConstituents();
214  for ( std::vector<reco::PFCandidatePtr>::const_iterator jetConstituent = jetConstituents.begin();
215  jetConstituent != jetConstituents.end(); ++jetConstituent ) {
216  reco::PFCandidate::ParticleType jetConstituentType = (*jetConstituent)->particleId();
217  if ( !(jetConstituentType == reco::PFCandidate::h0 || jetConstituentType == reco::PFCandidate::gamma) ) continue;
218  double dR = deltaR((*jetConstituent)->positionAtECALEntrance(), chargedHadron->positionAtECALEntrance_);
219  double dRmerge = -1.;
220  if ( jetConstituentType == reco::PFCandidate::h0 ) dRmerge = dRmergeNeutralHadron_;
221  else if ( jetConstituentType == reco::PFCandidate::gamma ) dRmerge = dRmergePhoton_;
222  if ( dR < dRmerge ) {
223  PFCandidate_withDistance jetConstituent_withDistance;
224  jetConstituent_withDistance.pfCandidate_ = (*jetConstituent);
225  jetConstituent_withDistance.distance_ = dR;
226  neutralJetConstituents_withDistance.push_back(jetConstituent_withDistance);
227  chargedHadron->addDaughter(*jetConstituent);
228  }
229  }
230  std::sort(neutralJetConstituents_withDistance.begin(), neutralJetConstituents_withDistance.end(), isSmallerDistance);
231 
232  const double caloResolutionCoeff = 1.0; // CV: approximate ECAL + HCAL calorimeter resolution for hadrons by 100%*sqrt(E)
233  double resolutionTrackP = track->p()*(track->ptError()/track->pt());
234  double neutralEnSum = 0.;
235  for ( std::vector<PFCandidate_withDistance>::const_iterator nextNeutral = neutralJetConstituents_withDistance.begin();
236  nextNeutral != neutralJetConstituents_withDistance.end(); ++nextNeutral ) {
237  double nextNeutralEn = nextNeutral->pfCandidate_->energy();
238  double resolutionCaloEn = caloResolutionCoeff*sqrt(neutralEnSum + nextNeutralEn);
239  double resolution = sqrt(resolutionTrackP*resolutionTrackP + resolutionCaloEn*resolutionCaloEn);
240  if ( (neutralEnSum + nextNeutralEn) < (track->p() + 2.*resolution) ) {
241  chargedHadron->neutralPFCandidates_.push_back(nextNeutral->pfCandidate_);
242  neutralEnSum += nextNeutralEn;
243  } else {
244  break;
245  }
246  }
247 
249 
250  if ( verbosity_ ) {
251  edm::LogPrint("TauChHFromTrack") << *chargedHadron;
252  }
253 
254  output.push_back(chargedHadron);
255  }
256 
257  return output.release();
258 }
const double Pi
void setCharge(float q)
set the MEASURED charge
Definition: RawParticle.cc:139
int Charge
electric charge type
Definition: Candidate.h:35
ParticleType
particle types
Definition: PFCandidate.h:44
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:252
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
reco::VertexRef associatedVertex(const PFJet &jet) const
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
Definition: Point3D.h:10
T Min(T a, T b)
Definition: MathUtil.h:39
boost::ptr_vector< PFRecoTauChargedHadron > ChargedHadronVector
void setPV(const reco::VertexRef &vtx) const
Update the primary vertex.
T sqrt(T t)
Definition: SSEVec.h:18
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:28
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
const std::string & name() const
void setChargedHadronP4(reco::PFRecoTauChargedHadron &chargedHadron, double scaleFactor_neutralPFCands=1.0)
bool filterTrack(const reco::TrackBaseRef &track) const
Filter a single Track.
math::XYZTLorentzVector XYZTLorentzVector
Definition: RawParticle.h:15

Member Data Documentation

double reco::tau::PFRecoTauChargedHadronFromTrackPlugin::dRcone_
private
bool reco::tau::PFRecoTauChargedHadronFromTrackPlugin::dRconeLimitedToJetArea_
private
double reco::tau::PFRecoTauChargedHadronFromTrackPlugin::dRmergeNeutralHadron_
private
double reco::tau::PFRecoTauChargedHadronFromTrackPlugin::dRmergePhoton_
private
math::XYZVector reco::tau::PFRecoTauChargedHadronFromTrackPlugin::magneticFieldStrength_
private

Definition at line 71 of file PFRecoTauChargedHadronFromTrackPlugin.cc.

Referenced by beginEvent(), and operator()().

int reco::tau::PFRecoTauChargedHadronFromTrackPlugin::maxWarnings_
private
int reco::tau::PFRecoTauChargedHadronFromTrackPlugin::numWarnings_
mutableprivate
RecoTauQualityCuts* reco::tau::PFRecoTauChargedHadronFromTrackPlugin::qcuts_
private
edm::InputTag reco::tau::PFRecoTauChargedHadronFromTrackPlugin::srcTracks_
private
edm::EDGetTokenT<reco::TrackCollection> reco::tau::PFRecoTauChargedHadronFromTrackPlugin::Tracks_token
private
int reco::tau::PFRecoTauChargedHadronFromTrackPlugin::verbosity_
private
RecoTauVertexAssociator reco::tau::PFRecoTauChargedHadronFromTrackPlugin::vertexAssociator_
private

Definition at line 59 of file PFRecoTauChargedHadronFromTrackPlugin.cc.

Referenced by beginEvent(), and operator()().