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.1 by tboccali, Wed Jun 8 17:25:32 2011 UTC vs.
Revision 1.5 by tboccali, Thu Jun 9 16:51:52 2011 UTC

# Line 17 | Line 17 | Implementation:
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())
# Line 37 | Line 40 | HbbAnalyzerNew::HbbAnalyzerNew(const edm
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    //
48    // put the setwhatproduced etc etc
49  
# Line 311 | Line 317 | HbbAnalyzerNew::produce(edm::Event& iEve
317    
318    Handle<GenParticleCollection> genParticles;
319    
314  bool isMC=1;
320    bool printJet=0;
321    
322    
323 <  if(isMC){
323 >  if(runOnMC_){
324      
325      int Hin=-99,Win=-99,Zin=-99,bin=-99,bbarin=-99;
326      
# Line 524 | 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  
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];
# Line 535 | Line 544 | HbbAnalyzerNew::produce(edm::Event& iEve
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    
# Line 561 | 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(isMC){
577 >    if(runOnMC_){
578        double minb2DR=9999.;
579        for(size_t i = 0; i < genParticles->size(); ++ i) {
580          const GenParticle & p = (*genParticles)[i];
# Line 571 | Line 582 | HbbAnalyzerNew::produce(edm::Event& iEve
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
# Line 648 | 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 737 | Line 748 | HbbAnalyzerNew::produce(edm::Event& iEve
748  
749      //     int muInfo[12];
750      //     fillMuBlock(mu,  muInfo);
751 <    if(isMC){
751 >    if(runOnMC_){
752        const GenParticle* muMc = mu->genLepton();
753        if(muMc!=0){
754          mf.mcId=muMc->pdgId();
# Line 762 | Line 773 | HbbAnalyzerNew::produce(edm::Event& iEve
773      Geom::Phi<double> deltaphi(elec->superCluster()->phi()-atan2(hbbInfo->calomet.fourMomentum.Py(),hbbInfo->calomet.fourMomentum.Px()));
774      ef.acop = deltaphi.value();
775      
776 <    if(isMC){
776 >    if(runOnMC_){
777        const GenParticle* elecMc = elec->genLepton();
778        if(elecMc!=0){
779          ef.mcId=elecMc->pdgId();
# Line 939 | 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