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.5 by tboccali, Thu Jun 9 16:51:52 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 526 | Line 529 | HbbAnalyzerNew::produce(edm::Event& iEve
529      sj.charge=jet_iter->jetCharge();
530      sj.ntracks=jet_iter->associatedTracks().size();
531      sj.fourMomentum=GENPTOLORP(jet_iter);
532 +    //
533 +    // add tVector
534 +    //
535 +    sj.tVector = getTvect(&(*jet_iter));
536  
537      Particle::LorentzVector p4Jet = jet_iter->p4();
538  
# Line 563 | Line 570 | HbbAnalyzerNew::produce(edm::Event& iEve
570      sj.ntracks=jet_iter->associatedTracks().size();
571      sj.fourMomentum=GENPTOLORP(jet_iter);
572  
573 +    sj.tVector = getTvect(&(*jet_iter));
574 +
575      Particle::LorentzVector p4Jet = jet_iter->p4();
576  
577      if(runOnMC_){
# Line 650 | Line 659 | HbbAnalyzerNew::produce(edm::Event& iEve
659      VHbbEvent::SimpleJet sj;
660  
661      sj.flavour = subjet_iter->partonFlavour();
662 <    
662 >    sj.tVector = getTvect(&(*subjet_iter));
663      sj.tche=subjet_iter->bDiscriminator("trackCountingHighEffBJetTags");
664      sj.tchp=subjet_iter->bDiscriminator("trackCountingHighPurBJetTags");
665      sj.jp=subjet_iter->bDiscriminator("jetProbabilityBJetTags");
# Line 941 | Line 950 | void
950   HbbAnalyzerNew::endJob() {
951   }
952  
953 +
954 + TVector2 HbbAnalyzerNew::getTvect( const pat::Jet* patJet ){
955 +
956 +  TVector2 t_Vect(0,0);
957 +  TVector2 null(0,0);
958 +  TVector2 ci(0,0);
959 +  TLorentzVector pi(0,0,0,0);
960 +  TLorentzVector J(0,0,0,0);
961 +  TVector2 r(0,0);
962 +  double patJetpfcPt = 1e10;
963 +  double r_mag = 1e10;
964 +  unsigned int nOfconst = 0;
965 +
966 + //re-reconstruct the jet direction with the charged tracks
967 +  std::vector<reco::PFCandidatePtr>
968 +    patJetpfc = patJet->getPFConstituents();
969 +  for(size_t idx = 0; idx < patJetpfc.size(); idx++){
970 +    if( patJetpfc.at(idx)->charge() != 0 ){
971 +      pi.SetPtEtaPhiE( patJetpfc.at(idx)->pt(), patJetpfc.at(idx)->eta(), patJetpfc.at(idx)->phi(), patJetpfc.at(idx)->energy() );
972 +      J += pi;
973 +      nOfconst++;
974 +    }
975 +  }
976 +
977 + // if there are less than two charged tracks do not calculate the pull (there is not enough info). It returns a null vector
978 +
979 +  if( nOfconst < 2 )
980 +    return null;
981 +
982 +  TVector2 v_J( J.Rapidity(), J.Phi() );
983 + //calculate TVector using only charged tracks
984 +  for(size_t idx = 0; idx < patJetpfc.size(); idx++){
985 +    if( patJetpfc.at(idx)->charge() != 0  ){
986 +      patJetpfcPt = patJetpfc.at(idx)->pt();
987 +      pi.SetPtEtaPhiE( patJetpfc.at(idx)->pt(), patJetpfc.at(idx)->eta(), patJetpfc.at(idx)->phi(), patJetpfc.at(idx)->energy() );
988 +      r.Set( pi.Rapidity() - J.Rapidity(), Geom::deltaPhi( patJetpfc.at(idx)->phi(), J.Phi() ) );
989 +      r_mag = r.Mod();
990 +      t_Vect += ( patJetpfcPt / J.Pt() ) * r_mag * r;
991 +    }
992 +  }
993 +
994 +  return t_Vect;
995 +  
996 + }
997 +
998 +
999   //define this as a plug-in
1000   DEFINE_FWK_MODULE(HbbAnalyzerNew);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines