45 : conf_(
config), theTrackPairFinder_(nullptr), theVertexFinder_(nullptr), theLikelihoodCalc_(nullptr) {
65 edm::InputTag oitracks(oitrackprod), oitracksassoc(oitrackprod, oitrackassoc), iotracks(iotrackprod),
66 iotracksassoc(iotrackprod, iotrackassoc);
91 mFToken_ = esConsumes<MagneticField, IdealMagneticFieldRecord, edm::Transition::BeginRun>();
92 transientTrackToken_ = esConsumes<TransientTrackBuilder, TransientTrackRecord, edm::Transition::BeginRun>(
142 auto outputConvPhotonCollection_p = std::make_unique<reco::ConversionCollection>();
145 auto cleanedConversionCollection_p = std::make_unique<reco::ConversionCollection>();
148 bool validBarrelSCHandle =
true;
151 if (!scBarrelHandle.
isValid()) {
152 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the scHybridBarrelProducer";
153 validBarrelSCHandle =
false;
157 bool validEndcapSCHandle =
true;
160 if (!scEndcapHandle.
isValid()) {
161 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the scIslandEndcapProducer";
162 validEndcapSCHandle =
false;
166 bool validTrackInputs =
true;
169 if (!outInTrkHandle.
isValid()) {
171 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the conversionOITrack "
173 validTrackInputs =
false;
180 if (!outInTrkSCAssocHandle.
isValid()) {
182 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the outInTrackSCAssociationCollection)";
183 validTrackInputs =
false;
189 if (!inOutTrkHandle.
isValid()) {
191 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the conversionIOTrack "
193 validTrackInputs =
false;
202 if (!generalTrkHandle.
isValid()) {
204 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the genralTracks "
212 if (!inOutTrkSCAssocHandle.
isValid()) {
214 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the inOutTrackSCAssociationCollection_.c_str()";
215 validTrackInputs =
false;
221 if (!bcBarrelHandle.
isValid()) {
222 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the bcBarrelCollection";
228 if (!bcEndcapHandle.
isValid()) {
229 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the bcEndcapCollection";
239 if (validTrackInputs) {
241 std::vector<reco::TransientTrack> t_outInTrk = (*theTransientTrackBuilder_).build(outInTrkHandle);
242 std::vector<reco::TransientTrack> t_inOutTrk = (*theTransientTrackBuilder_).build(inOutTrkHandle);
247 t_outInTrk, outInTrkHandle, outInTrkSCAssocHandle, t_inOutTrk, inOutTrkHandle, inOutTrkSCAssocHandle);
256 outputConvPhotonCollection);
263 outputConvPhotonCollection);
267 outputConvPhotonCollection_p->assign(outputConvPhotonCollection.begin(), outputConvPhotonCollection.end());
273 if (validBarrelSCHandle)
275 if (validEndcapSCHandle)
278 cleanedConversionCollection_p->assign(cleanedConversionCollection.begin(), cleanedConversionCollection.end());
297 std::vector<reco::TransientTrack> t_generalTrk;
299 t_generalTrk = (*theTransientTrackBuilder_).build(generalTrkHandle);
305 for (
auto const& aClus : scHandle->ptrs()) {
307 if (aClus->energy() / cosh(aClus->eta()) <=
minSCEt_)
318 std::vector<edm::Ref<reco::TrackCollection> > trackPairRef;
319 std::vector<math::XYZPointF> trackInnPos;
320 std::vector<math::XYZVectorF> trackPin;
321 std::vector<math::XYZVectorF> trackPout;
322 float minAppDist = -99;
334 if (!allPairs.empty()) {
338 iPair != allPairs.end();
344 if (!(aClus == caloPtr))
350 std::vector<math::XYZPointF> trkPositionAtEcal = theEcalImpactPositionFinder.
find(iPair->first, bcHandle);
351 std::vector<reco::CaloClusterPtr> matchingBC = theEcalImpactPositionFinder.
matchingBC();
355 if ((iPair->first).size() > 1) {
378 trackPairRef.clear();
383 for (std::vector<reco::TransientTrack>::const_iterator iTk = (iPair->first).begin();
384 iTk != (iPair->first).
end();
389 dynamic_cast<const reco::TrackTransientTrack*>(iTk->basicTransientTrack());
393 if (myTkRef->extra().isNonnull()) {
394 trackInnPos.push_back(
toFConverterP(myTkRef->innerPosition()));
396 trackPout.push_back(
toFConverterV(myTkRef->outerMomentum()));
398 trackPairRef.push_back(myTkRef);
405 if (theConversionVertex.
isValid()) {
428 outputConvPhotonCollection.push_back(newCandidate);
437 trackPairRef.clear();
441 std::vector<reco::TransientTrack>::const_iterator iTk = (iPair->first).begin();
444 dynamic_cast<const reco::TrackTransientTrack*>(iTk->basicTransientTrack());
446 if (myTk->extra().isNonnull()) {
451 trackPairRef.push_back(myTk);
455 float theta1 = myTk->innerMomentum().Theta();
457 float dCotTheta = -999.;
459 std::vector<reco::TransientTrack>::const_iterator iGoodGenTran;
460 for (std::vector<reco::TransientTrack>::const_iterator iTran = t_generalTrk.begin();
461 iTran != t_generalTrk.end();
464 dynamic_cast<const reco::TrackTransientTrack*>(iTran->basicTransientTrack());
466 if (trRef->charge() * myTk->charge() > 0)
468 float dEta = trRef->eta() - myTk->eta();
469 float dPhi = trRef->phi() - myTk->phi();
472 float theta2 = trRef->innerMomentum().Theta();
473 dCotTheta = 1. /
tan(theta1) - 1. /
tan(theta2);
475 if (fabs(dCotTheta) < dCot) {
476 dCot = fabs(dCotTheta);
478 iGoodGenTran = iTran;
487 trackInnPos.push_back(
toFConverterP(goodRef->innerPosition()));
489 trackPout.push_back(
toFConverterV(goodRef->outerMomentum()));
490 trackPairRef.push_back(goodRef);
493 std::vector<reco::TransientTrack> mypair;
494 mypair.push_back(*iTk);
495 mypair.push_back(*iGoodGenTran);
523 outputConvPhotonCollection.push_back(newCandidate);
535 for (
auto const& aClus : scHandle->ptrs()) {
537 if (aClus->energy() / cosh(aClus->eta()) <=
minSCEt_)
544 for (std::vector<reco::ConversionRef>::iterator iRef = bestRef.begin(); iRef != bestRef.end(); iRef++) {
545 if (iRef->isNonnull()) {
546 newCandidate = (*iRef)->
clone();
547 outputConversionCollection.push_back(*newCandidate);
555 if (!(aClus.id() == cpRef->caloCluster()[0].
id() && aClus.key() == cpRef->caloCluster()[0].
key()))
557 if (!cpRef->isConverted())
559 if (cpRef->nTracks() < 2)
561 newCandidate = (&(*cpRef))->
clone();
562 outputConversionCollection.push_back(*newCandidate);
573 std::multimap<double, reco::ConversionRef, std::greater<double> > convMap;
579 if (!(scRef.
id() == cpRef->caloCluster()[0].
id() && scRef.
key() == cpRef->caloCluster()[0].
key()))
581 if (!cpRef->isConverted())
583 double like = cpRef->MVAout();
584 if (cpRef->nTracks() < 2)
587 convMap.insert(std::make_pair(like, cpRef));
592 std::multimap<double, reco::ConversionRef>::iterator iMap;
593 std::vector<reco::ConversionRef> bestRefs;
594 for (iMap = convMap.begin(); iMap != convMap.end(); iMap++) {
596 bestRefs.push_back(iMap->second);
609 double xx_1 = track1->innerPosition().x(), yy_1 = track1->innerPosition().y(), zz_1 = track1->innerPosition().z();
610 double xx_2 = track2->innerPosition().x(), yy_2 = track2->innerPosition().y(), zz_2 = track2->innerPosition().z();
622 x1 = tk->innerPosition().x();
623 y1 = tk->innerPosition().y();
624 phi = tk->innerMomentum().phi();
625 const int charge = tk->charge();