47 : conf_(
config), theTrackPairFinder_(nullptr), theVertexFinder_(nullptr), theLikelihoodCalc_(nullptr) {
67 edm::InputTag oitracks(oitrackprod), oitracksassoc(oitrackprod, oitrackassoc), iotracks(iotrackprod),
68 iotracksassoc(iotrackprod, iotrackassoc);
139 auto outputConvPhotonCollection_p = std::make_unique<reco::ConversionCollection>();
142 auto cleanedConversionCollection_p = std::make_unique<reco::ConversionCollection>();
145 bool validBarrelSCHandle =
true;
148 if (!scBarrelHandle.
isValid()) {
149 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the scHybridBarrelProducer";
150 validBarrelSCHandle =
false;
154 bool validEndcapSCHandle =
true;
157 if (!scEndcapHandle.
isValid()) {
158 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the scIslandEndcapProducer";
159 validEndcapSCHandle =
false;
163 bool validTrackInputs =
true;
166 if (!outInTrkHandle.
isValid()) {
168 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the conversionOITrack "
170 validTrackInputs =
false;
177 if (!outInTrkSCAssocHandle.
isValid()) {
179 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the outInTrackSCAssociationCollection)";
180 validTrackInputs =
false;
186 if (!inOutTrkHandle.
isValid()) {
188 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the conversionIOTrack "
190 validTrackInputs =
false;
199 if (!generalTrkHandle.
isValid()) {
201 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the genralTracks "
209 if (!inOutTrkSCAssocHandle.
isValid()) {
211 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the inOutTrackSCAssociationCollection_.c_str()";
212 validTrackInputs =
false;
218 if (!bcBarrelHandle.
isValid()) {
219 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the bcBarrelCollection";
225 if (!bcEndcapHandle.
isValid()) {
226 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the bcEndcapCollection";
236 if (validTrackInputs) {
238 std::vector<reco::TransientTrack> t_outInTrk = (*theTransientTrackBuilder_).build(outInTrkHandle);
239 std::vector<reco::TransientTrack> t_inOutTrk = (*theTransientTrackBuilder_).build(inOutTrkHandle);
244 t_outInTrk, outInTrkHandle, outInTrkSCAssocHandle, t_inOutTrk, inOutTrkHandle, inOutTrkSCAssocHandle);
253 outputConvPhotonCollection);
260 outputConvPhotonCollection);
264 outputConvPhotonCollection_p->assign(outputConvPhotonCollection.begin(), outputConvPhotonCollection.end());
270 if (validBarrelSCHandle)
272 if (validEndcapSCHandle)
275 cleanedConversionCollection_p->assign(cleanedConversionCollection.begin(), cleanedConversionCollection.end());
294 std::vector<reco::TransientTrack> t_generalTrk;
296 t_generalTrk = (*theTransientTrackBuilder_).build(generalTrkHandle);
302 for (
auto const& aClus : scHandle->ptrs()) {
304 if (aClus->energy() / cosh(aClus->eta()) <=
minSCEt_)
315 std::vector<edm::Ref<reco::TrackCollection> > trackPairRef;
316 std::vector<math::XYZPointF> trackInnPos;
317 std::vector<math::XYZVectorF> trackPin;
318 std::vector<math::XYZVectorF> trackPout;
319 float minAppDist = -99;
331 if (!allPairs.empty()) {
335 iPair != allPairs.end();
341 if (!(aClus == caloPtr))
347 std::vector<math::XYZPointF> trkPositionAtEcal = theEcalImpactPositionFinder.
find(iPair->first, bcHandle);
348 std::vector<reco::CaloClusterPtr> matchingBC = theEcalImpactPositionFinder.
matchingBC();
352 if ((iPair->first).size() > 1) {
375 trackPairRef.clear();
380 for (std::vector<reco::TransientTrack>::const_iterator iTk = (iPair->first).begin();
381 iTk != (iPair->first).
end();
386 dynamic_cast<const reco::TrackTransientTrack*>(iTk->basicTransientTrack());
390 if (myTkRef->extra().isNonnull()) {
391 trackInnPos.push_back(
toFConverterP(myTkRef->innerPosition()));
393 trackPout.push_back(
toFConverterV(myTkRef->outerMomentum()));
395 trackPairRef.push_back(myTkRef);
402 if (theConversionVertex.
isValid()) {
425 outputConvPhotonCollection.push_back(newCandidate);
434 trackPairRef.clear();
438 std::vector<reco::TransientTrack>::const_iterator iTk = (iPair->first).
begin();
441 dynamic_cast<const reco::TrackTransientTrack*>(iTk->basicTransientTrack());
443 if (myTk->extra().isNonnull()) {
448 trackPairRef.push_back(myTk);
452 float theta1 = myTk->innerMomentum().Theta();
454 float dCotTheta = -999.;
456 std::vector<reco::TransientTrack>::const_iterator iGoodGenTran;
457 for (std::vector<reco::TransientTrack>::const_iterator iTran = t_generalTrk.begin();
458 iTran != t_generalTrk.end();
461 dynamic_cast<const reco::TrackTransientTrack*>(iTran->basicTransientTrack());
463 if (trRef->charge() * myTk->charge() > 0)
465 float dEta = trRef->eta() - myTk->eta();
466 float dPhi = trRef->phi() - myTk->phi();
469 float theta2 = trRef->innerMomentum().Theta();
470 dCotTheta = 1. /
tan(theta1) - 1. /
tan(theta2);
472 if (fabs(dCotTheta) < dCot) {
473 dCot = fabs(dCotTheta);
475 iGoodGenTran = iTran;
484 trackInnPos.push_back(
toFConverterP(goodRef->innerPosition()));
486 trackPout.push_back(
toFConverterV(goodRef->outerMomentum()));
487 trackPairRef.push_back(goodRef);
490 std::vector<reco::TransientTrack> mypair;
491 mypair.push_back(*iTk);
492 mypair.push_back(*iGoodGenTran);
520 outputConvPhotonCollection.push_back(newCandidate);
532 for (
auto const& aClus : scHandle->ptrs()) {
534 if (aClus->energy() / cosh(aClus->eta()) <=
minSCEt_)
541 for (std::vector<reco::ConversionRef>::iterator iRef = bestRef.begin(); iRef != bestRef.end(); iRef++) {
542 if (iRef->isNonnull()) {
543 newCandidate = (*iRef)->
clone();
544 outputConversionCollection.push_back(*newCandidate);
552 if (!(aClus.id() == cpRef->caloCluster()[0].
id() && aClus.key() == cpRef->caloCluster()[0].
key()))
554 if (!cpRef->isConverted())
556 if (cpRef->nTracks() < 2)
558 newCandidate = (&(*cpRef))->
clone();
559 outputConversionCollection.push_back(*newCandidate);
570 std::multimap<double, reco::ConversionRef, std::greater<double> > convMap;
576 if (!(scRef.
id() == cpRef->caloCluster()[0].
id() && scRef.
key() == cpRef->caloCluster()[0].
key()))
578 if (!cpRef->isConverted())
580 double like = cpRef->MVAout();
581 if (cpRef->nTracks() < 2)
584 convMap.insert(std::make_pair(like, cpRef));
589 std::multimap<double, reco::ConversionRef>::iterator iMap;
590 std::vector<reco::ConversionRef> bestRefs;
591 for (iMap = convMap.begin(); iMap != convMap.end(); iMap++) {
593 bestRefs.push_back(iMap->second);
606 double xx_1 = track1->innerPosition().x(), yy_1 = track1->innerPosition().y(), zz_1 = track1->innerPosition().z();
607 double xx_2 = track2->innerPosition().x(), yy_2 = track2->innerPosition().y(), zz_2 = track2->innerPosition().z();
619 x1 = tk->innerPosition().x();
620 y1 = tk->innerPosition().y();
621 phi = tk->innerMomentum().phi();
622 const int charge = tk->charge();