CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
OniaPhotonConversionProducer Class Reference

#include <OniaPhotonConversionProducer.h>

Inheritance diagram for OniaPhotonConversionProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 OniaPhotonConversionProducer (const edm::ParameterSet &ps)
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

bool CheckPi0 (const reco::Conversion &, const reco::PFCandidateCollection &, bool &)
 
bool checkTkVtxCompatibility (const reco::Conversion &, const reco::VertexCollection &)
 
reco::Candidate::LorentzVector convertVector (const math::XYZTLorentzVectorF &)
 
virtual void endJob ()
 
bool foundCompatibleInnerHits (const reco::HitPattern &hitPatA, const reco::HitPattern &hitPatB)
 
bool HighpuritySubset (const reco::Conversion &, const reco::VertexCollection &)
 
pat::CompositeCandidatemakePhotonCandidate (const reco::Conversion &)
 
int PackFlags (const reco::Conversion &, bool, bool, bool, bool, bool)
 
virtual void produce (edm::Event &event, const edm::EventSetup &esetup)
 
void removeDuplicates (reco::ConversionCollection &, std::vector< int > &)
 
const reco::PFCandidateCollection selectPFPhotons (const reco::PFCandidateCollection &)
 

Private Attributes

double _minDistanceOfApproachMaxCut
 
double _minDistanceOfApproachMinCut
 
double _trackchi2Cut
 
double _vertexChi2ProbCut
 
int algo_fail
 
int CInnerHits
 
int convAlgo_
 
edm::EDGetTokenT
< reco::ConversionCollection
convCollectionToken_
 
std::vector< int > convQuality_
 
std::string convSelectionCuts_
 
int duplicates
 
int final_conversion
 
int flag_fail
 
int highpurity_count
 
edm::EDGetTokenT
< reco::PFCandidateCollection
pfCandidateCollectionToken_
 
std::vector< double > pi0LargeWindow_
 
bool pi0OnlineSwitch_
 
std::vector< double > pi0SmallWindow_
 
int pizero_fail
 
int selection_fail
 
uint32_t sigmaTkVtxComp_
 
int store_conversion
 
edm::EDGetTokenT
< reco::VertexCollection
thePVsToken_
 
uint32_t TkMinNumOfDOF_
 
int TkVtxC
 
int total_conversions
 
bool wantCompatibleInnerHits_
 
bool wantHighpurity_
 
bool wantTkVtxCompatibility_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Select photon conversions and produce a conversion candidate collection

Definition at line 36 of file OniaPhotonConversionProducer.h.

Constructor & Destructor Documentation

OniaPhotonConversionProducer::OniaPhotonConversionProducer ( const edm::ParameterSet ps)
explicit

Definition at line 55 of file OniaPhotonConversionProducer.cc.

References _minDistanceOfApproachMaxCut, _minDistanceOfApproachMinCut, _trackchi2Cut, _vertexChi2ProbCut, ecalcalib_dqm_sourceclient-live_cfg::algo, algo_fail, CInnerHits, convAlgo_, convCollectionToken_, convQuality_, convSelectionCuts_, duplicates, final_conversion, flag_fail, edm::ParameterSet::getParameter(), highpurity_count, pfCandidateCollectionToken_, pi0LargeWindow_, pi0OnlineSwitch_, pi0SmallWindow_, pizero_fail, selection_fail, sigmaTkVtxComp_, store_conversion, AlCaHLTBitMon_QueryRunRegistry::string, thePVsToken_, TkMinNumOfDOF_, TkVtxC, total_conversions, wantCompatibleInnerHits_, wantHighpurity_, and wantTkVtxCompatibility_.

