192 std::multimap<float, edm::Ptr<reco::ConversionTrack> > convTrackMap;
194 convTrackMap.insert(std::make_pair((*tk_ref)->track()->eta(),*tk_ref));
201 if (!vertexHandle.isValid()) {
202 edm::LogError(
"ConversionProducer") <<
"Error! Can't get the product primary Vertex Collection "<<
"\n";
225 std::multimap<double, reco::CaloClusterPtr> basicClusterPtrs;
226 std::multimap<double, reco::CaloClusterPtr> superClusterPtrs;
231 buildCollection( iEvent, iSetup, convTrackMap, superClusterPtrs, basicClusterPtrs, the_pvtx, outputConvPhotonCollection);
233 outputConvPhotonCollection_p->assign(outputConvPhotonCollection.begin(), outputConvPhotonCollection.end());
240 std::multimap<double, reco::CaloClusterPtr>& basicClusterPtrs,
241 std::multimap<double, reco::CaloClusterPtr>& superClusterPtrs){
246 if (!scBarrelHandle.
isValid()) {
253 if (!scEndcapHandle.
isValid()) {
262 if (!bcBarrelHandle.
isValid()) {
267 if (! bcEndcapHandle.
isValid()) {
275 for (
unsigned jj = 0;
jj < 2; ++
jj ){
276 for (
unsigned ii = 0;
ii < bcHandle->size(); ++
ii ) {
278 basicClusterPtrs.insert(std::make_pair(bcHandle->ptrAt(
ii)->position().eta(), bcHandle->ptrAt(
ii)));
280 bcHandle = bcEndcapHandle;
286 for (
unsigned jj = 0;
jj < 2; ++
jj ){
287 for (
unsigned ii = 0;
ii < scHandle->size(); ++
ii ) {
289 superClusterPtrs.insert(std::make_pair(scHandle->ptrAt(
ii)->position().eta(), scHandle->ptrAt(
ii)));
291 scHandle = scEndcapHandle;
301 const std::multimap<double, reco::CaloClusterPtr>& superClusterPtrs,
302 const std::multimap<double, reco::CaloClusterPtr>& basicClusterPtrs,
329 std::map<edm::Ptr<reco::ConversionTrack>,
math::XYZPointF> trackImpactPosition;
338 const reco::Track* tk = tk_ref->second->trackRef().get() ;
344 trackImpactPosition[tk_ref->second] = ew;
349 trackMatchedBC[tk_ref->second] = closest_bc;
360 bool track1HighPurity=
true;
369 if (dynamic_cast<const reco::GsfTrack*>(left.
get())) {
382 if (!(
trackD0Cut(left, the_pvtx))) track1HighPurity=
false;
384 if (!(
trackD0Cut(left))) track1HighPurity=
false;
387 std::vector<int> right_candidates;
388 std::vector<double> right_candidate_theta, right_candidate_approach;
389 std::vector<std::pair<bool, reco::Vertex> > vertex_candidates;
393 std::multimap<float, edm::Ptr<reco::ConversionTrack> >::const_iterator
rr = ll;
395 for (; rr !=
allTracks.lower_bound(etasearch); ++
rr ) {
396 bool track2HighPurity =
true;
397 bool highPurityPair =
true;
404 if (dynamic_cast<const reco::GsfTrack*>(right.
get())) {
424 double approachDist = -999.;
449 highPurityPair=
false;
453 if (!(
trackD0Cut(right, the_pvtx))) track2HighPurity=
false;
455 if (!(
trackD0Cut(right))) track2HighPurity=
false;
460 std::vector<edm::RefToBase<reco::Track> > trackPairRef;
461 trackPairRef.push_back(left);
462 trackPairRef.push_back(right);
464 std::vector<math::XYZVectorF> trackPin;
465 std::vector<math::XYZVectorF> trackPout;
466 std::vector<math::XYZPointF> trackInnPos;
467 std::vector<uint8_t> nHitsBeforeVtx;
468 std::vector<Measurement1DFloat> dlClosestHitToVtx;
479 if (ll->second->trajRef().isNonnull() && rr->second->trajRef().isNonnull()) {
480 std::pair<uint8_t,Measurement1DFloat> leftWrongHits = hitChecker.
nHitsBeforeVtx(*ll->second->trajRef().get(),theConversionVertex);
481 std::pair<uint8_t,Measurement1DFloat> rightWrongHits = hitChecker.
nHitsBeforeVtx(*rr->second->trajRef().get(),theConversionVertex);
482 nHitsBeforeVtx.push_back(leftWrongHits.first);
483 nHitsBeforeVtx.push_back(rightWrongHits.first);
484 dlClosestHitToVtx.push_back(leftWrongHits.second);
485 dlClosestHitToVtx.push_back(rightWrongHits.second);
492 if (theConversionVertex.
isValid()){
494 if (chi2Prob<
vtxChi2_) highPurityPair=
false;
498 std::vector<math::XYZPointF> trkPositionAtEcal;
499 std::vector<reco::CaloClusterPtr> matchingBC;
505 std::map<edm::Ptr<reco::ConversionTrack>,
math::XYZPointF>::const_iterator trackImpactPositionLeft = trackImpactPosition.find(ll->second);
506 std::map<edm::Ptr<reco::ConversionTrack>,
math::XYZPointF>::const_iterator trackImpactPositionRight = trackImpactPosition.find(rr->second);
507 std::map<edm::Ptr<reco::ConversionTrack>,
reco::CaloClusterPtr>::const_iterator trackMatchedBCLeft = trackMatchedBC.find(ll->second);
508 std::map<edm::Ptr<reco::ConversionTrack>,
reco::CaloClusterPtr>::const_iterator trackMatchedBCRight = trackMatchedBC.find(rr->second);
510 if (trackImpactPositionLeft!=trackImpactPosition.end()) {
511 trkPositionAtEcal.push_back(trackImpactPositionLeft->second);
516 if (trackImpactPositionRight!=trackImpactPosition.end()) {
517 trkPositionAtEcal.push_back(trackImpactPositionRight->second);
520 double total_e_bc = 0.;
521 if (trackMatchedBCLeft!=trackMatchedBC.end()) {
522 matchingBC.push_back(trackMatchedBCLeft->second);
523 total_e_bc += trackMatchedBCLeft->second->energy();
528 if (trackMatchedBCRight!=trackMatchedBC.end()) {
529 matchingBC.push_back(trackMatchedBCRight->second);
530 total_e_bc += trackMatchedBCRight->second->energy();
534 highPurityPair =
false;
540 highPurityPair = highPurityPair && track1HighPurity && track2HighPurity && goodVertex &&
checkPhi(left, right, trackerGeom, magField, theConversionVertex) ;
554 const float minAppDist = approachDist;
558 reco::Conversion newCandidate(scPtrVec, trackPairRef, trkPositionAtEcal, theConversionVertex, matchingBC, minAppDist, trackInnPos, trackPin, trackPout, nHitsBeforeVtx, dlClosestHitToVtx, nSharedHits, dummy, algo );
560 if (
matchingSC ( superClusterPtrs, newCandidate, scPtrVec) )
566 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());
567 bool arbitratedEcalSeeded = ll->second->isArbitratedEcalSeeded() && rr->second->isArbitratedEcalSeeded();
568 bool arbitratedMerged = ll->second->isArbitratedMerged() && rr->second->isArbitratedMerged();
569 bool arbitratedMergedEcalGeneral = ll->second->isArbitratedMergedEcalGeneral() && rr->second->isArbitratedMergedEcalGeneral();
576 outputConvPhotonCollection.push_back(newCandidate);
630 const float barrelRadius = 129.f;
631 const float barrelHalfLength = 270.9f;
632 const float endcapRadius = 171.1f;
633 const float endcapZ = 320.5f;
636 -barrelHalfLength, barrelHalfLength)));
647 stateAtECAL = propag.propagate(myTSOS, *theBarrel_);
651 stateAtECAL = propag.propagate(myTSOS, *thePositiveEtaEndcap_);
653 stateAtECAL = propag.propagate(myTSOS, *theNegativeEtaEndcap_);
676 for (std::multimap<double, reco::CaloClusterPtr>::const_iterator scItr = scMap.begin(); scItr != scMap.end(); scItr++) {
679 double sceta = sc->eta();
681 const double delta_eta = fabs(conveta - sceta);
682 if ( fabs(delta_eta) < fabs(detaMin) && fabs(delta_phi) < fabs(dphiMin) ) {
683 detaMin= fabs(delta_eta);
684 dphiMin= fabs(delta_phi);
699 const double track_eta = trackImpactPosition.eta();
700 const double track_phi = trackImpactPosition.phi();
702 double min_eta = 999., min_phi = 999.;
704 for (std::multimap<double, reco::CaloClusterPtr>::const_iterator bc = bcMap.lower_bound(track_eta -
halfWayEta_);
705 bc != bcMap.upper_bound(track_eta +
halfWayEta_); ++bc){
707 const double delta_eta = track_eta-(ebc->position().eta());
710 if (fabs(min_eta)>fabs(delta_eta) && fabs(min_phi)>fabs(delta_phi)){
713 closest_bc = bc->second;
720 closestBC = closest_bc;
745 double recoPhoR = vtx.
position().Rho();
757 stateAtVtx1 = propag.propagate(myTSOS1, *theBarrel_);
759 stateAtVtx1 = propag.propagate(myTSOS1, *theDisk_);
764 stateAtVtx2 = propag.propagate(myTSOS2, *theBarrel_);
766 stateAtVtx2 = propag.propagate(myTSOS2, *theDisk_);
789 ClosestApproachInRPhi closest;
791 if (!closest.status()) {
795 if (closest.crossingPoint().perp() <
r_cut) {
808 double rho = tangentPoint.
perp();
819 std::pair<GlobalTrajectoryParameters,GlobalTrajectoryParameters> trajs = tangent.
trajectoryParameters();
822 if (
std::abs(trajs.first.position().z() - trajs.second.position().z()) >
dzCut_) {
827 float minApproach = tangent.
perpdist();
828 appDist = minApproach;
848 double total_e_bc = 0;
849 if (bc_l.
isNonnull()) total_e_bc += bc_l->energy();
852 total_e_bc += bc_r->energy();
868 std::vector<reco::TransientTrack> pair;
869 pair.push_back(ttk_l);
870 pair.push_back(ttk_r);
884 const float PI = 3.1415927;
887 const float R_ECAL = 136.5;
894 float ZEcal = R_ECAL*sinh(EtaParticle)+Zvertex;
896 if(ZEcal != 0.0) Theta = atan(R_ECAL/ZEcal);
897 if(Theta<0.0) Theta = Theta+
PI ;
900 if( fabs(ETA) > etaBarrelEndcap )
903 if(EtaParticle<0.0 ) Zend = -Zend ;
904 float Zlen = Zend - Zvertex ;
905 float RR = Zlen/sinh(EtaParticle);
906 Theta = atan(RR/Zend);
907 if(Theta<0.0) Theta = Theta+
PI ;
908 ETA = -
log(
tan(0.5*Theta));
T getParameter(std::string const &) const
unsigned int maxNumOfTrackInPU_
ConversionVertexFinder * theVertexFinder_
double d0Error() const
error on d0
double delta_eta(double eta1, double eta2)
TransientVertex run(const std::vector< reco::TransientTrack > &pair)
edm::InputTag scBarrelProducer_
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)
edm::InputTag bcBarrelCollection_
double dxyError() const
error on dxy
void push_back(Ptr< T > const &iPtr)
std::pair< uint8_t, Measurement1DFloat > nHitsBeforeVtx(const Trajectory &traj, const reco::Vertex &vtx, double sigmaTolerance=3.0) const
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::vector< Conversion > ConversionCollection
collectin of Conversion objects
edm::InputTag scEndcapProducer_
TrajectoryStateOnSurface innermostMeasurementState() const
bool matchingSC(const std::multimap< double, reco::CaloClusterPtr > &scMap, reco::Conversion &conv, reco::CaloClusterPtrVector &mSC)
virtual GlobalPoint crossingPoint() const
const math::XYZPoint & innerPosition() const
position of the innermost hit
TrackAlgorithm algo() const
bool isNonnull() const
Checks for non-null.
bool isNonnull() const
Checks for non-null.
double dPhi(double phi1, double phi2)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
math::XYZVectorF toFConverterV(const math::XYZVector &val)
Tan< T >::type tan(const T &t)
double chi2() const
chi-squares
float ChiSquaredProbability(double chiSquared, double nrDOF)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
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)
double delta_phi(double ph11, double phi2)
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)
double deltaPhi(double phi1, double phi2)
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
const Track & track() const
double dPhicutForSCmatching_
bool trackD0Cut(const edm::RefToBase< reco::Track > &ref)
REF castTo() const
cast to a concrete type
T const * product() const
bool bypassPreselEcalEcal_
std::string ConvertedPhotonCollection_
static const float etaBarrelEndcap
std::string vertexProducer_
static const float Z_Endcap
virtual bool status() const
edm::InputTag bcEndcapCollection_
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
unsigned short found() const
Number of valid hits on track.
static const float R_ECAL
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)
virtual void produce(edm::Event &, const edm::EventSetup &)
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...
virtual bool calculate(const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb)
value_type const * get() 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 &)
bool checkVertex(const reco::TransientTrack &ttk_l, const reco::TransientTrack &ttk_r, const MagneticField *magField, reco::Vertex &the_vertex)