CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
TwoBodyDecayConstraintProducer Class Reference

#include <RecoTracker/ConstraintProducerTest/src/TwoBodyDecayConstraintProducer.cc>

Inheritance diagram for TwoBodyDecayConstraintProducer:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 TwoBodyDecayConstraintProducer (const edm::ParameterSet &)
 
 ~TwoBodyDecayConstraintProducer () override=default
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

std::pair< bool, TrajectoryStateOnSurfaceinnermostState (const reco::TransientTrack &ttrack) const
 
bool match (const TrajectoryStateOnSurface &newTsos, const TrajectoryStateOnSurface &oldTsos) const
 
void produce (edm::StreamID streamid, edm::Event &, const edm::EventSetup &) const override
 

Private Attributes

const edm::InputTag bsSrcTag_
 
edm::EDGetTokenT< reco::BeamSpotbsToken_
 
const double chi2CutValue_
 
const double errorRescaleValue_
 
const double primaryMass_
 
const double primaryWidth_
 
const double secondaryMass_
 
const double sigmaPositionCutValue_
 
const edm::InputTag srcTag_
 
const TwoBodyDecayFitter tbdFitter_
 
edm::EDGetTokenT< reco::TrackCollectiontrackCollToken_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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

Description: Produces track parameter constraints for refitting tracks, according to information TwoBodyDecay kinematic fit.

Original Author: Edmund Widl

Definition at line 39 of file TwoBodyDecayConstraintProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 75 of file TwoBodyDecayConstraintProducer.cc.

References bsSrcTag_, bsToken_, srcTag_, and trackCollToken_.

