17 |
|
// |
18 |
|
// |
19 |
|
|
20 |
< |
#include "UserCode/HbbAnalyzer/interface/HbbAnalyzerNew.h" |
21 |
< |
#include "UserCode/HbbAnalyzer/interface/VHbbEvent.h" |
20 |
> |
#include "VHbbAnalysis/HbbAnalyzer/interface/HbbAnalyzerNew.h" |
21 |
> |
#include "VHbbAnalysis/HbbAnalyzer/interface/VHbbEvent.h" |
22 |
> |
|
23 |
> |
#include "DataFormats/GeometryVector/interface/VectorUtil.h" |
24 |
> |
|
25 |
|
|
26 |
|
#define GENPTOLOR(a) TLorentzVector((a).px(), (a).py(), (a).pz(), (a).energy()) |
27 |
|
#define GENPTOLORP(a) TLorentzVector((a)->px(), (a)->py(), (a)->pz(), (a)->energy()) |
40 |
|
phoLabel_(iConfig.getUntrackedParameter<edm::InputTag>("photonTag")), |
41 |
|
dimuLabel_(iConfig.getUntrackedParameter<edm::InputTag>("dimuTag")), |
42 |
|
dielecLabel_(iConfig.getUntrackedParameter<edm::InputTag>("dielecTag")), |
43 |
< |
hltResults_(iConfig.getUntrackedParameter<edm::InputTag>("hltResultsTag")){ |
43 |
> |
hltResults_(iConfig.getUntrackedParameter<edm::InputTag>("hltResultsTag")), |
44 |
> |
runOnMC_(iConfig.getParameter<bool>("runOnMC")) { |
45 |
> |
|
46 |
|
// |
47 |
|
// put the setwhatproduced etc etc |
48 |
|
|
316 |
|
|
317 |
|
Handle<GenParticleCollection> genParticles; |
318 |
|
|
314 |
– |
bool isMC=1; |
319 |
|
bool printJet=0; |
320 |
|
|
321 |
|
|
322 |
< |
if(isMC){ |
322 |
> |
if(runOnMC_){ |
323 |
|
|
324 |
|
int Hin=-99,Win=-99,Zin=-99,bin=-99,bbarin=-99; |
325 |
|
|
517 |
|
VHbbEvent::SimpleJet sj; |
518 |
|
sj.flavour = jet_iter->partonFlavour(); |
519 |
|
|
516 |
– |
|
520 |
|
sj.tche=jet_iter->bDiscriminator("trackCountingHighEffBJetTags"); |
521 |
|
sj.tchp=jet_iter->bDiscriminator("trackCountingHighPurBJetTags"); |
522 |
|
sj.jp=jet_iter->bDiscriminator("jetProbabilityBJetTags"); |
527 |
|
sj.charge=jet_iter->jetCharge(); |
528 |
|
sj.ntracks=jet_iter->associatedTracks().size(); |
529 |
|
sj.fourMomentum=GENPTOLORP(jet_iter); |
530 |
+ |
sj.chargedTracksFourMomentum=(getChargedTracksMomentum(&*(jet_iter))); |
531 |
+ |
|
532 |
+ |
// |
533 |
+ |
// add tVector |
534 |
+ |
// |
535 |
+ |
sj.tVector = getTvect(&(*jet_iter)); |
536 |
|
|
537 |
|
Particle::LorentzVector p4Jet = jet_iter->p4(); |
538 |
|
|
539 |
< |
if(isMC){ |
539 |
> |
if(runOnMC_){ |
540 |
|
double minb1DR=9999.; |
541 |
|
for(size_t i = 0; i < genParticles->size(); ++ i) { |
542 |
|
const GenParticle & p = (*genParticles)[i]; |
544 |
|
if(abs(id)<=6 || id==21 || id==23 || abs(id)==24){ |
545 |
|
double bb1DR=TMath::Sqrt((p.eta()-p4Jet.eta())*(p.eta()-p4Jet.eta())+ |
546 |
|
(p.phi()-p4Jet.phi())*(p.phi()-p4Jet.phi())); |
547 |
< |
if(bb1DR<minb1DR) {minb1DR=bb1DR; sj.b1BestMCid=id; if(p.mother()!=0) sj.b1BestMCmomid=p.mother()->pdgId();} |
547 |
> |
if(bb1DR<minb1DR) {minb1DR=bb1DR; sj.bestMCid=id; if(p.mother()!=0) sj.bestMCmomid=p.mother()->pdgId();} |
548 |
|
} |
549 |
|
} |
550 |
|
} //isMC |
569 |
|
sj.charge=jet_iter->jetCharge(); |
570 |
|
sj.ntracks=jet_iter->associatedTracks().size(); |
571 |
|
sj.fourMomentum=GENPTOLORP(jet_iter); |
572 |
+ |
sj.chargedTracksFourMomentum=(getChargedTracksMomentum(&*(jet_iter))); |
573 |
+ |
sj.tVector = getTvect(&(*jet_iter)); |
574 |
|
|
575 |
|
Particle::LorentzVector p4Jet = jet_iter->p4(); |
576 |
|
|
577 |
< |
if(isMC){ |
577 |
> |
if(runOnMC_){ |
578 |
|
double minb2DR=9999.; |
579 |
|
for(size_t i = 0; i < genParticles->size(); ++ i) { |
580 |
|
const GenParticle & p = (*genParticles)[i]; |
582 |
|
if(abs(id)<=6 || id==21 || id==23 || abs(id)==24){ |
583 |
|
double bb2DR=TMath::Sqrt((p.eta()-p4Jet.eta())*(p.eta()-p4Jet.eta())+ |
584 |
|
(p.phi()-p4Jet.phi())*(p.phi()-p4Jet.phi())); |
585 |
< |
if(bb2DR<minb2DR) {minb2DR=bb2DR; sj.b1BestMCid=id; if(p.mother()!=0) sj.b1BestMCmomid=p.mother()->pdgId();} |
585 |
> |
if(bb2DR<minb2DR) {minb2DR=bb2DR; sj.bestMCid=id; if(p.mother()!=0) sj.bestMCmomid=p.mother()->pdgId();} |
586 |
|
} |
587 |
|
} |
588 |
|
} //isMC |
634 |
|
hj.subFourMomentum.push_back(GENPTOLORP(icandJet)); |
635 |
|
hj.etaSub.push_back(icandJet->eta()); |
636 |
|
hj.phiSub.push_back(icandJet->phi()); |
626 |
– |
|
637 |
|
|
638 |
|
} |
639 |
|
hbbInfo->hardJets.push_back(hj); |
658 |
|
VHbbEvent::SimpleJet sj; |
659 |
|
|
660 |
|
sj.flavour = subjet_iter->partonFlavour(); |
661 |
< |
|
661 |
> |
sj.tVector = getTvect(&(*subjet_iter)); |
662 |
|
sj.tche=subjet_iter->bDiscriminator("trackCountingHighEffBJetTags"); |
663 |
|
sj.tchp=subjet_iter->bDiscriminator("trackCountingHighPurBJetTags"); |
664 |
|
sj.jp=subjet_iter->bDiscriminator("jetProbabilityBJetTags"); |
669 |
|
sj.charge=subjet_iter->jetCharge(); |
670 |
|
sj.ntracks=subjet_iter->associatedTracks().size(); |
671 |
|
sj.fourMomentum=GENPTOLORP(subjet_iter); |
672 |
< |
|
672 |
> |
sj.fourMomentum=(getChargedTracksMomentum(&*(subjet_iter))); |
673 |
|
hbbInfo->subJets.push_back(sj); |
674 |
|
|
675 |
|
} |
747 |
|
|
748 |
|
// int muInfo[12]; |
749 |
|
// fillMuBlock(mu, muInfo); |
750 |
< |
if(isMC){ |
750 |
> |
if(runOnMC_){ |
751 |
|
const GenParticle* muMc = mu->genLepton(); |
752 |
|
if(muMc!=0){ |
753 |
|
mf.mcId=muMc->pdgId(); |
772 |
|
Geom::Phi<double> deltaphi(elec->superCluster()->phi()-atan2(hbbInfo->calomet.fourMomentum.Py(),hbbInfo->calomet.fourMomentum.Px())); |
773 |
|
ef.acop = deltaphi.value(); |
774 |
|
|
775 |
< |
if(isMC){ |
775 |
> |
if(runOnMC_){ |
776 |
|
const GenParticle* elecMc = elec->genLepton(); |
777 |
|
if(elecMc!=0){ |
778 |
|
ef.mcId=elecMc->pdgId(); |
949 |
|
HbbAnalyzerNew::endJob() { |
950 |
|
} |
951 |
|
|
952 |
+ |
TVector2 HbbAnalyzerNew::getTvect( const pat::Jet* patJet ){ |
953 |
+ |
|
954 |
+ |
TVector2 t_Vect(0,0); |
955 |
+ |
TVector2 null(0,0); |
956 |
+ |
TVector2 ci(0,0); |
957 |
+ |
TLorentzVector pi(0,0,0,0); |
958 |
+ |
TLorentzVector J(0,0,0,0); |
959 |
+ |
TVector2 r(0,0); |
960 |
+ |
double patJetpfcPt = 1e10; |
961 |
+ |
double r_mag = 1e10; |
962 |
+ |
unsigned int nOfconst = 0; |
963 |
+ |
|
964 |
+ |
// std::cout <<" ECCCCCCOOOOO "<<patJet->isPFJet()<<std::endl; |
965 |
+ |
|
966 |
+ |
if (patJet->isPFJet() == false) { |
967 |
+ |
return t_Vect; |
968 |
+ |
} |
969 |
+ |
|
970 |
+ |
|
971 |
+ |
//re-reconstruct the jet direction with the charged tracks |
972 |
+ |
std::vector<reco::PFCandidatePtr> |
973 |
+ |
patJetpfc = patJet->getPFConstituents(); |
974 |
+ |
for(size_t idx = 0; idx < patJetpfc.size(); idx++){ |
975 |
+ |
if( patJetpfc.at(idx)->charge() != 0 ){ |
976 |
+ |
pi.SetPtEtaPhiE( patJetpfc.at(idx)->pt(), patJetpfc.at(idx)->eta(), patJetpfc.at(idx)->phi(), patJetpfc.at(idx)->energy() ); |
977 |
+ |
J += pi; |
978 |
+ |
nOfconst++; |
979 |
+ |
} |
980 |
+ |
} |
981 |
+ |
// if there are less than two charged tracks do not calculate the pull (there is not enough info). It returns a null vector |
982 |
+ |
|
983 |
+ |
if( nOfconst < 2 ) |
984 |
+ |
return null; |
985 |
+ |
|
986 |
+ |
|
987 |
+ |
|
988 |
+ |
TVector2 v_J( J.Rapidity(), J.Phi() ); |
989 |
+ |
//calculate TVector using only charged tracks |
990 |
+ |
for(size_t idx = 0; idx < patJetpfc.size(); idx++){ |
991 |
+ |
if( patJetpfc.at(idx)->charge() != 0 ){ |
992 |
+ |
patJetpfcPt = patJetpfc.at(idx)->pt(); |
993 |
+ |
pi.SetPtEtaPhiE( patJetpfc.at(idx)->pt(), patJetpfc.at(idx)->eta(), patJetpfc.at(idx)->phi(), patJetpfc.at(idx)->energy() ); |
994 |
+ |
r.Set( pi.Rapidity() - J.Rapidity(), Geom::deltaPhi( patJetpfc.at(idx)->phi(), J.Phi() ) ); |
995 |
+ |
r_mag = r.Mod(); |
996 |
+ |
t_Vect += ( patJetpfcPt / J.Pt() ) * r_mag * r; |
997 |
+ |
} |
998 |
+ |
} |
999 |
+ |
|
1000 |
+ |
|
1001 |
+ |
return t_Vect; |
1002 |
+ |
|
1003 |
+ |
} |
1004 |
+ |
|
1005 |
+ |
TLorentzVector HbbAnalyzerNew::getChargedTracksMomentum(const pat::Jet* patJet ){ |
1006 |
+ |
// return TLorentzVector(); |
1007 |
+ |
TLorentzVector pi(0,0,0,0); |
1008 |
+ |
TLorentzVector v_j1(0,0,0,0); |
1009 |
+ |
|
1010 |
+ |
|
1011 |
+ |
// std::cout <<"fff ECCCCCCOOOOO "<<patJet->isPFJet()<<std::endl; |
1012 |
+ |
|
1013 |
+ |
if (patJet->isPFJet() == false ){ |
1014 |
+ |
v_j1 = GENPTOLORP(patJet); |
1015 |
+ |
return v_j1; |
1016 |
+ |
} |
1017 |
+ |
std::vector<reco::PFCandidatePtr> |
1018 |
+ |
j1pfc = patJet->getPFConstituents(); |
1019 |
+ |
for(size_t idx = 0; idx < j1pfc.size(); idx++){ |
1020 |
+ |
if( j1pfc.at(idx)->charge() != 0 ){ |
1021 |
+ |
pi.SetPtEtaPhiE( j1pfc.at(idx)->pt(), j1pfc.at(idx)->eta(), j1pfc.at(idx)->phi(), j1pfc.at(idx)->energy() ); |
1022 |
+ |
v_j1 += pi; |
1023 |
+ |
} |
1024 |
+ |
} |
1025 |
+ |
return v_j1; |
1026 |
+ |
//re- |
1027 |
+ |
} |
1028 |
+ |
|
1029 |
|
//define this as a plug-in |
1030 |
|
DEFINE_FWK_MODULE(HbbAnalyzerNew); |