73 std::multimap<double, reco::CaloClusterPtr>& basicClusterPtrs,
74 std::multimap<double, reco::CaloClusterPtr>& superClusterPtrs);
134 const std::multimap<double, reco::CaloClusterPtr>& superClusterPtrs,
135 const std::multimap<double, reco::CaloClusterPtr>& basicClusterPtrs,
175 bool getMatchedBC(
const std::multimap<double, reco::CaloClusterPtr>& bcMap,
180 bool matchingSC(
const std::multimap<double, reco::CaloClusterPtr>& scMap,
195 return geom->idToDet(
hit.geographicalId());
209 src_ = consumes<edm::View<reco::ConversionTrack> >(iConfig.getParameter<
edm::InputTag>(
"src"));
211 maxNumOfTrackInPU_ = iConfig.getParameter<
int>(
"maxNumOfTrackInPU");
212 maxTrackRho_ = iConfig.getParameter<
double>(
"maxTrackRho");
213 maxTrackZ_ = iConfig.getParameter<
double>(
"maxTrackZ");
215 allowTrackBC_ = iConfig.getParameter<
bool>(
"AllowTrackBC");
216 allowD0_ = iConfig.getParameter<
bool>(
"AllowD0");
217 allowDeltaPhi_ = iConfig.getParameter<
bool>(
"AllowDeltaPhi");
218 allowDeltaCot_ = iConfig.getParameter<
bool>(
"AllowDeltaCot");
219 allowMinApproach_ = iConfig.getParameter<
bool>(
"AllowMinApproach");
220 allowOppCharge_ = iConfig.getParameter<
bool>(
"AllowOppCharge");
222 allowVertex_ = iConfig.getParameter<
bool>(
"AllowVertex");
224 bypassPreselGsf_ = iConfig.getParameter<
bool>(
"bypassPreselGsf");
225 bypassPreselEcal_ = iConfig.getParameter<
bool>(
"bypassPreselEcal");
226 bypassPreselEcalEcal_ = iConfig.getParameter<
bool>(
"bypassPreselEcalEcal");
228 deltaEta_ = iConfig.getParameter<
double>(
"deltaEta");
230 halfWayEta_ = iConfig.getParameter<
double>(
"HalfwayEta");
232 d0Cut_ = iConfig.getParameter<
double>(
"d0");
234 usePvtx_ = iConfig.getParameter<
bool>(
"UsePvtx");
236 vertexProducer_ = consumes<reco::VertexCollection>(iConfig.getParameter<
edm::InputTag>(
"primaryVertexProducer"));
243 dEtaTkBC_ = iConfig.getParameter<
double>(
"dEtaTrackBC");
244 dPhiTkBC_ = iConfig.getParameter<
double>(
"dPhiTrackBC");
246 bcBarrelCollection_ =
247 consumes<edm::View<reco::CaloCluster> >(iConfig.getParameter<
edm::InputTag>(
"bcBarrelCollection"));
248 bcEndcapCollection_ =
249 consumes<edm::View<reco::CaloCluster> >(iConfig.getParameter<
edm::InputTag>(
"bcEndcapCollection"));
251 scBarrelProducer_ = consumes<edm::View<reco::CaloCluster> >(iConfig.getParameter<
edm::InputTag>(
"scBarrelProducer"));
252 scEndcapProducer_ = consumes<edm::View<reco::CaloCluster> >(iConfig.getParameter<
edm::InputTag>(
"scEndcapProducer"));
254 energyBC_ = iConfig.getParameter<
double>(
"EnergyBC");
255 energyTotalBC_ = iConfig.getParameter<
double>(
"EnergyTotalBC");
256 minSCEt_ = iConfig.getParameter<
double>(
"minSCEt");
257 dEtacutForSCmatching_ = iConfig.getParameter<
double>(
258 "dEtacutForSCmatching");
259 dPhicutForSCmatching_ = iConfig.getParameter<
double>(
260 "dPhicutForSCmatching");
265 maxChi2Left_ = iConfig.getParameter<
double>(
"MaxChi2Left");
266 maxChi2Right_ = iConfig.getParameter<
double>(
"MaxChi2Right");
267 minHitsLeft_ = iConfig.getParameter<
int>(
"MinHitsLeft");
268 minHitsRight_ = iConfig.getParameter<
int>(
"MinHitsRight");
271 deltaCotTheta_ = iConfig.getParameter<
double>(
"DeltaCotTheta");
272 deltaPhi_ = iConfig.getParameter<
double>(
"DeltaPhi");
273 minApproachLow_ = iConfig.getParameter<
double>(
"MinApproachLow");
274 minApproachHigh_ = iConfig.getParameter<
double>(
"MinApproachHigh");
277 allowSingleLeg_ = iConfig.getParameter<
bool>(
"AllowSingleLeg");
278 rightBC_ = iConfig.getParameter<
bool>(
"AllowRightBC");
281 dzCut_ = iConfig.getParameter<
double>(
"dz");
283 r_cut = iConfig.getParameter<
double>(
"rCut");
284 vtxChi2_ = iConfig.getParameter<
double>(
"vtxChi2");
286 thettbuilder_ =
nullptr;
289 ConvertedPhotonCollection_ = iConfig.getParameter<
std::string>(
"convertedPhotonCollection");
291 produces<reco::ConversionCollection>(ConvertedPhotonCollection_);
299 auto outputConvPhotonCollection_p = std::make_unique<reco::ConversionCollection>();
305 iEvent.getByToken(
src_, trackCollectionHandle);
308 std::multimap<float, edm::Ptr<reco::ConversionTrack> > convTrackMap;
309 for (
auto const&
t : trackCollectionHandle->ptrs())
310 convTrackMap.emplace(
t->track()->eta(),
t);
317 edm::LogError(
"ConversionProducer") <<
"Error! Can't get the product primary Vertex Collection "
338 std::multimap<double, reco::CaloClusterPtr> basicClusterPtrs;
339 std::multimap<double, reco::CaloClusterPtr> superClusterPtrs;
349 outputConvPhotonCollection);
351 outputConvPhotonCollection_p->assign(outputConvPhotonCollection.begin(), outputConvPhotonCollection.end());
356 std::multimap<double, reco::CaloClusterPtr>& basicClusterPtrs,
357 std::multimap<double, reco::CaloClusterPtr>& superClusterPtrs) {
361 if (!scBarrelHandle.
isValid()) {
362 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the barrel superclusters!";
368 if (!scEndcapHandle.
isValid()) {
369 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the endcap superclusters!";
376 if (!bcBarrelHandle.
isValid()) {
377 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the barrel basic clusters!";
381 if (!bcEndcapHandle.
isValid()) {
382 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the endcap basic clusters!";
385 if (bcBarrelHandle.
isValid()) {
386 for (
auto const&
handle : {bcBarrelHandle, bcEndcapHandle}) {
387 for (
auto const& bc :
handle->ptrs()) {
389 basicClusterPtrs.emplace(bc->position().eta(), bc);
394 if (scBarrelHandle.
isValid()) {
395 for (
auto const&
handle : {scBarrelHandle, scEndcapHandle}) {
396 for (
auto const& sc :
handle->ptrs()) {
398 superClusterPtrs.emplace(sc->position().eta(), sc);
407 const std::multimap<double, reco::CaloClusterPtr>& superClusterPtrs,
408 const std::multimap<double, reco::CaloClusterPtr>& basicClusterPtrs,
428 std::map<edm::Ptr<reco::ConversionTrack>,
math::XYZPointF> trackImpactPosition;
436 const reco::Track* tk = tk_ref.second->trackRef().get();
441 trackImpactPosition[tk_ref.second] = ew;
446 trackMatchedBC[tk_ref.second] = closest_bc;
455 bool track1HighPurity =
true;
463 if (dynamic_cast<const reco::GsfTrack*>(left.
get())) {
475 track1HighPurity =
false;
478 track1HighPurity =
false;
481 std::vector<int> right_candidates;
482 std::vector<double> right_candidate_theta, right_candidate_approach;
483 std::vector<std::pair<bool, reco::Vertex> > vertex_candidates;
487 std::multimap<float, edm::Ptr<reco::ConversionTrack> >::const_iterator
rr = ll;
490 bool track2HighPurity =
true;
491 bool highPurityPair =
true;
497 if (dynamic_cast<const reco::GsfTrack*>(right.
get())) {
514 double approachDist = -999.;
535 bool goodVertex =
checkVertex(ttk_l, ttk_r, magField, theConversionVertex);
545 highPurityPair =
false;
550 track2HighPurity =
false;
553 track2HighPurity =
false;
557 std::vector<edm::RefToBase<reco::Track> > trackPairRef;
558 trackPairRef.push_back(left);
559 trackPairRef.push_back(right);
561 std::vector<math::XYZVectorF> trackPin;
562 std::vector<math::XYZVectorF> trackPout;
563 std::vector<math::XYZPointF> trackInnPos;
564 std::vector<uint8_t> nHitsBeforeVtx;
565 std::vector<Measurement1DFloat> dlClosestHitToVtx;
576 nHitsBeforeVtx.push_back(leftWrongHits.first);
577 nHitsBeforeVtx.push_back(rightWrongHits.first);
578 dlClosestHitToVtx.push_back(leftWrongHits.second);
579 dlClosestHitToVtx.push_back(rightWrongHits.second);
585 if (theConversionVertex.
isValid()) {
588 highPurityPair =
false;
592 std::vector<math::XYZPointF> trkPositionAtEcal;
593 std::vector<reco::CaloClusterPtr> matchingBC;
599 std::map<edm::Ptr<reco::ConversionTrack>,
math::XYZPointF>::const_iterator trackImpactPositionLeft =
600 trackImpactPosition.find(ll->second);
601 std::map<edm::Ptr<reco::ConversionTrack>,
math::XYZPointF>::const_iterator trackImpactPositionRight =
602 trackImpactPosition.find(
rr->second);
603 std::map<edm::Ptr<reco::ConversionTrack>,
reco::CaloClusterPtr>::const_iterator trackMatchedBCLeft =
604 trackMatchedBC.find(ll->second);
605 std::map<edm::Ptr<reco::ConversionTrack>,
reco::CaloClusterPtr>::const_iterator trackMatchedBCRight =
606 trackMatchedBC.find(
rr->second);
608 if (trackImpactPositionLeft != trackImpactPosition.end()) {
609 trkPositionAtEcal.push_back(trackImpactPositionLeft->second);
613 if (trackImpactPositionRight != trackImpactPosition.end()) {
614 trkPositionAtEcal.push_back(trackImpactPositionRight->second);
617 double total_e_bc = 0.;
618 if (trackMatchedBCLeft != trackMatchedBC.end()) {
619 matchingBC.push_back(trackMatchedBCLeft->second);
620 total_e_bc += trackMatchedBCLeft->second->energy();
624 if (trackMatchedBCRight != trackMatchedBC.end()) {
625 matchingBC.push_back(trackMatchedBCRight->second);
626 total_e_bc += trackMatchedBCRight->second->energy();
630 highPurityPair =
false;
634 highPurityPair = highPurityPair && track1HighPurity && track2HighPurity && goodVertex &&
635 checkPhi(left, right, trackerGeom, magField, theConversionVertex);
648 const float minAppDist = approachDist;
667 if (
matchingSC(superClusterPtrs, newCandidate, scPtrVec))
672 !dynamic_cast<const reco::GsfTrack*>(ll->second->trackRef().get()) &&
673 !dynamic_cast<const reco::GsfTrack*>(
rr->second->trackRef().get());
674 bool gsfTracksOpenOnly = ll->second->isGsfTrackOpen() &&
rr->second->isGsfTrackOpen();
676 bool arbitratedMerged = ll->second->isArbitratedMerged() &&
rr->second->isArbitratedMerged();
677 bool arbitratedMergedEcalGeneral =
678 ll->second->isArbitratedMergedEcalGeneral() &&
rr->second->isArbitratedMergedEcalGeneral();
686 outputConvPhotonCollection.push_back(newCandidate);
724 constexpr
float epsilon = 0.001;
729 constexpr
float endcapZ = 320.5f;
743 stateAtECAL = propag.
propagate(myTSOS, *theBarrel_);
746 if (myTSOS.globalPosition().z() > 0.) {
747 stateAtECAL = propag.
propagate(myTSOS, *thePositiveEtaEndcap_);
749 stateAtECAL = propag.
propagate(myTSOS, *theNegativeEtaEndcap_);
764 double detaMin = 999.;
767 for (std::multimap<double, reco::CaloClusterPtr>::const_iterator scItr = scMap.begin(); scItr != scMap.end();
771 double sceta = sc->eta();
773 const double delta_eta = fabs(conveta - sceta);
791 const double track_eta = trackImpactPosition.eta();
792 const double track_phi = trackImpactPosition.phi();
794 double min_eta = 999., min_phi = 999.;
796 for (std::multimap<double, reco::CaloClusterPtr>::const_iterator bc = bcMap.lower_bound(track_eta -
halfWayEta_);
800 const double delta_eta = track_eta - (ebc->position().eta());
806 closest_bc = bc->second;
813 closestBC = closest_bc;
835 double recoPhoR =
vtx.position().Rho();
842 recoPhoR - 0.001, recoPhoR + 0.001, -fabs(
vtx.position().z()), fabs(
vtx.position().z()))));
849 stateAtVtx1 = propag.
propagate(myTSOS1, *theBarrel_);
851 stateAtVtx1 = propag.
propagate(myTSOS1, *theDisk_);
856 stateAtVtx2 = propag.
propagate(myTSOS2, *theBarrel_);
858 stateAtVtx2 = propag.
propagate(myTSOS2, *theDisk_);
898 double rho = tangentPoint.
perp();
909 std::pair<GlobalTrajectoryParameters, GlobalTrajectoryParameters> trajs = tangent.
trajectoryParameters();
912 if (
std::abs(trajs.first.position().z() - trajs.second.position().z()) >
dzCut_) {
916 float minApproach = tangent.
perpdist();
917 appDist = minApproach;
934 double total_e_bc = 0;
936 total_e_bc += bc_l->energy();
939 total_e_bc += bc_r->energy();
950 const float PI = 3.1415927;
953 const float R_ECAL = 136.5;
960 float ZEcal =
R_ECAL * sinh(EtaParticle) + Zvertex;
970 if (EtaParticle < 0.0)
972 float Zlen = Zend - Zvertex;
973 float RR = Zlen / sinh(EtaParticle);
974 Theta = atan(RR / Zend);