75  :
76  srcTag_( iConfig.getParameter<edm::InputTag>( "src" ) ),
77  bsSrcTag_( iConfig.getParameter<edm::InputTag>( "beamSpot" ) ),
78  tbdFitter_( iConfig ),
79  primaryMass_( iConfig.getParameter<double>( "primaryMass" ) ),
80  primaryWidth_( iConfig.getParameter<double>( "primaryWidth" ) ),
81  secondaryMass_( iConfig.getParameter<double>( "secondaryMass" ) ),
82  sigmaPositionCutValue_( iConfig.getParameter<double>( "sigmaPositionCut" ) ),
83  chi2CutValue_( iConfig.getParameter<double>( "chi2Cut" ) ),
84  errorRescaleValue_( iConfig.getParameter<double>( "rescaleError" ) )
85 {
86  trackCollToken_ = consumes<reco::TrackCollection>(edm::InputTag(srcTag_));
87  bsToken_ = consumes<reco::BeamSpot>(edm::InputTag(bsSrcTag_));
88 
89  produces<std::vector<TrackParamConstraint> >();
90  produces<TrackParamConstraintAssociationCollection>();
91 
92 // //debug
93 // histos_["deltaEta1"] = new TH1F( "deltaEta1", "deltaEta1", 200, -1., 1. );
94 // histos_["deltaP1"] = new TH1F( "deltaP1", "deltaP1", 200, -50., 50. );
95 
96 // histos_["deltaEta2"] = new TH1F( "deltaEta2", "deltaEta2", 200, -1., 1. );
97 // histos_["deltaP2"] = new TH1F( "deltaP2", "deltaP2", 200, -50., 50. );
98 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::BeamSpot > bsToken_
edm::EDGetTokenT< reco::TrackCollection > trackCollToken_
TwoBodyDecayConstraintProducer::~TwoBodyDecayConstraintProducer ( )
overridedefault

Member Function Documentation

std::pair< bool, TrajectoryStateOnSurface > TwoBodyDecayConstraintProducer::innermostState ( const reco::TransientTrack ttrack) const
private

Definition at line 188 of file TwoBodyDecayConstraintProducer.cc.

References TrajectoryStateOnSurface::globalPosition(), reco::TransientTrack::innermostMeasurementState(), insideOut, reco::TransientTrack::outermostMeasurementState(), and PV3DBase< T, PVType, FrameType >::perp().

Referenced by produce().

189 {
190  double outerR = ttrack.outermostMeasurementState().globalPosition().perp();
191  double innerR = ttrack.innermostMeasurementState().globalPosition().perp();
192  bool insideOut = ( outerR > innerR );
193  return std::make_pair( insideOut, insideOut ? ttrack.innermostMeasurementState() : ttrack.outermostMeasurementState() );
194 }
T perp() const
Definition: PV3DBase.h:72
GlobalPoint globalPosition() const
TrajectoryStateOnSurface innermostMeasurementState() const
TrajectoryStateOnSurface outermostMeasurementState() const
bool TwoBodyDecayConstraintProducer::match ( const TrajectoryStateOnSurface newTsos,
const TrajectoryStateOnSurface oldTsos 
) const
private

Definition at line 198 of file TwoBodyDecayConstraintProducer.cc.

References DEFINE_FWK_MODULE, TrajectoryStateOnSurface::localPosition(), sigmaPositionCutValue_, PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

Referenced by produce().

200 {
201  LocalPoint lp1 = newTsos.localPosition();
202  LocalPoint lp2 = oldTsos.localPosition();
203 
204  double deltaX = lp1.x() - lp2.x();
205  double deltaY = lp1.y() - lp2.y();
206 
207  return ( ( fabs(deltaX) < sigmaPositionCutValue_ ) && ( fabs(deltaY) < sigmaPositionCutValue_ ) );
208 }
T y() const
Definition: PV3DBase.h:63
T x() const
Definition: PV3DBase.h:62
void TwoBodyDecayConstraintProducer::produce ( edm::StreamID  streamid,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
overrideprivate

Construct virtual measurement (for TBD)

Get transient tracks from track collection

Fit the TBD

Get the innermost trajectory states

Construct the TBD trajectory states

Match the old and the new estimates for the trajectory state

Definition at line 101 of file TwoBodyDecayConstraintProducer.cc.

References ecalDrivenElectronSeedsParameters_cff::beamSpot, bsToken_, TwoBodyDecay::chi2(), chi2CutValue_, errorRescaleValue_, TwoBodyDecayFitter::estimate(), edm::EventSetup::get(), edm::Event::getByToken(), edm::Event::getRefBeforePut(), innermostState(), TwoBodyDecay::isValid(), match(), eostools::move(), or, convertSQLitetoXML_cfg::output, primaryMass_, primaryWidth_, edm::Handle< T >::product(), edm::ESHandle< T >::product(), edm::Event::put(), secondaryMass_, reco::TransientTrack::setES(), tbdFitter_, pfDisplacedTrackerVertex_cfi::trackColl, trackCollToken_, and funct::true.

102 {
103  using namespace edm;
104 
106  iEvent.getByToken(trackCollToken_, trackColl);
107 
109  iEvent.getByToken(bsToken_, beamSpot);
110 
111  ESHandle<MagneticField> magField;
112  iSetup.get<IdealMagneticFieldRecord>().get( magField );
113 
114  edm::RefProd<std::vector<TrackParamConstraint> > rPairs = iEvent.getRefBeforePut<std::vector<TrackParamConstraint> >();
115  std::unique_ptr<std::vector<TrackParamConstraint> > pairs(new std::vector<TrackParamConstraint>);
116  std::unique_ptr<TrackParamConstraintAssociationCollection> output(new TrackParamConstraintAssociationCollection(trackColl, rPairs));
117 
118  if ( trackColl->size() == 2 )
119  {
122 
124  std::vector<reco::TransientTrack> ttracks(2);
125  ttracks[0] = reco::TransientTrack( reco::TrackRef( trackColl, 0 ), magField.product() );
126  ttracks[0].setES( iSetup );
127  ttracks[1] = reco::TransientTrack( reco::TrackRef( trackColl, 1 ), magField.product() );
128  ttracks[1].setES( iSetup );
129 
131  TwoBodyDecay tbd = tbdFitter_.estimate( ttracks, vm );
132 
133  if ( !tbd.isValid() or ( tbd.chi2() > chi2CutValue_ ) ) return;
134 
136  std::pair<bool, TrajectoryStateOnSurface> oldInnermostState1 = innermostState( ttracks[0] );
137  std::pair<bool, TrajectoryStateOnSurface> oldInnermostState2 = innermostState( ttracks[1] );
138  if ( !oldInnermostState1.second.isValid() || !oldInnermostState2.second.isValid() ) return;
139 
141  TwoBodyDecayTrajectoryState::TsosContainer trackTsos( oldInnermostState1.second, oldInnermostState2.second );
142  TwoBodyDecayTrajectoryState tbdTrajState( trackTsos, tbd, secondaryMass_, magField.product(), true );
143  if ( !tbdTrajState.isValid() ) return;
144 
146  bool match1 = match( tbdTrajState.trajectoryStates(true).first, oldInnermostState1.second );
147  bool match2 = match( tbdTrajState.trajectoryStates(true).second, oldInnermostState2.second );
148  if ( !match1 || !match2 ) return;
149 
150  // re-scale error of constraintTsos
151  tbdTrajState.rescaleError( errorRescaleValue_ );
152 
153  // produce constraint for first track
154  pairs->push_back(tbdTrajState.trajectoryStates(true).first);
155  output->insert( reco::TrackRef(trackColl,0), edm::Ref<std::vector<TrackParamConstraint> >(rPairs,0) );
156 
157  // produce constraint for second track
158  pairs->push_back(tbdTrajState.trajectoryStates(true).second);
159  output->insert( reco::TrackRef(trackColl,1), edm::Ref<std::vector<TrackParamConstraint> >(rPairs,1) );
160 
161 // // debug
162 // if ( tbd.isValid() ) {
163 // TwoBodyDecayModel model;
164 // const std::pair< AlgebraicVector, AlgebraicVector > fitMomenta = model.cartesianSecondaryMomenta( tbd );
165 
166 // TLorentzVector recoMomentum1( ttracks[0].track().px(), ttracks[0].track().py(), ttracks[0].track().pz(),
167 // sqrt((ttracks[0].track().p()*ttracks[0].track().p())+0.105658*0.105658) );
168 // TLorentzVector fitMomentum1( fitMomenta.first[0], fitMomenta.first[1], fitMomenta.first[2],
169 // sqrt( fitMomenta.first.normsq()+0.105658*0.105658) );
170 // histos_["deltaP1"]->Fill( recoMomentum1.P() - fitMomentum1.P() );
171 // histos_["deltaEta1"]->Fill( recoMomentum1.Eta() - fitMomentum1.Eta() );
172 
173 // TLorentzVector recoMomentum2( ttracks[1].track().px(), ttracks[1].track().py(), ttracks[1].track().pz(),
174 // sqrt((ttracks[1].track().p()*ttracks[1].track().p())+0.105658*0.105658) );
175 // TLorentzVector fitMomentum2( fitMomenta.second[0], fitMomenta.second[1], fitMomenta.second[2],
176 // sqrt( fitMomenta.second.normsq()+0.105658*0.105658) );
177 // histos_["deltaP2"]->Fill( recoMomentum2.P() - fitMomentum2.P() );
178 // histos_["deltaEta2"]->Fill( recoMomentum2.Eta() - fitMomentum2.Eta() );
179 // }
180  }
181 
182  iEvent.put(std::move(pairs));
183  iEvent.put(std::move(output));
184 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
virtual const TwoBodyDecay estimate(const std::vector< reco::TransientTrack > &tracks, const TwoBodyDecayVirtualMeasurement &vm) const
std::pair< bool, TrajectoryStateOnSurface > innermostState(const reco::TransientTrack &ttrack) const
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
edm::EDGetTokenT< reco::BeamSpot > bsToken_
RefProd< PROD > getRefBeforePut()
Definition: Event.h:150
void setES(const edm::EventSetup &es)
bool isValid(void) const
Definition: TwoBodyDecay.h:46
T const * product() const
Definition: Handle.h:74
std::pair< TrajectoryStateOnSurface, TrajectoryStateOnSurface > TsosContainer
double chi2(void) const
Definition: TwoBodyDecay.h:44
edm::EDGetTokenT< reco::TrackCollection > trackCollToken_
HLT enums.
T get() const
Definition: EventSetup.h:71
T const * product() const
Definition: ESHandle.h:86
bool match(const TrajectoryStateOnSurface &newTsos, const TrajectoryStateOnSurface &oldTsos) const
def move(src, dest)
Definition: eostools.py:511
edm::AssociationMap< edm::OneToOne< reco::TrackCollection, std::vector< TrackParamConstraint > > > TrackParamConstraintAssociationCollection

Member Data Documentation

const edm::InputTag TwoBodyDecayConstraintProducer::bsSrcTag_
private

Definition at line 55 of file TwoBodyDecayConstraintProducer.cc.

Referenced by TwoBodyDecayConstraintProducer().

edm::EDGetTokenT<reco::BeamSpot> TwoBodyDecayConstraintProducer::bsToken_
private

Definition at line 68 of file TwoBodyDecayConstraintProducer.cc.

Referenced by produce(), and TwoBodyDecayConstraintProducer().

const double TwoBodyDecayConstraintProducer::chi2CutValue_
private

Definition at line 64 of file TwoBodyDecayConstraintProducer.cc.

Referenced by produce().

const double TwoBodyDecayConstraintProducer::errorRescaleValue_
private

Definition at line 65 of file TwoBodyDecayConstraintProducer.cc.

Referenced by produce().

const double TwoBodyDecayConstraintProducer::primaryMass_
private

Definition at line 59 of file TwoBodyDecayConstraintProducer.cc.

Referenced by produce().

const double TwoBodyDecayConstraintProducer::primaryWidth_
private

Definition at line 60 of file TwoBodyDecayConstraintProducer.cc.

Referenced by produce().

const double TwoBodyDecayConstraintProducer::secondaryMass_
private

Definition at line 61 of file TwoBodyDecayConstraintProducer.cc.

Referenced by produce().

const double TwoBodyDecayConstraintProducer::sigmaPositionCutValue_
private

Definition at line 63 of file TwoBodyDecayConstraintProducer.cc.

Referenced by match().

const edm::InputTag TwoBodyDecayConstraintProducer::srcTag_
private

Definition at line 54 of file TwoBodyDecayConstraintProducer.cc.

Referenced by TwoBodyDecayConstraintProducer().

const TwoBodyDecayFitter TwoBodyDecayConstraintProducer::tbdFitter_
private

Definition at line 57 of file TwoBodyDecayConstraintProducer.cc.

Referenced by produce().

edm::EDGetTokenT<reco::TrackCollection> TwoBodyDecayConstraintProducer::trackCollToken_
private

Definition at line 67 of file TwoBodyDecayConstraintProducer.cc.

Referenced by produce(), and TwoBodyDecayConstraintProducer().