CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes
TwoBodyDecayMomConstraintProducer Class Reference

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

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

Public Member Functions

 TwoBodyDecayMomConstraintProducer (const edm::ParameterSet &)
 
 ~TwoBodyDecayMomConstraintProducer () 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 Types

enum  MomentumForRefitting { atVertex, atInnermostSurface }
 

Private Member Functions

std::pair< bool, TrajectoryStateOnSurfaceinnermostState (const reco::TransientTrack &ttrack) const
 
bool match (const TrajectoryStateOnSurface &newTsos, const TrajectoryStateOnSurface &oldTsos) const
 
std::pair< double, double > momentaAtInnermostSurface (const TwoBodyDecay &tbd, const std::vector< reco::TransientTrack > &ttracks, const MagneticField *magField) const
 
std::pair< double, double > momentaAtVertex (const TwoBodyDecay &tbd) const
 
void produce (edm::StreamID streamid, edm::Event &, const edm::EventSetup &) const override
 

Static Private Member Functions

static MomentumForRefitting momentumForRefittingFromString (std::string momentumForRefittingString)
 

Private Attributes

const edm::InputTag bsSrcTag_
 
edm::EDGetTokenT< reco::BeamSpotbsToken_
 
const double chi2CutValue_
 
const double fixedMomentumError_
 
const MomentumForRefitting momentumForRefitting_
 
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 40 of file TwoBodyDecayMomConstraintProducer.cc.

Member Enumeration Documentation

Constructor & Destructor Documentation

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

Definition at line 87 of file TwoBodyDecayMomConstraintProducer.cc.

References bsSrcTag_, bsToken_, srcTag_, and trackCollToken_.

