CMS 3D CMS Logo

PFCandidateEGammaExtra.cc
Go to the documentation of this file.
3 #include <ostream>
4 #include <iomanip>
5 
6 using namespace reco;
7 
9  status_ = 0;
10  mvaStatus_ = 0;
11  pout_ = math::XYZTLorentzVector(0., 0., 0., 0.);
12  hadEnergy_ = -9999.;
13  sigmaEtaEta_ = -9999.;
14 
15  for (MvaVariable m = MVA_FIRST; m < MVA_LAST; m = MvaVariable(m + 1))
16  mvaVariables_.push_back(-9999.);
17 
20 }
21 
23  status_ = 0;
24  mvaStatus_ = 0;
25  pout_ = math::XYZTLorentzVector(0., 0., 0., 0.);
26  hadEnergy_ = -9999.;
27  sigmaEtaEta_ = -9999.;
28 
29  for (MvaVariable m = MVA_FIRST; m < MVA_LAST; m = MvaVariable(m + 1))
30  mvaVariables_.push_back(-9999.);
31 
32  gsfTrackRef_ = gsfTrack;
34 
36  setVariable(MVA_EtaGsf, gsfTrackRef_->etaMode());
37  setVariable(MVA_Chi2Gsf, gsfTrackRef_->normalizedChi2());
38  float ptmodeerror = gsfTrackRef_->ptModeError();
39  if (ptmodeerror > 0.)
40  setVariable(MVA_SigmaPtOverPt, ptmodeerror / gsfTrackRef_->ptMode());
41  else
43 
44  setVariable(MVA_Fbrem, (gsfTrackRef_->ptMode() - pout_.pt()) / gsfTrackRef_->ptMode());
45 }
46 
48 
50 
52  kfTrackRef_ = ref;
53  float nhit_kf = 0;
54  float chi2_kf = -0.01;
55  // if the reference is null, it does not mean that the variables have not been set
56  if (kfTrackRef_.isNonnull()) {
57  nhit_kf = (float)kfTrackRef_->hitPattern().trackerLayersWithMeasurement();
58  chi2_kf = kfTrackRef_->normalizedChi2();
59  }
60  setVariable(MVA_NhitsKf, nhit_kf);
61  setVariable(MVA_Chi2Kf, chi2_kf);
62 }
63 
65  lateBrem_ = val;
67 }
68 
70  earlyBrem_ = val;
72 }
73 
75  hadEnergy_ = val;
76  if (!clusterEnergies_.empty())
78 }
79 
81  sigmaEtaEta_ = val;
83 }
84 
86  deltaEta_ = val;
88 }
89 
90 void PFCandidateEGammaExtra::setClusterEnergies(const std::vector<float>& energies) {
91  clusterEnergies_ = energies;
92 
93  if (pout_.t() != 0.)
95 
96  const float m_el2 = 0.00051 * 0.00051;
97  float Ein_gsf = sqrt(gsfTrackRef_->pMode() * gsfTrackRef_->pMode() + m_el2);
98 
99  float etot = 0;
100  unsigned size = clusterEnergies_.size();
101  // std::cout << " N clusters " << size << std::endl;
102  float ebrem = 0.;
103  for (unsigned ic = 0; ic < size; ++ic) {
104  etot += clusterEnergies_[ic];
105  if (ic > 0)
106  ebrem += clusterEnergies_[ic];
107  }
108  setVariable(MVA_EtotOverPin, etot / Ein_gsf);
109  setVariable(MVA_EbremOverDeltaP, ebrem / (Ein_gsf - pout_.t()));
110 
111  // recompute - as in PFElectronAglo, the had energy is filled before the cluster energies
112  if (hadEnergy_ != -9999.)
114 }
115 
117 
120  mvaStatus_ |= (1 << (type));
121 }
122 
124  if (status) {
125  status_ |= (1 << type);
126  } else {
127  status_ &= ~(1 << type);
128  }
129 }
130 
132 
134 
136  return (mvaStatus(var) ? mvaVariables_[var] : -9999.);
137 }
138 
139 void PFCandidateEGammaExtra::addSingleLegConvTrackRefMva(const std::pair<reco::TrackRef, float>& trackrefmva) {
140  assoSingleLeg_.push_back(trackrefmva);
141 }
142 
145 }
146 
149 }
150 
151 static const char* const listVar[] = {"LogPt",
152  "Eta",
153  "SigmaPtOverPt",
154  "fbrem",
155  "Chi2Gsf",
156  "NhitsKf",
157  "Chi2Kf",
158  "EtotOverPin",
159  "EseedOverPout",
160  "EbremOverDeltaP",
161  "DeltaEtaTrackCluster",
162  "LogSigmaEtaEta",
163  "H/(H+E)",
164  "LateBrem",
165  "FirstBrem",
166  "MVA"};
167 
168 std::ostream& reco::operator<<(std::ostream& out, const PFCandidateEGammaExtra& extra) {
169  if (!out)
170  return out;
171 
172  out << std::setiosflags(std::ios::left) << std::setw(20) << "Variable index" << std::setw(20) << "Name"
173  << std::setw(10) << "Set(0/1)" << std::setw(8) << "value" << std::endl;
176  out << std::setw(20) << i << std::setw(20) << listVar[i] << std::setw(10) << extra.mvaStatus(i) << std::setw(8)
177  << extra.mvaVariable(i) << std::endl;
178  }
179 
180  return out;
181 }
reco::PFCandidateEGammaExtra::setHadEnergy
void setHadEnergy(float val)
set the had energy. The cluster energies should be entered before
Definition: PFCandidateEGammaExtra.cc:74
reco::GsfTrackRef
edm::Ref< GsfTrackCollection > GsfTrackRef
persistent reference to a GsfTrack
Definition: GsfTrackFwd.h:13
reco::PFCandidateEGammaExtra::MVA_LnPtGsf
Definition: PFCandidateEGammaExtra.h:38
mps_fire.i
i
Definition: mps_fire.py:428
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
reco::PFCandidateEGammaExtra::MVA_LAST
Definition: PFCandidateEGammaExtra.h:54
reco::PFCandidateEGammaExtra::pout_
math::XYZTLorentzVector pout_
Variables entering the MVA that should be saved.
Definition: PFCandidateEGammaExtra.h:227
reco::PFCandidateEGammaExtra::setDeltaEta
void setDeltaEta(float val)
set the delta eta
Definition: PFCandidateEGammaExtra.cc:85
mps_update.status
status
Definition: mps_update.py:69
reco::PFCandidateEGammaExtra::deltaEta_
float deltaEta_
Definition: PFCandidateEGammaExtra.h:232
reco::PFCandidateEGammaExtra::addConversionRef
void addConversionRef(const reco::ConversionRef &convref)
add Conversions from PF
Definition: PFCandidateEGammaExtra.cc:143
reco::PFCandidateEGammaExtra::setClusterEnergies
void setClusterEnergies(const std::vector< float > &energies)
set the cluster energies. the Pout should be saved first
Definition: PFCandidateEGammaExtra.cc:90
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
reco::PFCandidateEGammaExtra::MVA_MVA
Definition: PFCandidateEGammaExtra.h:53
reco::PFCandidateEGammaExtra::mvaVariables_
std::vector< float > mvaVariables_
mva variables - transient !
Definition: PFCandidateEGammaExtra.h:218
reco::PFCandidateEGammaExtra
Definition: PFCandidateEGammaExtra.h:25
reco::PFCandidateEGammaExtra::MVA_NhitsKf
Definition: PFCandidateEGammaExtra.h:43
reco::PFCandidateEGammaExtra::setMVA
void setMVA(float val)
set the result (mostly for debugging)
Definition: PFCandidateEGammaExtra.cc:116
edm::Ref< GsfTrackCollection >
reco::PFCandidateEGammaExtra::kfTrackRef_
reco::TrackRef kfTrackRef_
Ref to the KF track.
Definition: PFCandidateEGammaExtra.h:191
reco::PFCandidateEGammaExtra::mvaVariable
float mvaVariable(MvaVariable var) const
access to any variable
Definition: PFCandidateEGammaExtra.cc:135
reco::PFCandidateEGammaExtra::setEarlyBrem
void setEarlyBrem(float val)
set EarlyBrem
Definition: PFCandidateEGammaExtra.cc:69
trigObjTnPSource_cfi.var
var
Definition: trigObjTnPSource_cfi.py:21
reco::PFCandidateEGammaExtra::lateBrem_
float lateBrem_
Definition: PFCandidateEGammaExtra.h:229
reco::PFCandidateEGammaExtra::setKfTrackRef
void setKfTrackRef(const reco::TrackRef &ref)
set kf track reference
Definition: PFCandidateEGammaExtra.cc:51
reco::PFCandidateEGammaExtra::gsfTrackRef_
reco::GsfTrackRef gsfTrackRef_
Ref to the GSF track.
Definition: PFCandidateEGammaExtra.h:189
reco::PFCandidateEGammaExtra::electronStatus
int electronStatus() const
access to the status
Definition: PFCandidateEGammaExtra.h:161
reco::PFCandidateEGammaExtra::setGsfTrackPout
void setGsfTrackPout(const math::XYZTLorentzVector &pout)
set the pout (not trivial to get from the GSF track)
Definition: PFCandidateEGammaExtra.cc:49
reco::PFCandidateEGammaExtra::MVA_Chi2Gsf
Definition: PFCandidateEGammaExtra.h:42
listVar
static const char *const listVar[]
Definition: PFCandidateEGammaExtra.cc:151
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
reco::PFCandidateEGammaExtra::setLateBrem
void setLateBrem(float val)
set LateBrem
Definition: PFCandidateEGammaExtra.cc:64
reco::PFCandidateEGammaExtra::MVA_HOverHE
Definition: PFCandidateEGammaExtra.h:50
reco::PFCandidateEGammaExtra::MVA_EbremOverDeltaP
Definition: PFCandidateEGammaExtra.h:47
reco::TrackRef
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
reco::PFCandidateEGammaExtra::setGsfTrackRef
void setGsfTrackRef(const reco::GsfTrackRef &ref)
set gsftrack reference
Definition: PFCandidateEGammaExtra.cc:47
reco::PFCandidateEGammaExtra::setSigmaEtaEta
void setSigmaEtaEta(float val)
set the sigmaetaeta
Definition: PFCandidateEGammaExtra.cc:80
reco::PFCandidateEGammaExtra::hadEnergy_
float hadEnergy_
Definition: PFCandidateEGammaExtra.h:231
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
reco::PFCandidateEGammaExtra::earlyBrem_
float earlyBrem_
Definition: PFCandidateEGammaExtra.h:228
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
gainCalibHelper::gainCalibPI::type
type
Definition: SiPixelGainCalibHelper.h:40
reco::PFCandidateEGammaExtra::MVA_LogSigmaEtaEta
Definition: PFCandidateEGammaExtra.h:49
reco::PFCandidateEGammaExtra::setStatus
void setStatus(StatusFlag type, bool status=true)
set status
Definition: PFCandidateEGammaExtra.cc:123
GsfTrack.h
reco::operator<<
std::ostream & operator<<(std::ostream &, BeamSpot beam)
Definition: BeamSpot.cc:66
reco::PFCandidateEGammaExtra::addSingleLegConvTrackRefMva
void addSingleLegConvTrackRefMva(const std::pair< reco::TrackRef, float > &trackrefmva)
add Single Leg Conversion TrackRef
Definition: PFCandidateEGammaExtra.cc:139
reco::PFCandidateEGammaExtra::PFCandidateEGammaExtra
PFCandidateEGammaExtra()
constructor
Definition: PFCandidateEGammaExtra.cc:8
reco::PFCandidateEGammaExtra::sigmaEtaEta_
float sigmaEtaEta_
Definition: PFCandidateEGammaExtra.h:230
reco::PFCandidateEGammaExtra::mvaStatus
bool mvaStatus(MvaVariable flag) const
access to mva variable status
Definition: PFCandidateEGammaExtra.cc:133
reco::PFCandidateEGammaExtra::setVariable
void setVariable(MvaVariable type, float var)
Definition: PFCandidateEGammaExtra.cc:118
edm::RefVector::push_back
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Definition: RefVector.h:67
reco::PFCandidateEGammaExtra::status_
int status_
Status of the electron.
Definition: PFCandidateEGammaExtra.h:224
reco::PFCandidateEGammaExtra::singleLegConversions_
reco::ConversionRefVector singleLegConversions_
Definition: PFCandidateEGammaExtra.h:211
reco::PFCandidateEGammaExtra::assoSingleLeg_
std::vector< std::pair< reco::TrackRef, float > > assoSingleLeg_
vector of TrackRef from Single Leg conversions and associated mva value
Definition: PFCandidateEGammaExtra.h:202
reco::PFCandidateEGammaExtra::addSingleLegConversionRef
void addSingleLegConversionRef(const reco::ConversionRef &convref)
add Conversions from PF
Definition: PFCandidateEGammaExtra.cc:147
reco::PFCandidateEGammaExtra::mvaStatus_
int mvaStatus_
status of mva variables
Definition: PFCandidateEGammaExtra.h:221
reco::PFCandidateEGammaExtra::MVA_Fbrem
Definition: PFCandidateEGammaExtra.h:41
reco::PFCandidateEGammaExtra::MVA_SigmaPtOverPt
Definition: PFCandidateEGammaExtra.h:40
reco::PFCandidateEGammaExtra::MVA_EtaGsf
Definition: PFCandidateEGammaExtra.h:39
heppy_batch.val
val
Definition: heppy_batch.py:351
reco::PFCandidateEGammaExtra::MVA_EtotOverPin
Definition: PFCandidateEGammaExtra.h:45
reco::PFCandidateEGammaExtra::MVA_Chi2Kf
Definition: PFCandidateEGammaExtra.h:44
reco::PFCandidateEGammaExtra::MvaVariable
MvaVariable
Definition: PFCandidateEGammaExtra.h:36
math::XYZTLorentzVector
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
PFCandidateEGammaExtra.h
reco::PFCandidateEGammaExtra::assoConversionsRef_
reco::ConversionRefVector assoConversionsRef_
vector of ConversionRef from PF
Definition: PFCandidateEGammaExtra.h:208
reco::PFCandidateEGammaExtra::MVA_DeltaEtaTrackCluster
Definition: PFCandidateEGammaExtra.h:48
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
reco::PFCandidateEGammaExtra::MVA_LateBrem
Definition: PFCandidateEGammaExtra.h:51
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
reco::PFCandidateEGammaExtra::clusterEnergies_
std::vector< float > clusterEnergies_
Definition: PFCandidateEGammaExtra.h:215
reco::PFCandidateEGammaExtra::MVA_FirstBrem
Definition: PFCandidateEGammaExtra.h:52
reco::PFCandidateEGammaExtra::MVA_FIRST
Definition: PFCandidateEGammaExtra.h:37
reco::PFCandidateEGammaExtra::StatusFlag
StatusFlag
Definition: PFCandidateEGammaExtra.h:27
reco::PFCandidateEGammaExtra::MVA_EseedOverPout
Definition: PFCandidateEGammaExtra.h:46
RemoveAddSevLevel.flag
flag
Definition: RemoveAddSevLevel.py:116
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443