120 : conversionOITrackProducer_{consumes(
config.getParameter<
std::string>(
"conversionOITrackProducer"))},
121 conversionIOTrackProducer_{consumes(
config.getParameter<
std::string>(
"conversionIOTrackProducer"))},
122 outInTrackSCAssociationCollection_{consumes({
config.getParameter<
std::string>(
"conversionOITrackProducer"),
124 inOutTrackSCAssociationCollection_{consumes({
config.getParameter<
std::string>(
"conversionIOTrackProducer"),
128 convertedPhotonCollectionPutToken_{
129 produces<reco::ConversionCollection>(
config.getParameter<
std::string>(
"convertedPhotonCollection"))},
130 cleanedConvertedPhotonCollectionPutToken_{
131 produces<reco::ConversionCollection>(
config.getParameter<
std::string>(
"cleanedConvertedPhotonCollection"))},
135 scHybridBarrelProducer_{consumes(
config.getParameter<
edm::InputTag>(
"scHybridBarrelProducer"))},
136 scIslandEndcapProducer_{consumes(
config.getParameter<
edm::InputTag>(
"scIslandEndcapProducer"))},
139 mFToken_{esConsumes<MagneticField, IdealMagneticFieldRecord, edm::Transition::BeginRun>()},
140 transientTrackToken_{esConsumes<TransientTrackBuilder, TransientTrackRecord, edm::Transition::BeginRun>(
145 hOverEConeSize_{
config.getParameter<
double>(
"hOverEConeSize")},
146 maxHOverE_{
config.getParameter<
double>(
"maxHOverE")},
147 minSCEt_{
config.getParameter<
double>(
"minSCEt")},
148 recoverOneTrackCase_{
config.getParameter<
bool>(
"recoverOneTrackCase")},
149 dRForConversionRecovery_{
config.getParameter<
double>(
"dRForConversionRecovery")},
150 deltaCotCut_{
config.getParameter<
double>(
"deltaCotCut")},
151 minApproachDisCut_{
config.getParameter<
double>(
"minApproachDisCut")},
153 maxNumOfCandidates_{
config.getParameter<
int>(
"maxNumOfCandidates")},
154 risolveAmbiguity_{
config.getParameter<
bool>(
"risolveConversionAmbiguity")},
177 bool validBarrelSCHandle =
true;
179 if (!scBarrelHandle.isValid()) {
180 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the scHybridBarrelProducer";
181 validBarrelSCHandle =
false;
185 bool validEndcapSCHandle =
true;
188 if (!scEndcapHandle.
isValid()) {
189 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the scIslandEndcapProducer";
190 validEndcapSCHandle =
false;
194 bool validTrackInputs =
true;
196 if (!outInTrkHandle.isValid()) {
198 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the conversionOITrack "
200 validTrackInputs =
false;
206 if (!outInTrkSCAssocHandle.isValid()) {
208 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the outInTrackSCAssociationCollection)";
209 validTrackInputs =
false;
214 if (!inOutTrkHandle.isValid()) {
216 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the conversionIOTrack "
218 validTrackInputs =
false;
227 if (!generalTrkHandle.
isValid()) {
229 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the genralTracks "
236 if (!inOutTrkSCAssocHandle.isValid()) {
238 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the inOutTrackSCAssociationCollection_.c_str()";
239 validTrackInputs =
false;
245 if (!bcBarrelHandle.
isValid()) {
246 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the bcBarrelCollection";
252 if (!bcEndcapHandle.
isValid()) {
253 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the bcEndcapCollection";
259 if (validTrackInputs) {
267 t_outInTrk, outInTrkHandle, outInTrkSCAssocHandle, t_inOutTrk, inOutTrkHandle, inOutTrkSCAssocHandle);
276 outputConvPhotonCollection);
283 outputConvPhotonCollection);
291 if (validBarrelSCHandle)
293 if (validEndcapSCHandle)
314 std::vector<reco::TransientTrack> t_generalTrk;
321 for (
auto const& aClus : scHandle->ptrs()) {
323 if (aClus->energy() / cosh(aClus->eta()) <=
minSCEt_)
326 auto const* sc = dynamic_cast<const reco::SuperCluster*>(pClus);
333 std::vector<edm::Ref<reco::TrackCollection> > trackPairRef;
334 std::vector<math::XYZPointF> trackInnPos;
335 std::vector<math::XYZVectorF> trackPin;
336 std::vector<math::XYZVectorF> trackPout;
337 float minAppDist = -99;
349 if (!allPairs.empty()) {
352 for (
auto iPair = allPairs.begin(); iPair != allPairs.end(); ++iPair) {
357 if (!(aClus == caloPtr))
363 std::vector<math::XYZPointF> trkPositionAtEcal = theEcalImpactPositionFinder.
find(iPair->first, bcHandle);
364 std::vector<reco::CaloClusterPtr> matchingBC = theEcalImpactPositionFinder.
matchingBC();
368 if ((iPair->first).size() > 1) {
391 trackPairRef.clear();
396 for (std::vector<reco::TransientTrack>::const_iterator iTk = (iPair->first).begin();
397 iTk != (iPair->first).
end();
401 auto const* ttt = dynamic_cast<const reco::TrackTransientTrack*>(iTk->basicTransientTrack());
405 if (myTkRef->extra().isNonnull()) {
406 trackInnPos.push_back(
toFConverterP(myTkRef->innerPosition()));
408 trackPout.push_back(
toFConverterV(myTkRef->outerMomentum()));
410 trackPairRef.push_back(myTkRef);
417 if (theConversionVertex.
isValid()) {
439 outputConvPhotonCollection.push_back(newCandidate);
448 trackPairRef.clear();
452 std::vector<reco::TransientTrack>::const_iterator iTk = (iPair->first).begin();
454 auto const* ttt = dynamic_cast<const reco::TrackTransientTrack*>(iTk->basicTransientTrack());
456 if (myTk->extra().isNonnull()) {
461 trackPairRef.push_back(myTk);
465 float theta1 = myTk->innerMomentum().Theta();
467 float dCotTheta = -999.;
469 for (
auto const& tran : t_generalTrk) {
470 auto const* ttt = dynamic_cast<const reco::TrackTransientTrack*>(tran.basicTransientTrack());
472 if (trRef->charge() * myTk->charge() > 0)
474 float dEta = trRef->eta() - myTk->eta();
475 float dPhi = trRef->phi() - myTk->phi();
478 float theta2 = trRef->innerMomentum().Theta();
479 dCotTheta = 1. /
tan(theta1) - 1. /
tan(theta2);
481 if (fabs(dCotTheta) < dCot) {
482 dCot = fabs(dCotTheta);
492 trackInnPos.push_back(
toFConverterP(goodRef->innerPosition()));
494 trackPout.push_back(
toFConverterV(goodRef->outerMomentum()));
495 trackPairRef.push_back(goodRef);
511 const double like = -999.;
512 outputConvPhotonCollection.emplace_back(scPtrVec,
523 auto& newCandidate = outputConvPhotonCollection.back();
536 for (
auto const& aClus : scHandle->ptrs()) {
538 if (aClus->energy() / cosh(aClus->eta()) <=
minSCEt_)
545 for (std::vector<reco::ConversionRef>::iterator iRef = bestRef.begin(); iRef != bestRef.end(); iRef++) {
546 if (iRef->isNonnull()) {
547 newCandidate = (*iRef)->
clone();
548 outputConversionCollection.push_back(*newCandidate);
556 if (!(aClus.id() == cpRef->caloCluster()[0].
id() && aClus.key() == cpRef->caloCluster()[0].
key()))
558 if (!cpRef->isConverted())
560 if (cpRef->nTracks() < 2)
562 newCandidate = (&(*cpRef))->
clone();
563 outputConversionCollection.push_back(*newCandidate);
574 std::multimap<double, reco::ConversionRef, std::greater<double> > convMap;
580 if (!(scRef.
id() == cpRef->caloCluster()[0].
id() && scRef.
key() == cpRef->caloCluster()[0].key()))
582 if (!cpRef->isConverted())
584 double like = cpRef->MVAout();
585 if (cpRef->nTracks() < 2)
588 convMap.emplace(like, cpRef);
593 std::vector<reco::ConversionRef> bestRefs;
594 for (
auto iMap = convMap.begin(); iMap != convMap.end(); iMap++) {
596 bestRefs.push_back(iMap->second);
607 double xx_1 = track1->innerPosition().x(), yy_1 = track1->innerPosition().y(), zz_1 = track1->innerPosition().z();
608 double xx_2 = track2->innerPosition().x(), yy_2 = track2->innerPosition().y(), zz_2 = track2->innerPosition().z();
621 x1 = tk->innerPosition().x();
622 y1 = tk->innerPosition().y();
623 phi = tk->innerMomentum().phi();
624 const int charge = tk->charge();