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 Types | Private Member Functions | Private Attributes
ConversionProducer Class Reference

#include <ConversionProducer.h>

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

Public Member Functions

 ConversionProducer (const edm::ParameterSet &)
 
 ~ConversionProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 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
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Types

typedef math::XYZPointF Point
 
typedef std::vector< PointPointCollection
 

Private Member Functions

void buildCollection (edm::Event &iEvent, const edm::EventSetup &iSetup, const std::multimap< float, edm::Ptr< reco::ConversionTrack > > &allTracks, const std::multimap< double, reco::CaloClusterPtr > &superClusterPtrs, const std::multimap< double, reco::CaloClusterPtr > &basicClusterPtrs, const reco::Vertex &the_pvtx, reco::ConversionCollection &outputConvPhotonCollection)
 
void buildSuperAndBasicClusterGeoMap (const edm::Event &, std::multimap< double, reco::CaloClusterPtr > &basicClusterPtrs, std::multimap< double, reco::CaloClusterPtr > &superClusterPtrs)
 
bool checkPhi (const edm::RefToBase< reco::Track > &tk_l, const edm::RefToBase< reco::Track > &tk_r, const TrackerGeometry *trackerGeom, const MagneticField *magField, const reco::Vertex &the_vertex)
 
bool checkTrackPair (const std::pair< edm::RefToBase< reco::Track >, reco::CaloClusterPtr > &ll, const std::pair< edm::RefToBase< reco::Track >, reco::CaloClusterPtr > &rr)
 
bool checkVertex (const reco::TransientTrack &ttk_l, const reco::TransientTrack &ttk_r, const MagneticField *magField, reco::Vertex &the_vertex)
 
double etaTransformation (float EtaParticle, float Zvertex)
 
bool getMatchedBC (const std::multimap< double, reco::CaloClusterPtr > &bcMap, const math::XYZPointF &trackImpactPosition, reco::CaloClusterPtr &closestBC)
 
bool getTrackImpactPosition (const reco::Track *tk_ref, const TrackerGeometry *trackerGeom, const MagneticField *magField, math::XYZPointF &ew)
 
bool matchingSC (const std::multimap< double, reco::CaloClusterPtr > &scMap, reco::Conversion &conv, reco::CaloClusterPtrVector &mSC)
 
bool preselectTrackPair (const reco::TransientTrack &ttk_l, const reco::TransientTrack &ttk_r, double &appDist)
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 
math::XYZPointF toFConverterP (const math::XYZPoint &val)
 
math::XYZVectorF toFConverterV (const math::XYZVector &val)
 
bool trackD0Cut (const edm::RefToBase< reco::Track > &ref)
 
bool trackD0Cut (const edm::RefToBase< reco::Track > &ref, const reco::Vertex &the_pvtx)
 
bool trackQualityFilter (const edm::RefToBase< reco::Track > &ref, bool isLeft)
 

Private Attributes

std::string algoName_
 
bool allowD0_
 
bool allowDeltaCot_
 
bool allowDeltaPhi_
 
bool allowMinApproach_
 
bool allowOppCharge_
 
bool allowSingleLeg_
 
bool allowTrackBC_
 
bool allowVertex_
 
edm::InputTag bcBarrelCollection_
 
edm::InputTag bcEndcapCollection_
 
bool bypassPreselEcal_
 
bool bypassPreselEcalEcal_
 
bool bypassPreselGsf_
 
std::string ConvertedPhotonCollection_
 
double d0Cut_
 
double deltaCotTheta_
 
double deltaEta_
 
double deltaPhi_
 
double dEtacutForSCmatching_
 
double dEtaTkBC_
 
double dPhicutForSCmatching_
 
double dPhiTkBC_
 
double dzCut_
 
double energyBC_
 
double energyTotalBC_
 
double halfWayEta_
 
double halfWayPhi_
 
double maxChi2Left_
 
double maxChi2Right_
 
unsigned int maxNumOfTrackInPU_
 
double maxTrackRho_
 
double maxTrackZ_
 
double minApproachHigh_
 
double minApproachLow_
 
double minHitsLeft_
 
double minHitsRight_
 
double minSCEt_
 
double r_cut
 
bool rightBC_
 
edm::InputTag scBarrelProducer_
 
edm::InputTag scEndcapProducer_
 
edm::InputTag src_
 
const TransientTrackBuilderthettbuilder_
 
ConversionVertexFindertheVertexFinder_
 
bool usePvtx_
 
std::string vertexProducer_
 
double vtxChi2_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- 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::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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

$Id:

Date:
2011/08/08 01:32:25
Revision:
1.6
Authors
H. Liu, UC of Riverside US, N. Marinelli Univ of Notre Dame

Description: Produces converted photon objects using default track collections

Implementation: <Notes on="" implementation>="">

Definition at line 67 of file ConversionProducer.h.

Member Typedef Documentation

Definition at line 87 of file ConversionProducer.h.

typedef std::vector<Point> ConversionProducer::PointCollection
private

Definition at line 88 of file ConversionProducer.h.

Constructor & Destructor Documentation

ConversionProducer::ConversionProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 74 of file ConversionProducer.cc.

References algoName_, allowD0_, allowDeltaCot_, allowDeltaPhi_, allowMinApproach_, allowOppCharge_, allowSingleLeg_, allowTrackBC_, allowVertex_, bcBarrelCollection_, bcEndcapCollection_, bypassPreselEcal_, bypassPreselEcalEcal_, bypassPreselGsf_, ConvertedPhotonCollection_, d0Cut_, deltaCotTheta_, deltaEta_, deltaPhi_, dEtacutForSCmatching_, dEtaTkBC_, dPhicutForSCmatching_, dPhiTkBC_, dzCut_, energyBC_, energyTotalBC_, edm::ParameterSet::getParameter(), halfWayEta_, maxChi2Left_, maxChi2Right_, maxNumOfTrackInPU_, maxTrackRho_, maxTrackZ_, minApproachHigh_, minApproachLow_, minHitsLeft_, minHitsRight_, minSCEt_, r_cut, rightBC_, scBarrelProducer_, scEndcapProducer_, src_, AlCaHLTBitMon_QueryRunRegistry::string, thettbuilder_, theVertexFinder_, usePvtx_, vertexProducer_, and vtxChi2_.

