-
Notifications
You must be signed in to change notification settings - Fork 45
Fix cone energy self-counting in IsolatedLeptonFinderProcessor #155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
cdb7266
2d630b7
1701e22
538b5f5
9a068a1
e881680
99ca1df
085214a
6425044
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,8 +22,8 @@ using namespace marlin; | |
|
|
||
| IsolatedLeptonFinderProcessor aIsolatedLeptonFinderProcessor; | ||
|
|
||
| IsolatedLeptonFinderProcessor::IsolatedLeptonFinderProcessor() : Processor("IsolatedLeptonFinderProcessor") { | ||
|
|
||
| IsolatedLeptonFinderProcessor::IsolatedLeptonFinderProcessor() | ||
| : Processor("IsolatedLeptonFinderProcessor"), _copy2orig() { | ||
| // Processor description | ||
| _description = "Isolated Lepton Finder Processor"; | ||
|
|
||
|
|
@@ -180,7 +180,16 @@ void IsolatedLeptonFinderProcessor::init() { | |
| printParameters(); | ||
| } | ||
|
|
||
| ReconstructedParticle* IsolatedLeptonFinderProcessor::findOriginal(ReconstructedParticle* pfo) const { | ||
| const auto it = _copy2orig.find(pfo); | ||
| if (it != _copy2orig.end()) { | ||
| return it->second; | ||
| } | ||
| return pfo; | ||
| } | ||
|
|
||
| void IsolatedLeptonFinderProcessor::processEvent(LCEvent* evt) { | ||
| _copy2orig.clear(); // Clear copy-origin map | ||
|
|
||
| streamlog_out(DEBUG) << std::endl; | ||
| streamlog_out(DEBUG) << "processing event: " << evt->getEventNumber() << " in run: " << evt->getRunNumber() | ||
|
|
@@ -238,6 +247,7 @@ void IsolatedLeptonFinderProcessor::processEvent(LCEvent* evt) { | |
| ReconstructedParticle* pfo_tmp = | ||
| static_cast<ReconstructedParticle*>(_pfoCol->getElementAt(goodLeptonIndices.at(i))); | ||
| ReconstructedParticleImpl* pfo = CopyReconstructedParticle(pfo_tmp); | ||
| _copy2orig[pfo] = pfo_tmp; // Map the address copy-original | ||
|
|
||
| if (_useDressedLeptons) { | ||
| // don't reprocess merged leptons | ||
|
|
@@ -334,9 +344,10 @@ void IsolatedLeptonFinderProcessor::dressLepton(ReconstructedParticleImpl* pfo, | |
| } | ||
| } | ||
| void IsolatedLeptonFinderProcessor::end() {} | ||
|
|
||
| ReconstructedParticleImpl* IsolatedLeptonFinderProcessor::CopyReconstructedParticle(ReconstructedParticle* pfo_orig) { | ||
| // copy this in an ugly fashion to be modifiable - a versatile copy constructor would be much better! | ||
| ReconstructedParticleImpl* pfo = new ReconstructedParticleImpl(); | ||
|
|
||
| pfo->setMomentum(pfo_orig->getMomentum()); | ||
| pfo->setEnergy(pfo_orig->getEnergy()); | ||
| pfo->setType(pfo_orig->getType()); | ||
|
|
@@ -346,14 +357,18 @@ ReconstructedParticleImpl* IsolatedLeptonFinderProcessor::CopyReconstructedParti | |
| pfo->setParticleIDUsed(pfo_orig->getParticleIDUsed()); | ||
| pfo->setGoodnessOfPID(pfo_orig->getGoodnessOfPID()); | ||
| pfo->setStartVertex(pfo_orig->getStartVertex()); | ||
| for (unsigned int i = 0; i < pfo->getTracks().size(); i++) { | ||
|
|
||
| // FIXED | ||
| for (unsigned int i = 0; i < pfo_orig->getTracks().size(); i++) { | ||
| pfo->addTrack(pfo_orig->getTracks()[i]); | ||
| } | ||
| for (unsigned int i = 0; i < pfo->getClusters().size(); i++) { | ||
| for (unsigned int i = 0; i < pfo_orig->getClusters().size(); i++) { | ||
| pfo->addCluster(pfo_orig->getClusters()[i]); | ||
| } | ||
|
|
||
| return pfo; | ||
| } | ||
|
|
||
| bool IsolatedLeptonFinderProcessor::IsCharged(ReconstructedParticle* pfo) { | ||
| if (pfo->getCharge() == 0) | ||
| return false; | ||
|
|
@@ -366,7 +381,6 @@ bool IsolatedLeptonFinderProcessor::IsPhoton(ReconstructedParticle* pfo) { | |
| return false; | ||
| } | ||
| bool IsolatedLeptonFinderProcessor::IsElectron(ReconstructedParticle* pfo) { | ||
|
|
||
| if (_usePandoraIDs) | ||
| return (abs(pfo->getType()) == 11); | ||
|
|
||
|
|
@@ -386,7 +400,6 @@ bool IsolatedLeptonFinderProcessor::IsElectron(ReconstructedParticle* pfo) { | |
| return false; | ||
| } | ||
| bool IsolatedLeptonFinderProcessor::IsMuon(ReconstructedParticle* pfo) { | ||
|
|
||
| if (_usePandoraIDs) | ||
| return (abs(pfo->getType()) == 13); | ||
|
|
||
|
|
@@ -406,14 +419,12 @@ bool IsolatedLeptonFinderProcessor::IsMuon(ReconstructedParticle* pfo) { | |
| return false; | ||
| } | ||
| bool IsolatedLeptonFinderProcessor::IsLepton(ReconstructedParticle* pfo) { | ||
|
|
||
| if (IsElectron(pfo) || IsMuon(pfo)) | ||
| return true; | ||
| return false; | ||
| } | ||
|
|
||
| bool IsolatedLeptonFinderProcessor::IsGoodLepton(ReconstructedParticle* pfo) { | ||
|
|
||
| if (!IsCharged(pfo)) | ||
| return false; | ||
|
|
||
|
|
@@ -430,7 +441,6 @@ bool IsolatedLeptonFinderProcessor::IsGoodLepton(ReconstructedParticle* pfo) { | |
| } | ||
|
|
||
| bool IsolatedLeptonFinderProcessor::IsIsolatedLepton(ReconstructedParticle* pfo) { | ||
|
|
||
| if (_useRectangularIsolation && !IsIsolatedRectangular(pfo)) | ||
| return false; | ||
|
|
||
|
|
@@ -469,27 +479,26 @@ bool IsolatedLeptonFinderProcessor::IsIsolatedPolynomial(ReconstructedParticle* | |
| } | ||
|
|
||
| bool IsolatedLeptonFinderProcessor::IsIsolatedJet(ReconstructedParticle* pfo) { | ||
| // jet-based isolated lepton (LAL algorithm) | ||
|
tmadlener marked this conversation as resolved.
|
||
| ReconstructedParticle* orig = findOriginal(pfo); | ||
|
|
||
| if (_rpJetMap.find(pfo) == _rpJetMap.end()) { | ||
| if (_rpJetMap.find(orig) == _rpJetMap.end()) { | ||
| // this is often the case when jet finding fails e.g. due to too few particles in event | ||
| // Use original address | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would move this comment further up. Alternatively, remove it entirely as it is pretty obvious from the code what we are doing, but the why we are doing it is missing. In this case the why is probably simply that the |
||
| return false; | ||
| } | ||
|
|
||
| ReconstructedParticle* jet = _rpJetMap[pfo]; | ||
| TVector3 vec1(pfo->getMomentum()); | ||
| ReconstructedParticle* jet = _rpJetMap[orig]; | ||
| TVector3 vec1(orig->getMomentum()); | ||
| TVector3 jetmom(jet->getMomentum()); | ||
| TLorentzVector jetmom4(jet->getMomentum(), jet->getEnergy()); | ||
|
|
||
| float jetxt = vec1.Pt(jetmom) / jetmom4.M(); | ||
| float jetz = pfo->getEnergy() / jet->getEnergy(); | ||
| float jetz = orig->getEnergy() / jet->getEnergy(); | ||
|
|
||
| if (jetxt >= _jetIsoVetoMinXt && jetxt < _jetIsoVetoMaxXt && jetz >= _jetIsoVetoMinZ && jetz < _jetIsoVetoMaxZ) { | ||
| // printf("xt=%f z=%f (not pass)\n",jetxt,jetz); | ||
| return false; | ||
| } | ||
|
|
||
| // printf("xt=%f z=%f (PASS)\n",jetxt,jetz); | ||
| return true; | ||
| } | ||
|
|
||
|
|
@@ -553,19 +562,24 @@ bool IsolatedLeptonFinderProcessor::PassesImpactParameterSignificanceCuts(Recons | |
| } | ||
|
|
||
| float IsolatedLeptonFinderProcessor::getConeEnergy(ReconstructedParticle* pfo) { | ||
| ReconstructedParticle* orig = findOriginal(pfo); // Get the original address | ||
|
|
||
| float coneE = 0; | ||
| TVector3 P(orig->getMomentum()); | ||
|
|
||
| TVector3 P(pfo->getMomentum()); | ||
| int npfo = _workingList.size(); | ||
| for (int i = 0; i < npfo; i++) { | ||
| ReconstructedParticle* pfo_i = static_cast<ReconstructedParticle*>(_workingList.at(i)); | ||
| ReconstructedParticle* pfo_i = _workingList[i]; | ||
|
|
||
| // don't add itself to the cone energy | ||
| if (pfo == pfo_i) | ||
| if (pfo_i == orig) | ||
| continue; | ||
|
|
||
| TVector3 P_i(pfo_i->getMomentum()); | ||
| if (P.Mag() == 0 || P_i.Mag() == 0) | ||
| continue; | ||
| float cosTheta = P.Dot(P_i) / (P.Mag() * P_i.Mag()); | ||
|
|
||
| if (cosTheta >= _cosConeAngle) | ||
| coneE += pfo_i->getEnergy(); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like another leftover from development.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, those comments was written earlier and forgot to arrange them