55  {
56  convCollectionToken_ = consumes<reco::ConversionCollection>(ps.getParameter<edm::InputTag>("conversions"));
57  thePVsToken_ = consumes<reco::VertexCollection>(ps.getParameter<edm::InputTag>("primaryVertexTag"));
58 
59  wantTkVtxCompatibility_ = ps.getParameter<bool>("wantTkVtxCompatibility");
60  sigmaTkVtxComp_ = ps.getParameter<uint32_t>("sigmaTkVtxComp");
61  wantCompatibleInnerHits_ = ps.getParameter<bool>("wantCompatibleInnerHits");
62  TkMinNumOfDOF_ = ps.getParameter<uint32_t>("TkMinNumOfDOF");
63 
64  wantHighpurity_ = ps.getParameter<bool>("wantHighpurity");
65  _vertexChi2ProbCut = ps.getParameter<double>("vertexChi2ProbCut");
66  _trackchi2Cut = ps.getParameter<double>("trackchi2Cut");
67  _minDistanceOfApproachMinCut = ps.getParameter<double>("minDistanceOfApproachMinCut");
68  _minDistanceOfApproachMaxCut = ps.getParameter<double>("minDistanceOfApproachMaxCut");
69 
70  pfCandidateCollectionToken_ = consumes<reco::PFCandidateCollection>(ps.getParameter<edm::InputTag>("pfcandidates"));
71 
72  pi0OnlineSwitch_ = ps.getParameter<bool>("pi0OnlineSwitch");
73  pi0SmallWindow_ = ps.getParameter<std::vector<double> >("pi0SmallWindow");
74  pi0LargeWindow_ = ps.getParameter<std::vector<double> >("pi0LargeWindow");
75 
76  std::string algo = ps.getParameter<std::string>("convAlgo");
77  convAlgo_ = StringToEnumValue<reco::Conversion::ConversionAlgorithm>(algo);
78 
79  std::vector<std::string> qual = ps.getParameter<std::vector<std::string> >("convQuality");
80  if( qual[0] != "" ) convQuality_ =StringToEnumValue<reco::Conversion::ConversionQuality>(qual);
81 
82  convSelectionCuts_ = ps.getParameter<std::string>("convSelection");
83 
84  produces<pat::CompositeCandidateCollection>("conversions");
85 
87  selection_fail = 0;
88  algo_fail = 0;
89  flag_fail = 0;
90  pizero_fail = 0;
91  duplicates = 0;
92  TkVtxC = 0;
93  CInnerHits = 0;
94  highpurity_count = 0;
95  final_conversion = 0;
96  store_conversion = 0;
97 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::VertexCollection > thePVsToken_
edm::EDGetTokenT< reco::ConversionCollection > convCollectionToken_
edm::EDGetTokenT< reco::PFCandidateCollection > pfCandidateCollectionToken_

Member Function Documentation

bool OniaPhotonConversionProducer::CheckPi0 ( const reco::Conversion conv,
const reco::PFCandidateCollection photons,
bool &  pizero_rejected 
)
private

Definition at line 356 of file OniaPhotonConversionProducer.cc.

References python.tagInventory::inv, pi0LargeWindow_, pi0SmallWindow_, and reco::Conversion::refittedPair4Momentum().

Referenced by produce().

357  {
358  // 2 windows are defined for Pi0 rejection, Conversions that, paired with others photons from the event, have an
359  // invariant mass inside the "small" window will be pizero_rejected and those that falls in the large window will
360  // be CheckPi0.
361  bool check_small = false;
362  bool check_large = false;
363 
364  float small1 = pi0SmallWindow_[0];
365  float small2 = pi0SmallWindow_[1];
366  float large1 = pi0LargeWindow_[0];
367  float large2 = pi0LargeWindow_[1];
368  for (reco::PFCandidateCollection::const_iterator photon = photons.begin(); photon!=photons.end(); ++photon) {
369  float inv = (conv.refittedPair4Momentum() + photon->p4()).M();
370  if (inv > large1 && inv < large2) {
371  check_large = true;
372  if (inv > small1 && inv < small2) {
373  check_small = true;
374  break;
375  }
376  }
377  }
378  pizero_rejected = check_small;
379  return check_large;
380 }
math::XYZTLorentzVectorF refittedPair4Momentum() const
Conversion track pair 4-momentum from the tracks refitted with vertex constraint. ...
Definition: Conversion.cc:235
bool OniaPhotonConversionProducer::checkTkVtxCompatibility ( const reco::Conversion conv,
const reco::VertexCollection priVtxs 
)
private

Definition at line 261 of file OniaPhotonConversionProducer.cc.

References begin, prof2calltree::count, reco::Vertex::covariance(), reco::TrackBase::dz(), reco::TrackBase::dzError(), end, customizeTrackingMonitorSeedNumber::idx, lt_(), reco::Vertex::position(), edm::second(), sigmaTkVtxComp_, findQualityFiles::size, mathSSE::sqrt(), and reco::Conversion::tracks().

Referenced by produce().

261  {
262  std::vector< std::pair< double, short> > idx[2];
263  short ik=-1;
264  BOOST_FOREACH(edm::RefToBase<reco::Track> tk, conv.tracks()){
265  ik++;
266  short count=-1;
267  BOOST_FOREACH(const reco::Vertex& vtx,priVtxs){
268  count++;
269 
270  double dz_= tk->dz(vtx.position());
271  double dzError_=tk->dzError();
272  dzError_=sqrt(dzError_*dzError_+vtx.covariance(2,2));
273 
274  if(fabs(dz_)/dzError_ > sigmaTkVtxComp_) continue;
275 
276  idx[ik].push_back(std::pair<double,short>(fabs(dz_),count));
277  }
278  if(idx[ik].size()==0) {return false;}
279 
280  std::stable_sort(idx[ik].begin(),idx[ik].end(),lt_);
281  }
282  if (idx[0][0].second==idx[1][0].second || idx[0][1].second==idx[1][0].second || idx[0][0].second==idx[1][1].second) return true;
283  return false;
284 }
double covariance(int i, int j) const
(i, j)-th element of error matrix, i, j = 0, ... 2
Definition: Vertex.h:123
const Point & position() const
position
Definition: Vertex.h:106
U second(std::pair< T, U > const &p)
T sqrt(T t)
Definition: SSEVec.h:48
#define end
Definition: vmac.h:37
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...
Definition: TrackBase.h:596
double dzError() const
error on dz
Definition: TrackBase.h:801
bool lt_(std::pair< double, short > a, std::pair< double, short > b)
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
#define begin
Definition: vmac.h:30
tuple size
Write out results.
std::vector< edm::RefToBase< reco::Track > > const & tracks() const
vector of track to base references
Definition: Conversion.cc:176
reco::Candidate::LorentzVector OniaPhotonConversionProducer::convertVector ( const math::XYZTLorentzVectorF v)
private

Definition at line 382 of file OniaPhotonConversionProducer.cc.

Referenced by makePhotonCandidate().

382  {
383  return reco::Candidate::LorentzVector(v.x(),v.y(), v.z(), v.t());
384 }
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
void OniaPhotonConversionProducer::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 387 of file OniaPhotonConversionProducer.cc.

References algo_fail, CInnerHits, gather_cfg::cout, duplicates, final_conversion, flag_fail, highpurity_count, pizero_fail, selection_fail, store_conversion, TkVtxC, and total_conversions.

387  {
388  std::cout << "############################" << std::endl;
389  std::cout << "Conversion Candidate producer report" << std::endl;
390  std::cout << "############################" << std::endl;
391  std::cout << "Total examined conversions: " << total_conversions << std::endl;
392  std::cout << "Selection fail candidates: " << selection_fail << std::endl;
393  std::cout << "Algo fail candidates: " << algo_fail << std::endl;
394  std::cout << "Quality fail candidates: " << flag_fail << std::endl;
395  std::cout << "Pi0 fail: " << pizero_fail << std::endl;
396  std::cout << "Total duplicates found: " << duplicates << std::endl;
397  std::cout << "Vertex compatibility fail: " << TkVtxC << std::endl;
398  std::cout << "Compatible inner hits fail: " << CInnerHits << std::endl;
399  std::cout << "Highpurity Subset fail: " << highpurity_count << std::endl;
400  std::cout << "############################" << std::endl;
401  std::cout << "Final number of conversions: " << final_conversion << std::endl;
402  std::cout << "Stored number of conversions: " << store_conversion << std::endl;
403  std::cout << "############################" << std::endl;
404 }
tuple cout
Definition: gather_cfg.py:121
bool OniaPhotonConversionProducer::foundCompatibleInnerHits ( const reco::HitPattern hitPatA,
const reco::HitPattern hitPatB 
)
private

Definition at line 286 of file OniaPhotonConversionProducer.cc.

References prof2calltree::count, reco::HitPattern::getHitPattern(), reco::HitPattern::getLayer(), reco::HitPattern::getSubStructure(), reco::HitPattern::getTrackerMonoStereo(), i, reco::HitPattern::numberOfHits(), reco::HitPattern::trackerHitFilter(), and reco::HitPattern::validHitFilter().

Referenced by produce().

286  {
287  size_t count=0;
288  uint32_t oldSubStr=0;
289  for (int i=0; i<hitPatA.numberOfHits(reco::HitPattern::HitCategory::TRACK_HITS) && count<2; i++) {
290  uint32_t hitA = hitPatA.getHitPattern(reco::HitPattern::HitCategory::TRACK_HITS,i);
291  if (!hitPatA.validHitFilter(hitA) || !hitPatA.trackerHitFilter(hitA)) continue;
292 
293  if(hitPatA.getSubStructure(hitA)==oldSubStr && hitPatA.getLayer(hitA)==oldSubStr)
294  continue;
295 
296  if(hitPatB.getTrackerMonoStereo(reco::HitPattern::HitCategory::TRACK_HITS,hitPatA.getSubStructure(hitA),hitPatA.getLayer(hitA)) != 0)
297  return true;
298 
299  oldSubStr=hitPatA.getSubStructure(hitA);
300  count++;
301  }
302  return false;
303 }
int i
Definition: DBlmapReader.cc:9
static uint32_t getLayer(uint16_t pattern)
Definition: HitPattern.h:680
uint16_t getTrackerMonoStereo(HitCategory category, uint16_t substr, uint16_t layer) const
Definition: HitPattern.cc:458
static bool validHitFilter(uint16_t pattern)
Definition: HitPattern.h:765
static uint32_t getSubStructure(uint16_t pattern)
Definition: HitPattern.h:671
static bool trackerHitFilter(uint16_t pattern)
Definition: HitPattern.h:657
uint16_t getHitPattern(HitCategory category, int position) const
Definition: HitPattern.h:502
int numberOfHits(HitCategory category) const
Definition: HitPattern.h:785
bool OniaPhotonConversionProducer::HighpuritySubset ( const reco::Conversion conv,
const reco::VertexCollection priVtxs 
)
private

Definition at line 306 of file OniaPhotonConversionProducer.cc.

References _minDistanceOfApproachMaxCut, _minDistanceOfApproachMinCut, _trackchi2Cut, _vertexChi2ProbCut, reco::TrackBase::charge(), reco::Vertex::chi2(), ChiSquaredProbability(), reco::Conversion::conversionVertex(), reco::Conversion::distOfMinimumApproach(), reco::TrackBase::dxy(), reco::TrackBase::dxyError(), i, reco::Vertex::ndof(), reco::TrackBase::ndof(), reco::TrackBase::normalizedChi2(), reco::Vertex::position(), TkMinNumOfDOF_, reco::Conversion::tracks(), and reco::Conversion::zOfPrimaryVertexFromTracks().

Referenced by produce().

306  {
307  // select high purity conversions our way:
308  // vertex chi2 cut
310 
311  // d0 cut
312  // Find closest primary vertex
313  int closest_pv_index = 0;
314  int i=0;
315  BOOST_FOREACH(const reco::Vertex& vtx,priVtxs){
316  if( conv.zOfPrimaryVertexFromTracks( vtx.position() ) < conv.zOfPrimaryVertexFromTracks( priVtxs[closest_pv_index].position() ) ) closest_pv_index = i;
317  i++;
318  }
319  // Now check impact parameter wtr with the just found closest primary vertex
320  BOOST_FOREACH(const edm::RefToBase<reco::Track> tk, conv.tracks()) if(-tk->dxy(priVtxs[closest_pv_index].position())*tk->charge()/tk->dxyError()<0) return false;
321 
322  // chi2 of single tracks
323  BOOST_FOREACH(const edm::RefToBase<reco::Track> tk, conv.tracks()) if(tk->normalizedChi2() > _trackchi2Cut) return false;
324 
325  // dof for each track
326  BOOST_FOREACH(const edm::RefToBase<reco::Track> tk, conv.tracks()) if(tk->ndof()< TkMinNumOfDOF_) return false;
327 
328  // distance of approach cut
330 
331  return true;
332 }
const reco::Vertex & conversionVertex() const
returns the reco conversion vertex
Definition: Conversion.h:97
int i
Definition: DBlmapReader.cc:9
double normalizedChi2() const
chi-squared divided by n.d.o.f. (or chi-squared * 1e6 if n.d.o.f. is zero)
Definition: TrackBase.h:548
double dxyError() const
error on dxy
Definition: TrackBase.h:783
double zOfPrimaryVertexFromTracks(const math::XYZPoint &myBeamSpot=math::XYZPoint()) const
Definition: Conversion.h:145
double distOfMinimumApproach() const
Definition: Conversion.h:125
const Point & position() const
position
Definition: Vertex.h:106
double ndof() const
number of degrees of freedom of the fit
Definition: TrackBase.h:542
double chi2() const
chi-squares
Definition: Vertex.h:95
float ChiSquaredProbability(double chiSquared, double nrDOF)
double ndof() const
Definition: Vertex.h:102
int charge() const
track electric charge
Definition: TrackBase.h:554
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
Definition: TrackBase.h:578
std::vector< edm::RefToBase< reco::Track > > const & tracks() const
vector of track to base references
Definition: Conversion.cc:176
pat::CompositeCandidate * OniaPhotonConversionProducer::makePhotonCandidate ( const reco::Conversion conv)
private

Definition at line 334 of file OniaPhotonConversionProducer.cc.

References pat::PATObject< ObjectType >::addUserData(), reco::Conversion::conversionVertex(), convertVector(), reco::Vertex::position(), reco::Conversion::refittedPair4Momentum(), reco::LeafCandidate::setP4(), reco::LeafCandidate::setVertex(), and reco::Conversion::tracks().

Referenced by produce().

334  {
335 
337  photonCand->setP4(convertVector(conv.refittedPair4Momentum()));
338  photonCand->setVertex(conv.conversionVertex().position());
339 
340  photonCand->addUserData<reco::Track>( "track0", *conv.tracks()[0] );
341  photonCand->addUserData<reco::Track>( "track1", *conv.tracks()[1] );
342 
343  return photonCand;
344 
345 }
const reco::Vertex & conversionVertex() const
returns the reco conversion vertex
Definition: Conversion.h:97
Analysis-level particle class.
reco::Candidate::LorentzVector convertVector(const math::XYZTLorentzVectorF &)
virtual void setP4(const LorentzVector &p4)
set 4-momentum
const Point & position() const
position
Definition: Vertex.h:106
virtual void setVertex(const Point &vertex)
set vertex
math::XYZTLorentzVectorF refittedPair4Momentum() const
Conversion track pair 4-momentum from the tracks refitted with vertex constraint. ...
Definition: Conversion.cc:235
void addUserData(const std::string &label, const T &data, bool transientOnly=false)
Definition: PATObject.h:309
std::vector< edm::RefToBase< reco::Track > > const & tracks() const
vector of track to base references
Definition: Conversion.cc:176
int OniaPhotonConversionProducer::PackFlags ( const reco::Conversion conv,
bool  flagTkVtxCompatibility,
bool  flagCompatibleInnerHits,
bool  flagHighpurity,
bool  pizero_rejected,
bool  large_pizero_window 
)
private

Definition at line 208 of file OniaPhotonConversionProducer.cc.

References reco::Conversion::algo(), flags, lumiQueryAPI::q, and reco::Conversion::quality().

Referenced by produce().

210  {
211  int flags = 0;
212  if ( flagTkVtxCompatibility ) flags += 1;
213  if ( flagCompatibleInnerHits ) flags += 2;
214  if ( flagHighpurity ) flags += 4;
215  if ( pizero_rejected ) flags += 8;
216  if ( large_pizero_window ) flags += 16;
217 
218  flags += (conv.algo()*32);
219  int q_mask = 0;
220  std::vector<std::string> s_quals;
221  s_quals.push_back("generalTracksOnly");
222  s_quals.push_back("arbitratedEcalSeeded");
223  s_quals.push_back("arbitratedMerged");
224  s_quals.push_back("arbitratedMergedEcalGeneral");
225  s_quals.push_back("highPurity");
226  s_quals.push_back("highEfficiency");
227  s_quals.push_back("ecalMatched1Track");
228  s_quals.push_back("ecalMatched2Track");
229  std::vector<int> i_quals = StringToEnumValue<reco::Conversion::ConversionQuality>(s_quals);
230  for (std::vector<int>::const_iterator qq = i_quals.begin(); qq!=i_quals.end(); ++qq) {
232  if (conv.quality(q)) q_mask = *qq;
233  }
234  flags += (q_mask*32*8);
235  return flags;
236 }
ConversionAlgorithm algo() const
Definition: Conversion.h:223
bool quality(ConversionQuality q) const
Definition: Conversion.h:181
std::vector< Variable::Flags > flags
Definition: MVATrainer.cc:135
void OniaPhotonConversionProducer::produce ( edm::Event event,
const edm::EventSetup esetup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 100 of file OniaPhotonConversionProducer.cc.

References pat::PATObject< ObjectType >::addUserInt(), algo_fail, CheckPi0(), checkTkVtxCompatibility(), CInnerHits, conv, convAlgo_, convCollectionToken_, convQuality_, convSelectionCuts_, final_conversion, flag_fail, flags, foundCompatibleInnerHits(), highpurity_count, HighpuritySubset(), i, makePhotonCandidate(), PackFlags(), pfCandidateCollectionToken_, pi0OnlineSwitch_, pizero_fail, edm::Handle< T >::product(), lumiQueryAPI::q, removeDuplicates(), selection_fail, selectPFPhotons(), store_conversion, thePVsToken_, TkVtxC, total_conversions, wantCompatibleInnerHits_, wantHighpurity_, and wantTkVtxCompatibility_.

100  {
101 
102  std::auto_ptr<reco::ConversionCollection> outCollection(new reco::ConversionCollection);
103  std::auto_ptr<pat::CompositeCandidateCollection> patoutCollection(new pat::CompositeCandidateCollection);
104  std::vector<int> flagCollection;
105 
107  event.getByToken(thePVsToken_, priVtxs);
108 
110  event.getByToken(convCollectionToken_,pConv);
111 
113  event.getByToken(pfCandidateCollectionToken_,pfcandidates);
114 
115  const reco::PFCandidateCollection pfphotons = selectPFPhotons(*pfcandidates);
116 
118 
119  for(reco::ConversionCollection::const_iterator conv = pConv->begin(); conv != pConv->end(); ++conv){
121 
122  if (! ( *convSelection_)(*conv)){
123  selection_fail++;
124  continue; // selection string
125  }
126  if (convAlgo_ != 0 && conv->algo()!= convAlgo_){
127  algo_fail++;
128  continue; // select algorithm
129  }
130  if(convQuality_.size() > 0){
131  bool flagsok=true;
132  for (std::vector<int>::const_iterator flag = convQuality_.begin(); flag!=convQuality_.end(); ++flag){
134  if (!conv->quality(q)) {
135  flagsok=false;
136  break;
137  }
138  }
139  if (!flagsok){
140  flag_fail++;
141  continue;
142  }
143  }
144 
145  bool flag1 = true;
146  bool flag2 = true;
147  bool flag3 = true;
148  bool flag4 = true;
149 
150  // The logic implies that by default this flags are true and if the check are not wanted conversions are saved.
151  // If checks are required and failed then don't save the conversion.
152 
153  bool flagTkVtxCompatibility = true;
154  if (! checkTkVtxCompatibility(*conv,*priVtxs.product())) {
155  flagTkVtxCompatibility = false;
157  TkVtxC++;
158  flag1 = false;
159  }
160  }
161  bool flagCompatibleInnerHits = false;
162  if (conv->tracks().size()==2) {
163  reco::HitPattern hitPatA=conv->tracks().at(0)->hitPattern();
164  reco::HitPattern hitPatB=conv->tracks().at(1)->hitPattern();
165  if ( foundCompatibleInnerHits(hitPatA,hitPatB) && foundCompatibleInnerHits(hitPatB,hitPatA) ) flagCompatibleInnerHits = true;
166  }
167  if (wantCompatibleInnerHits_ && ! flagCompatibleInnerHits) {
168  CInnerHits++;
169  flag2 = false;
170  }
171  bool flagHighpurity = true;
172  if (!HighpuritySubset(*conv,*priVtxs.product())) {
173  flagHighpurity = false;
174  if (wantHighpurity_) {
176  flag3 = false;
177  }
178  }
179  bool pizero_rejected = false;
180  bool large_pizero_window = CheckPi0(*conv, pfphotons, pizero_rejected);
181  if (pi0OnlineSwitch_ && pizero_rejected) {
182  pizero_fail++;
183  flag4 = false;
184  }
185 
186  if (flag1 && flag2 && flag3 && flag4){
187  int flags = PackFlags(*conv,flagTkVtxCompatibility,flagCompatibleInnerHits,flagHighpurity,pizero_rejected,large_pizero_window);
188  flagCollection.push_back(flags);
189  outCollection->push_back(*conv);
191  }
192  }
193  removeDuplicates(*outCollection,flagCollection);
194 
195  int i = -1;
196  for (reco::ConversionCollection::const_iterator conv = outCollection->begin(); conv != outCollection->end(); ++conv){
197  i++;
199  pat_conv->addUserInt("flags",flagCollection.at(i));
200  patoutCollection->push_back(*pat_conv);
201  }
202  store_conversion += patoutCollection->size();
203  event.put(patoutCollection,"conversions");
204 
205  delete convSelection_;
206 }
Analysis-level particle class.
int i
Definition: DBlmapReader.cc:9
bool foundCompatibleInnerHits(const reco::HitPattern &hitPatA, const reco::HitPattern &hitPatB)
void removeDuplicates(reco::ConversionCollection &, std::vector< int > &)
static HepMC::IO_HEPEVT conv
bool HighpuritySubset(const reco::Conversion &, const reco::VertexCollection &)
std::vector< Variable::Flags > flags
Definition: MVATrainer.cc:135
std::vector< Conversion > ConversionCollection
collectin of Conversion objects
Definition: ConversionFwd.h:9
bool checkTkVtxCompatibility(const reco::Conversion &, const reco::VertexCollection &)
int PackFlags(const reco::Conversion &, bool, bool, bool, bool, bool)
edm::EDGetTokenT< reco::VertexCollection > thePVsToken_
void addUserInt(const std::string &label, int32_t data)
Set user-defined int.
Definition: PATObject.h:832
const reco::PFCandidateCollection selectPFPhotons(const reco::PFCandidateCollection &)
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
edm::EDGetTokenT< reco::ConversionCollection > convCollectionToken_
std::vector< CompositeCandidate > CompositeCandidateCollection
T const * product() const
Definition: Handle.h:81
edm::EDGetTokenT< reco::PFCandidateCollection > pfCandidateCollectionToken_
bool CheckPi0(const reco::Conversion &, const reco::PFCandidateCollection &, bool &)
pat::CompositeCandidate * makePhotonCandidate(const reco::Conversion &)
void OniaPhotonConversionProducer::removeDuplicates ( reco::ConversionCollection c,
std::vector< int > &  f 
)
private

Put in out collection only those conversion candidates that are not sharing tracks. If sharing, keep the one with the best chi2.

Definition at line 241 of file OniaPhotonConversionProducer.cc.

References ConversionEqualByTrack(), ConversionLessByChi2(), duplicates, and python.multivaluedict::sort().

Referenced by produce().

241  {
242  // first sort from high to low chi2 prob
243  std::sort(c.begin(),c.end(),ConversionLessByChi2);
244  int iter1 = 0;
245  // Cycle over all the elements of the collection and compare to all the following,
246  // if two elements have at least one track in common delete the element with the lower chi2
247  while(iter1 < (( (int) c.size() ) - 1) ){
248  int iter2 = iter1+1;
249  while( iter2 < (int) c.size()) if(ConversionEqualByTrack( c[iter1], c[iter2] ) ){
250  c.erase( c.begin() + iter2 );
251  f.erase( f.begin() + iter2 );
252  duplicates++;
253  }else{
254  iter2++; // Increment index only if this element is no duplicate.
255  // If it is duplicate check again the same index since the vector rearranged elements index after erasing
256  }
257  iter1++;
258  }
259 }
bool ConversionLessByChi2(const reco::Conversion &c1, const reco::Conversion &c2)
bool ConversionEqualByTrack(const reco::Conversion &c1, const reco::Conversion &c2)
double f[11][100]
const reco::PFCandidateCollection OniaPhotonConversionProducer::selectPFPhotons ( const reco::PFCandidateCollection pfcandidates)
private

Definition at line 348 of file OniaPhotonConversionProducer.cc.

References reco::PFCandidate::gamma.

Referenced by produce().

348  {
349  reco::PFCandidateCollection pfphotons;
350  for (reco::PFCandidateCollection::const_iterator cand = pfcandidates.begin(); cand != pfcandidates.end(); ++cand){
351  if (cand->particleId() == reco::PFCandidate::gamma) pfphotons.push_back(*cand);
352  }
353  return pfphotons;
354 }
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates

Member Data Documentation

double OniaPhotonConversionProducer::_minDistanceOfApproachMaxCut
private
double OniaPhotonConversionProducer::_minDistanceOfApproachMinCut
private
double OniaPhotonConversionProducer::_trackchi2Cut
private
double OniaPhotonConversionProducer::_vertexChi2ProbCut
private
int OniaPhotonConversionProducer::algo_fail
private

Definition at line 78 of file OniaPhotonConversionProducer.h.

Referenced by endJob(), OniaPhotonConversionProducer(), and produce().

int OniaPhotonConversionProducer::CInnerHits
private

Definition at line 83 of file OniaPhotonConversionProducer.h.

Referenced by endJob(), OniaPhotonConversionProducer(), and produce().

int OniaPhotonConversionProducer::convAlgo_
private

Definition at line 73 of file OniaPhotonConversionProducer.h.

Referenced by OniaPhotonConversionProducer(), and produce().

edm::EDGetTokenT<reco::ConversionCollection> OniaPhotonConversionProducer::convCollectionToken_
private

Definition at line 55 of file OniaPhotonConversionProducer.h.

Referenced by OniaPhotonConversionProducer(), and produce().

std::vector<int> OniaPhotonConversionProducer::convQuality_
private

Definition at line 74 of file OniaPhotonConversionProducer.h.

Referenced by OniaPhotonConversionProducer(), and produce().

std::string OniaPhotonConversionProducer::convSelectionCuts_
private

Definition at line 88 of file OniaPhotonConversionProducer.h.

Referenced by OniaPhotonConversionProducer(), and produce().

int OniaPhotonConversionProducer::duplicates
private
int OniaPhotonConversionProducer::final_conversion
private

Definition at line 85 of file OniaPhotonConversionProducer.h.

Referenced by endJob(), OniaPhotonConversionProducer(), and produce().

int OniaPhotonConversionProducer::flag_fail
private

Definition at line 79 of file OniaPhotonConversionProducer.h.

Referenced by endJob(), OniaPhotonConversionProducer(), and produce().

int OniaPhotonConversionProducer::highpurity_count
private

Definition at line 84 of file OniaPhotonConversionProducer.h.

Referenced by endJob(), OniaPhotonConversionProducer(), and produce().

edm::EDGetTokenT<reco::PFCandidateCollection> OniaPhotonConversionProducer::pfCandidateCollectionToken_
private

Definition at line 57 of file OniaPhotonConversionProducer.h.

Referenced by OniaPhotonConversionProducer(), and produce().

std::vector<double> OniaPhotonConversionProducer::pi0LargeWindow_
private

Definition at line 71 of file OniaPhotonConversionProducer.h.

Referenced by CheckPi0(), and OniaPhotonConversionProducer().

bool OniaPhotonConversionProducer::pi0OnlineSwitch_
private

Definition at line 68 of file OniaPhotonConversionProducer.h.

Referenced by OniaPhotonConversionProducer(), and produce().

std::vector<double> OniaPhotonConversionProducer::pi0SmallWindow_
private

Definition at line 70 of file OniaPhotonConversionProducer.h.

Referenced by CheckPi0(), and OniaPhotonConversionProducer().

int OniaPhotonConversionProducer::pizero_fail
private

Definition at line 80 of file OniaPhotonConversionProducer.h.

Referenced by endJob(), OniaPhotonConversionProducer(), and produce().

int OniaPhotonConversionProducer::selection_fail
private

Definition at line 77 of file OniaPhotonConversionProducer.h.

Referenced by endJob(), OniaPhotonConversionProducer(), and produce().

uint32_t OniaPhotonConversionProducer::sigmaTkVtxComp_
private
int OniaPhotonConversionProducer::store_conversion
private

Definition at line 86 of file OniaPhotonConversionProducer.h.

Referenced by endJob(), OniaPhotonConversionProducer(), and produce().

edm::EDGetTokenT<reco::VertexCollection> OniaPhotonConversionProducer::thePVsToken_
private

Definition at line 56 of file OniaPhotonConversionProducer.h.

Referenced by OniaPhotonConversionProducer(), and produce().

uint32_t OniaPhotonConversionProducer::TkMinNumOfDOF_
private
int OniaPhotonConversionProducer::TkVtxC
private

Definition at line 82 of file OniaPhotonConversionProducer.h.

Referenced by endJob(), OniaPhotonConversionProducer(), and produce().

int OniaPhotonConversionProducer::total_conversions
private

Definition at line 76 of file OniaPhotonConversionProducer.h.

Referenced by endJob(), OniaPhotonConversionProducer(), and produce().

bool OniaPhotonConversionProducer::wantCompatibleInnerHits_
private

Definition at line 61 of file OniaPhotonConversionProducer.h.

Referenced by OniaPhotonConversionProducer(), and produce().

bool OniaPhotonConversionProducer::wantHighpurity_
private

Definition at line 63 of file OniaPhotonConversionProducer.h.

Referenced by OniaPhotonConversionProducer(), and produce().

bool OniaPhotonConversionProducer::wantTkVtxCompatibility_
private

Definition at line 59 of file OniaPhotonConversionProducer.h.

Referenced by OniaPhotonConversionProducer(), and produce().