74  :
76 
77 {
78  algoName_ = iConfig.getParameter<std::string>( "AlgorithmName" );
79 
80  src_ = iConfig.getParameter<edm::InputTag>("src");
81 
82  maxNumOfTrackInPU_ = iConfig.getParameter<int>("maxNumOfTrackInPU");
83  maxTrackRho_ = iConfig.getParameter<double>("maxTrackRho");
84  maxTrackZ_ = iConfig.getParameter<double>("maxTrackZ");
85 
86  allowTrackBC_ = iConfig.getParameter<bool>("AllowTrackBC");
87  allowD0_ = iConfig.getParameter<bool>("AllowD0");
88  allowDeltaPhi_ = iConfig.getParameter<bool>("AllowDeltaPhi");
89  allowDeltaCot_ = iConfig.getParameter<bool>("AllowDeltaCot");
90  allowMinApproach_ = iConfig.getParameter<bool>("AllowMinApproach");
91  allowOppCharge_ = iConfig.getParameter<bool>("AllowOppCharge");
92 
93  allowVertex_ = iConfig.getParameter<bool>("AllowVertex");
94 
95  bypassPreselGsf_ = iConfig.getParameter<bool>("bypassPreselGsf");
96  bypassPreselEcal_ = iConfig.getParameter<bool>("bypassPreselEcal");
97  bypassPreselEcalEcal_ = iConfig.getParameter<bool>("bypassPreselEcalEcal");
98 
99  deltaEta_ = iConfig.getParameter<double>("deltaEta");
100 
101  halfWayEta_ = iConfig.getParameter<double>("HalfwayEta");//open angle to search track matches with BC
102 
103  d0Cut_ = iConfig.getParameter<double>("d0");
104 
105  usePvtx_ = iConfig.getParameter<bool>("UsePvtx");//if use primary vertices
106 
107  vertexProducer_ = iConfig.getParameter<std::string>("primaryVertexProducer");
108 
109 
110  //Track-cluster matching eta and phi cuts
111  dEtaTkBC_ = iConfig.getParameter<double>("dEtaTrackBC");//TODO research on cut endcap/barrel
112  dPhiTkBC_ = iConfig.getParameter<double>("dPhiTrackBC");
113 
114  bcBarrelCollection_ = iConfig.getParameter<edm::InputTag>("bcBarrelCollection");
115  bcEndcapCollection_ = iConfig.getParameter<edm::InputTag>("bcEndcapCollection");
116 
117  scBarrelProducer_ = iConfig.getParameter<edm::InputTag>("scBarrelProducer");
118  scEndcapProducer_ = iConfig.getParameter<edm::InputTag>("scEndcapProducer");
119 
120  energyBC_ = iConfig.getParameter<double>("EnergyBC");//BC energy threshold
121  energyTotalBC_ = iConfig.getParameter<double>("EnergyTotalBC");//BC energy threshold
122  minSCEt_ = iConfig.getParameter<double>("minSCEt");//super cluster energy threshold
123  dEtacutForSCmatching_ = iConfig.getParameter<double>("dEtacutForSCmatching");// dEta between conversion momentum direction and SC position
124  dPhicutForSCmatching_ = iConfig.getParameter<double>("dPhicutForSCmatching");// dPhi between conversion momentum direction and SC position
125 
126 
127 
128 
129  //Track cuts on left right track: at least one leg reaches ECAL
130  //Left track: must exist, must reach Ecal and match BC, so loose cut on Chi2 and tight on hits
131  //Right track: not necessary to exist (if allowSingleLeg_), not necessary to reach ECAL or match BC, so tight cut on Chi2 and loose on hits
132  maxChi2Left_ = iConfig.getParameter<double>("MaxChi2Left");
133  maxChi2Right_ = iConfig.getParameter<double>("MaxChi2Right");
134  minHitsLeft_ = iConfig.getParameter<int>("MinHitsLeft");
135  minHitsRight_ = iConfig.getParameter<int>("MinHitsRight");
136 
137  //Track Open angle cut on delta cot(theta) and delta phi
138  deltaCotTheta_ = iConfig.getParameter<double>("DeltaCotTheta");
139  deltaPhi_ = iConfig.getParameter<double>("DeltaPhi");
140  minApproachLow_ = iConfig.getParameter<double>("MinApproachLow");
141  minApproachHigh_ = iConfig.getParameter<double>("MinApproachHigh");
142 
143 
144  // if allow single track collection, by default False
145  allowSingleLeg_ = iConfig.getParameter<bool>("AllowSingleLeg");
146  rightBC_ = iConfig.getParameter<bool>("AllowRightBC");
147 
148  //track inner position dz cut, need RECO
149  dzCut_ = iConfig.getParameter<double>("dz");
150  //track analytical cross cut
151  r_cut = iConfig.getParameter<double>("rCut");
152  vtxChi2_ = iConfig.getParameter<double>("vtxChi2");
153 
154 
155  theVertexFinder_ = new ConversionVertexFinder ( iConfig );
156 
157  thettbuilder_ = 0;
158 
159  //output
160  ConvertedPhotonCollection_ = iConfig.getParameter<std::string>("convertedPhotonCollection");
161 
162  produces< reco::ConversionCollection >(ConvertedPhotonCollection_);
163 
164 }
T getParameter(std::string const &) const
unsigned int maxNumOfTrackInPU_
ConversionVertexFinder * theVertexFinder_
edm::InputTag scBarrelProducer_
edm::InputTag bcBarrelCollection_
const TransientTrackBuilder * thettbuilder_
edm::InputTag scEndcapProducer_
std::string ConvertedPhotonCollection_
edm::InputTag bcEndcapCollection_
ConversionProducer::~ConversionProducer ( )

Definition at line 167 of file ConversionProducer.cc.

References theVertexFinder_.

168 {
169 
170  // do anything here that needs to be done at desctruction time
171  // (e.g. close files, deallocate resources etc.)
172  delete theVertexFinder_;
173 }
ConversionVertexFinder * theVertexFinder_

Member Function Documentation

void ConversionProducer::buildCollection ( edm::Event iEvent,
const edm::EventSetup iSetup,
const std::multimap< float, edm::Ptr< reco::ConversionTrack > > &  allTracks,
const std::multimap< double, reco::CaloClusterPtr > &  superClusterPtrs,
const std::multimap< double, reco::CaloClusterPtr > &  basicClusterPtrs,
const reco::Vertex the_pvtx,
reco::ConversionCollection outputConvPhotonCollection 
)
private

match the track pair with a SC. If at least one track matches, store the SC

Definition at line 299 of file ConversionProducer.cc.

References reco::TrackBase::algo(), reco::Conversion::algoByName(), algoName_, allowOppCharge_, allowTrackBC_, muonTagProbeFilters_cff::allTracks, reco::Conversion::arbitratedEcalSeeded, reco::Conversion::arbitratedMerged, reco::Conversion::arbitratedMergedEcalGeneral, TransientTrackBuilder::build(), bypassPreselEcal_, bypassPreselEcalEcal_, bypassPreselGsf_, edm::RefToBase< T >::castTo(), reco::TrackBase::charge(), checkPhi(), checkVertex(), reco::Vertex::chi2(), ChiSquaredProbability(), deltaEta_, energyTotalBC_, reco::Track::extra(), reco::Conversion::generalTracksOnly, edm::EventSetup::get(), edm::RefToBase< T >::get(), getMatchedBC(), getTrackImpactPosition(), ZmumuStandalonSelection_cff::goodVertex, reco::Conversion::highPurity, reco::Track::innerMomentum(), reco::Track::innerPosition(), edm::Ref< C, T, F >::isNonnull(), reco::Vertex::isValid(), matchingSC(), reco::Vertex::ndof(), ConversionHitChecker::nHitsBeforeVtx(), ConversionHitChecker::nSharedHits(), reco::Track::outerMomentum(), preselectTrackPair(), edm::ESHandle< class >::product(), findQualityFiles::rr, reco::Conversion::setMatchingSuperCluster(), reco::Conversion::setQuality(), thettbuilder_, toFConverterP(), toFConverterV(), trackD0Cut(), trackQualityFilter(), and vtxChi2_.

Referenced by produce().

