14 associatedByHighestPt(false),
20 associatedByHighestPt(associatedByHighestPt_),
26 associatedByHighestPt(associatedByHighestPt_),
32 associatedByHighestPt(particle_.associatedByHighestPt),
34 selfDecayMode(particle_.selfDecayMode),
35 associatedLeptons(particle_.associatedLeptons),
36 associatedNeutrinos(particle_.associatedNeutrinos),
37 associatedPhotons(particle_.associatedPhotons),
38 associatedJets(particle_.associatedJets),
39 associatedTops(particle_.associatedTops),
40 sortedDaughters(particle_.sortedDaughters)
129 std::vector<int> result;
131 if (dau) result.push_back(dau->id);
136 std::vector<int> result;
137 std::vector<std::vector<MELAParticle*>
const*> list; list.reserve(3);
141 for (std::vector<MELAParticle*>
const*& ll:list){
143 if (part) result.push_back(part->id);
194 std::vector<MELAParticle*> res;
195 std::vector<MELAParticle*>::iterator itEnd=
sortedVs.end();
196 std::vector<MELAParticle*>::iterator itBegin=itEnd;
197 for (std::vector<MELAParticle*>::iterator it=
sortedVs.begin(); it!=itEnd; it++){
199 for (
auto const& dau:
sortedDaughters){
if ((*it)->hasDaughter(dau)){ doSkip=
true;
break; } }
200 if (!doSkip){ itBegin=it;
break; }
202 if (itBegin!=itEnd) std::copy(itBegin, itEnd, std::back_inserter(res));
206 std::vector<MELAParticle*> res;
207 std::vector<MELAParticle*>::const_iterator itEnd=
sortedVs.cend();
208 std::vector<MELAParticle*>::const_iterator itBegin=itEnd;
209 for (std::vector<MELAParticle*>::const_iterator it=
sortedVs.cbegin(); it!=itEnd; it++){
211 for (
auto const& dau:
sortedDaughters){
if ((*it)->hasDaughter(dau)){ doSkip=
true;
break; } }
212 if (!doSkip){ itBegin=it;
break; }
214 if (itBegin!=itEnd) std::copy(itBegin, itEnd, std::back_inserter(res));
219 bool beginWithIdPair = (
227 int nDaughtersBooked=0;
228 int tmpDindex[2]={ 0 };
230 if (df[0]!=0) nDaughtersBooked++;
234 (beginWithIdPair && std::abs(dtmp->
charge())-std::abs(df[0]->
charge())==0 && std::abs(dtmp->
id)==std::abs(df[0]->
id))
240 (std::abs(dtmp->
charge()+df[0]->
charge())==1 && TMath::Sign(1, dtmp->
id)==-TMath::Sign(1, df[0]->
id))
255 if (j==tmpDindex[1])
continue;
260 if (sindex==2)
break;
264 if (
getNDaughters()>4)
MELAout <<
"MELACandidate::sortDaughtersInitial: Number of daughters passed " <<
getNDaughters() <<
">4 is currently not supported." << std::endl;
265 MELAout <<
"MELACandidate::sortDaughtersInitial: Number of daughters passed (" <<
getNDaughters() <<
") is not the same as number of daughters booked (" << nDaughtersBooked <<
")! Aborting, no daughters can be recorded." << std::endl;
268 if (part!=0)
MELAout <<
"\t- Passed daughter " << idau <<
" (X, Y, Z, T, M, Id) = "
269 << part->
x() <<
" " << part->
y() <<
" " << part->
z() <<
" " << part->
t() <<
" " << part->
m() <<
" " << part->
id << std::endl;
270 else MELAout <<
"\t- Passed daughter " << idau <<
" = 0!" << std::endl;
272 for (
unsigned int j=0; j<2; j++){
if (df[j]!=0)
MELAout <<
"\t- df[" << j <<
"] (X, Y, Z, T, M, Id) = " << df[j]->
x() <<
" " << df[j]->
y() <<
" " << df[j]->
z() <<
" " << df[j]->
t() <<
" " << df[j]->
m() <<
" " << df[j]->
id << std::endl; }
273 for (
unsigned int j=0; j<2; j++){
if (
ds[j]!=0)
MELAout <<
"\t- ds[" << j <<
"] (X, Y, Z, T, M, Id) = " <<
ds[j]->x() <<
" " <<
ds[j]->y() <<
" " <<
ds[j]->z() <<
" " <<
ds[j]->t() <<
" " <<
ds[j]->m() <<
" " <<
ds[j]->id << std::endl; }
278 (df[0]!=0 && df[1]!=0)
282 (df[0]->
id<df[1]->
id && beginWithIdPair)
284 (df[0]->
id<df[1]->
id && df[0]->
id<0 && beginWithWPair)
286 ((df[0]->
id*df[1]->
id>0 || (df[0]->
id==0 && df[1]->
id==0)) && df[0]->
phi()<df[1]->
phi())
295 (
ds[0]!=0 &&
ds[1]!=0)
299 (
ds[0]->
id<
ds[1]->
id && beginWithIdPair)
301 (
ds[0]->
id<
ds[1]->
id &&
ds[0]->
id<0 && beginWithWPair)
303 ((
ds[0]->
id*
ds[1]->
id>0 || (
ds[0]->
id==0 &&
ds[1]->
id==0)) &&
ds[0]->
phi()<
ds[1]->
phi())
310 if (df[1]==0 && df[0]!=0 &&
ds[0]!=0 &&
ds[1]!=0){
311 for (
int ip=0; ip<2; ip++){
317 for (
int i=0; i<2; i++){
320 for (
int i=0; i<2; i++){
325 bool beginWithZPair = (
330 bool beginWithMasslessPair = (
334 bool beginWithIdPair = beginWithZPair || beginWithMasslessPair;
342 TLorentzVector pZ1(0, 0, 0, 0);
343 TLorentzVector pZ2(0, 0, 0, 0);
345 bool dauDiffType =
true;
379 (dauDiffType && beginWithIdPair && (
400 !dauDiffType && beginWithIdPair && std::abs(pZ1.M() - HVVmass)<std::abs(pZ2.M() - HVVmass)
417 TLorentzVector ptmp = pZ1;
434 (orderedDs[0][1]!=0 && orderedDs[1][1]!=0)
436 (orderedDs[0][1]->
id == orderedDs[1][1]->
id)
440 (orderedDs[1][0]!=0 && orderedDs[0][0]!=0)
442 (orderedDs[1][0]->
id == orderedDs[0][0]->
id)
449 TLorentzVector pZ1p(0, 0, 0, 0);
450 TLorentzVector pZ2p(0, 0, 0, 0);
451 for (
int d=0; d<2; d++){
452 if (orderedDs[d][d]!=0) pZ1p = pZ1p + orderedDs[d][d]->
p4;
454 for (
int d=0; d<2; d++){
455 if (orderedDs[1-d][d]!=0) pZ2p = pZ2p + orderedDs[1-d][d]->
p4;
458 if (std::abs(pZ1p.M() - HVVmass)<std::abs(pZ2p.M() - HVVmass)){
459 orderedDps[0][0]=orderedDs[0][0];
460 orderedDps[0][1]=orderedDs[1][1];
461 orderedDps[1][0]=orderedDs[1][0];
462 orderedDps[1][1]=orderedDs[0][1];
465 orderedDps[0][0]=orderedDs[1][0];
466 orderedDps[0][1]=orderedDs[0][1];
467 orderedDps[1][0]=orderedDs[0][0];
468 orderedDps[1][1]=orderedDs[1][1];
469 TLorentzVector ptmp = pZ1p;
473 if (std::abs(pZ1p.M() - HVVmass)<std::abs(pZ1.M() - HVVmass) || (std::abs(pZ1p.M() - HVVmass)==std::abs(pZ1.M() - HVVmass) && pZ2p.Pt()>pZ2.Pt())){
474 for (
int i=0; i<2; i++){
475 for (
int j=0; j<2; j++) orderedDs[i][j] = orderedDps[i][j];
480 for (
int i=0; i<2; i++){
481 for (
int j=0; j<2; j++){
488 TLorentzVector nullVector(0, 0, 0, 0);
489 bool beginWithZPair = (
496 if (beginWithWPair) VID = 24;
497 else if (beginWithZPair) VID = 23;
501 int V1id=-9000, V2id=-9000;
502 if (icutoff==0) V1id=25;
504 double Vcharge[2]={ 0 };
505 for (
int d=0; d<icutoff; d++){
514 for (
int d=icutoff; d<imax; d++){
516 if ((imax-icutoff)==2){
517 V2id=(VID!=24 ? VID : -VID);
524 if (fabs(Vcharge[0]-1.)<0.001) V1id=24;
525 else if (fabs(Vcharge[0]+1.)<0.001) V1id=-24;
526 if (fabs(Vcharge[1]-1.)<0.001) V2id=24;
527 else if (fabs(Vcharge[1]+1.)<0.001) V2id=-24;
535 if (icutoff==0) Z1->
p4 = this->
p4;
548 bool beginWithZPair = (
559 TLorentzVector nullFourVector(0, 0, 0, 0);
564 return (index==0 ? pDD : pUU);
578 std::abs(pWp.M() - HVVmass) > std::abs(pWm.M() - HVVmass)
579 ) std::swap(pWp, pWm);
580 return (index==0 ? pWp : pWm);
586 return (index==0 ? pVa : pVb);
588 else return nullFourVector;
591 bool doInterfere =
false;
644 for (
unsigned int i = 0; i<particleArray.size(); i++){
645 double Qi = particleArray.at(i)->charge();
646 const int& id_i = particleArray.at(i)->id;
648 for (
unsigned int j = i+1; j<particleArray.size(); j++){
649 double Qj = particleArray.at(j)->charge();
650 const int& id_j = particleArray.at(j)->id;
653 if ((Qi+Qj)==0 && (id_i+id_j)==0) bosonId = (id_i==0 ? 0 : 23);
665 ) bosonId=24*(Qi+Qj);
670 int firstdaughter = i, seconddaughter = j;
672 (particleArray.at(firstdaughter)->id<particleArray.at(seconddaughter)->id)
679 ) std::swap(firstdaughter, seconddaughter);
680 *boson += particleArray.at(firstdaughter);
681 *boson += particleArray.at(seconddaughter);
692 if (!dau->passSelection){
701 for (
auto* part:
sortedDaughters){
if (part) part->getRelatedParticles(particles); }
702 for (
auto* part:
associatedTops){
if (part) part->getRelatedParticles(particles); }
703 for (
auto* part:
sortedVs){
if (part) part->getRelatedParticles(particles); }
704 for (
auto* part:
associatedLeptons){
if (part) part->getRelatedParticles(particles); }
705 for (
auto* part:
associatedPhotons){
if (part) part->getRelatedParticles(particles); }
706 for (
auto* part:
associatedJets){
if (part) part->getRelatedParticles(particles); }
710 for (
auto* part:
sortedDaughters){
if (part) part->getDaughterParticles(particles); }
712 if (!sortedV)
continue;
714 for (
auto& dau:
sortedDaughters){
if (dau && sortedV->hasDaughter(dau)){ doAddV=
true;
break; } }
715 if (doAddV) sortedV->getDaughterParticles(particles);
721 if (!inserted) particleArray.push_back(myParticle);
725 if (!inserted) particleArray.push_back(myParticle);
730 for (std::vector<MELAParticle*>::iterator it = particleArray.begin(); it<particleArray.end(); it++){
731 if ((*it)->pt()<myParticle->
pt()){
733 particleArray.insert(it, myParticle);
737 if (!inserted) particleArray.push_back(myParticle);
743 for (std::vector<MELAThreeBodyDecayCandidate*>::iterator it = particleArray.begin(); it<particleArray.end(); it++){
744 if ((*it)->pt()<myParticle->
pt()){
746 particleArray.insert(it, myParticle);
750 if (!inserted) particleArray.push_back(myParticle);