CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFCandidateElectronExtra.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 
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 
30  mvaVariables_.push_back(-9999.);
31 
32  gsfTrackRef_ = gsfTrack;
34 
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  gsfTrackRef_= ref;
49 }
50 
52  pout_ = pout;
53 
54 }
55 
57  kfTrackRef_ = ref;
58  float nhit_kf=0;
59  float chi2_kf=-0.01;
60  // if the reference is null, it does not mean that the variables have not been set
61  if(kfTrackRef_.isNonnull()) {
62  nhit_kf=(float)kfTrackRef_->hitPattern().trackerLayersWithMeasurement();
63  chi2_kf=kfTrackRef_->normalizedChi2();
64  }
65  setVariable(MVA_NhitsKf,nhit_kf);
66  setVariable(MVA_Chi2Kf,chi2_kf);
67 }
68 
70  lateBrem_ = val;
72 }
73 
75  earlyBrem_ = val;
77 }
78 
80  hadEnergy_ = val;
81  if(clusterEnergies_.size()>0)
83 }
84 
86  sigmaEtaEta_ = val;
88 }
89 
91  deltaEta_ = val;
93 }
94 
95 
96 void PFCandidateElectronExtra::setClusterEnergies(const std::vector<float>& energies){
97  clusterEnergies_=energies;
98 
99  if(pout_.t()!=0.)
101 
102  static float m_el2=0.00051*0.00051;
103  float Ein_gsf =sqrt(gsfTrackRef_->pMode()*
104  gsfTrackRef_->pMode()+m_el2);
105 
106  float etot=0;
107  unsigned size=clusterEnergies_.size();
108  // std::cout << " N clusters " << size << std::endl;
109  float ebrem=0.;
110  for(unsigned ic=0;ic<size;++ic) {
111  etot+=clusterEnergies_[ic];
112  if(ic>0)
113  ebrem+=clusterEnergies_[ic];
114  }
115  setVariable(MVA_EtotOverPin,etot/Ein_gsf);
116  setVariable(MVA_EbremOverDeltaP,ebrem/(Ein_gsf-pout_.t()));
117 
118  // recompute - as in PFElectronAglo, the had energy is filled before the cluster energies
119  if(hadEnergy_!=-9999.)
121 
122 }
123 
125  setVariable(MVA_MVA,val);
126 }
127 
129 
130  mvaVariables_[type]=val;
131  mvaStatus_ |= (1 << (type)) ;
132 }
133 
134 
136  if(status) {
137  status_ |= (1 << type);
138  }
139  else {
140  status_ &= ~(1 <<type);
141  }
142 }
143 
145  return status_ & (1<<flag) ;
146 }
147 
149  return mvaStatus_ & (1<< (flag)) ;
150 }
151 
153  return (mvaStatus(var) ? mvaVariables_[var] : -9999. );
154 }
155 
156 #include <string>
157 
158 std::ostream& reco::operator<<(std::ostream& out,
159  const PFCandidateElectronExtra& extra ) {
160  if(!out) return out;
161 
162  static std::vector<std::string> listVar;
163  if(listVar.size()==0) {
164  listVar.push_back("LogPt");
165  listVar.push_back("Eta");
166  listVar.push_back("SigmaPtOverPt");
167  listVar.push_back("fbrem");
168  listVar.push_back("Chi2Gsf");
169  listVar.push_back("NhitsKf");
170  listVar.push_back("Chi2Kf");
171  listVar.push_back("EtotOverPin");
172  listVar.push_back("EseedOverPout");
173  listVar.push_back("EbremOverDeltaP");
174  listVar.push_back("DeltaEtaTrackCluster");
175  listVar.push_back("LogSigmaEtaEta");
176  listVar.push_back("H/(H+E)");
177  listVar.push_back("LateBrem");
178  listVar.push_back("FirstBrem");
179  listVar.push_back("MVA");
180  }
181  out << std::setiosflags(std::ios::left)<< std::setw(20) << "Variable index" << std::setw(20) << "Name" << std::setw(10) << "Set(0/1)" << std::setw(8) << "value" << std::endl;
184  out << std::setw(20)<< i << std::setw(20) << listVar[i] << std::setw(10) << extra.mvaStatus(i) << std::setw(8) << extra.mvaVariable(i) << std::endl;
185  }
186 
187  return out;
188 }
edm::Ref< GsfTrackCollection > GsfTrackRef
persistent reference to a GsfTrack
Definition: GsfTrackFwd.h:13
type
Definition: HCALResponse.h:21
int i
Definition: DBlmapReader.cc:9
long int flag
Definition: mlp_lapack.h:47
std::vector< float > clusterEnergies_
energy of individual clusters (corrected). The first cluster is the seed
void setGsfTrackRef(const reco::GsfTrackRef &ref)
set gsftrack reference
void setMVA(float val)
set the result (mostly for debugging)
void setLateBrem(float val)
set LateBrem
void setVariable(MvaVariable type, float var)
math::XYZTLorentzVector pout_
Variables entering the MVA that should be saved.
void setSigmaEtaEta(float val)
set the sigmaetaeta
void setGsfTrackPout(const math::XYZTLorentzVector &pout)
set the pout (not trivial to get from the GSF track)
void setClusterEnergies(const std::vector< float > &energies)
set the cluster energies. the Pout should be saved first
void setEarlyBrem(float val)
set EarlyBrem
int mvaStatus_
status of mva variables
int electronStatus() const
access to the status
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:30
reco::TrackRef kfTrackRef_
Ref to the KF track.
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
std::ostream & operator<<(std::ostream &, BeamSpot beam)
Definition: BeamSpot.cc:72
T sqrt(T t)
Definition: SSEVec.h:48
reco::GsfTrackRef gsfTrackRef_
Ref to the GSF track.
void setStatus(StatusFlag type, bool status=true)
set status
void setDeltaEta(float val)
set the delta eta
int status_
Status of the electron.
std::vector< float > mvaVariables_
mva variables - transient !
tuple out
Definition: dbtoconf.py:99
void setKfTrackRef(const reco::TrackRef &ref)
set kf track reference
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:14
bool mvaStatus(MvaVariable flag) const
access to mva variable status
float mvaVariable(MvaVariable var) const
access to any variable
tuple status
Definition: ntuplemaker.py:245
tuple size
Write out results.
void setHadEnergy(float val)
set the had energy. The cluster energies should be entered before