304  {
305 
306 
307  edm::ESHandle<TrackerGeometry> trackerGeomHandle;
308  edm::ESHandle<MagneticField> magFieldHandle;
309  iSetup.get<TrackerDigiGeometryRecord>().get( trackerGeomHandle );
310  iSetup.get<IdealMagneticFieldRecord>().get( magFieldHandle );
311 
312  const TrackerGeometry* trackerGeom = trackerGeomHandle.product();
313  const MagneticField* magField = magFieldHandle.product();
314 
315 // std::vector<math::XYZPointF> trackImpactPosition;
316 // trackImpactPosition.reserve(allTracks.size());//track impact position at ECAL
317 // std::vector<bool> trackValidECAL;//Does this track reach ECAL basic cluster (reach ECAL && match with BC)
318 // trackValidECAL.assign(allTracks.size(), false);
319 //
320 // std::vector<reco::CaloClusterPtr> trackMatchedBC;
321 // reco::CaloClusterPtr empty_bc;
322 // trackMatchedBC.assign(allTracks.size(), empty_bc);//TODO find a better way to avoid copy constructor
323 //
324 // std::vector<int> bcHandleId;//the associated BC handle id, -1 invalid, 0 barrel 1 endcap
325 // bcHandleId.assign(allTracks.size(), -1);
326 
327  // not used std::multimap<double, int> trackInnerEta;//Track innermost state Eta map to TrackRef index, to be used in track pair sorting
328 
329  std::map<edm::Ptr<reco::ConversionTrack>, math::XYZPointF> trackImpactPosition;
330  std::map<edm::Ptr<reco::ConversionTrack>, reco::CaloClusterPtr> trackMatchedBC;
331 
332  ConversionHitChecker hitChecker;
333 
334 
335  //2 propagate all tracks into ECAL, record its eta and phi
336 
337  for (std::multimap<float, edm::Ptr<reco::ConversionTrack> >::const_iterator tk_ref = allTracks.begin(); tk_ref != allTracks.end(); ++tk_ref ){
338  const reco::Track* tk = tk_ref->second->trackRef().get() ;
339 
340 
341  //check impact position then match with BC
342  math::XYZPointF ew;
343  if ( getTrackImpactPosition(tk, trackerGeom, magField, ew) ){
344  trackImpactPosition[tk_ref->second] = ew;
345 
346  reco::CaloClusterPtr closest_bc;//the closest matching BC to track
347 
348  if ( getMatchedBC(basicClusterPtrs, ew, closest_bc) ){
349  trackMatchedBC[tk_ref->second] = closest_bc;
350  }
351  }
352  }
353 
354 
355 
356  //3. pair up tracks:
357  //TODO it is k-Closest pair of point problem
358  //std::cout << " allTracks.size() " << allTracks.size() << std::endl;
359  for(std::multimap<float, edm::Ptr<reco::ConversionTrack> >::const_iterator ll = allTracks.begin(); ll != allTracks.end(); ++ll ) {
360  bool track1HighPurity=true;
361  //std::cout << " Loop on allTracks " << std::endl;
362  const edm::RefToBase<reco::Track> & left = ll->second->trackRef();
363 
364 
365  //TODO: This is a workaround, should be fixed with a proper function in the TTBuilder
366  //(Note that the TrackRef and GsfTrackRef versions of the constructor are needed
367  // to properly get refit tracks in the output vertex)
368  reco::TransientTrack ttk_l;
369  if (dynamic_cast<const reco::GsfTrack*>(left.get())) {
370  ttk_l = thettbuilder_->build(left.castTo<reco::GsfTrackRef>());
371  }
372  else {
373  ttk_l = thettbuilder_->build(left.castTo<reco::TrackRef>());
374  }
375 
377  // if ((allowTrackBC_ && !trackValidECAL[ll-allTracks.begin()]) )//this Left leg should have valid BC
378  // continue;
379 
380 
381  if (the_pvtx.isValid()){
382  if (!(trackD0Cut(left, the_pvtx))) track1HighPurity=false;
383  } else {
384  if (!(trackD0Cut(left))) track1HighPurity=false;
385  }
386 
387  std::vector<int> right_candidates;//store all right legs passed the cut (theta/approach and ref pair)
388  std::vector<double> right_candidate_theta, right_candidate_approach;
389  std::vector<std::pair<bool, reco::Vertex> > vertex_candidates;
390 
391  //inner loop only over tracks between eta and eta + deltaEta of the first track
392  float etasearch = ll->first + deltaEta_;
393  std::multimap<float, edm::Ptr<reco::ConversionTrack> >::const_iterator rr = ll;
394  ++rr;
395  for (; rr != allTracks.lower_bound(etasearch); ++rr ) {
396  bool track2HighPurity = true;
397  bool highPurityPair = true;
398 
399  const edm::RefToBase<reco::Track> & right = rr->second->trackRef();
400 
401 
402  //TODO: This is a workaround, should be fixed with a proper function in the TTBuilder
403  reco::TransientTrack ttk_r;
404  if (dynamic_cast<const reco::GsfTrack*>(right.get())) {
405  ttk_r = thettbuilder_->build(right.castTo<reco::GsfTrackRef>());
406  }
407  else {
408  ttk_r = thettbuilder_->build(right.castTo<reco::TrackRef>());
409  }
410  //std::cout << " This track is " << right->algoName() << std::endl;
411 
412 
413  //all vertexing preselection should go here
414 
415  //check for opposite charge
416  if ( allowOppCharge_ && (left->charge()*right->charge() > 0) )
417  continue; //same sign, reject pair
418 
420  //if ( (allowTrackBC_ && !trackValidECAL[rr-allTracks.begin()] && rightBC_) )// if right track matches ECAL
421  // continue;
422 
423 
424  double approachDist = -999.;
425  //apply preselection to track pair, overriding preselection for gsf+X or ecalseeded+X pairs if so configured
426  bool preselected = preselectTrackPair(ttk_l,ttk_r, approachDist);
427  preselected = preselected || (bypassPreselGsf_ && (left->algo()==29 || right->algo()==29));
428  preselected = preselected || (bypassPreselEcal_ && (left->algo()==15 || right->algo()==15 || left->algo()==16 || right->algo()==16));
429  preselected = preselected || (bypassPreselEcalEcal_ && (left->algo()==15 || left->algo()==16) && (right->algo()==15 || right->algo()==16));
430 
431  if (!preselected) {
432  continue;
433  }
434 
435  //do the actual vertex fit
436  reco::Vertex theConversionVertex;//by default it is invalid
437  bool goodVertex = checkVertex(ttk_l, ttk_r, magField, theConversionVertex);
438 
439  //bail as early as possible in case the fit didn't return a good vertex
440  if (!goodVertex) {
441  continue;
442  }
443 
444 
445 
446  //track pair pass the quality cut
447  if ( !( (trackQualityFilter(left, true) && trackQualityFilter(right, false))
448  || (trackQualityFilter(left, false) && trackQualityFilter(right, true)) ) ) {
449  highPurityPair=false;
450  }
451 
452  if (the_pvtx.isValid()){
453  if (!(trackD0Cut(right, the_pvtx))) track2HighPurity=false;
454  } else {
455  if (!(trackD0Cut(right))) track2HighPurity=false;
456  }
457 
458 
459  //if all cuts passed, go ahead to make conversion candidates
460  std::vector<edm::RefToBase<reco::Track> > trackPairRef;
461  trackPairRef.push_back(left);//left track
462  trackPairRef.push_back(right);//right track
463 
464  std::vector<math::XYZVectorF> trackPin;
465  std::vector<math::XYZVectorF> trackPout;
466  std::vector<math::XYZPointF> trackInnPos;
467  std::vector<uint8_t> nHitsBeforeVtx;
468  std::vector<Measurement1DFloat> dlClosestHitToVtx;
469 
470  if (left->extra().isNonnull() && right->extra().isNonnull()){//only available on TrackExtra
471  trackInnPos.push_back( toFConverterP(left->innerPosition()));
472  trackInnPos.push_back( toFConverterP(right->innerPosition()));
473  trackPin.push_back(toFConverterV(left->innerMomentum()));
474  trackPin.push_back(toFConverterV(right->innerMomentum()));
475  trackPout.push_back(toFConverterV(left->outerMomentum()));
476  trackPout.push_back(toFConverterV(right->outerMomentum()));
477  }
478 
479  if (ll->second->trajRef().isNonnull() && rr->second->trajRef().isNonnull()) {
480  std::pair<uint8_t,Measurement1DFloat> leftWrongHits = hitChecker.nHitsBeforeVtx(*ll->second->trajRef().get(),theConversionVertex);
481  std::pair<uint8_t,Measurement1DFloat> rightWrongHits = hitChecker.nHitsBeforeVtx(*rr->second->trajRef().get(),theConversionVertex);
482  nHitsBeforeVtx.push_back(leftWrongHits.first);
483  nHitsBeforeVtx.push_back(rightWrongHits.first);
484  dlClosestHitToVtx.push_back(leftWrongHits.second);
485  dlClosestHitToVtx.push_back(rightWrongHits.second);
486  }
487 
488  uint8_t nSharedHits = hitChecker.nSharedHits(*left.get(),*right.get());
489 
490 
491  //if using kinematic fit, check with chi2 post cut
492  if (theConversionVertex.isValid()){
493  const float chi2Prob = ChiSquaredProbability(theConversionVertex.chi2(), theConversionVertex.ndof());
494  if (chi2Prob<vtxChi2_) highPurityPair=false;
495  }
496 
497  //std::cout << " highPurityPair after vertex cut " << highPurityPair << std::endl;
498  std::vector<math::XYZPointF> trkPositionAtEcal;
499  std::vector<reco::CaloClusterPtr> matchingBC;
500 
501  if (allowTrackBC_){//TODO find out the BC ptrs if not doing matching, otherwise, leave it empty
502  //const int lbc_handle = bcHandleId[ll-allTracks.begin()],
503  // rbc_handle = bcHandleId[rr-allTracks.begin()];
504 
505  std::map<edm::Ptr<reco::ConversionTrack>, math::XYZPointF>::const_iterator trackImpactPositionLeft = trackImpactPosition.find(ll->second);
506  std::map<edm::Ptr<reco::ConversionTrack>, math::XYZPointF>::const_iterator trackImpactPositionRight = trackImpactPosition.find(rr->second);
507  std::map<edm::Ptr<reco::ConversionTrack>, reco::CaloClusterPtr>::const_iterator trackMatchedBCLeft = trackMatchedBC.find(ll->second);
508  std::map<edm::Ptr<reco::ConversionTrack>, reco::CaloClusterPtr>::const_iterator trackMatchedBCRight = trackMatchedBC.find(rr->second);
509 
510  if (trackImpactPositionLeft!=trackImpactPosition.end()) {
511  trkPositionAtEcal.push_back(trackImpactPositionLeft->second);//left track
512  }
513  else {
514  trkPositionAtEcal.push_back(math::XYZPointF());//left track
515  }
516  if (trackImpactPositionRight!=trackImpactPosition.end()) {//second track ECAL position may be invalid
517  trkPositionAtEcal.push_back(trackImpactPositionRight->second);
518  }
519 
520  double total_e_bc = 0.;
521  if (trackMatchedBCLeft!=trackMatchedBC.end()) {
522  matchingBC.push_back(trackMatchedBCLeft->second);//left track
523  total_e_bc += trackMatchedBCLeft->second->energy();
524  }
525  else {
526  matchingBC.push_back( reco::CaloClusterPtr() );//left track
527  }
528  if (trackMatchedBCRight!=trackMatchedBC.end()) {//second track ECAL position may be invalid
529  matchingBC.push_back(trackMatchedBCRight->second);
530  total_e_bc += trackMatchedBCRight->second->energy();
531  }
532 
533  if (total_e_bc<energyTotalBC_) {
534  highPurityPair = false;
535  }
536 
537 
538  }
539  //signature cuts, then check if vertex, then post-selection cuts
540  highPurityPair = highPurityPair && track1HighPurity && track2HighPurity && goodVertex && checkPhi(left, right, trackerGeom, magField, theConversionVertex) ;
541 
542 
544  /*
545  for ( std::vector<edm::RefToBase<reco::Track> >::iterator iTk=trackPairRef.begin(); iTk!=trackPairRef.end(); iTk++) {
546  math::XYZPointF impPos;
547  if ( getTrackImpactPosition(*iTk, trackerGeom, magField, impPos) ) {
548 
549  }
550 
551  }
552  */
553 
554  const float minAppDist = approachDist;
556  float dummy=0;
558  reco::Conversion newCandidate(scPtrVec, trackPairRef, trkPositionAtEcal, theConversionVertex, matchingBC, minAppDist, trackInnPos, trackPin, trackPout, nHitsBeforeVtx, dlClosestHitToVtx, nSharedHits, dummy, algo );
559  // Fill in scPtrVec with the macthing SC
560  if ( matchingSC ( superClusterPtrs, newCandidate, scPtrVec) )
561  newCandidate.setMatchingSuperCluster( scPtrVec);
562 
563  //std::cout << " ConversionProducer scPtrVec.size " << scPtrVec.size() << std::endl;
564 
565  newCandidate.setQuality(reco::Conversion::highPurity, highPurityPair);
566  bool generalTracksOnly = ll->second->isTrackerOnly() && rr->second->isTrackerOnly() && !dynamic_cast<const reco::GsfTrack*>(ll->second->trackRef().get()) && !dynamic_cast<const reco::GsfTrack*>(rr->second->trackRef().get());
567  bool arbitratedEcalSeeded = ll->second->isArbitratedEcalSeeded() && rr->second->isArbitratedEcalSeeded();
568  bool arbitratedMerged = ll->second->isArbitratedMerged() && rr->second->isArbitratedMerged();
569  bool arbitratedMergedEcalGeneral = ll->second->isArbitratedMergedEcalGeneral() && rr->second->isArbitratedMergedEcalGeneral();
570 
571  newCandidate.setQuality(reco::Conversion::generalTracksOnly, generalTracksOnly);
572  newCandidate.setQuality(reco::Conversion::arbitratedEcalSeeded, arbitratedEcalSeeded);
573  newCandidate.setQuality(reco::Conversion::arbitratedMerged, arbitratedMerged);
574  newCandidate.setQuality(reco::Conversion::arbitratedMergedEcalGeneral, arbitratedMergedEcalGeneral);
575 
576  outputConvPhotonCollection.push_back(newCandidate);
577 
578  }
579 
580  }
581 
582 
583 
584 
585 
586 
587 }
bool getTrackImpactPosition(const reco::Track *tk_ref, const TrackerGeometry *trackerGeom, const MagneticField *magField, math::XYZPointF &ew)
const TrackExtraRef & extra() const
reference to &quot;extra&quot; object
Definition: Track.h:97
std::pair< uint8_t, Measurement1DFloat > nHitsBeforeVtx(const Trajectory &traj, const reco::Vertex &vtx, double sigmaTolerance=3.0) const
const TransientTrackBuilder * thettbuilder_
bool isValid() const
Tells whether the vertex is valid.
Definition: Vertex.h:61
reco::TransientTrack build(const reco::Track *p) const
static ConversionAlgorithm algoByName(const std::string &name)
Definition: Conversion.cc:157
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
Definition: Point3D.h:11
bool matchingSC(const std::multimap< double, reco::CaloClusterPtr > &scMap, reco::Conversion &conv, reco::CaloClusterPtrVector &mSC)
const math::XYZPoint & innerPosition() const
position of the innermost hit
Definition: Track.h:42
TrackAlgorithm algo() const
Definition: TrackBase.h:332
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
void setQuality(const TrackQuality, bool set=true)
Definition: TrackBase.h:393
math::XYZVectorF toFConverterV(const math::XYZVector &val)
double chi2() const
chi-squares
Definition: Vertex.h:82
float ChiSquaredProbability(double chiSquared, double nrDOF)
uint8_t nSharedHits(const reco::Track &trk1, const reco::Track &trk2) const
bool getMatchedBC(const std::multimap< double, reco::CaloClusterPtr > &bcMap, const math::XYZPointF &trackImpactPosition, reco::CaloClusterPtr &closestBC)
double ndof() const
Definition: Vertex.h:89
bool trackQualityFilter(const edm::RefToBase< reco::Track > &ref, bool isLeft)
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
Definition: Track.h:49
bool trackD0Cut(const edm::RefToBase< reco::Track > &ref)
const T & get() const
Definition: EventSetup.h:55
REF castTo() const
cast to a concrete type
Definition: RefToBase.h:241
T const * product() const
Definition: ESHandle.h:62
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
Definition: Track.h:45
int charge() const
track electric charge
Definition: TrackBase.h:113
math::XYZPointF toFConverterP(const math::XYZPoint &val)
bool preselectTrackPair(const reco::TransientTrack &ttk_l, const reco::TransientTrack &ttk_r, double &appDist)
value_type const * get() const
Definition: RefToBase.h:212
bool checkPhi(const edm::RefToBase< reco::Track > &tk_l, const edm::RefToBase< reco::Track > &tk_r, const TrackerGeometry *trackerGeom, const MagneticField *magField, const reco::Vertex &the_vertex)
bool checkVertex(const reco::TransientTrack &ttk_l, const reco::TransientTrack &ttk_r, const MagneticField *magField, reco::Vertex &the_vertex)
void ConversionProducer::buildSuperAndBasicClusterGeoMap ( const edm::Event iEvent,
std::multimap< double, reco::CaloClusterPtr > &  basicClusterPtrs,
std::multimap< double, reco::CaloClusterPtr > &  superClusterPtrs 
)
private

