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);
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;
963 Theta = atan(
R_ECAL / ZEcal);
970 if (EtaParticle < 0.0)
972 float Zlen = Zend - Zvertex;
973 float RR = Zlen / sinh(EtaParticle);
974 Theta = atan(RR / Zend);
constexpr double deltaPhi(double phi1, double phi2)
bool checkVertex(const reco::TransientTrack &ttk_l, const reco::TransientTrack &ttk_r, MagneticField const &magField, reco::Vertex &the_vertex)
unsigned int maxNumOfTrackInPU_
const Track & track() const
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::VertexCollection > vertexProducer_
double zOfPrimaryVertexFromTracks(const math::XYZPoint &myBeamSpot=math::XYZPoint()) const
edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > transientTrackBuilder_
TransientVertex run(const std::vector< reco::TransientTrack > &pair)
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
bool status() const override
void push_back(Ptr< T > const &iPtr)
const Point & position() const
position
const TransientTrackBuilder * thettbuilder_
void setQuality(ConversionQuality q, bool b)
Geom::Phi< T > phi() const
int closest(std::vector< int > const &vec, int value)
math::XYZVectorF refittedPairMomentum() const
Conversion tracks momentum from the tracks refitted with vertex constraint.
uint8_t nSharedHits(const reco::Track &trk1, const reco::Track &trk2) const
T const * product() const
Global3DPoint GlobalPoint
void buildCollection(edm::Event &iEvent, const edm::EventSetup &iSetup, const std::multimap< float, edm::Ptr< reco::ConversionTrack > > &allTracks, const std::multimap< double, reco::CaloClusterPtr > &superClusterPtrs, const std::multimap< double, reco::CaloClusterPtr > &basicClusterPtrs, const reco::Vertex &the_pvtx, reco::ConversionCollection &outputConvPhotonCollection)
bool getTrackImpactPosition(const reco::Track *tk_ref, TrackerGeometry const &trackerGeom, MagneticField const &magField, math::XYZPointF &ew)
static ConversionAlgorithm algoByName(const std::string &name)
void buildSuperAndBasicClusterGeoMap(const edm::Event &, std::multimap< double, reco::CaloClusterPtr > &basicClusterPtrs, std::multimap< double, reco::CaloClusterPtr > &superClusterPtrs)
bool isNonnull() const
Checks for non-null.
std::vector< Vertex > VertexCollection
collection of Vertex objects
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
constexpr float barrelHalfLength
Log< level::Error, false > LogError
static constexpr float R_ECAL
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticField_
std::vector< Conversion > ConversionCollection
collectin of Conversion objects
std::pair< uint8_t, Measurement1DFloat > nHitsBeforeVtx(const reco::TrackExtra &track, const reco::Vertex &vtx, float sigmaTolerance=3.0) const
bool matchingSC(const std::multimap< double, reco::CaloClusterPtr > &scMap, reco::Conversion &conv, reco::CaloClusterPtrVector &mSC)
unsigned short found() const
Number of valid hits on track.
reco::TransientTrack build(const reco::Track *p) const
int charge() const
track electric charge
GlobalPoint globalPosition() const
double dxyError() const
error on dxy
math::XYZVectorF toFConverterV(const math::XYZVector &val)
constexpr float endcapRadius
bool isNonnull() const
Checks for non-null.
ConversionVertexFinder vertexFinder_
Tan< T >::type tan(const T &t)
Abs< T >::type abs(const T &t)
std::pair< GlobalTrajectoryParameters, GlobalTrajectoryParameters > trajectoryParameters() const
float ChiSquaredProbability(double chiSquared, double nrDOF)
#define DEFINE_FWK_MODULE(type)
edm::EDGetTokenT< edm::View< reco::CaloCluster > > scEndcapProducer_
edm::EDGetTokenT< edm::View< reco::CaloCluster > > bcBarrelCollection_
TrajectoryStateOnSurface innermostMeasurementState() const
static constexpr float etaBarrelEndcap
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< float > > XYZVectorF
spatial vector with cartesian internal representation
bool calculate(const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb) override
bool checkPhi(const edm::RefToBase< reco::Track > &tk_l, const edm::RefToBase< reco::Track > &tk_r, TrackerGeometry const &trackerGeom, MagneticField const &magField, const reco::Vertex &the_vertex)
edm::EDGetTokenT< edm::View< reco::CaloCluster > > bcEndcapCollection_
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerGeometry_
bool getMatchedBC(const std::multimap< double, reco::CaloClusterPtr > &bcMap, const math::XYZPointF &trackImpactPosition, reco::CaloClusterPtr &closestBC)
LocalVector toLocal(const reco::Track::Vector &v, const Surface &s)
bool checkTrackPair(const std::pair< edm::RefToBase< reco::Track >, reco::CaloClusterPtr > &ll, const std::pair< edm::RefToBase< reco::Track >, reco::CaloClusterPtr > &rr)
bool trackQualityFilter(const edm::RefToBase< reco::Track > &ref, bool isLeft)
TrackAlgorithm algo() const
const Plane & surface() const
The nominal surface of the GeomDet.
double d0() const
dxy parameter in perigee convention (d0 = -dxy)
double dPhicutForSCmatching_
XYZVectorD XYZVector
spatial vector with cartesian internal representation
bool trackD0Cut(const edm::RefToBase< reco::Track > &ref)
XYZPointD XYZPoint
point in space with cartesian internal representation
GlobalVector globalDirection() const
double normalizedChi2() const
chi-squared divided by n.d.o.f. (or chi-squared * 1e6 if n.d.o.f. is zero)
bool bypassPreselEcalEcal_
std::string ConvertedPhotonCollection_
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
edm::EDGetTokenT< edm::View< reco::ConversionTrack > > src_
double chi2() const
chi-squares
edm::EDGetTokenT< edm::View< reco::CaloCluster > > scBarrelProducer_
std::vector< Point > PointCollection
void produce(edm::Event &, const edm::EventSetup &) override
double etaTransformation(float EtaParticle, float Zvertex)
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
math::XYZPointF toFConverterP(const math::XYZPoint &val)
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
double d0Error() const
error on d0
bool preselectTrackPair(const reco::TransientTrack &ttk_l, const reco::TransientTrack &ttk_r, double &appDist)
const math::XYZPoint & innerPosition() const
position of the innermost hit
const GeomDet * recHitDet(const TrackingRecHit &hit, const TrackingGeometry *geom)
math::XYZVector Vector
spatial vector
value_type const * get() const
void setMatchingSuperCluster(const reco::CaloClusterPtrVector &sc)
const BoundPlane & recHitSurface(const TrackingRecHit &hit, const TrackingGeometry *geom)
bool isValid() const
Tells whether the vertex is valid.
static constexpr float Z_Endcap
constexpr float barrelRadius
double dEtacutForSCmatching_
GlobalPoint crossingPoint() const override
Global3DVector GlobalVector
ConversionProducer(const edm::ParameterSet &)
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
const TrackExtraRef & extra() const
reference to "extra" object