CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
reco::tau::RecoTauElectronRejectionPlugin Class Reference
Inheritance diagram for reco::tau::RecoTauElectronRejectionPlugin:
reco::tau::RecoTauModifierPlugin reco::tau::RecoTauEventHolderPlugin reco::tau::RecoTauNamedPlugin

Public Member Functions

void operator() (PFTau &) const override
 
 RecoTauElectronRejectionPlugin (const edm::ParameterSet &pset, edm::ConsumesCollector &&iC)
 
virtual ~RecoTauElectronRejectionPlugin ()
 
- Public Member Functions inherited from reco::tau::RecoTauModifierPlugin
virtual void beginEvent ()
 
virtual void endEvent ()
 
 RecoTauModifierPlugin (const edm::ParameterSet &pset, edm::ConsumesCollector &&iC)
 
virtual ~RecoTauModifierPlugin ()
 
- 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 Attributes

std::string DataType_
 
double EcalStripSumE_deltaEta_
 
double EcalStripSumE_deltaPhiOverQ_maxValue_
 
double EcalStripSumE_deltaPhiOverQ_minValue_
 
double EcalStripSumE_minClusEnergy_
 
double ElecPreIDLeadTkMatch_maxDR_
 
double maximumForElectrionPreIDOutput_
 

Detailed Description

Definition at line 24 of file RecoTauElectronRejectionPlugin.cc.

Constructor & Destructor Documentation

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

Definition at line 39 of file RecoTauElectronRejectionPlugin.cc.

References DataType_, EcalStripSumE_deltaEta_, EcalStripSumE_deltaPhiOverQ_maxValue_, EcalStripSumE_deltaPhiOverQ_minValue_, EcalStripSumE_minClusEnergy_, ElecPreIDLeadTkMatch_maxDR_, edm::ParameterSet::getParameter(), maximumForElectrionPreIDOutput_, and AlCaHLTBitMon_QueryRunRegistry::string.

40  :RecoTauModifierPlugin(pset,std::move(iC)) {
41  // Load parameters
43  pset.getParameter<double>("ElecPreIDLeadTkMatch_maxDR");
45  pset.getParameter<double>("EcalStripSumE_minClusEnergy");
47  pset.getParameter<double>("EcalStripSumE_deltaEta");
49  pset.getParameter<double>("EcalStripSumE_deltaPhiOverQ_minValue");
51  pset.getParameter<double>("EcalStripSumE_deltaPhiOverQ_maxValue");
53  pset.getParameter<double>("maximumForElectrionPreIDOutput");
54  DataType_ = pset.getParameter<std::string>("DataType");
55 }
T getParameter(std::string const &) const
def move
Definition: eostools.py:508
RecoTauModifierPlugin(const edm::ParameterSet &pset, edm::ConsumesCollector &&iC)
virtual reco::tau::RecoTauElectronRejectionPlugin::~RecoTauElectronRejectionPlugin ( )
inlinevirtual

Definition at line 27 of file RecoTauElectronRejectionPlugin.cc.

27 {}

Member Function Documentation

void reco::tau::RecoTauElectronRejectionPlugin::operator() ( PFTau tau) const
overridevirtual

Implements reco::tau::RecoTauModifierPlugin.

Definition at line 70 of file RecoTauElectronRejectionPlugin.cc.

References funct::abs(), assert(), createPayload::block, filterCSVwithJSON::copy, DataType_, HLTFastRecoForTau_cff::deltaEta, reco::deltaPhi(), reco::deltaR(), HLT_25ns14e33_v1_cff::DeltaR, reco::PFBlockElement::ECAL, EcalStripSumE_deltaEta_, EcalStripSumE_deltaPhiOverQ_maxValue_, EcalStripSumE_deltaPhiOverQ_minValue_, EcalStripSumE_minClusEnergy_, reco::PFBlock::elements(), asciidump::elements, reco::PFBlockElement::HCAL, i, edm::Ptr< T >::isNonnull(), edm::Ref< C, T, F >::isNonnull(), reco::PFTau::isolationPFCands(), reco::PFTau::leadPFChargedHadrCand(), maximumForElectrionPreIDOutput_, reco::PFTau::setecalStripSumEOverPLead(), reco::PFTau::setelectronPreIDDecision(), reco::PFTau::setelectronPreIDOutput(), reco::PFTau::setelectronPreIDTrack(), reco::PFTau::setemFraction(), reco::PFTau::sethcal3x3OverPLead(), reco::PFTau::sethcalMaxOverPLead(), reco::PFTau::sethcalTotOverPLead(), reco::PFTau::setmaximumHCALPFClusterEt(), reco::PFTau::signalPFCands(), funct::sin(), and edm::OwnVector< T, P >::size().