Definition at line 239 of file ConversionProducer.cc.

References bcBarrelCollection_, bcEndcapCollection_, energyBC_, edm::Event::getByLabel(), cuy::ii, edm::HandleBase::isValid(), findQualityFiles::jj, minSCEt_, scBarrelProducer_, and scEndcapProducer_.

Referenced by produce().

241  {
242 
243  // Get the Super Cluster collection in the Barrel
245  iEvent.getByLabel(scBarrelProducer_,scBarrelHandle);
246  if (!scBarrelHandle.isValid()) {
247  edm::LogError("ConvertedPhotonProducer") << "Error! Can't get the product "<<scBarrelProducer_;
248  }
249 
250  // Get the Super Cluster collection in the Endcap
252  iEvent.getByLabel(scEndcapProducer_,scEndcapHandle);
253  if (!scEndcapHandle.isValid()) {
254  edm::LogError("ConvertedPhotonProducer") << "Error! Can't get the product "<<scEndcapProducer_;
255  }
256 
257 
259  edm::Handle<edm::View<reco::CaloCluster> > bcEndcapHandle;//TODO check cluster type if BasicCluster or PFCluster
260 
261  iEvent.getByLabel( bcBarrelCollection_, bcBarrelHandle);
262  if (!bcBarrelHandle.isValid()) {
263  edm::LogError("ConvertedPhotonProducer") << "Error! Can't get the product "<<bcBarrelCollection_;
264  }
265 
266  iEvent.getByLabel( bcEndcapCollection_, bcEndcapHandle);
267  if (! bcEndcapHandle.isValid()) {
268  edm::LogError("ConvertedPhotonProducer") << "Error! Can't get the product "<<bcEndcapCollection_;
269  }
270 
271  edm::Handle<edm::View<reco::CaloCluster> > bcHandle = bcBarrelHandle;
272  edm::Handle<edm::View<reco::CaloCluster> > scHandle = scBarrelHandle;
273 
274  if ( bcHandle.isValid() ) {
275  for (unsigned jj = 0; jj < 2; ++jj ){
276  for (unsigned ii = 0; ii < bcHandle->size(); ++ii ) {
277  if (bcHandle->ptrAt(ii)->energy()>energyBC_)
278  basicClusterPtrs.insert(std::make_pair(bcHandle->ptrAt(ii)->position().eta(), bcHandle->ptrAt(ii)));
279  }
280  bcHandle = bcEndcapHandle;
281  }
282  }
283 
284 
285  if ( scHandle.isValid() ) {
286  for (unsigned jj = 0; jj < 2; ++jj ){
287  for (unsigned ii = 0; ii < scHandle->size(); ++ii ) {
288  if (scHandle->ptrAt(ii)->energy()>minSCEt_)
289  superClusterPtrs.insert(std::make_pair(scHandle->ptrAt(ii)->position().eta(), scHandle->ptrAt(ii)));
290  }
291  scHandle = scEndcapHandle;
292  }
293  }
294 
295 
296 }
edm::InputTag scBarrelProducer_
edm::InputTag bcBarrelCollection_
int ii
Definition: cuy.py:588
edm::InputTag scEndcapProducer_
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
edm::InputTag bcEndcapCollection_
bool ConversionProducer::checkPhi ( const edm::RefToBase< reco::Track > &  tk_l,
const edm::RefToBase< reco::Track > &  tk_r,
const TrackerGeometry trackerGeom,
const MagneticField magField,
const reco::Vertex the_vertex 
)
private

