Go to the documentation of this file.00001 #include "ForIA/Jet.hh"
00002 #include "ForIA/JetKey.hh"
00003 #include "ForIA/Track.hh"
00004 #include "ForIA/Utils.hh"
00005 #include "ForIA/Units.hh"
00006 #include <stdexcept>
00007 #include <gsl/gsl_cdf.h>
00008 #include <cmath>
00009
00010 namespace ForIA{
00011
00012 Jet::Jet(JetKeyConstPtr key): IFourMomentum(), m_key(key),
00013 m_gotpx(false), m_gotpy(false), m_gotpz(false), m_gotRapidity(false),
00014 m_gotLARQualityMean(false), m_gotChargedFraction(false),
00015 m_gotBadLooser(false),
00016 m_gotMatchedTracks(false){
00017
00018 }
00019
00021 Jet::Jet(JetKeyConstPtr &key,
00022 double E, double pT, double mass, double eta, double phi): IFourMomentum(),
00023 m_key(key),
00024 m_E(E), m_PT(pT), m_mass(mass), m_phi(phi), m_eta(eta),
00025 m_gotpx(false), m_gotpy(false), m_gotpz(false), m_gotRapidity(false),
00026 m_gotLARQualityMean(false), m_gotChargedFraction(false),
00027 m_gotBadLooser(false),
00028 m_gotMatchedTracks(false){
00029
00030 }
00031
00033 double Jet::E() const{
00034 return m_E;
00035 }
00037 double Jet::ET() const{
00038 double et = E()*sin(theta());
00039 return et;
00040 }
00042 double Jet::PT() const{
00043 return m_PT;
00044 }
00046 double Jet::mass() const{
00047 return m_mass;
00048 }
00050 double Jet::theta() const{
00051 double theta = 2*atan(exp(-1.0*m_eta));
00052 return theta;
00053 }
00055 double Jet::phi() const{
00056 return m_phi;
00057 }
00059 double Jet::eta() const{
00060 return m_eta;
00061 }
00062
00064 double Jet::px()const{
00065 if(m_gotpx) return m_px;
00066 m_px = PT() * sin(phi());
00067 m_gotpx = true;
00068 return m_px;
00069 }
00070
00072 double Jet::py()const{
00073 if(m_gotpy) return m_py;
00074 m_py = PT() * cos(phi());
00075 m_gotpy = true;
00076 return m_py;
00077 }
00078
00080 double Jet::pz()const{
00081 if(m_gotpz) return m_pz;
00082 double tanp = tan(theta());
00083
00084 if(fabs(tanp) < 1.e-12){
00085 m_pz = sqrt(E()*E() - mass()*mass());
00086 }else{
00087 m_pz = PT() / tanp;
00088 }
00089
00090 m_gotpz = true;
00091 return m_pz;
00092 }
00093
00095 double Jet::rParam()const{
00096 return m_key->rParam();
00097 }
00098
00100 double Jet::rapidity() const{
00101 if(m_gotRapidity) return m_rapidity;
00102 double pz = PT() / tan(theta());
00103 m_rapidity = 0.5 * log((E() + pz)/ (E() - pz));
00104 m_gotRapidity = true;
00105 return m_rapidity;
00106 }
00107
00108 double Jet::HECFraction()const{
00109 return m_hecFraction;
00110 }
00111
00112 double Jet::HECQuality()const{
00113 return m_hecQuality;
00114 }
00115
00116 double Jet::LArQuality()const{
00117 return m_larQuality;
00118 }
00119
00120 double Jet::LArQualityMean()const{
00121
00122 if(m_gotLARQualityMean) return m_LARQualityMean;
00123
00124
00125 static const double bit16 = 1./65535.;
00126 m_LARQualityMean = bit16 * m_averageLARQualityFraction;
00127 m_gotLARQualityMean = true;
00128 return m_LARQualityMean;
00129 }
00130
00131 double Jet::negativeEnergy()const{
00132 return m_negEnergy;
00133 }
00134
00135 double Jet::EMFraction()const{
00136 return m_emFrac;
00137 }
00138
00139 double Jet::chargedFraction()const{
00140 if(m_gotChargedFraction) return m_chargedFraction;
00141 m_chargedFraction = m_trackPTSum / PT();
00142 m_gotChargedFraction=true;
00143 return m_chargedFraction;
00144 }
00145
00146 double Jet::fracSamplingMax()const{
00147 return m_fracSamplingMax;
00148 }
00149
00150 bool Jet::isBadLooser()const{
00151 if(m_gotBadLooser) return m_badLooser;
00152
00153 double modEta = fabs(emScaleEta());
00154
00155 bool hecSpike = ((HECFraction() > 0.5 && fabs(HECQuality()) > 0.5 && LArQualityMean() > 0.8) ||
00156 fabs(negativeEnergy()) > 60.*GeV);
00157
00158 bool emNoise = (EMFraction() > 0.95 && fabs(LArQuality()) > 0.8 &&
00159 LArQualityMean() > 0.8 && modEta < 2.8);
00160
00161 bool cosmic = ((EMFraction() < 0.05 && chargedFraction() < 0.05 && modEta < 2.) ||
00162 (EMFraction() < 0.05 && modEta >= 2.) ||
00163 (fracSamplingMax() > 0.99 && modEta < 2.));
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176 return hecSpike || emNoise || cosmic;
00177 }
00178
00180 bool Jet::isUgly()const{
00181 return m_tileGap3 > 0.5 || m_bchCorrCell > 0.5;
00182 }
00183
00185 int Jet::isBadLoose() const{
00186 return m_isBadLoose;
00187 }
00189 int Jet::isBadMedium() const{
00190 return m_isBadMedium;
00191 }
00193 int Jet::isBadTight() const{
00194 return m_isBadTight;
00195 }
00197
00198
00199
00201 double Jet::emScaleEta() const{
00202 return m_emScaleEta;
00203 }
00204
00206 void Jet::scaleEnergy(double scale, bool percentual){
00207 if(percentual){
00208 m_E = m_E*(1.+scale);
00209 }else{
00210 m_E *= scale;
00211 }
00212
00213 m_gotpx = false;
00214 m_gotpy = false;
00215 m_gotpz = false;
00216
00217 return;
00218 }
00219
00220 const TrackVector &Jet::matchedTracks()const{
00221
00222 if(m_gotMatchedTracks) return m_matchedTracks;
00223
00224 m_event->matchTracksToJets(*m_key);
00225 m_gotMatchedTracks = true;
00226
00227 return m_matchedTracks;
00228 }
00229
00230
00232 std::ostream &operator << (std::ostream &out, const Jet &jet){
00233 out<<"Jet: { E: "<<jet.m_E;
00234 out<<" , PT: "<<jet.m_PT;
00235 out<<" , eta: "<<jet.m_eta;
00236 out<<" , phi: "<<jet.m_phi;
00237 out<<" , isUgly: "<<jet.isUgly();
00238 out<<" , isBadLoose: "<<jet.m_isBadLoose;
00239 out<<" , isBadMedium: "<<jet.m_isBadMedium;
00240 out<<" , isBadTight: "<<jet.m_isBadTight;
00241 out<<"}";
00242 return out;
00243 }
00244
00246 }