87  :
88  srcTag_( iConfig.getParameter<edm::InputTag>( "src" ) ),
89  bsSrcTag_( iConfig.getParameter<edm::InputTag>( "beamSpot" ) ),
90  tbdFitter_( iConfig ),
91  primaryMass_( iConfig.getParameter<double>( "primaryMass" ) ),
92  primaryWidth_( iConfig.getParameter<double>( "primaryWidth" ) ),
93  secondaryMass_( iConfig.getParameter<double>( "secondaryMass" ) ),
94  sigmaPositionCutValue_( iConfig.getParameter<double>( "sigmaPositionCut" ) ),
95  chi2CutValue_( iConfig.getParameter<double>( "chi2Cut" ) ),
96  fixedMomentumError_( iConfig.getParameter<double>( "fixedMomentumError" ) ),
97  momentumForRefitting_( momentumForRefittingFromString( iConfig.getParameter<std::string>( "momentumForRefitting" ) ) )
98 {
99  trackCollToken_ = consumes<reco::TrackCollection>(edm::InputTag(srcTag_));
100  bsToken_ = consumes<reco::BeamSpot>(edm::InputTag(bsSrcTag_));
101 
102  produces< std::vector<MomentumConstraint> >();
103  produces<TrackMomConstraintAssociationCollection>();
104 
105 // //debug
106 // histos_["deltaEta1"] = new TH1F( "deltaEta1", "deltaEta1", 200, -1., 1. );
107 // histos_["deltaP1"] = new TH1F( "deltaP1", "deltaP1", 200, -50., 50. );
108 
109 // histos_["deltaEta2"] = new TH1F( "deltaEta2", "deltaEta2", 200, -1., 1. );
110 // histos_["deltaP2"] = new TH1F( "deltaP2", "deltaP2", 200, -50., 50. );
111 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::TrackCollection > trackCollToken_
static MomentumForRefitting momentumForRefittingFromString(std::string momentumForRefittingString)
edm::EDGetTokenT< reco::BeamSpot > bsToken_
TwoBodyDecayMomConstraintProducer::~TwoBodyDecayMomConstraintProducer ( )
overridedefault

Member Function Documentation

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

Definition at line 237 of file TwoBodyDecayMomConstraintProducer.cc.

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

Referenced by momentaAtInnermostSurface().

238 {
239  double outerR = ttrack.outermostMeasurementState().globalPosition().perp();
240  double innerR = ttrack.innermostMeasurementState().globalPosition().perp();
241  bool insideOut = ( outerR > innerR );
242  return std::make_pair( insideOut, insideOut ? ttrack.innermostMeasurementState() : ttrack.outermostMeasurementState() );
243 }
T perp() const
Definition: PV3DBase.h:72
GlobalPoint globalPosition() const
TrajectoryStateOnSurface innermostMeasurementState() const
TrajectoryStateOnSurface outermostMeasurementState() const
bool TwoBodyDecayMomConstraintProducer::match ( const TrajectoryStateOnSurface newTsos,
const TrajectoryStateOnSurface oldTsos 
) const
private

Definition at line 247 of file TwoBodyDecayMomConstraintProducer.cc.

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

Referenced by momentaAtInnermostSurface().

249 {
250  LocalPoint lp1 = newTsos.localPosition();
251  LocalPoint lp2 = oldTsos.localPosition();
252 
253  double deltaX = lp1.x() - lp2.x();
254  double deltaY = lp1.y() - lp2.y();
255 
256  return ( ( fabs(deltaX) < sigmaPositionCutValue_ ) && ( fabs(deltaY) < sigmaPositionCutValue_ ) );
257 }
T y() const
Definition: PV3DBase.h:63
T x() const
Definition: PV3DBase.h:62
std::pair< double, double > TwoBodyDecayMomConstraintProducer::momentaAtInnermostSurface ( const TwoBodyDecay tbd,
const std::vector< reco::TransientTrack > &  ttracks,
const MagneticField magField 
) const
private

Get the innermost trajectory states

Construct the TBD trajectory states

Match the old and the new estimates for the trajectory state

Definition at line 209 of file TwoBodyDecayMomConstraintProducer.cc.

References innermostState(), TwoBodyDecayTrajectoryState::isValid(), match(), mps_fire::result, secondaryMass_, and TwoBodyDecayTrajectoryState::trajectoryStates().

Referenced by produce().

212 {
213  std::pair<double, double> result = std::make_pair( -1., -1. );
214 
216  std::pair<bool, TrajectoryStateOnSurface> oldInnermostState1 = innermostState( ttracks[0] );
217  std::pair<bool, TrajectoryStateOnSurface> oldInnermostState2 = innermostState( ttracks[1] );
218  if ( !oldInnermostState1.second.isValid() || !oldInnermostState2.second.isValid() ) return result;
219 
221  TwoBodyDecayTrajectoryState::TsosContainer trackTsos( oldInnermostState1.second, oldInnermostState2.second );
222  TwoBodyDecayTrajectoryState tbdTrajState( trackTsos, tbd, secondaryMass_, magField, true );
223  if ( !tbdTrajState.isValid() ) return result;
224 
226  bool match1 = match( tbdTrajState.trajectoryStates(true).first, oldInnermostState1.second );
227  bool match2 = match( tbdTrajState.trajectoryStates(true).second, oldInnermostState2.second );
228  if ( !match1 || !match2 ) return result;
229 
230  result = std::make_pair( fabs( 1./tbdTrajState.trajectoryStates(true).first.localParameters().qbp() ),
231  fabs( 1./tbdTrajState.trajectoryStates(true).second.localParameters().qbp() ) );
232  return result;
233 }
bool match(const TrajectoryStateOnSurface &newTsos, const TrajectoryStateOnSurface &oldTsos) const
std::pair< bool, TrajectoryStateOnSurface > innermostState(const reco::TransientTrack &ttrack) const
std::pair< TrajectoryStateOnSurface, TrajectoryStateOnSurface > TsosContainer
std::pair< double, double > TwoBodyDecayMomConstraintProducer::momentaAtVertex ( const TwoBodyDecay tbd) const
private

Definition at line 197 of file TwoBodyDecayMomConstraintProducer.cc.

References TwoBodyDecayModel::cartesianSecondaryMomenta(), TwoBodyDecayParameters::mass, and secondaryMass_.

Referenced by produce().

198 {
199  // construct global trajectory parameters at the starting point
201  std::pair< AlgebraicVector, AlgebraicVector > secondaryMomenta = tbdDecayModel.cartesianSecondaryMomenta( tbd );
202 
203  return std::make_pair( secondaryMomenta.first.norm(),
204  secondaryMomenta.second.norm() );
205 }
TwoBodyDecayMomConstraintProducer::MomentumForRefitting TwoBodyDecayMomConstraintProducer::momentumForRefittingFromString ( std::string  momentumForRefittingString)
staticprivate

Definition at line 260 of file TwoBodyDecayMomConstraintProducer.cc.

References atInnermostSurface, atVertex, DEFINE_FWK_MODULE, and Exception.

260  {
261  if ( strMomentumForRefitting == "atVertex" ) {
262  return atVertex;
263  } else if ( strMomentumForRefitting == "atInnermostSurface" ) {
264  return atInnermostSurface;
265  } else {
266  throw cms::Exception("TwoBodyDecayMomConstraintProducer") << "value of config variable 'momentumForRefitting': "
267  << "has to be 'atVertex' or 'atInnermostSurface'";
268  }
269 }
void TwoBodyDecayMomConstraintProducer::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

Definition at line 116 of file TwoBodyDecayMomConstraintProducer.cc.

References atInnermostSurface, atVertex, ecalDrivenElectronSeedsParameters_cff::beamSpot, bsToken_, TwoBodyDecay::chi2(), chi2CutValue_, TwoBodyDecayFitter::estimate(), fixedMomentumError_, edm::EventSetup::get(), edm::Event::getByToken(), edm::Event::getRefBeforePut(), TwoBodyDecay::isValid(), momentaAtInnermostSurface(), momentaAtVertex(), momentumForRefitting_, 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, and trackCollToken_.

117 {
118  using namespace edm;
119 
121  iEvent.getByToken(trackCollToken_, trackColl);
122 
124  iEvent.getByToken(bsToken_, beamSpot);
125 
126  ESHandle<MagneticField> magField;
127  iSetup.get<IdealMagneticFieldRecord>().get( magField );
128 
129  edm::RefProd<std::vector<MomentumConstraint> > rPairs = iEvent.getRefBeforePut<std::vector<MomentumConstraint> >();
130  std::unique_ptr<std::vector<MomentumConstraint> > pairs(new std::vector<MomentumConstraint>);
131  std::unique_ptr<TrackMomConstraintAssociationCollection> output(new TrackMomConstraintAssociationCollection(trackColl, rPairs));
132 
133  if ( trackColl->size() == 2 )
134  {
137 
139  std::vector<reco::TransientTrack> ttracks(2);
140  ttracks[0] = reco::TransientTrack( reco::TrackRef( trackColl, 0 ), magField.product() );
141  ttracks[0].setES( iSetup );
142  ttracks[1] = reco::TransientTrack( reco::TrackRef( trackColl, 1 ), magField.product() );
143  ttracks[1].setES( iSetup );
144 
146  TwoBodyDecay tbd = tbdFitter_.estimate( ttracks, vm );
147 
148  if ( !tbd.isValid() or ( tbd.chi2() > chi2CutValue_ ) ) return;
149 
150  std::pair<double, double> fitMomenta;
151  if ( momentumForRefitting_ == atVertex ) {
152  fitMomenta = momentaAtVertex( tbd );
153  } else if ( momentumForRefitting_ == atInnermostSurface ) {
154  fitMomenta = momentaAtInnermostSurface( tbd, ttracks, magField.product() );
155  } // no other possibility!!!
156 
157  if ( ( fitMomenta.first > 0. ) and ( fitMomenta.second > 0. ) )
158  {
159  // produce constraint for first track
160  MomentumConstraint constraint1( fitMomenta.first, fixedMomentumError_ );
161  pairs->push_back( constraint1 );
162  output->insert(reco::TrackRef(trackColl, 0), edm::Ref<std::vector<MomentumConstraint> >(rPairs, 0));
163 
164  // produce constraint for second track
165  MomentumConstraint constraint2( fitMomenta.second, fixedMomentumError_ );
166  pairs->push_back( constraint2 );
167  output->insert(reco::TrackRef(trackColl, 1), edm::Ref<std::vector<MomentumConstraint> >(rPairs, 1));
168  }
169 
170 // // debug
171 // if ( tbd.isValid() and ( fitMomenta.first > 0. ) and ( fitMomenta.second > 0. ) ) {
172 // TwoBodyDecayModel model;
173 // const std::pair< AlgebraicVector, AlgebraicVector > fitMomenta = model.cartesianSecondaryMomenta( tbd );
174 
175 // TLorentzVector recoMomentum1( ttracks[0].track().px(), ttracks[0].track().py(), ttracks[0].track().pz(),
176 // sqrt((ttracks[0].track().p()*ttracks[0].track().p())+0.105658*0.105658) );
177 // TLorentzVector fitMomentum1( fitMomenta.first[0], fitMomenta.first[1], fitMomenta.first[2],
178 // sqrt( fitMomenta.first.normsq()+0.105658*0.105658) );
179 // histos_["deltaP1"]->Fill( recoMomentum1.P() - fitMomentum1.P() );
180 // histos_["deltaEta1"]->Fill( recoMomentum1.Eta() - fitMomentum1.Eta() );
181 
182 // TLorentzVector recoMomentum2( ttracks[1].track().px(), ttracks[1].track().py(), ttracks[1].track().pz(),
183 // sqrt((ttracks[1].track().p()*ttracks[1].track().p())+0.105658*0.105658) );
184 // TLorentzVector fitMomentum2( fitMomenta.second[0], fitMomenta.second[1], fitMomenta.second[2],
185 // sqrt( fitMomenta.second.normsq()+0.105658*0.105658) );
186 // histos_["deltaP2"]->Fill( recoMomentum2.P() - fitMomentum2.P() );
187 // histos_["deltaEta2"]->Fill( recoMomentum2.Eta() - fitMomentum2.Eta() );
188 // }
189  }
190 
191  iEvent.put(std::move(pairs));
192  iEvent.put(std::move(output));
193 }
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
edm::EDGetTokenT< reco::TrackCollection > trackCollToken_
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
std::pair< double, double > momentaAtVertex(const TwoBodyDecay &tbd) const
RefProd< PROD > getRefBeforePut()
Definition: Event.h:150
void setES(const edm::EventSetup &es)
edm::AssociationMap< edm::OneToOne< reco::TrackCollection, std::vector< MomentumConstraint > > > TrackMomConstraintAssociationCollection
bool isValid(void) const
Definition: TwoBodyDecay.h:46
std::pair< double, double > momentaAtInnermostSurface(const TwoBodyDecay &tbd, const std::vector< reco::TransientTrack > &ttracks, const MagneticField *magField) const
T const * product() const
Definition: Handle.h:74
double chi2(void) const
Definition: TwoBodyDecay.h:44
HLT enums.
T get() const
Definition: EventSetup.h:71
T const * product() const
Definition: ESHandle.h:86
edm::EDGetTokenT< reco::BeamSpot > bsToken_
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

const edm::InputTag TwoBodyDecayMomConstraintProducer::bsSrcTag_
private
edm::EDGetTokenT<reco::BeamSpot> TwoBodyDecayMomConstraintProducer::bsToken_
private
const double TwoBodyDecayMomConstraintProducer::chi2CutValue_
private

Definition at line 71 of file TwoBodyDecayMomConstraintProducer.cc.

Referenced by produce().

const double TwoBodyDecayMomConstraintProducer::fixedMomentumError_
private

Definition at line 72 of file TwoBodyDecayMomConstraintProducer.cc.

Referenced by produce().

const MomentumForRefitting TwoBodyDecayMomConstraintProducer::momentumForRefitting_
private

Definition at line 75 of file TwoBodyDecayMomConstraintProducer.cc.

Referenced by produce().

const double TwoBodyDecayMomConstraintProducer::primaryMass_
private

Definition at line 66 of file TwoBodyDecayMomConstraintProducer.cc.

Referenced by produce().

const double TwoBodyDecayMomConstraintProducer::primaryWidth_
private

Definition at line 67 of file TwoBodyDecayMomConstraintProducer.cc.

Referenced by produce().

const double TwoBodyDecayMomConstraintProducer::secondaryMass_
private
const double TwoBodyDecayMomConstraintProducer::sigmaPositionCutValue_
private

Definition at line 70 of file TwoBodyDecayMomConstraintProducer.cc.

Referenced by match().

const edm::InputTag TwoBodyDecayMomConstraintProducer::srcTag_
private
const TwoBodyDecayFitter TwoBodyDecayMomConstraintProducer::tbdFitter_
private

Definition at line 64 of file TwoBodyDecayMomConstraintProducer.cc.

Referenced by produce().

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