19 #include "Math/VectorUtil.h" 33 #define SET_LABEL(NAME,PSET) ( NAME = PSET.getParameter<string>( #NAME ) ) 42 const string&
name ) {
43 if ( cand.hasUserData(
name ) )
return cand.userData<
T>(
name );
48 const string&
name ) {
52 if ( ref ==
nullptr )
return nullptr;
53 if ( ref->isNull() )
return nullptr;
63 static vector<const reco::Candidate*>
get(
66 int n = cand.numberOfDaughters();
67 vector<const reco::Candidate*>
v;
69 for ( i = 0; i <
n; ++
i ) {
72 if ( ( mass > massMin ) && ( mass <
massMax ) ) v.push_back( dptr );
82 int cutPixelLayers = 0,
85 bool goodMuon =
true ,
87 cutTL ( cutTrackerLayers ),
88 cutPL ( cutPixelLayers ),
96 if ( p ==
nullptr )
return false;
99 if ( p->
innerTrack()->hitPattern().trackerLayersWithMeasurement() <= cutTL )
101 if ( p->
innerTrack()->hitPattern(). pixelLayersWithMeasurement() <= cutPL )
106 if ( pv ==
nullptr )
return true;
108 if ( fabs( p->
innerTrack()->dxy( pos ) ) >= maxXY )
132 softMuonselector =
nullptr ): pLMin( ptMinLoose ),
134 eLMax( etaMaxLoose ),
135 eTMax( etaMaxTight ),
136 sms( softMuonselector ) {
142 if ( dptr0 ==
nullptr )
return false;
143 if ( dptr1 ==
nullptr )
return false;
144 float pt0 = dptr0->
pt();
145 float pt1 = dptr1->
pt();
146 if ( ( pt0 < pLMin ) || ( pt1 < pLMin ) )
return false;
147 if ( ( pt0 <
pTMin ) && ( pt1 <
pTMin ) )
return false;
148 float eta0 = fabs( dptr0->
eta() );
149 float eta1 = fabs( dptr1->
eta() );
150 if ( ( eLMax > 0 ) &&
151 ( ( eta0 > eLMax ) || ( eta1 > eLMax ) ) )
return false;
152 if ( ( eTMax > 0 ) &&
153 ( ( eta0 > eTMax ) && ( eta1 > eTMax ) ) )
return false;
154 if ( sms !=
nullptr ) {
157 if ( pvtx ==
nullptr )
return false;
158 if ( !sms->accept( *dptr0, pvtx ) )
return false;
159 if ( !sms->accept( *dptr1, pvtx ) )
return false;
178 float rapidityMax = -1.0 ): mMin( massMin ),
182 yMax( rapidityMax ) {
186 if ( ( ( mMin > 0 ) && ( mMax < 0 ) ) ||
187 ( ( mMin < 0 ) && ( mMax > 0 ) ) ||
188 ( ( mMin > 0 ) && ( mMax > 0 ) && ( mMin < mMax ) ) ) {
190 if ( mass < mMin )
return false;
192 ( mass > mMax ) )
return false;
194 if ( cand.
pt() <
pMin )
return false;
196 ( fabs( cand.
eta() ) >
eMax ) )
return false;
217 float rapidityMax = -1.0 ): mMin( massMin ),
221 rMax( rapidityMax ) {
227 if ( ( ( mMin > 0 ) && ( mMax < 0 ) ) ||
228 ( ( mMin < 0 ) && ( mMax > 0 ) ) ||
229 ( ( mMin > 0 ) && ( mMax > 0 ) && ( mMin < mMax ) ) ) {
230 if ( mass < mMin )
return false;
232 ( mass > mMax ) )
return false;
236 if ( fmom ==
nullptr )
return false;
241 if ( fabs( fmom->
eta() ) >
eMax )
return false;
247 float e =
sqrt( ( x * x ) + ( y * y ) + ( z * z ) + ( mass * mass ) );
248 float r =
log( ( e + z ) / ( e - z ) ) / 2;
249 if ( fabs( r ) >
rMax )
return false;
267 float sigMin = -1.0 ):
pMin( probMin ),
275 if ( svtx ==
nullptr )
return false;
276 if ( pvtx ==
nullptr )
return false;
279 svtx->
ndof() ) <
pMin )
return false;
281 if ( ( cMin > 0 ) || ( sMin > 0 ) ) {
282 TVector3 disp( svtx->
x() - pvtx->x(),
283 svtx->
y() - pvtx->y(),
285 TVector3 cmom( cand.px(), cand.py(), 0 );
286 float cosAlpha = disp.Dot( cmom ) / ( disp.Perp() * cmom.Perp() );
287 if ( cosAlpha < cMin )
return false;
288 if ( sMin < 0 )
return true;
289 float mass = cand.mass();
293 double ctauPV = distXY.
value() * cosAlpha * mass / cmom.Perp();
297 double ctauErrPV =
sqrt( ROOT::Math::Similarity( vmom, vXYe ) ) * mass /
299 if ( ( ctauPV / ctauErrPV ) < sMin )
return false;
315 float sigMin = -1.0 ):
pMin( probMin ),
323 if ( svtx ==
nullptr )
return false;
326 svtx->
ndof() ) <
pMin )
return false;
328 if ( ( cMin > 0 ) || ( sMin > 0 ) ) {
329 TVector3 disp( svtx->
x() - pvtx->
x(),
330 svtx->
y() - pvtx->
y(),
334 if ( fmom ==
nullptr )
return false;
335 TVector3 cmom( fmom->x(), fmom->y(), 0 );
336 float cosAlpha = disp.Dot( cmom ) / ( disp.Perp() * cmom.Perp() );
337 if ( cosAlpha < cMin )
return false;
338 if ( sMin < 0 )
return true;
339 if ( !cand.hasUserFloat(
"fitMass" ) )
return false;
340 float mass = cand.userFloat(
"fitMass" );
344 double ctauPV = distXY.
value() * cosAlpha * mass / cmom.Perp();
348 double ctauErrPV =
sqrt( ROOT::Math::Similarity( vmom, vXYe ) ) * mass /
350 if ( ( ctauPV / ctauErrPV ) < sMin )
return false;
364 useOnia = (
SET_LABEL( oniaCandsLabel, ps ) !=
"" );
365 useSd = (
SET_LABEL( sdCandsLabel, ps ) !=
"" );
366 useSs = (
SET_LABEL( ssCandsLabel, ps ) !=
"" );
367 useBu = (
SET_LABEL( buCandsLabel, ps ) !=
"" );
368 useBd = (
SET_LABEL( bdCandsLabel, ps ) !=
"" );
369 useBs = (
SET_LABEL( bsCandsLabel, ps ) !=
"" );
370 if ( useOnia ) consume< vector<pat::CompositeCandidate> >( oniaCandsToken,
372 if ( useSd ) consume< vector<pat::CompositeCandidate> >( sdCandsToken,
374 if ( useSs ) consume< vector<pat::CompositeCandidate> >( ssCandsToken,
376 if ( useBu ) consume< vector<pat::CompositeCandidate> >( buCandsToken,
378 if ( useBd ) consume< vector<pat::CompositeCandidate> >( bdCandsToken,
380 if ( useBs ) consume< vector<pat::CompositeCandidate> >( bsCandsToken,
385 double phiMassMin = 0.85;
386 double phiMassMax = 3.30;
387 double phiPtMin = 16.0;
388 double phiEtaMax = -1.0;
389 double phiRMax = -1.0;
390 double jPsiMassMin = 2.95;
391 double jPsiMassMax = 3.30;
392 double jPsiPtMin = 16.0;
393 double jPsiEtaMax = -1.0;
394 double jPsiRMax = -1.0;
395 double psi2MassMin = 3.40;
396 double psi2MassMax = 4.00;
397 double psi2PtMin = 13.0;
398 double psi2EtaMax = -1.0;
399 double psi2RMax = -1.0;
400 double upsMassMin = 8.50;
401 double upsMassMax = 11.0;
402 double upsPtMin = 13.0;
403 double upsEtaMax = -1.0;
404 double upsRMax = -1.0;
406 double oniaProbMin = 0.005;
407 double oniaCosMin = -1.0;
408 double oniaSigMin = -1.0;
410 double oniaMuPtMinLoose = -1.0;
411 double oniaMuPtMinTight = -1.0;
412 double oniaMuEtaMaxLoose = -1.0;
413 double oniaMuEtaMaxTight = -1.0;
416 phiMassMin, phiMassMax,
417 phiPtMin , phiEtaMax , phiRMax );
419 jPsiMassMin, jPsiMassMax,
420 jPsiPtMin , jPsiEtaMax , jPsiRMax );
422 psi2MassMin, psi2MassMax,
423 psi2PtMin , psi2EtaMax , psi2RMax );
425 upsMassMin, upsMassMax,
426 upsPtMin , upsEtaMax , upsRMax );
428 oniaProbMin, oniaCosMin, oniaSigMin );
430 oniaMuPtMinLoose , oniaMuPtMinTight ,
431 oniaMuEtaMaxLoose, oniaMuEtaMaxTight, &sms );
435 double buJPsiPtMin = 8.0;
436 double buJPsiEtaMax = -1.0;
437 double buJPsiRMax = -1.0;
438 double buProbMin = 0.10;
439 double buCosMin = 0.99;
440 double buSigMin = 3.0;
441 double buMuPtMinLoose = 4.0;
442 double buMuPtMinTight = 4.0;
443 double buMuEtaMaxLoose = 2.2;
444 double buMuEtaMaxTight = 2.2;
449 buJPsiMassMin, buJPsiMassMax,
450 buJPsiPtMin , buJPsiEtaMax , buJPsiRMax );
452 buProbMin, buCosMin, buSigMin );
454 buMuPtMinLoose , buMuPtMinTight ,
455 buMuEtaMaxLoose, buMuEtaMaxTight, &sms );
459 double bdJPsiPtMin = 8.0;
460 double bdJPsiEtaMax = -1.0;
461 double bdJPsiRMax = -1.0;
464 double bdKx0PtMin = -1.0;
465 double bdKx0EtaMax = -1.0;
466 double bdKx0RMax = -1.0;
467 double bdProbMin = 0.10;
468 double bdCosMin = 0.99;
469 double bdSigMin = 3.0;
470 double bdMuPtMinLoose = 4.0;
471 double bdMuPtMinTight = 4.0;
472 double bdMuEtaMaxLoose = 2.2;
473 double bdMuEtaMaxTight = 2.2;
476 bdJPsiMassMin, bdJPsiMassMax,
477 bdJPsiPtMin , bdJPsiEtaMax , bdJPsiRMax );
479 bdKx0MassMin, bdKx0MassMax,
480 bdKx0PtMin , bdKx0EtaMax , bdKx0RMax );
482 bdProbMin, bdCosMin, bdSigMin );
484 bdMuPtMinLoose , bdMuPtMinTight ,
485 bdMuEtaMaxLoose, bdMuEtaMaxTight, &sms );
489 double bsJPsiPtMin = 8.0;
490 double bsJPsiEtaMax = -1.0;
491 double bsJPsiRMax = -1.0;
494 double bsPhiPtMin = -1.0;
495 double bsPhiEtaMax = -1.0;
496 double bsPhiRMax = -1.0;
497 double bsProbMin = 0.10;
498 double bsCosMin = 0.99;
499 double bsSigMin = 3.0;
500 double bsMuPtMinLoose = 4.0;
501 double bsMuPtMinTight = 4.0;
502 double bsMuEtaMaxLoose = 2.2;
503 double bsMuEtaMaxTight = 2.2;
505 bsJPsiMassMin, bsJPsiMassMax,
506 bsJPsiPtMin , bsJPsiEtaMax , bsJPsiRMax );
508 bsPhiMassMin, bsPhiMassMax,
509 bsPhiPtMin , bsPhiEtaMax , bsPhiRMax );
511 bsProbMin, bsCosMin, bsSigMin );
513 bsMuPtMinLoose , bsMuPtMinTight ,
514 bsMuEtaMaxLoose, bsMuEtaMaxTight, &sms );
521 delete phiBasicSelect;
522 delete jPsiBasicSelect;
523 delete psi2BasicSelect;
524 delete upsBasicSelect;
525 delete oniaVertexSelect;
526 delete oniaDaughterSelect;
528 delete buJPsiBasicSelect;
529 delete buVertexSelect;
530 delete buJPsiDaughterSelect;
532 delete bdJPsiBasicSelect;
533 delete bdKx0BasicSelect;
534 delete bdVertexSelect;
535 delete bdJPsiDaughterSelect;
537 delete bsJPsiBasicSelect;
538 delete bsPhiBasicSelect;
539 delete bsVertexSelect;
540 delete bsJPsiDaughterSelect;
548 desc.
add<
string>(
"oniaCandsLabel",
"" );
549 desc.
add<
string>(
"sdCandsLabel",
"" );
550 desc.
add<
string>(
"ssCandsLabel",
"" );
551 desc.
add<
string>(
"buCandsLabel",
"" );
552 desc.
add<
string>(
"bdCandsLabel",
"" );
553 desc.
add<
string>(
"bsCandsLabel",
"" );
554 descriptions.
add(
"bphHistoSpecificDecay", desc );
560 createHisto(
"massPhi" , 35, 0.85, 1.20 );
561 createHisto(
"massJPsi" , 35, 2.95, 3.30 );
562 createHisto(
"massPsi2" , 60, 3.40, 4.00 );
563 createHisto(
"massUps123" , 125, 8.50, 11.0 );
564 createHisto(
"massBu" , 50, 5.00, 6.00 );
565 createHisto(
"massBd" , 50, 5.00, 6.00 );
566 createHisto(
"massBs" , 50, 5.00, 6.00 );
567 createHisto(
"mfitBu" , 50, 5.00, 6.00 );
568 createHisto(
"mfitBd" , 50, 5.00, 6.00 );
569 createHisto(
"mfitBs" , 50, 5.00, 6.00 );
570 createHisto(
"massBuJPsi" , 35, 2.95, 3.30 );
571 createHisto(
"massBdJPsi" , 35, 2.95, 3.30 );
572 createHisto(
"massBsJPsi" , 35, 2.95, 3.30 );
573 createHisto(
"massBsPhi" , 50, 1.01, 1.03 );
574 createHisto(
"massBdKx0" , 50, 0.80, 1.05 );
576 createHisto(
"massFull" , 200, 2.00, 12.0 );
598 oniaCandsToken.get( ev, oniaCands );
599 nqo = oniaCands->size();
602 for ( iqo = 0; iqo < nqo; ++ iqo ) {
604 <<
"*********** quarkonium " << iqo <<
"/" << nqo <<
" ***********";
606 if ( !oniaVertexSelect->accept( cand,
607 BPHUserData::getByRef<reco::Vertex>( cand,
608 "primaryVertex" ) ) )
continue;
609 if ( !oniaDaughterSelect->accept( cand ) )
continue;
610 fillHisto(
"Full", cand );
611 if ( phiBasicSelect->accept( cand ) ) fillHisto(
"Phi" , cand );
612 if ( jPsiBasicSelect->accept( cand ) ) fillHisto(
"JPsi" , cand );
613 if ( psi2BasicSelect->accept( cand ) ) fillHisto(
"Psi2" , cand );
614 if ( upsBasicSelect->accept( cand ) ) fillHisto(
"Ups123", cand );
623 buCandsToken.get( ev, buCands );
624 nbu = buCands->size();
627 for ( ibu = 0; ibu < nbu; ++ ibu ) {
629 <<
"*********** Bu " << ibu <<
"/" << nbu <<
" ***********";
635 if ( jPsi ==
nullptr )
continue;
636 if ( !buJPsiBasicSelect ->
accept( *jPsi ) )
continue;
637 if ( !buJPsiDaughterSelect->accept( *jPsi ) )
continue;
638 if ( !buVertexSelect->accept( cand,
639 BPHUserData::getByRef<reco::Vertex>( *jPsi,
640 "primaryVertex" ) ) )
continue;
642 if ( kptr ==
nullptr )
continue;
643 if ( kptr->
pt() < buKPtMin )
continue;
644 fillHisto(
"Bu" , cand );
645 fillHisto(
"BuJPsi", *jPsi );
654 bdCandsToken.get( ev, bdCands );
655 nbd = bdCands->size();
658 for ( ibd = 0; ibd < nbd; ++ ibd ) {
660 <<
"*********** Bd " << ibd <<
"/" << nbd <<
" ***********";
666 if ( jPsi ==
nullptr )
continue;
671 if ( kx0 ==
nullptr )
continue;
672 if ( !bdJPsiBasicSelect ->
accept( *jPsi ) )
continue;
673 if ( !bdKx0BasicSelect ->
accept( * kx0 ) )
continue;
674 if ( !bdJPsiDaughterSelect->accept( *jPsi ) )
continue;
675 if ( !bdVertexSelect->accept( cand,
676 BPHUserData::getByRef<reco::Vertex>( *jPsi,
677 "primaryVertex" ) ) )
continue;
678 fillHisto(
"Bd" , cand );
679 fillHisto(
"BdJPsi", *jPsi );
680 fillHisto(
"BdKx0" , *kx0 );
689 bsCandsToken.get( ev, bsCands );
690 nbs = bsCands->size();
693 for ( ibs = 0; ibs < nbs; ++ ibs ) {
695 <<
"*********** Bs " << ibs <<
"/" << nbs <<
" ***********";
701 if ( jPsi ==
nullptr )
continue;
706 if ( phi ==
nullptr )
continue;
707 if ( !bsJPsiBasicSelect ->
accept( *jPsi ) )
continue;
708 if ( !bsPhiBasicSelect ->
accept( * phi ) )
continue;
709 if ( !bsJPsiDaughterSelect->accept( *jPsi ) )
continue;
710 if ( !bsVertexSelect->accept( cand,
711 BPHUserData::getByRef<reco::Vertex>( *jPsi,
712 "primaryVertex" ) ) )
continue;
713 fillHisto(
"Bs" , cand );
714 fillHisto(
"BsJPsi", *jPsi );
715 fillHisto(
"BsPhi" , *phi );
732 cand. userFloat(
"fitMass" ) : -1 );
733 fillHisto(
"mass" +
name, cand.
mass() );
734 fillHisto(
"mfit" +
name, mass );
740 map<string,TH1F*>::iterator iter = histoMap.find(
name );
741 map<string,TH1F*>::iterator iend = histoMap.end();
742 if ( iter == iend )
return;
743 iter->second->Fill( x );
749 int nbin,
float hmin,
float hmax ) {
750 histoMap[
name] = fs->make<TH1F>( name.c_str(), name.c_str(),
Analysis-level particle class.
BPHDaughterSelect(float ptMinLoose, float ptMinTight, float etaMaxLoose, float etaMaxTight, const BPHSoftMuonSelect *softMuonselector=0)
BPHHistoSpecificDecay(const edm::ParameterSet &ps)
BPHCompositeBasicSelect(float massMin, float massMax, float ptMin=-1.0, float etaMax=-1.0, float rapidityMax=-1.0)
BPHFittedVertexSelect(float probMin, float cosMin=-1.0, float sigMin=-1.0)
static const T * getByRef(const pat::CompositeCandidate &cand, const string &name)
bool accept(const pat::CompositeCandidate &cand, const reco::Vertex *pv=0) const override
const AlgebraicSymMatrix33 matrix() const
double y() const
y coordinate
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
double rapidity() const final
rapidity
bool hasUserFloat(const std::string &key) const
Return true if there is a user-defined float with a given name.
bool accept(const pat::CompositeCandidate &cand, const reco::Vertex *pvtx=0) const override
static const double jPsiMass
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
const Point & position() const
position
float userFloat(const std::string &key) const
static const T * get(const pat::CompositeCandidate &cand, const string &name)
bool accept(const pat::CompositeCandidate &cand, const reco::Vertex *pv=0) const override
void analyze(const edm::Event &ev, const edm::EventSetup &es) override
#define DEFINE_FWK_MODULE(type)
static const double kx0Mass
reco::TrackRef innerTrack() const override
reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
void createHisto(const std::string &name, int nbin, float hmin, float hmax)
ROOT::Math::SVector< double, 3 > AlgebraicVector3
double chi2() const
chi-squares
math::XYZPoint Point
point in the space
float ChiSquaredProbability(double chiSquared, double nrDOF)
BPHFittedBasicSelect(float massMin, float massMax, float ptMin=-1.0, float etaMax=-1.0, float rapidityMax=-1.0)
const Candidate * daughter(size_type) const override
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
const T * userData(const std::string &key) const
Returns user-defined data. Returns NULL if the data is not present, or not of type T...
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool hasUserData(const std::string &key) const
Check if user data with a specific type is present.
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call
bool accept(const reco::Candidate &cand, const reco::Vertex *pv) const
static const double phiMass
bool accept(const pat::CompositeCandidate &cand, const reco::Vertex *pvtx) const override
double x() const
x coordinate
bool accept(const pat::CompositeCandidate &cand, const reco::Vertex *pv=0) const override
BPHCompositeVertexSelect(float probMin, float cosMin=-1.0, float sigMin=-1.0)
virtual double eta() const =0
momentum pseudorapidity
virtual double pt() const =0
transverse momentum
virtual double mass() const =0
mass
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Error error() const
return SMatrix
BPHSoftMuonSelect(int cutTrackerLayers=5, int cutPixelLayers=0, float maxDxy=0.3, float maxDz=20.0, bool goodMuon=true, bool highPurity=true)
static vector< const reco::Candidate * > get(const pat::CompositeCandidate &cand, float massMin, float massMax)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const BPHSoftMuonSelect * sms
Analysis-level muon class.
#define SET_LABEL(NAME, PSET)
double mass() const final
mass
void fillHisto(const std::string &name, const pat::CompositeCandidate &cand)
~BPHHistoSpecificDecay() override