27 bool atLeastOneInCommon =
false;
28 for (
auto const& tk1 : c1.
tracks()) {
29 for (
auto const& tk2 : c2.
tracks()) {
31 atLeastOneInCommon =
true;
36 return atLeastOneInCommon;
39 bool lt_(std::pair<double, short>
a, std::pair<double, short>
b) {
return a.first < b.first; }
71 convAlgo_ = StringToEnumValue<reco::Conversion::ConversionAlgorithm>(
algo);
73 std::vector<std::string> qual = ps.
getParameter<std::vector<std::string>>(
"convQuality");
75 convQuality_ = StringToEnumValue<reco::Conversion::ConversionQuality>(qual);
79 produces<pat::CompositeCandidateCollection>(
"conversions");
97 for (reco::ConversionCollection::const_iterator
conv = pConv->begin();
conv != pConv->end(); ++
conv) {
108 if (!
conv->quality(q)) {
117 outCollection->push_back(*
conv);
122 for (reco::ConversionCollection::const_iterator
conv = outCollection->begin();
conv != outCollection->end(); ++
conv) {
131 bool flagTkVtxCompatibility =
true;
133 flagTkVtxCompatibility =
false;
138 bool flagCompatibleInnerHits =
false;
139 if (
conv->tracks().size() == 2) {
143 flagCompatibleInnerHits =
true;
148 bool flagHighpurity =
true;
150 flagHighpurity =
false;
155 bool pizero_rejected =
false;
156 bool large_pizero_window =
CheckPi0(*
conv, pfphotons, pizero_rejected);
162 if (flag1 && flag2 && flag3 && flag4) {
164 *
conv, flagTkVtxCompatibility, flagCompatibleInnerHits, flagHighpurity, pizero_rejected, large_pizero_window);
166 pat_conv->addUserInt(
"flags", flags);
167 patoutCollection->push_back(*pat_conv);
170 event.put(
std::move(patoutCollection),
"conversions");
174 bool flagTkVtxCompatibility,
175 bool flagCompatibleInnerHits,
177 bool pizero_rejected,
178 bool large_pizero_window) {
180 if (flagTkVtxCompatibility)
182 if (flagCompatibleInnerHits)
188 if (large_pizero_window)
191 flags += (conv.
algo() * 32);
193 std::vector<std::string> s_quals;
194 s_quals.push_back(
"generalTracksOnly");
195 s_quals.push_back(
"arbitratedEcalSeeded");
196 s_quals.push_back(
"arbitratedMerged");
197 s_quals.push_back(
"arbitratedMergedEcalGeneral");
198 s_quals.push_back(
"highPurity");
199 s_quals.push_back(
"highEfficiency");
200 s_quals.push_back(
"ecalMatched1Track");
201 s_quals.push_back(
"ecalMatched2Track");
202 std::vector<int> i_quals = StringToEnumValue<reco::Conversion::ConversionQuality>(s_quals);
203 for (std::vector<int>::const_iterator qq = i_quals.begin(); qq != i_quals.end(); ++qq) {
208 flags += (q_mask * 32 * 8);
221 while (iter1 < (((
int)c.size()) - 1)) {
222 int iter2 = iter1 + 1;
223 while (iter2 < (
int)c.size())
225 c.erase(c.begin() + iter2);
236 std::vector<std::pair<double, short>> idx[2];
238 for (
auto const& tk : conv.
tracks()) {
241 for (
auto const& vtx : priVtxs) {
244 double dz_ = tk->dz(vtx.position());
245 double dzError_ = tk->dzError();
246 dzError_ =
sqrt(dzError_ * dzError_ + vtx.covariance(2, 2));
249 idx[ik].push_back(std::pair<double, short>(fabs(dz_), count));
253 if (idx[ik].
size() > 1)
254 std::stable_sort(idx[ik].
begin(), idx[ik].
end(),
lt_);
260 if (idx[0].
size() > 1 && idx[0][1].second == idx[1][0].second)
262 if (idx[1].
size() > 1 && idx[0][0].second == idx[1][1].second)
271 uint32_t oldSubStr = 0;
272 for (
int i = 0;
i < hitPatA.
numberOfAllHits(reco::HitPattern::HitCategory::TRACK_HITS) && count < 2;
i++) {
273 uint32_t hitA = hitPatA.
getHitPattern(reco::HitPattern::HitCategory::TRACK_HITS,
i);
299 int closest_pv_index = 0;
301 for (
auto const& vtx : priVtxs) {
304 closest_pv_index =
i;
308 for (
auto const& tk : conv.
tracks())
309 if (-tk->dxy(priVtxs[closest_pv_index].position()) * tk->charge() / tk->dxyError() < 0)
313 for (
auto const& tk : conv.
tracks())
318 for (
auto const& tk : conv.
tracks())
345 for (reco::PFCandidateCollection::const_iterator cand = pfcandidates.begin(); cand != pfcandidates.end(); ++cand) {
347 pfphotons.push_back(*cand);
354 bool& pizero_rejected) {
358 bool check_small =
false;
359 bool check_large =
false;
365 for (reco::PFCandidateCollection::const_iterator photon = photons.begin(); photon != photons.end(); ++photon) {
367 if (inv > large1 && inv < large2) {
369 if (inv > small1 && inv < small2) {
375 pizero_rejected = check_small;
const reco::Vertex & conversionVertex() const
returns the reco conversion vertex
Analysis-level particle class.
static uint32_t getLayer(uint16_t pattern)
bool foundCompatibleInnerHits(const reco::HitPattern &hitPatA, const reco::HitPattern &hitPatB)
const edm::EventSetup & c
ConversionAlgorithm algo() const
std::vector< int > convQuality_
bool quality(ConversionQuality q) const
#define DEFINE_FWK_MODULE(type)
reco::Candidate::LorentzVector convertVector(const math::XYZTLorentzVectorF &)
void endStream() override
std::string convSelectionCuts_
std::vector< double > pi0LargeWindow_
uint16_t getTrackerMonoStereo(HitCategory category, uint16_t substr, uint16_t layer) const
double zOfPrimaryVertexFromTracks(const math::XYZPoint &myBeamSpot=math::XYZPoint()) const
double distOfMinimumApproach() const
double _minDistanceOfApproachMinCut
bool HighpuritySubset(const reco::Conversion &, const reco::VertexCollection &)
std::vector< Vertex > VertexCollection
collection of Vertex objects
bool ConversionLessByChi2(const reco::Conversion &c1, const reco::Conversion &c2)
const Point & position() const
position
std::vector< Conversion > ConversionCollection
collectin of Conversion objects
std::unique_ptr< StringCutObjectSelector< reco::Conversion > > convSelection_
void setVertex(const Point &vertex) override
set vertex
std::vector< double > pi0SmallWindow_
static bool validHitFilter(uint16_t pattern)
U second(std::pair< T, U > const &p)
bool operator==(const reco::Conversion &c1, const reco::Conversion &c2)
bool ConversionEqualByTrack(const reco::Conversion &c1, const reco::Conversion &c2)
bool checkTkVtxCompatibility(const reco::Conversion &, const reco::VertexCollection &)
void produce(edm::Event &event, const edm::EventSetup &esetup) override
int numberOfAllHits(HitCategory category) const
int PackFlags(const reco::Conversion &, bool, bool, bool, bool, bool)
double chi2() const
chi-squares
edm::EDGetTokenT< reco::VertexCollection > thePVsToken_
float ChiSquaredProbability(double chiSquared, double nrDOF)
static uint32_t getSubStructure(uint16_t pattern)
const reco::PFCandidateCollection selectPFPhotons(const reco::PFCandidateCollection &)
OniaPhotonConversionProducer(const edm::ParameterSet &ps)
math::XYZTLorentzVectorF refittedPair4Momentum() const
Conversion track pair 4-momentum from the tracks refitted with vertex constraint. ...
bool lt_(std::pair< double, short > a, std::pair< double, short > b)
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
static bool trackerHitFilter(uint16_t pattern)
edm::EDGetTokenT< reco::ConversionCollection > convCollectionToken_
std::vector< CompositeCandidate > CompositeCandidateCollection
T const * product() const
edm::EDGetTokenT< reco::PFCandidateCollection > pfCandidateCollectionToken_
bool wantCompatibleInnerHits_
T getParameter(std::string const &) const
math::XYZTLorentzVector LorentzVector
Lorentz vector.
bool CheckPi0(const reco::Conversion &, const reco::PFCandidateCollection &, bool &)
pat::CompositeCandidate * makePhotonCandidate(const reco::Conversion &)
bool wantTkVtxCompatibility_
void removeDuplicates(reco::ConversionCollection &)
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< float > > XYZTLorentzVectorF
Lorentz vector with cylindrical internal representation using pseudorapidity.
uint16_t getHitPattern(HitCategory category, int position) const
double _vertexChi2ProbCut
void setP4(const LorentzVector &p4) final
set 4-momentum
tuple size
Write out results.
void addUserData(const std::string &label, const T &data, bool transientOnly=false, bool overwrite=false)
double _minDistanceOfApproachMaxCut
std::vector< edm::RefToBase< reco::Track > > const & tracks() const
vector of track to base references