Definition at line 732 of file ConversionProducer.cc.

References allowDeltaPhi_, anyDirection, reco::deltaPhi(), deltaPhi_, dPhi(), reco::Track::extra(), TrajectoryStateOnSurface::globalDirection(), reco::Track::innerMomentum(), trajectoryStateTransform::innerStateOnSurface(), edm::Ref< C, T, F >::isNonnull(), reco::Vertex::isValid(), TrajectoryStateOnSurface::isValid(), PV3DBase< T, PVType, FrameType >::phi(), reco::Vertex::position(), and makeMuonMisalignmentScenario::rot.

Referenced by buildCollection().

734  {
735  if (!allowDeltaPhi_)
736  return true;
737  //if track has innermost momentum, check with innermost phi
738  //if track also has valid vertex, propagate to vertex then calculate phi there
739  //if track has no innermost momentum, just return true, because track->phi() makes no sense
740  if (tk_l->extra().isNonnull() && tk_r->extra().isNonnull()){
741  double iphi1 = tk_l->innerMomentum().phi(), iphi2 = tk_r->innerMomentum().phi();
742  if (vtx.isValid()){
743  PropagatorWithMaterial propag( anyDirection, 0.000511, magField );
744 
745  double recoPhoR = vtx.position().Rho();
748  new SimpleCylinderBounds( recoPhoR-0.001, recoPhoR+0.001,
749  -fabs(vtx.position().z()), fabs(vtx.position().z()))));
751  new BoundDisk( Surface::PositionType( 0, 0, vtx.position().z()), rot,
752  new SimpleDiskBounds( 0, recoPhoR, -0.001, 0.001)));
753 
754  const TrajectoryStateOnSurface myTSOS1 = trajectoryStateTransform::innerStateOnSurface(*tk_l, *trackerGeom, magField);
755  const TrajectoryStateOnSurface myTSOS2 = trajectoryStateTransform::innerStateOnSurface(*tk_r, *trackerGeom, magField);
756  TrajectoryStateOnSurface stateAtVtx1, stateAtVtx2;
757  stateAtVtx1 = propag.propagate(myTSOS1, *theBarrel_);
758  if (!stateAtVtx1.isValid() ) {
759  stateAtVtx1 = propag.propagate(myTSOS1, *theDisk_);
760  }
761  if (stateAtVtx1.isValid()){
762  iphi1 = stateAtVtx1.globalDirection().phi();
763  }
764  stateAtVtx2 = propag.propagate(myTSOS2, *theBarrel_);
765  if (!stateAtVtx2.isValid() ) {
766  stateAtVtx2 = propag.propagate(myTSOS2, *theDisk_);
767  }
768  if (stateAtVtx2.isValid()){
769  iphi2 = stateAtVtx2.globalDirection().phi();
770  }
771  }
772  const double dPhi = reco::deltaPhi(iphi1, iphi2);
773  return (fabs(dPhi) < deltaPhi_);
774  } else {
775  return true;
776  }
777 }
const TrackExtraRef & extra() const
reference to &quot;extra&quot; object
Definition: Track.h:97
TrajectoryStateOnSurface innerStateOnSurface(const reco::Track &tk, const TrackingGeometry &geom, const MagneticField *field)
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
Cylinder BoundCylinder
Definition: BoundCylinder.h:19
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:12
Disk BoundDisk
Definition: BoundDisk.h:64
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
Definition: Track.h:45
GlobalVector globalDirection() const
bool ConversionProducer::checkTrackPair ( const std::pair< edm::RefToBase< reco::Track >, reco::CaloClusterPtr > &  ll,
const std::pair< edm::RefToBase< reco::Track >, reco::CaloClusterPtr > &  rr 
)
private

Definition at line 839 of file ConversionProducer.cc.

References allowTrackBC_, energyTotalBC_, edm::Ptr< T >::isNonnull(), rightBC_, and findQualityFiles::rr.

840  {
841 
842  const reco::CaloClusterPtr& bc_l = ll.second;//can be null, so check isNonnull()
843  const reco::CaloClusterPtr& bc_r = rr.second;
844 
845  //The cuts should be ordered by considering if takes time and if cuts off many fakes
846  if (allowTrackBC_){
847  //check energy of BC
848  double total_e_bc = 0;
849  if (bc_l.isNonnull()) total_e_bc += bc_l->energy();
850  if (rightBC_)
851  if (bc_r.isNonnull())
852  total_e_bc += bc_r->energy();
853 
854  if (total_e_bc < energyTotalBC_) return false;
855  }
856 
857  return true;
858 }
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:152
bool ConversionProducer::checkVertex ( const reco::TransientTrack ttk_l,
const reco::TransientTrack ttk_r,
const MagneticField magField,
reco::Vertex the_vertex 
)
private

Definition at line 863 of file ConversionProducer.cc.

References newFWLiteAna::found, ConversionVertexFinder::run(), and theVertexFinder_.

Referenced by buildCollection().

865  {
866  bool found = false;
867 
868  std::vector<reco::TransientTrack> pair;
869  pair.push_back(ttk_l);
870  pair.push_back(ttk_r);
871 
872  found = theVertexFinder_->run(pair, the_vertex);
873 
874 
875 
876  return found;
877 }
ConversionVertexFinder * theVertexFinder_
TransientVertex run(const std::vector< reco::TransientTrack > &pair)
double ConversionProducer::etaTransformation ( float  EtaParticle,
float  Zvertex 
)
private

Definition at line 881 of file ConversionProducer.cc.

References ETA, etaBarrelEndcap, create_public_lumi_plots::log, PI, R_ECAL, funct::tan(), and Z_Endcap.

Referenced by matchingSC().

881  {
882 
883  //---Definitions
884  const float PI = 3.1415927;
885 
886  //---Definitions for ECAL
887  const float R_ECAL = 136.5;
888  const float Z_Endcap = 328.0;
889  const float etaBarrelEndcap = 1.479;
890 
891  //---ETA correction
892 
893  float Theta = 0.0 ;
894  float ZEcal = R_ECAL*sinh(EtaParticle)+Zvertex;
895 
896  if(ZEcal != 0.0) Theta = atan(R_ECAL/ZEcal);
897  if(Theta<0.0) Theta = Theta+PI ;
898  double ETA = - log(tan(0.5*Theta));
899 
900  if( fabs(ETA) > etaBarrelEndcap )
901  {
902  float Zend = Z_Endcap ;
903  if(EtaParticle<0.0 ) Zend = -Zend ;
904  float Zlen = Zend - Zvertex ;
905  float RR = Zlen/sinh(EtaParticle);
906  Theta = atan(RR/Zend);
907  if(Theta<0.0) Theta = Theta+PI ;
908  ETA = - log(tan(0.5*Theta));
909  }
910  //---Return the result
911  return ETA;
912  //---end
913 }
#define PI
#define ETA
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
static const float etaBarrelEndcap
static const float Z_Endcap
static const float R_ECAL
bool ConversionProducer::getMatchedBC ( const std::multimap< double, reco::CaloClusterPtr > &  bcMap,
const math::XYZPointF trackImpactPosition,
reco::CaloClusterPtr closestBC 
)
private

Definition at line 696 of file ConversionProducer.cc.

