51 #define SET_PAR(TYPE, NAME, PSET) (NAME = PSET.getParameter<TYPE>(#NAME))
58 usePM = (!
SET_PAR(
string, patMuonLabel, ps).empty());
59 useCC = (!
SET_PAR(
string, ccCandsLabel, ps).empty());
60 usePF = (!
SET_PAR(
string, pfCandsLabel, ps).empty());
61 usePC = (!
SET_PAR(
string, pcCandsLabel, ps).empty());
62 useGP = (!
SET_PAR(
string, gpCandsLabel, ps).empty());
63 useK0 = (!
SET_PAR(
string, k0CandsLabel, ps).empty());
64 useL0 = (!
SET_PAR(
string, l0CandsLabel, ps).empty());
65 useKS = (!
SET_PAR(
string, kSCandsLabel, ps).empty());
66 useLS = (!
SET_PAR(
string, lSCandsLabel, ps).empty());
80 SET_PAR(
bool, writeMomentum, ps);
84 rMap[
"PHiMuMu"] = Pmm;
97 rMap[
"Lambda0"] = Lambda0;
99 rMap[
"Lambdab"] = Lambdab;
101 rMap[
"X3872"] = X3872;
103 pMap[
"ptMin"] =
ptMin;
105 pMap[
"mJPsiMin"] = mPsiMin;
106 pMap[
"mJPsiMax"] = mPsiMax;
118 pMap[
"massFitMin"] = mFitMin;
119 pMap[
"massFitMax"] = mFitMax;
124 fMap[
"writeCandidate"] = writeCandidate;
126 recoOnia = recoKx0 = writeKx0 = recoPkk = writePkk = recoBu = writeBu = recoBd = writeBd = recoBs = writeBs =
127 recoK0s = writeK0s = recoLambda0 = writeLambda0 = recoB0 = writeB0 = recoLambdab = writeLambdab = recoBc =
128 writeBc = recoX3872 = writeX3872 =
false;
134 for (iSel = 0; iSel < nSel; ++iSel)
142 recoOnia = recoKx0 =
true;
144 recoOnia = recoPkk =
true;
146 recoOnia = recoK0s =
true;
148 recoOnia = recoLambda0 =
true;
156 writeOnia = writeKx0 =
true;
158 writeOnia = writePkk =
true;
160 writeOnia = writeK0s =
true;
162 writeOnia = writeLambda0 =
true;
169 consume<vector<reco::Vertex>>(pVertexToken, pVertexLabel);
171 consume<pat::MuonCollection>(patMuonToken, patMuonLabel);
173 consume<vector<pat::CompositeCandidate>>(ccCandsToken, ccCandsLabel);
175 consume<vector<reco::PFCandidate>>(pfCandsToken, pfCandsLabel);
177 consume<vector<BPHTrackReference::candidate>>(pcCandsToken, pcCandsLabel);
179 consume<vector<pat::GenericParticle>>(gpCandsToken, gpCandsLabel);
181 consume<vector<reco::VertexCompositeCandidate>>(k0CandsToken, k0CandsLabel);
183 consume<vector<reco::VertexCompositeCandidate>>(l0CandsToken, l0CandsLabel);
185 consume<vector<reco::VertexCompositePtrCandidate>>(kSCandsToken, kSCandsLabel);
187 consume<vector<reco::VertexCompositePtrCandidate>>(lSCandsToken, lSCandsLabel);
190 produces<pat::CompositeCandidateCollection>(oniaName);
192 produces<pat::CompositeCandidateCollection>(sdName);
194 produces<pat::CompositeCandidateCollection>(ssName);
196 produces<pat::CompositeCandidateCollection>(buName);
198 produces<pat::CompositeCandidateCollection>(bdName);
200 produces<pat::CompositeCandidateCollection>(bsName);
202 produces<pat::CompositeCandidateCollection>(k0Name);
204 produces<pat::CompositeCandidateCollection>(l0Name);
206 produces<pat::CompositeCandidateCollection>(b0Name);
208 produces<pat::CompositeCandidateCollection>(lbName);
210 produces<pat::CompositeCandidateCollection>(bcName);
212 produces<pat::CompositeCandidateCollection>(x3872Name);
219 desc.add<
string>(
"pVertexLabel",
"");
220 desc.add<
string>(
"patMuonLabel",
"");
221 desc.add<
string>(
"ccCandsLabel",
"");
222 desc.add<
string>(
"pfCandsLabel",
"");
223 desc.add<
string>(
"pcCandsLabel",
"");
224 desc.add<
string>(
"gpCandsLabel",
"");
225 desc.add<
string>(
"k0CandsLabel",
"");
226 desc.add<
string>(
"l0CandsLabel",
"");
227 desc.add<
string>(
"kSCandsLabel",
"");
228 desc.add<
string>(
"lSCandsLabel",
"");
229 desc.add<
string>(
"oniaName",
"oniaCand");
230 desc.add<
string>(
"sdName",
"kx0Cand");
231 desc.add<
string>(
"ssName",
"phiCand");
232 desc.add<
string>(
"buName",
"buFitted");
233 desc.add<
string>(
"bdName",
"bdFitted");
234 desc.add<
string>(
"bsName",
"bsFitted");
235 desc.add<
string>(
"k0Name",
"k0Fitted");
236 desc.add<
string>(
"l0Name",
"l0Fitted");
237 desc.add<
string>(
"b0Name",
"b0Fitted");
238 desc.add<
string>(
"lbName",
"lbFitted");
239 desc.add<
string>(
"bcName",
"bcFitted");
240 desc.add<
string>(
"x3872Name",
"x3872Fitted");
241 desc.add<
bool>(
"writeVertex",
true);
242 desc.add<
bool>(
"writeMomentum",
true);
244 dpar.
add<
string>(
"name");
245 dpar.add<
double>(
"ptMin", -2.0e35);
246 dpar.add<
double>(
"etaMax", -2.0e35);
247 dpar.add<
double>(
"mJPsiMin", -2.0e35);
248 dpar.add<
double>(
"mJPsiMax", -2.0e35);
249 dpar.add<
double>(
"mKx0Min", -2.0e35);
250 dpar.add<
double>(
"mKx0Max", -2.0e35);
251 dpar.add<
double>(
"mPhiMin", -2.0e35);
252 dpar.add<
double>(
"mPhiMax", -2.0e35);
253 dpar.add<
double>(
"mK0sMin", -2.0e35);
254 dpar.add<
double>(
"mK0sMax", -2.0e35);
255 dpar.add<
double>(
"mLambda0Min", -2.0e35);
256 dpar.add<
double>(
"mLambda0Max", -2.0e35);
257 dpar.add<
double>(
"massMin", -2.0e35);
258 dpar.add<
double>(
"massMax", -2.0e35);
259 dpar.add<
double>(
"probMin", -2.0e35);
260 dpar.add<
double>(
"massFitMin", -2.0e35);
261 dpar.add<
double>(
"massFitMax", -2.0e35);
262 dpar.add<
double>(
"constrMass", -2.0e35);
263 dpar.add<
double>(
"constrSigma", -2.0e35);
264 dpar.add<
bool>(
"constrMJPsi",
true);
265 dpar.add<
bool>(
"writeCandidate",
true);
266 vector<edm::ParameterSet> rpar;
267 desc.addVPSet(
"recoSelect", dpar, rpar);
268 descriptions.
add(
"bphWriteSpecificDecay",
desc);
331 pVertexToken.get(
ev, pVertices);
332 int npv = pVertices->size();
339 pfCandsToken.get(
ev, pfCands);
340 nrc = pfCands->size();
349 pcCandsToken.get(
ev, pcCands);
350 nrc = pcCands->size();
356 gpCandsToken.get(
ev, gpCands);
357 nrc = gpCands->size();
363 patMuonToken.get(
ev, patMuon);
369 k0CandsToken.get(
ev, k0Cand);
375 l0CandsToken.get(
ev, l0Cand);
381 kSCandsToken.get(
ev, kSCand);
387 lSCandsToken.get(
ev, lSCand);
392 vector<const reco::Candidate*> muDaugs;
393 set<const pat::Muon*> muonSet;
394 typedef multimap<const reco::Candidate*, const pat::CompositeCandidate*> mu_cc_map;
398 ccCandsToken.get(
ev, ccCands);
399 int n = ccCands->size();
403 set<const pat::Muon*>::const_iterator iter;
404 set<const pat::Muon*>::const_iterator iend;
406 for (
i = 0;
i <
n; ++
i) {
409 int m =
cc.numberOfDaughters();
410 for (
j = 0;
j <
m; ++
j) {
412 const pat::Muon* mp = dynamic_cast<const pat::Muon*>(
dp);
413 iter = muonSet.begin();
414 iend = muonSet.end();
415 bool add = (mp !=
nullptr) && (muonSet.find(mp) == iend);
416 while (
add && (iter != iend)) {
423 muCCMap.insert(pair<const reco::Candidate*, const pat::CompositeCandidate*>(
dp, &
cc));
426 iter = muonSet.begin();
427 iend = muonSet.end();
429 muDaugs.push_back(*iter++);
432 map<recoType, map<parType, double>>::const_iterator rIter = parMap.begin();
433 map<recoType, map<parType, double>>::const_iterator rIend = parMap.end();
447 if (onia !=
nullptr) {
448 while (rIter != rIend) {
449 const map<recoType, map<parType, double>>
::value_type& rEntry = *rIter++;
451 const map<parType, double>& pMap = rEntry.second;
478 map<parType, double>::const_iterator pIter = pMap.begin();
479 map<parType, double>::const_iterator pIend = pMap.end();
480 while (pIter != pIend) {
483 double pv = pEntry.second;
511 lFull = onia->
build();
517 int nFull = lFull.size();
518 map<const BPHRecoCandidate*, const reco::Vertex*> oniaVtxMap;
520 typedef mu_cc_map::const_iterator mu_cc_iter;
521 for (iFull = 0; iFull < nFull; ++iFull) {
525 const std::vector<const reco::Candidate*>& daugs = ptr->
daughters();
529 pair<mu_cc_iter, mu_cc_iter> cc0 = muCCMap.equal_range(ptr->
originalReco(daugs[0]));
530 pair<mu_cc_iter, mu_cc_iter> cc1 = muCCMap.equal_range(ptr->
originalReco(daugs[1]));
531 mu_cc_iter iter0 = cc0.first;
532 mu_cc_iter iend0 = cc0.second;
533 mu_cc_iter iter1 = cc1.first;
534 mu_cc_iter iend1 = cc1.second;
535 while ((iter0 != iend0) && (pVtx ==
nullptr)) {
537 while (iter1 != iend1) {
538 if (ccp != iter1++->
second)
543 float dMin = 999999.;
545 for (ipv = 0; ipv < npv; ++ipv) {
548 float dist =
pow(pPos.x() - tPos.x(), 2) +
pow(pPos.y() - tPos.y(), 2) +
pow(pPos.z() - tPos.z(), 2);
562 if (pVtx ==
nullptr) {
572 float minDz = 999999.;
573 float extrapZ = (
state ? ttmd.
points().first.z() : -9e20);
575 for (ipv = 0; ipv < npv; ++ipv) {
577 float deltaZ = fabs(extrapZ - tVtx.
position().z());
578 if (deltaZ <
minDz) {
586 oniaVtxMap[ptr] = pVtx;
589 pVertexToken.get(
ev, pVertices);
596 int nJPsi = lJPsi.size();
606 int nj = lJPsi.size();
607 int no = lFull.size();
608 for (ij = 0; ij < nj; ++ij) {
610 for (io = 0; io < no; ++io) {
633 rIter = parMap.find(Bu);
634 if (rIter != rIend) {
635 const map<parType, double>& pMap = rIter->second;
636 map<parType, double>::const_iterator pIter = pMap.begin();
637 map<parType, double>::const_iterator pIend = pMap.end();
638 while (pIter != pIend) {
641 double pv = pEntry.second;
687 vector<BPHPlusMinusConstCandPtr> lKx0;
701 if (kx0 !=
nullptr) {
702 rIter = parMap.find(Kx0);
703 if (rIter != rIend) {
704 const map<parType, double>& pMap = rIter->second;
705 map<parType, double>::const_iterator pIter = pMap.begin();
706 map<parType, double>::const_iterator pIend = pMap.end();
707 while (pIter != pIend) {
710 double pv = pEntry.second;
739 int nKx0 = lKx0.size();
743 if (recoBd && nKx0) {
745 rIter = parMap.find(Bd);
746 if (rIter != rIend) {
747 const map<parType, double>& pMap = rIter->second;
748 map<parType, double>::const_iterator pIter = pMap.begin();
749 map<parType, double>::const_iterator pIend = pMap.end();
750 while (pIter != pIend) {
753 double pv = pEntry.second;
756 bd->setJPsiMassMin(
pv);
759 bd->setJPsiMassMax(
pv);
762 bd->setKxMassMin(
pv);
765 bd->setKxMassMax(
pv);
777 bd->setMassFitMin(
pv);
780 bd->setMassFitMax(
pv);
783 bd->setConstr(
pv > 0);
797 set<BPHRecoConstCandPtr> sKx0;
799 int nBd = lBd.size();
800 for (iBd = 0; iBd < nBd; ++iBd)
801 sKx0.insert(lBd[iBd]->getComp(
"Kx0"));
802 set<BPHRecoConstCandPtr>::const_iterator iter = sKx0.begin();
803 set<BPHRecoConstCandPtr>::const_iterator iend = sKx0.end();
805 lSd.push_back(*iter++);
810 vector<BPHPlusMinusConstCandPtr> lPhi;
824 if (phi !=
nullptr) {
825 rIter = parMap.find(Pkk);
826 if (rIter != rIend) {
827 const map<parType, double>& pMap = rIter->second;
828 map<parType, double>::const_iterator pIter = pMap.begin();
829 map<parType, double>::const_iterator pIend = pMap.end();
830 while (pIter != pIend) {
833 double pv = pEntry.second;
862 int nPhi = lPhi.size();
866 if (recoBs &&
nPhi) {
868 rIter = parMap.find(Bs);
869 if (rIter != rIend) {
870 const map<parType, double>& pMap = rIter->second;
871 map<parType, double>::const_iterator pIter = pMap.begin();
872 map<parType, double>::const_iterator pIend = pMap.end();
873 while (pIter != pIend) {
876 double pv = pEntry.second;
879 bs->setJPsiMassMin(
pv);
882 bs->setJPsiMassMax(
pv);
885 bs->setPhiMassMin(
pv);
888 bs->setPhiMassMax(
pv);
900 bs->setMassFitMin(
pv);
903 bs->setMassFitMax(
pv);
906 bs->setConstr(
pv > 0);
920 set<BPHRecoConstCandPtr> sPhi;
922 int nBs = lBs.size();
923 for (iBs = 0; iBs < nBs; ++iBs)
924 sPhi.insert(lBs[iBs]->getComp(
"Phi"));
925 set<BPHRecoConstCandPtr>::const_iterator iter = sPhi.begin();
926 set<BPHRecoConstCandPtr>::const_iterator iend = sPhi.end();
928 lSs.push_back(*iter++);
940 if (k0s !=
nullptr) {
941 rIter = parMap.find(K0s);
942 if (rIter != rIend) {
943 const map<parType, double>& pMap = rIter->second;
944 map<parType, double>::const_iterator pIter = pMap.begin();
945 map<parType, double>::const_iterator pIend = pMap.end();
946 while (pIter != pIend) {
949 double pv = pEntry.second;
978 int nK0 = lK0.size();
989 if (l0s !=
nullptr) {
990 rIter = parMap.find(Lambda0);
991 if (rIter != rIend) {
992 const map<parType, double>& pMap = rIter->second;
993 map<parType, double>::const_iterator pIter = pMap.begin();
994 map<parType, double>::const_iterator pIend = pMap.end();
995 while (pIter != pIend) {
998 double pv = pEntry.second;
1015 case writeCandidate:
1016 writeLambda0 = (
pv > 0);
1027 int nL0 = lL0.size();
1031 if (recoB0 && nK0) {
1033 rIter = parMap.find(B0);
1034 if (rIter != rIend) {
1035 const map<parType, double>& pMap = rIter->second;
1036 map<parType, double>::const_iterator pIter = pMap.begin();
1037 map<parType, double>::const_iterator pIend = pMap.end();
1038 while (pIter != pIend) {
1041 double pv = pEntry.second;
1044 b0->setJPsiMassMin(
pv);
1047 b0->setJPsiMassMax(
pv);
1050 b0->setK0MassMin(
pv);
1053 b0->setK0MassMax(
pv);
1065 b0->setMassFitMin(
pv);
1068 b0->setMassFitMax(
pv);
1071 b0->setConstr(
pv > 0);
1073 case writeCandidate:
1083 const map<const BPHRecoCandidate*, const BPHRecoCandidate*>& b0Map =
b0->daughMap();
1084 daughMap.insert(b0Map.begin(), b0Map.end());
1090 if (recoLambdab && nL0) {
1092 rIter = parMap.find(Lambdab);
1093 if (rIter != rIend) {
1094 const map<parType, double>& pMap = rIter->second;
1095 map<parType, double>::const_iterator pIter = pMap.begin();
1096 map<parType, double>::const_iterator pIend = pMap.end();
1097 while (pIter != pIend) {
1100 double pv = pEntry.second;
1132 case writeCandidate:
1133 writeLambdab = (
pv > 0);
1142 const map<const BPHRecoCandidate*, const BPHRecoCandidate*>& ldMap = lb->
daughMap();
1143 daughMap.insert(ldMap.begin(), ldMap.end());
1159 if (bc !=
nullptr) {
1160 rIter = parMap.find(Bc);
1161 if (rIter != rIend) {
1162 const map<parType, double>& pMap = rIter->second;
1163 map<parType, double>::const_iterator pIter = pMap.begin();
1164 map<parType, double>::const_iterator pIend = pMap.end();
1165 while (pIter != pIend) {
1168 double pv = pEntry.second;
1200 case writeCandidate:
1227 if (x3872 !=
nullptr) {
1228 rIter = parMap.find(X3872);
1229 if (rIter != rIend) {
1230 const map<parType, double>& pMap = rIter->second;
1231 map<parType, double>::const_iterator pIter = pMap.begin();
1232 map<parType, double>::const_iterator pIend = pMap.end();
1233 while (pIter != pIend) {
1236 double pv = pEntry.second;
1268 case writeCandidate:
1269 writeX3872 = (
pv > 0);
1276 lX3872 = x3872->
build();
1287 bool writeCandidate = ps.
getParameter<
bool>(
"writeCandidate");
1288 switch (rMap[
name]) {
1291 writeOnia = writeCandidate;
1304 writeKx0 = writeCandidate;
1308 writePkk = writeCandidate;
1312 writeBu = writeCandidate;
1316 writeBd = writeCandidate;
1320 writeBs = writeCandidate;
1324 writeK0s = writeCandidate;
1328 writeLambda0 = writeCandidate;
1332 writeB0 = writeCandidate;
1336 writeLambdab = writeCandidate;
1340 writeBc = writeCandidate;
1344 writeX3872 = writeCandidate;
1348 map<string, parType>::const_iterator pIter = pMap.begin();
1349 map<string, parType>::const_iterator pIend = pMap.end();
1350 while (pIter != pIend) {
1352 const string& pn =
entry.first;
1356 edm::LogVerbatim(
"Configuration") <<
"BPHWriteSpecificDecay::setRecoParameters: set " << pn <<
" for " <<
name
1357 <<
" : " << (parMap[rMap[
name]][
id] =
pv);
1360 map<string, parType>::const_iterator fIter = fMap.begin();
1361 map<string, parType>::const_iterator fIend = fMap.end();
1362 while (fIter != fIend) {
1364 const string&
fn =
entry.first;
1366 edm::LogVerbatim(
"Configuration") <<
"BPHWriteSpecificDecay::setRecoParameters: set " <<
fn <<
" for " <<
name