47 #define SET_PAR(TYPE, NAME, PSET) (NAME = PSET.getParameter<TYPE>(#NAME)) 54 usePM = (!
SET_PAR(
string, patMuonLabel, ps).empty());
55 useCC = (!
SET_PAR(
string, ccCandsLabel, ps).empty());
56 usePF = (!
SET_PAR(
string, pfCandsLabel, ps).empty());
57 usePC = (!
SET_PAR(
string, pcCandsLabel, ps).empty());
58 useGP = (!
SET_PAR(
string, gpCandsLabel, ps).empty());
66 SET_PAR(
bool, writeMomentum, ps);
70 rMap[
"PHiMuMu"] = Pmm;
83 pMap[
"ptMin"] =
ptMin;
85 pMap[
"mJPsiMin"] = mPsiMin;
86 pMap[
"mJPsiMax"] = mPsiMax;
94 pMap[
"massFitMin"] = mFitMin;
95 pMap[
"massFitMax"] = mFitMax;
100 fMap[
"writeCandidate"] = writeCandidate;
102 recoOnia = recoKx0 = writeKx0 = recoPkk = writePkk = recoBu = writeBu = recoBd = writeBd = recoBs = writeBs =
false;
107 int nSel = recoSelect.size();
108 for (iSel = 0; iSel < nSel; ++iSel)
109 setRecoParameters(recoSelect[iSel]);
116 recoOnia = recoKx0 =
true;
118 recoOnia = recoPkk =
true;
122 writeOnia = writeKx0 =
true;
124 writeOnia = writePkk =
true;
127 consume<vector<reco::Vertex> >(pVertexToken, pVertexLabel);
129 consume<pat::MuonCollection>(patMuonToken, patMuonLabel);
131 consume<vector<pat::CompositeCandidate> >(ccCandsToken, ccCandsLabel);
133 consume<vector<reco::PFCandidate> >(pfCandsToken, pfCandsLabel);
135 consume<vector<BPHTrackReference::candidate> >(pcCandsToken, pcCandsLabel);
137 consume<vector<pat::GenericParticle> >(gpCandsToken, gpCandsLabel);
140 produces<pat::CompositeCandidateCollection>(oniaName);
142 produces<pat::CompositeCandidateCollection>(sdName);
144 produces<pat::CompositeCandidateCollection>(ssName);
146 produces<pat::CompositeCandidateCollection>(buName);
148 produces<pat::CompositeCandidateCollection>(bdName);
150 produces<pat::CompositeCandidateCollection>(bsName);
157 desc.
add<
string>(
"pVertexLabel",
"");
158 desc.
add<
string>(
"patMuonLabel",
"");
159 desc.
add<
string>(
"ccCandsLabel",
"");
160 desc.
add<
string>(
"pfCandsLabel",
"");
161 desc.
add<
string>(
"pcCandsLabel",
"");
162 desc.
add<
string>(
"gpCandsLabel",
"");
163 desc.
add<
string>(
"oniaName",
"oniaCand");
164 desc.
add<
string>(
"sdName",
"kx0Cand");
165 desc.
add<
string>(
"ssName",
"phiCand");
166 desc.
add<
string>(
"buName",
"buFitted");
167 desc.
add<
string>(
"bdName",
"bdFitted");
168 desc.
add<
string>(
"bsName",
"bsFitted");
169 desc.
add<
bool>(
"writeVertex",
true);
170 desc.
add<
bool>(
"writeMomentum",
true);
172 dpar.
add<
string>(
"name");
173 dpar.add<
double>(
"ptMin", -2.0e35);
174 dpar.add<
double>(
"etaMax", -2.0e35);
175 dpar.add<
double>(
"mJPsiMin", -2.0e35);
176 dpar.add<
double>(
"mJPsiMax", -2.0e35);
177 dpar.add<
double>(
"mKx0Min", -2.0e35);
178 dpar.add<
double>(
"mKx0Max", -2.0e35);
179 dpar.add<
double>(
"mPhiMin", -2.0e35);
180 dpar.add<
double>(
"mPhiMax", -2.0e35);
181 dpar.add<
double>(
"massMin", -2.0e35);
182 dpar.add<
double>(
"massMax", -2.0e35);
183 dpar.add<
double>(
"probMin", -2.0e35);
184 dpar.add<
double>(
"massFitMin", -2.0e35);
185 dpar.add<
double>(
"massFitMax", -2.0e35);
186 dpar.add<
double>(
"constrMass", -2.0e35);
187 dpar.add<
double>(
"constrSigma", -2.0e35);
188 dpar.add<
bool>(
"constrMJPsi",
true);
189 dpar.add<
bool>(
"writeCandidate",
true);
190 vector<edm::ParameterSet> rpar;
191 desc.
addVPSet(
"recoSelect", dpar, rpar);
192 descriptions.
add(
"bphWriteSpecificDecay", desc);
201 write(ev, lFull, oniaName);
203 write(ev, lSd, sdName);
205 write(ev, lSs, ssName);
207 write(ev, lBu, buName);
209 write(ev, lBd, bdName);
211 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;
275 typedef multimap<const reco::Candidate*, const pat::CompositeCandidate*> mu_cc_map;
279 ccCandsToken.get(ev, ccCands);
280 int n = ccCands->size();
284 set<const pat::Muon*>::const_iterator iter;
285 set<const pat::Muon*>::const_iterator iend;
287 for (i = 0; i <
n; ++
i) {
291 for (j = 0; j <
m; ++
j) {
294 iter = muonSet.
begin();
295 iend = muonSet.end();
296 bool add = (mp !=
nullptr) && (muonSet.find(mp) == iend);
297 while (add && (iter != iend)) {
304 muCCMap.insert(pair<const reco::Candidate*, const pat::CompositeCandidate*>(dp, &cc));
307 iter = muonSet.begin();
308 iend = muonSet.end();
310 muDaugs.push_back(*iter++);
313 map<recoType, map<parType, double> >::const_iterator rIter = parMap.begin();
314 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;
359 map<parType, double>::const_iterator pIter = pMap.begin();
360 map<parType, double>::const_iterator pIend = pMap.end();
361 while (pIter != pIend) {
364 double pv = pEntry.second;
392 lFull = onia->
build();
398 int nFull = lFull.size();
399 map<const BPHRecoCandidate*, const reco::Vertex*> oniaVtxMap;
401 typedef mu_cc_map::const_iterator mu_cc_iter;
402 for (iFull = 0; iFull < nFull; ++iFull) {
406 const std::vector<const reco::Candidate*>& daugs = ptr->
daughters();
410 pair<mu_cc_iter, mu_cc_iter> cc0 = muCCMap.equal_range(ptr->
originalReco(daugs[0]));
411 pair<mu_cc_iter, mu_cc_iter> cc1 = muCCMap.equal_range(ptr->
originalReco(daugs[1]));
412 mu_cc_iter iter0 = cc0.first;
413 mu_cc_iter iend0 = cc0.second;
414 mu_cc_iter iter1 = cc1.first;
415 mu_cc_iter iend1 = cc1.second;
416 while ((iter0 != iend0) && (pVtx ==
nullptr)) {
418 while (iter1 != iend1) {
419 if (ccp != iter1++->
second)
424 float dMin = 999999.;
426 for (ipv = 0; ipv < npv; ++ipv) {
429 float dist =
pow(pPos.x() - tPos.x(), 2) +
pow(pPos.y() - tPos.y(), 2) +
pow(pPos.z() - tPos.z(), 2);
443 if (pVtx ==
nullptr) {
453 float minDz = 999999.;
454 float extrapZ = (state ? ttmd.
points().first.z() : -9e20);
456 for (ipv = 0; ipv < npv; ++ipv) {
458 float deltaZ = fabs(extrapZ - tVtx.
position().z());
459 if (deltaZ < minDz) {
467 oniaVtxMap[ptr] = pVtx;
470 pVertexToken.get(ev, pVertices);
477 int nJPsi = lJPsi.size();
487 int nj = lJPsi.size();
488 int no = lFull.size();
489 for (ij = 0; ij < nj; ++ij) {
491 for (io = 0; io < no; ++io) {
514 rIter = parMap.find(Bu);
515 if (rIter != rIend) {
516 const map<parType, double>& pMap = rIter->second;
517 map<parType, double>::const_iterator pIter = pMap.begin();
518 map<parType, double>::const_iterator pIend = pMap.end();
519 while (pIter != pIend) {
522 double pv = pEntry.second;
568 vector<BPHPlusMinusConstCandPtr> lKx0;
582 if (kx0 !=
nullptr) {
583 rIter = parMap.find(Kx0);
584 if (rIter != rIend) {
585 const map<parType, double>& pMap = rIter->second;
586 map<parType, double>::const_iterator pIter = pMap.begin();
587 map<parType, double>::const_iterator pIend = pMap.end();
588 while (pIter != pIend) {
591 double pv = pEntry.second;
626 int nKx0 = lKx0.size();
630 if (recoBd && nKx0) {
632 rIter = parMap.find(Bd);
633 if (rIter != rIend) {
634 const map<parType, double>& pMap = rIter->second;
635 map<parType, double>::const_iterator pIter = pMap.begin();
636 map<parType, double>::const_iterator pIend = pMap.end();
637 while (pIter != pIend) {
640 double pv = pEntry.second;
684 set<BPHRecoConstCandPtr> sKx0;
686 int nBd = lBd.size();
687 for (iBd = 0; iBd < nBd; ++iBd)
688 sKx0.insert(lBd[iBd]->getComp(
"Kx0"));
689 set<BPHRecoConstCandPtr>::const_iterator iter = sKx0.begin();
690 set<BPHRecoConstCandPtr>::const_iterator iend = sKx0.end();
692 lSd.push_back(*iter++);
697 vector<BPHPlusMinusConstCandPtr> lPhi;
711 if (phi !=
nullptr) {
712 rIter = parMap.find(Pkk);
713 if (rIter != rIend) {
714 const map<parType, double>& pMap = rIter->second;
715 map<parType, double>::const_iterator pIter = pMap.begin();
716 map<parType, double>::const_iterator pIend = pMap.end();
717 while (pIter != pIend) {
720 double pv = pEntry.second;
755 int nPhi = lPhi.size();
759 if (recoBs && nPhi) {
761 rIter = parMap.find(Bs);
762 if (rIter != rIend) {
763 const map<parType, double>& pMap = rIter->second;
764 map<parType, double>::const_iterator pIter = pMap.begin();
765 map<parType, double>::const_iterator pIend = pMap.end();
766 while (pIter != pIend) {
769 double pv = pEntry.second;
813 set<BPHRecoConstCandPtr> sPhi;
815 int nBs = lBs.size();
816 for (iBs = 0; iBs < nBs; ++iBs)
817 sPhi.insert(lBs[iBs]->getComp(
"Phi"));
818 set<BPHRecoConstCandPtr>::const_iterator iter = sPhi.begin();
819 set<BPHRecoConstCandPtr>::const_iterator iend = sPhi.end();
821 lSs.push_back(*iter++);
831 bool writeCandidate = ps.
getParameter<
bool>(
"writeCandidate");
832 switch (rMap[name]) {
835 writeOnia = writeCandidate;
848 writeKx0 = writeCandidate;
852 writePkk = writeCandidate;
856 writeBu = writeCandidate;
860 writeBd = writeCandidate;
864 writeBs = writeCandidate;
868 map<string, parType>::const_iterator pIter = pMap.begin();
869 map<string, parType>::const_iterator pIend = pMap.end();
870 while (pIter != pIend) {
872 const string& pn = entry.first;
876 edm::LogVerbatim(
"Configuration") <<
"BPHWriteSpecificDecay::setRecoParameters: set " << pn <<
" for " << name
877 <<
" : " << (parMap[rMap[
name]][
id] =
pv);
880 map<string, parType>::const_iterator fIter = fMap.begin();
881 map<string, parType>::const_iterator fIend = fMap.end();
882 while (fIter != fIend) {
884 const string&
fn = entry.first;
886 edm::LogVerbatim(
"Configuration") <<
"BPHWriteSpecificDecay::setRecoParameters: set " << fn <<
" for " << name
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
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)
#define DEFINE_FWK_MODULE(type)
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