References kinem::delta_eta(), kinem::delta_phi(), reco::deltaPhi(), dEtaTkBC_, dPhiTkBC_, and halfWayEta_.

Referenced by buildCollection().

698  {
699  const double track_eta = trackImpactPosition.eta();
700  const double track_phi = trackImpactPosition.phi();
701 
702  double min_eta = 999., min_phi = 999.;
703  reco::CaloClusterPtr closest_bc;
704  for (std::multimap<double, reco::CaloClusterPtr>::const_iterator bc = bcMap.lower_bound(track_eta - halfWayEta_);
705  bc != bcMap.upper_bound(track_eta + halfWayEta_); ++bc){//use eta map to select possible BC collection then loop in
706  const reco::CaloClusterPtr& ebc = bc->second;
707  const double delta_eta = track_eta-(ebc->position().eta());
708  const double delta_phi = reco::deltaPhi(track_phi, (ebc->position().phi()));
709  if (fabs(delta_eta)<dEtaTkBC_ && fabs(delta_phi)<dPhiTkBC_){
710  if (fabs(min_eta)>fabs(delta_eta) && fabs(min_phi)>fabs(delta_phi)){//take the closest to track BC
711  min_eta = delta_eta;
712  min_phi = delta_phi;
713  closest_bc = bc->second;
714  //TODO check if min_eta>delta_eta but min_phi<delta_phi
715  }
716  }
717  }
718 
719  if (min_eta < 999.){
720  closestBC = closest_bc;
721  return true;
722  } else
723  return false;
724 }
double delta_eta(double eta1, double eta2)
Definition: AnglesUtil.h:98
double delta_phi(double ph11, double phi2)
Definition: AnglesUtil.h:91
double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:12
bool ConversionProducer::getTrackImpactPosition ( const reco::Track tk_ref,
const TrackerGeometry trackerGeom,
const MagneticField magField,
math::XYZPointF ew 
)
private

Definition at line 619 of file ConversionProducer.cc.

References alongMomentum, epsilon, PV3DBase< T, PVType, FrameType >::eta(), f, TrajectoryStateOnSurface::globalPosition(), TrajectoryStateOnSurface::isValid(), trajectoryStateTransform::outerStateOnSurface(), makeMuonMisalignmentScenario::rot, and PV3DBase< T, PVType, FrameType >::z().

Referenced by buildCollection().

621  {
622 
623  PropagatorWithMaterial propag( alongMomentum, 0.000511, magField );
624 
626  new BoundCylinder(129.f, GlobalPoint(0.,0.,0.), TkRotation<float>(),
627  new SimpleCylinderBounds( 129, 129, -320.5, 320.5 ) ) );
628  const float epsilon = 0.001;
629  Surface::RotationType rot; // unit rotation matrix
630  const float barrelRadius = 129.f;
631  const float barrelHalfLength = 270.9f;
632  const float endcapRadius = 171.1f;
633  const float endcapZ = 320.5f;
634  ReferenceCountingPointer<BoundCylinder> theBarrel_(new BoundCylinder(barrelRadius, Surface::PositionType(0,0,0), rot,
635  new SimpleCylinderBounds( barrelRadius-epsilon, barrelRadius+epsilon,
636 -barrelHalfLength, barrelHalfLength)));
637  ReferenceCountingPointer<BoundDisk> theNegativeEtaEndcap_(
638  new BoundDisk( Surface::PositionType( 0, 0, -endcapZ), rot,
639  new SimpleDiskBounds( 0, endcapRadius, -epsilon, epsilon)));
640  ReferenceCountingPointer<BoundDisk> thePositiveEtaEndcap_(
641  new BoundDisk( Surface::PositionType( 0, 0, endcapZ), rot,
642  new SimpleDiskBounds( 0, endcapRadius, -epsilon, epsilon)));
643 
644  //const TrajectoryStateOnSurface myTSOS = trajectoryStateTransform::innerStateOnSurface(*(*ref), *trackerGeom, magField);
645  const TrajectoryStateOnSurface myTSOS = trajectoryStateTransform::outerStateOnSurface(*tk_ref, *trackerGeom, magField);
646  TrajectoryStateOnSurface stateAtECAL;
647  stateAtECAL = propag.propagate(myTSOS, *theBarrel_);
648  if (!stateAtECAL.isValid() || ( stateAtECAL.isValid() && fabs(stateAtECAL.globalPosition().eta() ) >1.479f ) ) {
649  //endcap propagator
650  if (myTSOS.globalPosition().z() > 0.) {
651  stateAtECAL = propag.propagate(myTSOS, *thePositiveEtaEndcap_);
652  } else {
653  stateAtECAL = propag.propagate(myTSOS, *theNegativeEtaEndcap_);
654  }
655  }
656  if (stateAtECAL.isValid()){
657  ew = stateAtECAL.globalPosition();
658  return true;
659  }
660  else
661  return false;
662 }
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Cylinder BoundCylinder
Definition: BoundCylinder.h:19
GlobalPoint globalPosition() const
T z() const
Definition: PV3DBase.h:64
double f[11][100]
TrajectoryStateOnSurface outerStateOnSurface(const reco::Track &tk, const TrackingGeometry &geom, const MagneticField *field)
Disk BoundDisk
Definition: BoundDisk.h:64
T eta() const
Definition: PV3DBase.h:76
const double epsilon
bool ConversionProducer::matchingSC ( const std::multimap< double, reco::CaloClusterPtr > &  scMap,
reco::Conversion conv,
reco::CaloClusterPtrVector mSC 
)
private

Definition at line 667 of file ConversionProducer.cc.

References kinem::delta_eta(), kinem::delta_phi(), reco::deltaPhi(), dEtacutForSCmatching_, dPhicutForSCmatching_, etaTransformation(), match(), edm::PtrVector< T >::push_back(), reco::Conversion::refittedPairMomentum(), and reco::Conversion::zOfPrimaryVertexFromTracks().

Referenced by buildCollection().

670  {
671 
672  // double dRMin=999.;
673  double detaMin=999.;
674  double dphiMin=999.;
676  for (std::multimap<double, reco::CaloClusterPtr>::const_iterator scItr = scMap.begin(); scItr != scMap.end(); scItr++) {
677  const reco::CaloClusterPtr& sc = scItr->second;
678  const double delta_phi = reco::deltaPhi( aConv.refittedPairMomentum().phi(), sc->phi());
679  double sceta = sc->eta();
680  double conveta = etaTransformation(aConv.refittedPairMomentum().eta(), aConv.zOfPrimaryVertexFromTracks() );
681  const double delta_eta = fabs(conveta - sceta);
682  if ( fabs(delta_eta) < fabs(detaMin) && fabs(delta_phi) < fabs(dphiMin) ) {
683  detaMin= fabs(delta_eta);
684  dphiMin= fabs(delta_phi);
685  match=sc;
686  }
687  }
688 
689  if ( fabs(detaMin) < dEtacutForSCmatching_ && fabs(dphiMin) < dPhicutForSCmatching_ ) {
690  mSC.push_back(match);
691  return true;
692  } else
693  return false;
694 }
double delta_eta(double eta1, double eta2)
Definition: AnglesUtil.h:98
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:137
double delta_phi(double ph11, double phi2)
Definition: AnglesUtil.h:91
double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:12
double etaTransformation(float EtaParticle, float Zvertex)
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:6
bool ConversionProducer::preselectTrackPair ( const reco::TransientTrack ttk_l,
const reco::TransientTrack ttk_r,
double &  appDist 
)
private

Definition at line 779 of file ConversionProducer.cc.

