28 bool atLeastOneInCommon=
false;
29 for(
auto const& tk1 : c1.
tracks()){
30 for(
auto const& tk2 : c2.
tracks()){
32 atLeastOneInCommon=
true;
37 return atLeastOneInCommon;
40 bool lt_(std::pair<double,short>
a, std::pair<double,short>
b) {
41 return a.first < b.first; }
57 wantTkVtxCompatibility_ = ps.
getParameter<
bool>(
"wantTkVtxCompatibility");
58 sigmaTkVtxComp_ = ps.
getParameter<uint32_t>(
"sigmaTkVtxComp");
59 wantCompatibleInnerHits_ = ps.
getParameter<
bool>(
"wantCompatibleInnerHits");
60 TkMinNumOfDOF_ = ps.
getParameter<uint32_t>(
"TkMinNumOfDOF");
62 wantHighpurity_ = ps.
getParameter<
bool>(
"wantHighpurity");
63 _vertexChi2ProbCut = ps.
getParameter<
double>(
"vertexChi2ProbCut");
65 _minDistanceOfApproachMinCut = ps.
getParameter<
double>(
"minDistanceOfApproachMinCut");
66 _minDistanceOfApproachMaxCut = ps.
getParameter<
double>(
"minDistanceOfApproachMaxCut");
70 pi0OnlineSwitch_ = ps.
getParameter<
bool>(
"pi0OnlineSwitch");
71 pi0SmallWindow_ = ps.
getParameter<std::vector<double> >(
"pi0SmallWindow");
72 pi0LargeWindow_ = ps.
getParameter<std::vector<double> >(
"pi0LargeWindow");
75 convAlgo_ = StringToEnumValue<reco::Conversion::ConversionAlgorithm>(
algo);
77 std::vector<std::string> qual = ps.
getParameter<std::vector<std::string> >(
"convQuality");
78 if( !qual[0].
empty() ) convQuality_ =StringToEnumValue<reco::Conversion::ConversionQuality>(qual);
81 convSelection_ = std::make_unique<StringCutObjectSelector<reco::Conversion>>(convSelectionCuts_);
82 produces<pat::CompositeCandidateCollection>(
"conversions");
91 event.getByToken(thePVsToken_, priVtxs);
94 event.getByToken(convCollectionToken_,pConv);
97 event.getByToken(pfCandidateCollectionToken_,pfcandidates);
101 for(reco::ConversionCollection::const_iterator
conv = pConv->begin();
conv != pConv->end(); ++
conv){
103 if (! ( *convSelection_)(*conv)){
106 if (convAlgo_ != 0 &&
conv->algo()!= convAlgo_){
109 if(!convQuality_.empty()){
111 for (std::vector<int>::const_iterator
flag = convQuality_.begin();
flag!=convQuality_.end(); ++
flag){
113 if (!
conv->quality(q)) {
122 outCollection->push_back(*
conv);
125 removeDuplicates(*outCollection);
127 for (reco::ConversionCollection::const_iterator
conv = outCollection->begin();
conv != outCollection->end(); ++
conv){
137 bool flagTkVtxCompatibility =
true;
138 if (! checkTkVtxCompatibility(*
conv,*priVtxs.
product())) {
139 flagTkVtxCompatibility =
false;
140 if (wantTkVtxCompatibility_) {
144 bool flagCompatibleInnerHits =
false;
145 if (
conv->tracks().size()==2) {
148 if ( foundCompatibleInnerHits(hitPatA,hitPatB) && foundCompatibleInnerHits(hitPatB,hitPatA) ) flagCompatibleInnerHits =
true;
150 if (wantCompatibleInnerHits_ && ! flagCompatibleInnerHits) {
153 bool flagHighpurity =
true;
155 flagHighpurity =
false;
156 if (wantHighpurity_) {
160 bool pizero_rejected =
false;
161 bool large_pizero_window = CheckPi0(*
conv, pfphotons, pizero_rejected);
162 if (pi0OnlineSwitch_ && pizero_rejected) {
167 if (flag1 && flag2 && flag3 && flag4){
168 flags = PackFlags(*
conv,flagTkVtxCompatibility,flagCompatibleInnerHits,flagHighpurity,pizero_rejected,large_pizero_window);
169 std::unique_ptr<pat::CompositeCandidate> pat_conv(makePhotonCandidate(*
conv));
170 pat_conv->addUserInt(
"flags",flags);
171 patoutCollection->push_back(*pat_conv);
174 event.put(
std::move(patoutCollection),
"conversions");
178 bool flagCompatibleInnerHits,
bool flagHighpurity,
179 bool pizero_rejected,
bool large_pizero_window ) {
181 if ( flagTkVtxCompatibility ) flags += 1;
182 if ( flagCompatibleInnerHits ) flags += 2;
183 if ( flagHighpurity ) flags += 4;
184 if ( pizero_rejected ) flags += 8;
185 if ( large_pizero_window ) flags += 16;
187 flags += (conv.
algo()*32);
189 std::vector<std::string> s_quals;
190 s_quals.push_back(
"generalTracksOnly");
191 s_quals.push_back(
"arbitratedEcalSeeded");
192 s_quals.push_back(
"arbitratedMerged");
193 s_quals.push_back(
"arbitratedMergedEcalGeneral");
194 s_quals.push_back(
"highPurity");
195 s_quals.push_back(
"highEfficiency");
196 s_quals.push_back(
"ecalMatched1Track");
197 s_quals.push_back(
"ecalMatched2Track");
198 std::vector<int> i_quals = StringToEnumValue<reco::Conversion::ConversionQuality>(s_quals);
199 for (std::vector<int>::const_iterator qq = i_quals.begin(); qq!=i_quals.end(); ++qq) {
201 if (conv.
quality(q)) q_mask = *qq;
203 flags += (q_mask*32*8);
216 while(iter1 < (( (
int) c.size() ) - 1) ){
219 c.erase( c.begin() + iter2 );
229 std::vector< std::pair< double, short> >
idx[2];
231 for(
auto const& tk : conv.
tracks()){
234 for(
auto const&
vtx : priVtxs){
237 double dz_= tk->dz(
vtx.position());
238 double dzError_=tk->dzError();
239 dzError_=
sqrt(dzError_*dzError_+
vtx.covariance(2,2));
240 if(fabs(dz_)/dzError_ > sigmaTkVtxComp_)
continue;
241 idx[ik].push_back(std::pair<double,short>(fabs(dz_),count));
243 if (idx[ik].
empty())
return false;
244 if (idx[ik].
size()>1) std::stable_sort(idx[ik].
begin(),idx[ik].
end(),
lt_);
246 if (ik!=1)
return false;
248 if (idx[0].
size()>1 && idx[0][1].second==idx[1][0].second)
return true;
249 if (idx[1].
size()>1 && idx[0][0].second==idx[1][1].second)
return true;
256 uint32_t oldSubStr=0;
257 for (
int i=0;
i<hitPatA.
numberOfAllHits(reco::HitPattern::HitCategory::TRACK_HITS) && count<2;
i++) {
258 uint32_t hitA = hitPatA.
getHitPattern(reco::HitPattern::HitCategory::TRACK_HITS,
i);
281 int closest_pv_index = 0;
283 for(
auto const&
vtx : priVtxs){
288 for(
auto const& tk : conv.
tracks())
if(-tk->dxy(priVtxs[closest_pv_index].position())*tk->charge()/tk->dxyError()<0)
return false;
291 for(
auto const& tk : conv.
tracks())
if(tk->normalizedChi2() > _trackchi2Cut)
return false;
294 for(
auto const& tk : conv.
tracks())
if(tk->ndof()< TkMinNumOfDOF_)
return false;
318 for (reco::PFCandidateCollection::const_iterator
cand = pfcandidates.begin();
cand != pfcandidates.end(); ++
cand){
325 bool &pizero_rejected ) {
329 bool check_small =
false;
330 bool check_large =
false;
332 float small1 = pi0SmallWindow_[0];
333 float small2 = pi0SmallWindow_[1];
334 float large1 = pi0LargeWindow_[0];
335 float large2 = pi0LargeWindow_[1];
336 for (reco::PFCandidateCollection::const_iterator
photon = photons.begin();
photon!=photons.end(); ++
photon) {
338 if (inv > large1 && inv < large2) {
340 if (inv > small1 && inv < small2) {
346 pizero_rejected = check_small;
const reco::Vertex & conversionVertex() const
returns the reco conversion vertex
Analysis-level particle class.
T getParameter(std::string const &) const
static uint32_t getLayer(uint16_t pattern)
bool foundCompatibleInnerHits(const reco::HitPattern &hitPatA, const reco::HitPattern &hitPatB)
ConversionAlgorithm algo() const
static HepMC::IO_HEPEVT conv
bool quality(ConversionQuality q) const
#define DEFINE_FWK_MODULE(type)
reco::Candidate::LorentzVector convertVector(const math::XYZTLorentzVectorF &)
void endStream() override
uint16_t getTrackerMonoStereo(HitCategory category, uint16_t substr, uint16_t layer) const
double zOfPrimaryVertexFromTracks(const math::XYZPoint &myBeamSpot=math::XYZPoint()) const
double distOfMinimumApproach() const
bool HighpuritySubset(const reco::Conversion &, const reco::VertexCollection &)
std::vector< Variable::Flags > flags
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
void setVertex(const Point &vertex) override
set vertex
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
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)
std::vector< CompositeCandidate > CompositeCandidateCollection
T const * product() const
math::XYZTLorentzVector LorentzVector
Lorentz vector.
bool CheckPi0(const reco::Conversion &, const reco::PFCandidateCollection &, bool &)
pat::CompositeCandidate * makePhotonCandidate(const reco::Conversion &)
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
void setP4(const LorentzVector &p4) final
set 4-momentum
void addUserData(const std::string &label, const T &data, bool transientOnly=false, bool overwrite=false)
std::vector< edm::RefToBase< reco::Track > > const & tracks() const
vector of track to base references