70  {
71  // copy pasted from PFRecoTauAlgorithm...
72  double myECALenergy = 0.;
73  double myHCALenergy = 0.;
74  double myHCALenergy3x3 = 0.;
75  double myMaximumHCALPFClusterE = 0.;
76  double myMaximumHCALPFClusterEt = 0.;
77  double myStripClusterE = 0.;
78  double myEmfrac = -1.;
79  double myElectronPreIDOutput = -1111.;
80  bool myElecPreid = false;
81  reco::TrackRef myElecTrk;
82 
83  typedef std::pair<reco::PFBlockRef, unsigned> ElementInBlock;
84  typedef std::vector< ElementInBlock > ElementsInBlocks;
85 
86  PFCandidatePtr myleadPFChargedCand = tau.leadPFChargedHadrCand();
87  // Build list of PFCands in tau
88  std::vector<PFCandidatePtr> myPFCands;
89  myPFCands.reserve(tau.isolationPFCands().size()+tau.signalPFCands().size());
90 
91  std::copy(tau.isolationPFCands().begin(), tau.isolationPFCands().end(),
92  std::back_inserter(myPFCands));
93  std::copy(tau.signalPFCands().begin(), tau.signalPFCands().end(),
94  std::back_inserter(myPFCands));
95 
96  //Use the electron rejection only in case there is a charged leading pion
97  if(myleadPFChargedCand.isNonnull()){
98  myElectronPreIDOutput = myleadPFChargedCand->mva_e_pi();
99 
100  math::XYZPointF myElecTrkEcalPos = myleadPFChargedCand->positionAtECALEntrance();
101  myElecTrk = myleadPFChargedCand->trackRef();//Electron candidate
102 
103  if(myElecTrk.isNonnull()) {
104  //FROM AOD
105  if(DataType_ == "AOD"){
106  // Corrected Cluster energies
107  for(int i=0;i<(int)myPFCands.size();i++){
108  myHCALenergy += myPFCands[i]->hcalEnergy();
109  myECALenergy += myPFCands[i]->ecalEnergy();
110 
111  math::XYZPointF candPos;
112  if (myPFCands[i]->particleId()==1 || myPFCands[i]->particleId()==2)//if charged hadron or electron
113  candPos = myPFCands[i]->positionAtECALEntrance();
114  else
115  candPos = math::XYZPointF(myPFCands[i]->px(),myPFCands[i]->py(),myPFCands[i]->pz());
116 
117  double deltaR = ROOT::Math::VectorUtil::DeltaR(myElecTrkEcalPos,candPos);
118  double deltaPhi = ROOT::Math::VectorUtil::DeltaPhi(myElecTrkEcalPos,candPos);
119  double deltaEta = abs(myElecTrkEcalPos.eta()-candPos.eta());
120  double deltaPhiOverQ = deltaPhi/(double)myElecTrk->charge();
121 
122  if (myPFCands[i]->ecalEnergy() >= EcalStripSumE_minClusEnergy_ && deltaEta < EcalStripSumE_deltaEta_ &&
124  myStripClusterE += myPFCands[i]->ecalEnergy();
125  }
126  if (deltaR<0.184) {
127  myHCALenergy3x3 += myPFCands[i]->hcalEnergy();
128  }
129  if (myPFCands[i]->hcalEnergy()>myMaximumHCALPFClusterE) {
130  myMaximumHCALPFClusterE = myPFCands[i]->hcalEnergy();
131  }
132  if ((myPFCands[i]->hcalEnergy()*fabs(sin(candPos.Theta())))>myMaximumHCALPFClusterEt) {
133  myMaximumHCALPFClusterEt = (myPFCands[i]->hcalEnergy()*fabs(sin(candPos.Theta())));
134  }
135  }
136 
137  } else if(DataType_ == "RECO"){ //From RECO
138  // Against double counting of clusters
139  std::vector<math::XYZPoint> hcalPosV; hcalPosV.clear();
140  std::vector<math::XYZPoint> ecalPosV; ecalPosV.clear();
141  for(int i=0;i<(int)myPFCands.size();i++){
142  const ElementsInBlocks& elts = myPFCands[i]->elementsInBlocks();
143  for(ElementsInBlocks::const_iterator it=elts.begin(); it!=elts.end(); ++it) {
144  const reco::PFBlock& block = *(it->first);
145  unsigned indexOfElementInBlock = it->second;
147  assert(indexOfElementInBlock<elements.size());
148 
149  const reco::PFBlockElement& element = elements[indexOfElementInBlock];
150 
151  if(element.type()==reco::PFBlockElement::HCAL) {
152  math::XYZPoint clusPos = element.clusterRef()->position();
153  double en = (double)element.clusterRef()->energy();
154  double et = (double)element.clusterRef()->energy()*fabs(sin(clusPos.Theta()));
155  if (en>myMaximumHCALPFClusterE) {
156  myMaximumHCALPFClusterE = en;
157  }
158  if (et>myMaximumHCALPFClusterEt) {
159  myMaximumHCALPFClusterEt = et;
160  }
161  if (!checkPos(hcalPosV,clusPos)) {
162  hcalPosV.push_back(clusPos);
163  myHCALenergy += en;
164  double deltaR = ROOT::Math::VectorUtil::DeltaR(myElecTrkEcalPos,clusPos);
165  if (deltaR<0.184) {
166  myHCALenergy3x3 += en;
167  }
168  }
169  } else if(element.type()==reco::PFBlockElement::ECAL) {
170  double en = (double)element.clusterRef()->energy();
171  math::XYZPoint clusPos = element.clusterRef()->position();
172  if (!checkPos(ecalPosV,clusPos)) {
173  ecalPosV.push_back(clusPos);
174  myECALenergy += en;
175  double deltaPhi = ROOT::Math::VectorUtil::DeltaPhi(myElecTrkEcalPos,clusPos);
176  double deltaEta = abs(myElecTrkEcalPos.eta()-clusPos.eta());
177  double deltaPhiOverQ = deltaPhi/(double)myElecTrk->charge();
178  if (en >= EcalStripSumE_minClusEnergy_ && deltaEta<EcalStripSumE_deltaEta_ && deltaPhiOverQ > EcalStripSumE_deltaPhiOverQ_minValue_ && deltaPhiOverQ < EcalStripSumE_deltaPhiOverQ_maxValue_) {
179  myStripClusterE += en;
180  }
181  }
182  }
183  } //end elements in blocks
184  } //end loop over PFcands
185  } //end RECO case
186  } // end check for null electrk
187  } // end check for null pfChargedHadrCand
188 
189  if ((myHCALenergy+myECALenergy)>0.)
190  myEmfrac = myECALenergy/(myHCALenergy+myECALenergy);
191  tau.setemFraction((float)myEmfrac);
192 
193  // scale the appropriate quantities by the momentum of the electron if it exists
194  if (myElecTrk.isNonnull())
195  {
196  float myElectronMomentum = (float)myElecTrk->p();
197  if (myElectronMomentum > 0.)
198  {
199  myHCALenergy /= myElectronMomentum;
200  myMaximumHCALPFClusterE /= myElectronMomentum;
201  myHCALenergy3x3 /= myElectronMomentum;
202  myStripClusterE /= myElectronMomentum;
203  }
204  }
205  tau.sethcalTotOverPLead((float)myHCALenergy);
206  tau.sethcalMaxOverPLead((float)myMaximumHCALPFClusterE);
207  tau.sethcal3x3OverPLead((float)myHCALenergy3x3);
208  tau.setecalStripSumEOverPLead((float)myStripClusterE);
209  tau.setmaximumHCALPFClusterEt(myMaximumHCALPFClusterEt);
210  tau.setelectronPreIDOutput(myElectronPreIDOutput);
211  if (myElecTrk.isNonnull())
212  tau.setelectronPreIDTrack(myElecTrk);
213  if (myElectronPreIDOutput > maximumForElectrionPreIDOutput_)
214  myElecPreid = true;
215  tau.setelectronPreIDDecision(myElecPreid);
216 
217  // These need to be filled!
218  //tau.setbremsRecoveryEOverPLead(my...);
219 
220  /* End elecron rejection */
221 }
Abstract base class for a PFBlock element (track, cluster...)
int i
Definition: DBlmapReader.cc:9
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
assert(m_qm.get())
size_type size() const
Definition: OwnVector.h:254
list elements
Definition: asciidump.py:414
const edm::OwnVector< reco::PFBlockElement > & elements() const
Definition: PFBlock.h:107
double deltaR(const T1 &t1, const T2 &t2)
Definition: deltaR.h:48
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
Definition: Point3D.h:10
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:12
std::vector< ElementInBlock > ElementsInBlocks
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
std::pair< reco::PFBlockRef, unsigned > ElementInBlock
edm::Ptr< PFCandidate > PFCandidatePtr
persistent Ptr to a PFCandidate
Block of elements.
Definition: PFBlock.h:30

