188 auto outputConvPhotonCollection_p = std::make_unique<reco::ConversionCollection>();
197 std::multimap<float, edm::Ptr<reco::ConversionTrack> > convTrackMap;
198 for(
auto const&
t : trackCollectionHandle->ptrs()) convTrackMap.emplace(
t->track()->eta(),
t);
206 <<
"Error! Can't get the product primary Vertex Collection "<<
"\n";
210 vertexCollection = *(vertexHandle.
product());
219 if (!vertexCollection.empty())
220 the_pvtx = *(vertexCollection.begin());
229 std::multimap<double, reco::CaloClusterPtr> basicClusterPtrs;
230 std::multimap<double, reco::CaloClusterPtr> superClusterPtrs;
235 buildCollection( iEvent, iSetup, convTrackMap, superClusterPtrs, basicClusterPtrs, the_pvtx, outputConvPhotonCollection);
237 outputConvPhotonCollection_p->assign(outputConvPhotonCollection.begin(), outputConvPhotonCollection.end());
244 std::multimap<double, reco::CaloClusterPtr>& basicClusterPtrs,
245 std::multimap<double, reco::CaloClusterPtr>& superClusterPtrs){
250 if (!scBarrelHandle.
isValid()) {
252 <<
"Error! Can't get the barrel superclusters!";
258 if (!scEndcapHandle.
isValid()) {
260 <<
"Error! Can't get the endcap superclusters!";
268 if (!bcBarrelHandle.
isValid()) {
270 <<
"Error! Can't get the barrel basic clusters!";
274 if (! bcEndcapHandle.
isValid()) {
276 <<
"Error! Can't get the endcap basic clusters!";
279 if( bcBarrelHandle.
isValid() ) {
280 for(
auto const&
handle : {bcBarrelHandle, bcEndcapHandle} ) {
281 for(
auto const& bc :
handle->ptrs()) {
282 if(bc->energy() >
energyBC_) basicClusterPtrs.emplace(bc->position().eta(), bc);
287 if( scBarrelHandle.
isValid() ) {
288 for(
auto const&
handle : {scBarrelHandle, scEndcapHandle} ) {
289 for(
auto const&
sc :
handle->ptrs()) {
300 const std::multimap<double, reco::CaloClusterPtr>& superClusterPtrs,
301 const std::multimap<double, reco::CaloClusterPtr>& basicClusterPtrs,
328 std::map<edm::Ptr<reco::ConversionTrack>,
math::XYZPointF> trackImpactPosition;
337 const reco::Track* tk = tk_ref->second->trackRef().get() ;
343 trackImpactPosition[tk_ref->second] = ew;
348 trackMatchedBC[tk_ref->second] = closest_bc;
359 bool track1HighPurity=
true;
368 if (dynamic_cast<const reco::GsfTrack*>(left.
get())) {
381 if (!(
trackD0Cut(left, the_pvtx))) track1HighPurity=
false;
383 if (!(
trackD0Cut(left))) track1HighPurity=
false;
386 std::vector<int> right_candidates;
387 std::vector<double> right_candidate_theta, right_candidate_approach;
388 std::vector<std::pair<bool, reco::Vertex> > vertex_candidates;
392 std::multimap<float, edm::Ptr<reco::ConversionTrack> >::const_iterator
rr = ll;
394 for (; rr !=
allTracks.lower_bound(etasearch); ++
rr ) {
395 bool track2HighPurity =
true;
396 bool highPurityPair =
true;
403 if (dynamic_cast<const reco::GsfTrack*>(right.
get())) {
423 double approachDist = -999.;
436 bool goodVertex =
checkVertex(ttk_l, ttk_r, magField, theConversionVertex);
448 highPurityPair=
false;
452 if (!(
trackD0Cut(right, the_pvtx))) track2HighPurity=
false;
454 if (!(
trackD0Cut(right))) track2HighPurity=
false;
459 std::vector<edm::RefToBase<reco::Track> > trackPairRef;
460 trackPairRef.push_back(left);
461 trackPairRef.push_back(right);
463 std::vector<math::XYZVectorF> trackPin;
464 std::vector<math::XYZVectorF> trackPout;
465 std::vector<math::XYZPointF> trackInnPos;
466 std::vector<uint8_t> nHitsBeforeVtx;
467 std::vector<Measurement1DFloat> dlClosestHitToVtx;
478 nHitsBeforeVtx.push_back(leftWrongHits.first);
479 nHitsBeforeVtx.push_back(rightWrongHits.first);
480 dlClosestHitToVtx.push_back(leftWrongHits.second);
481 dlClosestHitToVtx.push_back(rightWrongHits.second);
488 if (theConversionVertex.
isValid()){
490 if (chi2Prob<
vtxChi2_) highPurityPair=
false;
494 std::vector<math::XYZPointF> trkPositionAtEcal;
495 std::vector<reco::CaloClusterPtr> matchingBC;
501 std::map<edm::Ptr<reco::ConversionTrack>,
math::XYZPointF>::const_iterator trackImpactPositionLeft = trackImpactPosition.find(ll->second);
502 std::map<edm::Ptr<reco::ConversionTrack>,
math::XYZPointF>::const_iterator trackImpactPositionRight = trackImpactPosition.find(rr->second);
503 std::map<edm::Ptr<reco::ConversionTrack>,
reco::CaloClusterPtr>::const_iterator trackMatchedBCLeft = trackMatchedBC.find(ll->second);
504 std::map<edm::Ptr<reco::ConversionTrack>,
reco::CaloClusterPtr>::const_iterator trackMatchedBCRight = trackMatchedBC.find(rr->second);
506 if (trackImpactPositionLeft!=trackImpactPosition.end()) {
507 trkPositionAtEcal.push_back(trackImpactPositionLeft->second);
512 if (trackImpactPositionRight!=trackImpactPosition.end()) {
513 trkPositionAtEcal.push_back(trackImpactPositionRight->second);
516 double total_e_bc = 0.;
517 if (trackMatchedBCLeft!=trackMatchedBC.end()) {
518 matchingBC.push_back(trackMatchedBCLeft->second);
519 total_e_bc += trackMatchedBCLeft->second->energy();
524 if (trackMatchedBCRight!=trackMatchedBC.end()) {
525 matchingBC.push_back(trackMatchedBCRight->second);
526 total_e_bc += trackMatchedBCRight->second->energy();
530 highPurityPair =
false;
536 highPurityPair = highPurityPair && track1HighPurity && track2HighPurity && goodVertex &&
checkPhi(left, right, trackerGeom, magField, theConversionVertex) ;
550 const float minAppDist = approachDist;
554 reco::Conversion newCandidate(scPtrVec, trackPairRef, trkPositionAtEcal, theConversionVertex, matchingBC, minAppDist, trackInnPos, trackPin, trackPout, nHitsBeforeVtx, dlClosestHitToVtx, nSharedHits, dummy, algo );
556 if (
matchingSC ( superClusterPtrs, newCandidate, scPtrVec) )
561 bool generalTracksOnly = ll->second->isTrackerOnly() && rr->second->isTrackerOnly() && !
dynamic_cast<const reco::GsfTrack*
>(ll->second->trackRef().get()) && !dynamic_cast<const reco::GsfTrack*>(rr->second->trackRef().get());
562 bool gsfTracksOpenOnly = ll->second->isGsfTrackOpen() && rr->second->isGsfTrackOpen();
563 bool arbitratedEcalSeeded = ll->second->isArbitratedEcalSeeded() && rr->second->isArbitratedEcalSeeded();
564 bool arbitratedMerged = ll->second->isArbitratedMerged() && rr->second->isArbitratedMerged();
565 bool arbitratedMergedEcalGeneral = ll->second->isArbitratedMergedEcalGeneral() && rr->second->isArbitratedMergedEcalGeneral();
573 outputConvPhotonCollection.push_back(newCandidate);
633 -barrelHalfLength, barrelHalfLength)));
644 stateAtECAL = propag.
propagate(myTSOS, *theBarrel_);
648 stateAtECAL = propag.
propagate(myTSOS, *thePositiveEtaEndcap_);
650 stateAtECAL = propag.
propagate(myTSOS, *theNegativeEtaEndcap_);
673 for (std::multimap<double, reco::CaloClusterPtr>::const_iterator scItr = scMap.begin(); scItr != scMap.end(); scItr++) {
676 double sceta = sc->eta();
678 const double delta_eta = fabs(conveta - sceta);
679 if ( fabs(delta_eta) < fabs(detaMin) && fabs(delta_phi) < fabs(dphiMin) ) {
680 detaMin= fabs(delta_eta);
681 dphiMin= fabs(delta_phi);
696 const double track_eta = trackImpactPosition.eta();
697 const double track_phi = trackImpactPosition.phi();
699 double min_eta = 999., min_phi = 999.;
701 for (std::multimap<double, reco::CaloClusterPtr>::const_iterator bc = bcMap.lower_bound(track_eta -
halfWayEta_);
702 bc != bcMap.upper_bound(track_eta +
halfWayEta_); ++bc){
704 const double delta_eta = track_eta-(ebc->position().eta());
707 if (fabs(min_eta)>fabs(delta_eta) && fabs(min_phi)>fabs(delta_phi)){
710 closest_bc = bc->second;
717 closestBC = closest_bc;
742 double recoPhoR = vtx.
position().Rho();
754 stateAtVtx1 = propag.
propagate(myTSOS1, *theBarrel_);
756 stateAtVtx1 = propag.
propagate(myTSOS1, *theDisk_);
761 stateAtVtx2 = propag.
propagate(myTSOS2, *theBarrel_);
763 stateAtVtx2 = propag.
propagate(myTSOS2, *theDisk_);
805 double rho = tangentPoint.
perp();
816 std::pair<GlobalTrajectoryParameters,GlobalTrajectoryParameters> trajs = tangent.
trajectoryParameters();
819 if (
std::abs(trajs.first.position().z() - trajs.second.position().z()) >
dzCut_) {
824 float minApproach = tangent.
perpdist();
825 appDist = minApproach;
845 double total_e_bc = 0;
846 if (bc_l.
isNonnull()) total_e_bc += bc_l->energy();
849 total_e_bc += bc_r->energy();
865 std::vector<reco::TransientTrack> pair;
866 pair.push_back(ttk_l);
867 pair.push_back(ttk_r);
881 const float PI = 3.1415927;
884 const float R_ECAL = 136.5;
891 float ZEcal = R_ECAL*sinh(EtaParticle)+Zvertex;
893 if(ZEcal != 0.0) Theta = atan(R_ECAL/ZEcal);
894 if(Theta<0.0) Theta = Theta+
PI ;
897 if( fabs(ETA) > etaBarrelEndcap )
900 if(EtaParticle<0.0 ) Zend = -Zend ;
901 float Zlen = Zend - Zvertex ;
902 float RR = Zlen/sinh(EtaParticle);
903 Theta = atan(RR/Zend);
904 if(Theta<0.0) Theta = Theta+
PI ;
905 ETA = -
log(
tan(0.5*Theta));
constexpr double deltaPhi(double phi1, double phi2)
value_type const * get() const
T getParameter(std::string const &) const
unsigned int maxNumOfTrackInPU_
ConversionVertexFinder * theVertexFinder_
double d0Error() const
error on d0
edm::EDGetTokenT< reco::VertexCollection > vertexProducer_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool isNonnull() const
Checks for non-null.
TransientVertex run(const std::vector< reco::TransientTrack > &pair)
double d0() const
dxy parameter in perigee convention (d0 = -dxy)
bool getTrackImpactPosition(const reco::Track *tk_ref, const TrackerGeometry *trackerGeom, const MagneticField *magField, math::XYZPointF &ew)
const TrackExtraRef & extra() const
reference to "extra" object
std::pair< GlobalTrajectoryParameters, GlobalTrajectoryParameters > trajectoryParameters() const
double normalizedChi2() const
chi-squared divided by n.d.o.f. (or chi-squared * 1e6 if n.d.o.f. is zero)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
double dxyError() const
error on dxy
void push_back(Ptr< T > const &iPtr)
const TransientTrackBuilder * thettbuilder_
void setQuality(ConversionQuality q, bool b)
bool isValid() const
Tells whether the vertex is valid.
Geom::Phi< T > phi() 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)
reco::TransientTrack build(const reco::Track *p) const
double zOfPrimaryVertexFromTracks(const math::XYZPoint &myBeamSpot=math::XYZPoint()) const
static ConversionAlgorithm algoByName(const std::string &name)
void buildSuperAndBasicClusterGeoMap(const edm::Event &, std::multimap< double, reco::CaloClusterPtr > &basicClusterPtrs, std::multimap< double, reco::CaloClusterPtr > &superClusterPtrs)
GlobalPoint globalPosition() const
std::vector< Vertex > VertexCollection
collection of Vertex objects
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
const Point & position() const
position
math::XYZVectorF refittedPairMomentum() const
Conversion tracks momentum from the tracks refitted with vertex constraint.
std::pair< uint8_t, Measurement1DFloat > nHitsBeforeVtx(const reco::TrackExtra &track, const reco::Vertex &vtx, float sigmaTolerance=3.0) const
std::vector< Conversion > ConversionCollection
collectin of Conversion objects
TrajectoryStateOnSurface innermostMeasurementState() const
bool matchingSC(const std::multimap< double, reco::CaloClusterPtr > &scMap, reco::Conversion &conv, reco::CaloClusterPtrVector &mSC)
const math::XYZPoint & innerPosition() const
position of the innermost hit
TrackAlgorithm algo() const
bool status() const override
bool calculate(const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb) override
math::XYZVectorF toFConverterV(const math::XYZVector &val)
Tan< T >::type tan(const T &t)
static float etaBarrelEndcap
Abs< T >::type abs(const T &t)
float energy() const
Energy. Note this is taken from the first SimTrack only.
double chi2() const
chi-squares
float ChiSquaredProbability(double chiSquared, double nrDOF)
edm::EDGetTokenT< edm::View< reco::CaloCluster > > scEndcapProducer_
edm::EDGetTokenT< edm::View< reco::CaloCluster > > bcBarrelCollection_
bool calculate(const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb) override
edm::EDGetTokenT< edm::View< reco::CaloCluster > > bcEndcapCollection_
uint8_t nSharedHits(const reco::Track &trk1, const reco::Track &trk2) const
bool getMatchedBC(const std::multimap< double, reco::CaloClusterPtr > &bcMap, const math::XYZPointF &trackImpactPosition, reco::CaloClusterPtr &closestBC)
bool isNonnull() const
Checks for non-null.
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)
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
T const * product() const
const Track & track() const
double dPhicutForSCmatching_
bool trackD0Cut(const edm::RefToBase< reco::Track > &ref)
GlobalPoint crossingPoint() const override
bool bypassPreselEcalEcal_
std::string ConvertedPhotonCollection_
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
edm::EDGetTokenT< edm::View< reco::ConversionTrack > > src_
edm::EDGetTokenT< edm::View< reco::CaloCluster > > scBarrelProducer_
~ConversionProducer() override
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
unsigned short found() const
Number of valid hits on track.
void produce(edm::Event &, const edm::EventSetup &) override
double etaTransformation(float EtaParticle, float Zvertex)
int charge() const
track electric charge
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)
bool status() const override
GlobalPoint crossingPoint() const override
bool preselectTrackPair(const reco::TransientTrack &ttk_l, const reco::TransientTrack &ttk_r, double &appDist)
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
T const * product() const
void setMatchingSuperCluster(const reco::CaloClusterPtrVector &sc)
bool checkPhi(const edm::RefToBase< reco::Track > &tk_l, const edm::RefToBase< reco::Track > &tk_r, const TrackerGeometry *trackerGeom, const MagneticField *magField, const reco::Vertex &the_vertex)
double dEtacutForSCmatching_
GlobalVector globalDirection() const
ConversionProducer(const edm::ParameterSet &)
float eta() const
Momentum pseudorapidity. Note this is taken from the simtrack before the calorimeter.
bool checkVertex(const reco::TransientTrack &ttk_l, const reco::TransientTrack &ttk_r, const MagneticField *magField, reco::Vertex &the_vertex)