References abs, allowDeltaCot_, allowMinApproach_, TangentApproachInRPhi::calculate(), TangentApproachInRPhi::crossingPoint(), deltaCotTheta_, dzCut_, reco::Track::innerMomentum(), reco::TransientTrack::innermostMeasurementState(), maxTrackRho_, maxTrackZ_, minApproachHigh_, PV3DBase< T, PVType, FrameType >::perp(), TangentApproachInRPhi::perpdist(), r_cut, rho, TangentApproachInRPhi::status(), funct::tan(), reco::TransientTrack::track(), TangentApproachInRPhi::trajectoryParameters(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by buildCollection().

780  {
781 
782 
783  double dCotTheta = 1./tan(ttk_l.track().innerMomentum().theta()) - 1./tan(ttk_r.track().innerMomentum().theta());
784  if (allowDeltaCot_ && (std::abs(dCotTheta) > deltaCotTheta_)) {
785  return false;
786  }
787 
788  //non-conversion hypothesis, reject prompt track pairs
789  ClosestApproachInRPhi closest;
790  closest.calculate(ttk_l.innermostMeasurementState(),ttk_r.innermostMeasurementState());
791  if (!closest.status()) {
792  return false;
793  }
794 
795  if (closest.crossingPoint().perp() < r_cut) {
796  return false;
797  }
798 
799 
800  //compute tangent point btw tracks (conversion hypothesis)
801  TangentApproachInRPhi tangent;
803  if (!tangent.status()) {
804  return false;
805  }
806 
807  GlobalPoint tangentPoint = tangent.crossingPoint();
808  double rho = tangentPoint.perp();
809 
810  //reject candidates well outside of tracker bounds
811  if (rho > maxTrackRho_) {
812  return false;
813  }
814 
815  if (std::abs(tangentPoint.z()) > maxTrackZ_) {
816  return false;
817  }
818 
819  std::pair<GlobalTrajectoryParameters,GlobalTrajectoryParameters> trajs = tangent.trajectoryParameters();
820 
821  //very large separation in z, no hope
822  if (std::abs(trajs.first.position().z() - trajs.second.position().z()) > dzCut_) {
823  return false;
824  }
825 
826 
827  float minApproach = tangent.perpdist();
828  appDist = minApproach;
829 
830  if (allowMinApproach_ && (minApproach < minApproachLow_ || minApproach > minApproachHigh_) ) {
831  return false;
832  }
833 
834  return true;
835 
836 
837 }
T perp() const
Definition: PV3DBase.h:72
std::pair< GlobalTrajectoryParameters, GlobalTrajectoryParameters > trajectoryParameters() const
Definition: DDAxes.h:10
#define abs(x)
Definition: mlp_lapack.h:159
TrajectoryStateOnSurface innermostMeasurementState() const
virtual GlobalPoint crossingPoint() const
T z() const
Definition: PV3DBase.h:64
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
const Track & track() const
virtual bool status() const
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
Definition: Track.h:45
virtual bool calculate(const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb)
void ConversionProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 178 of file ConversionProducer.cc.

References buildCollection(), buildSuperAndBasicClusterGeoMap(), ConvertedPhotonCollection_, edm::EventSetup::get(), edm::Event::getByLabel(), maxNumOfTrackInPU_, edm::Event::put(), src_, thettbuilder_, usePvtx_, GoodVertex_cfg::vertexCollection, and vertexProducer_.

179 {
180  using namespace edm;
181 
182  reco::ConversionCollection outputConvPhotonCollection;
183  std::auto_ptr<reco::ConversionCollection> outputConvPhotonCollection_p(new reco::ConversionCollection);
184 
185  //std::cout << " ConversionProducer::produce " << std::endl;
186  //Read multiple track input collections
187 
188  edm::Handle<edm::View<reco::ConversionTrack> > trackCollectionHandle;
189  iEvent.getByLabel(src_,trackCollectionHandle);
190 
191  //build map of ConversionTracks ordered in eta
192  std::multimap<float, edm::Ptr<reco::ConversionTrack> > convTrackMap;
193  for (edm::PtrVector<reco::ConversionTrack>::const_iterator tk_ref = trackCollectionHandle->ptrVector().begin(); tk_ref != trackCollectionHandle->ptrVector().end(); ++tk_ref ){
194  convTrackMap.insert(std::make_pair((*tk_ref)->track()->eta(),*tk_ref));
195  }
196 
199  if (usePvtx_){
200  iEvent.getByLabel(vertexProducer_, vertexHandle);
201  if (!vertexHandle.isValid()) {
202  edm::LogError("ConversionProducer") << "Error! Can't get the product primary Vertex Collection "<< "\n";
203  usePvtx_ = false;
204  }
205  if (usePvtx_)
206  vertexCollection = *(vertexHandle.product());
207  }
208 
209  edm::ESHandle<TransientTrackBuilder> hTransientTrackBuilder;
210  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",hTransientTrackBuilder);
211  thettbuilder_ = hTransientTrackBuilder.product();
212 
213  reco::Vertex the_pvtx;
214  //because the priamry vertex is sorted by quality, the first one is the best
215  if (!vertexCollection.empty())
216  the_pvtx = *(vertexCollection.begin());
217 
218  if (trackCollectionHandle->size()> maxNumOfTrackInPU_){
219  iEvent.put( outputConvPhotonCollection_p, ConvertedPhotonCollection_);
220  return;
221  }
222 
223 
224  // build Super and Basic cluster geometry map to search in eta bounds for clusters
225  std::multimap<double, reco::CaloClusterPtr> basicClusterPtrs;
226  std::multimap<double, reco::CaloClusterPtr> superClusterPtrs;
227 
228 
229  buildSuperAndBasicClusterGeoMap(iEvent,basicClusterPtrs,superClusterPtrs);
230 
231  buildCollection( iEvent, iSetup, convTrackMap, superClusterPtrs, basicClusterPtrs, the_pvtx, outputConvPhotonCollection);//allow empty basicClusterPtrs
232 
233  outputConvPhotonCollection_p->assign(outputConvPhotonCollection.begin(), outputConvPhotonCollection.end());
234  iEvent.put( outputConvPhotonCollection_p, ConvertedPhotonCollection_);
235 
236 }
unsigned int maxNumOfTrackInPU_
const TransientTrackBuilder * thettbuilder_
void buildCollection(edm::Event &iEvent, const edm::EventSetup &iSetup, const std::multimap< float, edm::Ptr< reco::ConversionTrack > > &allTracks, const std::multimap< double, reco::CaloClusterPtr > &superClusterPtrs, const std::multimap< double, reco::CaloClusterPtr > &basicClusterPtrs, const reco::Vertex &the_pvtx, reco::ConversionCollection &outputConvPhotonCollection)
void buildSuperAndBasicClusterGeoMap(const edm::Event &, std::multimap< double, reco::CaloClusterPtr > &basicClusterPtrs, std::multimap< double, reco::CaloClusterPtr > &superClusterPtrs)
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
tuple vertexCollection
std::vector< Conversion > ConversionCollection
collectin of Conversion objects
Definition: ConversionFwd.h:9
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
const T & get() const
Definition: EventSetup.h:55
std::string ConvertedPhotonCollection_
math::XYZPointF ConversionProducer::toFConverterP ( const math::XYZPoint val)
inlineprivate

Definition at line 188 of file ConversionProducer.h.

Referenced by buildCollection().

188  {
189  return math::XYZPointF(val.x(),val.y(),val.z());
190  }
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
Definition: Point3D.h:11
math::XYZVectorF ConversionProducer::toFConverterV ( const math::XYZVector val)
inlineprivate

Definition at line 192 of file ConversionProducer.h.

Referenced by buildCollection().

192  {
193  return math::XYZVectorF(val.x(),val.y(),val.z());
194  }
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< float > > XYZVectorF
spatial vector with cartesian internal representation
Definition: Vector3D.h:18
bool ConversionProducer::trackD0Cut ( const edm::RefToBase< reco::Track > &  ref)
inlineprivate

Definition at line 608 of file ConversionProducer.cc.

References allowD0_, reco::TrackBase::charge(), reco::TrackBase::d0(), d0Cut_, and reco::TrackBase::d0Error().

Referenced by buildCollection().

608  {
609  //NOTE if not allow d0 cut, always true
610  return ((!allowD0_) || !(ref->d0()*ref->charge()/ref->d0Error()<d0Cut_));
611 }
double d0Error() const
error on d0
Definition: TrackBase.h:211
double d0() const
dxy parameter in perigee convention (d0 = - dxy)
Definition: TrackBase.h:123
int charge() const
track electric charge
Definition: TrackBase.h:113
bool ConversionProducer::trackD0Cut ( const edm::RefToBase< reco::Track > &  ref,
const reco::Vertex the_pvtx 
)
inlineprivate

Definition at line 613 of file ConversionProducer.cc.

References allowD0_, reco::TrackBase::charge(), d0Cut_, reco::TrackBase::dxy(), reco::TrackBase::dxyError(), and reco::Vertex::position().

613  {
614  //
615  return ((!allowD0_) || !(-ref->dxy(the_pvtx.position())*ref->charge()/ref->dxyError()<d0Cut_));
616 }
double dxyError() const
error on dxy
Definition: TrackBase.h:209
const Point & position() const
position
Definition: Vertex.h:93
int charge() const
track electric charge
Definition: TrackBase.h:113
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:121
bool ConversionProducer::trackQualityFilter ( const edm::RefToBase< reco::Track > &  ref,
bool  isLeft 
)
inlineprivate

Definition at line 597 of file ConversionProducer.cc.

References reco::Track::found(), maxChi2Left_, maxChi2Right_, minHitsLeft_, minHitsRight_, and reco::TrackBase::normalizedChi2().

Referenced by buildCollection().

597  {
598  bool pass = true;
599  if (isLeft){
600  pass = (ref->normalizedChi2() < maxChi2Left_ && ref->found() >= minHitsLeft_);
601  } else {
602  pass = (ref->normalizedChi2() < maxChi2Right_ && ref->found() >= minHitsRight_);
603  }
604 
605  return pass;
606 }
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:111
unsigned short found() const
Number of valid hits on track.
Definition: Track.h:100

Member Data Documentation

std::string ConversionProducer::algoName_
private

Definition at line 85 of file ConversionProducer.h.

Referenced by buildCollection(), and ConversionProducer().

bool ConversionProducer::allowD0_
private

Definition at line 98 of file ConversionProducer.h.

Referenced by ConversionProducer(), and trackD0Cut().

bool ConversionProducer::allowDeltaCot_
private

Definition at line 98 of file ConversionProducer.h.

Referenced by ConversionProducer(), and preselectTrackPair().

bool ConversionProducer::allowDeltaPhi_
private

Definition at line 98 of file ConversionProducer.h.

Referenced by checkPhi(), and ConversionProducer().

bool ConversionProducer::allowMinApproach_
private

Definition at line 98 of file ConversionProducer.h.

Referenced by ConversionProducer(), and preselectTrackPair().

bool ConversionProducer::allowOppCharge_
private

Definition at line 98 of file ConversionProducer.h.

Referenced by buildCollection(), and ConversionProducer().

bool ConversionProducer::allowSingleLeg_
private

Definition at line 132 of file ConversionProducer.h.

Referenced by ConversionProducer().

bool ConversionProducer::allowTrackBC_
private

Definition at line 98 of file ConversionProducer.h.

Referenced by buildCollection(), checkTrackPair(), and ConversionProducer().

bool ConversionProducer::allowVertex_
private

Definition at line 98 of file ConversionProducer.h.

Referenced by ConversionProducer().

edm::InputTag ConversionProducer::bcBarrelCollection_
private

Definition at line 94 of file ConversionProducer.h.

Referenced by buildSuperAndBasicClusterGeoMap(), and ConversionProducer().

edm::InputTag ConversionProducer::bcEndcapCollection_
private

Definition at line 95 of file ConversionProducer.h.

Referenced by buildSuperAndBasicClusterGeoMap(), and ConversionProducer().

bool ConversionProducer::bypassPreselEcal_
private

Definition at line 100 of file ConversionProducer.h.

Referenced by buildCollection(), and ConversionProducer().

bool ConversionProducer::bypassPreselEcalEcal_
private

Definition at line 100 of file ConversionProducer.h.

Referenced by buildCollection(), and ConversionProducer().

bool ConversionProducer::bypassPreselGsf_
private

Definition at line 100 of file ConversionProducer.h.

Referenced by buildCollection(), and ConversionProducer().

std::string ConversionProducer::ConvertedPhotonCollection_
private

Definition at line 96 of file ConversionProducer.h.

Referenced by ConversionProducer(), and produce().

double ConversionProducer::d0Cut_
private

Definition at line 119 of file ConversionProducer.h.

Referenced by ConversionProducer(), and trackD0Cut().

double ConversionProducer::deltaCotTheta_
private

Definition at line 126 of file ConversionProducer.h.

Referenced by ConversionProducer(), and preselectTrackPair().

double ConversionProducer::deltaEta_
private

Definition at line 108 of file ConversionProducer.h.

Referenced by buildCollection(), and ConversionProducer().

double ConversionProducer::deltaPhi_
private

Definition at line 126 of file ConversionProducer.h.

Referenced by checkPhi(), and ConversionProducer().

double ConversionProducer::dEtacutForSCmatching_
private

Definition at line 115 of file ConversionProducer.h.

Referenced by ConversionProducer(), and matchingSC().

double ConversionProducer::dEtaTkBC_
private

Definition at line 121 of file ConversionProducer.h.

Referenced by ConversionProducer(), and getMatchedBC().

double ConversionProducer::dPhicutForSCmatching_
private

Definition at line 116 of file ConversionProducer.h.

Referenced by ConversionProducer(), and matchingSC().

double ConversionProducer::dPhiTkBC_
private

Definition at line 121 of file ConversionProducer.h.

Referenced by ConversionProducer(), and getMatchedBC().

double ConversionProducer::dzCut_
private

Definition at line 120 of file ConversionProducer.h.

Referenced by ConversionProducer(), and preselectTrackPair().

double ConversionProducer::energyBC_
private

Definition at line 117 of file ConversionProducer.h.

Referenced by buildSuperAndBasicClusterGeoMap(), and ConversionProducer().

double ConversionProducer::energyTotalBC_
private

Definition at line 118 of file ConversionProducer.h.

Referenced by buildCollection(), checkTrackPair(), and ConversionProducer().

double ConversionProducer::halfWayEta_
private

Definition at line 110 of file ConversionProducer.h.

Referenced by ConversionProducer(), and getMatchedBC().

double ConversionProducer::halfWayPhi_
private

Definition at line 110 of file ConversionProducer.h.

double ConversionProducer::maxChi2Left_
private

Definition at line 123 of file ConversionProducer.h.

Referenced by ConversionProducer(), and trackQualityFilter().

double ConversionProducer::maxChi2Right_
private

Definition at line 123 of file ConversionProducer.h.

Referenced by ConversionProducer(), and trackQualityFilter().

unsigned int ConversionProducer::maxNumOfTrackInPU_
private

Definition at line 111 of file ConversionProducer.h.

Referenced by ConversionProducer(), and produce().

double ConversionProducer::maxTrackRho_
private

Definition at line 113 of file ConversionProducer.h.

Referenced by ConversionProducer(), and preselectTrackPair().

double ConversionProducer::maxTrackZ_
private

Definition at line 112 of file ConversionProducer.h.

Referenced by ConversionProducer(), and preselectTrackPair().

double ConversionProducer::minApproachHigh_
private

Definition at line 126 of file ConversionProducer.h.

Referenced by ConversionProducer(), and preselectTrackPair().

double ConversionProducer::minApproachLow_
private

Definition at line 126 of file ConversionProducer.h.

Referenced by ConversionProducer().

double ConversionProducer::minHitsLeft_
private

Definition at line 124 of file ConversionProducer.h.

Referenced by ConversionProducer(), and trackQualityFilter().

double ConversionProducer::minHitsRight_
private

Definition at line 124 of file ConversionProducer.h.

Referenced by ConversionProducer(), and trackQualityFilter().

double ConversionProducer::minSCEt_
private

Definition at line 114 of file ConversionProducer.h.

Referenced by buildSuperAndBasicClusterGeoMap(), and ConversionProducer().

double ConversionProducer::r_cut
private

Definition at line 129 of file ConversionProducer.h.

Referenced by ConversionProducer(), and preselectTrackPair().

bool ConversionProducer::rightBC_
private

Definition at line 133 of file ConversionProducer.h.

Referenced by checkTrackPair(), and ConversionProducer().

edm::InputTag ConversionProducer::scBarrelProducer_
private

Definition at line 92 of file ConversionProducer.h.

Referenced by buildSuperAndBasicClusterGeoMap(), and ConversionProducer().

edm::InputTag ConversionProducer::scEndcapProducer_
private

Definition at line 93 of file ConversionProducer.h.

Referenced by buildSuperAndBasicClusterGeoMap(), and ConversionProducer().

edm::InputTag ConversionProducer::src_
private

Definition at line 90 of file ConversionProducer.h.

Referenced by ConversionProducer(), and produce().

const TransientTrackBuilder* ConversionProducer::thettbuilder_
private

Definition at line 106 of file ConversionProducer.h.

Referenced by buildCollection(), ConversionProducer(), and produce().

ConversionVertexFinder* ConversionProducer::theVertexFinder_
private

Definition at line 104 of file ConversionProducer.h.

Referenced by checkVertex(), ConversionProducer(), and ~ConversionProducer().

bool ConversionProducer::usePvtx_
private

Definition at line 102 of file ConversionProducer.h.

Referenced by ConversionProducer(), and produce().

std::string ConversionProducer::vertexProducer_
private

Definition at line 103 of file ConversionProducer.h.

Referenced by ConversionProducer(), and produce().

double ConversionProducer::vtxChi2_
private

Definition at line 130 of file ConversionProducer.h.

Referenced by buildCollection(), and ConversionProducer().