Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bph reco update, jan 01 2017 #17111

Merged
merged 10 commits into from Jan 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions HeavyFlavorAnalysis/RecoDecay/interface/BPHDecayVertex.h
Expand Up @@ -32,6 +32,8 @@ namespace reco {
// C++ Headers --
//---------------
#include <vector>
#include <map>
#include <string>

// ---------------------
// -- Class Interface --
Expand Down Expand Up @@ -71,6 +73,9 @@ class BPHDecayVertex: public virtual BPHDecayMomentum {
/// get TransientTrack for a daughter
reco::TransientTrack* getTransientTrack( const reco::Candidate* cand ) const;

/// retrieve track search list
const std::string& getTrackSearchList( const reco::Candidate* cand ) const;

protected:

// constructor
Expand Down
21 changes: 13 additions & 8 deletions HeavyFlavorAnalysis/RecoDecay/interface/BPHMultiSelect.h
Expand Up @@ -20,6 +20,7 @@
#include "HeavyFlavorAnalysis/RecoDecay/interface/BPHRecoSelect.h"
#include "HeavyFlavorAnalysis/RecoDecay/interface/BPHMomentumSelect.h"
#include "HeavyFlavorAnalysis/RecoDecay/interface/BPHVertexSelect.h"
#include "HeavyFlavorAnalysis/RecoDecay/interface/BPHFitSelect.h"
class BPHRecoBuilder;
class BPHDecayMomentum;
class BPHDecayVertex;
Expand Down Expand Up @@ -83,6 +84,7 @@ class BPHMultiSelect: public T {
virtual bool accept( const reco::Candidate & cand ) const { return false; }
virtual bool accept( const BPHDecayMomentum& cand ) const { return false; }
virtual bool accept( const BPHDecayVertex & cand ) const { return false; }
virtual bool accept( const BPHKinematicFit & cand ) const { return false; }

private:

Expand Down Expand Up @@ -124,18 +126,21 @@ class BPHMultiSelect: public T {
};

template<>
bool BPHMultiSelect<BPHRecoSelect>::accept(
const reco::Candidate& cand,
const BPHRecoBuilder* build ) const;
bool BPHMultiSelect<BPHRecoSelect >::accept(
const reco::Candidate & cand,
const BPHRecoBuilder* build ) const;
template<>
bool BPHMultiSelect<BPHRecoSelect>::accept(
const reco::Candidate& cand ) const;
bool BPHMultiSelect<BPHRecoSelect >::accept(
const reco::Candidate & cand ) const;
template<>
bool BPHMultiSelect<BPHMomentumSelect>::accept(
const BPHDecayMomentum& cand ) const;
const BPHDecayMomentum& cand ) const;
template<>
bool BPHMultiSelect<BPHVertexSelect>::accept(
const BPHDecayVertex& cand ) const;
bool BPHMultiSelect<BPHVertexSelect >::accept(
const BPHDecayVertex & cand ) const;
template<>
bool BPHMultiSelect<BPHFitSelect >::accept(
const BPHKinematicFit & cand ) const;

#endif

Expand Up @@ -65,8 +65,8 @@ class BPHPlusMinusCandidate: public BPHRecoCandidate,
/// charge selection is applied inside
static std::vector<BPHPlusMinusConstCandPtr> build(
const BPHRecoBuilder& builder,
const std::string nPos,
const std::string nNeg,
const std::string& nPos,
const std::string& nNeg,
double mass = -1,
double msig = -1 );

Expand Down
7 changes: 5 additions & 2 deletions HeavyFlavorAnalysis/RecoDecay/interface/BPHTrackReference.h
Expand Up @@ -66,10 +66,13 @@ class BPHTrackReference {
/// s : pat :: Muon :: standAloneMuon ()
/// e : pat :: Electron :: pfCandidateRef ()
static const reco::Track* getTrack( const reco::Candidate& rc,
const char* modeList = "cfhbpmnigse" ) {
const char* modeList = "cfhbpmnigse",
char* modeFlag = 0 ) {
if ( rc.charge() == 0 ) return 0;
const char* mptr = modeList;
char mode;
char c;
if ( modeFlag == 0 ) modeFlag = &c;
char& mode = *modeFlag;
const reco::Track* tkp = 0;
while ( ( mode = *mptr++ ) ) {
switch ( mode ) {
Expand Down
11 changes: 9 additions & 2 deletions HeavyFlavorAnalysis/RecoDecay/src/BPHDecayMomentum.cc
Expand Up @@ -119,8 +119,10 @@ const reco::Candidate* BPHDecayMomentum::getDaug(
// return a simple particle from the name
// return null pointer if not found
string::size_type pos = name.find( "/" );
if ( pos != string::npos ) return getComp( name.substr( 0, pos ) )
->getDaug( name.substr( pos + 1 ) );
if ( pos != string::npos ) {
const BPHRecoCandidate* comp = getComp( name.substr( 0, pos ) ).get();
return ( comp == 0 ? 0 : comp->getDaug( name.substr( pos + 1 ) ) );
}
map<const string,
const reco::Candidate*>::const_iterator iter = dMap.find( name );
return ( iter != dMap.end() ? iter->second : 0 );
Expand All @@ -130,6 +132,11 @@ const reco::Candidate* BPHDecayMomentum::getDaug(
BPHRecoConstCandPtr BPHDecayMomentum::getComp( const string& name ) const {
// return a previously reconstructed particle from the name
// return null pointer if not found
string::size_type pos = name.find( "/" );
if ( pos != string::npos ) {
const BPHRecoCandidate* comp = getComp( name.substr( 0, pos ) ).get();
return ( comp == 0 ? 0 : comp->getComp( name.substr( pos + 1 ) ) );
}
map<const string,
BPHRecoConstCandPtr>::const_iterator iter = cMap.find( name );
return ( iter != cMap.end() ? iter->second : 0 );
Expand Down
14 changes: 12 additions & 2 deletions HeavyFlavorAnalysis/RecoDecay/src/BPHDecayVertex.cc
Expand Up @@ -95,7 +95,7 @@ bool BPHDecayVertex::validTracks() const {

bool BPHDecayVertex::validVertex() const {
if ( oldVertex ) fitVertex();
return fittedVertex.isValid();
return validTks && fittedVertex.isValid();
}


Expand Down Expand Up @@ -139,12 +139,22 @@ reco::TransientTrack* BPHDecayVertex::getTransientTrack(
}


const string& BPHDecayVertex::getTrackSearchList(
const reco::Candidate* cand ) const {
static string dum = "";
map<const reco::Candidate*,string>::const_iterator iter =
searchMap.find( cand );
if ( iter != searchMap.end() ) return iter->second;
return dum;
}


void BPHDecayVertex::addV( const string& name,
const reco::Candidate* daug,
const string& searchList,
double mass ) {
addP( name, daug, mass );
searchMap[daug] = searchList;
searchMap[daughters().back()] = searchList;
return;
}

Expand Down
21 changes: 14 additions & 7 deletions HeavyFlavorAnalysis/RecoDecay/src/BPHMultiSelect.cc
Expand Up @@ -42,16 +42,16 @@
// Operations --
//--------------
template<>
bool BPHMultiSelect<BPHRecoSelect>::accept(
const reco::Candidate& cand,
const BPHRecoBuilder* build ) const {
bool BPHMultiSelect<BPHRecoSelect >::accept(
const reco::Candidate & cand,
const BPHRecoBuilder* build ) const {
return select( cand, build );
}


template<>
bool BPHMultiSelect<BPHRecoSelect>::accept(
const reco::Candidate& cand ) const {
bool BPHMultiSelect<BPHRecoSelect >::accept(
const reco::Candidate & cand ) const {
return select( cand );
}

Expand All @@ -64,8 +64,15 @@ bool BPHMultiSelect<BPHMomentumSelect>::accept(


template<>
bool BPHMultiSelect<BPHVertexSelect>::accept(
const BPHDecayVertex& cand ) const {
bool BPHMultiSelect<BPHVertexSelect >::accept(
const BPHDecayVertex & cand ) const {
return select( cand );
}


template<>
bool BPHMultiSelect<BPHFitSelect >::accept(
const BPHKinematicFit & cand ) const {
return select( cand );
}

4 changes: 2 additions & 2 deletions HeavyFlavorAnalysis/RecoDecay/src/BPHPlusMinusCandidate.cc
Expand Up @@ -97,8 +97,8 @@ void BPHPlusMinusCandidate::add( const string& name,

vector<BPHPlusMinusConstCandPtr> BPHPlusMinusCandidate::build(
const BPHRecoBuilder& builder,
const string nPos,
const string nNeg,
const string& nPos,
const string& nNeg,
double mass, double msig ) {
vector<BPHPlusMinusConstCandPtr> cList;
class ChargeSelect: public BPHRecoSelect {
Expand Down
Expand Up @@ -45,8 +45,8 @@ class BPHKx0ToKPiBuilder {
/** Constructor
*/
BPHKx0ToKPiBuilder( const edm::EventSetup& es,
const BPHRecoBuilder::BPHGenericCollection* kaonCollection,
const BPHRecoBuilder::BPHGenericCollection* pionCollection );
const BPHRecoBuilder::BPHGenericCollection* posCollection,
const BPHRecoBuilder::BPHGenericCollection* negCollection );

/** Destructor
*/
Expand Down Expand Up @@ -84,8 +84,8 @@ class BPHKx0ToKPiBuilder {
std::string pionName;

const edm::EventSetup* evSetup;
const BPHRecoBuilder::BPHGenericCollection* kCollection;
const BPHRecoBuilder::BPHGenericCollection* pCollection;
const BPHRecoBuilder::BPHGenericCollection* nCollection;

BPHParticlePtSelect * ptSel;
BPHParticleEtaSelect* etaSel;
Expand Down
Expand Up @@ -69,7 +69,8 @@ class BPHOniaToMuMuBuilder {
std::vector<BPHPlusMinusConstCandPtr> getList( oniaType type,
BPHRecoSelect * dSel = 0,
BPHMomentumSelect* mSel = 0,
BPHVertexSelect * vSel = 0 );
BPHVertexSelect * vSel = 0,
BPHFitSelect * kSel = 0 );

/// retrieve original candidate from a copy with the same daughters
/// obtained through "getList"
Expand Down
Expand Up @@ -172,9 +172,8 @@ class BPHWriteSpecificDecay:
const RefCountedKinematicParticle kinPart = ptr->currentParticle();
const KinematicState kinStat = kinPart->currentState();
cc.addUserFloat( "fitMass", kinStat.mass() );
cc.addUserData ( "fitMomentum",
kinStat.kinematicParameters().momentum() );

if ( writeMomentum ) cc.addUserData ( "fitMomentum",
kinStat.kinematicParameters().momentum() );
}

}
Expand Down
12 changes: 6 additions & 6 deletions HeavyFlavorAnalysis/SpecificDecay/src/BPHKx0ToKPiBuilder.cc
Expand Up @@ -40,13 +40,13 @@ using namespace std;
//----------------
BPHKx0ToKPiBuilder::BPHKx0ToKPiBuilder(
const edm::EventSetup& es,
const BPHRecoBuilder::BPHGenericCollection* kaonCollection,
const BPHRecoBuilder::BPHGenericCollection* pionCollection ):
const BPHRecoBuilder::BPHGenericCollection* posCollection,
const BPHRecoBuilder::BPHGenericCollection* negCollection ):
kaonName( "Kaon" ),
pionName( "Pion" ),
evSetup( &es ),
kCollection( kaonCollection ),
pCollection( pionCollection ) {
pCollection( posCollection ),
nCollection( negCollection ) {
ptSel = new BPHParticlePtSelect ( 0.7 );
etaSel = new BPHParticleEtaSelect( 10.0 );
massSel = new BPHMassSelect( 0.75, 1.05 );
Expand All @@ -72,9 +72,9 @@ vector<BPHPlusMinusConstCandPtr> BPHKx0ToKPiBuilder::build() {
if ( updated ) return kx0List;

BPHRecoBuilder bKx0( *evSetup );
bKx0.add( kaonName, kCollection, BPHParticleMasses::kaonMass,
bKx0.add( kaonName, pCollection, BPHParticleMasses::kaonMass,
BPHParticleMasses::kaonMSigma );
bKx0.add( pionName, pCollection, BPHParticleMasses::pionMass,
bKx0.add( pionName, nCollection, BPHParticleMasses::pionMass,
BPHParticleMasses::pionMSigma );
bKx0.filter( kaonName, *ptSel );
bKx0.filter( pionName, *ptSel );
Expand Down
24 changes: 15 additions & 9 deletions HeavyFlavorAnalysis/SpecificDecay/src/BPHOniaToMuMuBuilder.cc
Expand Up @@ -122,7 +122,8 @@ vector<BPHPlusMinusConstCandPtr> BPHOniaToMuMuBuilder::getList(
oniaType type,
BPHRecoSelect * dSel,
BPHMomentumSelect* mSel,
BPHVertexSelect * vSel ) {
BPHVertexSelect * vSel,
BPHFitSelect * kSel ) {
extractList( type );
vector<BPHPlusMinusConstCandPtr>& list = oniaList[type];
int i;
Expand All @@ -139,6 +140,7 @@ vector<BPHPlusMinusConstCandPtr> BPHOniaToMuMuBuilder::getList(
if ( ( dSel != 0 ) && ( !dSel->accept( *muNeg ) ) ) continue;
if ( ( mSel != 0 ) && ( !mSel->accept( *ptr ) ) ) continue;
if ( ( vSel != 0 ) && ( !vSel->accept( *ptr ) ) ) continue;
if ( ( kSel != 0 ) && ( !kSel->accept( *ptr ) ) ) continue;
lsub.push_back( list[i] );
}
return lsub;
Expand All @@ -147,15 +149,15 @@ vector<BPHPlusMinusConstCandPtr> BPHOniaToMuMuBuilder::getList(

BPHPlusMinusConstCandPtr BPHOniaToMuMuBuilder::getOriginalCandidate(
const BPHRecoCandidate& cand ) {
const reco::Candidate* mp = cand.originalReco( cand.getDaug( muPosName ) );
const reco::Candidate* mn = cand.originalReco( cand.getDaug( muNegName ) );
int nc = fullList.size();
int ic;
for ( ic = 0; ic < nc; ++ ic ) {
BPHPlusMinusConstCandPtr pmp = fullList[ic];
const BPHPlusMinusCandidate* pmc = pmp.get();
if ( pmc->originalReco( pmc->getDaug( muPosName ) ) !=
cand.originalReco( cand.getDaug( muPosName ) ) ) continue;
if ( pmc->originalReco( pmc->getDaug( muNegName ) ) !=
cand.originalReco( cand.getDaug( muNegName ) ) ) continue;
if ( pmc->originalReco( pmc->getDaug( muPosName ) ) != mp ) continue;
if ( pmc->originalReco( pmc->getDaug( muNegName ) ) != mn ) continue;
return pmp;
}
return BPHPlusMinusConstCandPtr( 0 );
Expand Down Expand Up @@ -291,17 +293,21 @@ void BPHOniaToMuMuBuilder::extractList( oniaType type ) {
list.reserve( n );
for ( i = 0; i < n; ++i ) {
BPHPlusMinusConstCandPtr ptr = fullList[i];
const reco::Candidate* muPos = ptr->originalReco( ptr->getDaug( "MuPos" ) );
const reco::Candidate* muNeg = ptr->originalReco( ptr->getDaug( "MuNeg" ) );
const reco::Candidate* mcPos = ptr->getDaug( "MuPos" );
const reco::Candidate* mcNeg = ptr->getDaug( "MuNeg" );
const reco::Candidate* muPos = ptr->originalReco( mcPos );
const reco::Candidate* muNeg = ptr->originalReco( mcNeg );
if ( !par.massSel->accept( *ptr ) ) continue;
if ( !par. ptSel->accept( *muPos ) ) continue;
if ( !par. etaSel->accept( *muPos ) ) continue;
if ( !par. ptSel->accept( *muNeg ) ) continue;
if ( !par. etaSel->accept( *muNeg ) ) continue;
if ( !par.chi2Sel->accept( *ptr ) ) continue;
BPHPlusMinusCandidate* np = new BPHPlusMinusCandidate( evSetup );
np->add( "MuPos", muPos, BPHParticleMasses::muonMass );
np->add( "MuNeg", muNeg, BPHParticleMasses::muonMass );
np->add( "MuPos", muPos, ptr->getTrackSearchList( mcPos ),
BPHParticleMasses::muonMass );
np->add( "MuNeg", muNeg, ptr->getTrackSearchList( mcNeg ),
BPHParticleMasses::muonMass );
if ( par.mass > 0.0 )
np->setConstraint( par.mass, par.sigma );
list.push_back( BPHPlusMinusConstCandPtr( np ) );
Expand Down
Expand Up @@ -345,7 +345,7 @@ void TestBPHSpecificDecay::analyze( const edm::Event& ev,
const reco::Candidate* mNeg = bu->originalReco(
bu->getDaug( "JPsi/MuNeg" ) );
const reco::Candidate* kaon = bu->originalReco(
bu->getDaug( "kaon" ) );
bu->getDaug( "Kaon" ) );
BPHRecoCandidatePtr njp( new BPHPlusMinusCandidate( &es ) );
njp->add( "MuPos", mPos,
BPHParticleMasses::muonMass,
Expand Down