18 #include <boost/foreach.hpp> 29 bool atLeastOneInCommon=
false;
33 atLeastOneInCommon=
true;
38 return atLeastOneInCommon;
41 bool lt_(std::pair<double,short>
a, std::pair<double,short>
b) {
42 return a.first < b.first; }
58 wantTkVtxCompatibility_ = ps.
getParameter<
bool>(
"wantTkVtxCompatibility");
59 sigmaTkVtxComp_ = ps.
getParameter<uint32_t>(
"sigmaTkVtxComp");
60 wantCompatibleInnerHits_ = ps.
getParameter<
bool>(
"wantCompatibleInnerHits");
61 TkMinNumOfDOF_ = ps.
getParameter<uint32_t>(
"TkMinNumOfDOF");
63 wantHighpurity_ = ps.
getParameter<
bool>(
"wantHighpurity");
64 _vertexChi2ProbCut = ps.
getParameter<
double>(
"vertexChi2ProbCut");
66 _minDistanceOfApproachMinCut = ps.
getParameter<
double>(
"minDistanceOfApproachMinCut");
67 _minDistanceOfApproachMaxCut = ps.
getParameter<
double>(
"minDistanceOfApproachMaxCut");
71 pi0OnlineSwitch_ = ps.
getParameter<
bool>(
"pi0OnlineSwitch");
72 pi0SmallWindow_ = ps.
getParameter<std::vector<double> >(
"pi0SmallWindow");
73 pi0LargeWindow_ = ps.
getParameter<std::vector<double> >(
"pi0LargeWindow");
76 convAlgo_ = StringToEnumValue<reco::Conversion::ConversionAlgorithm>(
algo);
78 std::vector<std::string> qual = ps.
getParameter<std::vector<std::string> >(
"convQuality");
79 if( !qual[0].
empty() ) convQuality_ =StringToEnumValue<reco::Conversion::ConversionQuality>(qual);
82 convSelection_ = std::make_unique<StringCutObjectSelector<reco::Conversion>>(convSelectionCuts_);
83 produces<pat::CompositeCandidateCollection>(
"conversions");
92 event.getByToken(thePVsToken_, priVtxs);
95 event.getByToken(convCollectionToken_,pConv);
98 event.getByToken(pfCandidateCollectionToken_,pfcandidates);
102 for(reco::ConversionCollection::const_iterator
conv = pConv->begin();
conv != pConv->end(); ++
conv){
104 if (! ( *convSelection_)(*conv)){
107 if (convAlgo_ != 0 &&
conv->algo()!= convAlgo_){
110 if(!convQuality_.empty()){
112 for (std::vector<int>::const_iterator
flag = convQuality_.begin();
flag!=convQuality_.end(); ++
flag){
114 if (!
conv->quality(q)) {
123 outCollection->push_back(*
conv);
126 removeDuplicates(*outCollection);
128 for (reco::ConversionCollection::const_iterator
conv = outCollection->begin();
conv != outCollection->end(); ++
conv){
138 bool flagTkVtxCompatibility =
true;
139 if (! checkTkVtxCompatibility(*
conv,*priVtxs.
product())) {
140 flagTkVtxCompatibility =
false;
141 if (wantTkVtxCompatibility_) {
145 bool flagCompatibleInnerHits =
false;
146 if (
conv->tracks().size()==2) {
149 if ( foundCompatibleInnerHits(hitPatA,hitPatB) && foundCompatibleInnerHits(hitPatB,hitPatA) ) flagCompatibleInnerHits =
true;
151 if (wantCompatibleInnerHits_ && ! flagCompatibleInnerHits) {
154 bool flagHighpurity =
true;
156 flagHighpurity =
false;
157 if (wantHighpurity_) {
161 bool pizero_rejected =
false;
162 bool large_pizero_window = CheckPi0(*
conv, pfphotons, pizero_rejected);
163 if (pi0OnlineSwitch_ && pizero_rejected) {
168 if (flag1 && flag2 && flag3 && flag4){
169 flags = PackFlags(*
conv,flagTkVtxCompatibility,flagCompatibleInnerHits,flagHighpurity,pizero_rejected,large_pizero_window);
170 std::unique_ptr<pat::CompositeCandidate> pat_conv(makePhotonCandidate(*
conv));
171 pat_conv->addUserInt(
"flags",flags);
172 patoutCollection->push_back(*pat_conv);
175 event.put(
std::move(patoutCollection),
"conversions");
179 bool flagCompatibleInnerHits,
bool flagHighpurity,
180 bool pizero_rejected,
bool large_pizero_window ) {
182 if ( flagTkVtxCompatibility ) flags += 1;
183 if ( flagCompatibleInnerHits ) flags += 2;
184 if ( flagHighpurity ) flags += 4;
185 if ( pizero_rejected ) flags += 8;
186 if ( large_pizero_window ) flags += 16;
188 flags += (conv.
algo()*32);
190 std::vector<std::string> s_quals;
191 s_quals.push_back(
"generalTracksOnly");
192 s_quals.push_back(
"arbitratedEcalSeeded");
193 s_quals.push_back(
"arbitratedMerged");
194 s_quals.push_back(
"arbitratedMergedEcalGeneral");
195 s_quals.push_back(
"highPurity");
196 s_quals.push_back(
"highEfficiency");
197 s_quals.push_back(
"ecalMatched1Track");
198 s_quals.push_back(
"ecalMatched2Track");
199 std::vector<int> i_quals = StringToEnumValue<reco::Conversion::ConversionQuality>(s_quals);
200 for (std::vector<int>::const_iterator qq = i_quals.begin(); qq!=i_quals.end(); ++qq) {
202 if (conv.
quality(q)) q_mask = *qq;
204 flags += (q_mask*32*8);
217 while(iter1 < (( (
int) c.size() ) - 1) ){
220 c.erase( c.begin() + iter2 );
230 std::vector< std::pair< double, short> >
idx[2];
241 if(fabs(dz_)/dzError_ > sigmaTkVtxComp_)
continue;
242 idx[ik].push_back(std::pair<double,short>(fabs(dz_),count));
244 if (idx[ik].
empty())
return false;
245 if (idx[ik].
size()>1) std::stable_sort(idx[ik].
begin(),idx[ik].
end(),
lt_);
247 if (ik!=1)
return false;
249 if (idx[0].
size()>1 && idx[0][1].second==idx[1][0].second)
return true;
250 if (idx[1].
size()>1 && idx[0][0].second==idx[1][1].second)
return true;
257 uint32_t oldSubStr=0;
258 for (
int i=0;
i<hitPatA.
numberOfAllHits(reco::HitPattern::HitCategory::TRACK_HITS) && count<2;
i++) {
259 uint32_t hitA = hitPatA.
getHitPattern(reco::HitPattern::HitCategory::TRACK_HITS,
i);
282 int closest_pv_index = 0;
319 for (reco::PFCandidateCollection::const_iterator
cand = pfcandidates.begin();
cand != pfcandidates.end(); ++
cand){
326 bool &pizero_rejected ) {
330 bool check_small =
false;
331 bool check_large =
false;
333 float small1 = pi0SmallWindow_[0];
334 float small2 = pi0SmallWindow_[1];
335 float large1 = pi0LargeWindow_[0];
336 float large2 = pi0LargeWindow_[1];
337 for (reco::PFCandidateCollection::const_iterator
photon = photons.begin();
photon!=photons.end(); ++
photon) {
339 if (inv > large1 && inv < large2) {
341 if (inv > small1 && inv < small2) {
347 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
double normalizedChi2() const
chi-squared divided by n.d.o.f. (or chi-squared * 1e6 if n.d.o.f. is zero)
static HepMC::IO_HEPEVT conv
double dxyError() const
error on dxy
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)
double covariance(int i, int j) const
(i, j)-th element of error matrix, i, j = 0, ... 2
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
double ndof() const
number of degrees of freedom of the fit
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)
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
double dzError() const
error on dz
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 &)
int charge() const
track electric charge
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 dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
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