Member Data Documentation

std::string reco::tau::RecoTauElectronRejectionPlugin::DataType_
private

Definition at line 36 of file RecoTauElectronRejectionPlugin.cc.

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

double reco::tau::RecoTauElectronRejectionPlugin::EcalStripSumE_deltaEta_
private

Definition at line 32 of file RecoTauElectronRejectionPlugin.cc.

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

double reco::tau::RecoTauElectronRejectionPlugin::EcalStripSumE_deltaPhiOverQ_maxValue_
private

Definition at line 34 of file RecoTauElectronRejectionPlugin.cc.

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

double reco::tau::RecoTauElectronRejectionPlugin::EcalStripSumE_deltaPhiOverQ_minValue_
private

Definition at line 33 of file RecoTauElectronRejectionPlugin.cc.

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

double reco::tau::RecoTauElectronRejectionPlugin::EcalStripSumE_minClusEnergy_
private

Definition at line 31 of file RecoTauElectronRejectionPlugin.cc.

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

double reco::tau::RecoTauElectronRejectionPlugin::ElecPreIDLeadTkMatch_maxDR_
private

Definition at line 30 of file RecoTauElectronRejectionPlugin.cc.

Referenced by RecoTauElectronRejectionPlugin().

double reco::tau::RecoTauElectronRejectionPlugin::maximumForElectrionPreIDOutput_
private

Definition at line 35 of file RecoTauElectronRejectionPlugin.cc.

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