47 #define SET_PAR(TYPE,NAME,PSET) ( NAME = PSET.getParameter< TYPE >( #NAME ) ) 55 usePM = (
SET_PAR(
string, patMuonLabel, ps ) !=
"" );
56 useCC = (
SET_PAR(
string, ccCandsLabel, ps ) !=
"" );
57 usePF = (
SET_PAR(
string, pfCandsLabel, ps ) !=
"" );
58 usePC = (
SET_PAR(
string, pcCandsLabel, ps ) !=
"" );
59 useGP = (
SET_PAR(
string, gpCandsLabel, ps ) !=
"" );
60 SET_PAR(
string, oniaName, ps );
67 SET_PAR(
bool, writeMomentum, ps );
68 SET_PAR(
bool, writeVertex , ps );
71 rMap[
"PHiMuMu"] = Pmm;
84 pMap[
"ptMin" ] =
ptMin;
86 pMap[
"mJPsiMin" ] = mPsiMin;
87 pMap[
"mJPsiMax" ] = mPsiMax;
88 pMap[
"mKx0Min" ] = mKx0Min;
89 pMap[
"mKx0Max" ] = mKx0Max;
90 pMap[
"mPhiMin" ] = mPhiMin;
91 pMap[
"mPhiMax" ] = mPhiMax;
92 pMap[
"massMin" ] = massMin;
94 pMap[
"probMin" ] = probMin;
95 pMap[
"massFitMin" ] = mFitMin;
96 pMap[
"massFitMax" ] = mFitMax;
97 pMap[
"constrMass" ] = constrMass;
98 pMap[
"constrSigma"] = constrSigma;
100 fMap[
"constrMJPsi" ] = constrMJPsi;
101 fMap[
"writeCandidate"] = writeCandidate;
108 recoBs = writeBs =
false;
111 const vector<edm::ParameterSet> recoSelect =
112 ps.
getParameter< vector<edm::ParameterSet> >(
"recoSelect" );
114 int nSel = recoSelect.size();
115 for ( iSel = 0; iSel < nSel; ++iSel ) setRecoParameters( recoSelect[iSel] );
116 if ( !recoOnia ) writeOnia =
false;
118 if ( recoBu ) recoOnia =
true;
119 if ( recoBd ) recoOnia = recoKx0 =
true;
120 if ( recoBs ) recoOnia = recoPkk =
true;
121 if ( writeBu ) writeOnia =
true;
122 if ( writeBd ) writeOnia = writeKx0 =
true;
123 if ( writeBs ) writeOnia = writePkk =
true;
125 if (
usePV ) consume< vector<reco::Vertex > >( pVertexToken,
127 if ( usePM ) consume< pat::MuonCollection >( patMuonToken,
129 if ( useCC ) consume< vector<pat::CompositeCandidate > >( ccCandsToken,
131 if ( usePF ) consume< vector<reco::PFCandidate > >( pfCandsToken,
133 if ( usePC ) consume< vector<BPHTrackReference::candidate> >( pcCandsToken,
135 if ( useGP ) consume< vector<pat::GenericParticle > >( gpCandsToken,
138 if ( writeOnia ) produces<pat::CompositeCandidateCollection>( oniaName );
139 if ( writeKx0 ) produces<pat::CompositeCandidateCollection>( sdName );
140 if ( writePkk ) produces<pat::CompositeCandidateCollection>( ssName );
141 if ( writeBu ) produces<pat::CompositeCandidateCollection>( buName );
142 if ( writeBd ) produces<pat::CompositeCandidateCollection>( bdName );
143 if ( writeBs ) produces<pat::CompositeCandidateCollection>( bsName );
155 desc.
add<
string>(
"pVertexLabel",
"" );
156 desc.
add<
string>(
"patMuonLabel",
"" );
157 desc.
add<
string>(
"ccCandsLabel",
"" );
158 desc.
add<
string>(
"pfCandsLabel",
"" );
159 desc.
add<
string>(
"pcCandsLabel",
"" );
160 desc.
add<
string>(
"gpCandsLabel",
"" );
161 desc.
add<
string>(
"oniaName",
"oniaCand" );
162 desc.
add<
string>(
"sdName",
"kx0Cand" );
163 desc.
add<
string>(
"ssName",
"phiCand" );
164 desc.
add<
string>(
"buName",
"buFitted" );
165 desc.
add<
string>(
"bdName",
"bdFitted" );
166 desc.
add<
string>(
"bsName",
"bsFitted" );
167 desc.
add<
bool>(
"writeVertex" ,
true );
168 desc.
add<
bool>(
"writeMomentum",
true );
170 dpar.
add<
string>(
"name" );
171 dpar.add<
double>(
"ptMin", -2.0e35 );
172 dpar.add<
double>(
"etaMax", -2.0e35 );
173 dpar.add<
double>(
"mJPsiMin", -2.0e35 );
174 dpar.add<
double>(
"mJPsiMax", -2.0e35 );
175 dpar.add<
double>(
"mKx0Min", -2.0e35 );
176 dpar.add<
double>(
"mKx0Max", -2.0e35 );
177 dpar.add<
double>(
"mPhiMin", -2.0e35 );
178 dpar.add<
double>(
"mPhiMax", -2.0e35 );
179 dpar.add<
double>(
"massMin", -2.0e35 );
180 dpar.add<
double>(
"massMax", -2.0e35 );
181 dpar.add<
double>(
"probMin", -2.0e35 );
182 dpar.add<
double>(
"massFitMin", -2.0e35 );
183 dpar.add<
double>(
"massFitMax", -2.0e35 );
184 dpar.add<
double>(
"constrMass", -2.0e35 );
185 dpar.add<
double>(
"constrSigma", -2.0e35 );
186 dpar.add<
bool>(
"constrMJPsi",
true );
187 dpar.add<
bool>(
"writeCandidate",
true );
188 vector<edm::ParameterSet> rpar;
189 desc.
addVPSet(
"recoSelect", dpar, rpar );
190 descriptions.
add(
"bphWriteSpecificDecay", desc );
203 if ( writeOnia )
write( ev, lFull, oniaName );
204 if ( writeKx0 )
write( ev, lSd , sdName );
205 if ( writePkk )
write( ev, lSs , ssName );
206 if ( writeBu )
write( ev, lBu , buName );
207 if ( writeBd )
write( ev, lBd , bdName );
208 if ( writeBs )
write( ev, lBs , bsName );
236 pVertexToken.get( ev, pVertices );
237 int npv = pVertices->size();
244 pfCandsToken.get( ev, pfCands );
245 nrc = pfCands->size();
254 pcCandsToken.get( ev, pcCands );
255 nrc = pcCands->size();
261 gpCandsToken.get( ev, gpCands );
262 nrc = gpCands->size();
268 patMuonToken.get( ev, patMuon );
273 vector<const reco::Candidate*> muDaugs;
274 set<const pat::Muon*> muonSet;
280 ccCandsToken.get( ev, ccCands );
281 int n = ccCands->size();
283 muDaugs.reserve( n );
285 set<const pat::Muon*>::const_iterator iter;
286 set<const pat::Muon*>::const_iterator iend;
288 for ( i = 0; i <
n; ++
i ) {
292 for ( j = 0; j <
m; ++j ) {
293 const reco::Candidate* dp = cc.
daughter( j );
295 iter = muonSet.
begin();
296 iend = muonSet.end();
297 bool add = ( mp !=
nullptr ) && ( muonSet.find( mp ) == iend );
298 while ( add && ( iter != iend ) ) {
301 if ( add ) muonSet.insert( mp );
303 muCCMap.insert( pair<
const reco::Candidate*,
307 iter = muonSet.begin();
308 iend = muonSet.end();
309 while ( iter != iend ) muDaugs.push_back( *iter++ );
312 map< recoType, map<parType,double> >::const_iterator rIter = parMap.begin();
313 map< recoType, map<parType,double> >::const_iterator rIend = parMap.end();
328 if ( onia !=
nullptr ) {
329 while ( rIter != rIend ) {
330 const map< recoType, map<parType,double> >
::value_type& rEntry = *rIter++;
332 const map<parType,double>& pMap = rEntry.second;
344 map<parType,double>::const_iterator pIter = pMap.begin();
345 map<parType,double>::const_iterator pIend = pMap.end();
346 while ( pIter != pIend ) {
349 double pv = pEntry.second;
353 case massMin : onia->
setMassMin( type, pv );
break;
355 case probMin : onia->
setProbMin( type, pv );
break;
356 case constrMass : onia->
setConstr ( type, pv,
365 lFull = onia->
build();
371 int nFull = lFull.size();
372 map<const BPHRecoCandidate*,const reco::Vertex*> oniaVtxMap;
374 typedef mu_cc_map::const_iterator mu_cc_iter;
375 for ( iFull = 0; iFull < nFull; ++iFull ) {
380 const std::vector<const reco::Candidate*>& daugs = ptr->
daughters();
384 pair<mu_cc_iter,mu_cc_iter> cc0 = muCCMap.equal_range(
386 pair<mu_cc_iter,mu_cc_iter> cc1 = muCCMap.equal_range(
388 mu_cc_iter iter0 = cc0.first;
389 mu_cc_iter iend0 = cc0.second;
390 mu_cc_iter iter1 = cc1.first;
391 mu_cc_iter iend1 = cc1.second;
392 while ( ( iter0 != iend0 ) && ( pVtx ==
nullptr ) ) {
394 while ( iter1 != iend1 ) {
395 if ( ccp != iter1++->
second )
continue;
399 float dMin = 999999.;
401 for ( ipv = 0; ipv < npv; ++ipv ) {
404 float dist =
pow( pPos.x() - tPos.x(), 2 ) +
405 pow( pPos.y() - tPos.y(), 2 ) +
406 pow( pPos.z() - tPos.z(), 2 );
420 if ( pVtx ==
nullptr ) {
432 float minDz = 999999.;
433 float extrapZ = ( state ? ttmd.
points().first.z() : -9e20 );
435 for ( ipv = 0; ipv < npv; ++ipv ) {
437 float deltaZ = fabs( extrapZ - tVtx.
position().z() ) ;
438 if ( deltaZ < minDz ) {
446 oniaVtxMap[ptr] = pVtx;
447 pvRefMap[ptr] =
vertex_ref( pVertices, pvId );
450 pVertexToken.get( ev, pVertices );
456 int nJPsi = lJPsi.size();
459 if ( !nJPsi )
return;
464 int nj = lJPsi.size();
465 int no = lFull.size();
466 for ( ij = 0; ij < nj; ++ij ) {
468 for ( io = 0; io < no; ++io ) {
494 if ( bu !=
nullptr ) {
495 rIter = parMap.find( Bu );
496 if ( rIter != rIend ) {
497 const map<parType,double>& pMap = rIter->second;
498 map<parType,double>::const_iterator pIter = pMap.begin();
499 map<parType,double>::const_iterator pIend = pMap.end();
500 while ( pIter != pIend ) {
503 double pv = pEntry.second;
514 case constrMJPsi: bu->
setConstr ( pv > 0 );
break;
515 case writeCandidate: writeBu = ( pv > 0 );
break;
526 vector<BPHPlusMinusConstCandPtr> lKx0;
542 if ( kx0 !=
nullptr ) {
543 rIter = parMap.find( Kx0 );
544 if ( rIter != rIend ) {
545 const map<parType,double>& pMap = rIter->second;
546 map<parType,double>::const_iterator pIter = pMap.begin();
547 map<parType,double>::const_iterator pIend = pMap.end();
548 while ( pIter != pIend ) {
551 double pv = pEntry.second;
560 case writeCandidate: writeKx0 = ( pv > 0 );
break;
569 int nKx0 = lKx0.size();
573 if ( recoBd && nKx0 ) {
576 rIter = parMap.find( Bd );
577 if ( rIter != rIend ) {
578 const map<parType,double>& pMap = rIter->second;
579 map<parType,double>::const_iterator pIter = pMap.begin();
580 map<parType,double>::const_iterator pIend = pMap.end();
581 while ( pIter != pIend ) {
584 double pv = pEntry.second;
595 case constrMJPsi: bd->
setConstr ( pv > 0 );
break;
596 case writeCandidate: writeBd = ( pv > 0 );
break;
605 set<BPHRecoConstCandPtr> sKx0;
607 int nBd = lBd.size();
608 for ( iBd = 0; iBd < nBd; ++iBd ) sKx0.insert( lBd[iBd]->getComp(
"Kx0" ) );
609 set<BPHRecoConstCandPtr>::const_iterator iter = sKx0.begin();
610 set<BPHRecoConstCandPtr>::const_iterator iend = sKx0.end();
611 while ( iter != iend ) lSd.push_back( *iter++ );
617 vector<BPHPlusMinusConstCandPtr> lPhi;
633 if ( phi !=
nullptr ) {
634 rIter = parMap.find( Pkk );
635 if ( rIter != rIend ) {
636 const map<parType,double>& pMap = rIter->second;
637 map<parType,double>::const_iterator pIter = pMap.begin();
638 map<parType,double>::const_iterator pIend = pMap.end();
639 while ( pIter != pIend ) {
642 double pv = pEntry.second;
651 case writeCandidate: writePkk = ( pv > 0 );
break;
660 int nPhi = lPhi.size();
664 if ( recoBs && nPhi ) {
667 rIter = parMap.find( Bs );
668 if ( rIter != rIend ) {
669 const map<parType,double>& pMap = rIter->second;
670 map<parType,double>::const_iterator pIter = pMap.begin();
671 map<parType,double>::const_iterator pIend = pMap.end();
672 while ( pIter != pIend ) {
675 double pv = pEntry.second;
686 case constrMJPsi: bs->
setConstr ( pv > 0 );
break;
687 case writeCandidate: writeBs = ( pv > 0 );
break;
696 set<BPHRecoConstCandPtr> sPhi;
698 int nBs = lBs.size();
699 for ( iBs = 0; iBs < nBs; ++iBs ) sPhi.insert( lBs[iBs]->getComp(
"Phi" ) );
700 set<BPHRecoConstCandPtr>::const_iterator iter = sPhi.begin();
701 set<BPHRecoConstCandPtr>::const_iterator iend = sPhi.end();
702 while ( iter != iend ) lSs.push_back( *iter++ );
719 bool writeCandidate = ps.
getParameter<
bool>(
"writeCandidate" );
720 switch( rMap[name] ) {
721 case Onia: recoOnia =
true; writeOnia = writeCandidate;
break;
728 case Ups3: recoOnia =
true;
break;
729 case Kx0 : recoKx0 =
true; writeKx0 = writeCandidate;
break;
730 case Pkk : recoPkk =
true; writePkk = writeCandidate;
break;
731 case Bu : recoBu =
true; writeBu = writeCandidate;
break;
732 case Bd : recoBd =
true; writeBd = writeCandidate;
break;
733 case Bs : recoBs =
true; writeBs = writeCandidate;
break;
736 map<string,parType>::const_iterator pIter = pMap.begin();
737 map<string,parType>::const_iterator pIend = pMap.end();
738 while ( pIter != pIend ) {
740 const string& pn = entry.first;
744 <<
"BPHWriteSpecificDecay::setRecoParameters: set " << pn
745 <<
" for " << name <<
" : " 749 map<string,parType>::const_iterator fIter = fMap.begin();
750 map<string,parType>::const_iterator fIend = fMap.end();
751 while ( fIter != fIend ) {
753 const string& fn = entry.first;
756 <<
"BPHWriteSpecificDecay::setRecoParameters: set " << fn
757 <<
" for " << name <<
" : " 758 << ( parMap[rMap[
name]][
id] =
Analysis-level particle class.
void setEtaMax(double eta)
double getConstrSigma() const
static bool sameTrack(const reco::Candidate *lCand, const reco::Candidate *rCand, double minPDifference)
T getParameter(std::string const &) const
std::vector< BPHRecoConstCandPtr > build()
build Bu candidates
void setProbMin(double p)
void setJPsiMassMax(double m)
void setMassMax(double m)
ParameterDescriptionBase * addVPSet(U const &iLabel, ParameterSetDescription const &validator, std::vector< ParameterSet > const &defaults)
void setProbMin(double p)
std::pair< GlobalPoint, GlobalPoint > points() const override
void setJPsiMassMin(double m)
set cuts
void setMassMax(oniaType type, double m)
double getConstrMass(oniaType type) const
#define DEFINE_FWK_MODULE(type)
void setMassFitMin(double m)
void setPtMin(double pt)
set cuts
void setJPsiMassMin(double m)
set cuts
void setMassMin(double m)
void setKPtMin(double pt)
set cuts
void setMassFitMax(double m)
void setKEtaMax(double eta)
void setKxMassMin(double m)
void setMassMin(double m)
void setProbMin(double p)
void setPhiMassMax(double m)
void setPtMin(double pt)
set cuts
double getConstrMass() const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void setMassMin(double m)
const Point & position() const
position
#define SET_PAR(TYPE, NAME, PSET)
virtual const std::vector< const reco::Candidate * > & daughters() const
virtual void fill(edm::Event &ev, const edm::EventSetup &es)
~BPHWriteSpecificDecay() override
void setProbMin(oniaType type, double p)
bool calculate(const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb) override
static BPHGenericCollection * createCollection(const edm::Handle< T > &collection, const std::string &list="cfhpmig")
std::vector< BPHPlusMinusConstCandPtr > build()
build Phi candidates
U second(std::pair< T, U > const &p)
const pat::CompositeCandidate & composite() const override
get a composite by the simple sum of simple particles
void setConstr(bool flag)
Container::value_type value_type
void setProbMin(double p)
BPHWriteSpecificDecay(const edm::ParameterSet &ps)
double getConstrSigma(oniaType type) const
void setEtaMax(double eta)
void setConstr(bool flag)
math::XYZPoint Point
point in the space
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...
const Candidate * daughter(size_type) const override
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
void setProbMin(double p)
void setMassFitMin(double m)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
virtual const reco::Candidate * originalReco(const reco::Candidate *daug) const
get the original particle from the clone
void setMassMin(double m)
void add(std::map< std::string, TH1 * > &h, TH1 *hist)
void setMassMax(double m)
void setJPsiMassMax(double m)
double getConstrSigma() const
void setJPsiMassMin(double m)
set cuts
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void setMassFitMax(double m)
void setKxMassMax(double m)
std::vector< BPHPlusMinusConstCandPtr > build()
build resonance candidates
void setConstr(double mass, double sigma)
void setConstr(bool flag)
void setConstr(oniaType type, double mass, double sigma)
void setEtaMax(oniaType type, double eta)
std::vector< BPHPlusMinusConstCandPtr > getList(oniaType type, BPHRecoSelect *dSel=0, BPHMomentumSelect *mSel=0, BPHVertexSelect *vSel=0, BPHFitSelect *kSel=0)
void setPhiMassMin(double m)
const_iterator begin() const
first daughter const_iterator
void setMassMax(double m)
void setMassMin(double m)
size_type numberOfDaughters() const override
number of daughters
void setMassMax(double m)
std::vector< BPHRecoConstCandPtr > build()
build Bs candidates
void setMassMax(double m)
virtual const reco::Candidate * getDaug(const std::string &name) const
void setMassMin(oniaType type, double m)
void setMassFitMax(double m)
void produce(edm::Event &ev, const edm::EventSetup &es) override
void setMassFitMin(double m)
Analysis-level muon class.
void setRecoParameters(const edm::ParameterSet &ps)
Power< A, B >::type pow(const A &a, const B &b)
void setPtMin(oniaType type, double pt)
set cuts
std::vector< BPHRecoConstCandPtr > build()
build Bs candidates
void setConstr(double mass, double sigma)
void setJPsiMassMax(double m)
double getConstrMass() const
virtual const reco::Vertex & vertex() const
get reconstructed vertex
std::vector< BPHPlusMinusConstCandPtr > build()
build Phi candidates