124 conversionIOTrackProducer_{consumes(
config.getParameter<
std::string>(
"conversionIOTrackProducer"))},
125 outInTrackSCAssociationCollection_{consumes({
config.getParameter<
std::string>(
"conversionOITrackProducer"),
132 produces<reco::ConversionCollection>(
config.getParameter<
std::string>(
"convertedPhotonCollection"))},
134 produces<reco::ConversionCollection>(
config.getParameter<
std::string>(
"cleanedConvertedPhotonCollection"))},
142 mFToken_{esConsumes<MagneticField, IdealMagneticFieldRecord, edm::Transition::BeginRun>()},
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) {
391 edm::LogWarning(metname) <<
"cms::Exception caught in ConvertedPhotonProducer::produce\n"
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);
521 edm::LogWarning(metname) <<
"cms::Exception caught in ConvertedPhotonProducer::produce\n"
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_)
558 if (conversionHandle.
isValid()) {
560 std::vector<reco::ConversionRef> bestRef =
solveAmbiguity(conversionHandle, aClus);
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);
571 for (
unsigned int icp = 0; icp < conversionHandle->size(); icp++) {
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;
593 for (
unsigned int icp = 0; icp < conversionHandle->size(); icp++) {
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);
623 double x1, x2, y1, y2;
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();
633 return std::sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) - radius1 - radius2;
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_
bool isNonnull() const
Checks for non-null.
TransientVertex run(const std::vector< reco::TransientTrack > &pair)
double hcalESum(const reco::SuperCluster &, int depth) const
inOutTrackSCAssociationCollection_
edm::EDPutTokenT< reco::ConversionCollection > convertedPhotonCollectionPutToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
const std::string metname
virtual std::string explainSelf() const
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_
bool isValid() const
Tells whether the vertex is valid.
Sin< T >::type sin(const T &t)
Global3DPoint GlobalPoint
reco::TransientTrack build(const reco::Track *p) const
edm::EDGetTokenT< edm::View< reco::CaloCluster > > scIslandEndcapProducer_
static ConversionAlgorithm algoByName(const std::string &name)
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeomToken_
cleanedConvertedPhotonCollectionPutToken_
std::unique_ptr< ElectronHcalHelper > hcalHelper_
edm::Ptr< CaloCluster > CaloClusterPtr
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
key_type key() const
Accessor for product key.
edm::EDGetTokenT< HBHERecHitCollection > hbheRecHits_
Log< level::Error, false > LogError
MagneticField const * magneticField_
edm::EDGetTokenT< HBHERecHitCollection > hbheRecHits
std::vector< Conversion > ConversionCollection
collectin of Conversion objects
ProductID id() const
Accessor for product ID.
double minApproachDisCut_
void beginRun(edm::Run const &, const edm::EventSetup &es) final
edm::EDGetTokenT< reco::TrackCollection > generalTrackProducer_
bool getData(T &iHolder) const
math::XYZVectorF toFConverterV(const math::XYZVector &val)
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
convertedPhotonCollectionPutToken_
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)
Tan< T >::type tan(const T &t)
math::XYZPoint Point
point in the space
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_
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< float > > XYZVectorF
spatial vector with cartesian internal representation
ConversionLikelihoodCalculator likelihoodCalc_
Conversion * clone() const
returns a clone of the candidate
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_
T getParameter(std::string const &) const
std::vector< reco::ConversionRef > solveAmbiguity(const edm::OrphanHandle< reco::ConversionCollection > &conversionHandle, reco::CaloClusterPtr const &sc)
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
ProductID id() const
Accessor for product ID.
ConvertedPhotonProducer(const edm::ParameterSet &ps)
ConversionTrackPairFinder trackPairFinder_
TransientTrackBuilder const * transientTrackBuilder_
tuple config
parse the configuration file
void clear()
Clear the PtrVector.
std::string fullPath() const
EgammaHcalIsolation::arrayHB eThresHB
math::XYZPointF toFConverterP(const math::XYZPoint &val)
EgammaHcalIsolation::arrayHE eThresHE
Log< level::Warning, false > LogWarning
std::vector< reco::CaloClusterPtr > matchingBC() const
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 recoverOneTrackCase_
std::array< double, 7 > arrayHE
void getCircleCenter(const reco::TrackRef &tk, double r, double &x0, double &y0)