ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/VHbbAnalysis/HbbAnalyzer/plugins/HbbAnalyzerNew.cc
(Generate patch)

Comparing UserCode/VHbbAnalysis/HbbAnalyzer/plugins/HbbAnalyzerNew.cc (file contents):
Revision 1.4 by tboccali, Thu Jun 9 07:07:12 2011 UTC vs.
Revision 1.6 by tboccali, Tue Jun 14 12:49:07 2011 UTC

# Line 20 | Line 20 | Implementation:
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())
28  
# Line 40 | Line 43 | HbbAnalyzerNew::HbbAnalyzerNew(const edm
43    hltResults_(iConfig.getUntrackedParameter<edm::InputTag>("hltResultsTag")),
44    runOnMC_(iConfig.getParameter<bool>("runOnMC")) {
45  
43
46    //
47    // put the setwhatproduced etc etc
48  
# Line 515 | Line 517 | HbbAnalyzerNew::produce(edm::Event& iEve
517      VHbbEvent::SimpleJet sj;
518      sj.flavour = jet_iter->partonFlavour();
519  
518
520      sj.tche=jet_iter->bDiscriminator("trackCountingHighEffBJetTags");
521      sj.tchp=jet_iter->bDiscriminator("trackCountingHighPurBJetTags");
522      sj.jp=jet_iter->bDiscriminator("jetProbabilityBJetTags");
# Line 526 | Line 527 | HbbAnalyzerNew::produce(edm::Event& iEve
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  
# Line 562 | Line 569 | HbbAnalyzerNew::produce(edm::Event& iEve
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  
# Line 625 | Line 634 | HbbAnalyzerNew::produce(edm::Event& iEve
634        hj.subFourMomentum.push_back(GENPTOLORP(icandJet));
635        hj.etaSub.push_back(icandJet->eta());
636        hj.phiSub.push_back(icandJet->phi());
628
637      
638      }
639      hbbInfo->hardJets.push_back(hj);
# Line 650 | Line 658 | HbbAnalyzerNew::produce(edm::Event& iEve
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");
# Line 661 | Line 669 | HbbAnalyzerNew::produce(edm::Event& iEve
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    }
# Line 941 | Line 949 | void
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);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines