3 #include "Math/VectorUtil.h"
10 namespace HWWFunctions {
19 bool truncated =
true;
53 if (hww.
mus_p4().at(index).pt()<20)
60 if (hww.
mus_p4().at(index).pt()>20) {
70 if (hww.
mus_p4().at(index).pt()>20) {
85 edm::LogError(
"InvalidInput") <<
"muonID ERROR: requested muon type is not defined. Abort.";
101 if ( hww.
mus_p4().at(index).pt() < 5.0) {
110 if (((hww.
mus_type().at(index)) & (1<<1)) == 0)
return false;
111 if (((hww.
mus_type().at(index)) & (1<<2)) == 0)
return false;
123 if (((hww.
mus_type().at(index)) & (1<<1)) == 0)
return false;
124 if (((hww.
mus_type().at(index)) & (1<<2)) == 0)
return false;
129 if (hww.
mus_ptErr().at(index)/hww.
mus_p4().at(index).pt()>0.1)
return false;
138 if (((hww.
mus_type().at(index)) & (1<<1)) == 0)
return false;
139 if (((hww.
mus_type().at(index)) & (1<<2)) == 0)
return false;
144 if (hww.
mus_ptErr().at(index)/hww.
mus_p4().at(index).pt()>0.1)
return false;
153 if (((hww.
mus_type().at(index)) & (1<<1)) == 0)
return false;
154 if (((hww.
mus_type().at(index)) & (1<<2)) == 0)
return false;
163 if (((hww.
mus_type().at(index)) & (1<<1)) == 0)
return false;
164 if (((hww.
mus_type().at(index)) & (1<<2)) == 0)
return false;
174 if (hww.
mus_p4().at(index).pt()<20){
184 if (((hww.
mus_type().at(index)) & (1<<1)) == 0)
return false;
185 if (((hww.
mus_type().at(index)) & (1<<2)) == 0)
return false;
189 if (hww.
mus_ptErr().at(index)/hww.
mus_p4().at(index).pt()>0.1)
return false;
201 if (hww.
mus_p4().at(index).pt()<20){
212 if (hww.
mus_ptErr().at(index)/hww.
mus_p4().at(index).pt()>0.1)
return false;
214 bool goodMuonGlobalMuon =
false;
215 if (((hww.
mus_type().at(index)) & (1<<1)) != 0) {
216 goodMuonGlobalMuon =
true;
217 if (hww.
mus_nmatches().at(index)<2) goodMuonGlobalMuon =
false;
221 bool goodMuonTrackerMuon =
false;
222 if (((hww.
mus_type().at(index)) & (1<<2)) != 0) {
223 goodMuonTrackerMuon =
true;
226 return goodMuonGlobalMuon || goodMuonTrackerMuon;
230 edm::LogError(
"InvalidInput") <<
"muonID ERROR: requested muon type is not defined. Abort.";
244 double pt = hww.
mus_p4().at(index).pt();
245 if(truncated) pt =
max( pt, 20.0 );
249 double pt = hww.
mus_p4().at(index).pt();
250 if(truncated) pt =
max( pt, 20.0 );
254 double pt = hww.
mus_p4().at(index).pt();
255 if(truncated) pt =
max( pt, 20.0 );
259 #ifdef PFISOFROMNTUPLE
260 double muonIsoValuePF(
HWW& hww,
unsigned int imu,
unsigned int ivtx,
float coner,
float minptn,
float dzcut,
int filterId){
261 if (fabs(coner-0.3)<0.0001) {
262 if (hww.mus_iso03_pf().at(imu)<-99.)
return 9999.;
263 return hww.mus_iso03_pf().at(imu)/hww.
mus_p4().at(imu).pt();
264 }
else if (fabs(coner-0.4)<0.0001) {
265 if (hww.mus_iso04_pf().at(imu)<-99.)
return 9999.;
266 return hww.mus_iso04_pf().at(imu)/hww.
mus_p4().at(imu).pt();
268 edm::LogWarning(
"InvalidInput") <<
"muonIsoValuePF: CONE SIZE NOT SUPPORTED";
273 double muonIsoValuePF(
HWW& hww,
unsigned int imu,
unsigned int ivtx,
float coner,
float minptn,
float dzcut,
int filterId){
278 for (
unsigned int ipf=0; ipf<hww.
pfcands_p4().size(); ++ipf){
280 if (dR>coner)
continue;
283 if (filterId!=0 && filterId!=pfid)
continue;
286 if (pfpt>minptn) pfniso+=pfpt;
291 if (mutkid>=0 && pftkid>=0 && mutkid==pftkid)
continue;
296 if(fabs(
gsftrks_dz_pv(hww, gsfid,ivtx ).first - mudz )<dzcut) {
310 return (pfciso+pfniso)/hww.
mus_p4().at(imu).pt();
321 unsigned int iMax = 0;
323 for (
unsigned int i = iMax+1;
i < hww.
vtxs_sumpt().size(); ++
i )
328 double dxyPV = hww.
mus_d0().at(index)-
336 double sumPtMax = -1;
338 for (
unsigned int i = 0;
i < hww.
vtxs_sumpt().size(); ++
i ){
348 if (iMax<0)
return 9999.;
349 double dxyPV = hww.
mus_d0().at(index)-
357 double dxyPV = hww.
mus_d0().at(index)-
364 return (vtx.z()-pv.z()) - ((vtx.x()-pv.x())*p4.x()+(vtx.y()-pv.y())*p4.y())/p4.pt() * p4.z()/p4.pt();
375 double sumPtMax = -1;
377 for (
unsigned int i = 0;
i < hww.
vtxs_sumpt().size(); ++
i ){
387 if (iMax<0)
return 9999.;
391 return (vtx.z()-pv.z()) - ((vtx.x()-pv.x())*p4.x()+(vtx.y()-pv.y())*p4.y())/p4.pt() * p4.z()/p4.pt();
402 if( ipf >=
int(hww.
pfmus_p4().size()) || ipf < 0 )
return false;
410 float pt_pf = hww.
pfmus_p4().at(ipf).pt();
411 float pt = hww.
mus_p4().at(index).pt();
413 if( fabs( pt_pf - pt ) > dpt_max )
return false;
std::vector< int > & pfels_elsidx()
double mud0PV_smurfV3(HWW &, unsigned int index)
std::vector< int > & trks_valid_pixelhits()
bool isPFMuon(HWW &, int index, bool requireSamePt=true, float dpt_max=1.0)
std::vector< float > & mus_gfit_chi2()
std::vector< int > & pfcands_charge()
Sin< T >::type sin(const T &t)
bool muonId(HWW &, unsigned int index, SelectionType type)
std::vector< int > & mus_pid_TMLastStationTight()
std::vector< int > & mus_trkidx()
std::vector< float > & mus_ptErr()
std::vector< LorentzVector > & mus_p4()
std::vector< float > & mus_iso03_hadEt()
std::vector< LorentzVector > & pfcands_p4()
std::vector< int > & mus_nmatches()
std::vector< float > & mus_iso03_sumPt()
std::vector< int > & mus_pfmusidx()
std::vector< int > & mus_gfit_validSTAHits()
std::vector< int > & els_gsftrkidx()
double mud0PV_wwV1(HWW &, unsigned int index)
std::vector< int > & pfcands_trkidx()
std::vector< int > & pfcands_pfelsidx()
std::pair< double, double > gsftrks_dz_pv(HWW &, int itrk, int ipv)
std::vector< LorentzVector > & mus_trk_p4()
std::vector< int > & mus_validHits()
double muonIsoValue(HWW &, unsigned int, bool=true)
Cos< T >::type cos(const T &t)
std::vector< float > & vtxs_ndof()
std::vector< int > & pfcands_particleId()
Abs< T >::type abs(const T &t)
std::vector< float > & mus_gfit_ndof()
std::vector< LorentzVector > & vtxs_position()
bool muonIdNotIsolated(HWW &, unsigned int index, SelectionType type)
std::vector< LorentzVector > & pfmus_p4()
double mudzPV_wwV1(HWW &, unsigned int index)
double muonIsoValuePF(HWW &, unsigned int imu, unsigned int ivtx, float coner=0.4, float minptn=1.0, float dzcut=0.1, int filterId=0)
double mudzPV_smurfV3(HWW &, unsigned int index)
double muonIsoValue_ECAL(HWW &, unsigned int, bool=true)
std::vector< float > & mus_d0()
std::pair< double, double > trks_dz_pv(HWW &, int itrk, int ipv)
double muonIsoValue_HCAL(HWW &, unsigned int, bool=true)
std::vector< float > & mus_sta_z0corr()
std::vector< int > & vtxs_isFake()
double mud0PV(HWW &, unsigned int index)
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< float > > LorentzVector
double muonIsoValue_TRK(HWW &, unsigned int, bool=true)
std::vector< LorentzVector > & mus_vertex_p4()
double dzPV_mu(HWW &hww, const LorentzVector &vtx, const LorentzVector &p4, const LorentzVector &pv)
std::vector< float > & vtxs_sumpt()
std::vector< float > & mus_iso03_emEt()
std::vector< int > & mus_type()