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;
338 for (
auto const& aClus : scHandle->ptrs()) {
340 if (aClus->energy() / cosh(aClus->eta()) <=
minSCEt_)
344 double HoE = hcalHelper.
hcalESum(*sc, 0) / sc->energy();
349 std::vector<edm::Ref<reco::TrackCollection>> trackPairRef;
350 std::vector<math::XYZPointF> trackInnPos;
351 std::vector<math::XYZVectorF> trackPin;
352 std::vector<math::XYZVectorF> trackPout;
353 float minAppDist = -99;
364 if (!allPairs.empty()) {
365 for (
auto iPair = allPairs.begin(); iPair != allPairs.end(); ++iPair) {
370 if (!(aClus == caloPtr))
375 std::vector<math::XYZPointF> trkPositionAtEcal = theEcalImpactPositionFinder.
find(iPair->first, bcHandle);
376 std::vector<reco::CaloClusterPtr> matchingBC = theEcalImpactPositionFinder.
matchingBC();
380 if ((iPair->first).size() > 1) {
403 trackPairRef.clear();
408 for (std::vector<reco::TransientTrack>::const_iterator iTk = (iPair->first).begin();
409 iTk != (iPair->first).
end();
418 trackInnPos.push_back(
toFConverterP(myTkRef->innerPosition()));
420 trackPout.push_back(
toFConverterV(myTkRef->outerMomentum()));
422 trackPairRef.push_back(myTkRef);
429 if (theConversionVertex.
isValid()) {
451 outputConvPhotonCollection.push_back(newCandidate);
459 trackPairRef.clear();
463 std::vector<reco::TransientTrack>::const_iterator iTk = (iPair->first).begin();
472 trackPairRef.push_back(myTk);
476 float theta1 = myTk->innerMomentum().Theta();
478 float dCotTheta = -999.;
480 for (
auto const& tran : t_generalTrk) {
483 if (trRef->charge() * myTk->charge() > 0)
485 float dEta = trRef->eta() - myTk->eta();
486 float dPhi = trRef->phi() - myTk->phi();
489 float theta2 = trRef->innerMomentum().Theta();
490 dCotTheta = 1. /
tan(theta1) - 1. /
tan(theta2);
492 if (fabs(dCotTheta) < dCot) {
493 dCot = fabs(dCotTheta);
503 trackInnPos.push_back(
toFConverterP(goodRef->innerPosition()));
505 trackPout.push_back(
toFConverterV(goodRef->outerMomentum()));
506 trackPairRef.push_back(goodRef);
522 const double like = -999.;
523 outputConvPhotonCollection.emplace_back(scPtrVec,
534 auto& newCandidate = outputConvPhotonCollection.back();
547 for (
auto const& aClus : scHandle->ptrs()) {
549 if (aClus->energy() / cosh(aClus->eta()) <=
minSCEt_)
556 for (std::vector<reco::ConversionRef>::iterator iRef = bestRef.begin(); iRef != bestRef.end(); iRef++) {
557 if (iRef->isNonnull()) {
558 newCandidate = (*iRef)->
clone();
559 outputConversionCollection.push_back(*newCandidate);
567 if (!(aClus.id() == cpRef->caloCluster()[0].
id() && aClus.key() == cpRef->caloCluster()[0].
key()))
569 if (!cpRef->isConverted())
571 if (cpRef->nTracks() < 2)
573 newCandidate = (&(*cpRef))->
clone();
574 outputConversionCollection.push_back(*newCandidate);
585 std::multimap<double, reco::ConversionRef, std::greater<double>> convMap;
591 if (!(scRef.
id() == cpRef->caloCluster()[0].
id() && scRef.
key() == cpRef->caloCluster()[0].key()))
593 if (!cpRef->isConverted())
595 double like = cpRef->MVAout();
596 if (cpRef->nTracks() < 2)
599 convMap.emplace(like, cpRef);
604 std::vector<reco::ConversionRef> bestRefs;
605 for (
auto iMap = convMap.begin(); iMap != convMap.end(); iMap++) {
607 bestRefs.push_back(iMap->second);
618 double xx_1 = track1->innerPosition().x(), yy_1 = track1->innerPosition().y(), zz_1 = track1->innerPosition().z();
619 double xx_2 = track2->innerPosition().x(), yy_2 = track2->innerPosition().y(), zz_2 = track2->innerPosition().z();
632 x1 = tk->innerPosition().x();
633 y1 = tk->innerPosition().y();
634 phi = tk->innerMomentum().phi();
635 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.
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
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.
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_
#define DEFINE_FWK_MODULE(type)
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_
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)