123 : conversionOITrackProducer_{consumes(
config.getParameter<
std::string>(
"conversionOITrackProducer"))},
124 conversionIOTrackProducer_{consumes(
config.getParameter<
std::string>(
"conversionIOTrackProducer"))},
125 outInTrackSCAssociationCollection_{consumes({
config.getParameter<
std::string>(
"conversionOITrackProducer"),
127 inOutTrackSCAssociationCollection_{consumes({
config.getParameter<
std::string>(
"conversionIOTrackProducer"),
131 convertedPhotonCollectionPutToken_{
132 produces<reco::ConversionCollection>(
config.getParameter<
std::string>(
"convertedPhotonCollection"))},
133 cleanedConvertedPhotonCollectionPutToken_{
134 produces<reco::ConversionCollection>(
config.getParameter<
std::string>(
"cleanedConvertedPhotonCollection"))},
138 scHybridBarrelProducer_{consumes(
config.getParameter<
edm::InputTag>(
"scHybridBarrelProducer"))},
139 scIslandEndcapProducer_{consumes(
config.getParameter<
edm::InputTag>(
"scIslandEndcapProducer"))},
142 mFToken_{esConsumes<MagneticField, IdealMagneticFieldRecord, edm::Transition::BeginRun>()},
143 transientTrackToken_{esConsumes<TransientTrackBuilder, TransientTrackRecord, edm::Transition::BeginRun>(
148 hOverEConeSize_{
config.getParameter<
double>(
"hOverEConeSize")},
149 maxHOverE_{
config.getParameter<
double>(
"maxHOverE")},
150 minSCEt_{
config.getParameter<
double>(
"minSCEt")},
151 recoverOneTrackCase_{
config.getParameter<
bool>(
"recoverOneTrackCase")},
152 dRForConversionRecovery_{
config.getParameter<
double>(
"dRForConversionRecovery")},
153 deltaCotCut_{
config.getParameter<
double>(
"deltaCotCut")},
154 minApproachDisCut_{
config.getParameter<
double>(
"minApproachDisCut")},
156 maxNumOfCandidates_{
config.getParameter<
int>(
"maxNumOfCandidates")},
157 risolveAmbiguity_{
config.getParameter<
bool>(
"risolveConversionAmbiguity")},
176 hcalHelper_ = std::make_unique<ElectronHcalHelper>(cfgCone, consumesCollector());
196 bool validBarrelSCHandle =
true;
198 if (!scBarrelHandle.isValid()) {
199 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the scHybridBarrelProducer";
200 validBarrelSCHandle =
false;
204 bool validEndcapSCHandle =
true;
207 if (!scEndcapHandle.
isValid()) {
208 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the scIslandEndcapProducer";
209 validEndcapSCHandle =
false;
213 bool validTrackInputs =
true;
215 if (!outInTrkHandle.isValid()) {
217 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the conversionOITrack " 219 validTrackInputs =
false;
225 if (!outInTrkSCAssocHandle.isValid()) {
227 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the outInTrackSCAssociationCollection)";
228 validTrackInputs =
false;
233 if (!inOutTrkHandle.isValid()) {
235 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the conversionIOTrack " 237 validTrackInputs =
false;
246 if (!generalTrkHandle.
isValid()) {
248 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the genralTracks " 255 if (!inOutTrkSCAssocHandle.isValid()) {
257 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the inOutTrackSCAssociationCollection_.c_str()";
258 validTrackInputs =
false;
264 if (!bcBarrelHandle.
isValid()) {
265 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the bcBarrelCollection";
271 if (!bcEndcapHandle.
isValid()) {
272 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the bcEndcapCollection";
275 if (validTrackInputs) {
283 t_outInTrk, outInTrkHandle, outInTrkSCAssocHandle, t_inOutTrk, inOutTrkHandle, inOutTrkSCAssocHandle);
294 outputConvPhotonCollection);
301 outputConvPhotonCollection);
309 if (validBarrelSCHandle)
311 if (validEndcapSCHandle)
332 std::vector<reco::TransientTrack> t_generalTrk;
339 for (
auto const& aClus : scHandle->ptrs()) {
341 if (aClus->energy() / cosh(aClus->eta()) <=
minSCEt_)
345 double HoE = hcalHelper.
hcalESum(*sc, 0) / sc->energy();
350 std::vector<edm::Ref<reco::TrackCollection>> trackPairRef;
351 std::vector<math::XYZPointF> trackInnPos;
352 std::vector<math::XYZVectorF> trackPin;
353 std::vector<math::XYZVectorF> trackPout;
354 float minAppDist = -99;
366 if (!allPairs.empty()) {
369 for (
auto iPair = allPairs.begin(); iPair != allPairs.end(); ++iPair) {
374 if (!(aClus == caloPtr))
380 std::vector<math::XYZPointF> trkPositionAtEcal = theEcalImpactPositionFinder.
find(iPair->first, bcHandle);
381 std::vector<reco::CaloClusterPtr> matchingBC = theEcalImpactPositionFinder.
matchingBC();
385 if ((iPair->first).size() > 1) {
408 trackPairRef.clear();
413 for (std::vector<reco::TransientTrack>::const_iterator iTk = (iPair->first).begin();
414 iTk != (iPair->first).
end();
423 trackInnPos.push_back(
toFConverterP(myTkRef->innerPosition()));
425 trackPout.push_back(
toFConverterV(myTkRef->outerMomentum()));
427 trackPairRef.push_back(myTkRef);
434 if (theConversionVertex.
isValid()) {
456 outputConvPhotonCollection.push_back(newCandidate);
465 trackPairRef.clear();
469 std::vector<reco::TransientTrack>::const_iterator iTk = (iPair->first).begin();
478 trackPairRef.push_back(myTk);
482 float theta1 = myTk->innerMomentum().Theta();
484 float dCotTheta = -999.;
486 for (
auto const& tran : t_generalTrk) {
489 if (trRef->charge() * myTk->charge() > 0)
491 float dEta = trRef->eta() - myTk->eta();
492 float dPhi = trRef->phi() - myTk->phi();
495 float theta2 = trRef->innerMomentum().Theta();
496 dCotTheta = 1. /
tan(theta1) - 1. /
tan(theta2);
498 if (fabs(dCotTheta) < dCot) {
499 dCot = fabs(dCotTheta);
509 trackInnPos.push_back(
toFConverterP(goodRef->innerPosition()));
511 trackPout.push_back(
toFConverterV(goodRef->outerMomentum()));
512 trackPairRef.push_back(goodRef);
528 const double like = -999.;
529 outputConvPhotonCollection.emplace_back(scPtrVec,
540 auto& newCandidate = outputConvPhotonCollection.back();
553 for (
auto const& aClus : scHandle->ptrs()) {
555 if (aClus->energy() / cosh(aClus->eta()) <=
minSCEt_)
562 for (std::vector<reco::ConversionRef>::iterator iRef = bestRef.begin(); iRef != bestRef.end(); iRef++) {
563 if (iRef->isNonnull()) {
564 newCandidate = (*iRef)->
clone();
565 outputConversionCollection.push_back(*newCandidate);
573 if (!(aClus.id() == cpRef->caloCluster()[0].
id() && aClus.key() == cpRef->caloCluster()[0].
key()))
575 if (!cpRef->isConverted())
577 if (cpRef->nTracks() < 2)
579 newCandidate = (&(*cpRef))->
clone();
580 outputConversionCollection.push_back(*newCandidate);
591 std::multimap<double, reco::ConversionRef, std::greater<double>> convMap;
597 if (!(scRef.
id() == cpRef->caloCluster()[0].
id() && scRef.
key() == cpRef->caloCluster()[0].key()))
599 if (!cpRef->isConverted())
601 double like = cpRef->MVAout();
602 if (cpRef->nTracks() < 2)
605 convMap.emplace(like, cpRef);
610 std::vector<reco::ConversionRef> bestRefs;
611 for (
auto iMap = convMap.begin(); iMap != convMap.end(); iMap++) {
613 bestRefs.push_back(iMap->second);
624 double xx_1 = track1->innerPosition().x(), yy_1 = track1->innerPosition().y(), zz_1 = track1->innerPosition().z();
625 double xx_2 = track2->innerPosition().x(), yy_2 = track2->innerPosition().y(), zz_2 = track2->innerPosition().z();
638 x1 = tk->innerPosition().x();
639 y1 = tk->innerPosition().y();
640 phi = tk->innerMomentum().phi();
641 const int charge = tk->charge();
edm::EDPutTokenT< reco::ConversionCollection > cleanedConvertedPhotonCollectionPutToken_
edm::EDGetTokenT< reco::TrackCaloClusterPtrAssociation > outInTrackSCAssociationCollection_
edm::EDGetTokenT< edm::View< reco::CaloCluster > > bcEndcapCollection_
TransientVertex run(const std::vector< reco::TransientTrack > &pair)
ProductID id() const
Accessor for product ID.
ProductID id() const
Accessor for product ID.
std::string fullPath() const
edm::EDPutTokenT< reco::ConversionCollection > convertedPhotonCollectionPutToken_
const std::string metname
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
#define DEFINE_FWK_MODULE(type)
void push_back(Ptr< T > const &iPtr)
edm::EDGetTokenT< reco::TrackCollection > conversionIOTrackProducer_
Sin< T >::type sin(const T &t)
Global3DPoint GlobalPoint
edm::EDGetTokenT< edm::View< reco::CaloCluster > > scIslandEndcapProducer_
static ConversionAlgorithm algoByName(const std::string &name)
bool isNonnull() const
Checks for non-null.
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeomToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::unique_ptr< ElectronHcalHelper > hcalHelper_
edm::Ptr< CaloCluster > CaloClusterPtr
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
edm::EDGetTokenT< HBHERecHitCollection > hbheRecHits_
Log< level::Error, false > LogError
MagneticField const * magneticField_
edm::EDGetTokenT< HBHERecHitCollection > hbheRecHits
key_type key() const
Accessor for product key.
std::vector< Conversion > ConversionCollection
collectin of Conversion objects
std::vector< reco::CaloClusterPtr > matchingBC() const
double minApproachDisCut_
reco::TransientTrack build(const reco::Track *p) const
void beginRun(edm::Run const &, const edm::EventSetup &es) final
edm::EDGetTokenT< reco::TrackCollection > generalTrackProducer_
double hcalESum(const reco::SuperCluster &, int depth) const
math::XYZVectorF toFConverterV(const math::XYZVector &val)
void buildCollections(edm::EventSetup const &es, const edm::Handle< edm::View< reco::CaloCluster >> &scHandle, const edm::Handle< edm::View< reco::CaloCluster >> &bcHandle, ElectronHcalHelper const &hcalHelper, const edm::Handle< reco::TrackCollection > &trkHandle, std::map< std::vector< reco::TransientTrack >, reco::CaloClusterPtr, CompareTwoTracksVectors > &allPairs, reco::ConversionCollection &outputConvPhotonCollection)
Cos< T >::type cos(const T &t)
Conversion * clone() const
returns a clone of the candidate
Tan< T >::type tan(const T &t)
math::XYZPoint Point
point in the space
std::vector< reco::ConversionRef > solveAmbiguity(const edm::OrphanHandle< reco::ConversionCollection > &conversionHandle, reco::CaloClusterPtr const &sc)
double dRForConversionRecovery_
edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > transientTrackToken_
float calculateMinApproachDistance(const reco::TrackRef &track1, const reco::TrackRef &track2)
edm::EDGetTokenT< reco::TrackCollection > conversionOITrackProducer_
edm::EDGetTokenT< reco::TrackCaloClusterPtrAssociation > inOutTrackSCAssociationCollection_
std::vector< math::XYZPointF > find(const std::vector< reco::TransientTrack > &tracks, const edm::Handle< edm::View< reco::CaloCluster > > &bcHandle)
std::string likelihoodWeights_
bool getData(T &iHolder) const
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< float > > XYZVectorF
spatial vector with cartesian internal representation
ConversionLikelihoodCalculator likelihoodCalc_
double calculateLikelihood(reco::ConversionRef conversion)
edm::EDGetTokenT< edm::View< reco::CaloCluster > > bcBarrelCollection_
edm::EDGetTokenT< edm::View< reco::CaloCluster > > scHybridBarrelProducer_
OrphanHandle< PROD > emplace(EDPutTokenT< PROD > token, Args &&... args)
puts a new product
XYZVectorD XYZVector
spatial vector with cartesian internal representation
XYZPointD XYZPoint
point in space with cartesian internal representation
void produce(edm::Event &evt, const edm::EventSetup &es) override
ConversionVertexFinder vertexFinder_
void cleanCollections(const edm::Handle< edm::View< reco::CaloCluster >> &scHandle, const edm::OrphanHandle< reco::ConversionCollection > &conversionHandle, reco::ConversionCollection &outputCollection)
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
void setMVAout(const float &mva)
set the value of the TMVA output
ConvertedPhotonProducer(const edm::ParameterSet &ps)
ConversionTrackPairFinder trackPairFinder_
TransientTrackBuilder const * transientTrackBuilder_
void clear()
Clear the PtrVector.
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
EgammaHcalIsolation::arrayHB eThresHB
math::XYZPointF toFConverterP(const math::XYZPoint &val)
EgammaHcalIsolation::arrayHE eThresHE
Log< level::Warning, false > LogWarning
std::array< double, 4 > arrayHB
std::map< std::vector< reco::TransientTrack >, reco::CaloClusterPtr, CompareTwoTracksVectors > run(const std::vector< reco::TransientTrack > &outIn, const edm::Handle< reco::TrackCollection > &outInTrkHandle, const edm::Handle< reco::TrackCaloClusterPtrAssociation > &outInTrackSCAssH, const std::vector< reco::TransientTrack > &inOut, const edm::Handle< reco::TrackCollection > &inOutTrkHandle, const edm::Handle< reco::TrackCaloClusterPtrAssociation > &inOutTrackSCAssH)
math::XYZTLorentzVector LorentzVector
Lorentz vector.
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > mFToken_
bool isValid() const
Tells whether the vertex is valid.
bool recoverOneTrackCase_
std::array< double, 7 > arrayHE
void getCircleCenter(const reco::TrackRef &tk, double r, double &x0, double &y0)