123 : conversionOITrackProducer_{consumes(
config.getParameter<
std::string>(
"conversionOITrackProducer"))},
124 conversionIOTrackProducer_{consumes(
config.getParameter<
std::string>(
"conversionIOTrackProducer"))},
125 outInTrackSCAssociationCollection_{consumes({
config.getParameter<
std::string>(
"conversionOITrackProducer"),
127 inOutTrackSCAssociationCollection_{consumes({
config.getParameter<
std::string>(
"conversionIOTrackProducer"),
131 convertedPhotonCollectionPutToken_{
132 produces<reco::ConversionCollection>(
config.getParameter<
std::string>(
"convertedPhotonCollection"))},
133 cleanedConvertedPhotonCollectionPutToken_{
134 produces<reco::ConversionCollection>(
config.getParameter<
std::string>(
"cleanedConvertedPhotonCollection"))},
138 scHybridBarrelProducer_{consumes(
config.getParameter<
edm::InputTag>(
"scHybridBarrelProducer"))},
139 scIslandEndcapProducer_{consumes(
config.getParameter<
edm::InputTag>(
"scIslandEndcapProducer"))},
142 mFToken_{esConsumes<MagneticField, IdealMagneticFieldRecord, edm::Transition::BeginRun>()},
143 transientTrackToken_{esConsumes<TransientTrackBuilder, TransientTrackRecord, edm::Transition::BeginRun>(
148 hOverEConeSize_{
config.getParameter<
double>(
"hOverEConeSize")},
149 maxHOverE_{
config.getParameter<
double>(
"maxHOverE")},
150 minSCEt_{
config.getParameter<
double>(
"minSCEt")},
151 recoverOneTrackCase_{
config.getParameter<
bool>(
"recoverOneTrackCase")},
152 dRForConversionRecovery_{
config.getParameter<
double>(
"dRForConversionRecovery")},
153 deltaCotCut_{
config.getParameter<
double>(
"deltaCotCut")},
154 minApproachDisCut_{
config.getParameter<
double>(
"minApproachDisCut")},
156 maxNumOfCandidates_{
config.getParameter<
int>(
"maxNumOfCandidates")},
157 risolveAmbiguity_{
config.getParameter<
bool>(
"risolveConversionAmbiguity")},
176 hcalHelper_ = std::make_unique<ElectronHcalHelper>(cfgCone, consumesCollector());
196 bool validBarrelSCHandle =
true;
198 if (!scBarrelHandle.isValid()) {
199 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the scHybridBarrelProducer";
200 validBarrelSCHandle =
false;
204 bool validEndcapSCHandle =
true;
207 if (!scEndcapHandle.
isValid()) {
208 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the scIslandEndcapProducer";
209 validEndcapSCHandle =
false;
213 bool validTrackInputs =
true;
215 if (!outInTrkHandle.isValid()) {
217 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the conversionOITrack "
219 validTrackInputs =
false;
225 if (!outInTrkSCAssocHandle.isValid()) {
227 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the outInTrackSCAssociationCollection)";
228 validTrackInputs =
false;
233 if (!inOutTrkHandle.isValid()) {
235 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the conversionIOTrack "
237 validTrackInputs =
false;
246 if (!generalTrkHandle.
isValid()) {
248 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the genralTracks "
255 if (!inOutTrkSCAssocHandle.isValid()) {
257 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the inOutTrackSCAssociationCollection_.c_str()";
258 validTrackInputs =
false;
264 if (!bcBarrelHandle.
isValid()) {
265 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the bcBarrelCollection";
271 if (!bcEndcapHandle.
isValid()) {
272 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the bcEndcapCollection";
275 if (validTrackInputs) {
283 t_outInTrk, outInTrkHandle, outInTrkSCAssocHandle, t_inOutTrk, inOutTrkHandle, inOutTrkSCAssocHandle);
294 outputConvPhotonCollection);
301 outputConvPhotonCollection);
309 if (validBarrelSCHandle)
311 if (validEndcapSCHandle)
332 std::vector<reco::TransientTrack> t_generalTrk;
339 for (
auto const& aClus : scHandle->ptrs()) {
341 if (aClus->energy() / cosh(aClus->eta()) <=
minSCEt_)
344 auto const* sc = dynamic_cast<const reco::SuperCluster*>(pClus);
345 double HoE = hcalHelper.
hcalESum(*sc, 0) / sc->energy();
350 std::vector<edm::Ref<reco::TrackCollection>> trackPairRef;
351 std::vector<math::XYZPointF> trackInnPos;
352 std::vector<math::XYZVectorF> trackPin;
353 std::vector<math::XYZVectorF> trackPout;
354 float minAppDist = -99;
366 if (!allPairs.empty()) {
369 for (
auto iPair = allPairs.begin(); iPair != allPairs.end(); ++iPair) {
374 if (!(aClus == caloPtr))
380 std::vector<math::XYZPointF> trkPositionAtEcal = theEcalImpactPositionFinder.
find(iPair->first, bcHandle);
381 std::vector<reco::CaloClusterPtr> matchingBC = theEcalImpactPositionFinder.
matchingBC();
385 if ((iPair->first).size() > 1) {
408 trackPairRef.clear();
413 for (std::vector<reco::TransientTrack>::const_iterator iTk = (iPair->first).begin();
414 iTk != (iPair->first).
end();
418 auto const* ttt = dynamic_cast<const reco::TrackTransientTrack*>(iTk->basicTransientTrack());
422 if (myTkRef->extra().isNonnull()) {
423 trackInnPos.push_back(
toFConverterP(myTkRef->innerPosition()));
425 trackPout.push_back(
toFConverterV(myTkRef->outerMomentum()));
427 trackPairRef.push_back(myTkRef);
434 if (theConversionVertex.
isValid()) {
456 outputConvPhotonCollection.push_back(newCandidate);
465 trackPairRef.clear();
469 std::vector<reco::TransientTrack>::const_iterator iTk = (iPair->first).begin();
471 auto const* ttt = dynamic_cast<const reco::TrackTransientTrack*>(iTk->basicTransientTrack());
473 if (myTk->extra().isNonnull()) {
478 trackPairRef.push_back(myTk);
482 float theta1 = myTk->innerMomentum().Theta();
484 float dCotTheta = -999.;
486 for (
auto const& tran : t_generalTrk) {
487 auto const* ttt = dynamic_cast<const reco::TrackTransientTrack*>(tran.basicTransientTrack());
489 if (trRef->charge() * myTk->charge() > 0)
491 float dEta = trRef->eta() - myTk->eta();
492 float dPhi = trRef->phi() - myTk->phi();
495 float theta2 = trRef->innerMomentum().Theta();
496 dCotTheta = 1. /
tan(theta1) - 1. /
tan(theta2);
498 if (fabs(dCotTheta) < dCot) {
499 dCot = fabs(dCotTheta);
509 trackInnPos.push_back(
toFConverterP(goodRef->innerPosition()));
511 trackPout.push_back(
toFConverterV(goodRef->outerMomentum()));
512 trackPairRef.push_back(goodRef);
528 const double like = -999.;
529 outputConvPhotonCollection.emplace_back(scPtrVec,
540 auto& newCandidate = outputConvPhotonCollection.back();
553 for (
auto const& aClus : scHandle->ptrs()) {
555 if (aClus->energy() / cosh(aClus->eta()) <=
minSCEt_)
562 for (std::vector<reco::ConversionRef>::iterator iRef = bestRef.begin(); iRef != bestRef.end(); iRef++) {
563 if (iRef->isNonnull()) {
564 newCandidate = (*iRef)->
clone();
565 outputConversionCollection.push_back(*newCandidate);
573 if (!(aClus.id() == cpRef->caloCluster()[0].
id() && aClus.key() == cpRef->caloCluster()[0].
key()))
575 if (!cpRef->isConverted())
577 if (cpRef->nTracks() < 2)
579 newCandidate = (&(*cpRef))->
clone();
580 outputConversionCollection.push_back(*newCandidate);
591 std::multimap<double, reco::ConversionRef, std::greater<double>> convMap;
597 if (!(scRef.
id() == cpRef->caloCluster()[0].
id() && scRef.
key() == cpRef->caloCluster()[0].key()))
599 if (!cpRef->isConverted())
601 double like = cpRef->MVAout();
602 if (cpRef->nTracks() < 2)
605 convMap.emplace(like, cpRef);
610 std::vector<reco::ConversionRef> bestRefs;
611 for (
auto iMap = convMap.begin(); iMap != convMap.end(); iMap++) {
613 bestRefs.push_back(iMap->second);
624 double xx_1 = track1->innerPosition().x(), yy_1 = track1->innerPosition().y(), zz_1 = track1->innerPosition().z();
625 double xx_2 = track2->innerPosition().x(), yy_2 = track2->innerPosition().y(), zz_2 = track2->innerPosition().z();
638 x1 = tk->innerPosition().x();
639 y1 = tk->innerPosition().y();
640 phi = tk->innerMomentum().phi();
641 const int charge = tk->charge();